-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotting.py
More file actions
79 lines (64 loc) · 2.76 KB
/
plotting.py
File metadata and controls
79 lines (64 loc) · 2.76 KB
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
"""
plotting.py — Final simulation result plots (gas side).
Generates 2 figures:
1. Gas parameters (N, P, T) — profile along the nozzle
2. Adiabatic wall temperature (T_aw) + static gas temperature
"""
import matplotlib.pyplot as plt
import numpy as np
def plot_final_results(xspan, YSol2, params, idx_throat):
"""
Draw final plots after the full computation cycle.
Parameters
----------
xspan : np.ndarray — axial grid [m]
YSol2 : np.ndarray, shape (n, 3) — final ODE solution [N, P, T]
params : dict — engine parameters
idx_throat : int — throat index
"""
x_throat = xspan[idx_throat]
# ===================================================================
# FIGURE 1: Gas parameters (N, pressure, temperature)
# ===================================================================
fig1, axes1 = plt.subplots(3, 1, figsize=(10, 10))
fig1.suptitle('Gas Parameters (Stage 2 — with friction)', fontsize=14)
# N = M^2
axes1[0].plot(xspan, YSol2[:, 0], 'b-', linewidth=2)
axes1[0].axhline(y=1, color='r', linestyle='--', label='Mach = 1')
axes1[0].axvline(x=x_throat, color='k', linestyle=':', alpha=0.7, label='Throat')
axes1[0].set_xlabel('x [m]')
axes1[0].set_ylabel('N (Mach²) [-]')
axes1[0].set_title('Mach Number Squared Profile (N)')
axes1[0].legend()
axes1[0].grid(True)
# Pressure [bar]
axes1[1].plot(xspan, YSol2[:, 1] / 1e5, 'g-', linewidth=2)
axes1[1].axvline(x=x_throat, color='k', linestyle=':', alpha=0.7)
axes1[1].set_xlabel('x [m]')
axes1[1].set_ylabel('Pressure P [bar]')
axes1[1].set_title('Static Pressure Profile')
axes1[1].grid(True)
# Temperature [K]
axes1[2].plot(xspan, YSol2[:, 2], 'r-', linewidth=2)
axes1[2].axvline(x=x_throat, color='k', linestyle=':', alpha=0.7)
axes1[2].set_xlabel('x [m]')
axes1[2].set_ylabel('Temperature T [K]')
axes1[2].set_title('Exhaust Gas Temperature Profile')
axes1[2].grid(True)
fig1.tight_layout()
# ===================================================================
# FIGURE 2: T_aw and static temperature
# ===================================================================
fig2, ax2 = plt.subplots(figsize=(10, 6))
ax2.plot(xspan, params['T_aw'], 'r-', linewidth=2,
label='T_aw (adiabatic wall temperature)')
ax2.plot(xspan, YSol2[:, 2], 'b--', linewidth=2,
label='T (static gas temperature)')
ax2.axvline(x=x_throat, color='k', linestyle=':', alpha=0.7, label='Throat')
ax2.set_xlabel('Axial position x [m]')
ax2.set_ylabel('Temperature [K]')
ax2.set_title('Adiabatic Wall Temperature vs. Static Gas Temperature')
ax2.legend(loc='best')
ax2.grid(True)
fig2.tight_layout()
plt.show()