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

Autotag #17

Merged
merged 5 commits into from
Jul 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ platform:

environment:
matrix:
- PYTHON: 2.7
- PYTHON: 3.6

init:
Expand Down
5 changes: 2 additions & 3 deletions examples/B738.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ def setup(self):

# airplanes which consume fuel will need to integrate
# fuel usage across the mission and subtract it from TOW
nn_simpson = int((nn - 1) / 2)
self.add_subsystem('intfuel', Integrator(num_intervals=nn_simpson, method='simpson',
self.add_subsystem('intfuel', Integrator(num_nodes=nn, method='simpson',
quantity_units='kg', diff_units='s',
time_setup='duration'),
promotes_inputs=[('dqdt', 'fuel_flow'), 'duration',
Expand All @@ -97,7 +96,7 @@ def setup(self):
nn = 11

# Define a bunch of design varaiables and airplane-specific parameters
dv_comp = self.add_subsystem('dv_comp', DictIndepVarComp(acdata, seperator='|'),
dv_comp = self.add_subsystem('dv_comp', DictIndepVarComp(acdata),
promotes_outputs=["*"])
dv_comp.add_output_from_dict('ac|aero|CLmax_TO')
dv_comp.add_output_from_dict('ac|aero|polar|e')
Expand Down
5 changes: 2 additions & 3 deletions examples/Caravan.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ def setup(self):

# airplanes which consume fuel will need to integrate
# fuel usage across the mission and subtract it from TOW
nn_simpson = int((nn - 1) / 2)
self.add_subsystem('intfuel', Integrator(num_intervals=nn_simpson, method='simpson',
self.add_subsystem('intfuel', Integrator(num_nodes=nn, method='simpson',
quantity_units='kg', diff_units='s',
time_setup='duration'),
promotes_inputs=[('dqdt', 'fuel_flow'), 'duration',
Expand All @@ -89,7 +88,7 @@ def setup(self):
nn = 11

# Define a bunch of design varaiables and airplane-specific parameters
dv_comp = self.add_subsystem('dv_comp', DictIndepVarComp(acdata, seperator='|'),
dv_comp = self.add_subsystem('dv_comp', DictIndepVarComp(acdata),
promotes_outputs=["*"])
dv_comp.add_output_from_dict('ac|aero|CLmax_TO')
dv_comp.add_output_from_dict('ac|aero|polar|e')
Expand Down
2 changes: 1 addition & 1 deletion examples/ElectricSinglewithThermal.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class ElectricTBMAnalysisGroup(Group):
def setup(self):
nn = 11

dv_comp = self.add_subsystem('dv_comp',DictIndepVarComp(acdata,seperator='|'),promotes_outputs=["*"])
dv_comp = self.add_subsystem('dv_comp',DictIndepVarComp(acdata),promotes_outputs=["*"])
#eventually replace the following aerodynamic parameters with an analysis module (maybe OpenAeroStruct)
dv_comp.add_output_from_dict('ac|aero|CLmax_TO')
dv_comp.add_output_from_dict('ac|aero|polar|e')
Expand Down
5 changes: 2 additions & 3 deletions examples/HybridTwin.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ def setup(self):
self.connect('propmodel.eng1.component_weight', 'W_engine')
self.connect('propmodel.gen1.component_weight', 'W_generator')
self.connect('propmodel.motors_weight', 'W_motors')
nn_simpson = int((nn - 1) / 2)
self.add_subsystem('intfuel', Integrator(num_intervals=nn_simpson, method='simpson',
self.add_subsystem('intfuel', Integrator(num_nodes=nn, method='simpson',
quantity_units='kg', diff_units='s',
time_setup='duration'),
promotes_inputs=[('dqdt', 'fuel_flow'), 'duration',
Expand All @@ -110,7 +109,7 @@ def setup(self):
nn = 11

# Define a bunch of design varaiables and airplane-specific parameters
dv_comp = self.add_subsystem('dv_comp', DictIndepVarComp(acdata, seperator='|'),
dv_comp = self.add_subsystem('dv_comp', DictIndepVarComp(acdata),
promotes_outputs=["*"])
dv_comp.add_output_from_dict('ac|aero|CLmax_TO')
dv_comp.add_output_from_dict('ac|aero|polar|e')
Expand Down
5 changes: 2 additions & 3 deletions examples/HybridTwin_thermal.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ def setup(self):
self.connect('propmodel.hx.frontal_area','hxadder.hx_frontal_area')
self.connect('propmodel.area_nozzle','hxadder.nozzle_area')

nn_simpson = int((nn - 1) / 2)
self.add_subsystem('intfuel', Integrator(num_intervals=nn_simpson, method='simpson',
self.add_subsystem('intfuel', Integrator(num_nodes=nn, method='simpson',
quantity_units='kg', diff_units='s',
time_setup='duration'),
promotes_inputs=[('dqdt', 'fuel_flow'), 'duration',
Expand All @@ -122,7 +121,7 @@ def setup(self):
nn = 11

# Define a bunch of design varaiables and airplane-specific parameters
dv_comp = self.add_subsystem('dv_comp', DictIndepVarComp(acdata, seperator='|'),
dv_comp = self.add_subsystem('dv_comp', DictIndepVarComp(acdata),
promotes_outputs=["*"])
dv_comp.add_output_from_dict('ac|aero|CLmax_TO')
dv_comp.add_output_from_dict('ac|aero|polar|e')
Expand Down
7 changes: 3 additions & 4 deletions examples/KingAirC90GT.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ def setup(self):
self.connect('propmodel.engines_weight', 'W_engine')

# airplanes which consume fuel will need to integrate
# fuel usage across the mission and subtract it from TOW
nn_simpson = int((nn - 1) / 2)
self.add_subsystem('intfuel', Integrator(num_intervals=nn_simpson, method='simpson',
# fuel usage across the mission and subtract it from TOW
self.add_subsystem('intfuel', Integrator(num_nodes=nn, method='simpson',
quantity_units='kg', diff_units='s',
time_setup='duration'),
promotes_inputs=[('dqdt', 'fuel_flow'), 'duration',
Expand All @@ -90,7 +89,7 @@ def setup(self):
nn = 11

# Define a bunch of design varaiables and airplane-specific parameters
dv_comp = self.add_subsystem('dv_comp', DictIndepVarComp(acdata, seperator='|'),
dv_comp = self.add_subsystem('dv_comp', DictIndepVarComp(acdata),
promotes_outputs=["*"])
dv_comp.add_output_from_dict('ac|aero|CLmax_TO')
dv_comp.add_output_from_dict('ac|aero|polar|e')
Expand Down
5 changes: 2 additions & 3 deletions examples/TBM850.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ def setup(self):

# airplanes which consume fuel will need to integrate
# fuel usage across the mission and subtract it from TOW
nn_simpson = int((nn - 1) / 2)
self.add_subsystem('intfuel', Integrator(num_intervals=nn_simpson, method='simpson',
self.add_subsystem('intfuel', Integrator(num_nodes=nn, method='simpson',
quantity_units='kg', diff_units='s',
time_setup='duration'),
promotes_inputs=[('dqdt', 'fuel_flow'), 'duration',
Expand All @@ -89,7 +88,7 @@ def setup(self):
nn = 11

# Define a bunch of design varaiables and airplane-specific parameters
dv_comp = self.add_subsystem('dv_comp', DictIndepVarComp(acdata, seperator='|'),
dv_comp = self.add_subsystem('dv_comp', DictIndepVarComp(acdata),
promotes_outputs=["*"])
dv_comp.add_output_from_dict('ac|aero|CLmax_TO')
dv_comp.add_output_from_dict('ac|aero|polar|e')
Expand Down
44 changes: 22 additions & 22 deletions openconcept/analysis/atmospherics/tests/test_atmospherics.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import division
import unittest
import numpy as np
from openmdao.utils.assert_utils import assert_rel_error, assert_check_partials
from openmdao.utils.assert_utils import assert_near_equal, assert_check_partials
from openmdao.api import IndepVarComp, Group, Problem
from openconcept.analysis.atmospherics.compute_atmos_props import ComputeAtmosphericProperties

Expand All @@ -27,22 +27,22 @@ def setUp(self):

def test_sea_level_and_30kft(self):
#check conditions at sea level
assert_rel_error(self, self.prob['fltcond|rho'][0],1.225,tolerance=1e-4)
assert_rel_error(self, self.prob['fltcond|p'][0],101325,tolerance=1e-3)
assert_rel_error(self, self.prob['fltcond|T'][0],288.15,tolerance=1e-3)
assert_rel_error(self, self.prob['fltcond|Utrue'][0],61.7333,tolerance=1e-3)
assert_rel_error(self, self.prob['fltcond|q'][0],2334.2398,tolerance=1e-3)
assert_rel_error(self, self.prob['fltcond|M'][0],0.1814,tolerance=1e-3)
assert_rel_error(self, self.prob['fltcond|a'][0],340.294,tolerance=1e-3)
assert_near_equal(self.prob['fltcond|rho'][0],1.225,tolerance=1e-4)
assert_near_equal(self.prob['fltcond|p'][0],101325,tolerance=1e-3)
assert_near_equal(self.prob['fltcond|T'][0],288.15,tolerance=1e-3)
assert_near_equal(self.prob['fltcond|Utrue'][0],61.7333,tolerance=1e-3)
assert_near_equal(self.prob['fltcond|q'][0],2334.2398,tolerance=1e-3)
assert_near_equal(self.prob['fltcond|M'][0],0.1814,tolerance=1e-3)
assert_near_equal(self.prob['fltcond|a'][0],340.294,tolerance=1e-3)

#check conditions at 30kft (1976 standard atmosphere verified at https://www.digitaldutch.com/atmoscalc/)
assert_rel_error(self, self.prob['fltcond|rho'][-1],0.458312,tolerance=1e-4)
assert_rel_error(self, self.prob['fltcond|p'][-1],30089.6,tolerance=1e-3)
assert_rel_error(self, self.prob['fltcond|T'][-1],228.714,tolerance=1e-3)
assert_rel_error(self, self.prob['fltcond|Utrue'][-1],61.7333*np.sqrt(1.225/0.458312),tolerance=1e-3)
assert_rel_error(self, self.prob['fltcond|q'][-1],2334.2398,tolerance=1e-3)
assert_rel_error(self, self.prob['fltcond|M'][-1],0.3326,tolerance=1e-3)
assert_rel_error(self, self.prob['fltcond|a'][-1],303.2301,tolerance=1e-3)
assert_near_equal(self.prob['fltcond|rho'][-1],0.458312,tolerance=1e-4)
assert_near_equal(self.prob['fltcond|p'][-1],30089.6,tolerance=1e-3)
assert_near_equal(self.prob['fltcond|T'][-1],228.714,tolerance=1e-3)
assert_near_equal(self.prob['fltcond|Utrue'][-1],61.7333*np.sqrt(1.225/0.458312),tolerance=1e-3)
assert_near_equal(self.prob['fltcond|q'][-1],2334.2398,tolerance=1e-3)
assert_near_equal(self.prob['fltcond|M'][-1],0.3326,tolerance=1e-3)
assert_near_equal(self.prob['fltcond|a'][-1],303.2301,tolerance=1e-3)

def test_partials(self):
partials = self.prob.check_partials(method='cs', out_stream=None)
Expand All @@ -55,13 +55,13 @@ def setUp(self):
self.prob.run_model()

def test_sea_level(self):
assert_rel_error(self, self.prob['fltcond|rho'][0],1.225,tolerance=1e-4)
assert_rel_error(self, self.prob['fltcond|p'][0],101325,tolerance=1e-3)
assert_rel_error(self, self.prob['fltcond|T'][0],288.15,tolerance=1e-3)
assert_rel_error(self, self.prob['fltcond|Utrue'][0],61.7333,tolerance=1e-3)
assert_rel_error(self, self.prob['fltcond|q'][0],2334.2398,tolerance=1e-3)
assert_rel_error(self, self.prob['fltcond|M'][0],0.1814,tolerance=1e-3)
assert_rel_error(self, self.prob['fltcond|a'][0],340.294,tolerance=1e-3)
assert_near_equal(self.prob['fltcond|rho'][0],1.225,tolerance=1e-4)
assert_near_equal(self.prob['fltcond|p'][0],101325,tolerance=1e-3)
assert_near_equal(self.prob['fltcond|T'][0],288.15,tolerance=1e-3)
assert_near_equal(self.prob['fltcond|Utrue'][0],61.7333,tolerance=1e-3)
assert_near_equal(self.prob['fltcond|q'][0],2334.2398,tolerance=1e-3)
assert_near_equal(self.prob['fltcond|M'][0],0.1814,tolerance=1e-3)
assert_near_equal(self.prob['fltcond|a'][0],340.294,tolerance=1e-3)

def test_partials(self):
partials = self.prob.check_partials(method='cs', out_stream=None)
Expand Down
26 changes: 13 additions & 13 deletions openconcept/analysis/performance/solver_phases.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,13 +546,13 @@ def setup(self):


self.add_subsystem('haccel',HorizontalAcceleration(num_nodes=nn), promotes_inputs=['*'],promotes_outputs=['*'])
nn_simpson = int((nn-1)/2)

if flight_phase == 'v1v0':
#unfortunately need to shoot backwards to avoid negative airspeeds
#reverse the order of the accelerations so the last one is first (and make them negative)
self.add_subsystem('flipaccel', FlipVectorComp(num_nodes=nn, units='m/s**2', negative=True), promotes_inputs=[('vec_in','accel_horiz')])
#integrate the timesteps in reverse from near zero speed.
self.add_subsystem('intvelocity',Integrator(num_intervals=nn_simpson, method='simpson', quantity_units='m/s', diff_units='s',time_setup='duration', lower=1.5),
self.add_subsystem('intvelocity',Integrator(num_nodes=nn, method='simpson', quantity_units='m/s', diff_units='s',time_setup='duration', lower=1.5),
promotes_inputs=['duration',('q_initial','zero_speed')],promotes_outputs=[('q_final','fltcond|Utrue_initial')])
self.connect('flipaccel.vec_out','intvelocity.dqdt')
#flip the result of the reverse integration again so the flight condition is forward and consistent with everythign else
Expand All @@ -563,7 +563,7 @@ def setup(self):
promotes_inputs=['*'],promotes_outputs=['duration'])
else:
# forward shooting for these acceleration segmentes
self.add_subsystem('intvelocity',Integrator(num_intervals=nn_simpson, method='simpson', quantity_units='m/s', diff_units='s', time_setup='duration', lower=1.5),
self.add_subsystem('intvelocity',Integrator(num_nodes=nn, method='simpson', quantity_units='m/s', diff_units='s', time_setup='duration', lower=1.5),
promotes_inputs=[('dqdt','accel_horiz'),'duration',('q_initial','fltcond|Utrue_initial')],promotes_outputs=[('q','fltcond|Utrue'),('q_final','fltcond|Utrue_final')])
if flight_phase == 'v0v1':
self.connect('zero_speed','fltcond|Utrue_initial')
Expand All @@ -574,10 +574,10 @@ def setup(self):
promotes_inputs=['*'],promotes_outputs=['duration'])

if zero_start:
self.add_subsystem('intrange',Integrator(num_intervals=nn_simpson, method='simpson', quantity_units='m', diff_units='s',zero_start=zero_start, time_setup='duration'),
self.add_subsystem('intrange',Integrator(num_nodes=nn, method='simpson', quantity_units='m', diff_units='s',zero_start=zero_start, time_setup='duration'),
promotes_inputs=[('dqdt','fltcond|groundspeed'),'duration'],promotes_outputs=[('q','range'),('q_final','range_final')])
else:
self.add_subsystem('intrange',Integrator(num_intervals=nn_simpson, method='simpson', quantity_units='m', diff_units='s',zero_start=zero_start, time_setup='duration'),
self.add_subsystem('intrange',Integrator(num_nodes=nn, method='simpson', quantity_units='m', diff_units='s',zero_start=zero_start, time_setup='duration'),
promotes_inputs=[('dqdt','fltcond|groundspeed'),'duration',('q_initial','range_initial')],promotes_outputs=[('q','range'),('q_final','range_final')])

class RotationPhase(Group):
Expand Down Expand Up @@ -673,17 +673,17 @@ def setup(self):
self.add_subsystem('lift',Lift(num_nodes=nn), promotes_inputs=['*'],promotes_outputs=['*'])
self.add_subsystem('haccel',HorizontalAcceleration(num_nodes=nn), promotes_inputs=['*'],promotes_outputs=['*'])
self.add_subsystem('vaccel',VerticalAcceleration(num_nodes=nn), promotes_inputs=['*'],promotes_outputs=['*'])
nn_simpson = int((nn-1)/2)

# TODO always starts from zero altitude
self.add_subsystem('clear_obstacle',BalanceComp(name='duration',units='s',val=1,eq_units='m',rhs_name='fltcond|h_final',lhs_name='h_obs',lower=0.1,upper=15),
promotes_inputs=['*'],promotes_outputs=['duration'])
self.add_subsystem('intvelocity',Integrator(num_intervals=nn_simpson, method='simpson', quantity_units='m/s', diff_units='s',time_setup='duration',lower=0.1),
self.add_subsystem('intvelocity',Integrator(num_nodes=nn, method='simpson', quantity_units='m/s', diff_units='s',time_setup='duration',lower=0.1),
promotes_inputs=[('dqdt','accel_horiz'),'duration',('q_initial','fltcond|Utrue_initial')],promotes_outputs=[('q','fltcond|Utrue'),('q_final','fltcond|Utrue_final')])
self.add_subsystem('intrange',Integrator(num_intervals=nn_simpson, method='simpson', quantity_units='m', diff_units='s', time_setup='duration'),
self.add_subsystem('intrange',Integrator(num_nodes=nn, method='simpson', quantity_units='m', diff_units='s', time_setup='duration'),
promotes_inputs=[('dqdt','fltcond|groundspeed'),'duration',('q_initial','range_initial')],promotes_outputs=[('q','range'),('q_final','range_final')])
self.add_subsystem('intvs',Integrator(num_intervals=nn_simpson, method='simpson', quantity_units='m/s', diff_units='s', time_setup='duration',zero_start=True),
self.add_subsystem('intvs',Integrator(num_nodes=nn, method='simpson', quantity_units='m/s', diff_units='s', time_setup='duration',zero_start=True),
promotes_inputs=[('dqdt','accel_vert'),'duration'],promotes_outputs=[('q','fltcond|vs'),('q_final','fltcond|vs_final')])
self.add_subsystem('inth',Integrator(num_intervals=nn_simpson, method='simpson', quantity_units='m', diff_units='s', time_setup='duration',zero_start=True),
self.add_subsystem('inth',Integrator(num_nodes=nn, method='simpson', quantity_units='m', diff_units='s', time_setup='duration',zero_start=True),
promotes_inputs=[('dqdt','fltcond|vs'),'duration'],promotes_outputs=[('q','fltcond|h'),('q_final','fltcond|h_final')])

class SteadyFlightPhase(Group):
Expand Down Expand Up @@ -762,8 +762,8 @@ def setup(self):
ivcomp.add_output('fltcond|Ueas',val=np.ones((nn,))*90, units='m/s')
ivcomp.add_output('fltcond|vs',val=np.ones((nn,))*1, units='m/s')
ivcomp.add_output('zero_accel',val=np.zeros((nn,)),units='m/s**2')
nn_simpson = int((nn-1)/2)
self.add_subsystem('inth',Integrator(num_intervals=nn_simpson, method='simpson', quantity_units='m', diff_units='s', time_setup='duration'),

self.add_subsystem('inth',Integrator(num_nodes=nn, method='simpson', quantity_units='m', diff_units='s', time_setup='duration'),
promotes_inputs=[('dqdt','fltcond|vs'),'duration',('q_initial','fltcond|h_initial')],promotes_outputs=[('q','fltcond|h'),('q_final','fltcond|h_final')])
self.add_subsystem('atmos', ComputeAtmosphericProperties(num_nodes=nn, true_airspeed_in=False), promotes_inputs=['*'], promotes_outputs=['*'])
self.add_subsystem('gs',Groundspeeds(num_nodes=nn),promotes_inputs=['*'],promotes_outputs=['*'])
Expand All @@ -773,7 +773,7 @@ def setup(self):
self.add_subsystem('lift',Lift(num_nodes=nn), promotes_inputs=['*'],promotes_outputs=['*'])
self.add_subsystem('haccel',HorizontalAcceleration(num_nodes=nn), promotes_inputs=['*'],promotes_outputs=['*'])

self.add_subsystem('intrange',Integrator(num_intervals=nn_simpson, method='simpson', quantity_units='m', diff_units='s', time_setup='duration'),
self.add_subsystem('intrange',Integrator(num_nodes=nn, method='simpson', quantity_units='m', diff_units='s', time_setup='duration'),
promotes_inputs=[('dqdt','fltcond|groundspeed'),'duration',('q_initial','range_initial')],promotes_outputs=[('q','range'),('q_final','range_final')])


Expand Down
Loading