Airfoil File Parm Access via API

72 views
Skip to first unread message

Chris Satterwhite

unread,
Nov 7, 2022, 11:49:11 AM11/7/22
to OpenVSP
Hey Rob,

I'm trying to access the .dat filename that defines an Xsec shape (via the Python API) in order to tell CHARM which C81 deck to use at a given radial station without manual entry (under the assumption the .dat and .inp files have the same filename). It doesn't appear to me that the .dat filename is stored as a parm as I don't see it when I print the result of GetXsecParmIDs nor does the GUI give me the Parm window when I click on "Name" for a Airfoil Section.  Am I missing something here or do you have any other workaround to get this info?

Thanks,
Chris

Rob McDonald

unread,
Nov 7, 2022, 5:31:23 PM11/7/22
to ope...@googlegroups.com
There are Parms, IntParms, BoolParms and a few others -- but there is no such thing as a StringParm.  So, if we have the information, it won't be available and handled like a Parm.

Right now, there is no common GetAirfoilName() method -- some airfoils implement it, but not all.  Certainly not all XSecCurve's.  GetAirfoilName() could be made common -- possibly even extended to a more generic GetXSecCurveName().  And then that method could be exposed to the API.

However, even that seems like it would be pretty fragile.

I'm not a heavy user of the CHARM interface.  Hopefully Jason, Brandon, Sienna, Dan, Alex, or someone else with more OpenVSP to CHARM experience than me will chime in with some thoughts.

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/e8cea3de-fc64-40a0-b2dd-660cbb97053bn%40googlegroups.com.

Chris Satterwhite

unread,
Nov 7, 2022, 5:38:16 PM11/7/22
to OpenVSP
Ah that makes sense. Thanks for the quick reply. Its not too bad to manually work around it in the interim.  I'll stay tuned for any other ideas.

Chris

Brandon Litherland

unread,
Nov 8, 2022, 10:22:43 AM11/8/22
to OpenVSP
I think it would all depend on how complex your airfoils are.  If you're talking about NACA airfoils, then you can just pull the parms that set the airfoil to tell you what it is.  On the other hand, if you are using AF or DAT files for all of your airfoils (which it sounds like you are), are you setting the airfoils manually or via the API?  Now that I think of it, are you using the OpenVSP-to-CHARM Automation tool?  If the DAT and INP files have the same filename e.g., airfoil.DAT and airfoil.INP, then you can just set the airfoil in the API along with telling the CHARM automation tool what INP to use for C81 tables.  It also begs the question of how many airfoils you are applying.  If you are talking about two or three, then keeping track of them as a string list in the API should be simple.  Now that I think a bit more about this, if you are doing this enough that you want the CHARM and OpenVSP models to match over several iterations, then you should almost certainly be using the CHARM automation API.

I suppose before I run off any longer, it would help to know exactly what process you are following here...  Are you setting the airfoil files manually in your OpenVSP model and then trying to script starting a CHARM run? Or are you setting the airfoil files from the API?  What is the end goal or why are you trying to do this?  Often there is an easier way of accomplishing something and we just need to know the context to give better advice.

- Brandon

Chris Satterwhite

unread,
Nov 8, 2022, 10:34:39 AM11/8/22
to OpenVSP
Hey Brandon,

I am indeed using the OpenVSP to CHARM Automation tool.  The workflow is partitioned into two parts to handle legacy vehicle definition contained in a MATLAB structure.  The original airfoil and section data lives in that structure. So first in MATLAB I use that structure definition to write out a Python file that will generate the .vsp3 file. I then move that .vsp3 file over to our linux box running CHARM and use separate Python scripts to do the batching and running.  I could come up with an export format for the MATLAB structure that I then could read, generate vsp geometry, and setup CHARM all in the python thats running on the linux box. In that case I would be able to set up the C81 assignments fairly readily. I was just curious if there was a way to extract that data from the vsp file in my more partitioned workflow once I'm decoupled from that wing definition that lives in matlab.  Does that make sense? Thanks for putting some thought into this.  

Chris

Brandon Litherland

unread,
Nov 9, 2022, 5:54:13 AM11/9/22
to OpenVSP
Okay.  In that case does it make sense to write the list of airfoils in a text file from MATLAB that you could bring over to the Linux side?  In your Python scripts you could then read that text file into a list of filenames that could tell your CHARM automation which files to use... This would probably be "better" than trying to logically parse the entire VSP3 XML file for the AF names.

For example, from MATLAB you may write a file that contains:
airfoil1.inp
airfoil2.inp
airfoil3.inp
...
airfoilN.inp

Then use something like this to read the file into a Python list:
#%% READ DATA FROM FILE
with open('airfoils.txt', 'r') as f:
    data = []
    curline = f.readline()
    # print(curline)
    while curline:
        curline = curline.strip() # strips extra whitespace from strings
        curline = curline.split(' ') # splits at spaces (may use any character)
        if curline != ['']:
            # convert the line entries to a list and append to data[]
            curline = list(curline) 
            data.append(curline)
        curline = f.readline()


From here you would have to set the airfoil INP files in the automation but it sounds like you have that in hand.

Chris Satterwhite

unread,
Nov 10, 2022, 10:59:14 AM11/10/22
to OpenVSP
Yeah I think thats the logical workaround. Thanks Brandon.

Chris

Reply all
Reply to author
Forward
0 new messages