Skip to content

Building a run script

Here we will go over the elements of setting up and running a basic analysis in OptVL in more detail. To see a complete example of a run script see the one in the overview page or the examples on GitHub

Initializing and Setting up AVL Solver

To begin with OptVL, start by initializing the OVLSolver class:

ovl = OVLSolver(geo_file="aircraft.avl")

Like AVL, you can also add a mass file as well.

ovl = OVLSolver(geo_file="aircraft.avl", mass_file="aircraft.mass")

Constraints

After initializing, you can set up various constraints directly. You can set alpha, beta, roll rate, pitch rate, and yaw rate as well as any control surface in this way.

ovl.set_constraint("alpha", 0.00)

You can also set a variable in order to meet a specific constraint value. The valid constraint options are CL, CY, Cl roll moment, Cm pitch moment, Cn yaw moment.

Warning

Be careful to state a constraint variable, con_var, that is affected by the input. For example if you accidentally specify that the pitching moment should be trimmed by the rudder the analysis will not converge.

# set the Elevator to trim Cm to zero
ovl.set_constraint("Elevator", 0.00, con_var="Cm pitch moment")
# set the Rudder to trim Cn to zero
ovl.set_constraint("Rudder", 0.00, con_var="Cn yaw moment")

You can also set parameters of the run case. The list of parameters you can set are CD0, bank, elevation, heading, Mach, velocity, density, grav.acc., turn rad., load fac., X cg, Y cg, Z cg, mass, Ixx, Iyy, Izz, Ixy, Iyz, Izx, visc CL_a, visc CL_u, visc CM_a, visc CM_u,

# set the flow parameters like mach numbers
ovl.set_parameter("Mach", 0.3)

Running Analysis

Once you've set up the solver, running the analysis is straightforward:

ovl.execute_run()

For a more detailed example and advanced use cases, see the analysis guide.

Looking at Data

After executing the run, then you can extract various output data from the solver. The methods for extracting data return a dictionary of data.

To get things like CL, CD, CM, etc., use

force_data = ovl.get_total_forces()
For stability derivatives such as dCm/dAlpha use
stab_deriv = ovl.get_stab_derivs()
And finally for control surface derivatives like dCm/dElevator use
consurf_derivs = ovl.get_control_stab_derivs()

Running an Optimization

See optimization

Visualization

The visualizations described in this section rely on the matplotlib package.

Looking at the geometry

To quickly look at your geometry you can use the

ovl.plot_geom()
command, which will produce a figure that looks like this. aircraft geometry plot

Cp plots

To get a quick view of the coefficient of pressure on the surfaces of the aircraft you can use

ovl.plot_cp()
Which will produce a plot like this.

aircraft cp You can rotate, zoom, and pan in the window to look at different parts for the aircraft. aircraft cp view 2