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