Python API Question

39 views
Skip to first unread message

Hansen Lian

unread,
Jul 12, 2024, 10:52:22 PM (8 days ago) Jul 12
to OpenVSP
Forgive me if I'm overlooking a really easy solution, but I've been quite stuck on trying to implement the adjoint method for VSPAERO using the Python API. I've managed to use the API to run an "VSPAEROSweep" analysis (called by vsp.ExecAnalysis(<analysis name>)) but I'm getting confused in the required imports needed to access the optimizer and other adjoint functions here https://github.com/OpenVSP/OpenVSP/tree/main/src/vsp_aero. Basically, what are the import steps in a Python script I can write to follow the steps shown in the 2022 workshop slides  fetch.php (openvsp.org)?




I think I'm just getting a little confused on the package structure.
Here's a skeleton of what I currently have (which is pretty much straight ripped from the AngelScript examples).

If I want to define a VSP_OPTIMIZER, for example, what import statement is needed on top of import openvsp as vsp?

import openvsp as vsp
vsp.VSPCheckSetup()
vsp.VSPRenew()

vsp.ReadVSPFile("notional_vehicle.vsp3")

analysis_name = "VSPAEROSweep"
//load inputs, etc. etc...
//for example...
vsp.SetIntAnalysisInput( analysis_name, "AlphaNpts", [0], 0 )
mach = [0.8]

vsp.SetDoubleAnalysisInput( analysis_name, "MachStart", mach, 0 )

rid = vsp.ExecAnalysis( analysis_name )

Rob McDonald

unread,
Jul 13, 2024, 2:07:13 AM (8 days ago) Jul 13
to OpenVSP
I don't believe the API is set up to use the adjoint version or optimizer version of VSPAERO -- both of which are experimental.

If you want to play with those, you'll have to run them from the command line.

Rob

Hansen Lian

unread,
Jul 13, 2024, 7:07:23 PM (8 days ago) Jul 13
to OpenVSP
Alright, thanks for the clarification! I think I was left a little confused due to this announcement, which mentioned something about time-gradients being tied to the API: OpenVSP 3.30.0 Released (google.com). Wondering if there is any other solution using the API besides wrapping around a script that will run from the command line. I'm currently trying to write a sort of OpenMDAO component that wraps around the VSPAERO tool, that can compute partial derivatives of the outputs with respect to flight conditions (alpha, mach) for a fixed geometry. My first thought was if there is no adjoint available, I was thinking I could use complex-step or finite difference, but still relatively new to this so was wondering if there are any other available methods in the API I can use to quickly compute the perturbations of the inputs, or if I will have to find a way to wrap an external component around the command line.

Thanks!

Rob McDonald

unread,
Jul 13, 2024, 7:17:04 PM (8 days ago) Jul 13
to ope...@googlegroups.com
You can run a static stability run.  It will perform a finite difference of the quantities and compute the S&C derivatives.

This should be possible through the API.

However, try it through the GUI first.  Run a test case, get familiar with how it works.  See if it meets your needs.

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 on the web visit https://groups.google.com/d/msgid/openvsp/44002fae-3f80-4905-a623-e109f271cf71n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages