ValveScale.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
# Applied Python PRISM
# (PRISM) PaRametrIc System Model
#
# Written by Charlie Taylor <cet@appliedpython.com> 
# Oct,21 2005

from prism.MassItem import MassItem
from math import *
from prism.utils import Constants
from prism.props import Materials
from prism.Summary import Summary


class ValveScale( MassItem ):
    '''Scale a reference valve as the square root of volumetric flow rate'''
    
    def __init__(self, name="propellant valve",  ref_lbm=50.0, ref_cuInchPerSec=35000.0,
        cxw=1.0, cuInchPerSec=35000.0, Number=1):
        
        MassItem.__init__(self, name, type="inert")
        
        self.cxw = cxw
        self.cuInchPerSec = cuInchPerSec
        self.Number = Number
        
        self.ref_lbm =ref_lbm
        self.ref_cuInchPerSec =ref_cuInchPerSec
        
        self._warnCount = 0
        self.reCalc()
        
    def reCalc(self, autoCalc=1):
        self.autoCalc = autoCalc
        
        self.basemass = self.ref_lbm * sqrt( self.cuInchPerSec / self.ref_cuInchPerSec )
        
        self.mass_lbm = self.Number * self.basemass * self.cxw

    def buildSummary(self):
        
        summ = Summary(  summName='Valve',
            componentName=self.name, mass_lbm=self.mass_lbm, type=self.type)
        
        # assumptions
        summ.addAssumption( 'Based on scaling reference valve')
        
        if self.Number>1:
            summ.addAssumption( 'Mass is for %i valves total'%self.Number )
        
        # inputs
        summ.addInput('cuInchPerSec', self.cuInchPerSec, 'cuin/sec', '%g')
        
        summ.addInput('ref_lbm', self.ref_lbm, 'lbm', '%.3f')
        summ.addInput('ref_cuInchPerSec', self.ref_cuInchPerSec, 'cuin/sec', '%g')
        
        summ.addInput('cxw', self.cxw, '', '%.3f')
        
        # outputs
        summ.addOutput(  'basemass', self.basemass, 'lbm', '%.3f' )

        return summ

if __name__ == "__main__":  #self test

    h = ValveScale(name="315 lbf valve", cxw=1.0, cuInchPerSec=38.0)
    print 'Actual valve weighs 2.0 lbm'
    print h.getMassStr()
    print
    print h.getSummary()
    
    print '================================================================'

    h = ValveScale(name="100 lbf valve", cxw=1.0, cuInchPerSec=12.0)
    print 'Actual valve weighs 1.0 lbm'
    print h.getMassStr()
    print
    print h.getSummary()
    
    print '================================================================'

    h = ValveScale(name="20 lbf valve", cxw=1.0, cuInchPerSec=2.4)
    print 'Actual valve weighs 0.5 lbm'
    print h.getMassStr()
    print
    print h.getSummary()