eng_Ptank_vs_mr.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
from prism import *
from prism.isp import off_mr

S = SysModel(name="Engine Pc/MR Study", type="analysis", 
    author="O.F. Design")

# set design constants from common Constants values

# add design variables to the system (these variables may be used to
# optimize the system or to create plots)
# design vars have: 
#     name, value, minVal, maxVal, step,  units,  description
S.addDesVars(
    ["PengInOx",277.7, 250.0, 350.0, 5.0, 'psia', 'Ox Engine Inlet Pressure'],
    ["PengInFuel",286.0, 250.0, 350.0, 5.0, 'psia', 'Fuel Engine Inlet Pressure'],
    )

# now add any Result Variables That might be plotted
# result variables have: 
#    name,      units,  description
S.addResultVars(
    ["sysMass", "lbm", "Total System Mass"],
    ["Pc", "psia", "Chamber Pressure"],
    ["MR", "", "Mixture Ratio"],
    ["Fvac", "lbf", "Vacuum Thrust"],
    )

RefEng =  off_mr.RefEngine()

# the following control routine ties together the system components
#  with the system design variables
def myControlRoutine(S):
    # get current values of design variables    
    PengInOx,PengInFuel = S("PengInOx","PengInFuel")
    
    Pc,MR = RefEng.solvePcMR_GivenPfeed(PengInOx,PengInFuel)
    Fvac = RefEng.calcThrustForPcMR( Pc, MR)

    S.reCalc()

    S["sysMass"] = S.mass_lbm
    S["Pc"] = Pc
    S["MR"] = MR
    S["Fvac"] = Fvac

# need to tell system the name of the control routine
S.setControlRoutine(myControlRoutine)

S.reCalcItems()
#S.saveShortSummary()

#make2DPlot(S, sysParam="Pc", desVar="PengInOx")
dpi = 100
make2DParametricPlot(S, sysParam="MR", desVar="PengInOx",
    paramVar=["PengInFuel",250.0,275.0,300.0,325.,350.]  ,makeHTML=1, dpi=dpi,
    ptData=[[277.7],[1.85]], ptLegend='Design Point', logX=0, logY=0)
    
make2DParametricPlot(S, sysParam="Pc", desVar="PengInOx",
    paramVar=["PengInFuel",250.0,275.0,300.0,325.,350.]  ,makeHTML=1, dpi=dpi,
    ptData=[[277.7,277.7],[150.,150.]], ptLegend='Design Point', logX=0, logY=0)
    
make2DParametricPlot(S, sysParam="Fvac", desVar="PengInOx",
    paramVar=["PengInFuel",250.0,275.0,300.0,325.,350.]  ,makeHTML=1, dpi=dpi,
    ptData=[[277.7,277.7],[7500.,7500.]], ptLegend='Design Point', logX=0, logY=0)
    

makeContourPlot(S, sysParam="MR", desVars=["PengInOx","PengInFuel"], interval=0.05, dpi=dpi)
makeContourPlot(S, sysParam="Pc", desVars=["PengInOx","PengInFuel"], interval=2.0, dpi=dpi)
makeContourPlot(S, sysParam="Fvac", desVars=["PengInOx","PengInFuel"],  dpi=dpi)

# now save summary of system
S.saveFullSummary()

# Be sure to wrap-up any files
S.close()