Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

from __future__ import print_function 

 

'''If CEA gives back Isp==0, then try to estimate it.''' 

""" 

 

----------------------- 

biprop_utils 

Copyright (C) 2015 Charlie Taylor 

 

This program is free software: you can redistribute it and/or modify 

it under the terms of the GNU General Public License as published by 

the Free Software Foundation, either version 3 of the License, or 

(at your option) any later version. 

 

This program is distributed in the hope that it will be useful, 

but WITHOUT ANY WARRANTY; without even the implied warranty of 

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

GNU General Public License for more details. 

 

You should have received a copy of the GNU General Public License 

along with this program. If not, see <http://www.gnu.org/licenses/>. 

 

----------------------- 

__author__ = 'Charlie Taylor' 

__copyright__ = 'Copyright (c) 2015 Charlie Taylor' 

__license__ = 'GPL-3' 

__email__ = "cet@appliedpython.com" 

 

""" 

def make_cea_ode_est(cea_ispObj, Pc=100.0, MR=1.0, eps=40.0): 

 

# Got here if simple call did not work  

# Try averaging a high and low Pc 

pc_hi = Pc * 1.05 

pc_lo = Pc * 0.95 

 

ispODE_hi = cea_ispObj.get_Isp( Pc=pc_hi, MR=MR, eps=eps) 

ispODE_lo = cea_ispObj.get_Isp( Pc=pc_lo, MR=MR, eps=eps) 

 

# If both look good, take the average 

if ispODE_hi>0.1 and ispODE_lo>0.1: 

ispODE = (ispODE_hi+ispODE_lo)/2.0 

else: 

# hope there's a good one (Is hope a plan?) 

ispODE = max(ispODE_hi, ispODE_lo) 

print( 'WARNING... make_cea_ode_est is returning max of hi and low =',ispODE ) 

 

print( 'Estimated CEA_Isp at Pc=%g, MR=%g, eps=%g'%(Pc, MR, eps),'ispODE%g'%ispODE ) 

return ispODE 

 

def make_cea_odf_est(cea_ispObj, Pc=100.0, MR=1.0, eps=40.0): 

 

# Got here if simple call did not work  

# Try averaging a high and low Pc 

pc_hi = Pc * 1.05 

pc_lo = Pc * 0.95 

 

ispFroz_hi,cstrODE,tcODE = cea_ispObj.getFrozen_IvacCstrTc( Pc=pc_hi, MR=MR, eps=eps, frozenAtThroat=0) 

ispFroz_lo,cstrODE,tcODE = cea_ispObj.getFrozen_IvacCstrTc( Pc=pc_lo, MR=MR, eps=eps, frozenAtThroat=0) 

 

# If both look good, take the average 

if ispFroz_hi>0.1 and ispFroz_lo>0.1: 

ispFroz = (ispFroz_hi+ispFroz_lo)/2.0 

else: 

# hope there's a good one (Is hope a plan?) 

ispFroz = max(ispFroz_hi, ispFroz_lo) 

if ispFroz <= 0.1: 

print( "Searching...", end='') 

for i_hope in range(18): 

if ispFroz <= 0.1: 

print( ".", end='') 

pc_hi *= 1.1 

pc_lo *= 0.9 

 

ispFroz_hi,cstrODE,tcODE = cea_ispObj.getFrozen_IvacCstrTc( Pc=pc_hi, MR=MR, eps=eps, frozenAtThroat=0) 

ispFroz_lo,cstrODE,tcODE = cea_ispObj.getFrozen_IvacCstrTc( Pc=pc_lo, MR=MR, eps=eps, frozenAtThroat=0) 

ispFroz = max(ispFroz_hi, ispFroz_lo) 

if ispFroz <= 0.1: 

print( "_NOT_FOUND_") 

print( 'Estimated CEA_Isp Frozen at Pc=%g, MR=%g, eps=%g'%(Pc, MR, eps),'ispFroz=%g'%ispFroz) 

else: 

print('') 

 

#print( 'Estimated CEA_Isp Frozen at Pc=%g, MR=%g, eps=%g'%(Pc, MR, eps),'ispFroz=%g'%ispFroz) 

return ispFroz 

 

 

def run_cea_ode(cea_ispObj, Pc=100.0, MR=1.0, eps=40.0): 

 

ispODE = cea_ispObj.get_Isp( Pc=Pc, MR=MR, eps=eps) 

 

if ispODE > 0.1: # i.e. it's probably OK 

return ispODE 

else: 

return make_cea_ode_est(cea_ispObj, Pc=Pc, MR=MR, eps=eps) 

 

def run_cea_odf(cea_ispObj, Pc=100.0, MR=1.0, eps=40.0): 

 

ispFroz,cstrODE,tcODE = cea_ispObj.getFrozen_IvacCstrTc( Pc=Pc, MR=MR, eps=eps, frozenAtThroat=0) 

 

if ispFroz > 0.1: # i.e. it's probably OK 

return ispFroz 

else: 

return make_cea_odf_est(cea_ispObj, Pc=Pc, MR=MR, eps=eps) 

 

def run_all_cea(cea_ispObj, Pc=100.0, MR=1.0, eps=40.0): 

 

ispFroz,cstrODE,tcODE = cea_ispObj.getFrozen_IvacCstrTc( Pc=Pc, MR=MR, eps=eps, frozenAtThroat=0) 

if ispFroz < 0.1: # try a guess 

ispFroz = make_cea_odf_est(cea_ispObj, Pc=Pc, MR=MR, eps=eps) 

 

ispODE = run_cea_ode(cea_ispObj, Pc=Pc, MR=MR, eps=eps) 

 

return ispODE, ispFroz, cstrODE, tcODE 

 

if __name__=="__main__": 

 

from rocketcea.cea_obj import CEA_Obj 

 

cea_ispObj = CEA_Obj(oxName='LOX', fuelName='LH2') 

 

for pc,mr,eps in [(100.,1.0,40),(100.,2.0,40),(400.,1.2453509339,32.),(400.,2.5,32.)]: 

 

isp_ode = run_cea_ode(cea_ispObj, Pc=pc, MR=mr, eps=eps) 

isp_odf = run_cea_odf(cea_ispObj, Pc=pc, MR=mr, eps=eps) 

isp_est = make_cea_ode_est(cea_ispObj, Pc=pc, MR=mr, eps=eps) 

isp_froz_est = make_cea_odf_est(cea_ispObj, Pc=pc, MR=mr, eps=eps) 

print( ' isp_ode =',isp_ode) 

print( ' isp_odf =',isp_odf) 

print( ' isp_est =',isp_est) 

print( 'isp_froz_est =',isp_froz_est) 

print('') 

 

 

ispODE, ispFroz, cstrODE, tcODE = run_all_cea(cea_ispObj, Pc=100.0, MR=6.0, eps=40.0) 

print('Run All:', ispODE, ispFroz, cstrODE, tcODE)