-
Notifications
You must be signed in to change notification settings - Fork 0
/
tools.py
235 lines (189 loc) · 6.72 KB
/
tools.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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
import numpy as np
from enum import Enum
class Propellant_Phase(Enum):
"""Records the phase of material in a tank"""
NONE = -1
SELF_PRESSURISING = 0
LIQUID = 1
class Pressurant_Name(Enum):
"""Records the pressurant uses"""
HELIUM = 0
NITROGEN = 1
CO2 = 2
class Propellant_Name(Enum):
"""Records the propellant used"""
NONE = -1
NITROUS = 0
IPA = 10
propellants = {
"nitrous-self-pressurised" : {
"phase": Propellant_Phase.SELF_PRESSURISING,
"prop_name": Propellant_Name.NITROUS,
"pressurant": None,
"propep_name": 'NITROUS OXIDE',
"octopus_name": ' nitrous oxide'
},
"nitrous-helium-pressurised" : {
"phase": Propellant_Phase.SELF_PRESSURISING,
"prop_name": Propellant_Name.NITROUS,
"pressurant": Pressurant_Name.HELIUM,
"propep_name": 'NITROUS OXIDE',
"octopus_name": ' nitrous oxide'
},
"ipa-helium-pressurised": {
"phase": Propellant_Phase.LIQUID,
"prop_name": Propellant_Name.IPA,
"pressurant": Pressurant_Name.HELIUM,
"propep_name": 'ISOPROPYL ALCOHOL',
"octopus_name": "isopropanol"
},
"none": {
"phase": Propellant_Phase.NONE,
"prop_name": Propellant_Name.NONE,
"pressurant": None,
"propep_name": 'NONE'
}
}
def nitrous_thermophys(temp):
"""Get N2O data at a given temperature.
Uses polynomials from ESDU sheet 91022. All units SI.
Returns:
- N2O liquid density
- vapour density
- liquid enthalphy
- vapour enthalpy
- latent heat of vaporization
- dynamic viscosity
- vapour pressure for input temperature
"""
if not 183.15 <= temp <= 309.57:
return None
#raise ValueError('nitrous oxide temperature out of data range')
# Some handy definitions
# ...I don't know what to call these properly
T0 = temp / 309.57
T0_RECIP = 1 / T0
T0_INV = 1 - T0
R = 8.314 / 44.013
lden = 452 * np.exp(+ 1.72328 * pow(T0_INV, 1/3)
- 0.83950 * pow(T0_INV, 2/3)
+ 0.51060 * T0_INV
- 0.10412 * pow(T0_INV, 4/3))
vden = 452 * np.exp(- 1.009000 * pow(T0_RECIP - 1, 1/3)
- 6.287920 * pow(T0_RECIP - 1, 2/3)
+ 7.503320 * (T0_RECIP - 1)
- 7.904630 * pow(T0_RECIP - 1, 4/3)
+ 0.629427 * pow(T0_RECIP - 1, 5/3))
hl = ((-200 + 116.043 * (T0_INV ** (1 / 3))+ -917.225 * (T0_INV ** (2 / 3))
+794.779 * T0_INV + -589.587 * (T0_INV ** (4 / 3))) * 1000)
hg = ((-200 + 440.055 * (T0_INV ** (1 / 3)) + -459.701 * ((1- (temp / 309.57)) ** (2 / 3))
+434.081 * T0_INV + -485.338 * (T0_INV ** (4 / 3))) * 1000)
cp_l = ((2.49973 * (1 + 0.023454 * (T0_INV ** (-1)) + -3.80136 * T0_INV
+ 13.0945 * (T0_INV ** 2) + -14.5180 * (T0_INV ** 3))) * 1000)
cp_g = (132.632 * (1 + (0.052187 * pow(T0_INV, (-2 / 3))) +
(-0.364923 * pow(T0_INV, (-1 / 3))) +
(-1.20233 * pow(T0_INV, ( 1 / 3))) +
(0.536141 * pow(T0_INV, ( 2 / 3))))) * 1000
vpres = 7251000 * (np.e **(T0_RECIP *
( -6.71893 * T0_INV) +
(1.35966 * pow(T0_INV, 1.5)) +
(-1.3779 * pow(T0_INV, 2.5)) +
(-4.051 * pow(T0_INV, 5))))
ldynvis = (0.0293423*np.e**((1.609*(((309.57-5.24)/(temp-5.24)-1)**(1/3)))
+(2.0439*(((309.57-5.24)/(temp-5.24)-1)**(4/3)))))
properties = {
"rho_l" : lden,
"rho_v" : vden,
"h_l" : hl,
"h_v" : hg,
"R" : R,
"cp_g" : cp_g,
"cv_g" : cp_g - R,
"cp_l": cp_l,
"cv_l": cp_l,
"vapour_pressure": vpres,
"dynamic_visc": ldynvis,
"v_l": (1/lden),
"v_v": (1/vden)
}
return(properties)
def nitrous_thermophys_dt(temp):
if not 183.15 <= temp <= 309.57:
raise ValueError('nitrous oxide temperature out of data range')
# Some handy definitions
# ...I don't know what to call these properly
T0 = temp / 309.57
T_crit = 309.57
T0_RECIP = 1 / T0
T0_INV = 1 - T0
nitrous_properties = nitrous_thermophys(temp)
vpres_dT = nitrous_properties["vapour_pressure"] * (((T_crit*(
(6.71893 / T_crit) +
((-2.03949 * pow(T0_INV, 0.5)) / T_crit) +
(((3.44475 * pow(T0_INV, 1.5)) / T_crit) +
(20.255 * pow(T0_INV, 4)) / T_crit))
/ temp)) -
((T_crit / pow(temp, 2)) * (
(-6.71893 * T0_INV) +
(1.35966 * pow(T0_INV, 1.5)) +
(-1.3779 * pow(T0_INV, 2.5)) +
(-4.051 * pow(T0_INV, 5))
)))
print(vpres_dT)
def ipa_thermophys(temp):
"""Get IPA data at a given temperature
Uses polynomials from a range of sources. All units SI
It would be really nice to get a hold of ESDU 89017 datasheet, alas he is expensive
Format is designed to match nitrous_thermophys, hence the range of empty /redundant valyes
Returns
- IPA liquid density
- vapour density (set at 0)
- liquid enthalphy
- vapour enthalpy (set at 0)
- latent heat of vaporization (set at 0)
- dynamic viscosity
- vapour pressure for input temperature
"""
R = 8.314 / 60.096
lden = 925.87 + (-0.0359 * temp) + (-0.0015 * temp**2)
# Fit for data obtained from http://www.ddbst.com/en/EED/PCP/DEN_C95.php
vden = 1e-7
hl = -247.1 + (-0.6133 * temp) + (0.0055 * temp**2)
# Fit for data obtained from https://pubs.acs.org/doi/10.1021/ie50466a033
hg = 0
cp_l = 212
cp_g = 0
vpres = 1000 * (20693 + (-119.57 * temp) + (0.1724 * temp**2))
# Fit for data obtained from http://www.ddbst.com/en/EED/PCP/VAP_C95.php
ldynvis = 22.397 * np.e ** (-0.031 * temp)
# Fit for data obtained from http://www.ddbst.com/en/EED/PCP/VIS_C95.php
properties = {
"rho_l" : lden,
"rho_v" : vden,
"h_l" : hl,
"h_v": hg,
"cp_g" : cp_g,
"cv_g" : cp_g - R,
"cp_l": cp_l,
"cv_l": cp_l,
"vapour_pressure": vpres,
"dynamic_visc": ldynvis,
"v_l": (1/lden),
"v_v": (1/vden)
}
return(properties)
def helium_thermophys(temp, pressure):
"""Gets helium data at a given temperature and pressure with ideal gas assumptions
Returns:
- gas density
- gas enthalpy
"""
R = 2080
vden = pressure / (R * temp)
hv = 5.19 * temp
properties = {
"rho_v" : vden,
"h_v" : hv,
"R" : R
}
return(properties)