Source code for hyperloop.cycle.compression_system

from openmdao.main.api import Assembly, Component
from openmdao.lib.drivers.api import DOEdriver
from openmdao.lib.doegenerators.api import FullFactorial
from openmdao.lib.casehandlers.api import DumpCaseRecorder
from openmdao.lib.datatypes.api import Float

from pycycle.api import (FlowStartStatic, SplitterW, Inlet, Compressor, Duct,
    Nozzle, CycleComponent, HeatExchanger, FlowStation)


[docs]class Performance(CycleComponent): C1_pwr = Float(0, iotype='in', units='hp') C2_pwr = Float(0, iotype='in', units='hp') Fg = Float(0, iotype='in', units='lbf') F_ram = Float(0, iotype='in', units='lbf') Ps_bearing_target = Float(iotype="in", units="psi") Ps_bearing = Float(iotype="in", units="psi") pwr = Float(0, iotype='out', units='hp') F_net = Float(0, iotype='out', units='lbf') Ps_bearing_residual = Float(iotype="out", desc="residual related to the proper value for bearing air static pressure", units="psi")
[docs] def execute(self): self.pwr = self.C1_pwr + self.C2_pwr self.F_net = self.Fg - self.F_ram self.Ps_bearing_residual = .001*(self.Ps_bearing - self.Ps_bearing_target)
[docs]class CompressionSystem(Assembly): #I/O Variables accessible on the boundary of the assembly #NOTE: Some unit conversions to metric also happen here Mach_pod_max = Float(1.0, iotype="in", desc="Maximum travel Mach of the pod") W_in = Float(.69, iotype="in", desc="mass flow rate into the compression system", units="kg/s") W_bearing_in = Float(.2, iotype="in", desc="required mass flow rate for the bearing system", units="kg/s") Ps_tube = Float(99, iotype="in", desc="static pressure in the tube", units="Pa") Ts_tube = Float(292.1, iotype="in", desc="static temperature in the tube", units="degK") Mach_c1_in = Float(.6, iotype="in", desc="Mach number at entrance to the first compressor at design conditions") c1_PR_des = Float(12.47, iotype="in", desc="pressure ratio of first compressor at design conditions") Ps_bearing = Float(11000, iotype="in", desc="Static pressure of the bearing air", units="Pa") nozzle_Fl_O = FlowStation(iotype="out", desc="flow exiting the nozzle", copy=None) bearing_Fl_O = FlowStation(iotype="out", desc="flow exiting the bearings", copy=None) rho_air = Float(iotype="out", desc="Density (needed for aero calcs in another component)") speed_max = Float(iotype="out", desc="maximum velocity of the pod", units="m/s") area_c1_in = Float(iotype="out", desc="flow area required for the input to the first compressor", units="cm**2") area_c1_out = Float(iotype="out", desc="flow area required for the output to the first compressor", units="cm**2") area_inlet_in = Float(iotype="out", desc="flow area required for the first compressor", units="cm**2") nozzle_flow_area = Float(iotype="out", desc="flow area required for the nozzle exit", units="cm**2") pwr_req = Float(iotype="out", desc="pwr required to drivr the compression system", units="kW") F_net = Float(iotype="out", desc="Thrust generated by the nozzle", units="N") #state variables c2_PR_des = Float(5, iotype="in", desc="pressure ratio of second compressor at design conditions") #residuals Ps_bearing_residual = Float(iotype="out", desc="residual related to the proper value for bearing air static pressure", units="Pa")
[docs] def configure(self): #Add Compressor Cycle Components tube = self.add('tube', FlowStartStatic()) #tube.W = 1.521 tube.Ps = 0.01436 tube.Ts = 525.6 inlet = self.add('inlet', Inlet()) inlet.ram_recovery = 1.0 #inlet.MNexit_des = .6 comp1 = self.add('comp1', Compressor()) comp1.PR_des = 12.47 comp1.MNexit_des = .4 comp1.eff_des = .80 duct1 = self.add('duct1', Duct()) duct1.Q_dot = 0# no heat exchangers duct1.dPqP = .1 #no losses split = self.add('split', SplitterW()) split.W1_des = .44 split.MNexit1_des = 1.0 split.MNexit2_des = 1.0 nozzle = self.add('nozzle', Nozzle()) nozzle.dPqP = 0 #no losses comp2 = self.add('comp2', Compressor()) comp2.PR_des = 5.0 comp2.MNexit_des = .4 comp2.eff_des = .80 duct2 = self.add('duct2', Duct()) #to bearings duct2.Q_dot = 0 #no heat exchangers duct2.dPqP = .1 #no losses perf = self.add('perf', Performance()) #Inter Component Connections self.connect('tube.Fl_O', 'inlet.Fl_I') self.connect('inlet.Fl_O','comp1.Fl_I') self.connect('comp1.Fl_O', 'duct1.Fl_I') self.connect('duct1.Fl_O', 'split.Fl_I') self.connect('split.Fl_O2', 'nozzle.Fl_I') self.connect('tube.Fl_O', 'nozzle.Fl_ref') self.connect('split.Fl_O1', 'comp2.Fl_I') self.connect('comp2.Fl_O','duct2.Fl_I') self.connect('comp1.pwr','perf.C1_pwr') self.connect('comp2.pwr','perf.C2_pwr') self.connect('duct2.Fl_O.Ps', 'perf.Ps_bearing') self.connect('nozzle.Fg', 'perf.Fg') self.connect('inlet.F_ram', 'perf.F_ram') #Input variable pass_throughs to the assembly boundary #Compress -> Tube self.connect('W_in', 'tube.W') self.connect('Ts_tube','tube.Ts') self.connect('Ps_tube', 'tube.Ps') self.connect('Mach_pod_max', 'tube.Mach') #Compress -> Inlet self.connect('Mach_c1_in', 'inlet.MNexit_des') #Compress -> C1 self.connect('c1_PR_des','comp1.PR_des') #Compress -> C2 self.connect('c2_PR_des','comp2.PR_des') #Compress -> Splitter self.connect('W_bearing_in', 'split.W1_des') #Compress -> Perf self.connect('Ps_bearing', 'perf.Ps_bearing_target') #Output variable pass_throughs to the assembly boundary self.connect('tube.Fl_O.rhot', 'rho_air') #promoted for aero calc self.connect('tube.Fl_O.area', 'area_inlet_in') self.connect('tube.Fl_O.Vflow', 'speed_max') self.connect('inlet.Fl_O.area', 'area_c1_in') self.connect('comp1.Fl_O.area', 'area_c1_out') self.connect('nozzle.Fl_O.area', 'nozzle_flow_area') self.connect('nozzle.Fl_O', 'nozzle_Fl_O') self.connect('duct2.Fl_O', 'bearing_Fl_O') self.connect('perf.F_net','F_net') self.connect('perf.pwr', 'pwr_req') self.connect('perf.Ps_bearing_residual', 'Ps_bearing_residual') #driver setup design = self.driver comp_list = ['tube','inlet','comp1', 'duct1', 'split', 'nozzle', 'comp2', 'duct2', 'perf'] design.workflow.add(comp_list) for comp_name in comp_list: #need to put everything in design mode design.add_event('%s.design'%comp_name)
if __name__ == "__main__": from math import pi from openmdao.main.api import set_as_top hlc = set_as_top(CompressionSystem()) hlc.Mach_pod_max = 1 hlc.run() print "pwr: ", hlc.comp1.pwr+hlc.comp2.pwr,hlc.comp1.pwr,hlc.comp2.pwr print "tube area:", hlc.tube.Fl_O.area print "tube Ps", hlc.tube.Fl_O.Ps, hlc.tube.Fl_O.Pt print "tube Rhos", hlc.tube.Fl_O.rhos print "tube W", hlc.tube.W print "inlet W", hlc.inlet.Fl_I.W print "tube rad: ", (hlc.tube.Fl_O.area/pi)**.5 print "tube V: ", hlc.tube.Fl_O.Vflow, hlc.tube.Fl_O.Mach fs = hlc.tube.Fl_O