Skip to content

Commit

Permalink
updated Model
Browse files Browse the repository at this point in the history
  • Loading branch information
FernCarrera committed May 31, 2019
1 parent 0512737 commit 2676b20
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 277 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
81 changes: 0 additions & 81 deletions Model/costanalysis(2)/costanalysis/cost_buildup.py

This file was deleted.

62 changes: 0 additions & 62 deletions Model/costanalysis(2)/costanalysis/tooling_cost.py

This file was deleted.

121 changes: 0 additions & 121 deletions Model/costanalysis(2)/operating_cost.py

This file was deleted.

2 changes: 1 addition & 1 deletion Model/costanalysis/OperatingCost.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def setup(self):
self.add_input('shaft_power',desc = 'shaft power')
self.add_input('mass_struct',desc = 'structural mass')
self.add_input('mass_batt',desc = 'battery mass')
self.add_input('mass_motor',desc = 'motor mass')
#self.add_input('mass_motor',desc = 'motor mass')
self.add_input('b_ref',desc = 'span')
self.add_input('power_to_weight',desc = 'power to weight ratio')

Expand Down
24 changes: 21 additions & 3 deletions solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from Model.Weight.gross_weight_comp import GrossWeightComp
from Model.Weight.thrust_weight_comp import ThrustWeightComp
from Model.Weight.weight_buildup_comp import EmptyWeightComp
from Model.costanalysis1.operating_cost import OperatingCost


prob = Problem(model=Group())
Expand All @@ -16,6 +17,7 @@
ivc.add_output('Wb',val=600) #[kg], battery weight
ivc.add_output('Wp',val=454) #[kg], weight of passangers
#ivc.add_output('We_W0') # empty to gross fraction
ivc.add_output('Wm',val=50)

ivc.add_output('m')
ivc.add_output('r')
Expand All @@ -42,7 +44,7 @@
model.add_subsystem('range',RangeComp())
model.add_subsystem('cruiseP',CruiseComp()) # cruise power
model.add_subsystem('emptyW',EmptyWeightComp())
#model.add_subsystem('T_W',ThrustWeightComp())
model.add_subsystem('cost',OperatingCost())

# conencting to gross_weights comp
model.connect('Wb','weight.Wb')
Expand Down Expand Up @@ -91,6 +93,20 @@
model.connect('cruiseP.P_C','range.P_C')
model.connect('V','range.V')

# connecting to cost analysis
model.connect('r','cost.r_prop')
model.connect('V','cost.cruise_speed')
model.connect('range.R','cost.avg_dist')
model.connect('weight.We_W0','cost.We/W0')
model.connect('weight.W0','cost.W0')
model.connect('Wb','cost.mass_batt')
model.connect('Wm','cost.mass_motor')
model.connect('Neg','cost.Neg')
model.connect('S','cost.S')
model.connect('AR','cost.AR')
model.connect('FOM.PH','cost.shaft_power')
model.connect('cruiseP.P_C','cost.P_C')


prob.driver = ScipyOptimizeDriver()
prob.driver.options['optimizer'] = 'SLSQP'
Expand All @@ -108,10 +124,11 @@
model.add_constraint('range.R',equals=340)
model.add_constraint('weight.Wb_W0',lower=0.25,upper=0.30) # batt to gross
#model.add_constraint('FOM.PH',upper=550)
model.add_constraint('cruiseP.P_C',upper=100)
model.add_constraint('cruiseP.P_C',upper=80)
#model.add_constraint('cruiseP.cl',upper=0.4)
model.add_objective('cost.Cost',scaler=-1)

model.add_objective('FOM.PH',scaler=-1)
#model.add_objective('FOM.PH',scaler=-1)

prob.setup()

Expand Down Expand Up @@ -141,6 +158,7 @@
print('Required Power for Hover:',prob['FOM.PH'],'[kW]')
print('Required Power for Cruise:',prob['cruiseP.P_C'],'[kW]')
print('Max Trip Range @',prob['V'],'[m/s]:',prob['range.R'],'[km]','Time',prob['range.t'],'[hr]')
print('Cost per trip (2025?): $',prob['cost.Cost']*1.146)
print('cl',prob['cruiseP.cl'])
print('cd',prob['cruiseP.cd'])
print('cd0',prob['cruiseP.cd0'])
Expand Down
18 changes: 9 additions & 9 deletions solver_withcost.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from openmdao.api import Problem, Group, IndepVarComp, ExecComp, ScipyOptimizeDriver, pyOptSparseDriver
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
# from Model.Weight.thrust_weight_comp import ThrustWeightComp
from Model.costanalysis(2).operating_cost import OperatingCost
from Model.costanalysis1.operating_cost import OperatingCost


prob = Problem(model=Group())
Expand Down Expand Up @@ -95,13 +95,13 @@


# Setup optimization algorithm
prob.driver = pyOptSparseDriver()
prob.driver.options['optimizer'] = "SLSQP"
prob.driver.hist_file = 'hist.hst'
# prob.driver = ScipyOptimizeDriver()
# prob.driver.options['optimizer'] = 'SLSQP'
# prob.driver.options['tol'] = 1e-9
# prob.driver.options['disp'] = True
#prob.driver = pyOptSparseDriver()
#prob.driver.options['optimizer'] = "SLSQP"
#prob.driver.hist_file = 'hist.hst'
prob.driver = ScipyOptimizeDriver()
prob.driver.options['optimizer'] = 'SLSQP'
prob.driver.options['tol'] = 1e-9
prob.driver.options['disp'] = True

model.add_design_var('r',lower=0.5,upper=1.5)
model.add_design_var('We/W0',lower=0.40,upper=0.70) # 30% - 70%, from lecture
Expand Down

0 comments on commit 2676b20

Please sign in to comment.