XSec and Airfoil Functions¶
This group of functions provides API control of cross-sections (XSecs). Airfoils are a type of XSec included in this group as well. API functions for Body of Revolution XSecs are included in the Specialized Geometry group.
|
Set XSec Alias by ID |
|
Get XSec Alias by ID |
|
Set XSecCurve Alias by XSec ID |
Get XSecCurve Alias by XSec ID |
|
|
Cut a cross-section from the specified geometry and maintain it in memory |
|
Copy a cross-section from the specified geometry and maintain it in memory |
|
Paste the cross-section currently held in memory to the specified geometry |
|
Insert a cross-section of particular type to the specified geometry after the given index |
|
Choose which quantities drive a wing section. |
|
Convert an airfoil cross section to a CST airfoil fitted to the shape it already has, the way the Fit CST button on the airfoil panels does. |
|
Get the shape of an XSec |
|
Get the width of an XSec. |
|
Get the height of an XSec. |
|
Set the width and height of an XSec. |
|
Set the width of an XSec. |
|
Set the height of an XSec. |
|
Get all Parm IDs for specified XSec Parm Container |
|
Get a specific Parm ID from an Xsec |
|
Read in XSec shape from fuselage (*.fsx) file and set to the specified XSec. |
|
Set the coordinate points for a specific XSec. |
|
Copy the XSecCurve of a cross section to the XSecCurve clipboard. |
|
Paste the XSecCurve clipboard onto a cross section |
|
Set the points of a file XSec. |
|
Compute 3D coordinate for a point on an XSec curve given the parameter value (U) along the curve |
|
Compute the tangent vector of a point on an XSec curve given the parameter value (U) along the curve |
|
Reset all skinning Parms for a specified XSec. |
|
Set C-type continuity enforcement for a particular XSec |
|
Set how many derivatives are continuous across an XSec: 0 for position only, 1 to also match slope, 2 to also match curvature. |
|
Set the tangent angles for the specified XSec |
|
Set the tangent angles for one side of an XSec. |
|
Set the tangent slew angles for the specified XSec |
|
Set the tangent slews for one side of an XSec. |
|
Set the tangent strengths for the specified XSec |
|
Set the tangent strengths for one side of an XSec. |
|
Set curvatures for the specified XSec |
|
Set the curvatures for one side of an XSec. |
|
Read in XSec shape from airfoil file and set to the specified XSec. |
|
Set the upper points for an airfoil. |
|
Set the lower points for an airfoil. |
|
Set the upper and lower points for an airfoil. |
|
Get the theoretical lift (Cl) distribution for a Hershey Bar wing with unit chord length using Glauert's Method. |
|
Get the theoretical drag (Cd) distribution for a Hershey Bar wing with unit chord length using Glauert's Method. |
|
Get the 2D coordinates an input number of points along a Von K�rm�n-Trefftz airfoil of specified shape |
|
Get the pressure coefficient (Cp) along a Von Kármán-Trefftz airfoil of specified shape at specified points along the airfoil |
|
Generate the surface coordinate points for a ellipsoid at specified center of input radius along each axis. |
|
Get the points along the feature lines of a particular Geom |
|
Generate Analytical Solution for Potential Flow for specified ellipsoid shape at input surface points for input velocity vector. |
|
Get the coordinate points for the upper surface of an airfoil. |
|
Get the coordinate points for the lower surface of an airfoil. |
|
Get the CST coefficients for the upper surface of an airfoil. |
|
Get the CST coefficients for the lower surface of an airfoil. |
|
Get the CST degree for the upper surface of an airfoil. |
|
Get the CST degree for the lower surface of an airfoil. |
|
Set the CST degree and coefficients for the upper surface of an airfoil. |
|
Set the CST degree and coefficients for the lower surface of an airfoil. |
|
Promote the CST for the upper airfoil surface. |
|
Promote the CST for the lower airfoil surface. |
|
Demote the CST for the upper airfoil surface. |
|
Demote the CST for the lower airfoil surface. |
|
Fit a CST airfoil for an existing airfoil of type XS_FOUR_SERIES, XS_SIX_SERIES, XS_FOUR_DIGIT_MOD, XS_FIVE_DIGIT, XS_FIVE_DIGIT_MOD, XS_ONE_SIX_SERIES, or XS_FILE_AIRFOIL. |
|
Write out the untwisted unit-length 2D Bezier curve for the specified airfoil in custom*.bz format. |
|
Write out the untwisted unit-length 2D coordinate points for the specified airfoil in Selig format. |
|
Get the untwisted unit-length 2D coordinate points for the specified airfoil |
Details¶
- openvsp.SetXSecAlias(id, alias)[source]¶
Set XSec Alias by ID
# Add Stack sid = AddGeom( "STACK", "" ) # Get First (and Only) XSec Surf xsec_surf = GetXSecSurf( sid, 0 ) # Identify XSec 1 xsec_1 = GetXSec( xsec_surf, 1 ) # Set Alias and verify alias match alias = "XSec_One_Alias" SetXSecAlias( xsec_1, alias ) get_alias = GetXSecAlias( xsec_1 ) if alias != get_alias: print("SetXSecAlias/GetXSecAlias error!") assert False, "SetXSecAlias/GetXSecAlias error!"
- Parameters:
[in] – id string XSec ID
[in] – alias string Xsec alias
- openvsp.GetXSecAlias(id)[source]¶
Get XSec Alias by ID
# Add Stack sid = AddGeom( "STACK", "" ) # Get First (and Only) XSec Surf xsec_surf = GetXSecSurf( sid, 0 ) # Identify XSec 1 xsec_1 = GetXSec( xsec_surf, 1 ) # Set Alias and verify alias match alias = "XSec_One_Alias" SetXSecAlias( xsec_1, alias ) get_alias = GetXSecAlias( xsec_1 ) if alias != get_alias: print("SetXSecAlias/GetXSecAlias error!") assert False, "SetXSecAlias/GetXSecAlias error!"
- Parameters:
[in] – id string XSec ID
- Return type:
string
- Returns:
string Xsec alias
- openvsp.SetXSecCurveAlias(id, alias)[source]¶
Set XSecCurve Alias by XSec ID
# Add Stack sid = AddGeom( "STACK", "" ) # Get First (and Only) XSec Surf xsec_surf = GetXSecSurf( sid, 0 ) # Identify XSec 1 xsec_1 = GetXSec( xsec_surf, 1 ) # Set Alias and verify alias match alias = "XSecCurve_One_Alias" SetXSecCurveAlias( xsec_1, alias ) get_alias = GetXSecCurveAlias( xsec_1 ) if alias != get_alias: print("SetXSecCurveAlias/GetXSecCurveAlias error!") assert False, "SetXSecCurveAlias/GetXSecCurveAlias error!"
- Parameters:
[in] – id string XSec ID
[in] – alias string XsecCurve alias
- openvsp.GetXSecCurveAlias(id)[source]¶
Get XSecCurve Alias by XSec ID
# Add Stack sid = AddGeom( "STACK", "" ) # Get First (and Only) XSec Surf xsec_surf = GetXSecSurf( sid, 0 ) # Identify XSec 1 xsec_1 = GetXSec( xsec_surf, 1 ) # Set Alias and verify alias match alias = "XSecCurve_One_Alias" SetXSecCurveAlias( xsec_1, alias ) get_alias = GetXSecCurveAlias( xsec_1 ) if alias != get_alias: print("SetXSecCurveAlias/GetXSecCurveAlias error!") assert False, "SetXSecCurveAlias/GetXSecCurveAlias error!"
- Parameters:
[in] – id string XSec ID
- openvsp.CutXSec(geom_id, index)[source]¶
Cut a cross-section from the specified geometry and maintain it in memory
fid = AddGeom( "FUSELAGE", "" ) # Add Fuselage #==== Insert, Cut, Paste Example ====// xsec_surf = GetXSecSurf( fid, 0 ) num_start = GetNumXSec( xsec_surf ) InsertXSec( fid, 1, XS_ROUNDED_RECTANGLE ) # Insert A Cross-Section assert GetNumXSec( xsec_surf ) == num_start + 1, "InsertXSec did not add a section" assert GetXSecShape( GetXSec( xsec_surf, 2 ) ) == XS_ROUNDED_RECTANGLE, "InsertXSec did not insert after the given index" CopyXSec( fid, 2 ) # Copy Just Created XSec To Clipboard PasteXSec( fid, 1 ) # Paste Clipboard # Pasting replaces a section rather than adding one, and section 1 now # carries the shape that was copied. assert GetNumXSec( xsec_surf ) == num_start + 1, "PasteXSec changed the number of sections" assert GetXSecShape( GetXSec( xsec_surf, 1 ) ) == XS_ROUNDED_RECTANGLE, "PasteXSec did not paste the copied section" CutXSec( fid, 2 ) # Cut Created XSec assert GetNumXSec( xsec_surf ) == num_start, "CutXSec did not remove a section"
See also: PasteXSec :param [in]: geom_id string Geom ID :param [in]: index int XSec index
- openvsp.CopyXSec(geom_id, index)[source]¶
Copy a cross-section from the specified geometry and maintain it in memory
# Add Stack sid = AddGeom( "STACK", "" ) xsec_surf = GetXSecSurf( sid, 0 ) # Give XSec 1 a shape that XSec 3 does not have. ChangeXSecShape( xsec_surf, 1, XS_ROUNDED_RECTANGLE ) Update() num_start = GetNumXSec( xsec_surf ) # Copy XSec To Clipboard CopyXSec( sid, 1 ) # Paste To XSec 3 PasteXSec( sid, 3 ) Update() # Pasting replaces the target section, so the count is unchanged and XSec 3 # now carries the shape that was copied. assert GetNumXSec( xsec_surf ) == num_start, "PasteXSec changed the number of sections" assert GetXSecShape( GetXSec( xsec_surf, 3 ) ) == XS_ROUNDED_RECTANGLE, "PasteXSec did not paste the copied section" # The section that was copied has to be left alone. assert GetXSecShape( GetXSec( xsec_surf, 1 ) ) == XS_ROUNDED_RECTANGLE, "CopyXSec disturbed the section it copied"
See also: PasteXSec :param [in]: geom_id string Geom ID :param [in]: index int XSec index
- openvsp.PasteXSec(geom_id, index)[source]¶
Paste the cross-section currently held in memory to the specified geometry
# Add Stack sid = AddGeom( "STACK", "" ) xsec_surf = GetXSecSurf( sid, 0 ) # Give XSec 1 a shape that XSec 3 does not have. ChangeXSecShape( xsec_surf, 1, XS_ROUNDED_RECTANGLE ) Update() num_start = GetNumXSec( xsec_surf ) # Copy XSec To Clipboard CopyXSec( sid, 1 ) # Paste To XSec 3 PasteXSec( sid, 3 ) Update() # Pasting replaces the target section, so the count is unchanged and XSec 3 # now carries the shape that was copied. assert GetNumXSec( xsec_surf ) == num_start, "PasteXSec changed the number of sections" assert GetXSecShape( GetXSec( xsec_surf, 3 ) ) == XS_ROUNDED_RECTANGLE, "PasteXSec did not paste the copied section" # The section that was copied has to be left alone. assert GetXSecShape( GetXSec( xsec_surf, 1 ) ) == XS_ROUNDED_RECTANGLE, "CopyXSec disturbed the section it copied"
See also: CutXSec, CopyXSec :param [in]: geom_id string Geom ID :param [in]: index int XSec index
- openvsp.InsertXSec(geom_id, index, type)[source]¶
Insert a cross-section of particular type to the specified geometry after the given index
wing_id = AddGeom( "WING" ) xsec_surf = GetXSecSurf( wing_id, 0 ) num_start = GetNumXSec( xsec_surf ) #===== Add XSec ====// InsertXSec( wing_id, 1, XS_SIX_SERIES ) Update() # The new section lands after the given index. assert GetNumXSec( xsec_surf ) == num_start + 1, "InsertXSec did not add a section" assert GetXSecShape( GetXSec( xsec_surf, 2 ) ) == XS_SIX_SERIES, "InsertXSec did not insert the requested shape"
See also: XSEC_CRV_TYPE :param [in]: geom_id string Geom ID :param [in]: index int XSec index :param [in]: type int XSec type enum (i.e. XS_GENERAL_FUSE)
- openvsp.SetDriverGroup(geom_id, section_index, driver_0, driver_1=-1, driver_2=-1)[source]¶
Choose which quantities drive a wing section. A section is defined by three of its measures and the rest follow; this says which three.
wid = AddGeom( "WING", "" ) SetDriverGroup( wid, 1, SPAN_WSECT_DRIVER, ROOTC_WSECT_DRIVER, TIPC_WSECT_DRIVER ) Update()
See also: WING_DRIVERS :param [in]: geom_id string Geom ID :param [in]: section_index int Wing section index :param [in]: driver_0 int Wing driver enum (i.e. SPAN_WSECT_DRIVER) :param [in]: driver_1 int Second wing driver enum :param [in]: driver_2 int Third wing driver enum
- openvsp.FitCSTAirfoil(xsec_surf_id, xsec_index, deg)[source]¶
Convert an airfoil cross section to a CST airfoil fitted to the shape it already has, the way the Fit CST button on the airfoil panels does. A CST airfoil is described by coefficients rather than by a table or a series designation, which is what makes it useful for optimization; fitting is how an airfoil of any other type is brought into that form without changing shape.
wing_id = AddGeom( "WING", "" ) xsec_surf = GetXSecSurf( wing_id, 0 ) ChangeXSecShape( xsec_surf, 1, XS_FOUR_SERIES ) Update() FitCSTAirfoil( xsec_surf, 1, 8 ) Update() xsec = GetXSec( xsec_surf, 1 ) assert GetXSecShape( xsec ) == XS_CST_AIRFOIL, "FitCSTAirfoil did not convert the XSec" # The fit is carried out at the degree that was asked for. assert GetUpperCSTDegree( xsec ) == 8, "FitCSTAirfoil did not fit at the requested degree" assert GetLowerCSTDegree( xsec ) == 8, "FitCSTAirfoil did not fit at the requested degree"
See also: ChangeXSecShape, GetUpperCSTCoefs, PromoteCSTUpper :param [in]: xsec_surf_id string XSecSurf ID :param [in]: xsec_index int XSec index :param [in]: deg int Degree to fit the CST airfoil at
- openvsp.GetXSecShape(xsec_id)[source]¶
Get the shape of an XSec
# Add Stack sid = AddGeom( "STACK", "" ) # Get First (and Only) XSec Surf xsec_surf = GetXSecSurf( sid, 0 ) ChangeXSecShape( xsec_surf, 1, XS_EDIT_CURVE ) xsec = GetXSec( xsec_surf, 1 ) if GetXSecShape( xsec ) != XS_EDIT_CURVE : print( "ERROR: GetXSecShape" ) assert False, "ERROR: GetXSecShape"
See also: XSEC_CRV_TYPE :param [in]: xsec_id string XSec ID :rtype: int :return: int XSec type enum (i.e. XS_ELLIPSE)
- openvsp.GetXSecWidth(xsec_id)[source]¶
Get the width of an XSec. Note that POINT type XSecs have a width and height of 0, regardless of what width and height it is set to.
# Add Fuselage Geom fuseid = AddGeom( "FUSELAGE", "" ) xsec_surf = GetXSecSurf( fuseid, 0 ) xsec = GetXSec( xsec_surf, GetNumXSec( xsec_surf ) - 2 ) # Get 2nd to last XSec SetXSecWidthHeight( xsec, 3.0, 6.0 ) if abs( GetXSecWidth( xsec ) - 3.0 ) > 1e-6 : print( "---> Error: API Get/Set Width " ) assert False, "---> Error: API Get/Set Width"
See also: SetXSecWidth :param [in]: xsec_id string XSec ID :rtype: float :return: double Xsec width
- openvsp.GetXSecHeight(xsec_id)[source]¶
Get the height of an XSec. Note that POINT type XSecs have a width and height of 0, regardless of what width and height it is set to.
# Add Fuselage Geom fuseid = AddGeom( "FUSELAGE", "" ) xsec_surf = GetXSecSurf( fuseid, 0 ) xsec = GetXSec( xsec_surf, GetNumXSec( xsec_surf ) - 2 ) # Get 2nd to last XSec SetXSecWidthHeight( xsec, 3.0, 6.0 ) if abs( GetXSecHeight( xsec ) - 6.0 ) > 1e-6 : print( "---> Error: API Get/Set Width " ) assert False, "---> Error: API Get/Set Width"
See also: SetXSecHeight :param [in]: xsec_id string XSec ID :rtype: float :return: double Xsec height
- openvsp.SetXSecWidthHeight(xsec_id, w, h)[source]¶
Set the width and height of an XSec. Note, if the XSec is an EDIT_CURVE type and PreserveARFlag is true, the input width value will be ignored and instead set from on the input height and aspect ratio. Use SetXSecWidth and SetXSecHeight directly to avoid this.
# Add Stack sid = AddGeom( "STACK", "" ) # Get First (and Only) XSec Surf xsec_surf = GetXSecSurf( sid, 0 ) # Identify XSec 2 xsec_2 = GetXSec( xsec_surf, 2 ) SetXSecWidthHeight( xsec_2, 1.5, 1.5 ) Update() assert abs( GetXSecWidth( xsec_2 ) - 1.5 ) < 1e-6, "SetXSecWidthHeight did not take" assert abs( GetXSecHeight( xsec_2 ) - 1.5 ) < 1e-6, "SetXSecWidthHeight did not take" # The neighbouring sections have to be left alone. xsec_1 = GetXSec( xsec_surf, 1 ) assert abs( GetXSecWidth( xsec_1 ) - 1.5 ) > 1e-6 or abs( GetXSecHeight( xsec_1 ) - 1.5 ) > 1e-6, "SetXSecWidthHeight reached a section it was not given"
See also: SetXSecWidth, SetXSecHeight :param [in]: xsec_id string XSec ID :param [in]: w double Xsec width :param [in]: h double Xsec height
- openvsp.SetXSecWidth(xsec_id, w)[source]¶
Set the width of an XSec. Note that POINT type XSecs have a width and height of 0, regardless of what is input to SetXSecWidth.
# Add Stack sid = AddGeom( "STACK", "" ) # Get First (and Only) XSec Surf xsec_surf = GetXSecSurf( sid, 0 ) # Identify XSec 2 xsec_2 = GetXSec( xsec_surf, 2 ) SetXSecWidth( xsec_2, 1.5 ) assert abs( GetXSecWidth( xsec_2 ) - 1.5 ) < 1e-9, "SetXSecWidth did not take"
See also: GetXSecWidth :param [in]: xsec_id string XSec ID :param [in]: w double Xsec width
- openvsp.SetXSecHeight(xsec_id, h)[source]¶
Set the height of an XSec. Note that POINT type XSecs have a width and height of 0, regardless of what is input to SetXSecHeight.
# Add Stack sid = AddGeom( "STACK", "" ) # Get First (and Only) XSec Surf xsec_surf = GetXSecSurf( sid, 0 ) # Identify XSec 2 xsec_2 = GetXSec( xsec_surf, 2 ) SetXSecHeight( xsec_2, 1.5 ) assert abs( GetXSecHeight( xsec_2 ) - 1.5 ) < 1e-9, "SetXSecHeight did not take"
See also: GetXSecHeight :param [in]: xsec_id string XSec ID :param [in]: h double Xsec height
- openvsp.GetXSecParmIDs(xsec_id)[source]¶
Get all Parm IDs for specified XSec Parm Container
# Add Fuselage Geom fuseid = AddGeom( "FUSELAGE", "" ) xsec_surf = GetXSecSurf( fuseid, 0 ) xsec = GetXSec( xsec_surf, GetNumXSec( xsec_surf ) - 1 ) parm_array = GetXSecParmIDs( xsec ) if len(parm_array) < 1 : print( "---> Error: API GetXSecParmIDs " ) assert False, "---> Error: API GetXSecParmIDs"
- Parameters:
[in] – xsec_id string XSec ID
- Return type:
std::vector< std::string,std::allocator< std::string > >
- Returns:
vector<string> Array of Parm IDs
- openvsp.GetXSecParm(xsec_id, name)[source]¶
Get a specific Parm ID from an Xsec
# Add Fuselage Geom fuseid = AddGeom( "FUSELAGE", "" ) xsec_surf = GetXSecSurf( fuseid, 0 ) ChangeXSecShape( xsec_surf, GetNumXSec( xsec_surf ) - 1, XS_ROUNDED_RECTANGLE ) xsec = GetXSec( xsec_surf, GetNumXSec( xsec_surf ) - 1 ) wid = GetXSecParm( xsec, "RoundedRect_Width" ) if not ValidParm( wid ) : print( "---> Error: API GetXSecParm " ) assert False, "---> Error: API GetXSecParm"
- Parameters:
[in] – xsec_id string XSec ID
[in] – name string Parm name
- Return type:
string
- Returns:
string Parm ID
- openvsp.ReadFileXSec(xsec_id, file_name)[source]¶
Read in XSec shape from fuselage (*.fsx) file and set to the specified XSec. The XSec must be of type XS_FILE_FUSE.
# Add Fuselage Geom fuseid = AddGeom( "FUSELAGE", "" ) xsec_surf = GetXSecSurf( fuseid, 0 ) ChangeXSecShape( xsec_surf, 2, XS_FILE_FUSE ) xsec = GetXSec( xsec_surf, 2 ) vec_array = ReadFileXSec(xsec, "TestXSec.fxs") Update() # The file holds a closed diamond, so the first and last points coincide and # the section takes its size from their extents. assert len( vec_array ) >= 3, "ReadFileXSec returned too few points" assert dist( vec_array[0], vec_array[-1] ) < 1e-8, "ReadFileXSec returned an open curve" # The shape is normalized on the way in and then scaled by the section's own # width and height, so the curve has to fit inside them. w = GetXSecWidth( xsec ) h = GetXSecHeight( xsec ) for i in range( 11 ): p = ComputeXSecPnt( xsec, i * 0.1 ) assert abs( p.y() ) <= 0.5 * w + 1e-6, "ReadFileXSec left the curve outside the section" assert abs( p.z() ) <= 0.5 * h + 1e-6, "ReadFileXSec left the curve outside the section"
- Parameters:
[in] – xsec_id string XSec ID
[in] – file_name string Fuselage XSec file name
- Return type:
std::vector< vec3d,std::allocator< vec3d > >
- Returns:
vector<vec3d> Array of coordinate points read from the file and set to the XSec
- openvsp.GetXSecPnts(xsec_id)[source]¶
Set the coordinate points for a specific XSec. The XSec must be of type XS_FILE_FUSE.
# Add Fuselage Geom fuseid = AddGeom( "FUSELAGE", "" ) xsec_surf = GetXSecSurf( fuseid, 0 ) ChangeXSecShape( xsec_surf, 2, XS_FILE_FUSE ) xsec = GetXSec( xsec_surf, 2 ) # ReadFileXSec hands back a tuple, so copy it into a list to edit it. vec_array = list( ReadFileXSec(xsec, "TestXSec.fxs") ) assert len( vec_array ) > 0, "ReadFileXSec returned no points" # The Python vec3d carries no arithmetic operators, so scale by component. vec_array[1] = vec3d( vec_array[1].x() * 2.0, vec_array[1].y() * 2.0, vec_array[1].z() * 2.0 ) vec_array[3] = vec3d( vec_array[3].x() * 2.0, vec_array[3].y() * 2.0, vec_array[3].z() * 2.0 ) # A file XSec takes its width and height from the extents of the points it # was given, in X and Y respectively. wmin = min( [ p.x() for p in vec_array ] ) wmax = max( [ p.x() for p in vec_array ] ) hmin = min( [ p.y() for p in vec_array ] ) hmax = max( [ p.y() for p in vec_array ] ) SetXSecPnts( xsec, vec_array ) Update() assert abs( GetXSecWidth( xsec ) - ( wmax - wmin ) ) < 1e-6, "SetXSecPnts did not set the section width" assert abs( GetXSecHeight( xsec ) - ( hmax - hmin ) ) < 1e-6, "SetXSecPnts did not set the section height"
- Parameters:
[in] – xsec_id string XSec ID
[in] – pnt_vec vector<vec3d> Vector of XSec coordinate points
Get the coordinate points for a specific XSec. The XSec must be of type XS_FILE_FUSE. The points are returned normalized to the section’s width and height.
# Add Fuselage Geom fuseid = AddGeom( "FUSELAGE", "" ) xsec_surf = GetXSecSurf( fuseid, 0 ) ChangeXSecShape( xsec_surf, 2, XS_FILE_FUSE ) xsec = GetXSec( xsec_surf, 2 ) vec_array = list( ReadFileXSec( xsec, "TestXSec.fxs" ) ) # The points that were read are the points the section is carrying. check_array = GetXSecPnts( xsec ) assert len( check_array ) > 0, "GetXSecPnts returned nothing" # The stored points are normalized, so they fit in the unit box. for p in check_array: assert abs( p.x() ) <= 0.5 + 1e-9, "GetXSecPnts returned a point outside the unit box" assert abs( p.y() ) <= 0.5 + 1e-9, "GetXSecPnts returned a point outside the unit box" # The curve closes on itself. assert dist( check_array[0], check_array[-1] ) < 1e-8, "GetXSecPnts returned an open curve" # Setting points has to be what comes back. SetXSecPnts( xsec, vec_array ) after_array = GetXSecPnts( xsec ) assert len( after_array ) == len( check_array ), "GetXSecPnts did not follow SetXSecPnts"
See also: SetXSecPnts, ReadFileXSec :param [in]: xsec_id string XSec ID :rtype: std::vector< vec3d,std::allocator< vec3d > > :return: vector<vec3d> Vector of XSec coordinate points
- openvsp.CopyXSecCurve(geom_id, index)[source]¶
Copy the XSecCurve of a cross section to the XSecCurve clipboard. This carries the section shape without the section’s placement, and works on a body of revolution too, where the index is ignored because it holds only one curve.
# Add Stack sid = AddGeom( "STACK", "" ) xsec_surf = GetXSecSurf( sid, 0 ) ChangeXSecShape( xsec_surf, 1, XS_ROUNDED_RECTANGLE ) Update() CopyXSecCurve( sid, 1 ) PasteXSecCurve( sid, 3 ) Update() # The shape travels to the pasted section. assert GetXSecShape( GetXSec( xsec_surf, 3 ) ) == XS_ROUNDED_RECTANGLE, "the XSecCurve did not paste" # A Geom that carries no cross sections has to be rejected. err_mgr = ErrorMgrSingleton.getInstance() pid = AddGeom( "POD" ) CopyXSecCurve( pid, 0 ) assert err_mgr.GetNumTotalErrors() > 0, "CopyXSecCurve accepted a Geom with no cross sections" while err_mgr.GetNumTotalErrors() > 0 : err = err_mgr.PopLastError()
See also: PasteXSecCurve, CopyXSec, CopyAirfoil :param [in]: geom_id string Geom ID :param [in]: index int XSec index, ignored for a body of revolution
- openvsp.PasteXSecCurve(geom_id, index)[source]¶
Paste the XSecCurve clipboard onto a cross section
# A body of revolution holds one XSecCurve, so its index is ignored. sid = AddGeom( "STACK", "" ) xsec_surf = GetXSecSurf( sid, 0 ) ChangeXSecShape( xsec_surf, 1, XS_ROUNDED_RECTANGLE ) Update() CopyXSecCurve( sid, 1 ) bor_id = AddGeom( "BODYOFREVOLUTION", "" ) PasteXSecCurve( bor_id, 0 ) Update() assert GetBORXSecShape( bor_id ) == XS_ROUNDED_RECTANGLE, "the XSecCurve did not paste onto the body of revolution" # An index past the end has to be rejected. err_mgr = ErrorMgrSingleton.getInstance() PasteXSecCurve( sid, 100 ) assert err_mgr.GetNumTotalErrors() > 0, "PasteXSecCurve accepted an index past the end" while err_mgr.GetNumTotalErrors() > 0 : err = err_mgr.PopLastError()
See also: CopyXSecCurve, PasteXSec, PasteAirfoil :param [in]: geom_id string Geom ID :param [in]: index int XSec index, ignored for a body of revolution
- openvsp.SetXSecPnts(xsec_id, pnt_vec)[source]¶
Set the points of a file XSec. The XSec must be of type XS_FILE_FUSE; this is how a section read from a file is replaced from a script.
sid = AddGeom( "STACK", "" ) xsec_surf = GetXSecSurf( sid, 0 ) ChangeXSecShape( xsec_surf, 1, XS_FILE_FUSE ) Update() xsec = GetXSec( xsec_surf, 1 ) # Take the section's own points and hand back a squashed copy of them. Building a set from # nothing has to match what a file section expects, which is a closed curve in the section's # own plane. pnt_vec = [ vec3d( p.x(), 0.5 * p.y(), p.z() ) for p in GetXSecPnts( xsec ) ] SetXSecPnts( xsec, pnt_vec ) Update() assert len( GetXSecPnts( xsec ) ) == len( pnt_vec ), "SetXSecPnts did not take the points"
See also: GetXSecPnts, ChangeXSecShape :param [in]: xsec_id string XSec ID, of type XS_FILE_FUSE :param [in]: pnt_vec vector<vec3d> Points defining the section
- openvsp.ComputeXSecPnt(xsec_id, fract)[source]¶
Compute 3D coordinate for a point on an XSec curve given the parameter value (U) along the curve
#==== Add Geom ====// stack_id = AddGeom( "STACK" ) #==== Get The XSec Surf ====// xsec_surf = GetXSecSurf( stack_id, 0 ) xsec = GetXSec( xsec_surf, 2 ) u_fract = 0.25 pnt = ComputeXSecPnt(xsec, u_fract) # The section is a closed curve, so the ends meet. assert dist( ComputeXSecPnt( xsec, 0.0 ), ComputeXSecPnt( xsec, 1.0 ) ) < 1e-6, "the XSec curve does not close" # The point has to lie on the section, which is sized by its width and # height about the section origin. w = GetXSecWidth( xsec ) h = GetXSecHeight( xsec ) assert abs( pnt.y() ) <= 0.5 * w + 1e-6, "ComputeXSecPnt returned a point off the section" assert abs( pnt.z() ) <= 0.5 * h + 1e-6, "ComputeXSecPnt returned a point off the section"
- Parameters:
[in] – xsec_id string XSec ID
[in] – fract double Curve parameter value (range: 0 - 1)
- Return type:
- Returns:
vec3d 3D coordinate point
- openvsp.ComputeXSecTan(xsec_id, fract)[source]¶
Compute the tangent vector of a point on an XSec curve given the parameter value (U) along the curve
#==== Add Geom ====// stack_id = AddGeom( "STACK" ) #==== Get The XSec Surf ====// xsec_surf = GetXSecSurf( stack_id, 0 ) xsec = GetXSec( xsec_surf, 2 ) u_fract = 0.25 tan = ComputeXSecTan( xsec, u_fract ) # A tangent is a direction, so it has to have some length. assert tan.mag() > 1e-9, "ComputeXSecTan returned a degenerate tangent" # The tangent has to follow the curve, so stepping along the curve from the # point has to line up with it. du = 1.0e-5 p0 = ComputeXSecPnt( xsec, u_fract ) p1 = ComputeXSecPnt( xsec, u_fract + du ) fd = vec3d( p1.x() - p0.x(), p1.y() - p0.y(), p1.z() - p0.z() ) assert fd.mag() > 1e-12, "the XSec curve does not advance" align = ( fd.x() * tan.x() + fd.y() * tan.y() + fd.z() * tan.z() ) / ( fd.mag() * tan.mag() ) assert align > 0.999, "ComputeXSecTan does not follow the curve"
- Parameters:
[in] – xsec_id string XSec ID
[in] – fract double Curve parameter value (range: 0 - 1)
- Return type:
- Returns:
vec3d Tangent vector
- openvsp.ResetXSecSkinParms(xsec_id)[source]¶
Reset all skinning Parms for a specified XSec. Set top, bottom, left, and right strengths, slew, angle, and curvature to 0. Set all symmetry and equality conditions to false.
fid = AddGeom( "FUSELAGE", "" ) # Add Fuselage xsec_surf = GetXSecSurf( fid, 0 ) # Get First (and Only) XSec Surf num_xsecs = GetNumXSec( xsec_surf ) xsec = GetXSec( xsec_surf, 1 ) SetXSecTanAngles( xsec, XSEC_BOTH_SIDES, 15.0, -1.0e12, -1.0e12, -1.0e12 ) # Set Tangent Angles At Cross Section SetXSecContinuity( xsec, 1 ) # Set Continuity At Cross Section assert abs( GetParmVal( GetXSecParm( xsec, "TopLAngle" ) ) - 15.0 ) < 1e-6, "the skin Parms were never set" ResetXSecSkinParms( xsec ) # Resetting zeroes every skin value on all four sides and turns the symmetry # flags back on. Continuity is left alone. for skin_parm in [ "TopLAngle", "TopRAngle", "TopLSlew", "TopLStrength", "TopLCurve", "RightLAngle", "BottomLAngle", "LeftLAngle" ]: assert abs( GetParmVal( GetXSecParm( xsec, skin_parm ) ) ) < 1e-6, "ResetXSecSkinParms did not zero " + skin_parm assert abs( GetParmVal( GetXSecParm( xsec, "TBSym" ) ) - 1.0 ) < 1e-12, "ResetXSecSkinParms did not restore the symmetry flags" assert abs( GetParmVal( GetXSecParm( xsec, "RLSym" ) ) - 1.0 ) < 1e-12, "ResetXSecSkinParms did not restore the symmetry flags"
- Parameters:
[in] – xsec_id string XSec ID
- openvsp.GetXSecContinuity(xsec_id)[source]¶
Set C-type continuity enforcement for a particular XSec
fid = AddGeom( "FUSELAGE", "" ) # Add Fuselage xsec_surf = GetXSecSurf( fid, 0 ) # Get First (and Only) XSec Surf num_xsecs = GetNumXSec( xsec_surf ) for i in range(num_xsecs): xsec = GetXSec( xsec_surf, i ) SetXSecContinuity( xsec, 1 ) # Set Continuity At Cross Section # The setter is shorthand for the section's continuity Parm. assert abs( GetParmVal( GetXSecParm( xsec, "ContinuityTop" ) ) - 1.0 ) < 1e-12, "SetXSecContinuity did not set section " + str( i ) SetXSecContinuity( xsec, 0 ) assert abs( GetParmVal( GetXSecParm( xsec, "ContinuityTop" ) ) ) < 1e-12, "SetXSecContinuity did not clear section " + str( i ) SetXSecContinuity( xsec, 1 )
- Parameters:
[in] – xsec_id string XSec ID
[in] – cx int Continuity level (0, 1, or 2)
Get the C-type continuity enforcement for a particular XSec
fid = AddGeom( "FUSELAGE", "" ) # Add Fuselage xsec_surf = GetXSecSurf( fid, 0 ) # Get First (and Only) XSec Surf xsec = GetXSec( xsec_surf, 1 ) SetXSecContinuity( xsec, 1 ) assert GetXSecContinuity( xsec ) == 1, "GetXSecContinuity did not report the level that was set" SetXSecContinuity( xsec, 0 ) assert GetXSecContinuity( xsec ) == 0, "GetXSecContinuity did not follow a second set" # The level is the section's continuity Parm, so the two have to agree. assert abs( GetParmVal( GetXSecParm( xsec, "ContinuityTop" ) ) - GetXSecContinuity( xsec ) ) < 1e-12, "the continuity level disagrees with its Parm"
See also: SetXSecContinuity :param [in]: xsec_id string XSec ID :rtype: int :return: int Continuity level (0, 1, or 2)
- openvsp.SetXSecContinuity(xsec_id, cx)[source]¶
Set how many derivatives are continuous across an XSec: 0 for position only, 1 to also match slope, 2 to also match curvature.
sid = AddGeom( "STACK", "" ) xsec_surf = GetXSecSurf( sid, 0 ) xsec = GetXSec( xsec_surf, 1 ) SetXSecContinuity( xsec, 1 ) assert GetXSecContinuity( xsec ) == 1, "SetXSecContinuity did not take"
See also: GetXSecContinuity :param [in]: xsec_id string XSec ID :param [in]: cx int Number of continuous derivatives, 0, 1 or 2
- openvsp.GetXSecTanAngles(xsec_id, side)[source]¶
Set the tangent angles for the specified XSec
# Add Stack sid = AddGeom( "STACK", "" ) # Get First (and Only) XSec Surf xsec_surf = GetXSecSurf( sid, 0 ) num_xsecs = GetNumXSec( xsec_surf ) for i in range(num_xsecs): xsec = GetXSec( xsec_surf, i ) SetXSecTanAngles( xsec, XSEC_BOTH_SIDES, 10.0, -1.0e12, -1.0e12, -1.0e12 ) # Set Tangent Angles At Cross Section # The setter is shorthand for the skin Parms, so the value has to show up # on both sides of the section. assert abs( GetParmVal( GetXSecParm( xsec, "TopLAngle" ) ) - 10.0 ) < 1e-6, "SetXSecTanAngles did not set the top of section " + str( i ) assert abs( GetParmVal( GetXSecParm( xsec, "TopRAngle" ) ) - 10.0 ) < 1e-6, "SetXSecTanAngles did not set the top of section " + str( i )
See also: XSEC_SIDES_TYPE :param [in]: xsec_id string XSec ID :param [in]: side int Side type enum (i.e. XSEC_BOTH_SIDES) :param [in]: top double Top angle (degrees) :param [in]: right double Right angle (degrees) :param [in]: bottom double Bottom angle (degrees) :param [in]: left double Left angle (degrees)
Get the tangent angles for one side of the specified XSec. The four values come back in the order the setter takes them: top, right, bottom and left. The two sides can hold different values, so XSEC_BOTH_SIDES is not accepted here.
# Add Stack sid = AddGeom( "STACK", "" ) # Get First (and Only) XSec Surf xsec_surf = GetXSecSurf( sid, 0 ) xsec = GetXSec( xsec_surf, 1 ) SetXSecTanAngles( xsec, XSEC_BOTH_SIDES, 10.0, -1.0e12, -1.0e12, -1.0e12 ) vals = GetXSecTanAngles( xsec, XSEC_LEFT_SIDE ) # Setting both sides at once sets all four positions of each. assert len( vals ) == 4, "GetXSecTanAngles did not report four values" for v in vals: assert abs( v - 10.0 ) < 1e-6, "GetXSecTanAngles did not report the value that was set" # Both sides were set, so they agree, and each matches its Parm. right_vals = GetXSecTanAngles( xsec, XSEC_RIGHT_SIDE ) assert len( right_vals ) == 4, "the two sides disagree after setting both" assert abs( right_vals[0] - vals[0] ) < 1e-9, "the two sides disagree after setting both" assert abs( vals[0] - GetParmVal( GetXSecParm( xsec, "TopLAngle" ) ) ) < 1e-9, "GetXSecTanAngles disagrees with its Parm" # XSEC_BOTH_SIDES names no single answer, so it has to be rejected. The # error queue is reached through the error manager singleton in Python. err_mgr = ErrorMgrSingleton.getInstance() GetXSecTanAngles( xsec, XSEC_BOTH_SIDES ) assert err_mgr.GetNumTotalErrors() > 0, "GetXSecTanAngles accepted XSEC_BOTH_SIDES" # That error was raised deliberately, so take it back off the queue. while err_mgr.GetNumTotalErrors() > 0 : err = err_mgr.PopLastError()
See also: XSEC_SIDES_TYPE, SetXSecTanAngles :param [in]: xsec_id string XSec ID :param [in]: side int Side type enum (XSEC_LEFT_SIDE or XSEC_RIGHT_SIDE) :rtype: std::vector< double,std::allocator< double > > :return: vector<double> Top, right, bottom and left values for that side
- openvsp.SetXSecTanAngles(xsec_id, side, top, right, bottom, left)[source]¶
Set the tangent angles for one side of an XSec. The four values are given in the order top, right, bottom and left; a value of -1.0e12 leaves that position as it was. XSEC_BOTH_SIDES sets both sides at once.
sid = AddGeom( "STACK", "" ) xsec_surf = GetXSecSurf( sid, 0 ) xsec = GetXSec( xsec_surf, 1 ) SetXSecTanAngles( xsec, XSEC_BOTH_SIDES, 5.0, 5.0, 5.0, 5.0 ) vals = GetXSecTanAngles( xsec, XSEC_LEFT_SIDE ) for v in vals: assert abs( v - 5.0 ) < 1e-6, "SetXSecTanAngles did not take"
See also: GetXSecTanAngles, XSEC_SIDES_TYPE :param [in]: xsec_id string XSec ID :param [in]: side int XSec side type enum (i.e. XSEC_BOTH_SIDES) :param [in]: top double Value at the top, or -1.0e12 to leave it :param [in]: right double Value at the right, or -1.0e12 to leave it :param [in]: bottom double Value at the bottom, or -1.0e12 to leave it :param [in]: left double Value at the left, or -1.0e12 to leave it
- openvsp.GetXSecTanSlews(xsec_id, side)[source]¶
Set the tangent slew angles for the specified XSec
# Add Stack sid = AddGeom( "STACK", "" ) # Get First (and Only) XSec Surf xsec_surf = GetXSecSurf( sid, 0 ) num_xsecs = GetNumXSec( xsec_surf ) for i in range(num_xsecs): xsec = GetXSec( xsec_surf, i ) SetXSecTanSlews( xsec, XSEC_BOTH_SIDES, 5.0, -1.0e12, -1.0e12, -1.0e12 ) # Set Tangent Slews At Cross Section # The setter is shorthand for the skin Parms, so the value has to show up # on both sides of the section. assert abs( GetParmVal( GetXSecParm( xsec, "TopLSlew" ) ) - 5.0 ) < 1e-6, "SetXSecTanSlews did not set the top of section " + str( i ) assert abs( GetParmVal( GetXSecParm( xsec, "TopRSlew" ) ) - 5.0 ) < 1e-6, "SetXSecTanSlews did not set the top of section " + str( i )
See also: XSEC_SIDES_TYPE :param [in]: xsec_id string XSec ID :param [in]: side int Side type enum (i.e. XSEC_BOTH_SIDES) :param [in]: top double Top angle (degrees) :param [in]: right double Right angle (degrees) :param [in]: bottom double Bottom angle (degrees) :param [in]: left double Left angle (degrees)
Get the tangent slew angles for one side of the specified XSec. The four values come back in the order the setter takes them: top, right, bottom and left. The two sides can hold different values, so XSEC_BOTH_SIDES is not accepted here.
# Add Stack sid = AddGeom( "STACK", "" ) # Get First (and Only) XSec Surf xsec_surf = GetXSecSurf( sid, 0 ) xsec = GetXSec( xsec_surf, 1 ) SetXSecTanSlews( xsec, XSEC_BOTH_SIDES, 5.0, -1.0e12, -1.0e12, -1.0e12 ) vals = GetXSecTanSlews( xsec, XSEC_LEFT_SIDE ) # Setting both sides at once sets all four positions of each. assert len( vals ) == 4, "GetXSecTanSlews did not report four values" for v in vals: assert abs( v - 5.0 ) < 1e-6, "GetXSecTanSlews did not report the value that was set" # Both sides were set, so they agree, and each matches its Parm. right_vals = GetXSecTanSlews( xsec, XSEC_RIGHT_SIDE ) assert len( right_vals ) == 4, "the two sides disagree after setting both" assert abs( right_vals[0] - vals[0] ) < 1e-9, "the two sides disagree after setting both" assert abs( vals[0] - GetParmVal( GetXSecParm( xsec, "TopLSlew" ) ) ) < 1e-9, "GetXSecTanSlews disagrees with its Parm" # XSEC_BOTH_SIDES names no single answer, so it has to be rejected. The # error queue is reached through the error manager singleton in Python. err_mgr = ErrorMgrSingleton.getInstance() GetXSecTanSlews( xsec, XSEC_BOTH_SIDES ) assert err_mgr.GetNumTotalErrors() > 0, "GetXSecTanSlews accepted XSEC_BOTH_SIDES" # That error was raised deliberately, so take it back off the queue. while err_mgr.GetNumTotalErrors() > 0 : err = err_mgr.PopLastError()
See also: XSEC_SIDES_TYPE, SetXSecTanSlews :param [in]: xsec_id string XSec ID :param [in]: side int Side type enum (XSEC_LEFT_SIDE or XSEC_RIGHT_SIDE) :rtype: std::vector< double,std::allocator< double > > :return: vector<double> Top, right, bottom and left values for that side
- openvsp.SetXSecTanSlews(xsec_id, side, top, right, bottom, left)[source]¶
Set the tangent slews for one side of an XSec. The four values are given in the order top, right, bottom and left; a value of -1.0e12 leaves that position as it was. XSEC_BOTH_SIDES sets both sides at once.
sid = AddGeom( "STACK", "" ) xsec_surf = GetXSecSurf( sid, 0 ) xsec = GetXSec( xsec_surf, 1 ) SetXSecTanSlews( xsec, XSEC_BOTH_SIDES, 5.0, 5.0, 5.0, 5.0 ) vals = GetXSecTanSlews( xsec, XSEC_LEFT_SIDE ) for v in vals: assert abs( v - 5.0 ) < 1e-6, "SetXSecTanSlews did not take"
See also: GetXSecTanSlews, XSEC_SIDES_TYPE :param [in]: xsec_id string XSec ID :param [in]: side int XSec side type enum (i.e. XSEC_BOTH_SIDES) :param [in]: top double Value at the top, or -1.0e12 to leave it :param [in]: right double Value at the right, or -1.0e12 to leave it :param [in]: bottom double Value at the bottom, or -1.0e12 to leave it :param [in]: left double Value at the left, or -1.0e12 to leave it
- openvsp.GetXSecTanStrengths(xsec_id, side)[source]¶
Set the tangent strengths for the specified XSec
# Add Stack sid = AddGeom( "STACK", "" ) # Get First (and Only) XSec Surf xsec_surf = GetXSecSurf( sid, 0 ) # Flatten ends num_xsecs = GetNumXSec( xsec_surf ) for i in range(num_xsecs): xsec = GetXSec( xsec_surf, i ) SetXSecTanStrengths( xsec, XSEC_BOTH_SIDES, 0.8, -1.0e12, -1.0e12, -1.0e12 ) # Set Tangent Strengths At Cross Section # The setter is shorthand for the skin Parms, so the value has to show up # on both sides of the section. assert abs( GetParmVal( GetXSecParm( xsec, "TopLStrength" ) ) - 0.8 ) < 1e-6, "SetXSecTanStrengths did not set the top of section " + str( i ) assert abs( GetParmVal( GetXSecParm( xsec, "TopRStrength" ) ) - 0.8 ) < 1e-6, "SetXSecTanStrengths did not set the top of section " + str( i )
See also: XSEC_SIDES_TYPE :param [in]: xsec_id string XSec ID :param [in]: side int Side type enum (i.e. XSEC_BOTH_SIDES) :param [in]: top double Top strength :param [in]: right double Right strength :param [in]: bottom double Bottom strength :param [in]: left double Left strength
Get the tangent strengths for one side of the specified XSec. The four values come back in the order the setter takes them: top, right, bottom and left. The two sides can hold different values, so XSEC_BOTH_SIDES is not accepted here.
# Add Stack sid = AddGeom( "STACK", "" ) # Get First (and Only) XSec Surf xsec_surf = GetXSecSurf( sid, 0 ) xsec = GetXSec( xsec_surf, 1 ) SetXSecTanStrengths( xsec, XSEC_BOTH_SIDES, 0.8, -1.0e12, -1.0e12, -1.0e12 ) vals = GetXSecTanStrengths( xsec, XSEC_LEFT_SIDE ) # Setting both sides at once sets all four positions of each. assert len( vals ) == 4, "GetXSecTanStrengths did not report four values" for v in vals: assert abs( v - 0.8 ) < 1e-6, "GetXSecTanStrengths did not report the value that was set" # Both sides were set, so they agree, and each matches its Parm. right_vals = GetXSecTanStrengths( xsec, XSEC_RIGHT_SIDE ) assert len( right_vals ) == 4, "the two sides disagree after setting both" assert abs( right_vals[0] - vals[0] ) < 1e-9, "the two sides disagree after setting both" assert abs( vals[0] - GetParmVal( GetXSecParm( xsec, "TopLStrength" ) ) ) < 1e-9, "GetXSecTanStrengths disagrees with its Parm" # XSEC_BOTH_SIDES names no single answer, so it has to be rejected. The # error queue is reached through the error manager singleton in Python. err_mgr = ErrorMgrSingleton.getInstance() GetXSecTanStrengths( xsec, XSEC_BOTH_SIDES ) assert err_mgr.GetNumTotalErrors() > 0, "GetXSecTanStrengths accepted XSEC_BOTH_SIDES" # That error was raised deliberately, so take it back off the queue. while err_mgr.GetNumTotalErrors() > 0 : err = err_mgr.PopLastError()
See also: XSEC_SIDES_TYPE, SetXSecTanStrengths :param [in]: xsec_id string XSec ID :param [in]: side int Side type enum (XSEC_LEFT_SIDE or XSEC_RIGHT_SIDE) :rtype: std::vector< double,std::allocator< double > > :return: vector<double> Top, right, bottom and left values for that side
- openvsp.SetXSecTanStrengths(xsec_id, side, top, right, bottom, left)[source]¶
Set the tangent strengths for one side of an XSec. The four values are given in the order top, right, bottom and left; a value of -1.0e12 leaves that position as it was. XSEC_BOTH_SIDES sets both sides at once.
sid = AddGeom( "STACK", "" ) xsec_surf = GetXSecSurf( sid, 0 ) xsec = GetXSec( xsec_surf, 1 ) SetXSecTanStrengths( xsec, XSEC_BOTH_SIDES, 5.0, 5.0, 5.0, 5.0 ) vals = GetXSecTanStrengths( xsec, XSEC_LEFT_SIDE ) for v in vals: assert abs( v - 5.0 ) < 1e-6, "SetXSecTanStrengths did not take"
See also: GetXSecTanStrengths, XSEC_SIDES_TYPE :param [in]: xsec_id string XSec ID :param [in]: side int XSec side type enum (i.e. XSEC_BOTH_SIDES) :param [in]: top double Value at the top, or -1.0e12 to leave it :param [in]: right double Value at the right, or -1.0e12 to leave it :param [in]: bottom double Value at the bottom, or -1.0e12 to leave it :param [in]: left double Value at the left, or -1.0e12 to leave it
- openvsp.GetXSecCurvatures(xsec_id, side)[source]¶
Set curvatures for the specified XSec
# Add Stack sid = AddGeom( "STACK", "" ) # Get First (and Only) XSec Surf xsec_surf = GetXSecSurf( sid, 0 ) # Flatten ends num_xsecs = GetNumXSec( xsec_surf ) for i in range(num_xsecs): xsec = GetXSec( xsec_surf, i ) SetXSecCurvatures( xsec, XSEC_BOTH_SIDES, 0.2, -1.0e12, -1.0e12, -1.0e12 ) # Set Curvatures At Cross Section # The setter is shorthand for the skin Parms, so the value has to show up # on both sides of the section. assert abs( GetParmVal( GetXSecParm( xsec, "TopLCurve" ) ) - 0.2 ) < 1e-6, "SetXSecCurvatures did not set the top of section " + str( i ) assert abs( GetParmVal( GetXSecParm( xsec, "TopRCurve" ) ) - 0.2 ) < 1e-6, "SetXSecCurvatures did not set the top of section " + str( i )
See also: XSEC_SIDES_TYPE :param [in]: xsec_id string XSec ID :param [in]: side int Side type enum (i.e. XSEC_BOTH_SIDES) :param [in]: top double Top curvature :param [in]: right double Right curvature :param [in]: bottom double Bottom curvature :param [in]: left double Left curvature
Get the curvatures for one side of the specified XSec. The four values come back in the order the setter takes them: top, right, bottom and left. The two sides can hold different values, so XSEC_BOTH_SIDES is not accepted here.
# Add Stack sid = AddGeom( "STACK", "" ) # Get First (and Only) XSec Surf xsec_surf = GetXSecSurf( sid, 0 ) xsec = GetXSec( xsec_surf, 1 ) SetXSecCurvatures( xsec, XSEC_BOTH_SIDES, 0.2, -1.0e12, -1.0e12, -1.0e12 ) vals = GetXSecCurvatures( xsec, XSEC_LEFT_SIDE ) # Setting both sides at once sets all four positions of each. assert len( vals ) == 4, "GetXSecCurvatures did not report four values" for v in vals: assert abs( v - 0.2 ) < 1e-6, "GetXSecCurvatures did not report the value that was set" # Both sides were set, so they agree, and each matches its Parm. right_vals = GetXSecCurvatures( xsec, XSEC_RIGHT_SIDE ) assert len( right_vals ) == 4, "the two sides disagree after setting both" assert abs( right_vals[0] - vals[0] ) < 1e-9, "the two sides disagree after setting both" assert abs( vals[0] - GetParmVal( GetXSecParm( xsec, "TopLCurve" ) ) ) < 1e-9, "GetXSecCurvatures disagrees with its Parm" # XSEC_BOTH_SIDES names no single answer, so it has to be rejected. The # error queue is reached through the error manager singleton in Python. err_mgr = ErrorMgrSingleton.getInstance() GetXSecCurvatures( xsec, XSEC_BOTH_SIDES ) assert err_mgr.GetNumTotalErrors() > 0, "GetXSecCurvatures accepted XSEC_BOTH_SIDES" # That error was raised deliberately, so take it back off the queue. while err_mgr.GetNumTotalErrors() > 0 : err = err_mgr.PopLastError()
See also: XSEC_SIDES_TYPE, SetXSecCurvatures :param [in]: xsec_id string XSec ID :param [in]: side int Side type enum (XSEC_LEFT_SIDE or XSEC_RIGHT_SIDE) :rtype: std::vector< double,std::allocator< double > > :return: vector<double> Top, right, bottom and left values for that side
- openvsp.SetXSecCurvatures(xsec_id, side, top, right, bottom, left)[source]¶
Set the curvatures for one side of an XSec. The four values are given in the order top, right, bottom and left; a value of -1.0e12 leaves that position as it was. XSEC_BOTH_SIDES sets both sides at once.
sid = AddGeom( "STACK", "" ) xsec_surf = GetXSecSurf( sid, 0 ) xsec = GetXSec( xsec_surf, 1 ) SetXSecCurvatures( xsec, XSEC_BOTH_SIDES, 5.0, 5.0, 5.0, 5.0 ) vals = GetXSecCurvatures( xsec, XSEC_LEFT_SIDE ) for v in vals: assert abs( v - 5.0 ) < 1e-6, "SetXSecCurvatures did not take"
See also: GetXSecCurvatures, XSEC_SIDES_TYPE :param [in]: xsec_id string XSec ID :param [in]: side int XSec side type enum (i.e. XSEC_BOTH_SIDES) :param [in]: top double Value at the top, or -1.0e12 to leave it :param [in]: right double Value at the right, or -1.0e12 to leave it :param [in]: bottom double Value at the bottom, or -1.0e12 to leave it :param [in]: left double Value at the left, or -1.0e12 to leave it
- openvsp.ReadFileAirfoil(xsec_id, file_name)[source]¶
Read in XSec shape from airfoil file and set to the specified XSec. The XSec must be of type XS_FILE_AIRFOIL. Airfoil files may be in Lednicer or Selig format with *.af or *.dat extensions.
# Add Fuselage Geom fuseid = AddGeom( "FUSELAGE", "" ) xsec_surf = GetXSecSurf( fuseid, 0 ) ChangeXSecShape( xsec_surf, 1, XS_FILE_AIRFOIL ) xsec = GetXSec( xsec_surf, 1 ) ReadFileAirfoil( xsec, "airfoil/N0012_VSP.af" ) up_array = GetAirfoilUpperPnts( xsec ) low_array = GetAirfoilLowerPnts( xsec ) assert len( up_array ) > 0, "ReadFileAirfoil did not read matching surfaces" assert len( up_array ) == len( low_array ), "ReadFileAirfoil did not read matching surfaces" # The points run from the leading edge to the trailing edge on a unit chord. assert abs( up_array[0].x() ) < 1e-6, "ReadFileAirfoil did not normalize the chord" assert abs( up_array[-1].x() - 1.0 ) < 1e-6, "ReadFileAirfoil did not normalize the chord" assert abs( low_array[0].x() ) < 1e-6, "ReadFileAirfoil did not normalize the chord" # A NACA 0012 is symmetric, so the lower surface mirrors the upper, and the # section is twelve percent thick. for i in range( len( up_array ) ): assert abs( low_array[i].y() + up_array[i].y() ) < 1e-6, "ReadFileAirfoil did not read a symmetric section" max_up = max( [ p.y() for p in up_array ] ) assert abs( 2.0 * max_up - 0.12 ) < 1e-3, "ReadFileAirfoil did not read a twelve percent section"
- Parameters:
[in] – xsec_id string XSec ID
[in] – file_name string Airfoil XSec file name
- openvsp.SetAirfoilUpperPnts(xsec_id, up_pnt_vec)[source]¶
Set the upper points for an airfoil. The XSec must be of type XS_FILE_AIRFOIL.
# Add Fuselage Geom fuseid = AddGeom( "FUSELAGE", "" ) xsec_surf = GetXSecSurf( fuseid, 0 ) ChangeXSecShape( xsec_surf, 1, XS_FILE_AIRFOIL ) xsec = GetXSec( xsec_surf, 1 ) ReadFileAirfoil( xsec, "airfoil/N0012_VSP.af" ) up_array = GetAirfoilUpperPnts( xsec ) for i in range(int( len(up_array) )): up_array[i].scale_y( 2.0 ) SetAirfoilUpperPnts( xsec, up_array ) check_array = GetAirfoilUpperPnts( xsec ) assert len( check_array ) == len( up_array ), "SetAirfoilUpperPnts point count" # The doubled upper surface has to come back doubled, and the lower surface # has to be left alone. for i in range( len( up_array ) ): assert dist( check_array[i], up_array[i] ) < 1e-6, "SetAirfoilUpperPnts did not store point " + str( i ) low_array = GetAirfoilLowerPnts( xsec ) max_up = max( [ p.y() for p in check_array ] ) min_low = min( [ p.y() for p in low_array ] ) assert abs( max_up + 2.0 * min_low ) < 1e-6, "SetAirfoilUpperPnts did not leave the lower surface alone"
- Parameters:
[in] – xsec_id string XSec ID
[in] – up_pnt_vec vector<vec3d> Array of points defining the upper surface of the airfoil
- openvsp.SetAirfoilLowerPnts(xsec_id, low_pnt_vec)[source]¶
Set the lower points for an airfoil. The XSec must be of type XS_FILE_AIRFOIL.
# Add Fuselage Geom fuseid = AddGeom( "FUSELAGE", "" ) xsec_surf = GetXSecSurf( fuseid, 0 ) ChangeXSecShape( xsec_surf, 1, XS_FILE_AIRFOIL ) xsec = GetXSec( xsec_surf, 1 ) ReadFileAirfoil( xsec, "airfoil/N0012_VSP.af" ) low_array = GetAirfoilLowerPnts( xsec ) for i in range(int( len(low_array) )): low_array[i].scale_y( 0.5 ) SetAirfoilLowerPnts( xsec, low_array ) check_array = GetAirfoilLowerPnts( xsec ) assert len( check_array ) == len( low_array ), "SetAirfoilLowerPnts point count" # The halved lower surface has to come back halved, and the upper surface # has to be left alone. for i in range( len( low_array ) ): assert dist( check_array[i], low_array[i] ) < 1e-6, "SetAirfoilLowerPnts did not store point " + str( i ) up_array = GetAirfoilUpperPnts( xsec ) max_up = max( [ p.y() for p in up_array ] ) min_low = min( [ p.y() for p in check_array ] ) assert abs( 0.5 * max_up + min_low ) < 1e-6, "SetAirfoilLowerPnts did not leave the upper surface alone"
- Parameters:
[in] – xsec_id string XSec ID
[in] – low_pnt_vec vector<vec3d> Array of points defining the lower surface of the airfoil
- openvsp.SetAirfoilPnts(xsec_id, up_pnt_vec, low_pnt_vec)[source]¶
Set the upper and lower points for an airfoil. The XSec must be of type XS_FILE_AIRFOIL.
# Add Fuselage Geom fuseid = AddGeom( "FUSELAGE", "" ) xsec_surf = GetXSecSurf( fuseid, 0 ) ChangeXSecShape( xsec_surf, 1, XS_FILE_AIRFOIL ) xsec = GetXSec( xsec_surf, 1 ) ReadFileAirfoil( xsec, "airfoil/N0012_VSP.af" ) up_array = GetAirfoilUpperPnts( xsec ) low_array = GetAirfoilLowerPnts( xsec ) for i in range(int( len(up_array) )): up_array[i].scale_y( 2.0 ) low_array[i].scale_y( 0.5 ) SetAirfoilPnts( xsec, up_array, low_array ) check_up = GetAirfoilUpperPnts( xsec ) check_low = GetAirfoilLowerPnts( xsec ) assert len( check_up ) == len( up_array ), "SetAirfoilPnts point count" assert len( check_low ) == len( low_array ), "SetAirfoilPnts point count" for i in range( len( up_array ) ): assert dist( check_up[i], up_array[i] ) < 1e-6, "SetAirfoilPnts did not store point " + str( i ) assert dist( check_low[i], low_array[i] ) < 1e-6, "SetAirfoilPnts did not store point " + str( i ) # The section started symmetric; doubling the top and halving the bottom # leaves the top four times as deep as the bottom. max_up = max( [ p.y() for p in check_up ] ) min_low = min( [ p.y() for p in check_low ] ) assert abs( max_up + 4.0 * min_low ) < 1e-6, "SetAirfoilPnts did not scale the two surfaces apart"
- Parameters:
[in] – xsec_id string XSec ID
[in] – up_pnt_vec vector<vec3d> Array of points defining the upper surface of the airfoil
[in] – low_pnt_vec vector<vec3d> Array of points defining the lower surface of the airfoil
- openvsp.GetHersheyBarLiftDist(npts, alpha, Vinf, span, full_span_flag=False)[source]¶
Get the theoretical lift (Cl) distribution for a Hershey Bar wing with unit chord length using Glauert’s Method. This function was initially created to compare VSPAERO results to Lifting Line Theory. If full_span_flag is set to true symmetry is applied to the results.
pi = 3.14159265358979323846 # Compute theoretical lift and drag distributions using 100 points Vinf = 100 halfAR = 20 alpha_deg = 10 n_pts = 100 cl_dist_theo = GetHersheyBarLiftDist( int( n_pts ), alpha_deg*pi/180, Vinf, ( 2 * halfAR ), False ) assert len( cl_dist_theo ) > 0, "GetHersheyBarLiftDist returned nothing" cd_dist_theo = GetHersheyBarDragDist( int( n_pts ), alpha_deg*pi/180, Vinf, ( 2 * halfAR ), False )
- Parameters:
[in] – npts int Number of points along the span to assess
[in] – alpha double Wing angle of attack (Radians)
[in] – Vinf double Freestream velocity
[in] – span double Hershey Bar full-span. Note, only half is used in the calculation
[in] – full_span_flag bool Flag to apply symmetry to results
- Return type:
std::vector< vec3d,std::allocator< vec3d > >
- Returns:
vector<vec3d> Theoretical coefficient of lift distribution array (size = 2*npts if full_span_flag = true)
- openvsp.GetHersheyBarDragDist(npts, alpha, Vinf, span, full_span_flag=False)[source]¶
Get the theoretical drag (Cd) distribution for a Hershey Bar wing with unit chord length using Glauert’s Method. This function was initially created to compare VSPAERO results to Lifting Line Theory. If full_span_flag is set to true symmetry is applied to the results.
pi = 3.14159265358979323846 # Compute theoretical lift and drag distributions using 100 points Vinf = 100 halfAR = 20 alpha_deg = 10 n_pts = 100 cl_dist_theo = GetHersheyBarLiftDist( int( n_pts ), alpha_deg*pi/180, Vinf, ( 2 * halfAR ), False ) cd_dist_theo = GetHersheyBarDragDist( int( n_pts ), alpha_deg*pi/180, Vinf, ( 2 * halfAR ), False ) assert len( cd_dist_theo ) > 0, "GetHersheyBarDragDist returned nothing"
- Parameters:
[in] – npts int Number of points along the span to assess
[in] – alpha double Wing angle of attack (Radians)
[in] – Vinf double Freestream velocity
[in] – span double Hershey Bar full-span. Note, only half is used in the calculation
[in] – full_span_flag bool Flag to apply symmetry to results (default: false)
- Return type:
std::vector< vec3d,std::allocator< vec3d > >
- Returns:
vector<vec3d> Theoretical coefficient of drag distribution array (size = 2*npts if full_span_flag = true)
- openvsp.GetVKTAirfoilPnts(npts, alpha, epsilon, kappa, tau)[source]¶
Get the 2D coordinates an input number of points along a Von K�rm�n-Trefftz airfoil of specified shape
pi = 3.14159265358979323846 npts = 122 alpha = 0.0 epsilon = 0.1 kappa = 0.1 tau = 10 xyz_airfoil = GetVKTAirfoilPnts(npts, alpha, epsilon, kappa, tau*(pi/180) ) assert len( xyz_airfoil ) > 0, "GetVKTAirfoilPnts returned nothing" cp_dist = GetVKTAirfoilCpDist( alpha, epsilon, kappa, tau*(pi/180), xyz_airfoil )
- Parameters:
[in] – npts int Number of points along the airfoil to return
[in] – alpha double Airfoil angle of attack (Radians)
[in] – epsilon double Airfoil thickness
[in] – kappa double Airfoil camber
[in] – tau double Airfoil trailing edge angle (Radians)
- Return type:
std::vector< vec3d,std::allocator< vec3d > >
- Returns:
vector<vec3d> Array of points on the VKT airfoil (size = npts)
- openvsp.GetVKTAirfoilCpDist(alpha, epsilon, kappa, tau, xyz_data)[source]¶
Get the pressure coefficient (Cp) along a Von Kármán-Trefftz airfoil of specified shape at specified points along the airfoil
pi = 3.14159265358979323846 npts = 122 alpha = 0.0 epsilon = 0.1 kappa = 0.1 tau = 10 xyz_airfoil = GetVKTAirfoilPnts(npts, alpha, epsilon, kappa, tau*(pi/180) ) cp_dist = GetVKTAirfoilCpDist( alpha, epsilon, kappa, tau*(pi/180), xyz_airfoil ) assert len( cp_dist ) > 0, "GetVKTAirfoilCpDist returned nothing"
See also: GetVKTAirfoilPnts :param [in]: alpha double Airfoil angle of attack (Radians) :param [in]: epsilon double Airfoil thickness :param [in]: kappa double Airfoil camber :param [in]: tau double Airfoil trailing edge angle (Radians) :param [in]: xyz_data vector<vec3d> Vector of points on the airfoil to evaluate :rtype: std::vector< double,std::allocator< double > > :return: vector<double> Vector of Cp values for each point in xydata
- openvsp.GetEllipsoidSurfPnts(center, abc_rad, u_npts=20, w_npts=20)[source]¶
Generate the surface coordinate points for a ellipsoid at specified center of input radius along each axis. Based on the MATLAB function ellipsoid (https://in.mathworks.com/help/matlab/ref/ellipsoid.html).
pnts = GetEllipsoidSurfPnts( vec3d( 0.0, 0.0, 0.0 ), vec3d( 1.0, 2.0, 3.0 ), 10, 10 ) assert len( pnts ) > 0, "GetEllipsoidSurfPnts returned nothing"
See also: GetVKTAirfoilPnts :param [in]: center vec3d 3D location of the ellipsoid center :param [in]: abc_rad vec3d Radius along the A (X), B (Y), and C (Z) axes :param [in]: u_npts int Number of points in the U direction :param [in]: w_npts int Number of points in the W direction :rtype: std::vector< vec3d,std::allocator< vec3d > > :return: vector<vec3d> Array of coordinates describing the ellipsoid surface
- openvsp.GetFeatureLinePnts(geom_id)[source]¶
Get the points along the feature lines of a particular Geom
pid = AddGeom( "POD" ) Update() pnts = GetFeatureLinePnts( pid ) assert len( pnts ) > 0, "GetFeatureLinePnts returned nothing"
- Parameters:
[in] – geom_id string Geom ID
- Return type:
std::vector< vec3d,std::allocator< vec3d > >
- Returns:
vector<vec3d> Array of points along the Geom’s feature lines
- openvsp.GetEllipsoidCpDist(surf_pnt_vec, abc_rad, V_inf)[source]¶
Generate Analytical Solution for Potential Flow for specified ellipsoid shape at input surface points for input velocity vector. Based on Munk, M. M., ‘Remarks on the Pressure Distribution over the Surface of an Ellipsoid, Moving Translationally Through a Perfect Fluid,’ NACA TN-196, June 1924. Function initially created to compare VSPAERO results to theory.
import math pi = 3.14159265358979323846 npts = 101 abc_rad = vec3d(1.0, 2.0, 3.0) alpha = 5 # deg beta = 5 # deg V_inf = 100.0 x_slice_pnt_vec = [None]*npts theta_vec = [None]*npts theta_vec[0] = 0 for i in range(1, npts): theta_vec[i] = theta_vec[i-1] + (2 * pi / (npts - 1)) for i in range(npts): x_slice_pnt_vec[i] = vec3d( 0, abc_rad.y() * math.cos( theta_vec[i] ), abc_rad.z() * math.sin( theta_vec[i] ) ) V_vec = vec3d( ( V_inf * math.cos( alpha*pi/180 ) * math.cos( beta*pi/180 ) ), ( V_inf * math.sin( beta*pi/180 ) ), ( V_inf * math.sin( alpha*pi/180 ) * math.cos( beta*pi/180 ) ) ) cp_dist = GetEllipsoidCpDist( x_slice_pnt_vec, abc_rad, V_vec ) assert len( cp_dist ) > 0, "GetEllipsoidCpDist returned nothing"
See also: GetEllipsoidSurfPnts :param [in]: surf_pnt_vec vector<vec3d> Vector of points on the ellipsoid surface to assess :param [in]: abc_rad vec3d Radius along the A (X), B (Y), and C (Z) axes :param [in]: V_inf vec3d 3D components of freestream velocity :rtype: std::vector< double,std::allocator< double > > :return: vector<double> Vector of Cp results corresponding to each point in surf_pnt_arr
- openvsp.GetAirfoilUpperPnts(xsec_id)[source]¶
Get the coordinate points for the upper surface of an airfoil. The XSec must be of type XS_FILE_AIRFOIL
# Add Fuselage Geom fuseid = AddGeom( "FUSELAGE", "" ) xsec_surf = GetXSecSurf( fuseid, 0 ) ChangeXSecShape( xsec_surf, 1, XS_FILE_AIRFOIL ) xsec = GetXSec( xsec_surf, 1 ) ReadFileAirfoil( xsec, "airfoil/N0012_VSP.af" ) up_array = GetAirfoilUpperPnts( xsec ) assert len( up_array ) > 0, "GetAirfoilUpperPnts returned nothing"
See also: SetAirfoilPnts :param [in]: xsec_id string XSec ID :rtype: std::vector< vec3d,std::allocator< vec3d > > :return: vector<vec3d> VectorArray of coordinate points for the upper airfoil surface
- openvsp.GetAirfoilLowerPnts(xsec_id)[source]¶
Get the coordinate points for the lower surface of an airfoil. The XSec must be of type XS_FILE_AIRFOIL
# Add Fuselage Geom fuseid = AddGeom( "FUSELAGE", "" ) xsec_surf = GetXSecSurf( fuseid, 0 ) ChangeXSecShape( xsec_surf, 1, XS_FILE_AIRFOIL ) xsec = GetXSec( xsec_surf, 1 ) ReadFileAirfoil( xsec, "airfoil/N0012_VSP.af" ) low_array = GetAirfoilLowerPnts( xsec ) assert len( low_array ) > 0, "GetAirfoilLowerPnts returned nothing"
See also: SetAirfoilPnts :param [in]: xsec_id string XSec ID :rtype: std::vector< vec3d,std::allocator< vec3d > > :return: vector<vec3d> Vector of coordinate points for the lower airfoil surface
- openvsp.GetUpperCSTCoefs(xsec_id)[source]¶
Get the CST coefficients for the upper surface of an airfoil. The XSec must be of type XS_CST_AIRFOIL
wid = AddGeom( "WING" ) xsec_surf = GetXSecSurf( wid, 0 ) ChangeXSecShape( xsec_surf, 1, XS_CST_AIRFOIL ) Update() xsec = GetXSec( xsec_surf, 1 ) coefs = GetUpperCSTCoefs( xsec ) assert len( coefs ) > 0, "GetUpperCSTCoefs returned nothing"
See also: SetUpperCST :param [in]: xsec_id string XSec ID :rtype: std::vector< double,std::allocator< double > > :return: vector<double> Vector of CST coefficients for the upper airfoil surface
- openvsp.GetLowerCSTCoefs(xsec_id)[source]¶
Get the CST coefficients for the lower surface of an airfoil. The XSec must be of type XS_CST_AIRFOIL
wid = AddGeom( "WING" ) xsec_surf = GetXSecSurf( wid, 0 ) ChangeXSecShape( xsec_surf, 1, XS_CST_AIRFOIL ) Update() xsec = GetXSec( xsec_surf, 1 ) coefs = GetLowerCSTCoefs( xsec ) assert len( coefs ) > 0, "GetLowerCSTCoefs returned nothing"
See also: SetLowerCST :param [in]: xsec_id string XSec ID :rtype: std::vector< double,std::allocator< double > > :return: vector<double> Vector of CST coefficients for the lower airfoil surface
- openvsp.GetUpperCSTDegree(xsec_id)[source]¶
Get the CST degree for the upper surface of an airfoil. The XSec must be of type XS_CST_AIRFOIL
wid = AddGeom( "WING" ) xsec_surf = GetXSecSurf( wid, 0 ) ChangeXSecShape( xsec_surf, 1, XS_CST_AIRFOIL ) Update() xsec = GetXSec( xsec_surf, 1 ) assert GetUpperCSTDegree( xsec ) >= 1, "GetUpperCSTDegree returned a degenerate degree"
See also: SetUpperCST :param [in]: xsec_id string XSec ID :rtype: int :return: int CST Degree for upper airfoil surface
- openvsp.GetLowerCSTDegree(xsec_id)[source]¶
Get the CST degree for the lower surface of an airfoil. The XSec must be of type XS_CST_AIRFOIL
wid = AddGeom( "WING" ) xsec_surf = GetXSecSurf( wid, 0 ) ChangeXSecShape( xsec_surf, 1, XS_CST_AIRFOIL ) Update() xsec = GetXSec( xsec_surf, 1 ) assert GetLowerCSTDegree( xsec ) >= 1, "GetLowerCSTDegree returned a degenerate degree"
See also: SetLowerCST :param [in]: xsec_id string XSec ID :rtype: int :return: int CST Degree for lower airfoil surface
- openvsp.SetUpperCST(xsec_id, deg, coefs)[source]¶
Set the CST degree and coefficients for the upper surface of an airfoil. The number of coefficients should be one more than the CST degree. The XSec must be of type XS_CST_AIRFOIL
wid = AddGeom( "WING" ) xsec_surf = GetXSecSurf( wid, 0 ) ChangeXSecShape( xsec_surf, 1, XS_CST_AIRFOIL ) Update() xsec = GetXSec( xsec_surf, 1 ) coefs = GetUpperCSTCoefs( xsec ) SetUpperCST( xsec, GetUpperCSTDegree( xsec ), coefs ) Update()
See also: GetUpperCSTDegree, GetUpperCSTCoefs :param [in]: xsec_id string XSec ID :param [in]: deg int CST degree of upper airfoil surface :param [in]: coefs vector<double> Vector of CST coefficients for the upper airfoil surface
- openvsp.SetLowerCST(xsec_id, deg, coefs)[source]¶
Set the CST degree and coefficients for the lower surface of an airfoil. The number of coefficients should be one more than the CST degree. The XSec must be of type XS_CST_AIRFOIL
wid = AddGeom( "WING" ) xsec_surf = GetXSecSurf( wid, 0 ) ChangeXSecShape( xsec_surf, 1, XS_CST_AIRFOIL ) Update() xsec = GetXSec( xsec_surf, 1 ) coefs = GetLowerCSTCoefs( xsec ) SetLowerCST( xsec, GetLowerCSTDegree( xsec ), coefs ) Update()
See also: GetLowerCSTDegree, GetLowerCSTCoefs :param [in]: xsec_id string XSec ID :param [in]: deg int CST degree of lower airfoil surface :param [in]: coefs vector<double> Vector of CST coefficients for the lower airfoil surface
- openvsp.PromoteCSTUpper(xsec_id)[source]¶
Promote the CST for the upper airfoil surface. The XSec must be of type XS_CST_AIRFOIL
wid = AddGeom( "WING" ) xsec_surf = GetXSecSurf( wid, 0 ) ChangeXSecShape( xsec_surf, 1, XS_CST_AIRFOIL ) Update() xsec = GetXSec( xsec_surf, 1 ) deg = GetUpperCSTDegree( xsec ) PromoteCSTUpper( xsec ) assert GetUpperCSTDegree( xsec ) == deg + 1, "PromoteCSTUpper did not raise the degree"
See also: GetUpperCSTDegree :param [in]: xsec_id string XSec ID
- openvsp.PromoteCSTLower(xsec_id)[source]¶
Promote the CST for the lower airfoil surface. The XSec must be of type XS_CST_AIRFOIL
wid = AddGeom( "WING" ) xsec_surf = GetXSecSurf( wid, 0 ) ChangeXSecShape( xsec_surf, 1, XS_CST_AIRFOIL ) Update() xsec = GetXSec( xsec_surf, 1 ) deg = GetLowerCSTDegree( xsec ) PromoteCSTLower( xsec ) assert GetLowerCSTDegree( xsec ) == deg + 1, "PromoteCSTLower did not raise the degree"
See also: GetLowerCSTDegree :param [in]: xsec_id string XSec ID
- openvsp.DemoteCSTUpper(xsec_id)[source]¶
Demote the CST for the upper airfoil surface. The XSec must be of type XS_CST_AIRFOIL
wid = AddGeom( "WING" ) xsec_surf = GetXSecSurf( wid, 0 ) ChangeXSecShape( xsec_surf, 1, XS_CST_AIRFOIL ) Update() xsec = GetXSec( xsec_surf, 1 ) PromoteCSTUpper( xsec ) deg = GetUpperCSTDegree( xsec ) DemoteCSTUpper( xsec ) assert GetUpperCSTDegree( xsec ) == deg - 1, "DemoteCSTUpper did not lower the degree"
See also: GetUpperCSTDegree :param [in]: xsec_id string XSec ID
- openvsp.DemoteCSTLower(xsec_id)[source]¶
Demote the CST for the lower airfoil surface. The XSec must be of type XS_CST_AIRFOIL
wid = AddGeom( "WING" ) xsec_surf = GetXSecSurf( wid, 0 ) ChangeXSecShape( xsec_surf, 1, XS_CST_AIRFOIL ) Update() xsec = GetXSec( xsec_surf, 1 ) PromoteCSTLower( xsec ) deg = GetLowerCSTDegree( xsec ) DemoteCSTLower( xsec ) assert GetLowerCSTDegree( xsec ) == deg - 1, "DemoteCSTLower did not lower the degree"
See also: GetLowerCSTDegree :param [in]: xsec_id string XSec ID
- openvsp.FitAfCST(xsec_surf_id, xsec_index, deg)[source]¶
Fit a CST airfoil for an existing airfoil of type XS_FOUR_SERIES, XS_SIX_SERIES, XS_FOUR_DIGIT_MOD, XS_FIVE_DIGIT, XS_FIVE_DIGIT_MOD, XS_ONE_SIX_SERIES, or XS_FILE_AIRFOIL.
wid = AddGeom( "WING" ) xsec_surf = GetXSecSurf( wid, 0 ) Update() FitAfCST( xsec_surf, 1, 5 ) Update()
- Parameters:
[in] – xsec_surf_id string XsecSurf ID
[in] – xsec_index int XSec index
[in] – deg int CST degree
- openvsp.WriteBezierAirfoil(file_name, geom_id, foilsurf_u)[source]¶
Write out the untwisted unit-length 2D Bezier curve for the specified airfoil in custom*.bz format. The output will describe the analytical shape of the airfoil. See BezierAirfoilExample.m and BezierCtrlToCoordPnts.m for examples of discretizing the Bezier curve and generating a Selig airfoil file.
#==== Add Wing Geometry and Set Parms ====// wing_id = AddGeom( "WING", "" ) u = 0.5 # export airfoil at mid span location #==== Write Bezier Airfoil File ====// WriteBezierAirfoil( "Example_Bezier.bz", wing_id, u ) # The call above should have produced a file with content in it. import os assert os.path.getsize( "Example_Bezier.bz" ) > 0, "WriteBezierAirfoil wrote no file"
- Parameters:
[in] – file_name string Airfoil (*.bz) output file name
[in] – geom_id string Geom ID
[in] – foilsurf_u double U location (range: 0 - 1) along the surface. The foil surface does not include root and tip caps (i.e. 2 section wing -> XSec0 @ u=0, XSec1 @ u=0.5, XSec2 @ u=1.0)
- openvsp.WriteSeligAirfoil(file_name, geom_id, foilsurf_u)[source]¶
Write out the untwisted unit-length 2D coordinate points for the specified airfoil in Selig format. Coordinate points follow the on-screen wire frame W tessellation.
#==== Add Wing Geometry and Set Parms ====// wing_id = AddGeom( "WING", "" ) u = 0.5 # export airfoil at mid span location #==== Write Selig Airfoil File ====// WriteSeligAirfoil( "Example_Selig.dat", wing_id, u ) # The call above should have produced a file with content in it. import os assert os.path.getsize( "Example_Selig.dat" ) > 0, "WriteSeligAirfoil wrote no file"
See also: GetAirfoilCoordinates :param [in]: file_name string Airfoil (*.dat) output file name :param [in]: geom_id string Geom ID :param [in]: foilsurf_u double U location (range: 0 - 1) along the surface. The foil surface does not include root and tip caps (i.e. 2 section wing -> XSec0 @ u=0, XSec1 @ u=0.5, XSec2 @ u=1.0)
- openvsp.GetAirfoilCoordinates(geom_id, foilsurf_u)[source]¶
Get the untwisted unit-length 2D coordinate points for the specified airfoil
wid = AddGeom( "WING" ) Update() pnts = GetAirfoilCoordinates( wid, 0.5 ) assert len( pnts ) > 0, "GetAirfoilCoordinates returned nothing"
See also: WriteSeligAirfoil :param [in]: geom_id string Geom ID :param [in]: foilsurf_u double U location (range: 0 - 1) along the surface. The foil surface does not include root and tip caps (i.e. 2 section wing -> XSec0 @ u=0, XSec1 @ u=0.5, XSec2 @ u=1.0)