optvl_class
This module contains the OVLSolver, which is the main wrapper for the Fortran level API.
OVLSolver
¶
Bases: object
__get_des_var_param(surf_name, idx_sec, param)
¶
Returns the parameters that define the control surface. Can also get design variables (AVL).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
surf_name
|
str
|
the name of the surface containing the control surface |
required |
idx_sec
|
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 |
__init__(geo_file=None, mass_file=None, input_dict=None, debug=False, timing=False)
¶
Initalize the python and fortran libary from the given objects
Parameters:
Name | Type | Description | Default |
---|---|---|---|
geo_file
|
Optional[str]
|
AVL geometry file |
None
|
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_index(body_name)
¶
Given a body name returns the index
Parameters:
Name | Type | Description | Default |
---|---|---|---|
body_name
|
str
|
name of the body |
required |
Returns:
Name | Type | Description |
---|---|---|
idx_body |
int
|
index of the body |
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_param(body_name, param)
¶
Get a parameter of a specified body
Parameters:
Name | Type | Description | Default |
---|---|---|---|
body_name
|
str
|
the body containing the parameter |
required |
param
|
str
|
the body parameter to return. Could be either geometric or paneling |
required |
Returns:
Name | Type | Description |
---|---|---|
val |
ndarray
|
the val of parameter of the body |
get_body_params(include_body_oml=False)
¶
Get the parameters of the bodies
Parameters:
Name | Type | Description | Default |
---|---|---|---|
include_body_oml
|
bool
|
include the raw oml coordinates in the output dict |
False
|
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_sec, param)
¶
Returns the parameters that define the control surface. Can also get design variables (AVL).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
surf_name
|
str
|
the name of the surface containing the control surface |
required |
idx_sec
|
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_design_var_names()
¶
Get the names of the design_var surfaces
Returns:
Name | Type | Description |
---|---|---|
design_var_names |
List[str]
|
list of design_var surface names |
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_header_params()
¶
Gets the header input settings in AVL and returns them in a dictionary.
Returns:
Type | Description |
---|---|
Dict
|
Dict[str]: Dictionary containing the header input settings in AVL |
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_input_dict(include_surfaces=True, include_section_geom=False, include_bodies=True)
¶
Returns all input information from AVL in input dictionary format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
include_surfaces
|
bool
|
Include all surfaces in the dictionary. Defaults to True. |
True
|
include_section_geom
|
bool
|
Include all the section geometry information for each surface. Defaults to False. |
False
|
include_bodies
|
bool
|
Include all bodies in the dictionary. Defaults to True. |
True
|
Returns:
Type | Description |
---|---|
Dict[str, Dict[str, Any]]
|
Dict[str, Dict[str, Any]]: OptVL input dictionary |
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. Does not get control surface or design variables.
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_section_geom=False, include_paneling=False, include_con_surf=False, include_des_vars=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", "clcdsec", "claf"] |
True
|
include_section_geom
|
bool
|
flag to include section geometry data in the output. The data is ["xasec", "sasec", "tasec", xuasec, xlasec, zlasec, zuasec, casec, nasec] |
False
|
include_paneling
|
bool
|
flag to include paneling information in the output. The data ["nchordwise", "cspace","nspan", "sspace","sspaces","nspans","yduplicate", "wake", "able", "load", "use surface spacing", "component"] |
False
|
include_con_surf
|
bool
|
flag to include control surface and design variable 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. |
load_input_dict(input_dict, preCheck=True, postCheck=False)
¶
Reads and loads the input dictionary data into optvl. Equivalent to INPUT routine in AVL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_dict
|
dict
|
input dictionary in optvl format |
required |
preCheck
|
bool
|
perform additional verification of the user's input dictionary before loading into AVL |
True
|
postCheck
|
bool
|
verify certain inputs values are correctly reflected in the Fortran layer |
False
|
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
|
post_check_input(inputDict)
¶
This routine verifies that a few critical values in the Fortran layer have been set correctly with regard to the input dict.
To be expanded later...
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_body_coordinates(ibod, nasec, x, y, storecoords=False)
¶
Sets the body of revolution oml points for the specified body. Computes the camber line and interpolates it with AVL's 1D Akima Spline implementation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ibod
|
int
|
body number to set the outer mold line too |
required |
nasec
|
int
|
number of points to evaluate the interpolated camber line and thickness curves at |
required |
x
|
ndarray
|
oml x-coordinate array |
required |
y
|
ndarray
|
oml y-coodinate array |
required |
xfminmax
|
length 2 array with the min and max x/c to slice the oml |
required | |
storecoords
|
bool
|
store the raw input coordinates in common block |
False
|
set_body_param(body_name, param, val, update_geom=True)
¶
Set a parameter of a specified body
Parameters:
Name | Type | Description | Default |
---|---|---|---|
body_name
|
str
|
the body containing the parameter |
required |
param
|
str
|
the surface parameter to return. Could be either geometric or paneling |
required |
val
|
value to set |
required | |
update_geom
|
bool
|
flag to update the geometry after setting |
True
|
set_body_params(body_data)
¶
Set the give body data of the current geometry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
body_data
|
Dict[str, Dict[str, Any]]
|
Nested dictionary where the 1st key is the body name and the 2nd key is the parameter. |
required |
set_con_surf_param(surf_name, idx_slice, param, val, update_geom=True)
¶
Sets the parameters that define the control surface. Can also set design variables (AVL).
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_section_coordinates(isec, isurf, nasec, x, y, xfminmax, storecoords=False)
¶
Sets the airfoil oml points for the specified surface and section. Computes the camber line and interpolates it with AVL's 1D Akima Spline implementation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
isec
|
int
|
section number to set the airfoil mesh |
required |
isurf
|
int
|
surface number to set the airfoil mesh |
required |
nasec
|
int
|
number of points to evaluate the interpolated camber line and thickness curves at |
required |
x
|
ndarray
|
airfoil x-coordinate array |
required |
y
|
ndarray
|
airfoil y-coodinate array |
required |
xfminmax
|
ndarray
|
length 2 array with the min and max x/c to slice the airfoil |
required |
storecoords
|
bool
|
store the raw input coordinates in common block |
False
|
set_section_naca(isec, isurf, nasec, naca, xfminmax)
¶
Sets the airfoil oml points for the specified surface and section. Computes camber lines, thickness, and oml shape from NACA 4-digit specification.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
isec
|
int
|
section number to set the airfoil mesh |
required |
isurf
|
int
|
surface number to set the airfoil mesh |
required |
nasec
|
int
|
number of points to evaluate the interpolated camber line and thickness curves at |
required |
naca
|
str
|
4-digit naca specificaion as a string |
required |
xfminmax
|
ndarray
|
length 2 array with the min and max x/c to slice the airfoil |
required |
set_surface_param(surf_name, param, val, update_geom=True)
¶
Set a parameter of a specified surface. Supports setting params related to geometry and panelling. Section geometry can be directly set here but this is not recommended. Use set_section_coordinates instead.
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 given data of the current geometry. ASSUMES THE CONTROL SURFACE DATA STAYS AT THE SAME LOCATION (i.e you didn't move the control surfaces to new sections or surfaces. If so re-initialize OptVL)
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
|