ValveSolenoid.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
# 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 ValveSolenoid( MassItem ):
    
    def __init__(self, name="propellant valve",  
        cxw=1.0, cuInchPerSec=12.0, Number=1, isGas=0):
        
        MassItem.__init__(self, name, type="inert")
        
        self.cxw = cxw
        self.cuInchPerSec = cuInchPerSec
        self.Number = Number
        self.isGas = isGas
        self._warnCount = 0
        self.reCalc()
        
    def reCalc(self, autoCalc=1):
        self.autoCalc = autoCalc
        
        v = self.cuInchPerSec
        if self.isGas:
            # make the effective volume lower for gases (assume something like M=0.1 vs. 20 ft/sec)
            v = v/15.0
        
        if v > 70.0: # start linear extrapolation at XX ci/s
            #self.basemass = 2.4599732 + 0.01231274 * (v-60.0)
            self.basemass = 2.5454048 + 0.00477358 * (v-70.0)

            if self._warnCount < 5:
                print "Extrapolating Solenoid Valve Data"
                self._warnCount += 1
        else:
            self.basemass = -3.76958E-04 * v**2 + 5.75477E-02 * v + 3.64160E-01
        
        self.mass_lbm = self.Number * self.basemass * self.cxw

    def buildSummary(self):
        
        summ = Summary(  summName='Solenoid Valve',
            componentName=self.name, mass_lbm=self.mass_lbm, type=self.type)
        
        # assumptions
        summ.addAssumption( 'Based on Solenoid Valve Experience')
        
        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('cxw', self.cxw, '', '%.3f')
        
        # outputs
        summ.addOutput(  'basemass', self.basemass, 'lbm', '%.3f' )

        return summ

if __name__ == "__main__":  #self test

    h = ValveSolenoid(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 = ValveSolenoid(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 = ValveSolenoid(name="20 lbf valve", cxw=1.0, cuInchPerSec=2.4)
    print 'Actual valve weighs 0.5 lbm'
    print h.getMassStr()
    print
    print h.getSummary()