From d9094b22e56be8d73e6dec367dbb11366e107922 Mon Sep 17 00:00:00 2001 From: Fern Carrera Date: Tue, 21 May 2019 20:12:20 -0700 Subject: [PATCH] initial commit --- .../__pycache__/power_comp.cpython-36.pyc | Bin 0 -> 1331 bytes .../__pycache__/weight_comp.cpython-36.pyc | Bin 0 -> 719 bytes Model/Propulsion/liftoff_comp.py | 56 + Model/Propulsion/n2.html | 4194 +++++++++++++++++ Model/Propulsion/power_comp.py | 48 + Model/Propulsion/weight_comp.py | 14 + Model/__pycache__/__init__.cpython-36.pyc | Bin 0 -> 150 bytes setup.py | 18 + solver.py | 47 + 9 files changed, 4377 insertions(+) create mode 100644 Model/Propulsion/__pycache__/power_comp.cpython-36.pyc create mode 100644 Model/Propulsion/__pycache__/weight_comp.cpython-36.pyc create mode 100644 Model/Propulsion/liftoff_comp.py create mode 100644 Model/Propulsion/n2.html create mode 100644 Model/Propulsion/power_comp.py create mode 100644 Model/Propulsion/weight_comp.py create mode 100644 Model/__pycache__/__init__.cpython-36.pyc create mode 100644 setup.py create mode 100644 solver.py diff --git a/Model/Propulsion/__pycache__/power_comp.cpython-36.pyc b/Model/Propulsion/__pycache__/power_comp.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a154cae79b33f9840a4a2c99232c96701b5fbe93 GIT binary patch literal 1331 zcmZV-J&zkjbY|CU@9z2QI75Phzy*ydPKi(&IN^g!jv#TTLzgI$WofnAH}-9`_AIlr z39;6qNGK@s1E4?@G)NSb(D4WO15+VEV^JVcAVkG`W9M>#H=6e~Z{EkeH*dCD;Wyv^ zHvXf=*stsYpv?Ah7kxy)fM;yRN1U_w893lRX5b3`$Q?OQJ7oiJg;s39&GyYt@+?hK zeIRGKoQt_m=;SFl$n4`TUO^<-hyz0p9Gu5&rq=i{6j870`s-Ta~P3Zct9z=%bc%I9snLLRzZ-gP&%Qr~y2W#W<*LI*dE zrS1NA$W$Eo%WUZ)b&%GOx=1~wHKcW<9?}NXs~R+RSdT6J%3TIkP&tXk-+U9~F*+Iy^O zA?@s~=cae8D0xMNs|F#TP#w|qwa{T2O>>BPdH!xa_28IoUyD;oY4-I;#* z1;LL)6{4h?&#e9)PJe#;)5%v~|25p)`)Rnb{(NYgJm{zw(caYUd=#d!9**Kaxs3vi z4K8vaz-DMT4()B@BpP>)Bl&?1yH0?H$2wP+$aRAnU21U|1^dq#_n$7e$!omFFXQTQ z-|_ik`}~*hZtfiqJmW{vJf4XtGGP?WB$OHP%_#b~jI;HLBLC|3^VrX4q3G@Cy$eFV p=Xb2;7{5nT=3+jBSnkGos_4b-(Yk`?y%>LQ9sC`7{DN$o?!U#+KO6u6 literal 0 HcmV?d00001 diff --git a/Model/Propulsion/__pycache__/weight_comp.cpython-36.pyc b/Model/Propulsion/__pycache__/weight_comp.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..75c1876dc5fab10fef319d37c7ddecbf841aaff4 GIT binary patch literal 719 zcmZWnL2J}N6rRZ>yJ_4ND?KO(3Z8OVDAJ1**_u{QE-j@LmcS4)(>0Q0#+d}Q?5*wJ z=-s0?f6H9;BK`wUzBf@^@WFfYOcWreF8-gL2J^` zC8gvw5rJUWL@-IO*fJ2|DM_Or@D@p_+dlfJ>#D4}Of_1yvh7Oj{EYy>9MV35BFT~p z0t{3H*JQ~A6Ctdjh=6hAl5<(D-g=@E)cL>_IWkE50Lq%Y18rBJ3lQ)i5(K_y3r8DA z&(pwd6+-Z;)qUp@gsSfVgV@l@`r0$on;3(hS+k2VoO7m6K@viTbsfzml2ggR~zP6QW^AFwzFJT}v{mDgEcD){>0h}?R z3BA1c&+5##ONK27Trs`j9RO=8=tH=I9kPaN*dNS>3xiy%$2UJuzTQ5an+SH^R?18a z*p0k@>&An5>zhMKus=q5eJ7`|u{dEuFYj-t`qN&dk&8KRi$-$p63!bX`Wo?s^Y?vG z4;^y{2+Un9INObahZ!`4di?-m7LWXsMatYnY1uZSP_sf;26gz>27%}ElH>j1@E7<~ Ic+C^`8>msK!2kdN literal 0 HcmV?d00001 diff --git a/Model/Propulsion/liftoff_comp.py b/Model/Propulsion/liftoff_comp.py new file mode 100644 index 0000000..f74cda7 --- /dev/null +++ b/Model/Propulsion/liftoff_comp.py @@ -0,0 +1,56 @@ +from openmdao.api import IndepVarComp, Group, Problem, ExecComp, ScipyOptimizeDriver +import numpy as np +# should get like .81 +prob = Problem() +prob.model = model = Group() + +model.add_subsystem('Radius', IndepVarComp('r', 1)) # radius +model.add_subsystem('T_S', IndepVarComp('tip_speed', 170)) #SOS @ SL * Mach. Mach = 0.5 for noise +model.add_subsystem('Weight', IndepVarComp('W', 24525)) #[N] +model.add_subsystem('Zero_L', IndepVarComp('cd0', 0.0197)) +model.add_subsystem('density', IndepVarComp('rho', 1.225)) # density @ Sl + + +model.add_subsystem('Thrust', ExecComp('T = W/8')) # thrust req per propeller +model.add_subsystem('Disk_Area', ExecComp('S = 3.14*(r**2)')) +model.add_subsystem('T_C', ExecComp('ct = T/( rho *S* (tip_speed**2) )')) +model.add_subsystem('P_C', ExecComp('cp = ( 1.15*( (ct**(3/2)) /(2**.5) ) + (1/8)*0.1*cd0 )')) # power coefficient +model.add_subsystem('P_I', ExecComp('PI = T * ((T/(2*S*rho))**.5)')) +model.add_subsystem('P_H', ExecComp('PH = cp*rho*S*(tip_speed**3)')) +model.add_subsystem('F_merit', ExecComp('FM = PI/PH')) + +model.connect('Zero_L.cd0', 'P_C.cd0') # con cd0 to pc +model.connect('Weight.W', 'Thrust.W') # connecting weight to thrust calc +model.connect('Radius.r', 'Disk_Area.r') # connecting radius to disk calc +model.connect('Thrust.T', ['T_C.T','P_I.T' ]) # connecting the thrust to eqs that need it +model.connect('Disk_Area.S', ['T_C.S','P_I.S','P_H.S' ]) # connecting area to things +model.connect('T_S.tip_speed', ['T_C.tip_speed','P_H.tip_speed' ]) # connecting tip speed +model.connect('density.rho', ['T_C.rho','P_I.rho','P_H.rho' ]) # con rho +model.connect('T_C.ct', 'P_C.ct') # ct to P_C +model.connect('P_C.cp', 'P_H.cp') +model.connect('P_I.PI','F_merit.PI') +model.connect('P_H.PH','F_merit.PH') + +# Optimization Stuff +prob.driver = ScipyOptimizeDriver() +prob.driver.options['optimizer'] = 'SLSQP' +prob.driver.options['tol'] = 1e-9 +prob.driver.options['disp'] = True + +model.add_design_var('Radius.r', lower=0.70, upper=1) +model.add_objective('density.rho',scaler=-1) # random obj to force it to run +model.add_constraint('F_merit.FM',equals=0.85) +#add constraint for minimum power??????? + + +prob.setup() +print('Running Optimizer') +prob.set_solver_print(level=0) +prob.run_driver() + +print('Figure of Merit') +print(prob['F_merit.FM']) +print('Radius [m]') +print(prob['Radius.r']) +print('Power Required for liftoff [kW]') +print(8*prob['P_H.PH']/1000) \ No newline at end of file diff --git a/Model/Propulsion/n2.html b/Model/Propulsion/n2.html new file mode 100644 index 0000000..1974862 --- /dev/null +++ b/Model/Propulsion/n2.html @@ -0,0 +1,4194 @@ + + + + + + + + + + + + + + +
+
+

OpenMDAO Partition Tree and N2 diagram.

+
+
+ + +
+
+
+ + + + +
+
+ + + + + +
+
+ + + + + + + + +
+
+ +
+
+ +
+
+
+
+ + + +
+ + +
+
+
+
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Model/Propulsion/power_comp.py b/Model/Propulsion/power_comp.py new file mode 100644 index 0000000..9c1b984 --- /dev/null +++ b/Model/Propulsion/power_comp.py @@ -0,0 +1,48 @@ +from openmdao.api import ExplicitComponent + + +class PowerComp(ExplicitComponent): + + + + + def setup(self): + self.add_input('W',desc='Weight') # weight + self.add_input('cd0',desc='zero lift coeff') # zero lift coeff + self.add_input('rho',desc='density at SL') + self.add_input('TS') # tip speed + self.add_input('r') + + + self.add_output('FM',val=0.0,desc='Figure of Merit') + self.add_output('PH',val=0.0,desc='Power for Hover') + + # self.declare_partials('y', 'x') + self.declare_partials(of='*', wrt='*', method='fd') + # self.set_check_partial_options('x', method='cs') + + def compute(self, inputs, outputs): + W = inputs['W'] + r = inputs['r'] + rho = inputs['rho'] + tip_speed = inputs['TS'] + cd0 = inputs['cd0'] + + + S = 3.14*(r**2) + T = W # thrust required + ct = T/( rho *S* (tip_speed**2) ) + cp = ( 1.15*( (ct**(3/2)) /(2**.5) ) + (1/8)*0.1*cd0 ) + PI = T * ((T/(2*S*rho))**.5) + PH = cp*rho*S*(tip_speed**3) + FM = PI/PH + + outputs['FM'] = FM + outputs['PH'] = PH + + + + + + # def compute_partials(self, inputs, partials): + # partials['y', 'x'] = 2. \ No newline at end of file diff --git a/Model/Propulsion/weight_comp.py b/Model/Propulsion/weight_comp.py new file mode 100644 index 0000000..009fc90 --- /dev/null +++ b/Model/Propulsion/weight_comp.py @@ -0,0 +1,14 @@ +from openmdao.api import ExplicitComponent + +#def initialize(self): +class WeightComp(ExplicitComponent): + + + def setup(self): + self.add_input('m') + self.add_output('W') + + #self.declare_partials('*','*') + + def compute(self,inputs,outputs): + outputs['W'] = inputs['m']*9.81 \ No newline at end of file diff --git a/Model/__pycache__/__init__.cpython-36.pyc b/Model/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7a06b4276b68ef8a74df37647c45ad51df5ffd7a GIT binary patch literal 150 zcmXr!<>gwZayy0r2p)q77+?f49Dul(1xTbY1T$zd`mJOr0tq9CU(WiW#i>Qb`dJy} ziFxVzE~&-YCHV#V1(^l$>6s<*C8Z_#MVW~?m;&+fnR!43@p=W7w>WHa^HWN5Qtd#7 I7XvW^0E7f53IG5A literal 0 HcmV?d00001 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..993cfd0 --- /dev/null +++ b/setup.py @@ -0,0 +1,18 @@ +from distutils.core import setup + +setup( +<<<<<<< HEAD + name='pip_git_tutorial', + version='0.1', + description="Tutorial", + packages=[ + 'pip_git_tutorial', +======= + name='Model', + version='0.1', + description=":(", + packages=[ + 'Model', +>>>>>>> init commit + ], +) \ No newline at end of file diff --git a/solver.py b/solver.py new file mode 100644 index 0000000..d8ed430 --- /dev/null +++ b/solver.py @@ -0,0 +1,47 @@ +from openmdao.api import Problem, Group, IndepVarComp, ExecComp, ScipyOptimizeDriver +from pip_git_tutorial.Propulsion.power_comp import PowerComp +from pip_git_tutorial.Propulsion.weight_comp import WeightComp + +prob = Problem(model=Group()) + +model = prob.model + +ivc = model.add_subsystem('ivc',IndepVarComp(),promotes_outputs = ['*']) +#ivc.add_output('PH',val=0.0) +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('Fig',PowerComp()) + + +model.connect('m','weight.m') + +model.connect('weight.W','Fig.W') +model.connect('cd0','Fig.cd0') +model.connect('rho','Fig.rho') +model.connect('TS','Fig.TS') +model.connect('r','Fig.r') + + +prob.driver = ScipyOptimizeDriver() + +model.add_design_var('r', lower=0.5, upper=1) +model.add_constraint('Fig.FM',equals=0.85) +model.add_objective('rho',scaler=-1) + +prob.setup() + +prob['m'] = 2500 +prob['r'] = 0.9 + + +#prob.run_model() +prob.run_driver() +print(prob['Fig.FM']) +print(prob['Fig.r']) +#print(prob['PH']) \ No newline at end of file