-
Notifications
You must be signed in to change notification settings - Fork 401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Constraint analysis scripts for initial sizing #398
base: develop
Are you sure you want to change the base?
Conversation
A deep methods update and a regression script
Updated the propeller aircraft constraint analysis regression
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The two big overall comments:
Split things out into methods and make consistent with SUAVE vehicle data structures.
Overall good work. I think this is a good contribution.
trunk/SUAVE/Analyses/Constraint_Analysis/Constraint_Analysis.py
Outdated
Show resolved
Hide resolved
trunk/SUAVE/Analyses/Constraint_Analysis/Constraint_Analysis.py
Outdated
Show resolved
Hide resolved
trunk/SUAVE/Analyses/Constraint_Analysis/Constraint_Analysis.py
Outdated
Show resolved
Hide resolved
return e | ||
|
||
|
||
def estimate_max_lift(self,highlift_type): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could be useful for many other calculations. Can you make this more general and move to methods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that SUAVE already has the maximum lift estimation function. Is it better to have this function as a stand-alone or to integrate it into the SUAVE default maximum lift function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're able to integrate it, that would be great. You can make a setting that will switch between types.
raise ValueError(highliftmsg) | ||
|
||
|
||
def compressibility_drag(self,mach,cl): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
call the existing scripts since this is much the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, I am struggling with the fundamental difference between functions of SUAVE and requirements for the constraint diagram. All default functions require definitions of settings, states, etc, since thez are created for the mission segment analysis. Here, I just need 2-3 inputs for the execution with minimum input, so the constraint diagram can be initialized and executed as simple as possible. For the latest update, I still have not managed to integrate these functions into the default SUAVE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand you're trying to do a simple analysis here. I'm not trying to change that. I bet you think this is frustrating because you coded this with a certain intention of this being simple.
For this function, you can easily replace it with the original. Settings are not used, hence they become None. Geometry only requires wing that has a thickness to chord and sweep. State is just a dictionary that saves the outputs and provides a CL. It's not tricky to use the existing script.
We've found that having reproduced code eventually leads to bugs and just bloat. It's more confusing and it all becomes a mess eventually.
If you haven't seen already, there's an issue with versions of a Python package unrelated to SUAVE. This is giving the red X. When the issue is fixed, I'll rebuild and we can finish off the pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just adding a few new comments.
ca.geometry.high_lift_type_clean = None | ||
ca.geometry.high_lift_type_takeoff = 'double-slotted Fowler' | ||
ca.geometry.high_lift_type_landing = 'double-slotted Fowler' | ||
ca.geometry.aspect_ratio = vehicle.wings['main_wing'].aspect_ratio |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was hoping it would look something like this:
ca.geometry = B737_vehicle()
That way a user doesn't need to do all of this manually.
I think a really neat workflow for a new user who would be interested in your contributions here could be to draw a vehicle in OpenVSP and very quickly produce the constraint diagram. That would enable this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am actually working on the neat integration now, so the constraint diagram script will accept the entire vehicle with some pre-defined constraint diagram settings. I can also do it the way you suggested. Hope, I will commit the deep update by the end of next week
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Do what you think makes most sense here.
I'm looking forward to this. I think your work here fills an important need in SUAVE.
from SUAVE.Methods.Constraint_Analysis.compute_cruise_constraint import compute_cruise_constraint | ||
from SUAVE.Methods.Constraint_Analysis.compute_ceiling_constraint import compute_ceiling_constraint | ||
from SUAVE.Methods.Constraint_Analysis.compute_landing_constraint import compute_landing_constraint | ||
from SUAVE.Input_Output.Results.plot_constraint_diagram import plot_constraint_diagram |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
f.close() | ||
|
||
|
||
# ---------------------------------------------------------------------- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete this lower bit. This is our fault for leaving this in our style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
1. Moved the geometry and energy network definition into the Vehicle (where was possible) 2. Defined the constraint analysis variable set within the vehicle 3. Allocated analyses scripts within the Aero folder 4. Allocated the post-processing code into the Input/Output folder 5. Fixed many parts to make the structure work
Emilio, I think, I have changed almost all parts where needed and embedded the constraint analyses definitions into the vehicle, so, as you described, the designer can start from minimum data and then build the vehicle step-by-step. |
@@ -0,0 +1,103 @@ | |||
## @ingroup Input_Output-Results |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be moved to this folder: https://github.com/suavecode/SUAVE/tree/develop/trunk/SUAVE/Plots/Performance
f.close() | ||
|
||
|
||
# ---------------------------------------------------------------------- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
""" | ||
|
||
# Unpack inputs | ||
taper = vehicle.wings['main_wing'].taper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer if this parsed for the main wing rather than look for a name. The code is simple:
from SUAVE.Components.Wings.Main_Wing
main_wing = None
for wing in wings:
if isinstance(wing,main_wing):
main_wing = wing
@@ -0,0 +1,78 @@ | |||
## @ingroup Methods-Constraint_Analysis | |||
# Oswald_efficiency.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This header is wrong
import numpy as np | ||
|
||
# ------------------------------------------------------------------------------------ | ||
# Compute maximum lift coefficient for the constraint analysis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This title is wrong
T_W[i] = Vy/Vx + q/W_S[i]*cd0 + k/q*W_S[i] | ||
P_W[i] = T_W[i]*Vx/etap | ||
|
||
if eng_type == ('turboprop' or 'Turboprop'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check for instances
eng_type = vehicle.constraints.engine.type | ||
cd_min = vehicle.constraints.aerodynamics.cd_min_clean | ||
W_S = vehicle.constraints.wing_loading | ||
AR = vehicle.wings['main_wing'].aspect_ratio |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parse
if etap == 0: | ||
raise ValueError('Warning: Set the propeller efficiency during turn') | ||
|
||
for i in range(len(W_S)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 things I see.
First, this section of code is used repeatedly in several scripts. This indicates this could be functionalized.
Second, I believe you could vectorize this for loop.
trunk/SUAVE/Vehicle.py
Outdated
self.plot_tag = False | ||
|
||
|
||
# Defines default constraint analyses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vehicle.analyses breaks a fundamental assumption of SUAVE having data/analysis orthogonality
trunk/SUAVE/Vehicle.py
Outdated
self.propeller.OEI_climb_efficiency = 0.0 | ||
|
||
# Define aerodynamics | ||
self.aerodynamics = Data() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is basically an analysis
Updated the data constraint analysis structure Fixed all errors, relocated useful files Added a dummy turboprop energy network (similar to ICE, but with a different power lapse function)
@planes Have updated the analyses, used existing scripts as much as possible, and corrected many small things in the code |
@@ -0,0 +1,228 @@ | |||
# ICE_Test.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update header
# | ||
# Created: Jan 2022, S. Karpuk | ||
|
||
""" setup file for a mission with a Beech 99 with a turboprop energy network |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C172
sys.path.append('../Vehicles') | ||
# the analysis functions | ||
|
||
#from Beech_99 import vehicle_setup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove commented out code
# Fuel | ||
# ------------------------------------------------------------------ | ||
# define fuel weight needed to size fuel system | ||
fuel = SUAVE.Attributes.Propellants.Aviation_Gasoline() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not avgas
# Sample jet airplane | ||
# ------------------------------------------------------------------ | ||
|
||
# Define the vehicle and required constrain analysis parameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constraint
ca.propeller.ceiling_efficiency = 0.85 | ||
ca.propeller.OEI_climb_efficiency = 0.5 | ||
|
||
# Define aerodynamics (an example case with max lift calculation for differnet flap settions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
different flap settings
# Network | ||
# ---------------------------------------------------------------------- | ||
## @ingroup Components-Energy-Networks | ||
class Turboprop_Constant_Speed(Network): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should inherit from this network: https://github.com/suavecode/SUAVE/blob/develop/trunk/SUAVE/Components/Energy/Networks/Internal_Combustion_Propeller_Constant_Speed.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@planes I see. Indeed this script is identical to the ICE. The only difference is inside the turboprop converter (https://github.com/stankarpuktubs/SUAVE/blob/develop/trunk/SUAVE/Components/Energy/Converters/Turboprop.py) where I am using the power lapse formulation for a turboprop. Shall I then modify the ICE network to work with the turboprop converter to avoid unnecessary copies of the code?
# Network | ||
# ---------------------------------------------------------------------- | ||
## @ingroup Components-Energy-Networks | ||
class Turboprop(Network): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should inherit from here: https://github.com/suavecode/SUAVE/blob/develop/trunk/SUAVE/Components/Energy/Networks/Internal_Combustion_Propeller.py
isinstance(prop, Nets.Internal_Combustion_Propeller_Constant_Speed) or isinstance(prop, Nets.Turboprop): | ||
|
||
P_W = np.zeros(len(W_S)) | ||
etap = ca.propeller.cruise_efficiency |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ceiling efficiency
|
||
for i in range(len(W_S)): | ||
error = 1 | ||
tollerance = 1e-6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tolerance is spelled wrong
Merged a sample turboprop and an ICE into one energy network. modified the constraint analysis script to include changes of the energy network
Pull Request Checklist