Skip to content

Commit

Permalink
Attached GrossWeightComp to Model
Browse files Browse the repository at this point in the history
  • Loading branch information
FernCarrera committed May 24, 2019
1 parent 710ab23 commit 02311b2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
Binary file modified Model/Propulsion/__pycache__/power_comp.cpython-36.pyc
Binary file not shown.
4 changes: 2 additions & 2 deletions Model/Propulsion/power_comp.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ def setup(self):
self.add_output('PH',val=0.0,desc='Power for Hover')

# self.declare_partials('y', 'x')
self.declare_partials(of='*', wrt='*', method='fd')
self.declare_partials(of='*', wrt='*', method='cs')
# self.set_check_partial_options('x', method='cs')

def compute(self, inputs, outputs):
W = inputs['W']
W = inputs['W']*9.81 # convert to [N]
r = inputs['r']
rho = inputs['rho']
tip_speed = inputs['TS']
Expand Down
31 changes: 23 additions & 8 deletions solver.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
from openmdao.api import Problem, Group, IndepVarComp, ExecComp, ScipyOptimizeDriver
from Model.Propulsion.power_comp import PowerComp
from Model.Propulsion.weight_comp import WeightComp
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('Wp',val=454) #[kg], weight of passangers
ivc.add_output('We/W0') # empty to gross fraction

ivc.add_output('m',val=0.0)
ivc.add_output('r',val=0.0)
ivc.add_output('TS',val=170)
ivc.add_output('cd0',val=0.0197)
ivc.add_output('rho',val=1.225)


model.add_subsystem('weight',WeightComp())
model.add_subsystem('weight',GrossWeightComp())
model.add_subsystem('FOM',PowerComp())

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

model.connect('m','weight.m')

model.connect('weight.W','FOM.W')
# connecting to Props group
model.connect('weight.W0','FOM.W')
model.connect('cd0','FOM.cd0')
model.connect('rho','FOM.rho')
model.connect('TS','FOM.TS')
Expand All @@ -30,21 +38,28 @@

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

model.add_design_var('r',lower=0.5,upper=1.5)
model.add_constraint('FOM.FM',equals=0.85)
model.add_design_var('We/W0',lower=0.50,upper=0.80)
model.add_constraint('weight.W0',lower = 2000,upper=2500)
model.add_constraint('FOM.FM',equals=0.80)
model.add_objective('FOM.PH')

prob.setup()

prob['m'] = 2500
# Initial Guesses
prob['We/W0'] = 0.60
prob['r'] = 1.5


#prob.run_model()
prob.set_solver_print(level=0)
prob.run_driver()
print('Gross Weight Fraction:',prob['We/W0'])
print('Gross Weight:',prob['weight.W0'],'[kg]')
print('Figure of Merit:',prob['FOM.FM'])
print('Required Radius:',prob['FOM.r'])
print('Required Radius:',prob['FOM.r'],'[m]')
print('Required Power for Hover:',prob['FOM.PH'],'[kW]')

0 comments on commit 02311b2

Please sign in to comment.