Skip to content

Commit f97c6f5

Browse files
committed
hvlm tighter tolerance + cont print rms0
1 parent c2282be commit f97c6f5

File tree

3 files changed

+23
-27
lines changed

3 files changed

+23
-27
lines changed

lib/libhbvlm3.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ void HBVLM::run(f64 t_start, f64 omega, const Vars& v, Assembly<f64>& assembly,
413413
gamma_coeffs_v.reshape(gamma_coeffs_v.shape(0)*gamma_coeffs_v.shape(1)),
414414
hb_vlm_iter,
415415
100, // max iterations
416-
1e-9, // tolerance
416+
1e-12, // tolerance
417417
10 // history
418418
);
419419

scripts/continuation.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,9 @@ def continuation(X0, motion, metadata: Metadata):
355355
X0 = Xtmp.copy()
356356
X = X0 * Dscale # unscaled X
357357
X_mat[:, iteration] = X
358+
X_h = X[0:omega_idx:metadata.dims.n_d]
359+
A = np.sqrt(X_h[1::2]**2 + X_h[2::2]**2)
360+
rms_0 = np.sqrt(X_h[0]**2 + 0.5 * np.sum(A**2, axis=0))
358361

359362
# Stability analysis
360363
is_stable, floquet_exponents = stability_analysis(J @ np.diag(1.0 / Dscale), motion, X[omega_idx], omega_idx, metadata.dims)
@@ -374,8 +377,8 @@ def continuation(X0, motion, metadata: Metadata):
374377
if np.copysign(1.0, metadata.bifurcation_test[i, iteration-1]) != np.copysign(1.0, metadata.bifurcation_test[i, iteration]):
375378
print(f"{name} bifurcation detected")
376379
metadata.bifurcation[name].append(iteration-1)
377-
378-
print(f"{iteration} | ds: {ds * Dscale[-1]:.4f}, param: {X[-1]:.3f}, omega: {X[omega_idx]:.3f}, stable: {is_stable}, nfev: {nfev}, njev: {njev}, timing: {timing:.2f}s")
380+
381+
print(f"{iteration} | ds: {ds * Dscale[-1]:.4f}, param: {X[-1]:.3f}, omega: {X[omega_idx]:.3f}, rms0: {rms_0:.3e}, stable: {is_stable}, nfev: {nfev}, njev: {njev}, timing: {timing:.2f}s")
379382

380383
if metadata.step_adapt:
381384
n_f = nfev + J.shape[1] * njev
@@ -389,10 +392,6 @@ def continuation(X0, motion, metadata: Metadata):
389392
print("Continuation reached the end")
390393
break
391394

392-
X_h = X[0:omega_idx:metadata.dims.n_d]
393-
A = np.sqrt(X_h[1::2]**2 + X_h[2::2]**2)
394-
rms_0 = np.sqrt(X_h[0]**2 + 0.5 * np.sum(A**2, axis=0))
395-
# print(f"rms_0: {rms_0:.6e}")
396395
if rms_0 < 1e-10 and iteration > 1:
397396
print("Continuation reached trivial solution, stopping.")
398397
break

scripts/dof3_hb.py

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def dKdU(U): return np.zeros((3, 3))
120120
flutter_speed = 23.9
121121
# param_start = flutter_speed * 0.3
122122
# param_end = flutter_speed * 0.6
123-
param_start = 6.0
123+
param_start = 8.0
124124
param_end = 20.0
125125

126126
v = dof3.Vars()
@@ -189,7 +189,7 @@ def dKdU(U): return np.zeros((3, 3))
189189
metadata.name = f"3dof_hbvlm_{torsional_spring_names[torsional_spring]}"
190190
metadata.param_start = param_start
191191
metadata.param_end = param_end
192-
metadata.max_steps = 1 if INITIAL_ONLY else 10000
192+
metadata.max_steps = 1 if INITIAL_ONLY else 5000
193193
metadata.scaling = True
194194
metadata.step_adapt = True
195195
metadata.ds = 0.02
@@ -202,21 +202,18 @@ def dKdU(U): return np.zeros((3, 3))
202202

203203
if helpers.getenv("PLOT"):
204204
X_mat = metadata.X
205-
if X_mat.shape[1] == 1:
206-
hb_sol_t, hb_sol0 = hb.to_timedomain(vec_t, dims.n_d, X_mat[:-2, 0], X_mat[-2, 0], dims.n_h)
207-
aero_forces = system.aero_forces(sol.y)
208-
fig = plot.create_dofs_figure(["Heave", "Pitch", "Control"])
209-
dof3.plot_solution(fig, aero_forces, sol, v)
210-
211-
plot.add_data_and_psd(fig, hb_sol_t, hb_sol0[0, :], "HB-VLM", 1, 1, 3)
212-
plot.add_data_and_psd(fig, hb_sol_t, np.degrees(hb_sol0[1, :]), "HB-VLM", 3, 1, 3)
213-
plot.add_data_and_psd(fig, hb_sol_t, np.degrees(hb_sol0[2, :]), "HB-VLM", 5, 1, 3)
214-
215-
plot.add_data_and_psd(fig, hb_sol_t, hb_sol0[3, :], "HB-VLM", 1, 2, 3)
216-
plot.add_data_and_psd(fig, hb_sol_t, np.degrees(hb_sol0[4, :]), "HB-VLM", 3, 2, 3)
217-
plot.add_data_and_psd(fig, hb_sol_t, np.degrees(hb_sol0[5, :]), "HB-VLM", 5, 2, 3)
218-
219-
dof3.format_plot(fig)
220-
plot.fig_save(fig, f"build/3dof/hbvlm0", html=True, pdf=False)
221-
else:
222-
cont.plot_hb_continuation(metadata)
205+
hb_sol_t, hb_sol0 = hb.to_timedomain(vec_t, dims.n_d, X_mat[:-2, 0], X_mat[-2, 0], dims.n_h)
206+
aero_forces = system.aero_forces(sol.y)
207+
fig = plot.create_dofs_figure(["Heave", "Pitch", "Control"])
208+
dof3.plot_solution(fig, aero_forces, sol, v)
209+
210+
plot.add_data_and_psd(fig, hb_sol_t, hb_sol0[0, :], "HB-VLM", 1, 1, 3)
211+
plot.add_data_and_psd(fig, hb_sol_t, np.degrees(hb_sol0[1, :]), "HB-VLM", 3, 1, 3)
212+
plot.add_data_and_psd(fig, hb_sol_t, np.degrees(hb_sol0[2, :]), "HB-VLM", 5, 1, 3)
213+
214+
plot.add_data_and_psd(fig, hb_sol_t, hb_sol0[3, :], "HB-VLM", 1, 2, 3)
215+
plot.add_data_and_psd(fig, hb_sol_t, np.degrees(hb_sol0[4, :]), "HB-VLM", 3, 2, 3)
216+
plot.add_data_and_psd(fig, hb_sol_t, np.degrees(hb_sol0[5, :]), "HB-VLM", 5, 2, 3)
217+
218+
dof3.format_plot(fig)
219+
plot.fig_save(fig, f"build/3dof/hbvlm0", html=True, pdf=False)

0 commit comments

Comments
 (0)