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

from math import *

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


class SimpleEqnMass( MassItem ):
    
    def __init__(self, name="Simple Mass", type="inert",  mass_lbm=0.0,  eqn="1.2*1.1", desc='mass = simple eqn'):
        
        MassItem.__init__(self, name, type=type)
        
        self.eqn = eqn
        self.desc = desc
        self.reCalc()
        
    def reCalc(self):
        self.mass_lbm = eval( self.eqn )

    def buildSummary(self):
        
        summ = Summary(  summName='Simple Equation Mass',
            componentName=self.name, mass_lbm=self.mass_lbm, type=self.type)
        
        # assumptions
        if len(self.desc)>0:
            summ.addAssumption(  self.desc )
        summ.addAssumption( 'Calc Wt from Eqn : ' + self.eqn )
        

        return summ

if __name__ == "__main__":  #self test

    h = SimpleEqnMass(name="Whatchamahoozits")
    print h.getMassStr()
    print
    print h.getSummary()