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 | # Applied Python PRISM
# (PRISM) PaRametrIc System Model
#
# Written by Charlie Taylor <cet@appliedpython.com>
# Oct,21 2005
from prism.props.refprop7.n_dll_fluid import n_fluid
from prism.isp import isp
from prism.MassItem import MassItem
from math import *
from prism.Summary import Summary
#C THIS ROUTINE CALCULATES THE COLD GAS Nitrogen REQUIRED TO PRESSURIZE
#C A STORABLE PROPELLANT TANK
#C
class Pressurant_Gas( MassItem ):
def __init__(self, name="tank", mass_lbm=0.0, symbol="N2",
VpropTnk=1000.0,PGasTnk=5000.0,PpropNom=350.0,
PfinGasOvPnom=1.1,
tAction=100.0,TminR=500.0,TmaxR=550.0,
ItotLLACSinp=None, etaNoz=.965, AreaRatio=10.0, wtGasACS=0.0,
fracIsenBottle=0.5, fracIsenTank=0.1):
MassItem.__init__(self, name, type="pressurant")
self.VpropTnk=VpropTnk
self.wtGasACS = wtGasACS
self.PGasTnk=PGasTnk
self.PpropNom=PpropNom
self.PfinGasOvPnom=PfinGasOvPnom
self.tAction=tAction
self.TminR=TminR
self.TmaxR=TmaxR
self.symbol = symbol
self.gasObj = n_fluid(symbol,T=530.0,P=1000.0)
self.fracIsenBottle = fracIsenBottle
self.fracIsenTank = fracIsenTank
self.ItotLLACSinp = ItotLLACSinp
self.etaNoz = etaNoz
self.AreaRatio = AreaRatio
self.Pamb = 0.0
self.reCalc()
def buildSummary(self):
summ = Summary( summName='%s Pressurant (%s)'%(self.gasObj.name,self.symbol),
componentName=self.name, mass_lbm=self.mass_lbm, type=self.type)
if self.fracIsenBottle >= 1.0:
summ.addAssumption( 'Isentropic Bottle Blow-Down')
elif self.fracIsenBottle <= 0.0:
summ.addAssumption( 'Iso-Thermal Bottle Blow-Down')
else:
summ.addAssumption( '%g%% Isentropic from Isothermal Bottle Blow-Down'%(100.0*self.fracIsenBottle,))
if self.fracIsenTank >= 1.0:
summ.addAssumption( 'Isentropic Tank Temperature')
elif self.fracIsenTank <= 0.0:
summ.addAssumption( 'Iso-Thermal Tank Temperature')
else:
summ.addAssumption( '%g%% Isentropic from Isothermal Tank Temperature'%(100.0*self.fracIsenTank,))
# add inputs
summ.addInput( 'VpropTnk', self.VpropTnk, 'cuin', '%g' )
summ.addInput( 'PGasTnk', self.PGasTnk, 'psia', '%g' )
summ.addInput( 'PpropNom', self.PpropNom, 'psia', '%g' )
summ.addInput( 'PfinGasOvPnom', self.PfinGasOvPnom, '', '%g' )
summ.addInput( 'tAction', self.tAction, 'sec', '%g' )
summ.addInput( 'TminR', self.TminR, 'degR', '%.1f' )
summ.addInput( 'TmaxR', self.TmaxR, 'degR', '%.1f' )
summ.addInput( 'fracIsenBottle', self.fracIsenBottle, '', '%g' )
summ.addInput( 'fracIsenTank', self.fracIsenTank, '', '%g' )
if self.ItotLLACSinp != None:
summ.addInput( 'ItotLLACS', self.ItotLLACSinp, 'lbf-sec', '%g' )
if self.ItotLLACSinp != None or self.wtGasACS > 0.0:
summ.addInput( 'etaNoz', self.etaNoz, '', '%g' )
summ.addInput( 'AreaRatio', self.AreaRatio, '', '%g' )
# add outputs
summ.addOutput( 'WGasTotal', self.WtGasGas, 'lbm', '%.3f' )
summ.addOutput( 'WtGasResid', self.WtGasResid, 'lbm', '%.3f' )
if self.wtGasACS > 0.0:
summ.addOutput( 'wtGasACS', self.wtGasACS, 'lbm', '%.3f' )
summ.addOutput( 'WGasExpended', self.WGasExpended, 'lbm', '%.3f' )
summ.addOutput( 'Vbottle', self.Vbottle, 'cuin', '%g' )
summ.addOutput( 'wdotGas', self.wdotGas, 'lbm/sec', '%g' )
summ.addOutput( 'WtMolGas', self.WtMolGas, 'lbm/lbm-mole', '%g' )
if self.ItotLLACS>0.0:
summ.addOutput( 'TregInit', self.TregInit, 'degR', '%.3f' )
summ.addOutput( 'TregFinal', self.TregFinal, 'degR', '%.3f' )
summ.addOutput( 'TregAve', self.TregAve, 'degR', '%.3f' )
summ.addOutput( 'gammaAve', self.gammaAve, '', '%.3f' )
summ.addOutput( 'IspAmb', self.IspAmb, 'sec', '%.3f' )
summ.addOutput( 'Cstar', self.Cstar, 'ft/sec', '%.1f' )
summ.addOutput( 'compressInit', self.compressInit, '', '%g' )
summ.addOutput( 'PinitCold', self.PinitCold, 'psia', '%g' )
summ.addOutput( 'densInitBot', self.densInit, 'lbm/cuft', '%g' )
summ.addOutput( 'densFinalBot', self.densFinal, 'lbm/cuft', '%g' )
summ.addOutput( 'densFinalProp', self.densFinalProp, 'lbm/cuft', '%g' )
summ.addOutput( 'gammaIsen', self.gammaIsen, '', '%g' )
summ.addOutput( 'gammaPolyBottle', self.gammaPolyBottle, '', '%g' )
summ.addOutput( 'gammaPolyTank', self.gammaPolyTank, '', '%g' )
summ.addOutput( 'TfinalPropGas', self.TfinalPropGas, 'degR', '%.1f' )
summ.addOutput( 'TfinalGasBot', self.TfinalGasBot, 'degR', '%.1f' )
summ.addOutput( 'PfinalGasBot', self.PfinalGasBot, 'psia', '%.1f' )
return summ
def reCalc(self):
WtMolGas = self.gasObj.WtMol
#C FINAL PRESSURE
PF = self.PfinGasOvPnom*self.PpropNom
self.PfinalGasBot = PF
#C ASSUME MINIMUM TEMPERATURE FOR INITIAL PRESSURE CONDITION
#c... Get starting pressure assuming minimum temperature
self.gasObj.setTP(T=self.TmaxR,P=self.PGasTnk)
self.rhoLoaded = self.gasObj.rho
self.gasObj.setTD(T=self.TminR,D=self.rhoLoaded*1728.0)
PinitMin = self.gasObj.P
self.PinitCold = PinitMin
self.gammaIsen=self.gasObj.gamma()
self.compressInit = self.gasObj.compressibility()
pratio=self.PfinalGasBot/PinitMin
if pratio < 1.0E-5:pratio=1.0E-5
if pratio > 0.9999:pratio=0.9999
self.TfinalIsen = self.TminR*(pratio)**(1.-1./self.gammaIsen)
if self.PpropNom > PinitMin:
#C THE FOLLOWING ARE ERROR CONDITION OUTPUTS
print 'ERROR CONDITION IN Pressurant_Gas.py '
print 'TANK PRESSURE IS HIGHER THAN Nitrogen TANK PRESSURE'
print 'self.TmaxR, self.PGasTnk',self.TmaxR, self.PGasTnk
print 'PinitMin,PropNom,rhoLoaded',PinitMin,self.PpropNom,self.rhoLoaded
WGasTotal=(PinitMin-self.PpropNom)*1000.+10000.
WtGasResid = WGasTotal / 2.0
WGasExpended = WGasTotal / 2.0
wdotGas=WGasTotal/self.tAction
TfinalPropGas = 1.0
TfinalGasBot = 1.0
Vbottle=((PinitMin-self.PpropNom)*100.+100.)*self.VpropTnk
self.densInit = 0.0
self.densFinal = 0.0
else:
#C FINAL TEMPERATURES
gammaPolyBottle = 1.0 + self.fracIsenBottle * (self.gammaIsen - 1.0)
gammaPolyTank = 1.0 + self.fracIsenTank * (self.gammaIsen - 1.0)
gammaExp=1.-1./gammaPolyBottle
if gammaExp > 10.0:gammaExp=10.0
if gammaExp < -10.0:gammaExp=-10.0
TfinalGasBot = self.TminR*(pratio)**gammaExp
self.gasObj.setTP(T=TfinalGasBot,P=self.PfinalGasBot)
self.rhoFinal = self.gasObj.rho
gammaExp=1.-1./gammaPolyTank
if gammaExp > 10.0:gammaExp=10.0
if gammaExp < -10.0:gammaExp=-10.0
TfinalPropGas = self.TminR*(pratio)**gammaExp
self.gasObj.setTP(T=TfinalPropGas,P=self.PpropNom)
self.rhoPropFinal = self.gasObj.rho
# estimate regulator outlet temperature
self.gasObj.setTP(T=self.TminR,P=PinitMin)
self.gasObj.constH_newP( self.PpropNom )
# ignore heat transfer, just use Joule Thomson effect
self.TregInit = self.gasObj.T
self.gasObj.setTP( T=TfinalGasBot, P=self.PfinalGasBot )
self.gasObj.constH_newP( self.PpropNom )
self.TregFinal = self.gasObj.T
# now use average Treg outlet to calc Isp
self.TregAve = (self.TregInit + self.TregFinal) / 2.0
self.gasObj.setTP(T=self.TregAve,P=self.PpropNom)
self.gammaAve = self.gasObj.gamma()
self.IspAmb = self.etaNoz * isp.calcidealis(self.gammaAve,self.TregAve,WtMolGas,self.AreaRatio,self.PpropNom,self.Pamb)
self.Cstar = isp.calccstar(self.gammaAve,self.TregAve,WtMolGas)
if self.ItotLLACSinp != None:
self.wtGasACS = self.ItotLLACSinp / self.IspAmb
self.ItotLLACS = self.ItotLLACSinp
else:
self.ItotLLACS = self.wtGasACS * self.IspAmb
#C WEIGHT OF EXPELLED GAS
self.Vbottle = (self.wtGasACS + self.rhoPropFinal*self.VpropTnk) / (self.rhoLoaded-self.rhoFinal)
WGasExpended = self.Vbottle * (self.rhoLoaded-self.rhoFinal)
#C WEIGHT OF RESIDUAL GAS
WtGasResid = self.Vbottle * self.rhoFinal
WGasTotal = WGasExpended + WtGasResid
self.densInit = 1728.0 * self.rhoLoaded
self.densFinal = 1728.0 * self.rhoFinal
self.densFinalProp = 1728.0 * self.rhoPropFinal
#C AVERAGE GAS FLOW RATE
wdotGas = WGasExpended/self.tAction
if wdotGas < 1.0E-10:wdotGas=1.0E-10
self.WtGasGas = WGasTotal
self.WtGasResid = WtGasResid
self.WGasExpended = WGasExpended
self.wdotGas = wdotGas
self.TfinalPropGas= TfinalPropGas
self.TfinalGasBot= TfinalGasBot
self.gammaPolyBottle = gammaPolyBottle
self.gammaPolyTank = gammaPolyTank
self.WtMolGas = WtMolGas
self.mass_lbm = WGasTotal
if __name__ == "__main__": #self test
h = Pressurant_Gas(name="Press Tank Mixture", symbol="HE",
VpropTnk=60.0,PGasTnk=5500.0,PpropNom=1100.0,
PfinGasOvPnom=1.1, ItotLLACSinp=8.0,
tAction=100.0,TminR=500.0,TmaxR=550.0, fracIsenBottle=0.4, fracIsenTank=0.06)
print h.getMassStr()
print
print h.getSummary()
h = Pressurant_Gas(name="Press Tank Mixture", symbol="N2",
VpropTnk=60.0,PGasTnk=5500.0,PpropNom=1100.0,
PfinGasOvPnom=1.1, ItotLLACSinp=8.0,
tAction=100.0,TminR=500.0,TmaxR=550.0, fracIsenBottle=0.36, fracIsenTank=0.06)
print h.getMassStr()
print
print h.getSummary()
|