Engine_ColdGas.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
# Applied Python PRISM
# (PRISM) PaRametrIc System Model
#
# Written by Charlie Taylor <cet@appliedpython.com> 
# Sep 7, 2007

from prism.MassItem import MassItem
from math import *
from prism.utils import Constants
from prism.Summary import Summary
from prism.isp import Nozzle_Eff
#from prism.props.refprop7.n23_fluid import n_fluid
from prism.props.refprop7.n_dll_fluid import n_fluid

from prism.isp import isp
from prism.props import Materials
from prism.utils import mensuration

class Engine_ColdGas( MassItem ):
    
    '''Note that cold gas thrusters get about the same thrust with any gas.
    
       Isp goes like sqrt( T/M )
       wdot goes like sqrt( M/T )
       
       So a given throat size and area ratio get about the same thrust
    '''
    
    def __init__(self, name="ColdGasEngine",  mass_lbm=0.0, gasSymbol='He', 
        Tin=530.0, matlBody="SS",
        cxw=1.0, Pc=150.0, Fvac=1.0, eps=50.0, CR=2.5, LoverDt=4.0,
        etaCham=0.97, etaNoz=0.99, isBell=1, pcentBell=80.0,
        halfAngDeg=15.0, Number=1, calcEtaNoz=1):
        
        MassItem.__init__(self, name, type="inert")
        
        self.Number = Number # number of engines
        self.gasSymbol = gasSymbol
        self.matlBody = matlBody
        self.rhoBody, self.syBody, self.eBody, self.tmingBody = Materials.getMatlProps(matlBody)
        
        
        self.Fvac = Fvac
        self.Pc = Pc
        self.Tin = Tin
        self.eps = eps
        
        self.CR = CR
        self.LoverDt = LoverDt
        self.cxw = cxw
        self.etaCham = etaCham
        self.etaNoz = etaNoz
        self.calcEtaNoz = calcEtaNoz
        
        self.isBell = isBell
        self.pcentBell = pcentBell
        self.halfAngDeg = halfAngDeg
        
        self.gas = n_fluid(symbol=gasSymbol, T=Tin, P=Pc, child=1)
        self.reCalc()
        
    def reCalc(self):
        # set design variables
        
        
        self.gas.setTP(T=self.Tin,P=self.Pc)
        Gam = self.gas.gamma()
        Pamb = 0.0
        
        self.IspODE = isp.calcidealis(Gam,self.Tin,self.gas.WtMol,self.eps,self.Pc,Pamb)
        self.CstarODE = isp.calccstar(Gam,self.Tin,self.gas.WtMol)
        self.Tc = self.Tin
            
        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.gasSymbol, mr=1.0, etaKinInp=1.0,
                adjBL=1.0, adjKin=1.0, adjDiv=1.0, isRegenCham=0, isRegenNoz=0 )
                
            self.etaNoz = self.etaBL * self.etaDiv  # ignore etaKin for now on monoprop

        self.effIsp = self.etaCham * self.etaNoz
        self.Isp = self.IspODE * self.effIsp
        self.Cstar = self.CstarODE * self.etaCham
        
        self.wdotTot = self.Fvac / self.Isp
        
        
        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.Dcham * self.LoverDt
        self.xlc = self.Lcham / 2.0
        self.xln = self.Lcham / 2.0
        
        if self.isBell:
            self.Lnoz = (sqrt(self.eps)-1.0)*self.pcentBell*(self.Dt/2.0)/100.0/tan(15.0*pi/180.0)
        else:
            self.Lnoz = (sqrt(self.eps)-1.0)*(self.Dt/2.0)/tan(self.halfAngDeg*pi/180.0)
        self.Dexit = self.Dt * sqrt( self.eps )
        
        self.Lengine = self.Lnoz + self.Lcham + self.Dcham  # use Dcham as an inj face fwd length

        # start weight calcs
        self.wtValve = 0.05 + self.At*100.0
        
        

        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)
        if self.thkCham < self.tmingBody: 
            self.thkCham = self.tmingBody
            
        self.thkNoz = (self.thkCham*0.9 + 3.5*self.tmingBody) / 4.5
        if self.thkNoz < self.tmingBody: 
            self.thkNoz = self.tmingBody
            
        self.WtNoz = self.thkNoz * self.SAnoz * self.rhoBody
        
        
        VolChamber = mensuration.cylVol( self.thkCham, self.Dcham, self.xlc ) + \
                     mensuration.coneVol( self.thkCham, self.Dcham, self.Dt, self.xln )
                     
        self.WtChamber = VolChamber * self.rhoBody # chamber is made of same matl as nozzle
        
        self.wtEngine = self.WtChamber + self.WtNoz + self.wtValve
                
        self.mass_lbm = self.Number * self.cxw * self.wtEngine
#END        
        self.FtoW = self.Fvac * self.Number / self.mass_lbm

        
    def buildSummary(self):
        
        summ = Summary(  summName='Cold Gas Thruster',
        componentName=self.name, mass_lbm=self.mass_lbm, type=self.type)
        
        summ.addAssumption( 'Propellant : %s (%s)'%(self.gas.name,self.gasSymbol) )

        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('Fvac', self.Fvac, 'lbf', '%g')
        summ.addInput('Tc', self.Tc, 'degR', '%.1f')
        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('CR', self.CR, '', '%g')
        summ.addInput('LoverDt', self.LoverDt, '', '%g')
        summ.addInput('cxw', self.cxw, '', '%g')
        summ.addInput('etaCham', self.etaCham, '', '%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')
            # later... 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('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('wtValve', self.wtValve, 'lbm', '%.3f')
        summ.addOutput('wtEngine', self.wtEngine, 'lbm', '%.3f')
        
        if self.Number>1:
            summ.addOutput( 'wt/Assembly', 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')

        return summ


if __name__ == "__main__":  #self test

    h = Engine_ColdGas(name="ColdGasEngine",  gasSymbol='He', 
        Tin=400.0, 
        cxw=1.0, Pc=1000.0, Fvac=0.7, eps=15.0, CR=2.5, LoverDt=4.0,
        etaCham=0.97, etaNoz=0.99, isBell=0, pcentBell=100.0,
        halfAngDeg=15.0, Number=1, calcEtaNoz=1)
    print h.getMassStr()
    print
    print h.getSummary()