.bem file through Python API

253 views
Skip to first unread message

Matthew Clarke

unread,
Apr 11, 2021, 3:42:07 AM4/11/21
to OpenVSP
I am trying to import the propeller data from OpenVSP's .bem file into SUAVE (python based). Is this possible through the VSP python API

Rob McDonald

unread,
Apr 11, 2021, 4:05:46 PM4/11/21
to OpenVSP
From the OpenVSP API, the best way to get at the BEM data is through the "BladeElement" analysis.  This will place all the data in a BEM file into a ResultsManager data structure which you can easily access from Python.

This is exactly like exporting a BEM file - and then parsing the file into memory -- but in one step and without writing a file.

Once you have the BEM data in memory, I can't help you with what to do in terms of feeding it to SUAVE.  To my knowledge, SUAVE does not have any detailed propeller analysis capability like a BEM.  Instead, you will likely need to run a separate analysis like XRotor of CCBlade and then parse the results of that analysis to then feed into SUAVE.  Even then, I do not know what level of detail SUAVE will deal with propeller data.  Ask in the SUAVE Google Group for better answers there.

Alternatively, you can export the BEM file - just like going through the Export menu in the GUI using the normal Export API call passing EXPORT_BEM.

Perhaps you use a tool like XRotor or CCBlade to design a propeller and you want to read that back into OpenVSP.  You can import a BEM file (except for the airfoils) through the GUI.  Or, you can use the Import call to the API with IMPORT_BEM.  At present, there is no way to do the equivalent of IMPORT_BEM directly in-memory from the API.

Rob

Matthew Clarke

unread,
Apr 13, 2021, 1:40:04 AM4/13/21
to OpenVSP
Thanks, Rob,

I have a follow-up question:  Are there any examples of how exactly to export the BEM in the API. I tried  vsp.ExportFile("filename.bem" , vsp.SET_ALL, vsp.EXPORT_BEM) 
but it does not generate the .bem file. I am certain I have to use the ID of the propeller somewhere but I am not sure where exactly. 

Btw. I am a developer of SUAVE at Stanford. We are trying to improve the geometry translation of VSP to/from SUAVE.

Thanks.

jvgr...@gmail.com

unread,
Apr 13, 2021, 11:59:48 AM4/13/21
to OpenVSP
I'm looking through the code and the BEM export through the API might be missing the ability to set the Prop Geom prior to export, as is done through the GUI. There is a "BladeElement" analysis that can be run to generate the results output to the BEM file, but these would then have to be written to the *.bem from the external API script. 

I can add a quick function to set the BEM export Prop ID so it can be called before "ExportFile". We can also update the BladeElement analysis to include an option to set the Prop ID as an analysis input with an option to export results. If you need this capability before the next release I should be able to point you to the branch to compile or just email you the binaries. 

-Justin

Rob McDonald

unread,
Apr 13, 2021, 12:37:39 PM4/13/21
to ope...@googlegroups.com
What Justin Said...

Good to know you're a SUAVE developer - you clearly know more about that side of things than we do.  The best way to export a geometry almost always depends on the analysis you want to do with it later.  If, down the road, you have more questions about using OpenVSP geometry in other tools, let me know.

Not being able to set the BEMPropID from the API is an oversight - thinking about it, there might be some other export options that are similarly deficient.  We should do an audit of the Export menu for special options.

That said, I do think the best way for you to work will be through the Analysis Manager - which will give you the results in memory instead of dealing with a file.

string propid = AddGeom( "PROP" );
SetStringAnalysisInput( "BladeElement", "PropID", propid );
string rid = ExecAnalysis( "BladeElement" );
PrintResults( rid );

To work with the BEM results in more detail, check out the Results Manager Functions documentation.

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/73288482-ee4d-47c3-aa87-40cab85e52f6n%40googlegroups.com.

Matthew Clarke

unread,
Apr 14, 2021, 12:44:07 AM4/14/21
to OpenVSP
Thank you for the response Justin and Rob, 

When do you expect there to be a release? That will give me an idea of where to proceed on our end. Our team has been working on some new features for eVTOL analysis and noise and would love to have the capabilities of taking a geometry from SUAVE->OpenVSP->SU2 and vice-versa. We hope to package a release in a few months (probably after AIAA Aviation (Mid June) when our team has more free time. If the next release is later in the year, please email the binaries with the corrections.

With regards to the issue at hand. Having a function to set the BEM export Prop ID so it can be called before "ExportFile" would be great. I also played around with the working through the Analysis Manager however I think I am running into similar issues with setting the propeller. I will continue to parse our source code to verify. 

Thanks
Matthew

Rob McDonald

unread,
Apr 14, 2021, 1:43:24 AM4/14/21
to ope...@googlegroups.com
If you were trying to follow my example earlier exactly - it will fall substantially short.  It was meant to be more of a list of ideas than actual code that will work.  If that caused more problems than it was worth, I suggest you try out this instead...

void main()
{

    string propid = AddGeom( "PROP" );
    Update();

    array<string> pids = GetStringAnalysisInput( "BladeElement", "PropID" );
    pids[0] = propid;
    SetStringAnalysisInput( "BladeElement", "PropID", pids );

    string rid = ExecAnalysis( "BladeElement" );
    PrintResults( rid );

    //==== Check For API Errors ====//
    while ( GetNumTotalErrors() > 0 )
    {
        ErrorObj err = PopLastError();
        Print( err.GetErrorString() );
    }
}


This has the advantage that I actually tried it (:


Rob



Reply all
Reply to author
Forward
0 new messages