Engine_Fixed_Design.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
# Applied Python PRISM
# (PRISM) PaRametrIc System Model
#
# Written by Charlie Taylor <cet@appliedpython.com> 
# Oct,21 2005

from math import *
from prism.MassItem import MassItem
from prism.isp.cea import CEA_Isp
from prism.utils import Constants
from prism.Summary import Summary
from prism.isp import Nozzle_Eff
from prism.props import Inc_liquid
from prism.pov import POV_Items, POV_Basics



class Engine_Fixed_Design( MassItem ):
    
    def __init__(self, name="engine",  mass_lbm=10.0, oxName='N2O4', fuelName='MMH',
        Pc=150.0, Dt=1.0, eps=50.0, mr=1.6, CR=2.5, xlcOxln=1.0, Lprime=4.0,
        etaERE=0.97, etaNoz=0.99, isBell=1, pcentBell=80.0,
        halfAngDeg=15.0, useFastCEALookup=0, Number=1, etaKinInp=1.0,
        calcEtaNoz=1, inputIspDel=0, IspDel=300.0):
        
        MassItem.__init__(self, name, type="inert")
        
        self.Number = Number # number of engines
        self.mass_lbm_inp = mass_lbm
        self.oxName = oxName
        self.fuelName = fuelName
        self.iprop = oxName + '/' + fuelName
        
        self.Pc = Pc
        self.eps = eps
        self.mr = mr
        self.CR = CR
        self.Dt = Dt
        
        self.xlcOxln = xlcOxln
        self.Lprime = Lprime
        
        self.etaERE = etaERE
        self.etaKinInp = etaKinInp
        
        self.inputIspDel = inputIspDel
        self.IspDel = IspDel
        
        self.isBell = isBell
        self.pcentBell = pcentBell
        self.halfAngDeg = halfAngDeg
        self.etaNoz = etaNoz
        self.calcEtaNoz = calcEtaNoz
        
        # assume storable liquids for the FFC engine
        self.FlObj = Inc_liquid.Inc_liquid(symbol=fuelName,T=None,P=Pc*1.5)
        self.OxObj = Inc_liquid.Inc_liquid(symbol=oxName,T=None,P=Pc*1.5)
        
        
        self.ispObj = CEA_Isp.CEA_Isp( oxName=oxName, fuelName=fuelName, 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.xlc , xln=self.xln, 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)
            
        self.Cstar = self.CstarODE * self.etaERE
        
        self.Rt = self.Dt / 2.0
        self.At = pi * self.Rt**2 
        self.wdotTot = self.Pc * self.At * Constants.gc / self.Cstar
        
        FvacEst = self.wdotTot * self.IspODE * self.etaERE * 0.98
            
        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=FvacEst, 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
        
        # if isp delivered is input, correct etaNoz to reflect that input
        if self.inputIspDel:
            self.Isp = self.IspDel
            self.effIsp = self.Isp / self.IspODE
            self.etaNoz = self.effIsp / self.etaERE
        else:
            self.effIsp = self.etaERE * self.etaNoz
            self.Isp = self.IspODE * self.effIsp
            
        self.Fvac = self.wdotTot * self.Isp
        
        self.wdotOx  = self.wdotTot * self.mr / (1.0 + self.mr)
        self.wdotFl = self.wdotTot - self.wdotOx 
        
        self.volDotOx = self.wdotOx / self.OxObj.rho
        self.volDotFl = self.wdotFl / self.FlObj.rho
        
        
        self.Dcham = self.Dt * sqrt( self.CR )
        self.Dexit = self.Dt * sqrt( self.eps )
        
        self.xln = self.Lprime / (1.0 + self.xlcOxln)
        self.xlc = self.Lprime - self.xln
        self.Lcham = self.Lprime
        
        
        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.Lengine = self.Lnoz + self.Lcham + self.Dcham  # use Dcham as an inj face fwd length

        
        # add up parts
        self.mass_lbm = self.Number * ( self.mass_lbm_inp  )
        
        self.FtoW = self.Fvac * self.Number / self.mass_lbm
        
        self.pov_h = self.Lengine
        self.pov_w = max( self.Dexit, self.Dcham )
        self.pov_d = self.pov_w

        
    def buildSummary(self):
        
        name = self.name
        if self.Number>1:
            name += ' (%i)'%self.Number
        
        summList = []
        summ = Summary(  summName='Bipropellant Engine',
        componentName=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( 'Actual Hardware Weight ')
        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.addInput(self, label='generic param', value=0.0, units='', format='%g')

        summ.addInput('Pc', self.Pc, 'psia', '%.1f')
        summ.addInput('Dt', self.Dt, 'in', '%.3f')
        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('Lprime', self.Lprime, 'in', '%.3f')
        summ.addInput('xlc/xln', self.xlcOxln, '', '%g')
        
        
        summ.addInput('etaERE', self.etaERE, '', '%g')
        if not self.calcEtaNoz:
            summ.addInput('etaNoz', self.etaNoz, '', '%g')
        
        # outputs
        summ.addOutput('Fvac', self.Fvac, 'lbf', '%g')
        summ.addOutput('Isp', self.Isp, 'sec', '%g')
        summ.addOutput('Cstar', self.Cstar, 'ft/sec', '%.1f')
        if self.inputIspDel:
            summ.addOutput('etaNoz', self.etaNoz, '', '%g')
        
        elif 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('At', self.At, 'sqin', '%g')
        summ.addOutput('Dcham', self.Dcham, 'in', '%.3f')
        summ.addOutput('Dexit', self.Dexit, 'in', '%.3f')
        summ.addOutput('xlc', self.xlc, 'in', '%.3f')
        summ.addOutput('xln', self.xln, 'in', '%.3f')
        summ.addOutput('Lcham', self.Lcham, 'in', '%.3f')
        summ.addOutput('Lnoz', self.Lnoz, 'in', '%.3f')
        summ.addOutput('Lengine', self.Lengine, 'in', '%.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 )
        
        return summList

if __name__ == "__main__":  #self test

    print "Actual IR&D Style Engine =", 2.071,"lbm (1.815 w/o valves)"
    
    h = Engine_Fixed_Design(name="Ref Axial Engine",  mass_lbm=6.245, oxName='N2O4', fuelName='MMH',
        Pc=500.0, Dt=1.03, eps=17.0, mr=1.08, CR=2.06, xlcOxln=1.0, Lprime=4.0,
        etaERE=0.97, etaNoz=0.99, isBell=1, pcentBell=84.58,
        halfAngDeg=15.0, useFastCEALookup=0, Number=1, calcEtaNoz=1)
    print
    print h.getSummary()