17 time_history: np.ndarray,
18 recession_history: np.ndarray,
19 D_chamber_initial: float,
20 D_throat_initial: float,
25 Create working animation.
29 time_history : np.ndarray
31 recession_history : np.ndarray
33 D_chamber_initial : float
34 Initial chamber diameter [m]
35 D_throat_initial : float
36 Initial throat diameter [m]
48 n_steps = len(time_history)
49 if n_steps > max_frames:
50 step =
max(1, n_steps // max_frames)
51 indices = np.arange(0, n_steps, step)
52 time_history = time_history[indices]
53 recession_history = recession_history[indices]
54 n_steps = len(time_history)
57 raise ValueError(
"No time steps")
61 positions = np.linspace(0.0, L_chamber, n_points)
62 throat_pos = L_chamber
66 for recession
in recession_history:
67 D_chamber = D_chamber_initial + 2.0 * recession
68 all_D_chamber.append(D_chamber)
73 subplot_titles=(
"Recession vs Time",
"Chamber Cross-Section"),
74 vertical_spacing=0.15,
75 row_heights=[0.3, 0.7],
79 D_chamber_0 = all_D_chamber[0]
80 R_chamber_0 = D_chamber_0 / 2.0
81 R_throat_0 = D_throat_initial / 2.0
84 R_profile_0 = np.zeros(n_points)
85 for i, x
in enumerate(positions):
86 if x < throat_pos * 0.8:
87 R_profile_0[i] = R_chamber_0
89 x_conv = (x - throat_pos * 0.8) / (throat_pos * 0.2 + 1e-10)
90 x_conv = np.clip(x_conv, 0.0, 1.0)
91 R_profile_0[i] = R_chamber_0 + (R_throat_0 - R_chamber_0) * x_conv
94 fig.add_trace(go.Scatter(
96 y=[recession_history[0] * 1000],
99 line=dict(color=
'red', width=2),
103 fig.add_trace(go.Scatter(
108 line=dict(color=
'orange', width=3),
111 fig.add_trace(go.Scatter(
115 name=
'Gas Boundary Lower',
116 line=dict(color=
'orange', width=3),
122 for i
in range(n_steps):
123 D_chamber_i = all_D_chamber[i]
124 R_chamber_i = D_chamber_i / 2.0
127 R_profile_i = np.zeros(n_points)
128 for j, x
in enumerate(positions):
129 if x < throat_pos * 0.8:
130 R_profile_i[j] = R_chamber_i
132 x_conv = (x - throat_pos * 0.8) / (throat_pos * 0.2 + 1e-10)
133 x_conv = np.clip(x_conv, 0.0, 1.0)
134 R_profile_i[j] = R_chamber_i + (R_throat_0 - R_chamber_i) * x_conv
137 frames.append(go.Frame(
142 x=time_history[:i+1],
143 y=recession_history[:i+1] * 1000,
144 mode=
'lines+markers',
145 line=dict(color=
'red', width=2),
152 line=dict(color=
'orange', width=3)
158 line=dict(color=
'orange', width=3)
167 title=
"Recession Evolution",
173 {
"label":
"▶ Play",
"method":
"animate",
"args": [
None, {
174 "frame": {
"duration": 500,
"redraw":
True},
177 {
"label":
"⏸ Pause",
"method":
"animate",
"args": [[
None], {
178 "frame": {
"duration": 0,
"redraw":
False},
185 "currentvalue": {
"prefix":
"Time: ",
"suffix":
" s"},
188 "frame": {
"duration": 300,
"redraw":
True},
191 "label": f
"{time_history[i]:.2f}",
193 }
for i
in range(len(time_history))]
197 fig.update_xaxes(title_text=
"Time [s]", row=1, col=1)
198 fig.update_yaxes(title_text=
"Recession [mm]", row=1, col=1)
199 fig.update_xaxes(title_text=
"Axial Position [m]", row=2, col=1)
200 fig.update_yaxes(title_text=
"Radius [m]", row=2, col=1)