Groups
Groups

VSPAERO Python API Stability Results Missing

232 views
Skip to first unread message

Nathan Collins

unread,
Jan 20, 2025, 1:46:40 PM1/20/25
to OpenVSP
Hi - working on a big tool that defines operating points and trims them using VSPAERO Stability results. I used to locate the stability results using vsp.GetLatestResultsID("VSPAERO_Stab") which worked until the updated released today (although I rolled back my version and have the same issue). Attached is the code. Note that the part that prints out all analysis names does not show VSPAERO_Stab. The .stab file also appear empty after running the analysis.

    def _simulate(self):
        """Single iteration of simulation"""
        analysisString = "VSPAEROSweep"
        vsp.SetAnalysisInputDefaults(analysisString)
       
        # Set static parameters
        vsp.SetIntAnalysisInput(analysisString, "GeomSet", [1])  # Use Set 0
        vsp.SetDoubleAnalysisInput(analysisString, "MachStart", [self.getParameter("Mach")['value']])
        vsp.SetDoubleAnalysisInput(analysisString, "ReCref", [self.getParameter("Re")['value']])
        vsp.SetDoubleAnalysisInput(analysisString, "Vinf", [self.getParameter("velocity")['value']])
        vsp.SetDoubleAnalysisInput(analysisString, "Vref", [self.getParameter("velocity")['value']])
        vsp.SetDoubleAnalysisInput(analysisString, "Rho", [self.getParameter("density")['value']])
        mconfig = config.getMassConfiguration(self.getParameter("massconfig_index")['value'])
        vsp.SetDoubleAnalysisInput(analysisString, "Xcg", [mconfig.cg[0]])
        vsp.SetDoubleAnalysisInput(analysisString, "Ycg", [mconfig.cg[1]])
        vsp.SetDoubleAnalysisInput(analysisString, "Zcg", [mconfig.cg[2]])


        vsp.SetStringAnalysisInput(analysisString, "RedirectFile", [""])

        vsp.SetIntAnalysisInput(analysisString, "AnalysisMethod", [vsp.VORTEX_LATTICE])
        vsp.SetIntAnalysisInput(analysisString, "NCPU", [config.settings["num_procs"]])
        vsp.SetIntAnalysisInput(analysisString, "UnsteadyType", [vsp.STABILITY_DEFAULT])
        vsp.SetIntAnalysisInput(analysisString, "2DFEMFlag", [0])

        # Set inputs that change from iteration to iteration
        vsp.SetDoubleAnalysisInput(analysisString, "AlphaStart", [self._getNextInput("alpha")])
        vsp.SetIntAnalysisInput(analysisString, "AlphaNpts", [1])
        vsp.SetDoubleAnalysisInput(analysisString, "AlphaEnd", [self._getNextInput("alpha")])

        vsp.SetDoubleAnalysisInput(analysisString, "BetaStart", [self._getNextInput("beta")])
        vsp.SetIntAnalysisInput(analysisString, "BetaNpts", [1])
        vsp.SetDoubleAnalysisInput(analysisString, "BetaEnd", [self._getNextInput("beta")])
        control_group_settings_container = vsp.FindContainer("VSPAEROSettings",0)
        for key in self.controls.keys():
            #need to get ID of control group
            group_id = self.controls[key]["details"]["id"]
            deflection_angle_id = vsp.FindParm(control_group_settings_container, "DeflectionAngle", f"ControlSurfaceGroup_{group_id}")
            vsp.SetParmVal(deflection_angle_id, self._getNextInput(key))

        vsp.PrintAnalysisInputs(analysisString)

        #TODO: There are so many more inputs I can set. need to investigate further
        #TODO: Can add multiple levels of fidelity depending on how far from convergence we are (currently does not need to be so high)
       
        #Actually run VSPAERO
        try:
            self._recentResultID = vsp.ExecAnalysis("VSPAEROSweep")
        except Exception as e:
            console.print(f"{self._prefix} Error during simulation: {e}")
            self._recentResultID = None
 

Adjei Ameyaw

unread,
Feb 5, 2025, 9:57:49 AM2/5/25
to OpenVSP
Hello Nathan,
I don't have answers for your question, but I wanted to ask you a question of my own seeing you have understanding of the VSPAero simulation. I have an issue with my code where I am not getting simulation results and I wanted to know if you wouldn't mind going through my code and telling me what I am doing wrong. Thanks

Nathan Collins

unread,
Feb 6, 2025, 2:20:30 PM2/6/25
to OpenVSP
Hey - It can be pretty finicky to see what's wrong. I would suggest watching the output of vspaero. If you're seeing real numbers as it goes through the analysis, then it's probably your code. If you're seeing NaN or IND in the output as it runs then it's probably a problem with the geometry you included. This happened to me when I accidentally included my inlet (a stack object) when running VSPAERO in VLM mode, and the solution failed. It would finish executing, but no results would be available after. If you can show me more specifically what the problem is I might be able to help.

Adjei Ameyaw

unread,
Feb 6, 2025, 2:28:09 PM2/6/25
to OpenVSP
Hello Nathan, this is My code. Can you please tell me if you see anything wrong with it. Because when I run on the GUI I get real results.


vsp.ClearVSPModel()
vsp.ReadVSPFile("S3_Viking.vsp3")
vsp.Update()

compGeom = "VSPAEROComputeGeometry"
vsp.SetAnalysisInputDefaults(compGeom)
method = list(vsp.GetIntAnalysisInput(compGeom, "AnalysisMethod"))
method[0] = vsp.VORTEX_LATTICE
vsp.SetIntAnalysisInput(compGeom, "AnalysisMethod", method)



#vsp.PrintAnalysisInputs(compGeom)
vsp.ExecAnalysis(compGeom)


analysis_name = "VSPAEROSweep"
#vsp.SetIntAnalysisInput(analysis_name, "AnalysisMethod", [vsp.VORTEX_LATTICE])
vsp.SetAnalysisInputDefaults(analysis_name)

vsp.SetDoubleAnalysisInput(analysis_name, "MachStart", [0])
vsp.SetIntAnalysisInput(analysis_name, "MachNpts", [1])

vsp.SetDoubleAnalysisInput(analysis_name, "AlphaStart", [0])
vsp.SetDoubleAnalysisInput(analysis_name, "AlphaEnd", [10.0])
vsp.SetIntAnalysisInput(analysis_name, "AlphaNpts", [3]) # Number of alpha points

vsp.SetDoubleAnalysisInput(analysis_name, "ReCref", [1e7]) # Reynolds number
vsp.SetIntAnalysisInput(analysis_name, "NumWakeNodes", [32])

vsp.SetIntAnalysisInput(analysis_name, "WakeNumIter", [5])
# Analysis method

vsp.SetIntAnalysisInput(analysis_name, "UnsteadyType", [vsp.STABILITY_DEFAULT])

vsp.Update()

allResults = vsp.ExecAnalysis(analysis_name)


#Process report
history_res = vsp.FindLatestResultsID("VSPAERO_History")
CL = vsp.GetDoubleResults(history_res, "CL",0)
CDtot = vsp.GetDoubleResults(history_res, "CDtot",0)
L2D = vsp.GetDoubleResults(history_res, "L/D",0)
E = vsp.GetDoubleResults(history_res, "E",0)
CMy = vsp.GetDoubleResults(history_res, "CMy",0)
print(CL[-1])
print(CDtot[-1])
print(L2D[-1])
print(E[-1])
Reply all
Reply to author
Forward

Nathan Collins

unread,
Feb 6, 2025, 2:30:58 PM2/6/25
to OpenVSP
The only thing I can see wrong is you don't select a GeomSet. I usually push in 1 and that seems to use the currently shown geometry set.

Adjei Ameyaw

unread,
Feb 6, 2025, 2:33:30 PM2/6/25
to OpenVSP
you mean something like this ?
vsp.SetIntAnalysisInput(analysis_name, "GeomSet", [1])

Nathan Collins

unread,
Feb 6, 2025, 2:34:30 PM2/6/25
to OpenVSP
Yeah

Adjei Ameyaw

unread,
Feb 6, 2025, 2:36:35 PM2/6/25
to OpenVSP
Thanks, I will try it out. Sorry for taking over your discussion.
Reply all
Reply to author
Forward
0 new messages
Search
Clear search
Close search
Google apps
Main menu