Tank_Piston.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
# Applied Python PRISM
# (PRISM) PaRametrIc System Model
#
# Written by Charlie Taylor <cet@appliedpython.com> 
# Feb 15, 2007
#
# Adding Jim Ponzo scaling equations 3/26/2008

from math import *

from prism.MassItem import MassItem
from prism.props import Materials
from prism.Summary import Summary
from math import *
from prism.pov import POV_Items, POV_Basics


# Model of Piston tank.  very thin metal shell overwrapped with composite
# positive expulsion with a piston

#C INPUT
#C   vfree-total volume Usabel Volume (ullage plus propellant)
#          (does NOT include Residual Propellant)
#C   ptank-pressure in tank
#C   SF-safety factor
#C   CXW-tank weight multiplier (welds, bosses, etc.)
#C   INPEX-input expulsion efficiency flag(0=calculate eff,1=input)
#C   EXPEFI-input expulsion efficiency

exp_dict = {0:'calculate expulsion eff',1:'input expulsion eff'}

class Tank_Piston( MassItem ):
    
    def __init__(self, name="tank",  mass_lbm=0.0,
        inputLoverD=1, metalName="Ti", overwrapName="grEpox",
        vfree=4.0,ptank=1400.0,
        sf=1.5,cxw=1.0,Number=1,
        inpex=0,expefi=0.99, dPpiston=10.0, LoDpiston=0.45,
        LoverD=5.0,Dinside=1.0, thkMetal_minG=0.010, thkMetal=None,
        thkOvInput=None, thkMetalInp=None):
        
        MassItem.__init__(self, name, type="inert", mass_lbm=mass_lbm)
        
        self.inputLoverD = inputLoverD
        self.metalName = metalName
        self.thkMetal_minG = thkMetal_minG
        
        # maintain backward compatibility with thkMetal input
        if thkMetal:
            self.thkMetal_minG = thkMetal
        
        self.overwrapName = overwrapName
        self.rhoMetal, self.syMetal, self.eMetal, self.tmingMetal = Materials.getMatlProps(metalName)
        self.tmingMetal = thkMetal_minG
        self.thkOvInput = thkOvInput
        self.thkMetalInp = thkMetalInp
        
        self.rhoOv, self.syOv, self.eOv, self.tmingOv = Materials.getMatlProps(overwrapName)
        
        self.Number = Number  # each tank has vfree
        self.vfree = vfree
        self.LoverD = LoverD
        self.LoDpiston = LoDpiston
        self.ptank = ptank
        self.sf = sf
        self.cxw = cxw
        self.Dinside = Dinside
        self.inpex = inpex
        self.expefi = expefi
        self.dPpiston = dPpiston
        
        self.reCalc()
        
    def getPOV_Item(self):
        if hasattr( self, 'texture'):
            texture = self.texture
        else:
            
            texture = POV_Basics.Texture( colorName="Gray50" )
        s = POV_Items.Cylinder( texture=texture, bottom=[0,0,0], top=[0,self.Ltotal,0], radius=self.radius )
        
        return s
        
    def reCalc(self):
        
        default_cxw = 1.0
        
        # reference values for piston tank
        P1 = 1400.0 # MEOP
        r1 = 1.625 / 2.0 # inside radius
        a1 = 0.010 # metal thickness
        b1 = 0.007 # overwrap thickness
        Em = self.eMetal
        En = self.eOv
        SF1 = 1.5  # 2100/1400 = design burst / design MEOP
        
        t1 = r1 / 4.0 # end cap thickness
        
        # get diameter and wet length figured out
        if not self.inputLoverD: # Dinside is input
            self.Across = pi*self.Dinside**2/4.0
            self.Lwet = self.vfree / self.Across
            self.LoverD = self.Lwet / self.Dinside
        else: # LoverD is input
            self.Dinside = (4. * self.vfree / pi / self.LoverD)**(1./3.)
            self.Across = pi*self.Dinside**2/4.0
            self.Lwet = self.vfree / self.Across
            
        # get inside radius
        self.radius = self.Dinside / 2.0
        R = self.radius
        r2 = R
        
        # assume dPpiston = const
        self.pullag = self.ptank + self.dPpiston
        P2 = self.pullag
        
        # figure out lengths of piston and heads
        self.Lpiston = self.LoDpiston * self.Dinside
        t2_deflect= t1 * (r2/r1)**(3./2.) * sqrt(P2/P1)
        t2_stress = t1 * (r2/r1) * sqrt(P2/P1)
         
        self.Lhead = max( t2_stress, t2_deflect )
        if self.Lhead < self.tmingMetal:
            self.Lhead = self.tmingMetal
        
        self.Ltotal = self.Lwet + self.Lpiston + self.Lhead*2.0
        
        # calc metal thickness
        a2 = sqrt((P2/P1)*(r2/r1)**2 * ((r1+a1)**2 - r1**2) + r2**2) - r2
        b2 = (r2+a2)**2 / En * ((P2/P1)*(Em*a1/r1**2 + En*b1/(r1+a1)**2) - Em*a2/r2**2)
        
        self.thkMetal = self.sf * a2 / SF1
        
        if self.thkMetal < self.tmingMetal:
            self.thkMetal = self.tmingMetal
            
        if self.thkMetalInp:
            self.thkMetal = self.thkMetalInp
        
        # calc overwrap thickness
        self.thkOv = self.sf * b2 / SF1
        if self.thkOv < self.tmingOv:
            self.thkOv = self.tmingOv

        if self.thkOvInput:
            self.thkOv = self.thkOvInput
            
        if self.thkOv <= self.tmingOv:
            self.Pburst = self.tmingOv * self.syOv / (R+self.thkMetal)
        else:
            self.Pburst = self.sf * self.pullag


        # weigh metal shell, overwrap, piston, and heads
        Vshell = pi * ((R+self.thkMetal)**2-R**2) * self.Ltotal
        self.WmetalShell = Vshell * self.rhoMetal
        
        Vovr =  pi * ( (R+self.thkMetal+self.thkOv)**2 - (R+self.thkMetal)**2 ) * self.Ltotal
        self.Woverwrap = Vovr * self.rhoOv
        
        
        self.thkPiston = R/20.
        if self.thkPiston < self.tmingMetal:
            self.thkPiston = self.tmingMetal
        #           base           shell                   seal inner shell         seal cross pieces
        SApiston = pi*R**2 + 2.*pi*R*self.Lpiston + 2.*pi*(0.7*R)*(0.35*R) + pi*(R**2 - (.7*R)**2)*2.
        self.Wpiston = SApiston * self.rhoMetal * self.thkPiston
        self.Whead = self.Lhead * pi * R**2 * 0.8 * self.rhoMetal
        
        # get total mass
        self.Wtotal = self.WmetalShell + self.Woverwrap + self.Wpiston + self.Whead*2.0
        
        self.vresid=(1.-self.expefi)*self.vfree
        self.vtank = self.vresid + self.vfree

        self.mass_lbm = self.Wtotal * self.cxw

        # if more than one tank, increase mass to reflect that
        self.mass_lbm *= self.Number
        
        try:
            self.PVoverW      = self.ptank *self.vtank*self.Number/self.mass_lbm
            self.PburstVoverW = self.Pburst*self.vtank*self.Number/self.mass_lbm
        except:
            self.PVoverW = 0.0    
            self.PburstVoverW = 0.0
            
        self.pov_h = self.Ltotal
        self.pov_w = self.Dinside
        self.pov_d = self.Dinside
        self.OD = self.Dinside + 2.0 *( self.thkOv  + self.thkMetal )
        self.OR = self.OD / 2.0
        self.OH = self.Ltotal
        
    def buildSummary(self):
        
        summ = Summary(  summName='Positive Expulsion Piston Tank',
        componentName=self.name, mass_lbm=self.mass_lbm, type=self.type)
        
        
        summ.addAssumption('Piston Tank')
        summ.addAssumption('Metallic Material : ' + self.metalName )
        summ.addAssumption('Overwrap Material : ' + self.overwrapName )
        summ.addAssumption('inputLoverD = ' + str( self.inputLoverD ) )
            
        if self.Number>1:
            summ.addAssumption( 'Mass is for %i Tanks total'%self.Number )
        
        # add inputs
        summ.addInput('vfree', self.vfree, 'cuin', '%g')
        if self.Number>1:
            summ.addInput('vfreeTotal', self.vfree*self.Number, 'cuin', '%g')
        if self.inputLoverD:
            summ.addInput('LoverD', self.LoverD, '', '%g')
        else:
            summ.addInput( 'Dinside', self.Dinside, 'in', '%.3f' )
            
        summ.addInput('ptank', self.ptank, 'psia', '%g')
        summ.addInput('dPpiston', self.dPpiston, 'psig', '%g' )
        summ.addInput('sf', self.sf, '', '%g')
        summ.addInput('thkMetal_minG', self.thkMetal_minG, 'in', '%.3f')
        summ.addInput('cxw', self.cxw, '', '%g')
        summ.addInput('inpex', self.inpex, '', '%g')
        summ.addInput('expefi', self.expefi, '', '%g')
        
        
        # add outputs

        summ.addOutput( 'radius', self.radius, 'in', '%.3f' )
        if self.inputLoverD:
            summ.addOutput( 'Dinside', self.Dinside, 'in', '%.3f' )
        else:
            summ.addOutput('LoverD', self.LoverD, '', '%g')
            
        summ.addOutput( 'OD', self.OD, 'in', '%.3f' )
        summ.addOutput( 'thkPiston', self.thkPiston, 'in', '%.3f' )
        summ.addOutput( 'thkOv', self.thkOv, 'in', '%.3f' )
        summ.addOutput( 'thkMetal', self.thkMetal, 'in', '%.3f' )
        summ.addOutput( 'rhoMetal', self.rhoMetal, 'lbm/cuin', '%g' )
        summ.addOutput( 'rhoOv', self.rhoOv, 'lbm/cuin', '%g' )
        summ.addOutput( 'designStress', self.syOv, 'psi', '%.0f' )
        
        summ.addOutput( 'Lpiston', self.Lpiston, 'in', '%.3f' )
        summ.addOutput( 'Lhead', self.Lhead, 'in', '%.3f' )
        summ.addOutput( 'Lwet', self.Lwet, 'in', '%.3f' )
        summ.addOutput( 'Ltotal', self.Ltotal, 'in', '%.3f' )
        summ.addOutput( 'vresid', self.vresid, 'cuin', '%g' )
        summ.addOutput( 'vtank', self.vtank, 'cuin', '%g' )
        
        summ.addOutput( 'WmetalShell', self.WmetalShell, 'lbm', '%.3f' )
        summ.addOutput( 'Woverwrap', self.Woverwrap, 'lbm', '%.3f' )
        summ.addOutput( 'Whead', self.Whead, 'lbm', '%.3f' )
        summ.addOutput( 'Wpiston', self.Wpiston, 'lbm', '%.3f' )
        summ.addOutput( 'Wtotal', self.Wtotal, 'lbm', '%.3f' )
        
        summ.addOutput( 'pullag', self.pullag, 'psia', '%.0f' )
        summ.addOutput( 'Pburst', self.Pburst, 'psia', '%.0f' )
        
        summ.addOutput( 'PVoverW', self.PVoverW, 'lbf-in/lbm', '%.0f' )
        summ.addOutput( 'SF*PVoverW', self.sf*self.PVoverW, 'lbf-in/lbm', '%.0f' )
        summ.addOutput( 'PburstVoverW', self.PburstVoverW, 'lbf-in/lbm', '%.0f' )
        

        return summ


if __name__ == "__main__":  #self test

    print "Calculated =   ",

    testTnk = Tank_Piston(name="Piston tank",  mass_lbm=0.0,
        inputLoverD=0, metalName="Ti", overwrapName="grEpox",
        vfree=4.0*2.25,LoverD=5.0,ptank=1400.0,
        sf=1.5,cxw=1.02,
        inpex=0,expefi=0.99,
        Dinside=2.0*0.85)
    print testTnk.getMassStr()
    print
    print testTnk.getSummary()

    if 0:
        print "Calculated =   ",
    
        testTnk = Tank_Piston(name="Large Piston tank",  mass_lbm=0.0,
            inputLoverD=1, metalName="Ti", overwrapName="grEpox",
            vfree=40.0,LoverD=5.0,ptank=1400.0,
            sf=1.5,cxw=1.02, Number=1,
            inpex=0,expefi=0.99,
            Dinside=1.0 )
        print testTnk.getMassStr()
        print
        print testTnk.getSummary()