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