Skip to content
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

Open
wants to merge 31 commits into
base: develop
Choose a base branch
from

Conversation

stankarpuktubs
Copy link
Contributor

Pull Request Checklist

  • Merge in the latest Develop branch changes to your branch
  • Remove .pyc files from your repository:
    • Linux/Mac
      • find . -name *.pyc -delete
    • Windows
      • del /S *.pyc
  • Run automatic regression and makes sure everything is passing
  • Did you make a new regression test that covers your new code?
  • Did you update your docstrings?
  • Did you update your headers to include your name and date?
  • Do a final compare with the Develop branch to be sure what you're changing

@coveralls
Copy link

coveralls commented Dec 27, 2020

Coverage Status

Coverage increased (+0.01%) to 89.998% when pulling 693adfe on stankarpuktubs:develop into 4f83c46 on suavecode:develop.

Copy link
Member

@planes planes left a 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.

Tutorials-master/tut_payload_range.py Outdated Show resolved Hide resolved
Tutorials-master/tut_solar_uav.py Outdated Show resolved Hide resolved
regression/automatic_regression.py Outdated Show resolved Hide resolved
return e


def estimate_max_lift(self,highlift_type):
Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Member

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):
Copy link
Member

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

Copy link
Contributor Author

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

Copy link
Member

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.

@planes
Copy link
Member

planes commented Nov 18, 2021

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.

Copy link
Member

@planes planes left a 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
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

f.close()


# ----------------------------------------------------------------------
Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This

stankarpuktubs and others added 6 commits January 2, 2022 14:48
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
@stankarpuktubs
Copy link
Contributor Author

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f.close()


# ----------------------------------------------------------------------
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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'):
Copy link
Member

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
Copy link
Member

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)):
Copy link
Member

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.

self.plot_tag = False


# Defines default constraint analyses
Copy link
Member

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

self.propeller.OEI_climb_efficiency = 0.0

# Define aerodynamics
self.aerodynamics = Data()
Copy link
Member

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)
@stankarpuktubs
Copy link
Contributor Author

stankarpuktubs commented Jan 15, 2022

@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
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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()
Copy link
Member

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
Copy link
Member

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)
Copy link
Member

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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@stankarpuktubs stankarpuktubs Feb 14, 2022

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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tolerance is spelled wrong

stankarpuktubs and others added 4 commits February 24, 2022 23:50
Merged a sample turboprop and an ICE into one energy network.
modified the constraint analysis script to include changes of the energy network
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants