Line_Liq_inpD.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
# Applied Python PRISM
# (PRISM) PaRametrIc System Model
#
# Written by Charlie Taylor <cet@appliedpython.com> 
# Jan 2008

from math import *
import sys

from prism.MassItem import MassItem
from prism.props import Materials
from prism.Summary import Summary
from prism.props import Inc_liquid
from prism.fortran import orifice

class Line_Liq_inpD( MassItem ):
    
    def __str__(self):
        return self.name + ' wdot=%g lbm/sec'%self.wdot
    
    def __init__(self, name="liquid line", liqObj=None,  matlName="Ti", 
        wdot=0.1, pLine=400.0, OD=0.5, thkWall=0.045,
        len_inches=50.0, Kfactors=2.0,  Number=1,
        cxw=1.25, roughness=5.0E-6, mass_lbm=0.0 ):
            
        # default roughness (5.0E-6) is for drawn tubing
        
        MassItem.__init__(self, name, type="inert", mass_lbm=mass_lbm)
        
        self.liqObj = liqObj
        #if (liqObj is not Inc_liquid.Inc_liquid):
        #    print "ERROR...",name,"must have Inc_liquid object input for liqObj"
        #    sys.exit(1)
        
        self.Number = Number
        self.matlName = matlName
        self.rho, self.sy, self.e, self.tming = Materials.getMatlProps(matlName)
        
        
        self.OD=OD
        self.thkWall=thkWall
        
        self.wdot = wdot
        self.Kfactors = Kfactors
        self.roughness = roughness
        self.pLine = pLine
        self.len_inches = len_inches
        
        self.cxw = cxw
        
        self.reCalc()
        
    def reCalc(self, autoCalc=1):
        self.autoCalc = autoCalc

        self.Q = self.wdot / self.liqObj.rho
        
        self.ID = self.OD - 2.0*self.thkWall
        self.Ac = pi * self.ID**2 / 4.0
        self.velFPS = self.Q / (self.Ac * 12.0)
        
        self.rinsid = self.ID / 2.0
        self.dinsid = self.ID
        
        self.ReNum= self.liqObj.D * self.velFPS * \
            (self.dinsid/12.0) / (self.liqObj.Visc/1.0E5)  # liq Visc is in [lb/ft-sec * 1.0E5]
            
        
        self.volLine = pi * self.rinsid**2 * self.len_inches
        
        self.sf = self.thkWall * self.sy * 2.0 / self.pLine / self.dinsid
        
        self.dpLine = orifice.calcturbulenttubedp(self.len_inches ,\
            self.Kfactors, self.dinsid, self.wdot, self.liqObj.D, self.roughness,
            self.ReNum)
            
        self.deltaP = self.dpLine
        
        self.dPperVelHead = self.wdot**2 / (self.ID**4 * 0.27622 * self.liqObj.D)
        
        self.mass_lbm = pi * ((self.rinsid+self.thkWall)**2 - self.rinsid**2) *\
            self.len_inches * self.rho * self.cxw * self.Number
        
    
    def minGaugeStr(self, t):
        if t<= self.tming:
            return 'Min Gauge'
        else:
            return ''
        
    def buildSummary(self):
        
        summ = Summary(  summName='Liquid Line',
        componentName=self.name, mass_lbm=self.mass_lbm, type=self.type)
        
        summ.addAssumption( 'fluid : ' + self.liqObj.symbol )
        summ.addAssumption( 'Structural Material : ' + self.matlName )
        
        if self.Number>1:
            summ.addAssumption( 'Mass is for %i lines total'%self.Number )
        
        # add inputs
        summ.addInput('wdot', self.wdot, 'lbm/sec', '%g')
        summ.addInput( 'OD', self.OD, 'in', '%.3f' )
        summ.addInput( 'thkWall', self.thkWall, 'in', '%.3f' )
        summ.addInput('len_inches', self.len_inches, 'in', '%g')
        summ.addInput('Kfactors', self.Kfactors, 'vel heads', '%g')
        summ.addInput('roughness', self.roughness, 'in', '%g')
        summ.addInput('pLine', self.pLine, 'psia', '%g')
        summ.addInput('cxw', self.cxw, '', '%g')
        summ.addInput('# Lines', self.Number, '', '%i')
        
        # add outputs

        summ.addOutput( 'dpLine', self.dpLine, 'psid', '%.2f' )
        summ.addOutput( 'dPperVelHead', self.dPperVelHead, 'psid', '%.2f' )
        
        summ.addOutput('velFPS', self.velFPS, 'ft/sec', '%g')
        summ.addOutput( 'ReNum', self.ReNum, '', '%E' )
        summ.addOutput( 'rinsid', self.rinsid, 'in', '%.3f' )
        summ.addOutput( 'dinsid', self.dinsid, 'in', '%.3f' )
        summ.addOutput( 'volLine', self.volLine, 'cuin', '%g' )
        summ.addOutput( 'rho', self.rho, 'lbm/cuin', '%g' )
        summ.addOutput( 'sy', self.sy, 'psi', '%g' )
        summ.addOutput( '', '', '', '%s' )
        summ.addOutput('sf', self.sf, '', '%g')
        summ.addOutput( 'tming', self.tming, 'in', '%.3f' )
        summ.addOutput( 'fluid rho', self.liqObj.rho, 'lbm/cuin', '%g' )
        summ.addOutput( 'fluid visc', self.liqObj.Visc, '1.0E5 * lb/ft-sec', '%g' )
        if self.Number>1:
            summ.addOutput( 'wt/Line', self.mass_lbm/self.Number, 'lbm', '%.3f' )

        return summ


if __name__ == "__main__":  #self test


    Fl = Inc_liquid.Inc_liquid( symbol="MMH",T=530.0,P=240.0, mass_lbm=10.0)
    Ox = Inc_liquid.Inc_liquid( symbol="N2O4",T=530.0,P=240.0, mass_lbm=10.0)
        
    wdotFl = 7.6*.447
    h = Line_Liq_inpD(name="Fuel Line",wdot=wdotFl, liqObj=Fl, matlName="Ti", 
        pLine=400.0, OD=1.5, thkWall=0.03,
        len_inches=10.0, Kfactors=2.0,  Number=1,
        cxw=1.25, roughness=5.0E-6, mass_lbm=0.0)
    print h.getMassStr()
    print
    print h.getSummary()
        

    wdotOx = 14.2*.3655
    
    h = Line_Liq_inpD(name="Oxidizer Line", liqObj=Ox ,wdot=wdotOx, matlName="Ti", 
        pLine=400.0, OD=1.5, thkWall=0.03,
        len_inches=10.0, Kfactors=2.0,  Number=1,
        cxw=1.25, roughness=5.0E-6, mass_lbm=0.0)
    print h.getMassStr()
    print
    print h.getSummary()