Some questions about the API of OpenVSP

1,192 views
Skip to first unread message

Yifan Fu (be happy)

unread,
Mar 7, 2023, 3:37:45 AM3/7/23
to OpenVSP
I recently ran into some problems with aerodynamic simulations of a two-bladed propeller using OpenVSP via python. In my code, RPM, Vinf, Rho and RotatingBlades are set, but from the results, these settings don't seem to work . (I am currently using version 3.26.1 and some of the functions on the official website do not work, and when I change the version to 3.32, I cannot enable the VSPAERO module) I would like to ask what command should I use to satisfy my above needs? Or is there y some code here about similar propeller simulation for me to learn?
PS: I use 'SetIntAnalysisInput' to display my input and the parameters are set correctly.
I would be grateful if you could help me with this problem.
vsp.PNGpython.PNG
vsp_prop.py

Garrett Klunk

unread,
Mar 7, 2023, 11:54:44 AM3/7/23
to OpenVSP
One thing I would try first is adding the following lines:

  vsp.Update()
  vsp.WriteVSPFile("TEMP.vsp3",vsp.SET_ALL)
  pass

just under where you're calling "vsp.SetIntAnalysisInput()" to update your values and add a debug breakpoint on "pass". The parm values you prescribe should be assigned to their respective parms with the "vsp.Update()" call, and the "vsp.WriteVSPFile()" call will write a TEMP.vsp3 VSP file including those changes so you can open it in the GUI and verify your changes have been applied properly.

Yifan Fu (be happy)

unread,
Mar 7, 2023, 12:05:56 PM3/7/23
to OpenVSP
Thank you for the suggestion! I debugged the updated code. It still doesn't show the settings I expect when I open it in the GUI. It may be that I am using an inappropriate command that prevents me from setting some options of VSPAERO. I would like to ask if you can advise me on what commands to use to meet some of my settings for VSPAERO (e.g. Vinf, Rho, etc.)

Rob McDonald

unread,
Mar 7, 2023, 12:13:45 PM3/7/23
to ope...@googlegroups.com
This is not surprising or a bug.  It may not be intuitive, but this is by design.

The GUI displays values of Parms.  Parms get written to the *.vsp3 file.  They are the permanent variables used to store stuff in OpenVSP.

When you use Analysis Manager to run an analysis, you set variables via 'SetXXXAnalysisInput'.  When you do this, every AnalysisInput already has a default value -- that default is not hard-coded, it was obtained from the corresponding Parm value in the model.

Let's say you set one of the AnalysisInput values to something different than the default (the value held in the Parm).  And then you Execute the analysis.

At that time, OpenVSP makes a backup copy of the value stored in Parm.  It then takes the value you set in AnalysisInput and assigns the Parm to that value. It then Executes the analysis tool (whatever that does).  When complete, it parses the results into the ResultsManager data structures.  It then restores the backed up values of the inputs to the Parms -- i.e. the Parms do not permanently take on the value set via AnalysisInput.

Consequently, when you save this file to a *.vsp3, it will not reflect your AnalysisInput values.

However, you can open a *.vsp3 file in the GUI, go to all the appropriate screens and set the Parm values - and save that *.vsp3 file.  Then, when you open that file via the API and run an analysis, all the AnalysisInputs should have the default values you set in the GUI.

If you want to create a file from scratch in the API -- and you want to change the analysis Parm values (to change the Analysis Input defaults and have those values recorded to an eventual *.vsp3 file), then you need to change those variables using the 'normal' routines for changing Parm values -- just like you would for wing span or fuselage length, or whatever.

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/a7e140b9-01f5-40fc-83c1-fe5d87ede4cfn%40googlegroups.com.

Yifan Fu (be happy)

unread,
Mar 8, 2023, 7:04:01 AM3/8/23
to OpenVSP
Rob
Thanks for the suggestion, I tried to specify my in-flow condition Vinf=6 like I did with the wing span. but there were some errors, I made some attempts, but I still can't specify anything else except the RPM. Could you please tell me exactly which command to use to achieve what I need?
code.PNGerror.PNG

Brandon Litherland

unread,
Mar 8, 2023, 10:49:06 AM3/8/23
to OpenVSP
It seems that you are looking at the Prop ID for VSPAERO settings.  The container that holds those parameters is VSPAEROSettings.  You can search this forum on how to use the Design Variable window to seek out parameters, groups, and containers.  The VSPSCRIPT below will update the model Vinf parameter.

void main()
{
    string aero_id = FindContainer( "VSPAEROSettings", 0);
    SetParmVal(aero_id, "Vinf", "VSPAERO", 6.0);
Update();
}


Yifan Fu (be happy)

unread,
Mar 8, 2023, 11:13:21 AM3/8/23
to OpenVSP

 Thank you very much! You have solved my problems these days, thank you!

Yifan Fu (be happy)

unread,
Mar 8, 2023, 11:22:25 AM3/8/23
to OpenVSP
I still have a question about which command I should choose to perform my next analysis. When I choose to use vsp.ExecAnalysis(analysis="VSPAEROSinglePoint") to perform the analysis, the results are different from the results I get when I click launch solvers on the generated .vsp3 file through the GUI interface . It seems that I am using the incorrect command. So what command should I use to analyze the .vsp3 I generated in the previous step?

Yifan Fu (be happy)

unread,
Mar 11, 2023, 3:43:12 AM3/11/23
to OpenVSP
Sorry, I really need your help. I noticed that for non-stationary rotating blades, the README file mentions that after I get the .vsp3 file, I then open the `prop.vsp3` file in that directory, go to the `VSPAERO... ` GUI and click on `Launch Solver`. I would like to ask how to implement this function by clicking "Launch Solver" through python code?readme.PNG

Brandon Litherland

unread,
Mar 11, 2023, 6:55:47 AM3/11/23
to OpenVSP
When you run a VSPAEROSweep analysis from the API, having the rotating blades flag active or True should tell the solver to use the appropriate mode.  You will have to ensure that you are setting all of the appropriate unsteady solver values as well.

OpenVSP 3.32.0 saw the introduction of analysis input documentation to the API via the PrintAnalysisDocs() function.  I tried executing this from the Python API after installing 3.32.1 but it didn't read the function.  However, the function is available from the command line using AngelScript (or Run Script... from the GUI).  The documentation for VSPAEROSweep is below.  With this information and the example VSPAERO scripts in the /scripts/ folder distributed with OpenVSP, I think you'll be able to get up and running.  If you need to check if your settings from the API match what you've run from the GUI, use the PrintAnalysisInput() function and compare the values.

Good luck!

VSPAEROSweep
Perform VSPAERO calculation while sweeping flow condition.
   [input_name]                  [type]         [doc]
   2DFEMFlag                     integer        Flag to write 2D FEM file.
   ActuatorDiskFlag              integer        Flag to model propellers or rotors as actuator disks.
   AlphaEnd                      double         Alpha sweep end point.
   AlphaNpts                     integer        Number of points in alpha sweep.
   AlphaStart                    double         Alpha sweep starting point.
   AlternateInputFormatFlag      integer        Flag to use alternate input file format.
   AnalysisMethod                integer        Flag to indicate analysis method (thin vs. thick).
   AutoTimeNumRevs               integer        Number of desired revolutions for computing automatic time step.
   AutoTimeStepFlag              integer        Flag to automatically determine time step.
   BetaEnd                       double         Beta sweep end point.
   BetaNpts                      integer        Number of points in Beta sweep.
   BetaStart                     double         Beta sweep starting point.
   CGGeomSet                     integer        Geometry set for center of gravity computation.
   Clmax                         double         CL max value.
   ClmaxToggle                   integer        Flag to enable stall model.
   FarDist                       double         Far field distance.
   FarDistToggle                 integer        Far field distance toggle.
   FixedWakeFlag                 integer        Flag to use fixed wake with no relaxation.
   FromSteadyState               integer        Start unsteady solution from steady state.
   GeomSet                       integer        Geometry Set for analysis.
   GroundEffect                  double         Height aboe ground.
   GroundEffectToggle            integer        Flag to enable ground effect model.
   HoverRamp                     double         Hover ramp value.
   HoverRampFlag                 integer        Flag to enable hover ramp.
   KTCorrection                  integer        Compressibility correction enum.
   MachEnd                       double         Mach number sweep end point.
   MachNpts                      integer        Number of points in Mach number sweep.
   MachStart                     double         Mach number sweep starting point.
   Machref                       double         Reference Mach number.
   ManualVrefFlag                integer        Flag to enable setting Vref different from Vinf.
   MassSliceDir                  integer        Slicing direction for mass properties.
   MaxTurnAngle                  double         Max turning angle value.
   MaxTurnToggle                 integer        Flag to enable max turning model.
   NCPU                          integer        Number of processors to use for computation.
   NoiseCalcFlag                 integer        Flag to enable noise calculations.
   NoiseCalcType                 integer        Noise calculation type enum.
   NoiseUnits                    integer        Units ot use for noise calculations.
   NumMassSlice                  integer        Number of slices for CG computation.
   NumTimeSteps                  integer        Number of time steps in unsteady simulation.
   NumWakeNodes                  integer        Number of wake nodes.
   Precondition                  integer        Matrix preconditioner mode enum.
   ReCref                        double         Reynolds number sweep starting point.
   ReCrefEnd                     double         Reynolds number sweep end point.
   ReCrefNpts                    integer        Number of points in Reynolds number sweep.
   RefFlag                       integer        Flag to control how reference quantities are set.
   Rho                           double         Freestream density.
   RotateBladesFlag              integer        Flag to model propellers or rotors as unsteady rotating blades.
   Sref                          double         Reference area.
   Symmetry                      integer        Symmetry mode enum.
   TimeStepSize                  double         Unsteady time step.
   UnsteadyType                  integer        Stability and control mode enum.
   Vinf                          double         Freestream airspeed.
   Vref                          double         Reference airspeed.
   WakeNumIter                   integer        Number of wake iterations.
   WingID                        string         Reference wing GeomID.
   Xcg                           double         X moment reference point.
   Ycg                           double         Y moment reference point.
   Zcg                           double         Z moment reference point.
   bref                          double         Reference span.
   cref                          double         Reference chord.

Yifan Fu (be happy)

unread,
Mar 11, 2023, 10:30:02 AM3/11/23
to OpenVSP
Sir, thank you very much for your help. I may have overlooked VSPAEROSweep before, but now that my problem is solved, I can have a good night's sleep tonight! Thanks again for your help!
Reply all
Reply to author
Forward
0 new messages