Tank_Torus.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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
# 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.fortran import tank_eles
from prism.props import Materials
from prism.Summary import Summary
from prism.pov import POV_Items, POV_Basics
from prism.utils.Goal import Goal


# comments from the ELES tank routine
'''
C   this subroutine calculates the geometry of a torus and
C its associated weights
C
C INPUT
C   KALMOD-CALCULATION MODE (0=INPUT RRAD, 1=INPUT RHUB)
C   TNKTMP-TEMPERATURE OF TANK MATERIAL(EG. MAX PROPELLANT TEMP)
C   VFREE-total free volume
C   RRAD-ratio of large radius to small internal radius
C        (MAY BE INPUT OR OUTPUT)
C   PPROP-tank pressure
C   MATFLG-material flag
C   SF-safety factor
C   CXW-tank weight multiplier (bosses welds etc.)
C   ITHTOR-torus thickness flag(0=variable thickness,1=constant)
C   KACQUI-kind of acquisition device flag(0=none,1=transverse collapsin
C          Alum. bladder,2=full bonded rolling diaphram(BRD) Al,3=half
C          BRD Al,4=full BRD stainless steel,5=half BRD ss,6=capillary
C          device)
C   INPEX-input expulsion efficiency flag(0=calculate eff,1=input)
C   EXPEFI-input expulsion efficiency
C   TBLAD-bladder thickness(in)(0<KACQUI<6)
C   TBOND-bond thickness(in)(1<KACQUI<6)
C   TTRSPC-transverse collapsing bladder initial space distance(in)
C          (KACQUI=1)
C   RHOBND-density of bonding material (lbm/in**3)(1<KACQUI<6)
C   RHOACQ-density of acquisition device(lbm/in**3)(KACQUI=6)
C OUTPUT
C   Rminor-small inner radius
C   RHUB-larger external radius  (MAY BE INPUT OR OUTPUT)
C   THKMIN-minimum thickness for a variable wall torus
C   THKMAX-maximum thickness for variable wall torus or the thickness
C          of a constant wall torus
C   WTANK-torus weight
C   TMING-minimum guage of material chosen
C   WACQUI-weight of acquisition device (lbm)
C   VACQUI-displacement volume of acquisition device (lbm)
C   DPACQ-pressure drop across acquisition device (psia)
C   PULLAG-ullage pressure (psia)
C   VRESID-residual propellant volume (in**3)
C   VTANK-total tank volume(in**3)
C'''


acq_dict = {0:'no acq. device',1:'transverse collapsing Alum. bladder',
    2:'full bonded rolling diaphram(BRD) Al',3:'half BRD Al',
    4:'full BRD stainless steel',5:'half BRD ss',6:'capillary device',
    7:'elastomeric transverse bladder (dP=0)',
    8:'Titanium transverse collapsing'}


class Tank_Torus( MassItem ):
    
    def __init__(self, name="toroidal_tank",  mass_lbm=0.0,
        makeCompositeTank=0, matlName="Ti",  
        RmajorOverRminor=3.0, RmajorInput=None, RminorInput=None,
        tMinGaugeUser=0.0,
        vfree=1000.0,ptank=350.0,
        sf=1.5,cxw=1.25,  NumExtraBaffles=0,
        kacqui=0,inpex=0,expefi=0.99, Number=1,
        inpTblad=1, tblad=0.030,tbond=0.030,ttrspc=0.010,
        rhobnd=0.04,rhoacq=0.28,tliner=0.0,rholiner=0.1):
        
        MassItem.__init__(self, name, type="inert", mass_lbm=mass_lbm)
        
        self.name = name
        self.mass_lbm = mass_lbm
        self.makeCompositeTank = makeCompositeTank
        
        self.matlName = matlName
        self.tMinGaugeUser = tMinGaugeUser
        self.vfree = vfree
        self.RmajorOverRminor = RmajorOverRminor
        
        # these may be == None
        self.RmajorInput = RmajorInput
        self.RminorInput = RminorInput
        if RmajorInput or RminorInput:
            self.inputRRatio = 0
        else:
            self.inputRRatio = 1
            
        
        self.ptank = ptank
        self.sf = sf
        self.cxw = cxw
        self.NumExtraBaffles = NumExtraBaffles
        self.kacqui = kacqui
        self.inpex = inpex
        self.expefi = expefi
        self.Number = Number
        self.inpTblad = inpTblad
        self.tblad = tblad
        self.tbond = tbond
        self.ttrspc = ttrspc
        self.rhobnd = rhobnd
        self.rhoacq = rhoacq
        self.tliner = tliner
        self.rholiner = rholiner
        self.rho, self.sy, self.e, self.tming = Materials.getMatlProps(matlName)
        
        if tMinGaugeUser> self.tming:
            self.tming = tMinGaugeUser

        self.reCalc()
        
    def getPOV_Item(self):
        if hasattr( self, 'texture'):
            texture = self.texture
        else:
            from POV import POV_Basics
            texture = POV_Basics.Texture( colorName="Gray50" )
        s = POV_Items.Torus( rmajor=self.Rmajor, rminor=self.ORminor, texture=texture)
        
        return s
            

    def setToMaxOD(self, ODmax=10.0, RORmin=1.1, RORmax=100.0):
        
        for i in range(40):
            ROR = (RORmin + RORmax)/2.0
            self.RmajorOverRminor = ROR
            self.Rminor = (self.vfree/(2.*pi**2*self.RmajorOverRminor))**(1./3.)
            self.Rmajor = self.Rminor * self.RmajorOverRminor
            self.RmajorInput = self.Rmajor
            self.RminorInput = self.Rminor
            self.reCalc()

            if self.OD > ODmax:
                RORmax = ROR
            else:
                RORmin = ROR
        self.reCalc()

    def reCalc(self):


        if self.inputRRatio:
            self.Rminor = (self.vfree/(2.*pi**2*self.RmajorOverRminor))**(1./3.)
            self.Rmajor = self.Rminor * self.RmajorOverRminor
        else:
            if self.RmajorInput:
                self.Rmajor = self.RmajorInput
                self.Rminor = sqrt(self.vfree/2./pi**2/self.Rmajor)
                self.RmajorOverRminor = self.Rmajor / self.Rminor
            else :
                self.Rminor = self.RminorInput
                self.Rmajor = self.vfree/2./pi**2/self.Rminor**2
                self.RmajorOverRminor = self.Rmajor / self.Rminor
        
        self.Across = pi * self.Rminor**2
        
        self.SAinsid = 4.*pi**2*self.Rminor*self.Rmajor
        
        if self.NumExtraBaffles > 0:
            self.WtExtraBaffles = pi * self.Rminor**2 * self.tming * self.rho * self.NumExtraBaffles
        else:
            self.WtExtraBaffles = 0.0
            
        # calc acquisition device params
        self.getWtAquiDevice()
        self.vliner=self.SAinsid*self.tliner
        self.wliner=self.vliner*self.rholiner
        
        # THKMIN only used in variable wall thickness model
        #THKMIN=self.sf*(self.pullag*self.Rminor/self.sy)*(2.*self.Rmajor+self.Rminor)/(2.*(self.Rmajor+self.Rminor))
        #THKMIN=max(THKMAX,self.tming)
        
        THKMAX=self.sf*(self.pullag*self.Rminor/self.sy)*(2.*self.Rmajor-self.Rminor)/(2.*self.Rmajor-2.*self.Rminor)
        THKMAX=max(THKMAX,self.tming)
        
        self.thkwall = THKMAX
        
        #C  CALCULATE JOINT REINFORCEMENT WEIGHT
        DAVE=2.*(self.Rmajor+self.Rminor)
        self.wtJoints=0.5*6.664*DAVE**1.5*self.thkwall*sqrt(self.thkwall)*self.rho
        
        # assume constant wall thickness torus
        self.wtank= self.wtJoints + self.SAinsid*self.thkwall*self.rho + self.wliner
        
        # calc total mass
        self.mass_lbm = (self.wtank + self.wacqui ) * self.cxw   + self.WtExtraBaffles

        if self.thkwall <= self.tming:
            self.Pburst = self.tming * self.sy / self.Rminor 
        else:
            self.Pburst = self.sf * self.ptank
        
        self.dinsid = 2.0*self.Rminor
        self.pov_h = 2.0*self.Rminor
        self.pov_w = 2.0*self.Rmajor
        self.pov_d = 2.0*self.Rmajor
            
        self.OD = 2.0* (self.Rminor + self.Rmajor + self.thkwall + self.thkBladOut + self.tliner + self.tbond)
        
        
        self.ORminor = self.Rminor + self.thkwall + self.thkBladOut + self.tliner + self.tbond
        
        self.OH = 2.0* (self.Rminor + self.thkwall + self.thkBladOut + self.tliner + self.tbond)

        # 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

    def getWtAquiDevice(self):
        default_cxw = 1.0
        rinsid,hinsid,cyl,self.wacqui,\
            self.vacqui,self.dpacq,self.pullag,self.vresid,\
            self.vtank,thkcyl,thkend,self.thkBladOut,self.wliner,wtank= \
            tank_eles.csetnk(self.makeCompositeTank,0,
            self.sy,self.e,self.rho,self.tming,self.vfree,
            1.4,1.0,self.ptank,self.sf,default_cxw,
            1,self.kacqui,self.inpex,self.expefi,
            self.inpTblad,self.tblad,self.tbond,self.ttrspc,
            self.rhobnd,self.rhoacq,self.tliner,self.rholiner)
        

    def minGaugeStr(self, t):
        if t<= self.tming:
            return 'Min Gauge'
        else:
            return ''
        
    def buildSummary(self):
        
        summ = Summary(  summName='Torroidal Tank',
        componentName=self.name, mass_lbm=self.mass_lbm, type=self.type)
        
        
        if self.makeCompositeTank:
            summ.addAssumption('Composite Tank')
        else:
            summ.addAssumption('Metal Tank')
            summ.addAssumption('Structural Material : ' + self.matlName )
            
        if self.NumExtraBaffles > 0:
            summ.addAssumption("%i Extra Baffles are added to tank"%self.NumExtraBaffles)
            
        if self.kacqui in [1,2,3,4,5]:
            if self.inpTblad:
                summ.addAssumption('Bladder Thickness is input at %.3f in'%self.tblad)
            else:
                summ.addAssumption('Bladder Thickness is calculated at %.3f in'%self.tblad)
            
        if self.inputRRatio:
            summ.addAssumption('Rmajor/Rminor = %.3f'%self.RmajorOverRminor  )
        elif self.RmajorInput:
            summ.addAssumption('Rmajor = %.3f'%self.RmajorInput )
        elif self.RminorInput:
            summ.addAssumption('Rminor = %.3f'%self.RminorInput  )
            
        if self.Number>1:
            summ.addAssumption( 'Mass is for %i Tanks total'%self.Number )
        
        
        # add inputs
        summ.addInput('vfree', self.vfree, 'cuin', '%g')
        summ.addInput('vfreeTotal', self.vfree*self.Number, 'cuin', '%g')
        
        summ.addInput('RmajorOverRminor', self.RmajorOverRminor, '', '%g')
        summ.addInput('ptank', self.ptank, 'psia', '%g')
        summ.addInput('sf', self.sf, '', '%g')
        summ.addInput('cxw', self.cxw, '', '%g')
        
        summ.addInput('kacqui', self.kacqui, acq_dict[self.kacqui], '%s')
        summ.addInput('inpex', self.inpex, '', '%g')
        summ.addInput('expefi', self.expefi, '', '%g')
        summ.addInput('tblad', self.tblad, 'in', '%.3f')
        summ.addInput('tbond', self.tbond, 'in', '%.3f')
        summ.addInput('ttrspc', self.ttrspc, 'in', '%.3f')
        summ.addInput('rhobnd', self.rhobnd, 'lbm/cuin', '%g')
        summ.addInput('rhoacq', self.rhoacq, 'lbm/cuin', '%g')
        summ.addInput('tliner', self.tliner, 'in', '%.3f')
        summ.addInput('rholiner', self.rholiner, 'lbm/cuin', '%g')
        
        # add outputs

        summ.addOutput( 'Rminor', self.Rminor, 'in', '%.3f' )
        summ.addOutput( 'Rmajor', self.Rmajor, 'in', '%.3f' )
        summ.addOutput( 'OD', self.OD, 'in', '%.3f' )
        summ.addOutput( 'OH', self.OH, 'in', '%.3f' )
        summ.addOutput( 'SAinsid', self.SAinsid, 'sqin', '%.3f' )
        
        summ.addOutput( 'wacqui', self.wacqui, 'lbm', '%.3f' )
        summ.addOutput( 'vacqui', self.vacqui, 'cuin', '%g' )
        summ.addOutput( 'dpacq', self.dpacq, 'psig', '%g' )
        summ.addOutput( 'pullag', self.pullag, 'psia', '%g' )
        summ.addOutput( 'vresid', self.vresid, 'cuin', '%g' )
        summ.addOutput( 'vtank', self.vtank, 'cuin', '%g' )
        summ.addOutput( 'thkwall', self.thkwall, 'in', '%.3f' )
        
        summ.addOutput( 'thkBladOut', self.thkBladOut, 'in', '%.3f' )
        if self.NumExtraBaffles > 0:
            summ.addOutput( 'WtExtraBaffles', self.WtExtraBaffles, 'lbm', '%.3f' )
            
        
        summ.addOutput( 'wtJoints', self.wtJoints, 'lbm', '%.3f' )
            
        if self.wliner > 0.0:
            summ.addOutput( 'wliner', self.wliner, 'lbm', '%.3f' )
            summ.addOutput( 'wtank(+liner)', self.wtank, 'lbm', '%.3f' )
        else:
            summ.addOutput( 'wtank', self.wtank, 'lbm', '%.3f' )
            
        summ.addOutput( 'rho', self.rho, 'lbm/cuin', '%g' )
        if not self.makeCompositeTank:
            summ.addOutput( 'sy', self.sy, 'psi', '%g' )
            summ.addOutput( 'e', self.e, 'psi', '%g' )
            summ.addOutput( 'tming', self.tming, 'in', '%.3f' )
        summ.addOutput( 'PmeopVoverW', self.PVoverW, 'lbf-in/lbm', '%g' )
        summ.addOutput( 'Pburst(est.)', self.Pburst, 'psia', '%.1f' )
        summ.addOutput( 'PburstVoverW', self.PburstVoverW, 'lbf-in/lbm', '%g' )

        return summ


if __name__ == "__main__":  #self test

    print "IF EKV Prop Tank were a Torus?????? =", 3.703,"lbm"
    print "Calculated =   ",
    oxekv = Tank_Torus(name="EKV Propellant Tank", mass_lbm=3.703,
        makeCompositeTank=1, 
        matlName="grEpox",   vfree=486.0,RmajorOverRminor=3.0,
        ptank=1400.0,sf=1.5,cxw=1.5,
        kacqui=1,inpex=1,expefi=0.98,
        tblad=0.030,tbond=0.030,ttrspc=0.010,
        rhobnd=0.04,rhoacq=0.098,tliner=0.03,rholiner=0.098)
    print oxekv.getMassStr()
    print
    print oxekv.getSummary()