OpenVSP API Documentation 3.51.3
Loading...
Searching...
No Matches
Parasite Drag Functions

This group of API functions is supplemental to performing a Paraste Drag analysis through the Analysis Manager. They include functions to write out Parasite Drag Tool equations, calculate atmospheric properties, and control excrescences. Click here to return to the main page. More...

Functions

void vsp::AddExcrescence (const std::string &excresName, const int &excresType, const double &excresVal)
int vsp::GetNumExcrescences ()
void vsp::DeleteAllExcrescences ()
void vsp::UpdateParasiteDrag ()
std::string vsp::ExportParasiteDragToCSV (const std::string &file_name)
void vsp::WriteAtmosphereCSVFile (const std::string &file_name, const int &atmos_type)
void vsp::CalcAtmosphere (const double &alt, const double &delta_temp, const int &atmos_type, double &temp, double &pres, double &pres_ratio, double &rho_ratio)
void vsp::WriteBodyFFCSVFile (const std::string &file_name)
void vsp::WriteWingFFCSVFile (const std::string &file_name)
void vsp::WriteCfEqnCSVFile (const std::string &file_name)
void vsp::WritePartialCfMethodCSVFile (const std::string &file_name)

Detailed Description

Function Documentation

◆ AddExcrescence()

void vsp::AddExcrescence ( const std::string & excresName,
const int & excresType,
const double & excresVal )
extern

Add an Excresence to the Parasite Drag Tool

AddExcrescence( "Miscellaneous", EXCRESCENCE_COUNT, 8.5 );
AddExcrescence( "Cowl Boattail", EXCRESCENCE_CD, 0.0003 );
// Each excrescence gets its own row, so deleting them one at a time has to
// empty the table and then start being rejected.
DeleteExcrescence( 1 );
DeleteExcrescence( 0 );
if ( GetNumTotalErrors() != 0 )
{
Print( "ERROR: the two excrescences were not both added" );
__failure++;
}
DeleteExcrescence( 0 );
if ( GetNumTotalErrors() == 0 )
{
Print( "ERROR: more excrescences were added than asked for" );
__failure++;
}
// That error was raised deliberately, so take it back off the queue.
while ( GetNumTotalErrors() > 0 )
{
ErrorObj err = PopLastError();
}
@ EXCRESCENCE_COUNT
Definition APIDefines.h:548
@ EXCRESCENCE_CD
Definition APIDefines.h:549
void AddExcrescence(const std::string &excresName, const int &excresType, const double &excresVal)
See also
EXCRES_TYPE
Parameters
[in]excresNamestring Name of the Excressence
[in]excresTypeint Excressence type enum (i.e. EXCRESCENCE_PERCENT_GEOM)
[in]excresValdouble Excressence value

◆ CalcAtmosphere()

void vsp::CalcAtmosphere ( const double & alt,
const double & delta_temp,
const int & atmos_type,
double & temp,
double & pres,
double & pres_ratio,
double & rho_ratio )
extern

Calculate the atmospheric properties determined by a specified model at input altitude and temperature deviation. This function may not be used for any manual atmospheric model types (i.e. ATMOS_TYPE_MANUAL_P_T). This function assumes freestream units are metric, temperature units are Kelvin, and pressure units are kPA.

double temp, pres, pres_ratio, rho_ratio;
double alt = 4000;
double delta_temp = 0;
CalcAtmosphere( alt, delta_temp, ATMOS_TYPE_US_STANDARD_1976, temp, pres, pres_ratio, rho_ratio );
// The ratios are against sea level standard day, so asking at sea level with
// no temperature offset has to return the sea level standard itself.
double sl_temp, sl_pres, sl_pres_ratio, sl_rho_ratio;
CalcAtmosphere( 0.0, 0.0, ATMOS_TYPE_US_STANDARD_1976, sl_temp, sl_pres, sl_pres_ratio, sl_rho_ratio );
if ( !closeTo( sl_temp, 288.15, 1e-2 ) )
{
Print( "ERROR: sea level is not the standard day temperature" );
__failure++;
}
// The density ratio carries a little rounding from the model constants.
if ( !closeTo( sl_pres_ratio, 1.0, 1e-9 ) || !closeTo( sl_rho_ratio, 1.0, 1e-4 ) )
{
Print( "ERROR: the sea level ratios are not one" );
__failure++;
}
// The atmosphere thins with altitude.
if ( temp >= sl_temp || pres >= sl_pres || pres_ratio >= 1.0 || rho_ratio >= 1.0 )
{
Print( "ERROR: the atmosphere did not thin with altitude" );
__failure++;
}
// The pressure ratio is the pressure against sea level.
if ( !closeTo( pres_ratio, pres / sl_pres, 1e-6 ) )
{
Print( "ERROR: the pressure ratio does not match the pressure" );
__failure++;
}
@ ATMOS_TYPE_US_STANDARD_1976
Definition APIDefines.h:69
void CalcAtmosphere(const double &alt, const double &delta_temp, const int &atmos_type, double &temp, double &pres, double &pres_ratio, double &rho_ratio)
See also
ATMOS_TYPE
Parameters
[in]altdouble Altitude
[in]delta_tempdouble Deviation in temperature from the value specified in the atmospheric model
[in]atmos_typeint Atmospheric model enum (i.e. ATMOS_TYPE_HERRINGTON_1966)
[out]tempdouble output Temperature
[out]presdouble output Pressure
[out]pres_ratiodouble Output pressure ratio
[out]rho_ratiodouble Output density ratio

◆ DeleteAllExcrescences()

void vsp::DeleteAllExcrescences ( )
extern

Delete all Excresences from the Parasite Drag Tool

AddExcrescence( "Miscellaneous", EXCRESCENCE_COUNT, 8.5 );
AddExcrescence( "Cowl Boattail", EXCRESCENCE_CD, 0.0003 );
AddExcrescence( "Percentage Example", EXCRESCENCE_PERCENT_GEOM, 5 );
if ( GetNumExcrescences() != 0 )
{
Print( "ERROR: DeleteAllExcrescences left excrescences behind" );
__failure++;
}
// Clearing an empty table is not an error.
if ( GetNumTotalErrors() != 0 )
{
Print( "ERROR: DeleteAllExcrescences complained about an empty table" );
__failure++;
}
@ EXCRESCENCE_PERCENT_GEOM
Definition APIDefines.h:550
int GetNumExcrescences()
void DeleteAllExcrescences()
See also
AddExcrescence, DeleteExcrescence, GetNumExcrescences

◆ ExportParasiteDragToCSV()

std::string vsp::ExportParasiteDragToCSV ( const std::string & file_name)
extern

Write the Parasite Drag Tool buildup table out to a CSV file, the way the Export CSV button on the tool does. The same table is also placed in the Results Manager under the name "Parasite_Drag", so the returned ID gives access to it without going through the file.

string pod_id = AddGeom( "POD", "" );
// The table is filled in by running the buildup, so do that first.
ExecAnalysis( "ParasiteDrag" );
string res_id = ExportParasiteDragToCSV( "ParasiteDragExample.csv" );
if ( res_id.length() == 0 )
{
Print( "ERROR: ExportParasiteDragToCSV returned no results" );
__failure++;
}
// The buildup carries one row per Geom, so the Pod has to be in there.
array< string > @labels = GetStringResults( res_id, "Comp_Label" );
if ( labels.size() == 0 )
{
Print( "ERROR: the buildup table is empty" );
__failure++;
}
std::string ExecAnalysis(const std::string &analysis)
std::string AddGeom(const std::string &type, const std::string &parent=std::string())
std::string ExportParasiteDragToCSV(const std::string &file_name)
const std::vector< std::string > & GetStringResults(const std::string &id, const std::string &name, int index=0)
void Update(bool update_managers=true)
See also
UpdateParasiteDrag
Parameters
[in]file_namestring Name of the CSV file to write
Returns
string Results ID for the buildup table

◆ GetNumExcrescences()

int vsp::GetNumExcrescences ( )
extern

Delete an Excresence from the Parasite Drag Tool

AddExcrescence( "Miscellaneous", EXCRESCENCE_COUNT, 8.5 );
AddExcrescence( "Cowl Boattail", EXCRESCENCE_CD, 0.0003 );
AddExcrescence( "Percentage Example", EXCRESCENCE_PERCENT_GEOM, 5 );
DeleteExcrescence( 2 ); // Last Index
// Three were added and one was deleted, so index 2 no longer exists and
// asking for it again has to be rejected.
DeleteExcrescence( 2 );
if ( GetNumTotalErrors() == 0 )
{
Print( "ERROR: DeleteExcrescence accepted an index past the end" );
__failure++;
}
// That error was raised deliberately, so take it back off the queue.
while ( GetNumTotalErrors() > 0 )
{
ErrorObj err = PopLastError();
}
Parameters
[in]indexint Index of the Excressence to delete

Get the number of Excresences in the Parasite Drag Tool

if ( GetNumExcrescences() != 0 )
{
Print( "ERROR: a new model starts with excrescences" );
__failure++;
}
AddExcrescence( "Miscellaneous", EXCRESCENCE_COUNT, 8.5 );
AddExcrescence( "Cowl Boattail", EXCRESCENCE_CD, 0.0003 );
if ( GetNumExcrescences() != 2 )
{
Print( "ERROR: GetNumExcrescences did not count what was added" );
__failure++;
}
DeleteExcrescence( 1 );
if ( GetNumExcrescences() != 1 )
{
Print( "ERROR: GetNumExcrescences did not follow DeleteExcrescence" );
__failure++;
}
See also
AddExcrescence, DeleteExcrescence, DeleteAllExcrescences
Returns
int Number of excrescences

◆ UpdateParasiteDrag()

void vsp::UpdateParasiteDrag ( )
extern

Update any reference geometry, atmospheric properties, excressences, etc. in the Parasite Drag Tool

◆ WriteAtmosphereCSVFile()

void vsp::WriteAtmosphereCSVFile ( const std::string & file_name,
const int & atmos_type )
extern

Calculate the atmospheric properties determined by a specified model for a preset array of altitudes ranging from 0 to 90000 m and write the results to a CSV output file

Print( "Starting USAF Atmosphere 1966 Table Creation. \n" );
WriteAtmosphereCSVFile( "USAFAtmosphere1966Data.csv", ATMOS_TYPE_HERRINGTON_1966 );
// The call above should have produced a file with content in it.
file __f;
if ( __f.open( "USAFAtmosphere1966Data.csv", "r" ) < 0 )
{
Print( "ERROR: WriteAtmosphereCSVFile wrote no file" );
__failure++;
}
else
{
if ( __f.getSize() <= 0 )
{
Print( "ERROR: WriteAtmosphereCSVFile wrote an empty file" );
__failure++;
}
__f.close();
}
@ ATMOS_TYPE_HERRINGTON_1966
Definition APIDefines.h:70
void WriteAtmosphereCSVFile(const std::string &file_name, const int &atmos_type)
See also
ATMOS_TYPE
Parameters
[in]file_namestring Output CSV file
[in]atmos_typeint Atmospheric model enum (i.e. ATMOS_TYPE_HERRINGTON_1966)

◆ WriteBodyFFCSVFile()

void vsp::WriteBodyFFCSVFile ( const std::string & file_name)
extern

Calculate the form factor from each body FF equation (i.e. Hoerner Streamlined Body) and write the results to a CSV output file

Print( "Starting Body Form Factor Data Creation. \n" );
WriteBodyFFCSVFile( "BodyFormFactorData.csv" );
// The call above should have produced a file with content in it.
file __f;
if ( __f.open( "BodyFormFactorData.csv", "r" ) < 0 )
{
Print( "ERROR: WriteBodyFFCSVFile wrote no file" );
__failure++;
}
else
{
if ( __f.getSize() <= 0 )
{
Print( "ERROR: WriteBodyFFCSVFile wrote an empty file" );
__failure++;
}
__f.close();
}
void WriteBodyFFCSVFile(const std::string &file_name)
Parameters
[in]file_namestring Output CSV file

◆ WriteCfEqnCSVFile()

void vsp::WriteCfEqnCSVFile ( const std::string & file_name)
extern

Calculate the coefficient of friction from each Cf equation (i.e. Power Law Blasius) and write the results to a CSV output file

Print( "Starting Turbulent Friciton Coefficient Data Creation. \n" );
WriteCfEqnCSVFile( "FrictionCoefficientData.csv" );
// The call above should have produced a file with content in it.
file __f;
if ( __f.open( "FrictionCoefficientData.csv", "r" ) < 0 )
{
Print( "ERROR: WriteCfEqnCSVFile wrote no file" );
__failure++;
}
else
{
if ( __f.getSize() <= 0 )
{
Print( "ERROR: WriteCfEqnCSVFile wrote an empty file" );
__failure++;
}
__f.close();
}
void WriteCfEqnCSVFile(const std::string &file_name)
Parameters
[in]file_namestring Output CSV file

◆ WritePartialCfMethodCSVFile()

void vsp::WritePartialCfMethodCSVFile ( const std::string & file_name)
extern

Calculate the partial coefficient of friction and write the results to a CSV output file

Print( "Starting Partial Friction Method Data Creation. \n" );
WritePartialCfMethodCSVFile( "PartialFrictionMethodData.csv" );
// The call above should have produced a file with content in it.
file __f;
if ( __f.open( "PartialFrictionMethodData.csv", "r" ) < 0 )
{
Print( "ERROR: WritePartialCfMethodCSVFile wrote no file" );
__failure++;
}
else
{
if ( __f.getSize() <= 0 )
{
Print( "ERROR: WritePartialCfMethodCSVFile wrote an empty file" );
__failure++;
}
__f.close();
}
void WritePartialCfMethodCSVFile(const std::string &file_name)
Parameters
[in]file_namestring Output CSV file

◆ WriteWingFFCSVFile()

void vsp::WriteWingFFCSVFile ( const std::string & file_name)
extern

Calculate the form factor from each wing FF equation (i.e. Schemensky 4 Series Airfoil) and write the results to a CSV output file

Print( "Starting Wing Form Factor Data Creation. \n" );
WriteWingFFCSVFile( "WingFormFactorData.csv" );
// The call above should have produced a file with content in it.
file __f;
if ( __f.open( "WingFormFactorData.csv", "r" ) < 0 )
{
Print( "ERROR: WriteWingFFCSVFile wrote no file" );
__failure++;
}
else
{
if ( __f.getSize() <= 0 )
{
Print( "ERROR: WriteWingFFCSVFile wrote an empty file" );
__failure++;
}
__f.close();
}
void WriteWingFFCSVFile(const std::string &file_name)
Parameters
[in]file_namestring Output CSV file