Problems creating Fuselage with Script

501 views
Skip to first unread message

Philipp Dice

unread,
Jan 16, 2018, 10:17:08 AM1/16/18
to OpenVSP
Hi there,

I currently work on an API in Python which converts data from a XML-File (CPACS, shown bottom right corner of the attached Image) to an OpenVSP Scriptfile.
Basically it just reads the data, converts it to the parameters used in OpenVSP and than writes the scriptfile. The scripts for the wing, horizontal and vertical tale are working fine so far.

But I have problems creating a fuselage.
Basically the XML-File stores elliptical sections and I convert the data in Python (number of sections, width, height, length and translation coords).

Now my questions:

  1. Why does OpenVSP automatically create Sections by generating the geom and is there a way to force creating sections manually? (I currently have a loop that catches the number of sections and creates the sections left to have the same amount of sections as in my XML-File)

  2. Why does OpenVSP suddenly ignore my limits starting at XSec_30 / XSec_31 and changes all of them to 0.50? (Eventhough it is doing fine till 50% of the fuselage length)

For each Section I defined the following Parameters:


- The xLocPercent is 1 (or very close to 1) in the last section, representing 100% of the total length.
- The lower_limit is the upper_limit of the section before (This is my way to set the length of each section)

- The value equals the upper_limit


Examples:


SetParmVal( fid, "Ellipse_Height", "XSecCurve_3", 0.865358 );
SetParmVal( fid, "Ellipse_Width", "XSecCurve_3", 1.016999 );
xsec = GetXSec( xsec_surf, 3 );
parmid_xloc = GetXSecParm( xsec, "XLocPercent" );
SetParmValLimits( parmid_xloc, 0.0044208283287032685, 0.0017705631337507413, 0.0044208283287032685 );
Update();


...


SetParmVal( fid, "Ellipse_Height", "XSecCurve_30", 4.15 );
SetParmVal( fid, "Ellipse_Width", "XSecCurve_30", 4.15 );
xsec = GetXSec( xsec_surf, 30 );
parmid_xloc = GetXSecParm( xsec, "XLocPercent" );
SetParmValLimits( parmid_xloc, 0.43768710767754826, 0.35378591260263514, 0.43768710767754826 );
parmid_zloc = GetXSecParm( xsec, "ZLocPercent" );
SetParmValLimits( parmid_zloc, -0.002599260622885924, -0.002599260622885924, -0.002599260622885924 );
Update();

SetParmVal( fid, "Ellipse_Height", "XSecCurve_31", 4.15 );
SetParmVal( fid, "Ellipse_Width", "XSecCurve_31", 4.15 );
xsec = GetXSec( xsec_surf, 31 );
parmid_xloc = GetXSecParm( xsec, "XLocPercent" );
SetParmValLimits( parmid_xloc, 0.5215883027524614, 0.43768710767754826, 0.5215883027524614 );
parmid_zloc = GetXSecParm( xsec, "ZLocPercent" );
SetParmValLimits( parmid_zloc, -0.002599260622885924, -0.002599260622885924, -0.002599260622885924 );
Update();






It would be awesome, if anyone could help me out or give me an idea which I could try.

Thank you in advance,
Philipp
fuselage.vspscript
Auto Generated Inline Image 1
Auto Generated Inline Image 2
Message has been deleted

Philipp Dice

unread,
Jan 19, 2018, 9:25:42 AM1/19/18
to OpenVSP
Okay I managed to fix this issue.
Just in case someone runs into the same problem:

The Problems seems to be the "X Sec Order" in the Design group. I changed it from "MONOTONIC" to "FREE" at the beginning of the script file:

//== Set XSec Order to FREE ==//
SetParmVal( fuselage, "OrderPolicy", "Design", 2.0);

Additionally:
In the last sections OpenVSP seemed to have some problems taking the correct locations/translations. I figured out that changing the total length at the end fixed it.
Thats why I added in the script 0.00001 to the total length with an update() and the problem was solved.

//== Set Total length of Fuselage again to prevent bugs ==//
SetParmVal( fuselage, "Length", "Design", 36.81778777780002);
Update();

Pictures comparing the results of the API for three different airplanes (the dataset for the first one is not correct):









Greetings

Philipp
Auto Generated Inline Image 1
Auto Generated Inline Image 2
Auto Generated Inline Image 3
Auto Generated Inline Image 4

Rob McDonald

unread,
Jan 19, 2018, 9:58:50 AM1/19/18
to ope...@googlegroups.com
The original problem you were observing is really rooted with how you are adding/inserting the cross sections to the baseline fuselage.

Changing the order policy from monotonic to free works around the problem, but it actually creates a situation where the cross sections jump around.

I believe you are adding cross sections that you want to appear at the aft-end of the fuselage -- but you are attempting to add them 'in front' of a pre-existing cross section.


Also, there should be no reason to use 'SetValAndLimits' in your script.  The limits should be fine the way they are.


In general, you are better off modeling something like a fuselage with as few cross sections as possible.  Your shape is probably attainable by specifying six.  

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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Philipp Dice

unread,
Jan 23, 2018, 1:05:41 PM1/23/18
to OpenVSP
Hi Rob,

thanks a lot for your answer.

Is there a better way than inserting the sections and changing them afterwards? If so, could you explain?

Regarding "SetValAndLimits": I used this because in the 'X Sec Order' 'MONOTONIC' I tried to force the sections moving the way I want to. I will change it back to "SetParmVal".

The thing is, that I have a fixed amount of sections from the first datatype (CPACS). I read the parameters for each section and translate/convert it to a script line in the vspscript. The amount of sections in CPACS needs to match the amount of sections in OpenVSP. For the future it will be necessary to convert it back aswell. The maximum amount of fuselage sections I had so far were 78. Loading it took a while but it is still acceptable. It takes around two minutes but I print the status of the loop into the vsp console so I know whats happening.

Philipp

Julius Bartaševičius

unread,
Mar 9, 2021, 3:30:35 AM3/9/21
to OpenVSP
Hello Phillip,

Would you be open to share your Python CPACS-to-OpenVSP translator script?

We are currently trying out different aerodynamic solvers for a UAV geometry, and our main geometry is defined in CPACS. Not having to transfer it manually to OpenVSP would be of great help.

Best regards,
Julius

p_bamrah

unread,
Jul 8, 2022, 11:28:13 AM7/8/22
to OpenVSP
Hi Philip,

It is amazing to know that you were able to convert XML file to vspscript. This is something I am currently struggling with being a beginner. Could you please share how you were able to convert CPACS file to OpenVSP script file. It will be very helpful.

Thank you,
Parush
Reply all
Reply to author
Forward
0 new messages