optvl_class
This module contains the OVLSolver, which is the main wrapper for the Fortran level API.
OVLSolver
¶
Bases: object
__init__(geo_file, mass_file=None, debug=False, timing=False)
¶
Initalize the python and fortran libary from the given objects
Parameters:
Name | Type | Description | Default |
---|---|---|---|
geo_file
|
str
|
AVL geometry file |
required |
mass_file
|
Optional[str]
|
AVL mass file |
None
|
debug
|
Optional[bool]
|
flag for debug printing |
False
|
timing
|
Optional[bool]
|
flag for timing printing |
False
|
add_mesh_plot(axis, xaxis='x', yaxis='y', color='black', mesh_style='--', mesh_linewidth=0.3, show_mesh=True)
¶
adds a plot of the aircraft mesh to the axis
Parameters:
Name | Type | Description | Default |
---|---|---|---|
axis
|
axis to add the plot to |
required | |
xaxis
|
str
|
what variable should be plotted on the x axis. Options are ['x', 'y', 'z'] |
'x'
|
yaxis
|
str
|
what variable should be plotted on the y-axis. Options are ['x', 'y', 'z'] |
'y'
|
color
|
str
|
what color should the mesh be |
'black'
|
mesh_style
|
line style of the interior mesh, e.g. '-' or '--' |
'--'
|
|
mesh_linewidth
|
width of the interior mesh, 1.0 will match the surface outline |
0.3
|
|
show_mesh
|
bool
|
flag to show the interior mesh of the geometry |
True
|
execute_eigen_mode_calc()
¶
execute a modal analysis (x from the MODE menu in AVL)
execute_run(tol=2e-05)
¶
run the analysis (equivalent to the AVL command x
in the OPER menu)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tol
|
float
|
the tolerace of the Newton solver used for timing the aircraft |
2e-05
|
execute_run_sensitivities(funcs, stab_derivs=None, consurf_derivs=None, print_timings=False)
¶
Run the sensitivities of the input functionals in adjoint mode
Parameters:
Name | Type | Description | Default |
---|---|---|---|
funcs
|
List[str]
|
force coefficients to compute the sensitivities with respect to |
required |
stab_derivs
|
Optional[List[str]]
|
stability derivatives to compute the sensitivities with respect to |
None
|
consurf_derivs
|
Optional[List[str]]
|
control surface derivates to compute the sensitivities with respect to |
None
|
print_timings
|
Optional[bool]
|
flag to print timing information |
False
|
Returns:
Name | Type | Description |
---|---|---|
sens |
Dict[str, Dict[str, float]]
|
a nested dictionary of sensitivities. The first key is the function and the next keys are for the design variables. |
get_avl_fort_arr(common_block, variable, slicer=None)
¶
get data from the Fortran level common block data structure. see AVL.INC for all availible variables
Parameters:
Name | Type | Description | Default |
---|---|---|---|
common_block
|
str
|
Name of the common block of the variable like |
required |
variable
|
str
|
Name of the variable to retrive |
required |
slicer
|
Optional[slice]
|
slice applied to the common block variable to return a subset of the data. i.e. (100) or slice(2, 5) |
None
|
Returns:
Name | Type | Description |
---|---|---|
val |
ndarray
|
value of variable after applying the slice (if present) |
get_body_names(remove_dublicated=False)
¶
get the body names from the geometry
Parameters:
Name | Type | Description | Default |
---|---|---|---|
remove_dublicated
|
Optional[bool]
|
remove the body that were created by duplication about symmetry planes |
False
|
Returns:
Name | Type | Description |
---|---|---|
body_names |
List[str]
|
list of body names |
get_body_params()
¶
Get the parameters of the bodies
Returns:
Name | Type | Description |
---|---|---|
body_data |
Dict[str, Dict[str, Any]]
|
Nested dictionary where the 1st key is the body name and the 2nd key is the parameter. |
get_con_surf_param(surf_name, idx_slice, param)
¶
returns the parameters that define the control surface
Parameters:
Name | Type | Description | Default |
---|---|---|---|
surf_name
|
str
|
the name of the surface containing the control surface |
required |
idx_slice
|
int
|
the section index of the control surface data |
required |
param
|
str
|
control surface parameter to get |
required |
Returns:
Name | Type | Description |
---|---|---|
parm |
ndarray
|
parameter value |
get_constraint(con_key)
¶
get the value of a constraint
Parameters:
Name | Type | Description | Default |
---|---|---|---|
con_key
|
str
|
name of the constraint. Options are ["alpha","beta","roll rate","pitch rate","yaw rate","CL","CY","CR BA","CM","CR"] |
required |
Returns:
Name | Type | Description |
---|---|---|
con_val |
float
|
value of the constraint |
get_control_deflections()
¶
get the deflections of all the control surfaces
Returns:
Name | Type | Description |
---|---|---|
def_dict |
Dict[str, float]
|
dictionary of control surfaces as the keys and deflections as the values |
get_control_names()
¶
get the names of the control surfaces
Returns:
Name | Type | Description |
---|---|---|
control_names |
List[str]
|
list of control surface names |
get_control_stab_derivs()
¶
Get the control surface derivative data, i.e. dCL/dElevator, for the current analysis run
Returns:
Name | Type | Description |
---|---|---|
stab_deriv_dict |
Dict[str, float]
|
The dictionary of control surface derivatives, d{force coefficent}/d{control surface}. |
get_cp_data()
¶
Gets the current surface mesh and cp distribution
Returns:
Name | Type | Description |
---|---|---|
xyz_list |
List[ndarray]
|
list of surface mesh points |
cp_list |
List[ndarray]
|
list of cp points |
get_eigenvalues()
¶
after running an eigenmode calculation, this function will return the eigenvalues in the order used by AVL
Returns:
Name | Type | Description |
---|---|---|
eig_vals |
ndarray
|
array of eigen values |
get_eigenvectors()
¶
after running an eigenmode calculation, this function will return the eigenvalues in the order used by AVL
Returns:
Name | Type | Description |
---|---|---|
eig_vec |
ndarray
|
2D array of eigen vectors |
get_hinge_moments()
¶
get the hinge moments from the fortran layer and return them as a dictionary
Returns:
Name | Type | Description |
---|---|---|
hinge_moments |
Dict[str, float]
|
array of control surface moments. The order the control surfaces are declared are the indices, |
get_mesh_size()
¶
Get the number of vortices in the mesh
Returns:
Name | Type | Description |
---|---|---|
val |
int
|
the number of vortices |
get_num_control_surfs()
¶
Get the number of control surfaces
Returns:
Name | Type | Description |
---|---|---|
val |
int
|
number of control surfaces |
get_num_sections(surf_name)
¶
Get the number of sections in a surface.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
surf_name
|
str
|
name of the surface |
required |
Returns:
Name | Type | Description |
---|---|---|
nsec |
int
|
numer of sections |
get_num_strips()
¶
Get the number of strips in the mesh
get_num_surfaces()
¶
Returns the number of surface including duplicated
Returns:
Name | Type | Description |
---|---|---|
val |
int
|
number of surfaces |
get_parameter(param_key)
¶
analogous to ruinont Modify parameters for the OPER menu to view parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
param_key
|
str
|
the name of the parameter to return |
required |
Returns:
Name | Type | Description |
---|---|---|
param_val |
float
|
the value of the parameter |
get_stab_derivs()
¶
gets the stability derivates after an analysis run
Returns:
Name | Type | Description |
---|---|---|
stab_deriv_dict |
Dict[str, Dict[str, float]]
|
Dictionary of stability derivatives. |
get_strip_forces()
¶
get force data for each strip (chordwise segment) of the mesh.
Returns:
Name | Type | Description |
---|---|---|
strip_data |
Dict[str, Dict[str, ndarray]]
|
dictionary of strip data. The keys are ["chord", "width", "X LE", "Y LE", "Z LE", "twist","CL", "CD", "CDv", "downwash", "CX", "CY", "CZ","CM", "CN", "CR","CL strip", "CD strip", "CF strip", "CM strip","CL perp","CM c/4,"CM LE"] |
get_surface_forces()
¶
returns the force data from each surface (including mirriored surfaces)
Returns:
Name | Type | Description |
---|---|---|
surf_data_dict |
Dict[str, Dict[str, float]]
|
a dictionary of surface data where the first key is the surface and the second is the force coefficient |
get_surface_index(surf_name)
¶
given a surface name returns the index
Parameters:
Name | Type | Description | Default |
---|---|---|---|
surf_name
|
str
|
name of the surface |
required |
Returns:
Name | Type | Description |
---|---|---|
idx_surf |
int
|
index of the surface |
get_surface_names(remove_dublicated=False)
¶
get the surface names from the geometry
Parameters:
Name | Type | Description | Default |
---|---|---|---|
remove_dublicated
|
Optional[bool]
|
remove the surface that were created by duplication about symmetry planes |
False
|
Returns:
Name | Type | Description |
---|---|---|
surf_names |
List[str]
|
list of surface names |
get_surface_param(surf_name, param)
¶
Get a parameter of a specified surface
Parameters:
Name | Type | Description | Default |
---|---|---|---|
surf_name
|
str
|
the surface containing the parameter |
required |
param
|
str
|
the surface parameter to return. Could be either geometric or paneling |
required |
Returns:
Name | Type | Description |
---|---|---|
param |
ndarray
|
the parameter of the surface |
get_surface_params(include_geom=True, include_paneling=False, include_con_surf=False, include_airfoils=False)
¶
get all the surface level parameters for each suface
Parameters:
Name | Type | Description | Default |
---|---|---|---|
include_geom
|
bool
|
flag to include geometry data in the output. The data is ["scale", "translate", "angle", "xles", "yles", "zles", "chords", "aincs", "xasec", "sasec", "tasec", "clcdsec", "claf"] |
True
|
include_paneling
|
bool
|
flag to include paneling information in the output. The data ["nchordwise", "cspace","nspan", "sspace","sspaces","nspans","yduplicate", "use surface spacing", "component"] |
False
|
include_con_surf
|
bool
|
flag to include control surface data in the output. This is data like the hinge vector and gain. |
False
|
include_airfoils
|
bool
|
flag to include airfoil file data in the output |
False
|
Return
surf_data: Nested dictionary where the 1st key is the surface name and the 2nd key is the parameter.
get_system_matrix()
¶
returns the system matrix used for the eigenmode calculation
Returns:
Name | Type | Description |
---|---|---|
asys |
ndarray
|
2D array representing the system matrix for the eigen value analysis |
get_total_forces()
¶
Get the aerodynamic data for the last run case and return it as a dictionary.
Returns:
Type | Description |
---|---|
Dict[str, float]
|
Dict[str, float]: Dictionary of aerodynamic data. The keys the aerodyanmic coefficients. |
plot_cp()
¶
create a matplotlib plot of the surface and cp distribution
plot_geom(axes=None)
¶
generate a matplotlib plot of geometry
Parameters:
Name | Type | Description | Default |
---|---|---|---|
axes
|
Matplotlib axis object to add the plots too. If none are given, the axes will be generated. |
None
|
set_avl_fort_arr(common_block, variable, val, slicer=None)
¶
set data from the Fortran level common block data structure. see AVL.INC for all availible variables
Parameters:
Name | Type | Description | Default |
---|---|---|---|
common_block
|
str
|
Name of the common block of the variable like |
required |
variable
|
str
|
Name of the variable to retrive |
required |
val
|
float
|
value to set, which can be a numpy array |
required |
slicer
|
Optional[slice]
|
slice applied to the common block variable to return a subset of the data. i.e. (100) or slice(2, 5) |
None
|
set_con_surf_param(surf_name, idx_slice, param, val, update_geom=True)
¶
returns the parameters that define the control surface
Parameters:
Name | Type | Description | Default |
---|---|---|---|
surf_name
|
str
|
the name of the surface containing the control surface |
required |
idx_slice
|
int
|
the section index of the control surface data |
required |
param
|
str
|
control surface parameter to set |
required |
val
|
float
|
value to set |
required |
update_geom
|
Optional[bool]
|
flag to update the geometry after setting |
True
|
set_constraint(var, val, con_var=None)
¶
Set the constraints on the analysis case (equivalent to setting a variable in AVL's OPER menu)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
var
|
str
|
variable to be constrained ["alpha"", "beta"", "roll rate", "pitch rate", "yaw rate"] or any control surface. |
required |
val
|
float
|
target value of |
required |
con_var
|
str
|
variable output that needs to be constrained. It could be any value for |
None
|
set_parameter(param_key, param_val)
¶
modify a parameter of the run (analogous to M from the OPER menu in AVL).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
param_key
|
str
|
parameter to modify. Options are ["alpha", "beta", "pb/2V", "qc/2V", "rb/2V", "CL"] |
required |
param_val
|
float
|
value to set |
required |
set_surface_param(surf_name, param, val, update_geom=True)
¶
Get a parameter of a specified surface
Parameters:
Name | Type | Description | Default |
---|---|---|---|
surf_name
|
str
|
the surface containing the parameter |
required |
param
|
str
|
the surface parameter to return. Could be either geometric or paneling |
required |
val
|
float
|
value to set |
required |
update_geom
|
bool
|
flag to update the geometry after setting |
True
|
set_surface_params(surf_data)
¶
set the give surface data of the current geometry. ASSUMES THE CONTROL SURFACE DATA STAYS AT THE SAME LOCATION
Parameters:
Name | Type | Description | Default |
---|---|---|---|
surf_data
|
Dict[str, Dict[str, any]]
|
Nested dictionary where the 1st key is the surface name and the 2nd key is the parameter. |
required |
set_trim_condition(variable, val)
¶
Set a variable of the trim condition (analogus to the AVL's C1 command from the OPER menu)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
variable
|
str
|
variable to be set. Options are ["bankAng", "CL", "velocity", "mass", "dens", "G", "X cg","Y cg","Z cg"] |
required |
val
|
float
|
value to set the variable to |
required |
write_geom_file(filename)
¶
write the current geometry to a file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str
|
name of the output AVL-style geometry file |
required |
write_tecplot(file_name, solution_time=None)
¶
Write a tecplot file of the current surface and Cp distribution
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_name
|
str
|
Name of the output file |
required |
solution_time
|
float
|
Add a solution time to the output. This is useful for flipping through data in tecplot, but breaks Paraview. |
None
|