example_1.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
import sys
import os
from prism import *


vOxTank = 150000.0
vFlTank = 100000.0
vPropTanks = vOxTank + vFlTank
ptank = 300.0
PHeTnk=2000.0

Oxtank = Tank(name="Oxidizer Tank", makeCompositeTank=0, matlName="Ti",
    kacqui=4, tliner=0.030, vfree=vOxTank, ptank=ptank)
Fltank = Tank(name="Fuel Tank", makeCompositeTank=0,
    kacqui=4, tliner=0.030, vfree=vFlTank, ptank=ptank)

he = PressurantHe(name="Helium Pressurant",
    VpropTnk=vPropTanks,PHeTnk=PHeTnk,PpropNom=159.36,
    PfinHeOvPnom=1.0,
    tAction=433.94,TminR=510.0,TmaxR=550.0)

Hetank = Tank(name="Helium Tank",  makeCompositeTank=0,
   matlName="Ti", ptank=PHeTnk,
    tliner=0.030, vfree=he.volHeTotal)

def myControlRoutine(S):
    PHe    = S("PHe")
    he.PHeTnk =  PHe
    he.reCalc()
    Hetank.vfree = he.volHeTotal
    Hetank.ptank = PHe
    S.reCalcItems()
    
    S["sysMass"] = S.mass_lbm
    
Hetank.texture = Texture( colorName="Gray50" )
Oxtank.texture = Texture( colorName="Aquamarine" )
Fltank.texture = Texture( colorName="Pink" )

def myRenderControlRoutine(S):
    povItemL = []
    loc = 0.0
    for i,item in enumerate(S.items):
        povItem = item.getPOV_Item()
        if povItem:
            povItemL.append( povItem )
        
            if len(povItemL)>0:
                loc = loc + item.pov_w/2.0 + S.items[i-1].pov_w/2.0
                povItemL[-1].translate([loc,0.,0.])
        
        
    return povItemL

S = SysModel(author="I.B. Simpleton", name="simple system", type="trial baloon", 
    controlRoutine=myControlRoutine, renderControlRoutine=myRenderControlRoutine)
S.addMassItem( Oxtank )
S.addMassItem( Fltank )
S.addMassItem( he )
S.addMassItem( Hetank )

# design vars have: 
#     name, value, minVal, maxVal, step,  units,  description
S.addDesignVariable( name="PHe", InitialVal=3250.0, minVal=500.0, maxVal=10000.0, step=200.0,
                     units='psia', desc="Helium Tank MEOP")

# result variables have: 
#    name,      units,  description
S.addResultVars( ["sysMass", "lbm", "Total System Mass"] )


print S.getMassStr()
print
print S.getShortSummary()
#print Hetank.getSummary()

S.render()

#optimize(S, figureOfMerit="mass_lbm", desVars=["PHe"])
#print S.getShortSummary()
#print Hetank.getSummary()

make2DPlot(S, sysParam="sysMass", desVar="PHe")


S.close()