Skip to content

Conversation

@joshkellyjak
Copy link
Contributor

Proposed Changes

Implemented updated turboperformance methods and adds improved history ouput of turboperformance variables to match screen output

Related Work

Follows on from removal of legacy output - #2003

Implements improved turboperformance calculations used in feature_turbomachinery_restruct_singlezone - #1316

PR Checklist

  • I am submitting my contribution to the develop branch.
  • My contribution generates no new compiler warnings (try with --warnlevel=3 when using meson).
  • My contribution is commented and consistent with SU2 style (https://su2code.github.io/docs_v7/Style-Guide/).
  • I used the pre-commit hook to prevent dirty commits and used pre-commit run --all to format old commits.
  • I have added a test case that demonstrates my contribution, if necessary.
  • I have updated appropriate documentation (Tutorials, Docs Page, config_template.cpp), if necessary.

@pr-triage pr-triage bot added the PR: draft label Apr 14, 2023
@joshkellyjak joshkellyjak changed the title [WIP] New turbo ouputs New turbo ouputs Apr 14, 2023
@pcarruscag pcarruscag changed the title New turbo ouputs [WIP] New turbo ouputs Apr 14, 2023
Copy link
Contributor

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeQL found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.

Copy link
Member

@pcarruscag pcarruscag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good, just trying to trim down the interface if possible

Comment on lines 623 to 868
void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptr<CTurboOutput> TurboPerf, CGeometry *geometry, CConfig **config, unsigned short val_iZone) {

string inMarker_Tag, outMarker_Tag, inMarkerTag_Mix;
unsigned short nZone = config[val_iZone]->GetnZone();

unsigned short iDim, iSpan;

unsigned long iExtIter = config[val_iZone]->GetOuterIter();
const su2double* SpanWiseValuesIn, *SpanWiseValuesOut;
ofstream file;
string spanwise_performance_filename;

if (rank != MASTER_NODE){
return;
}

auto BladePerformance = TurboPerf->GetBladesPerformances();

/*--- Start of write file turboperformance spanwise ---*/
SpanWiseValuesIn = geometry->GetSpanWiseValue(INFLOW);
SpanWiseValuesOut = geometry->GetSpanWiseValue(OUTFLOW);

/*--- Writing Span wise inflow thermodynamic quantities. ---*/
spanwise_performance_filename = "TURBOMACHINERY/inflow_spanwise_thermodynamic_values.dat";
char buffer[50];
if (nZone > 1){
unsigned short lastindex = spanwise_performance_filename.find_last_of(".");
spanwise_performance_filename = spanwise_performance_filename.substr(0, lastindex);
SPRINTF (buffer, "_%d.dat", SU2_TYPE::Int(val_iZone));
spanwise_performance_filename.append(string(buffer));
}


file.open (spanwise_performance_filename.data(), ios::out | ios::trunc);
file.setf(ios::scientific);
file.precision(12);

file << "TITLE = \"Inflow Spanwise Thermodynamic Values. iOuterIter = " << iExtIter << " \"" << endl;
file << "VARIABLES =" << endl;

file.width(30); file << "\"SpanWise Value[m]\"";
file.width(15); file << "\"iSpan\"";
file.width(30); file << "\"Pressure[Pa]\"";
file.width(30); file << "\"TotalPressure[Pa]\"";
file.width(30); file << "\"Temperature[K]\"";
file.width(30); file << "\"TotalTemperature[K]\"";
file.width(30); file << "\"Enthalpy[J]\"";
file.width(30); file << "\"TotalEnthalpy[J]\"";
file.width(30); file << "\"Density[kg/m3]\"";
file.width(30); file << "\"Entropy[J/K]\"";
file << endl;

for(iSpan = 0; iSpan < config[val_iZone]->GetnSpanWiseSections(); iSpan++){
const auto& BladePerf = BladePerformance.at(val_iZone).at(iSpan);

file.width(30); file << SpanWiseValuesIn[iSpan];
file.width(15); file << iSpan;
file.width(30); file << BladePerf->GetInletState().GetPressure()*config[ZONE_0]->GetPressure_Ref();
file.width(30); file << BladePerf->GetInletState().GetTotalPressure()*config[ZONE_0]->GetPressure_Ref();
file.width(30); file << BladePerf->GetInletState().GetTemperature()*config[ZONE_0]->GetTemperature_Ref();
file.width(30); file << BladePerf->GetInletState().GetTotalTemperature()*config[ZONE_0]->GetTemperature_Ref();
file.width(30); file << BladePerf->GetInletState().GetEnthalpy()*config[ZONE_0]->GetEnergy_Ref();
file.width(30); file << BladePerf->GetInletState().GetTotalEnthalpy()*config[ZONE_0]->GetEnergy_Ref();
file.width(30); file << BladePerf->GetInletState().GetDensity()*config[ZONE_0]->GetDensity_Ref();
file.width(30); file << BladePerf->GetInletState().GetEntropy()*config[ZONE_0]->GetEnergy_Ref()/config[ZONE_0]->GetTemperature_Ref();
}

file.close();

/*--- Writing Span wise outflow thermodynamic quantities. ---*/
spanwise_performance_filename = "TURBOMACHINERY/outflow_spanwise_thermodynamic_values.dat";
if (nZone > 1){
unsigned short lastindex = spanwise_performance_filename.find_last_of(".");
spanwise_performance_filename = spanwise_performance_filename.substr(0, lastindex);
SPRINTF (buffer, "_%d.dat", SU2_TYPE::Int(val_iZone));
spanwise_performance_filename.append(string(buffer));
}

file.open (spanwise_performance_filename.data(), ios::out | ios::trunc);
file.setf(ios::scientific);
file.precision(12);

file << "TITLE = \"Outflow Span-wise Thermodynamic Values. iOuterIter = " << iExtIter << " \"" << endl;
file << "VARIABLES =" << endl;

file.width(30); file << "\"SpanWise Value[m]\"";
file.width(15); file << "\"iSpan\"";
file.width(30); file << "\"Pressure[Pa]\"";
file.width(30); file << "\"TotalPressure[Pa]\"";
file.width(30); file << "\"Temperature[K]\"";
file.width(30); file << "\"TotalTemperature[K]\"";
file.width(30); file << "\"Enthalpy[J]\"";
file.width(30); file << "\"TotalEnthalpy[J]\"";
file.width(30); file << "\"Density[kg/m3]\"";
file.width(30); file << "\"Entropy[J/K]\"";
file << endl;


for(iSpan = 0; iSpan < config[val_iZone]->GetnSpanWiseSections(); iSpan++){
const auto& BladePerf = BladePerformance.at(val_iZone).at(iSpan);

file.width(30); file << SpanWiseValuesOut[iSpan];
file.width(15); file << iSpan;
file.width(30); file << BladePerf->GetOutletState().GetPressure()*config[ZONE_0]->GetPressure_Ref();
file.width(30); file << BladePerf->GetOutletState().GetTotalPressure()*config[ZONE_0]->GetPressure_Ref();
file.width(30); file << BladePerf->GetOutletState().GetTemperature()*config[ZONE_0]->GetTemperature_Ref();
file.width(30); file << BladePerf->GetOutletState().GetTotalTemperature()*config[ZONE_0]->GetTemperature_Ref();
file.width(30); file << BladePerf->GetOutletState().GetEnthalpy()*config[ZONE_0]->GetEnergy_Ref();
file.width(30); file << BladePerf->GetOutletState().GetTotalEnthalpy()*config[ZONE_0]->GetEnergy_Ref();
file.width(30); file << BladePerf->GetOutletState().GetDensity()*config[ZONE_0]->GetDensity_Ref();
file.width(30); file << BladePerf->GetOutletState().GetEntropy()*config[ZONE_0]->GetEnergy_Ref()/config[ZONE_0]->GetTemperature_Ref();
}

file.close();

/*--- Writing Span wise inflow kinematic quantities. ---*/
spanwise_performance_filename = "TURBOMACHINERY/inflow_spanwise_kinematic_values.dat";
if (nZone > 1){
unsigned short lastindex = spanwise_performance_filename.find_last_of(".");
spanwise_performance_filename = spanwise_performance_filename.substr(0, lastindex);
SPRINTF (buffer, "_%d.dat", SU2_TYPE::Int(val_iZone));
spanwise_performance_filename.append(string(buffer));
}

file.open (spanwise_performance_filename.data(), ios::out | ios::trunc);
file.setf(ios::scientific);
file.precision(12);

file << "TITLE = \"Inflow Span-wise Kinematic Values. iOuterIter = " << iExtIter << " \"" << endl;
file << "VARIABLES =" << endl;

file.width(30); file << "\"SpanWise Value[m]\"";
file.width(15); file << "\"iSpan\"";
file.width(30); file << "\"Normal Mach[-]\"";
file.width(30); file << "\"Tangential Mach[-]\"";
if (geometry->GetnDim() == 3) {
file.width(30); file << "\"3rd Component Mach[-]\"";
};
file.width(30); file << "\"Mach Module[-]\"";
file.width(30); file << "\"Normal Velocity[m/s]\"";
file.width(30); file << "\"Tangential Velocity[m/s]\"";
if (geometry->GetnDim() == 3) {
file.width(30); file << "\"3rd Component Velocity[m/s]\"";
};
file.width(30); file << "\"Velocity Module[m/s]\"";
file.width(30); file << "\"Absolute Flow Angle[deg]\"";
file.width(30); file << "\"Relative Flow Angle[deg]\"";
file << endl;


for(iSpan = 0; iSpan < config[val_iZone]->GetnSpanWiseSections(); iSpan++){
const auto& BladePerf = BladePerformance.at(val_iZone).at(iSpan);

file.width(30); file << SpanWiseValuesIn[iSpan];
file.width(15); file << iSpan;
for (iDim = 0; iDim < geometry->GetnDim(); iDim++){
file.width(30); file << BladePerf->GetInletState().GetMach()[iDim];
}
file.width(30); file << BladePerf->GetInletState().GetMachValue();
for (iDim = 0; iDim < geometry->GetnDim(); iDim++){
file.width(30); file << BladePerf->GetInletState().GetVelocity()[iDim]*config[ZONE_0]->GetVelocity_Ref();
}
file.width(30); file << BladePerf->GetInletState().GetVelocityValue()*config[ZONE_0]->GetVelocity_Ref();
// This captures NaNs
if(isnan(BladePerf->GetInletState().GetAbsFlowAngle())){
file.width(30); file << "0.0000";
}
else {
file.width(30); file << BladePerf->GetInletState().GetAbsFlowAngle()*180.0/PI_NUMBER;
}
if(isnan(BladePerf->GetInletState().GetFlowAngle())){
file.width(30); file << "0.0000";
}
else{
file.width(30); file << BladePerf->GetInletState().GetFlowAngle()*180.0/PI_NUMBER;
}
file << endl;
}

file.close();

/*--- Writing Span wise outflow thermodynamic quantities. ---*/
spanwise_performance_filename = "TURBOMACHINERY/outflow_spanwise_kinematic_values.dat";
if (nZone > 1){
unsigned short lastindex = spanwise_performance_filename.find_last_of(".");
spanwise_performance_filename = spanwise_performance_filename.substr(0, lastindex);
SPRINTF (buffer, "_%d.dat", SU2_TYPE::Int(val_iZone));
spanwise_performance_filename.append(string(buffer));
}

file.open (spanwise_performance_filename.data(), ios::out | ios::trunc);
file.setf(ios::scientific);
file.precision(12);

file << "TITLE = \"Outflow Span-wise Kinematic Values. iOuterIter = " << iExtIter << " \"" << endl;
file << "VARIABLES =" << endl;

file.width(30); file << "\"SpanWise Value[m]\"";
file.width(15); file << "\"iSpan\"";
file.width(30); file << "\"Normal Mach[-]\"";
file.width(30); file << "\"Tangential Mach[-]\"";
if (geometry->GetnDim() == 3) {
file.width(30); file << "\"3rd Component Mach[-]\"";
};
file.width(30); file << "\"Mach Module[-]\"";
file.width(30); file << "\"Normal Velocity[m/s]\"";
file.width(30); file << "\"Tangential Velocity[m/s]\"";
if (geometry->GetnDim() == 3) {
file.width(30); file << "\"3rd Component Velocity[m/s]\"";
};
file.width(30); file << "\"Velocity Module[m/s]\"";
file.width(30); file << "\"Absolute Flow Angle[deg]\"";
file.width(30); file << "\"Relative Flow Angle[deg]\"";
file << endl;


for(iSpan = 0; iSpan < config[val_iZone]->GetnSpanWiseSections(); iSpan++){
const auto& BladePerf = BladePerformance.at(val_iZone).at(iSpan);

file.width(30); file << SpanWiseValuesOut[iSpan];
file.width(15); file << iSpan;
for (iDim = 0; iDim < geometry->GetnDim(); iDim++){
file.width(30); file << BladePerf->GetOutletState().GetMach()[iDim];
}
file.width(30); file << BladePerf->GetInletState().GetMachValue();
for (iDim = 0; iDim < geometry->GetnDim(); iDim++){
file.width(30); file << BladePerf->GetOutletState().GetVelocity()[iDim]*config[ZONE_0]->GetVelocity_Ref();
}
file.width(30); file << BladePerf->GetInletState().GetVelocityValue()*config[ZONE_0]->GetVelocity_Ref();
if(isnan(BladePerf->GetInletState().GetAbsFlowAngle())){
file.width(30); file << "0.0000";
}
else {
file.width(30); file << BladePerf->GetOutletState().GetAbsFlowAngle()*180.0/PI_NUMBER;
}
if(isnan(BladePerf->GetInletState().GetAbsFlowAngle())){
file.width(30); file << "0.0000";
}
else{
file.width(30); file << BladePerf->GetOutletState().GetFlowAngle()*180.0/PI_NUMBER;
}
file << endl;
}

file.close();
}

Check notice

Code scanning / CodeQL

Block with too many statements

Block with too many statements (4 complex statements in the block).
@joshkellyjak joshkellyjak merged commit e554994 into develop Feb 7, 2024
@joshkellyjak joshkellyjak deleted the new_turbo_outputs branch February 7, 2024 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants