-
Notifications
You must be signed in to change notification settings - Fork 2
/
temperature_model.py
283 lines (235 loc) · 24.7 KB
/
temperature_model.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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
import math
from spacecraft_model import atmosphere_model
import plotly.graph_objects as go
from plotly.subplots import make_subplots
import numpy as np
from numba import jit, njit
from scipy.stats import pearsonr
# Constants
C = 100 # example constant value, should be updated based on the geometry and flow regime
STAG_K = 1.83e-4 # Stagnation point heat transfer coefficient (W/m^2-K^0.5)
RATIO_OF_SPECIFIC_HEATS = 1.4
AIR_GAS_CONSTANT = 287.058
# assumptions
K_REF = 0.02476 # W/m·K (reference thermal conductivity at 15ºC or 288.15K)
T_REF = 288.15 # K (reference temperature)
S = 110.4 # K (Sutherland's constant)
RHO_REF = 1.225 # kg/m³ (reference density at 15ºC or 288.15K)
STEFAN_BOLTZMANN_CONSTANT = 5.670374419e-8 # W/m²·K⁴ (Stefan-Boltzmann constant)
# materials with name, lorentz number, density, specific heat, melting point, and emissivity
MATERIALS = {
"Aluminum": {
'thermal_conductivity': 237, # W/m*K
'specific_heat_capacity': 903, # 0.94 J/kg*K
'emissivity': 0.1,
'ablation_efficiency': 0.1 # (assumed)
},
"Copper": {
'thermal_conductivity': 401, # W/m*K
'specific_heat_capacity': 385, # 0.39 J/kg*K
'emissivity': 0.03,
'ablation_efficiency': 0.1 # (assumed)
},
'PICA': {
'thermal_conductivity': 0.167, # W/m*K
'specific_heat_capacity': 1260, # 0.094 J/kg*K
'emissivity': 0.9,
'ablation_efficiency': 0.7 # (assumed)
},
"RCC": {
'thermal_conductivity': 7.64, # W/m*K
'specific_heat_capacity': 1670, # 1.67 J/kg*K
'emissivity': 0.5,
'ablation_efficiency': 0.99 # completely ablates (assumed)
},
"Cork": {
'thermal_conductivity': 0.043, # W/m*K
'specific_heat_capacity': 2100, # 2.01 J/kg*K
'emissivity': 0.7,
'ablation_efficiency': 0.3 # (assumed)
},
"InconelX": {
'thermal_conductivity': 35.3, # W/m*K
'specific_heat_capacity': 540, # 0.54 kJ/kg*K
'emissivity': 0.2,
'ablation_efficiency': 0.1 # (assumed)
},
"Alumina enhanced thermal barrier rigid tile": {
'thermal_conductivity': 0.064, # W/m*K
'specific_heat_capacity': 630, # 0.63 kJ/kg*K
'emissivity': 0.9,
'ablation_efficiency': 0.7 # (assumed)
},
}
# a common function to calculate the heat transfer coefficient
#@jit(nopython=True)
def heat_transfer(v,ablation_efficiency, T_s, atmo_T, thermal_conductivity, capsule_length, emissivity,spacecraft_m, a_drag, specific_heat_capacity, dt):
drag_force = spacecraft_m * a_drag
# Calculate work done (W) using the drag force and change in velocity (dv)
W = drag_force * v_norm
# Calculate the heat generated (Q) from the work done (W) and the ablation efficiency factor
Q = ablation_efficiency * W
Qc = thermal_conductivity * (T_s - atmo_T) / capsule_length
Qr = emissivity * STEFAN_BOLTZMANN_CONSTANT * (T_s**4 - atmo_T**4)
Q_net = Q - Qc - Qr
dT = Q_net / (spacecraft_m * specific_heat_capacity) * dt
return Qc, Qr, Q_net, Q, T_s, dT
# @jit(nopython=True)
def spacecraft_temperature(v, atmo_T, a_drag, capsule_length, dt, thermal_conductivity ,specific_heat_capacity, emissivity, ablation_efficiency, iter_fact=2, spacecraft_m=500):
# Initialize the spacecraft temperature to the atmospheric temperature
T_s = atmo_T
dt = int(dt / iter_fact)
iterations = dt
for _ in range(iterations):
# Calculate radiative heat transfer (Qr) using the emissivity of the heat shield material and the Stefan-Boltzmann constant (sigma)
Qc, Qr, Q_net, Q, T_s, dT = heat_transfer(v,ablation_efficiency, T_s, atmo_T, thermal_conductivity, capsule_length, emissivity,spacecraft_m, a_drag, specific_heat_capacity, dt)
# Update the spacecraft temperature (T_s) by adding the temperature change (dT) to the current temperature
T_s += dT
return Qc, Qr, Q_net, Q, T_s, dT
Cd = 1.4 # (drag coefficient)
spacecraft_area = 1 # m² (reference area)
epoch_jd = 2459270.5
v_norms = [ 7540.0, 7542.958643821361, 7545.939261893025, 7548.94153811717, 7551.9651523877055, 7555.009780673242, 7558.07509584061, 7561.160766814818, 7564.266458122529, 7567.391830971209, 7570.536542426172, 7573.700246605868, 7576.882593868851, 7580.083229927942, 7583.30179743495, 7586.5379343903305, 7589.791275846661, 7593.061453947109, 7596.348096907371, 7599.650827957564, 7602.969267120278, 7606.303030910372, 7609.651731600936, 7613.014979309466, 7616.392380948224, 7619.783539128381, 7623.188051030233, 7626.605511798554, 7630.0355127686225, 7633.477641055429, 7636.931482055717, 7640.396618337003, 7643.872628475694, 7647.359085846252, 7650.855559334661, 7654.361618299436, 7657.876825130269, 7661.400740876019, 7664.932924783595, 7668.4729330914515, 7672.020317766554, 7675.574625186882, 7679.135398811355, 7682.70218271991, 7686.2745137326965, 7689.85192824649, 7693.433961278744, 7697.020145183736, 7700.610008304678, 7704.203073563935, 7707.798859987705, 7711.396890127897, 7714.996678101426, 7718.597737844604, 7722.199582833736, 7725.801724749697, 7729.403672069077, 7733.004928584078, 7736.604992241065, 7740.203365706581, 7743.799546187384, 7747.3930279846645, 7750.983306277965, 7754.569875771026, 7758.152229252992, 7761.729856077241, 7765.3022405601905, 7768.868864306655, 7772.429215571283, 7775.982773784337, 7779.529019733335, 7783.067435343781, 7786.59750224542, 7790.118700243536, 7793.6305056976025, 7797.132389819825, 7800.623828250604, 7804.10429691084, 7807.57326718251, 7811.030213270472, 7814.474610807073, 7817.905935348265, 7821.323660763566, 7824.727257522306, 7828.116193288505, 7831.4899453095595, 7834.847984357312, 7838.189783283592, 7841.514817960152, 7844.822565824547, 7848.1125043060465, 7851.384109133938, 7854.636852702789, 7857.870214785437, 7861.0836753029935, 7864.276713576956, 7867.448813229019, 7870.599460788756, 7873.728144167857, 7876.834351003233, 7879.917566881757, 7882.977283323508, 7886.012995556825, 7889.024198303917, 7892.010391455119, 7894.971078733736, 7897.90576621481, 7900.813960700035, 7903.695168336599, 7906.548903858135, 7909.374683652916, 7912.172027179649, 7914.940459484969, 7917.67950990159, 7920.388710588971, 7923.067594918662, 7925.715699613675, 7928.332570325818, 7930.917753741379, 7933.47080296958, 7935.9912766600855, 7938.4787376892245, 7940.932751678871, 7943.352887853168, 7945.738724760544, 7948.089843797102, 7950.405833123062, 7952.686286988256, 7954.93080451385, 7957.1389883069105, 7959.310447290826, 7961.444797966593, 7963.541661208959, 7965.600662805294, 7967.621432282475, 7969.60360030788, 7971.546802127707, 7973.450671854623, 7975.314827972954, 7977.1388719577335, 7978.922381862098, 7980.664886098668, 7982.36587095416, 7984.024663965155, 7985.640416039175, 7987.2120693448, 7988.738211923055, 7990.217080852863, 7991.646028136956, 7993.021449534743, 7994.338704080693, 7995.591483809308, 7996.771668768343, 7997.867999707718, 7998.865865840393, 7999.74698401839, 8000.488103807546, 8001.060439730194, 8001.427966178775, 8001.5472754058455, 8001.3672216029845, 8000.827784924993, 7999.860087226513, 7998.386189177294, 7996.319842904198, 7993.567551508186, 7990.029285564, 7985.600548829347, 7980.1701191658585, 7973.65621731367, 7966.324653546332, 7958.3168463996835, 7949.639233155127, 7940.290745285441, 7930.271844294016, 7919.583883550009, 7908.227121552232, 7896.200719236961, 7883.500554023703, 7870.118232015338, 7856.039817931101, 7841.243502156565, 7825.698878284544, 7809.363688687281, 7792.182763849368, 7774.084069236219, 7754.976553655287, 7734.745021981551, 7713.2461603830525, 7690.301069045807, 7665.688263559879, 7639.131858820633, 7610.289098131873, 7578.730889920714, 7543.918705340991, 7505.17186883339, 7461.623644423253, 7412.163272169314, 7355.380893312593, 7289.646255506785, 7212.72324243319, 7121.661371978788, 7012.6153880807715, 6880.585555148677, 6719.12887163635, 6520.10573872949, 6273.621730309774, 5968.492014237151, 5593.784660765223, 5191.479314198936, 4727.014575331319, 4126.983249411025, 3406.063879739064, 2642.1373264463373, 1952.2397438656071, 1425.3487098036242, 1064.0115389897703, 828.3013846539579, 676.0889579108593, 576.3998981123493, 509.87563334743237, 465.33584145310374, 436.6595480619113, 419.253877565382, 409.4579795649788, 404.12276189288116, 400.9183870502492, 398.7896482718614, 397.2396984951455, 396.029541636104, 395.03988818756244, 394.20671007512453, 393.4919969225438, 392.8707762039155 ]
altitudes = [ 489349.92941798735, 486709.6925601391, 484052.0043148799, 481377.1722470699, 478685.5063529322, 475977.31933658663, 473252.9267173698, 470512.64633557666, 467756.7980335606, 464985.7044579694, 462199.690781394, 459399.08492896054, 456584.21710793395, 453755.4192703888, 450913.02588286065, 448057.3737949971, 445188.802585613, 442307.65440474637, 439414.273402201, 436509.0050981166, 433592.19709661976, 430664.1997678941, 427725.36563366745, 424776.0499356678, 421816.61006925814, 418847.404955755, 415868.79435830377, 412881.1403475506, 409884.8075773297, 406880.1625940073, 403867.5745554585, 400847.4146430595, 397820.0554094985, 394785.8700630367, 391745.2325599324, 388698.5205723364, 385646.11269263364, 382588.3899735138, 379525.7356076846, 376458.53428269736, 373387.17146825325, 370312.0326366648, 367233.5042061955, 364151.97629948147, 361067.8393614106, 357981.48616768327, 354893.311318988, 351803.710564279, 348713.0800525248, 345621.81551359687, 342530.3126334129, 339438.9712621467, 336348.19095366914, 333258.373159091, 330169.9209740516, 327083.23845668044, 323998.7298693359, 320916.79884484503, 317837.8476283364, 314762.2816640865, 311690.50721446984, 308622.9309946336, 305559.96125972643, 302502.00714316405, 299449.4779134691, 296402.78215040173, 293362.32684115786, 290328.51802724414, 287301.76592157036, 284282.4791795956, 281271.0674941605, 278267.9413637463, 275273.5113862399, 272288.1874663895, 269312.377937695, 266346.48860326037, 263390.92649724707, 260446.10027819127, 257512.4171515042, 254590.28497081902, 251680.11158355605, 248782.30408443976, 245897.26797768753, 243025.40624865983, 240167.1192783313, 237322.81064507738, 234492.88187304232, 231677.73407888692, 228877.76811696868, 226093.3838841254, 223324.9795274241, 220572.9505556235, 217837.68891727086, 215119.58724028524, 212419.03784324322, 209736.43103426043, 207072.1564149754, 204426.60223102476, 201800.15462010074, 199193.19675827865, 196606.10790905077, 194039.26640742365, 191493.05046025012, 188967.83547200542, 186463.99550912902, 183981.90268004872, 181521.92640783358, 179084.43259610888, 176669.7828273112, 174278.33804692142, 171910.45723578427, 169566.49666548707, 167246.81046756078, 164951.7500167871, 162681.66320270114, 160436.89358995296, 158217.78099174052, 156024.664549103, 153857.8795945095, 151717.75880035106, 149604.6317305034, 147518.8241905067, 145460.65746216476, 143430.44839606062, 141428.51224702038, 139455.1602538405, 137510.70035356376, 135595.43680721242, 133709.66958836932, 131853.69365711324, 130027.80019153003, 128232.27736356761, 126467.40902145673, 124733.47494896036, 123030.75029539224, 121359.5053179115, 119720.00649625622, 118112.51592894923, 116537.29140842147, 114994.58595305681, 113484.6473018527, 112007.718788133, 110564.03903085459, 109153.84201120026, 107777.35657892749, 106434.80586117785, 105126.40775819682, 103852.37399110664, 102612.91138577648, 101408.22017594427, 100238.49225087091, 99103.91145182401, 98004.64996746741, 96940.87224660441, 95912.72850797698, 94920.34952112474, 93963.84317717236, 93043.28853792045, 92158.74057929032, 91310.20825028047, 90497.63992285822, 89720.92295010481, 88979.86866385397, 88274.18848861847, 87603.47386450786, 86967.18221634533, 86364.60773379821, 85794.85558800865, 85256.82046964299, 84749.15405879915, 84270.24039444886, 83818.24745387305, 83391.17119802628, 82986.84619358275, 82602.94687466603, 82236.98851412535, 81886.32812057249, 81548.16644078773, 81219.54849676508, 80897.36421101168, 80578.34829318989, 80259.07787747215, 79935.97011949122, 79605.27628072724, 79263.07468079869, 78905.26053770538, 78527.53191520367, 78125.37386572175, 77694.03518532868, 77228.50412039366, 76723.47364674509, 76173.30429231096, 75571.97540070117, 74913.02833902277, 74189.50039110333, 73393.83977081813, 72517.81591422297, 71552.40346100274, 70487.65587716736, 69312.55370129365, 68014.87390566617, 66581.08102424257, 64996.234434062615, 63243.9908559788, 61306.79715644196, 59166.443725923076, 56805.23760027252, 54208.15762292594, 51366.37704762351, 48274.193889833055, 44917.95065682568, 41370.46093543153, 37764.89595280867, 34266.87301104143, 31016.51011460554, 28062.2958384268, 25363.017788023688, 22855.24547345098, 20494.95652081445, 18274.201645894907, 16214.037445720285, 14347.432446448132, 12691.222872884944, 11233.55146418605, 9941.534389316104, 8768.986293483526, 7686.3977535981685, 6676.612661587074, 5727.820484071039, 4831.219253612682, 3979.973827597685, 3168.6304936949164, 2392.746929083951, 1648.6436787610874 ]
drag_accelerations = [ 9.395655183583864e-16, 9.403762088320975e-16, 9.411937893892634e-16, 9.420181801353494e-16, 9.42849299723791e-16, 9.436870653658379e-16, 9.445313930436527e-16, 9.45382197292496e-16, 9.462393910801526e-16, 9.471028860693442e-16, 9.479725924014117e-16, 9.488484190067572e-16, 9.49730273393903e-16, 9.506180614197909e-16, 9.515116876892693e-16, 9.524110551278267e-16, 9.533160654286027e-16, 9.542266190632369e-16, 9.551426150184125e-16, 9.560639505220085e-16, 9.569905214972666e-16, 9.579222224610884e-16, 9.588589463427741e-16, 9.598005850292534e-16, 9.607470290938493e-16, 9.616981675130073e-16, 9.626538873741253e-16, 9.636140747489846e-16, 9.645786142066604e-16, 9.655473887227777e-16, 9.6652028033605e-16, 9.674971698615807e-16, 9.684779365908227e-16, 9.69462457978654e-16, 9.70450609829624e-16, 9.714422675630472e-16, 9.724373042738715e-16, 9.73435592219713e-16, 9.744370027045233e-16, 9.75441405767417e-16, 9.764486698565758e-16, 9.77458661488696e-16, 9.784712459468075e-16, 9.794862881727847e-16, 9.805036507191753e-16, 9.815231955591872e-16, 9.825447838418521e-16, 9.835682755610638e-16, 9.84593529207608e-16, 9.856204014046678e-16, 9.866487473118677e-16, 9.876784225440579e-16, 9.88709280032305e-16, 9.897411722250674e-16, 9.90773951022654e-16, 9.918074674332074e-16, 9.928415712090835e-16, 9.938761104641541e-16, 9.949109313748464e-16, 9.959458809568564e-16, 9.969808043493536e-16, 9.980155455328464e-16, 9.990499483441306e-16, 1.0000838561278186e-15, 1.001117111365214e-15, 1.002149555281062e-15, 1.0031810274287312e-15, 1.0042113663138042e-15, 1.0052404118442656e-15, 1.0062680012373292e-15, 1.0072939717608935e-15, 1.0083181606873017e-15, 1.0093404049238791e-15, 1.0103605406179098e-15, 1.0113784027366198e-15, 1.012393824625408e-15, 1.0134066405578588e-15, 1.0144166845961328e-15, 1.0154237893528634e-15, 1.0164277879790812e-15, 1.0174285138050664e-15, 1.01842579995198e-15, 1.0194194789148043e-15, 1.0204093821171736e-15, 1.0213953400825727e-15, 1.022377185727903e-15, 1.0233547500677747e-15, 1.0243278645538834e-15, 1.0252963613427854e-15, 1.0262600729205506e-15, 1.0272188316949532e-15, 1.0281724695557694e-15, 1.0291208174500029e-15, 1.030063708259143e-15, 1.0310009748338083e-15, 1.0319324498434868e-15, 1.0328579671171805e-15, 1.03377736128396e-15, 1.0346904673773646e-15, 1.035597120404193e-15, 1.0364971548810557e-15, 1.0373904069923132e-15, 1.6646240197588593e-15, 3.700759075476488e-15, 8.17199230653924e-15, 1.7921585599724428e-14, 3.9028826430204186e-14, 8.439269415308766e-14, 1.8116938860906692e-13, 3.8607865672865125e-13, 8.166358576529752e-13, 1.7143275964736756e-12, 3.5712745796644378e-12, 7.381904791362434e-12, 1.513845666234469e-11, 3.079750383063231e-11, 6.214747508204597e-11, 1.243823957454225e-10, 2.4687420902362613e-10, 4.858790650975094e-10, 9.481368552738184e-10, 1.8342540045608059e-09, 3.5176237217188537e-09, 6.686474698901099e-09, 1.259678246771523e-08, 2.3517648023844338e-08, 4.350685218174396e-08, 7.974604437739863e-08, 1.4481286015704058e-07, 2.6050200850670317e-07, 4.6417417587279536e-07, 8.191760224750179e-07, 1.4317290761564436e-06, 2.477954745900465e-06, 4.246557440546537e-06, 7.205439113183924e-06, 1.2104965608118258e-05, 2.013112423246062e-05, 3.3138926127962955e-05, 5.39933147419456e-05, 8.70640075768495e-05, 0.0001389315777124315, 0.0002193785287971382, 0.00034275667187709356, 0.000529840133900224, 0.0008102894358594512, 0.0012258626789898859, 0.0018345118888420566, 0.002715486262321981, 0.003975531229978483, 0.005756206225675346, 0.008242238713265767, 0.011670706490048744, 0.01634061411368811, 0.02262229169262434, 0.03096576426435855, 0.041906997382931056, 0.05607079537357135, 0.07416870487225892, 0.09699120151650475, 0.12539289903362924, 0.1602696057230993, 0.20252801285614583, 0.25304951238295875, 0.31265015767790033, 0.3820395869133754, 0.4617853004472738, 0.5522868632049915, 0.6537641623781116, 0.7550122789250263, 0.8180693023240646, 0.8818154621721916, 0.9460084539213732, 1.0104769571020589, 1.075136808795281, 1.1400039136326434, 1.2052055011390412, 1.2709908051070022, 1.3377410078976752, 1.4059799745411585, 1.4763865557326765, 1.5498097861323152, 1.6272890910095128, 1.7100806755500655, 1.7996938949895391, 1.8979390455776923, 2.0069929681644223, 2.1294849096195354, 2.268613620815029, 2.4283009842658685, 2.613401106173195, 2.8299776991038246, 3.085682169713931, 3.390263941392645, 3.7562679919478974, 4.1999938792475255, 4.742810078919622, 5.412976594488694, 6.236224527663904, 7.249016398317553, 8.522085145127923, 10.13395798215163, 12.187001684651696, 14.81179406300922, 18.167967350846325, 22.43492190926215, 27.779572912209716, 34.28039527866195, 41.78530979928753, 41.205102545998514, 53.773297665677646, 67.7181192288895, 77.22877816063264, 76.1260133203632, 63.53138379442348, 46.39736857056061, 32.27447821573776, 22.780204835265117, 17.21045147559021, 14.268843470477908, 12.954682821365136, 12.33529354450154, 11.883027733773389, 11.466502331320186, 10.922476493370013, 10.641128309807861, 10.476515586742844, 10.363035465297006, 10.278722123447345, 10.21359490246942, 10.161973776782379, 10.12024620919821, 10.0859782135361, 10.057465502708709 ]
capsule_length = 1.315 * np.sqrt(spacecraft_area/np.pi) # m , same ratio as orion capsule
# Initialize lists
Heat_Generated_data = []
Convective_Heat_transfered_data = []
Radiative_Heat_transfered_data = []
Net_heat_transfered_data = []
Temperature_change_data = []
Spacecraft_surface_temperature_data = []
atmo_rho_data = []
atmo_T_data = []
selected_material = MATERIALS['PICA']
material_properties = list(selected_material.values())
spacecraft_m= 1000 # kg
t_span = 10
dt = 10
#unpack material properties
thermal_conductivity = material_properties[0]
specific_heat_capacity = material_properties[1]
emissivity = material_properties[2]
ablation_efficiency = material_properties[3]
# Example usage
for altitude, v_norm, drag_acceleration in zip(altitudes, v_norms, drag_accelerations):
atmo_rho, atmo_T = atmosphere_model(altitude, 0, epoch_jd)
Qc, Qr, Q_net, Q, T_s, dT = spacecraft_temperature(v_norm, atmo_T, drag_acceleration, capsule_length, dt, thermal_conductivity ,specific_heat_capacity, emissivity, ablation_efficiency, spacecraft_m=spacecraft_m, iter_fact=3)
Heat_Generated_data.append(Q)
Convective_Heat_transfered_data.append(Qc)
Radiative_Heat_transfered_data.append(Qr)
Net_heat_transfered_data.append(Q_net)
Temperature_change_data.append(dT)
Spacecraft_surface_temperature_data.append(T_s)
atmo_rho_data.append(atmo_rho)
atmo_T_data.append(atmo_T)
result = {
'Spacecraft_surface_temperature': (Spacecraft_surface_temperature_data,'K', 'red'),
'Net_heat_transfered_(Q_net)': (Net_heat_transfered_data,'W', 'orange'),
'Heat_Generated_(Q)': (Heat_Generated_data,'W', 'red'),
'Convective_Heat_transfered_(Qc)': (Convective_Heat_transfered_data,'W', 'blue'),
'Radiative_Heat_transfered_(Qr)': (Radiative_Heat_transfered_data,'W', 'green'),
'Temperature_change_(dT)': (Temperature_change_data,'K', 'purple'),
'v_norm': (v_norms,'m/s', 'red'),
'drag_acceleration': (drag_accelerations,'m/s²', 'blue'),
'atmo_rho': (atmo_rho_data,'kg/m³', 'green'),
'atmo_T': (atmo_T_data,'K', 'orange'),
}
# reverse order of altitude list
np.flip(altitudes)
total_plots = len(result)
# find the number of rows and columns from total number of subplots
num_rows = math.ceil(len(result) / 3)
num_cols = math.ceil(len(result) / 4)
# set font size for all subplots
title_size = 12
font_size = 8
# create a list of titles for each subplot
titles = [f'{key} vs. Altitude' for key in result.keys()]
# the x labels are the same for all subgraphs
xlabels = ['Altitude (m)' for i in range(total_plots)]
ylabels = [f'{key} ({unit})' for key, (value, unit, color) in result.items()]
# create a list of data to plot for each subgraph
xdata = [altitudes for i in range(total_plots)]
ydata = [value for key, (value, unit, color) in result.items()]
colors = [color for key, (value, unit, color) in result.items()]
# create a 4x3 grid of subplots
fig = make_subplots(rows=num_rows, cols=num_cols, subplot_titles=titles)
# loop over the subplots and plot the data with the titles, labels and colors
for i in range(num_rows):
for j in range(num_cols):
if i * num_cols + j >= total_plots:
break
# get the index of the subplot
k = i * num_cols + j
# create a line plot with the data and color
trace = go.Scatter(x=xdata[k], y=ydata[k], mode='lines', line=dict(color=colors[k]), showlegend=False)
# add the trace to the subplot
fig.add_trace(trace, row=i+1, col=j+1)
# update the x and y-axis labels
fig.update_xaxes(title_text=xlabels[k], row=i+1, col=j+1)
fig.update_yaxes(title_text=ylabels[k], row=i+1, col=j+1, title_font=dict(size=font_size), tickfont=dict(size=font_size))
fig.update_annotations(font_size=title_size)
# update the layout of the figure
fig.update_layout(title_text='Spacecraft Surface Temperature vs. Altitude and Velocity', height=1200, autosize=True, template='plotly_dark', font=dict(size=title_size))
# show the figure
fig.show()
# def final_temperature(spacecraft_area, epoch_jd, altitude, v_norm, capsule_length):
# atmo_rho, atmo_T = atmosphere_model(altitude, 0, epoch_jd)
# # calculate mach number
# speed_of_sound = math.sqrt(RATIO_OF_SPECIFIC_HEATS * AIR_GAS_CONSTANT * atmo_T)
# mach_number = v_norm / speed_of_sound
# # Calculate dynamic pressure
# q_din = 0.5 * atmo_rho * v_norm**2 # dynamic pressure (Pa)
# # Calculate specific heat
# cp_air = 2 * q_din / (atmo_rho * mach_number**2) # J/kg·K (specific heat at constant pressure)
# # Calculate thermal conductivity
# k_air = K_REF * (atmo_T / T_REF)**1.5 * (T_REF + S) / (atmo_T + S)
# # Calculate heat flux using the modified Newtonian heating model
# q = k_air * cp_air * atmo_T * math.sqrt(atmo_rho / RHO_REF) * v_norm**3
# # Estimate heat transfer coefficient (assuming constant value)
# NU_REF=1.81e-5 # kg/ms (reference viscosity at 15ºC or 288.15K)
# alpha = k_air / (atmo_rho * cp_air) # m²/s (thermal diffusivity)
# # Calculate Reynolds and Nusselt numbers iteratively
# nu = NU_REF * (atmo_T / T_REF)**1.5 * (T_REF + S) / (atmo_T + S) # m²/s (kinematic viscosity)
# mu = atmo_rho * nu # kg/m·s (dynamic viscosity)
# # Calculate Prandtl number
# Pr = nu / alpha
# # Calculate Reynolds and Nusselt numbers iteratively
# max_iter=100
# tol=1e-6
# Re_prev = 1e5 # initial estimate of Reynolds number
# Nu = None # initial estimate of Nusselt number
# for _ in range(max_iter):
# Re = (atmo_rho * v_norm * capsule_length) / mu
# Nu = C * (Pr * Re)**0.5 * Pr**(-2/3)
# if abs(Re - Re_prev) < tol:
# break
# Re_prev = Re
# # Calculate heat transfer coefficient
# h = (Nu * k_air) / capsule_length # W/m²·K
# # Calculate spacecraft surface temperature
# Ts = atmo_T + q / h
# # Calculate heat loss due to drag
# q_drag = 0.5 * atmo_rho * v_norm**2 * Cd * spacecraft_area
# # Calculate final spacecraft surface temperature
# Ts_final = Ts + q_drag / (h * spacecraft_area)
# return Ts_final
# # Generate a large number of random input parameter values
# N_SAMPLES = 1000
# spacecraft_areas = np.random.uniform(0.5, 5, N_SAMPLES)
# epoch_jds = np.random.uniform(2459270, 2459300, N_SAMPLES)
# altitudes = np.random.uniform(0, 200000, N_SAMPLES)
# v_norms = np.random.uniform(500, 10000, N_SAMPLES)
# capsule_lengths = np.random.uniform(1, 5, N_SAMPLES)
# # Calculate the corresponding Ts_final values
# Ts_finals = [final_temperature(sa, ejd, alt, vn, cl) for sa, ejd, alt, vn, cl in zip(spacecraft_areas, epoch_jds, altitudes, v_norms, capsule_lengths)]
# # Calculate the correlation coefficients for each input parameter
# correlations = {
# "spacecraft_area": pearsonr(spacecraft_areas, Ts_finals)[0],
# "capsule_length": pearsonr(capsule_lengths, Ts_finals)[0],
# }
# # Print the correlations
# for factor, correlation in correlations.items():
# print(f"{factor}: {correlation}")