Modal Analysis¶
You can also perform eigenvalue analysis of the aircraft to characterize its dynamic stability.
Instead of calling execute_run, call execute_eigen_mode_calc.
To run this type of analysis the aircraft should be in trim, so here we determine the CL necessary for lift = weight.
You must also set a velocity before the analysis with ovl.set_parameter("velocity", <velocity>)
You can retrieve the eigenvalues and vectors after the analysis with get_eigenvalues and get_eigenvectors.
from optvl import OVLSolver
import numpy as np
import matplotlib.pyplot as plt
def syssho(asys,bsys):
"""
Prints out state-system matrix A in an organized manner.
Parameters
----------
asys : ndarray (nsys x nsys)
State matrix A.
"""
nsys = asys.shape[0]
consurf_names = ovl.get_control_names()
num_consurf = len(consurf_names)
# Header
state_labels = ["u", "w", "q", "the", "v", "p", "r", "phi", "x", "y", "z", "psi"]
header = " ".join(f"{lab:>10}" for lab in state_labels) + " |"
header += " ".join(f"{lab:>10}" for lab in consurf_names)
print(header)
# Rows
for i in range(nsys):
row_str = "".join(f"{val:11.4f}" for val in asys[i, :12])
row_str += "".join(f"{val:11.4f}" for val in bsys[i, :num_consurf])
print(row_str)
ovl = OVLSolver(geo_file="../geom_files/aircraft.avl", mass_file="../geom_files/aircraft.mass", debug=True)
ovl.set_trim_condition("velocity", 10.0)
ovl.set_constraint("Elevator", "Cm", 0.00)
ovl.execute_eigen_mode_calc()
Amat, Bmat, _ = ovl.get_system_matrices(in_body_axis=True)
syssho(Amat,Bmat)
vals_ovl = ovl.get_eigenvalues()
# plot the eigenvalues
plt.plot(np.real(vals_ovl), np.imag(vals_ovl), "o")
plt.xlabel("real")
plt.ylabel("imag")
plt.title("Eigenvalues")
plt.grid("on")
plt.show()
# ----------------------------------------------------
The eigenvalues should look like this
