Skip to content

Commit

Permalink
connected range/cruise/
Browse files Browse the repository at this point in the history
  • Loading branch information
FernCarrera committed May 28, 2019
1 parent 0384523 commit 467c22c
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 10 deletions.
5 changes: 3 additions & 2 deletions Model/Propulsion/cruise_comp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
rho = 1.225 #density, [kg/m**3]


class WeightComp(ExplicitComponent):
class CruiseComp(ExplicitComponent):


def setup(self):
Expand All @@ -21,4 +21,5 @@ def setup(self):


def compute(self,inputs,outputs):
outputs['P_C'] = (( (2*(inputs['W']**3)*(inputs['Cd']**2))/(inputs['S']*rho*(inputs['Cl']**3)) )**.5)/1000
W = inputs['W']*9.81
outputs['P_C'] = (( (2*(W**3)*(inputs['Cd']**2))/(inputs['S']*rho*(inputs['Cl']**3)) )**.5)/1000
Binary file modified Model/Weight/__pycache__/gross_weight_comp.cpython-36.pyc
Binary file not shown.
5 changes: 5 additions & 0 deletions Model/Weight/gross_weight_comp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@


class GrossWeightComp(ExplicitComponent):
# Coefficients





def setup(self):
self.add_input('Wp') # weight of payload (passangers)
Expand Down
2 changes: 1 addition & 1 deletion Model/costanalysis/costanalysis/CostBuildup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#function toolCostPerVehicle = costBuildup(rProp,cruiseOutput)
import numpy as np
from .ToolingCost import ToolingCost
from ToolingCost import ToolingCost

def CostBuildup(r_prop,c_ref, b_ref):
# Inputs
Expand Down
2 changes: 1 addition & 1 deletion n2.html
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ <h1>OpenMDAO Partition Tree and N<sup>2</sup> diagram.</h1>
</script>

<script type="text/javascript">
var modelData = {"tree": {"name": "root", "type": "root", "subsystem_type": "group", "linear_solver": "LN: RUNONCE", "nonlinear_solver": "NL: RUNONCE", "children": [{"name": "ivc", "type": "subsystem", "subsystem_type": "component", "linear_solver": "", "nonlinear_solver": "", "children": [{"name": "Wb", "type": "unknown", "implicit": false, "dtype": "ndarray"}, {"name": "Wp", "type": "unknown", "implicit": false, "dtype": "ndarray"}, {"name": "We/W0", "type": "unknown", "implicit": false, "dtype": "ndarray"}, {"name": "m", "type": "unknown", "implicit": false, "dtype": "ndarray"}, {"name": "r", "type": "unknown", "implicit": false, "dtype": "ndarray"}, {"name": "TS", "type": "unknown", "implicit": false, "dtype": "ndarray"}, {"name": "cd0", "type": "unknown", "implicit": false, "dtype": "ndarray"}, {"name": "rho", "type": "unknown", "implicit": false, "dtype": "ndarray"}]}, {"name": "weight", "type": "subsystem", "subsystem_type": "component", "linear_solver": "", "nonlinear_solver": "", "children": [{"name": "Wp", "type": "param", "dtype": "ndarray"}, {"name": "Wb", "type": "param", "dtype": "ndarray"}, {"name": "We/W0", "type": "param", "dtype": "ndarray"}, {"name": "W0", "type": "unknown", "implicit": false, "dtype": "ndarray"}]}, {"name": "FOM", "type": "subsystem", "subsystem_type": "component", "linear_solver": "", "nonlinear_solver": "", "children": [{"name": "W", "type": "param", "dtype": "ndarray"}, {"name": "cd0", "type": "param", "dtype": "ndarray"}, {"name": "rho", "type": "param", "dtype": "ndarray"}, {"name": "TS", "type": "param", "dtype": "ndarray"}, {"name": "r", "type": "param", "dtype": "ndarray"}, {"name": "FM", "type": "unknown", "implicit": false, "dtype": "ndarray"}, {"name": "PH", "type": "unknown", "implicit": false, "dtype": "ndarray"}]}]}, "connections_list": [{"src": "ivc.TS", "tgt": "FOM.TS"}, {"src": "weight.W0", "tgt": "FOM.W"}, {"src": "ivc.cd0", "tgt": "FOM.cd0"}, {"src": "ivc.r", "tgt": "FOM.r"}, {"src": "ivc.rho", "tgt": "FOM.rho"}, {"src": "ivc.Wb", "tgt": "weight.Wb"}, {"src": "ivc.We/W0", "tgt": "weight.We/W0"}, {"src": "ivc.Wp", "tgt": "weight.Wp"}], "abs2prom": {"input": {"weight.Wp": "weight.Wp", "weight.Wb": "weight.Wb", "weight.We/W0": "weight.We/W0", "FOM.W": "FOM.W", "FOM.cd0": "FOM.cd0", "FOM.rho": "FOM.rho", "FOM.TS": "FOM.TS", "FOM.r": "FOM.r"}, "output": {"ivc.Wb": "Wb", "ivc.Wp": "Wp", "ivc.We/W0": "We/W0", "ivc.m": "m", "ivc.r": "r", "ivc.TS": "TS", "ivc.cd0": "cd0", "ivc.rho": "rho", "weight.W0": "weight.W0", "FOM.FM": "FOM.FM", "FOM.PH": "FOM.PH"}}}
var modelData = {"tree": {"name": "root", "type": "root", "subsystem_type": "group", "linear_solver": "LN: RUNONCE", "nonlinear_solver": "NL: RUNONCE", "children": [{"name": "ivc", "type": "subsystem", "subsystem_type": "component", "linear_solver": "", "nonlinear_solver": "", "children": [{"name": "Wb", "type": "unknown", "implicit": false, "dtype": "ndarray"}, {"name": "Wp", "type": "unknown", "implicit": false, "dtype": "ndarray"}, {"name": "We/W0", "type": "unknown", "implicit": false, "dtype": "ndarray"}, {"name": "m", "type": "unknown", "implicit": false, "dtype": "ndarray"}, {"name": "r", "type": "unknown", "implicit": false, "dtype": "ndarray"}, {"name": "TS", "type": "unknown", "implicit": false, "dtype": "ndarray"}, {"name": "cd0", "type": "unknown", "implicit": false, "dtype": "ndarray"}, {"name": "rho", "type": "unknown", "implicit": false, "dtype": "ndarray"}, {"name": "V", "type": "unknown", "implicit": false, "dtype": "ndarray"}, {"name": "Cd", "type": "unknown", "implicit": false, "dtype": "ndarray"}, {"name": "Cl", "type": "unknown", "implicit": false, "dtype": "ndarray"}, {"name": "S", "type": "unknown", "implicit": false, "dtype": "ndarray"}, {"name": "AR", "type": "unknown", "implicit": false, "dtype": "ndarray"}]}, {"name": "weight", "type": "subsystem", "subsystem_type": "component", "linear_solver": "", "nonlinear_solver": "", "children": [{"name": "Wp", "type": "param", "dtype": "ndarray"}, {"name": "Wb", "type": "param", "dtype": "ndarray"}, {"name": "We/W0", "type": "param", "dtype": "ndarray"}, {"name": "W0", "type": "unknown", "implicit": false, "dtype": "ndarray"}]}, {"name": "FOM", "type": "subsystem", "subsystem_type": "component", "linear_solver": "", "nonlinear_solver": "", "children": [{"name": "W", "type": "param", "dtype": "ndarray"}, {"name": "cd0", "type": "param", "dtype": "ndarray"}, {"name": "rho", "type": "param", "dtype": "ndarray"}, {"name": "TS", "type": "param", "dtype": "ndarray"}, {"name": "r", "type": "param", "dtype": "ndarray"}, {"name": "FM", "type": "unknown", "implicit": false, "dtype": "ndarray"}, {"name": "PH", "type": "unknown", "implicit": false, "dtype": "ndarray"}]}, {"name": "range", "type": "subsystem", "subsystem_type": "component", "linear_solver": "", "nonlinear_solver": "", "children": [{"name": "B_W", "type": "param", "dtype": "ndarray"}, {"name": "P_L", "type": "param", "dtype": "ndarray"}, {"name": "P_C", "type": "param", "dtype": "ndarray"}, {"name": "V", "type": "param", "dtype": "ndarray"}, {"name": "R", "type": "unknown", "implicit": false, "dtype": "ndarray"}, {"name": "t", "type": "unknown", "implicit": false, "dtype": "ndarray"}]}, {"name": "cruiseP", "type": "subsystem", "subsystem_type": "component", "linear_solver": "", "nonlinear_solver": "", "children": [{"name": "W", "type": "param", "dtype": "ndarray"}, {"name": "Cd", "type": "param", "dtype": "ndarray"}, {"name": "Cl", "type": "param", "dtype": "ndarray"}, {"name": "AR", "type": "param", "dtype": "ndarray"}, {"name": "S", "type": "param", "dtype": "ndarray"}, {"name": "V", "type": "param", "dtype": "ndarray"}, {"name": "P_C", "type": "unknown", "implicit": false, "dtype": "ndarray"}]}]}, "connections_list": [{"src": "ivc.TS", "tgt": "FOM.TS"}, {"src": "weight.W0", "tgt": "FOM.W"}, {"src": "ivc.cd0", "tgt": "FOM.cd0"}, {"src": "ivc.r", "tgt": "FOM.r"}, {"src": "ivc.rho", "tgt": "FOM.rho"}, {"src": "ivc.AR", "tgt": "cruiseP.AR"}, {"src": "ivc.Cd", "tgt": "cruiseP.Cd"}, {"src": "ivc.Cl", "tgt": "cruiseP.Cl"}, {"src": "ivc.S", "tgt": "cruiseP.S"}, {"src": "ivc.V", "tgt": "cruiseP.V"}, {"src": "weight.W0", "tgt": "cruiseP.W"}, {"src": "ivc.Wb", "tgt": "range.B_W"}, {"src": "cruiseP.P_C", "tgt": "range.P_C"}, {"src": "FOM.PH", "tgt": "range.P_L"}, {"src": "ivc.V", "tgt": "range.V"}, {"src": "ivc.Wb", "tgt": "weight.Wb"}, {"src": "ivc.We/W0", "tgt": "weight.We/W0"}, {"src": "ivc.Wp", "tgt": "weight.Wp"}], "abs2prom": {"input": {"weight.Wp": "weight.Wp", "weight.Wb": "weight.Wb", "weight.We/W0": "weight.We/W0", "FOM.W": "FOM.W", "FOM.cd0": "FOM.cd0", "FOM.rho": "FOM.rho", "FOM.TS": "FOM.TS", "FOM.r": "FOM.r", "range.B_W": "range.B_W", "range.P_L": "range.P_L", "range.P_C": "range.P_C", "range.V": "range.V", "cruiseP.W": "cruiseP.W", "cruiseP.Cd": "cruiseP.Cd", "cruiseP.Cl": "cruiseP.Cl", "cruiseP.AR": "cruiseP.AR", "cruiseP.S": "cruiseP.S", "cruiseP.V": "cruiseP.V"}, "output": {"ivc.Wb": "Wb", "ivc.Wp": "Wp", "ivc.We/W0": "We/W0", "ivc.m": "m", "ivc.r": "r", "ivc.TS": "TS", "ivc.cd0": "cd0", "ivc.rho": "rho", "ivc.V": "V", "ivc.Cd": "Cd", "ivc.Cl": "Cl", "ivc.S": "S", "ivc.AR": "AR", "weight.W0": "weight.W0", "FOM.FM": "FOM.FM", "FOM.PH": "FOM.PH", "range.R": "range.R", "range.t": "range.t", "cruiseP.P_C": "cruiseP.P_C"}}}
</script>

<script type="text/javascript">
Expand Down
45 changes: 39 additions & 6 deletions solver.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
from openmdao.api import Problem, Group, IndepVarComp, ExecComp, ScipyOptimizeDriver
from Model.Propulsion.power_comp import PowerComp
from Model.Propulsion.range_comp import RangeComp
from Model.Propulsion.cruise_comp import CruiseComp
from Model.Weight.gross_weight_comp import GrossWeightComp


prob = Problem(model=Group())

model = prob.model

ivc = model.add_subsystem('ivc',IndepVarComp(),promotes_outputs = ['*'])

ivc.add_output('Wb',val=350.0) #[kg], battery weight
ivc.add_output('Wb',val=627.0) #[kg], battery weight
ivc.add_output('Wp',val=454) #[kg], weight of passangers
ivc.add_output('We/W0') # empty to gross fraction

Expand All @@ -18,39 +21,67 @@
ivc.add_output('cd0',val=0.0197)
ivc.add_output('rho',val=1.225)

ivc.add_output('V',val=180)
ivc.add_output('Cd',val=0.0255)
ivc.add_output('Cl',val=0.32)
ivc.add_output('S',val=13.2)
ivc.add_output('AR',val=7)


model.add_subsystem('weight',GrossWeightComp())
model.add_subsystem('FOM',PowerComp())
model.add_subsystem('range',RangeComp())
model.add_subsystem('cruiseP',CruiseComp()) # cruise power

# conencting to weights group
# conencting to weights comp
model.connect('Wb','weight.Wb')
model.connect('Wp','weight.Wp')
model.connect('We/W0','weight.We/W0')

# connecting to Props group
# connecting to Props comp
model.connect('weight.W0','FOM.W')
model.connect('cd0','FOM.cd0')
model.connect('rho','FOM.rho')
model.connect('TS','FOM.TS')
model.connect('r','FOM.r')

# connecting to cruise power comp
model.connect('weight.W0','cruiseP.W')
model.connect('Cd','cruiseP.Cd')
model.connect('Cl','cruiseP.Cl')
model.connect('AR','cruiseP.AR')
model.connect('S','cruiseP.S')
model.connect('V','cruiseP.V')

# connecting to range comp
model.connect('Wb','range.B_W')
model.connect('FOM.PH','range.P_L')
model.connect('cruiseP.P_C','range.P_C')
model.connect('V','range.V')


prob.driver = ScipyOptimizeDriver()
prob.driver.options['optimizer'] = 'SLSQP'
prob.driver.options['tol'] = 1e-5
prob.driver.options['tol'] = 1e-7
prob.driver.options['disp'] = True

model.add_design_var('r',lower=0.5,upper=1.5)
model.add_design_var('We/W0',lower=0.30,upper=0.70) # 30% - 70%, from lecture
model.add_constraint('weight.W0',lower = 1500,upper=2500)
model.add_constraint('FOM.FM',equals=0.80)
model.add_constraint('weight.W0',lower = 1700,upper=2500)
model.add_constraint('FOM.FM',equals=0.8)
model.add_objective('FOM.PH')

prob.setup()

# Initial Guesses
prob['We/W0'] = 0.60
prob['r'] = 1.5
# guesses from CDR
prob['AR'] = 7
prob['S'] = 13.2
prob['V'] = 230
prob['Cd'] = 0.03
prob['Cl'] = 0.32


#prob.run_model()
Expand All @@ -61,4 +92,6 @@
print('Figure of Merit:',prob['FOM.FM'])
print('Required Radius:',prob['FOM.r'],'[m]')
print('Required Power for Hover:',prob['FOM.PH'],'[kW]')
print('Required Power for Cruise:',prob['cruiseP.P_C'],'[kW]')
print('Range Not Using Reserve and battHealth :',prob['range.R'],'[km]')

0 comments on commit 467c22c

Please sign in to comment.