Extracted Wetted Area Calculations from OpenVSP using Python API

182 views
Skip to first unread message

Jon Watts

unread,
Apr 11, 2022, 9:31:44 AM4/11/22
to OpenVSP
Hi all,

I think potentially quite a naïve post from me here. I'm attempting to run the CompGeom function in OpenVSP so that I can obtain the wetted area information of my aircraft, but purely by using the Python API to do it.

I've seen a mixture of previous threads, and couple of tutorials too, discussing CompGeom and AnalysisMgr but sadly am still just very much baffled as to what I actually need to code in order to run any of it.

I'm at a bit of a loss as to where to go from this below:

# OpenVSP Imports
import openvsp as vsp
from openvsp import COMP_GEOM_CSV_TYPE

vsp.ComputeCompGeom(vsp.SET_ALL, False, COMP_GEOM_CSV_TYPE)

where the end result of this is my laptop going into tornado mode and once the line above is run, it can't seem to stop itself even if the process is stopped in the IDE. Just for reference, this code is at the end of a SUAVE script that writes the vehicle to OpenVSP (in .vsp3) format successfully immediately prior.

I can only assume that I have missed something very significant and probably obvious here, for example it occurs to me that there is nothing in the line to target a specific file. So I'm not sure if that's what I need to add, and if so, how to set that.

Any advice would be greatly appreciated, and apologies again for what I'm sure is a bit of a daft enquiry!

Kind regards,
Jon

Rob McDonald

unread,
Apr 11, 2022, 11:43:06 AM4/11/22
to ope...@googlegroups.com
Here is an example script that shows how to work with AnalysisMgr and ResultsMgr.

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/3b9eca89-8519-461e-af1d-1858bcf3dbe1n%40googlegroups.com.
AnalysisTutorial.py

Jon Watts

unread,
Apr 13, 2022, 8:35:31 AM4/13/22
to OpenVSP
Thank you very much for that Rob!

I've got that working great with CompGeom now (unsurprisingly as that was the example one in the script) and am now going to try setting it up for MassProp as well - hopefully I'll be able to figure that out myself!

Kind regards,
Jon

Jon Watts

unread,
Apr 13, 2022, 11:22:42 AM4/13/22
to OpenVSP
Hi Rob,

I've tried looking at doing a similar sort of thing with MassProp, but have run into some trouble in that I don't fully understand what the inputs are for the function. I'm aware that in the tutorial file you sent me that vsp.PrintAnalysisInputs("MassProp") (or "CompGeom" originally) should then send a list of available inputs for the analysis to stdout. My problem is that stdout is currently a SwigPyObject that I'm unsure how to access or work with. I've tried a few things and looking online elsewhere, but haven't found anything very helpful.

If you have any further advice on this it would be much appreciated as I think with this information I would hopefully be able to proceed without assistance from here, as everything else theoretically makes sense to me.

Kind regards,
Jon

Rob McDonald

unread,
Apr 13, 2022, 12:48:45 PM4/13/22
to ope...@googlegroups.com
Truth is, I'm pretty terrible at Python and am probably not the person to ask about getting stdout to show up in your environment.  You can probably redirect it somehow, but I would only be able to google it for you.

Are you running in an IDE or at the command line?  Your IDE probably redirects stdout somewhere -- you might try running from the command line.

Before PrintAnalysisInputs() was added to the API, I implemented essentially the same thing in AngelScript.  It was super useful, so we made it 'official'.

That said, I kept the original around (as an AngelScript script) as an example.  You might look there for a template of how to implement your own version of PrintAnalysisInputs natively in Python.

Or, you can look at the source code where MassProp is registered as an analysis.  That will show that there are only two inputs -- the Set used and NumMassSlices.

The results is a little more spread out.  Here is the code where MassProp is implemented.  The Results object is 'res' (line 3013).  Information is added to the results object throughout the function -- every place there is a res->Add() (3014-3019,3034,3035,3422-3444, 3477)

Rob


Reply all
Reply to author
Forward
0 new messages