Engine_GasGas.py

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# Applied Python PRISM
# (PRISM) PaRametrIc System Model
#
# Written by Charlie Taylor <cet@appliedpython.com> 
# Oct,21 2005

from prism.MassItem import MassItem
from prism.isp.cea import CEA_Isp
from math import *
from prism.utils import Constants
from prism.Summary import Summary
from prism.props import Materials
from prism.isp import Nozzle_Eff
from prism.utils import mensuration
from prism.engines import ValveSolenoid
#from prism.props.refprop7.n23_fluid import n_fluid
from prism.props.refprop7.n_dll_fluid import n_fluid

from prism.pov import POV_Items, POV_Basics

class Engine_GasGas( MassItem ):
    
    def __init__(self, name="engine",  mass_lbm=0.0, oxName='O2', fuelName='CH4',
        cxw=1.25, Pc=150.0, Fvac=100.0, eps=50.0, mr=2.5, CR=2.5, LoverDt=4.0, LchamMin=1.5,
        etaERE=0.97, etaNoz=0.99, 
        matlInj="SS", cxwInj=1.0, cxwValves=1.0, 
        matlCham="Cb103(2250F)", cxwCham=1.0, 
        isBell=1, pcentBell=80.0, WtIgnAssy=6.0,
        halfAngDeg=15.0, useFastCEALookup=0, Number=1, etaKinInp=1.0,
        calcEtaNoz=1, thkChamMin=0.2, thkNozMin=0.02, matlNoz="Cb103", minBipropValveWt=0.2):
        
        MassItem.__init__(self, name, type="inert")
        
        self.Number = Number # number of engines
        self.oxName = oxName
        self.fuelName = fuelName
        self.iprop = oxName + '/' + fuelName
        self.Fvac = Fvac
        self.Pc = Pc
        self.eps = eps
        self.mr = mr
        self.CR = CR
        self.LoverDt = LoverDt
        self.LchamMin = LchamMin
        self.cxw = cxw
        self.cxwValves = cxwValves
        self.minBipropValveWt = minBipropValveWt
        self.etaERE = etaERE
        self.etaKinInp = etaKinInp
        
        self.WtIgnAssy = WtIgnAssy
        
        self.isBell = isBell
        self.pcentBell = pcentBell
        self.halfAngDeg = halfAngDeg
        self.etaNoz = etaNoz
        self.calcEtaNoz = calcEtaNoz
        
        self.matlInj = matlInj
        self.thkNozMin = thkNozMin
        self.thkChamMin = thkChamMin
        self.cxwInj = cxwInj
        self.rhoInj, self.syInj, self.eInj, tmingInj = Materials.getMatlProps(matlInj)
        
        self.matlCham = matlCham
        self.cxwCham = cxwCham
        self.rhoCham, self.syCham, self.eCham, tmingCham = Materials.getMatlProps(matlCham)

        
        self.matlNoz = matlNoz
        self.rhoNoz, self.syNoz, self.eNoz, self.tmingNoz = Materials.getMatlProps(matlNoz)
        
        # make gas property objects
        self.FlObj  = n_fluid(fuelName)
        self.OxObj  = n_fluid(oxName)
        
        # assume identical ox and fuel valves
        self.Valves = ValveSolenoid.ValveSolenoid( name='biprop valves', 
            Number=2, cxw=cxwValves, isGas=1 )
        
        
        self.ispObj = CEA_Isp.CEA_Isp( oxName=oxName+'(G)', fuelName=fuelName+'(G)', useFastLookup=useFastCEALookup ) # create isp calculating object
        self.reCalc()
        
    def getPOV_Item(self):
        # be sure to include pov_h, pov_w, and pov_d calcs in reCalc
        if hasattr( self, 'texture'):
            texture = self.texture
        else:
            
            texture = POV_Basics.Texture( colorName="Coral" )
        
        s = POV_Items.TCA_Bell( xlc=self.Lcham*2./3. , xln=self.Lcham/3., CR=self.CR, 
            Rt=self.Dt/2., eps=self.eps,  pcentBell=self.pcentBell,  texture=texture)
        
        return s
        
    def reCalc(self, autoCalc=1):
        self.autoCalc = autoCalc
        # set design variables
        
        self.IspODE,self.CstarODE,self.Tc = \
            self.ispObj.get_IvacCstrTc(Pc=self.Pc, MR=self.mr, eps=self.eps)
            
        if self.calcEtaNoz:
            if self.isBell:
                isConical=0
            else:
                isConical=1
            self.etaBL,self.etaDiv,self.etaKin, etaCf = \
                Nozzle_Eff.calcNozzleEfficiency(Pc=self.Pc, Fvac=self.Fvac, eps=self.eps, 
                epsAtt=self.eps, isConical=isConical, pcentBell=self.pcentBell, halfAngleDeg=self.halfAngDeg,
                iprop=self.iprop, mr=self.mr, etaKinInp=self.etaKinInp,
                adjBL=1.0, adjKin=1.0, adjDiv=1.0, isRegenCham=0, isRegenNoz=0 )
                
            self.etaNoz = etaCf
        
        self.effIsp = self.etaERE * self.etaNoz
        self.Isp = self.IspODE * self.effIsp
        self.Cstar = self.CstarODE * self.etaERE
        
        self.wdotTot = self.Fvac / self.Isp
        self.wdotOx  = self.wdotTot * self.mr / (1.0 + self.mr)
        self.wdotFl = self.wdotTot - self.wdotOx 
        
        self.OxObj.setTP( 530.0, self.Pc )
        self.FlObj.setTP( 530.0, self.Pc )
        
        self.volDotOx = self.wdotOx / self.OxObj.rho
        self.volDotFl = self.wdotFl / self.FlObj.rho
        
        self.Valves.cuInchPerSec = max( self.volDotOx, self.volDotFl )
        self.Valves.reCalc()
        self.WtValves = self.Valves.mass_lbm
        
        ftPerSec = 30.0 # through valve
        dCharFl = sqrt( 4.0 * self.volDotFl/ pi / ftPerSec) 
        dCharOx = sqrt( 4.0 * self.volDotOx / pi / ftPerSec)
        self.dChar = max( dCharFl, dCharOx)
        
        # weight of two identical valves
        #self.WtValves = 2.0 * 0.268 * (self.dChar/1.279)**2
        #if self.WtValves < self.minBipropValveWt: # minimum of 45 (0.2 lbm) grams per valve (90 total)
        #    self.WtValves = self.minBipropValveWt
        #self.WtValves *= self.cxwValves
            
        self.WtMisc = 0.319 * (self.dChar/1.279)**2  # scale miscellaneous like valve
        if self.WtMisc < 0.1:
            self.WtMisc = 0.1
        
        self.At = self.Cstar* self.wdotTot / self.Pc / Constants.gc
        self.Dt = sqrt( self.At / pi ) * 2.0
        self.Dcham = self.Dt * sqrt( self.CR )
        self.Lcham = self.Dt * self.LoverDt
        if self.Lcham < self.LchamMin:
            self.Lcham = self.LchamMin
        self.Dexit = self.Dt * sqrt( self.eps )
        
        if self.isBell:
            self.Lnoz = (sqrt(self.eps)-1.0)*self.pcentBell*(self.Dt/2.0)/100.0/tan(15.0*pi/180.0)
            # curve fit of ratio to minimum length rao nozzle
            self.ratmlr = (self.pcentBell/100.0) * 1612.1/(self.eps + 1009.0)
            self.SAnoz = self.Dt**2/4.*(3.368*(self.eps+10.875)**1.2606 + \
                self.eps*(self.ratmlr-1.25)*10.75)
        else:
            self.Lnoz = (sqrt(self.eps)-1.0)*(self.Dt/2.0)/tan(self.halfAngDeg*pi/180.0)
            r1 = self.Dt/2.0
            r2 = self.Dexit/2.0
            self.SAnoz = pi * sqrt((r1-r2)**2 + self.Lnoz**2) * (r1+r2)
            
        
        #self.thkCham = 0.06 * (self.Pc/1000.0) * (self.Dcham/1.48)
        self.thkCham = self.Pc * self.Dcham / self.syCham # SF=2 by using D instead of R
        if self.thkCham < self.thkChamMin: 
            self.thkCham = self.thkChamMin
            
        self.thkNoz = (self.thkCham*0.9 + 3.5*self.tmingNoz) / 4.5
        if self.thkNoz < self.thkNozMin: 
            self.thkNoz = self.thkNozMin
            
        self.WtNoz = self.thkNoz * self.SAnoz * self.rhoNoz
        
        VolChamber = mensuration.cylVol( self.thkCham, self.Dcham, self.Lcham/2.0 ) + \
                     mensuration.coneVol( self.thkCham, self.Dcham, self.Dt, self.Lcham/2.0 )
                     
        self.WtChamber = VolChamber * self.rhoNoz # chamber is made of same matl as nozzle
        
        thkMultAcc = 0.05 + 0.25/self.Dcham
        VolAccustic = mensuration.cylVol( thkMultAcc*self.Dcham, self.Dcham, self.Lcham/2.0 )
        self.WtAccustic = VolAccustic * self.rhoNoz
        
        # the injector ht also gets smaller with increased Dcham
        htMultDCham = min(1.0, 1.5/self.Dcham) * 2.0 # factor of 2.0 is for gas volume
        
        htInj =  self.Dcham*htMultDCham
        VolInj = mensuration.solidCylVol( self.Dcham*1.1 , htInj )
        self.WtInj = self.rhoInj * VolInj * self.cxwInj
           
        self.Lengine = self.Lnoz + self.Lcham + self.Dcham  # use Dcham as an inj face fwd length

        # assume that the engine is submerged and insulated
        VinsExt = mensuration.solidFrustrumVol(  self.Dcham+.1, self.Dexit+.1, self.Lengine )
        VinsExt = VinsExt - mensuration.solidFrustrumVol(  self.Dt, self.Dexit, self.Lnoz ) \
            - mensuration.solidFrustrumVol(  self.Dt, self.Dcham, self.Lcham )
        self.WtInsulation = VinsExt * 0.006
        # add up parts
        self.mass_lbm = self.WtNoz + self.WtChamber + self.WtInj + self.WtAccustic  + \
            self.WtMisc + self.WtInsulation + self.WtIgnAssy
            
        self.mass_lbm = self.Number * ( self.mass_lbm * self.cxw   + self.WtValves )
        
        self.FtoW = self.Fvac * self.Number / self.mass_lbm

        
    def buildSummary(self):
        
        summList = []
        summ = Summary(  summName='Bipropellant Engine',
        componentName=self.name, mass_lbm=self.mass_lbm, type=self.type)
        
        summ.addAssumption( 'Propellants : ' + self.oxName + ' / ' + self.fuelName )
        summ.addAssumption( 'NASA CEA Code for ODE performance ')
        summ.addAssumption( 'Physical Weight Model ')
        summ.addAssumption( 'Injector Material is ' + self.matlInj)
        summ.addAssumption( 'Nozzle Material is ' + self.matlNoz)
        if self.isBell:
            summ.addAssumption( 'Bell Nozzle with Percent Bell = %g'%self.pcentBell)
        else:
            summ.addAssumption( 'Conical Nozzle with Half Angle = %g deg'%self.halfAngDeg )
        
        if self.Number>1:
            summ.addAssumption( 'Mass is for %i engines total'%self.Number )
            
        summ.addAssumption( self.FlObj.getStrTPDphase() )
        summ.addAssumption( self.OxObj.getStrTPDphase() )


        #summ.addInput(self, label='generic param', value=0.0, units='', format='%g')

        summ.addInput('Fvac', self.Fvac, 'lbf', '%g')
        summ.addInput('Pc', self.Pc, 'psia', '%.1f')
        summ.addInput('eps', self.eps, '', '%g')
        if self.isBell:
            summ.addInput('%Bell', self.pcentBell, '%', '%.2f')
        else:
            summ.addInput('halfAngDeg', self.halfAngDeg, 'deg', '%.2f')
        summ.addInput('mr', self.mr, '', '%g')
        summ.addInput('CR', self.CR, '', '%g')
        summ.addInput('LoverDt', self.LoverDt, '', '%g')
        summ.addInput('LchamMin',self.LchamMin, 'in', '%.3f')
        summ.addInput('cxwInj', self.cxwInj, '', '%g')
        summ.addInput('cxwValves', self.cxwValves, '', '%g')
        summ.addInput('cxw', self.cxw, '', '%g')
        summ.addInput('etaERE', self.etaERE, '', '%g')
        if not self.calcEtaNoz:
            summ.addInput('etaNoz', self.etaNoz, '', '%g')
        
        # outputs
        summ.addOutput('Isp', self.Isp, 'sec', '%g')
        summ.addOutput('Cstar', self.Cstar, 'ft/sec', '%.1f')
        if self.calcEtaNoz:
            summ.addOutput('etaBL', self.etaBL, '', '%g')
            summ.addOutput('etaDiv', self.etaDiv, '', '%g')
            summ.addOutput('etaKin', self.etaKin, '', '%g')
            summ.addOutput('etaNoz', self.etaNoz, '', '%g')
        summ.addOutput('effIsp', self.effIsp, '', '%g')
        
        summ.addOutput('IspODE', self.IspODE, 'sec', '%g')
        summ.addOutput('CstarODE', self.CstarODE, 'ft/sec', '%.1f')
        summ.addOutput('Tc', self.Tc, 'degR', '%.1f')
        
        
        summ.addOutput('wdotTot', self.wdotTot, 'lbm/sec', '%g')
        summ.addOutput('wdotOx ', self.wdotOx , 'lbm/sec', '%g')
        summ.addOutput('wdotFl', self.wdotFl, 'lbm/sec', '%g')

        summ.addOutput('rhoFl', self.FlObj.rho, 'lbm/cuin', '%.4f')
        summ.addOutput('rhoOx', self.OxObj.rho, 'lbm/cuin', '%.4f')

        summ.addOutput('volDotOx ', self.volDotOx , 'cuin/sec', '%g')
        summ.addOutput('volDotFl', self.volDotFl, 'cuin/sec', '%g')
        summ.addOutput('DFlow',self.dChar,'in','%.3f')
        
        summ.addOutput('At', self.At, 'sqin', '%g')
        summ.addOutput('Dt', self.Dt, 'in', '%.3f')
        summ.addOutput('Dcham', self.Dcham, 'in', '%.3f')
        summ.addOutput('Dexit', self.Dexit, 'in', '%.3f')
        summ.addOutput('Lcham', self.Lcham, 'in', '%.3f')
        summ.addOutput('Lnoz', self.Lnoz, 'in', '%.3f')
        summ.addOutput('Lengine', self.Lengine, 'in', '%.3f')

        summ.addOutput('rhoInj', self.rhoInj, 'lbm/cuin', '%.3f')
        summ.addOutput('rhoNoz', self.rhoNoz, 'lbm/cuin', '%.3f')
        
        summ.addOutput('thkCham', self.thkCham, 'in', '%.3f')
        summ.addOutput('thkNoz', self.thkNoz, 'in', '%.3f')

        summ.addOutput('WtNoz', self.WtNoz, 'lbm', '%.3f')
        summ.addOutput('WtChamber', self.WtChamber, 'lbm', '%.3f')
        summ.addOutput('WtInj', self.WtInj, 'lbm', '%.3f')
        summ.addOutput('WtAccustic',self.WtAccustic, 'lbm', '%.3f')
        summ.addOutput('WtValves(2)',self.WtValves, 'lbm', '%.3f')
        summ.addOutput('WtMisc',self.WtMisc, 'lbm', '%.3f')
        summ.addOutput('WtInsulation',self.WtInsulation,'lbm', '%.3f')
        summ.addOutput('WtIgnAssy',self.WtIgnAssy,'lbm', '%.3f')
        if self.Number>1:
            summ.addOutput( 'wt/Engine', self.mass_lbm/self.Number, 'lbm', '%.3f' )
            summ.addOutput('F/W', self.Number * self.Fvac/self.mass_lbm, 'lbf/lbm', '%.3f')
        else:
            summ.addOutput('F/W',  self.Fvac/self.mass_lbm, 'lbf/lbm', '%.3f')
        
        summList.append( summ )
        
        # ======== now valves
        summList.append( self.Valves.buildSummary() )
        
        return summList

if __name__ == "__main__":  #self test

    print "Ponzo Proposal Engine =", 2.071,"lbm (1.815 w/o valves)"
    
    h = Engine_GasGas(name="Ref Axial Engine",  mass_lbm=0.0, oxName='O2', fuelName='CH4',
        cxw=1.27, Pc=200.0, Fvac=100.0, eps=25.0, mr=2.5, CR=2.5, LoverDt=1.2,
        etaERE=0.9, etaNoz=0.97, matlInj="SS", cxwInj=1.0, isBell=1, pcentBell=84.58, etaKinInp=.98,
        halfAngDeg=15.0, useFastCEALookup=0, Number=1, calcEtaNoz=1,  matlNoz="Cb103")
    print "Calculated =   ",h.getMassStr()
    print "w/o valves= %.3f lbm"%(h.mass_lbm - h.WtValves,)
    print
    print h.getSummary()

    print