Tank_PVOW.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
# 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
    

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

class Tank_PVOW( MassItem ):
    
    def __init__(self, name="tank",  mass_lbm=0.0,
        PVOW_inp = 0.5E6, MEOP_based=1,
        vfree=1000.0,ell=1.414,rcyltd=2.0,ptank=350.0,
        sf=1.5,cxw=1.0,  matlName="Ti",
        inpex=0,expefi=0.99, Number=1,
        tliner=0.0,rholiner=0.1):
            
        self.PVOW_inp = PVOW_inp
        self.MEOP_based = MEOP_based # if NOT based on MEOP, then use burst
        
        MassItem.__init__(self, name, type="inert", mass_lbm=mass_lbm)
        
        self.makeCompositeTank = 0
        self.kalmod = 0
        self.matlName = matlName
        self.rho, self.sy, self.e, self.tming = Materials.getMatlProps(self.matlName)
        
        self.Cp_eff = 0.15  # effective Cp of all tank materials combined
        
        self.Number = Number  # each tank has vfree
        self.vfree = vfree
        self.ell = ell
        self.rcyltd = rcyltd
        self.ptank = ptank
        self.sf = sf
        self.cxw = cxw
        self.ithcyl = 1
        self.kacqui = 0
        self.inpex = inpex
        self.expefi = expefi
        self.inpTblad = 1
        self.tblad = 0.0
        self.tbond = 0.0
        self.ttrspc = 0.0
        self.rhobnd = 0.04
        self.rhoacq = 0.1
        self.tliner = tliner
        self.rholiner = rholiner
        
        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.CSE_Tank( radius=self.OR, ellRatio=self.ell, cylLen=self.cyl, texture=texture)
        
        return s
        
    def setToMaxID(self, IDmax=100.0):
        
        self.rcyltd = 0.0
        self.reCalc()
        Rmax = IDmax / 2.0
        if self.rinsid > Rmax:
            Vd = 4.*pi*Rmax**3/3./self.ell
            L = (self.vtank-Vd)/pi/Rmax**2
            
            self.rcyltd = max(0.0,L/Rmax/2.0)
            self.reCalc()
        
    def setToLength(self, L=100.0):
        
        self.rcyltd = 0.0
        self.reCalc()
        
        # only try to make it L long by adding cylinder length
        if self.hinsid < L:
            V = self.vtank
            e = self.ell
            rmax = (V*e*3./4./pi)**(1./3.)
            rmin = sqrt( V/pi/L )
            for i in range(40):
                r = (rmin+rmax)/2.0
                Lcyl = L - 2.0*r/e
                Vtest = 4.*pi*r**3/3./e + pi*r**2*Lcyl
                if Vtest>V:
                    rmax = r
                else:
                    rmin = r
                    
            
            self.rcyltd = max(0.0,Lcyl/r/2.0)
            self.reCalc()

            
        
    def reCalc(self):
        
        default_cxw = 1.0

        self.rinsid,self.hinsid,self.cyl,self.wacqui,\
            self.vacqui,self.dpacq,self.pullag,self.vresid,\
            self.vtank,self.thkcyl,self.thkend,self.thkBladOut,self.wliner,self.wtank= \
            tank_eles.csetnk(self.makeCompositeTank,self.kalmod,
            self.sy,self.e,self.rho,self.tming,self.vfree,
            self.ell,self.rcyltd,self.ptank,self.sf,default_cxw,
            self.ithcyl,self.kacqui,self.inpex,self.expefi,
            self.inpTblad,self.tblad,self.tbond,self.ttrspc,
            self.rhobnd,self.rhoacq,self.tliner,self.rholiner)
        
        self.dinsid = 2.0*self.rinsid
        self.pov_h = self.cyl + self.dinsid/self.ell
        self.pov_w = self.dinsid
        self.pov_d = self.dinsid
        
        self.Across = pi * self.rinsid**2
        
        ECC=sqrt(1.-(1./self.ell)**2)
        HEADCO=pi/2.
        if self.ell>1.0:
            HEADCO=(pi/4.)*(1.+log((1.+ECC)/(1.-ECC))/(2.*ECC*self.ell**2))
        HSA = HEADCO*self.dinsid**2 
        self.SAinsid = pi*self.dinsid*self.cyl + 2.*HSA
        
        
        if self.thkcyl <= self.tming:
            self.Pburst = self.tming * self.sy / self.rinsid 
        else:
            self.Pburst = self.sf * self.ptank
            
        self.OD = 2.0* (self.rinsid + self.thkcyl + self.thkBladOut + self.tliner)
        self.OR = self.OD / 2.0
        
        self.OH = self.hinsid +  2.0* ( self.thkend + self.thkBladOut + self.tliner)

        
        if self.MEOP_based:
            self.wtank = self.cxw * self.ptank * self.vtank / self.PVOW_inp
        else:
            self.wtank = self.cxw * self.Pburst * self.vtank / self.PVOW_inp

        # if more than one tank, increase mass to reflect that
        self.mass_lbm = self.wtank * 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 minGaugeStr(self, t):
        if t<= self.tming:
            return 'Min Gauge'
        else:
            return ''
        
    def buildSummary(self):
        
        summ = Summary(  summName='Cylindrical/Spherical/Elliptical Tank',
        componentName=self.name, mass_lbm=self.mass_lbm, type=self.type)
        
        if self.MEOP_based:
            summ.addAssumption( 'PV/W is based on MEOP' )
        else:
            summ.addAssumption( 'PV/W is based on Burst Pressure' )
            
        if self.Number>1:
            summ.addAssumption( 'Mass is for %i Tanks total'%self.Number )
        
        
        # add inputs
        summ.addInput('PV/W input', self.PVOW_inp, 'lbf-in/lbm', '%g')
        summ.addInput('vfree', self.vfree, 'cuin', '%g')
        summ.addInput('vfreeTotal', self.vfree*self.Number, 'cuin', '%g')
        summ.addInput('ell', self.ell, '', '%g')
        summ.addInput('rcyltd', self.rcyltd, '', '%g')
        summ.addInput('ptank', self.ptank, 'psia', '%g')
        summ.addInput('sf', self.sf, '', '%g')
        summ.addInput('cxw', self.cxw, '', '%g')
        summ.addInput('inpex', self.inpex, '', '%g')
        summ.addInput('expefi', self.expefi, '', '%g')
        summ.addInput('tliner', self.tliner, 'in', '%.3f')
        summ.addInput('rholiner', self.rholiner, 'lbm/cuin', '%g')
        
        # add outputs

        summ.addOutput( 'rinsid', self.rinsid, 'in', '%.3f' )
        summ.addOutput( 'dinsid', self.dinsid, 'in', '%.3f' )
        summ.addOutput( 'hinsid', self.hinsid, 'in', '%.3f' )
        summ.addOutput( 'SAinsid', self.SAinsid, 'sqin', '%.3f' )
        summ.addOutput( 'cyl', self.cyl, 'in', '%.3f' )
        summ.addOutput( 'pullag', self.pullag, 'psia', '%g' )
        summ.addOutput( 'vresid', self.vresid, 'cuin', '%g' )
        summ.addOutput( 'vtank', self.vtank, 'cuin', '%g' )
            
        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 "X33 GOX Tank =", 3.703,"lbm"
    print "Calculated =   ",
    oxekv = Tank_PVOW(name="X33 GOX Tank", mass_lbm=179.4,
        PVOW_inp = 0.51E6, MEOP_based=1,
        vfree=18300.0,ell=1.767,rcyltd=1.445,
        ptank=5000.0,sf=1.5,cxw=1.0,
        inpex=1,expefi=0.98,
        tliner=0.03,rholiner=0.098)
    print oxekv.getMassStr()
    print
    print oxekv.getSummary()