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 | # Applied Python PRISM
# (PRISM) PaRametrIc System Model
#
# Written by Charlie Taylor <cet@appliedpython.com>
# Oct,21 2005
#from prism.props.refprop7.n23_fluid import n_fluid
from prism.props.refprop7.n_dll_fluid import n_fluid
from prism.MassItem import MassItem
from math import *
from prism.Summary import Summary
#C THIS ROUTINE CALCULATES THE COLD GAS HELIUM REQUIRED TO PRESSURIZE
#C A STORABLE PROPELLANT TANK
#C
class PressurantHe( MassItem ):
def calibrate(self, TfBottle=400.0, TfProp=500. ):
try:
lnT = log(TfBottle/self.TminR)
except:
lnT = 0.0
try:
lnP = log(self.PfinalHeBot/self.PinitCold)
except:
lnP = 1.0
R = lnT / lnP
self.gammaPolyInp = 1.0 / (1.0 - R)
self.THeTnkHX = TfProp
self.calibrateCalled = 1
self.reCalc()
def __init__(self, name="tank", mass_lbm=0.0,
VpropTnk=1000.0,PHeTnk=5000.0,PpropNom=350.0,
PfinHeOvPnom=1.1, wtHeACS=0.0,
tAction=100.0,TminR=500.0,TmaxR=550.0,
tPolyCorr=240.0, gamPolyCorr=1.66, gamLimPolyCorr=1.0,
gammaPolyInp=None,
THeTnkHX=None):
MassItem.__init__(self, name, type="pressurant")
self.VpropTnk=VpropTnk
self.wtHeACS = wtHeACS
self.PHeTnk=PHeTnk
self.PpropNom=PpropNom
self.PfinHeOvPnom=PfinHeOvPnom
self.tAction=tAction
self.TminR=TminR
self.TmaxR=TmaxR
self.tPolyCorr=tPolyCorr
self.gamPolyCorr=gamPolyCorr
self.gamLimPolyCorr=gamLimPolyCorr
self.gammaPolyInp = gammaPolyInp
self.symbol = "He"
self.gasObj = n_fluid("HE",T=530.0,P=1000.0)
self.THeTnkHX = THeTnkHX # if not None, then using HX downstream of bottle
self.calibrateCalled = 0
self.reCalc()
def buildSummary(self):
summ = Summary( summName='Helium Pressurant',
componentName=self.name, mass_lbm=self.mass_lbm, type=self.type)
if self.calibrateCalled:
summ.addAssumption( 'Calibrated Polytropic Heat Transfer')
else:
summ.addAssumption( 'Polytropic Heat Transfer')
if self.THeTnkHX:
if self.calibrateCalled:
summ.addAssumption('Final Helium Temperatures Calibrated with High Fidelity Analysis')
else:
summ.addAssumption('Heated Helium (Heat Exchanger between source and tank')
# add inputs
summ.addInput( 'VpropTnk', self.VpropTnk, 'cuin', '%g' )
summ.addInput( 'PHeTnk', self.PHeTnk, 'psia', '%g' )
summ.addInput( 'PpropNom', self.PpropNom, 'psia', '%g' )
summ.addInput( 'PfinHeOvPnom', self.PfinHeOvPnom, '', '%g' )
summ.addInput( 'tAction', self.tAction, 'sec', '%g' )
summ.addInput( 'TminR', self.TminR, 'degR', '%.1f' )
summ.addInput( 'TmaxR', self.TmaxR, 'degR', '%.1f' )
if self.gammaPolyInp:
if self.calibrateCalled:
summ.addInput( 'gammaPolyCalibrated', self.gammaPolyInp, '', '%g' )
else:
summ.addInput( 'gammaPolyInp', self.gammaPolyInp, '', '%g' )
else:
summ.addInput( 'tPolyCorr', self.tPolyCorr, 'sec', '%g' )
summ.addInput( 'gamPolyCorr', self.gamPolyCorr, '', '%g' )
summ.addInput( 'gamLimPolyCorr', self.gamLimPolyCorr, '', '%g' )
if self.THeTnkHX:
if self.calibrateCalled:
summ.addInput( 'THeCalibrated', self.THeTnkHX, 'degR', '%.1f')
else:
summ.addInput( 'THeTnkHX', self.THeTnkHX, 'degR', '%.1f')
# add outputs
summ.addOutput( 'WHeTotal', self.WtHeGas, 'lbm', '%.3f' )
summ.addOutput( 'WtHeResid', self.WtHeResid, 'lbm', '%.3f' )
if self.wtHeACS > 0.0:
summ.addOutput( 'wtHeACS', self.wtHeACS, 'lbm', '%.3f' )
summ.addOutput( 'WHeExpended', self.WHeExpended, 'lbm', '%.3f' )
summ.addOutput( 'volHeTotal', self.volHeTotal, 'cuin', '%g' )
summ.addOutput( 'wdotHe', self.wdotGas, 'lbm/sec', '%g' )
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.rhoPropHe*1728.0, 'lbm/cuft', '%g' )
summ.addOutput( 'gammaPoly', self.gammaPoly, '', '%g' )
summ.addOutput( 'TfinalPropHe', self.TfinalPropHe, 'degR', '%.1f' )
summ.addOutput( 'TfinalHeBot', self.TfinalHeBot, 'degR', '%.1f' )
summ.addOutput( 'PfinalHeBot', self.PfinalHeBot, 'psia', '%.1f' )
return summ
def reCalc(self):
#C CALCULATE POLYTROPIC GAMMA
WtMolHe = self.gasObj.WtMol
if self.gammaPolyInp:
gammaPoly = self.gammaPolyInp
elif self.tAction <= self.tPolyCorr:
gammaPoly = self.gamPolyCorr - self.tAction*(self.gamPolyCorr - 1.1)/self.tPolyCorr
else:
abot=self.tPolyCorr*(1.1-self.gamLimPolyCorr)
if abs(abot) < 1.0E-10:
if abot > 0.0:
abot=1.0E-10
else:
abot=-1.0E-10
atop=-1.0*(self.gamPolyCorr-1.1)*(self.tAction-self.tPolyCorr)
arat=atop/abot
if abs(arat) > 30.0:
if arat > 0.0:
arat=30.0
else:
arat=-30.0
gammaPoly = self.gamLimPolyCorr + (1.1-self.gamLimPolyCorr)*exp(arat)
#C FINAL PRESSURE
PF = self.PfinHeOvPnom*self.PpropNom
self.PfinalHeBot = PF
#C ASSUME MINIMUM TEMPERATURE FOR INITIAL PRESSURE CONDITION
#c... Get starting pressure assuming minimum temperature
self.gasObj.setTP(T=self.TmaxR,P=self.PHeTnk)
rhoLoaded = self.gasObj.rho
self.gasObj.setTD(T=self.TminR, D=rhoLoaded*1728.0)
PinitMin = self.gasObj.P
self.PinitCold = PinitMin
self.rhoBotInitCold = self.gasObj.rho
if self.PpropNom > PinitMin:
#C THE FOLLOWING ARE ERROR CONDITION OUTPUTS
print 'ERROR CONDITION IN PressurantHe.py '
print 'TANK PRESSURE IS HIGHER THAN HELIUM TANK PRESSURE'
print 'self.TmaxR, self.PHeTnk',self.TmaxR, self.PHeTnk
print 'PinitMin,PropNom,rhoLoaded',PinitMin,self.PpropNom,rhoLoaded
WHeTotal=(PinitMin-self.PpropNom)*1000.+10000.
WtHeResid = WHeTotal / 2.0
WHeExpended = WHeTotal / 2.0
wdotHe=WHeTotal/self.tAction
TfinalPropHe = 1.0
TfinalHeBot = 1.0
volHeTotal=((PinitMin-self.PpropNom)*100.+100.)*self.VpropTnk
self.densInit = 0.0
self.densFinal = 0.0
else:
#C FINAL TEMPERATURES
pratio=self.PpropNom/self.PinitCold
if pratio < 1.0E-5:pratio=1.0E-5
if pratio > 0.9999:pratio=0.9999
gammaExp=1.-1./gammaPoly
if gammaExp > 10.0:gammaExp=10.0
if gammaExp < -10.0:gammaExp=-10.0
Tf1R=self.TminR*(pratio)**gammaExp
# heat exchanger downstream of bottle
if self.THeTnkHX:
Tf1R = self.THeTnkHX
pratio=PF/PinitMin
if pratio < 1.0E-5:pratio=1.0E-5
if pratio > 0.9999:pratio=0.9999
TfbR = self.TminR*(pratio)**gammaExp
#C COMPRESSIBILITY FACTORS
self.gasObj.setTP(T=Tf1R,P=self.PpropNom)
ZF1 = self.gasObj.compressibility()
self.rhoPropHe = self.gasObj.rho
#if ZF1 < 1.0:ZF1=1.0
self.gasObj.setTP(T=TfbR,P=PF)
ZFB = self.gasObj.compressibility()
self.rhoBotFinal = self.gasObj.rho
#if ZFB < 1.0:ZFB=1.0
self.gasObj.setTP(T=self.TminR,P=PinitMin)
ZIB = self.gasObj.compressibility()
self.compressInit = ZIB
#if ZIB < 1.0:ZIB=1.0
TfinalPropHe=Tf1R
TfinalHeBot=TfbR
#C WEIGHT OF EXPELLED GAS
#WHeExpended = (self.PpropNom*self.VpropTnk/(Tf1R*ZF1) )*WtMolHe/18540. + self.wtHeACS
WHeExpended = self.rhoPropHe*self.VpropTnk + self.wtHeACS
if self.PfinHeOvPnom<1.0:WHeExpended=WHeExpended*self.PfinHeOvPnom
if WHeExpended < 1.0E-10:WHeExpended=1.0E-10
#C INITIAL VOLUME OF EXPELLED GAS
#volHeExpended = WHeExpended*18540.*self.TminR*ZIB/(PinitMin*WtMolHe)
volHeExpended = WHeExpended / self.rhoBotInitCold
if volHeExpended < 1.0E-10:volHeExpended=1.0E-10
#C WEIGHT OF RESIDUAL GAS
WtHeResid = volHeExpended/(TfbR*ZFB/PF - self.TminR*ZIB/PinitMin)* WtMolHe/18540.
#WtHeResid = WHeExpended * self.rhoBotFinal / (self.rhoBotInitCold - self.rhoBotFinal)
if WtHeResid < 1.0E-10:WtHeResid=1.0E-10
#C TOTAL GAS WEIGHT, VOLUME AND PRESSURE
WHeTotal = WHeExpended + WtHeResid
if WHeTotal < 1.0E-10:WHeTotal=1.0E-10
volHeTotal = WHeTotal*volHeExpended/WHeExpended
if volHeTotal < 1.0E-10:volHeTotal=1.0E-10
self.densInit = 1728.0 * PinitMin * WtMolHe / 18540.0 / self.TminR / ZIB
self.densFinal = 1728.0 * PF * WtMolHe / 18540.0 / TfbR / ZFB
#C AVERAGE GAS FLOW RATE
wdotHe = WHeExpended/self.tAction
if wdotHe < 1.0E-10:wdotHe=1.0E-10
self.WtHeGas = WHeTotal
self.WtHeResid = WtHeResid
self.WHeExpended = WHeExpended
self.volHeTotal = volHeTotal
self.wdotGas = wdotHe
self.TfinalPropHe= TfinalPropHe
self.TfinalHeBot= TfinalHeBot
self.gammaPoly = gammaPoly
self.mass_lbm = WHeTotal
if __name__ == "__main__": #self test
# validate against Transtage
h = PressurantHe(name="Oxidizer Tank Helium",
VpropTnk=565754.0,PHeTnk=3250.0,PpropNom=159.36,
PfinHeOvPnom=1.0,
tAction=433.94,TminR=510.0,TmaxR=550.0)
print h.getMassStr()
print
print h.getSummary()
h = PressurantHe(name="MKV cold gas",
VpropTnk=10.,PHeTnk=10000.0,PpropNom=2600.,
PfinHeOvPnom=1.0,
tAction=220.,TminR=510.0,TmaxR=550.0)
print h.getMassStr()
print
print h.getSummary()
|