# 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()