Python API Questions

217 views
Skip to first unread message

Nathan Collins

unread,
Jan 5, 2025, 10:14:50 PMJan 5
to OpenVSP
Hi - Building a python wrapper app for OpenVSP aimed at GNC engineers & beginners to stability and control (something like AVL). I represent an undergraduate design team who really like OpenVSP and is extending it's capability. A few questions:

- The API build you install through the setup script that comes with vsp 3.41.. does not have GUI capability. How do you enable that, or is there another way to install with it?
- Is there more detailed information about analysis inputs available? I can see many things as input but definitions are lacking. 
- Is there a good way to make VSPAero faster with steady stability mode enabled? More threads and fewer iterations works well, but my app is doing things like trimming operations (newton-raphson approach) and running multiple iterations when each stability run takes ~200s is very slow.
- Is there a way to globally redirect stdout? Most analysis types can execute silently, but VSPAERO sweep prints out wing reference parameters regardless of what you try, which I'd rather not have.
- Is there any information on the FOpt result? I know there are rumors about optimization algorithms running, and that a future update will share more, but I am interested to know if there's any documentation.

If you think it's helpful, I'll share the git repo. Thanks!

Rob McDonald

unread,
Jan 6, 2025, 11:31:44 AMJan 6
to ope...@googlegroups.com
Nathan - that sounds like a very interesting project.  I'll try to help as I can.  I'm glad that you've found OpenVSP and VSPAERO to be useful.

What do you mean the API does not have GUI capability?  I just looked at the stuff bundled with the 3.41.2 Windows download and the files were all there.  In order to load the OpenVSP API with certain options enabled (such as the GUI), you need to load another package, the openvsp_options package.  You'll use it something like this....

import openvsp_config
openvsp_config.LOAD_GRAPHICS = True
openvsp_config.LOAD_FACADE = True
import openvsp as vsp

What analysis inputs are you asking about?  Most are not documented through the GUI.  However, they do have brief documentation through the Analysis Manager via the API.  I also believe there is some documentation about VSPAERO on the Wiki and also the VSP Ground School.  If you have a specific request, I may be able to point you in the right direction.

If you are just doing pitch trim analysis, I suggest you run in -pitch mode instead of -stab mode.  It will run fewer cases -- just those needed to get the CLalpha and CMalpha derivatives.  If that doesn't run control surface deflections (it might not), then I suggest you just run three cases manually -- one at baseline alpha, deltae, one at perturbed alpha, baseline delta, and one at baseline alpha, perturbed delta (start with 1 degree perturbations).  Then you can finite-difference these cases to estimate your own derivatives and do your trim solution.

Running VSPAERO through the API includes the option 'RedirectFile' which you can set to '' (empty string) to silence most output.  It will still echo the reference quantities.  That is a bug that has been fixed going forward.

Don't worry about FOpt.

There are a ton of changes to VSPAERO and OpenVSP's interaction with it that have been building up for about two years.  These will hopefully be released in the next six weeks or so.  The first release will likely be some sort of Beta release as I expect the transition to the new stuff to be bumpier than our normal upgrade process.

Among other things, the new version will integrate a totally re-written adjoint capability.  This will make stability derivatives much faster and more accurate.  It will also enable built-in modes to take advantage of the adjoint -- these will come later in the year, but I expect us to integrate an optimization tool and also a trim tool sometime this year.

Understanding the demands on your time and how much OpenVSP / VSPAERO is going to be changing going forward, I suggest you focus on solving your immediate problems for your design team.

I can't recommend you invest a lot of time building something elaborate beyond that at this time.  Hopefully we'll get the new stuff sorted and released quickly -- which will allow you to accomplish your goals better and easier than before.

Rob



--
You received this message because you are subscribed to the Google Groups "OpenVSP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openvsp+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/openvsp/daa78701-34e8-43fd-a7ec-13920daceb9bn%40googlegroups.com.

Nathan Collins

unread,
Jan 6, 2025, 12:20:59 PMJan 6
to OpenVSP
Mr. McDonald,

Thanks so much for the reply! In case you're interested, repo is here: https://github.com/machworksvt/utils. It's within the tools folder, main script is streamline.py. I took a lot of inspiration from AVL. 
- The analysis inputs I mentioned are things like "hi-lift" (which we're interested in for automated takeoff controls and better takeoff run estimation). "Precondition" which I understand is about matrix preconditionion, but not something I understand very well, and the "NoiseCalc" inputs.
- How good is the 2DClmax cutoff approximation for stall (I understand that inviscid solvers like VSPAero are just not the right thing to use for stall behavior, but I am wondering if you think an approach based on extraction of airfoil sections, viscous analysis in XFOIL, and extension to a CLmax for the entire wing might be a decent approximation).
- Understood on the redirectfile. I will just stick with the bug for now.
- Doing simply the pitch analysis doesn't work for me unfortunately, I have set up a system of constraints like AVL to allow any type of trimming, and was planning to reform the stability derivatives into a Jacobian (alpha, beta, controls -> coefficients) and use a gradient descent/newton Raphson type solver to find trim conditions. I could set this up manually, but I think I'll just stick with the slow method of using VSPAERO's stab analysis. Is there a way other than manually finding results from the stability analysis ie. "CMm__Yaw_Rate" and placing them back into a matrix?
- I look forward to the release of stab analysis using an adjoint method instead. I come from an optimal control background, and that concept is exciting for me.
- We really want to build this tool out to make development of this airplane and our future aircraft easier. Is it safe to build out capability knowing that the API will remain relatively similar, or should we expect an overhaul on the API overall?

On another note, being from a GNC background, I am interested in learning nonlinear models from this type of analysis. To get the whole picture, my group is trying to make fast, jet-powered UAVs with autonomous capability. Do you have any advice on this? I understand I can sample around the flight envelope to create nonlinear models from huge batch runs of stability analyses and feed them into something like PySiNDy or just make my own model with something like PyTorch. Is there/do you know of a better way?

Thanks,
Nathan

Rob McDonald

unread,
Jan 7, 2025, 12:23:39 PMJan 7
to OpenVSP
The NoiseCalc stuff would tell VSPAERO to write out input files for PSU-WOPWOP, an acoustics propagation code.  This is only relevant in cases with unsteady rotating blades.

The preconditioner settings change how the internal solver works.  You shouldn't need to mess with that setting.

The high lift options include a couple of different ways of modeling stall.  I haven't spent a lot of time working with them and testing them on cases relevant to any particular use.  I would suggest you experiment with the models by comparing to some appropriate data.  For example, it may work better on higher aspect ratio unswept wings (those with less spanwise flow and 3D effects) than it would on low aspect ratio swept wings.

Using VSPAERO's stab analysis sounds like the best way forward for now.  Once the new version comes out, it will calculate all the derivatives very efficiently using the adjoint.

Using VSPAERO through the API (via the Analysis Manager) will change the least.

There will be new input parameters -- and some existing ones will go away.  However, you should pretty quickly be able to figure out a new baseline set of settings and move forward.

VSPAERO's output files are changing -- but mostly in the details, not in significant substance.  This causes a big headache for anyone parsing those files (me), but since I provide them through the ResultsMgr API, you won't see much of a change.  Some output variable names may change, there may be some new outputs.

Right now, we do not do a highly detailed job of parsing the -stab outputs.  This won't change in the near term, but eventually, I want to do a better job parsing that file -- which mostly means putting the data into more meaningful bins in the ResultsMgr.

I don't have a lot of advice on the controls/simulation side of things.  Usually it seems that controls folks do a deep dive at specific points in the flight envelope -- or they have models that they interpolate more broadly and use in flight simulation (which can span the flight envelope).  It seems that depending on the details of your application, a variety of approaches might be reasonable.

Rob

Mike Isted

unread,
Nov 23, 2025, 12:20:53 PM (4 days ago) Nov 23
to OpenVSP
This is a related but extension question. Hope that's ok.

I am trying to use the Python API to generate the .stab file when running VSPAero. Could anyone provide a snippet or guidance to help here please. Tried many things and it won't generate.
Many thanks,

Mike

Rob McDonald

unread,
Nov 23, 2025, 2:43:25 PM (4 days ago) Nov 23
to ope...@googlegroups.com
In the API, the flag that controls the stability mode is actually called 'UnsteadyType'.  This is due to historical reasons.

It is set via an enum that has values:

enum VSPAERO_STABILITY_TYPE { STABILITY_OFF,    /*!< No stability analysis (off) */
STABILITY_DEFAULT, /*!< Steady 6DOF stability analysis */
STABILITY_P_ANALYSIS, /*!< Unsteady roll stability analysis */
STABILITY_Q_ANALYSIS, /*!< Unsteady pitch stability analysis */
STABILITY_R_ANALYSIS, /*!< Unsteady yaw stability analysis */
STABILITY_PITCH, /*!< Simplified pitch stability analysis */
STABILITY_ADJOINT, /*!< Steady 6DOF stability analysis using adjoint */
STABILITY_NUM_TYPES /*!< Number of stability analysis types */

Rob


Mike Isted

unread,
Nov 24, 2025, 1:54:57 AM (4 days ago) Nov 24
to OpenVSP
Thanks Rob, I’ll take a look.
Mike

Brandon Litherland

unread,
Nov 24, 2025, 11:07:06 AM (3 days ago) Nov 24
to OpenVSP
It's been a minute since I've had to mess with these values but for the python API, I think the enums are called using your openvsp or vsp leader as "openvsp.STABILITY_OFF or vsp.STABILITY_OFF" etc.  I'd have to go pull up an example script to check for sure though.
Reply all
Reply to author
Forward
0 new messages