Skip to content

Commit

Permalink
Added extra turbo ramp options, generalised function
Browse files Browse the repository at this point in the history
  • Loading branch information
joshkellyjak committed Jan 13, 2025
1 parent 77a5b14 commit 2b74501
Show file tree
Hide file tree
Showing 7 changed files with 205 additions and 75 deletions.
54 changes: 54 additions & 0 deletions Common/include/CConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1068,11 +1068,16 @@ class CConfig {
bool turbMixingPlane; /*!< \brief option for turbulent mixingplane */
bool SpatialFourier; /*!< \brief option for computing the fourier transforms for subsonic non-reflecting BC. */
bool RampRotatingFrame; /*!< \brief option for ramping up or down the Rotating Frame values */
bool RampTranslationFrame; /*!< \brief option for ramping up or down the Translation Frame values */
bool RampOutletPressure; /*!< \brief option for ramping up or down the outlet pressure */
bool RampOutletMassFlow; /*!< \brief option for ramping up or down the mass flow rate*/
su2double AverageMachLimit; /*!< \brief option for turbulent mixingplane */
su2double FinalRotation_Rate_Z; /*!< \brief Final rotation rate Z if Ramp rotating frame is activated. */
su2double FinalTranslation_Rate_Y; /*!< \brief Final translation rate Y if Ramp translation frame is activated. */
su2double FinalOutletPressure; /*!< \brief Final outlet pressure if Ramp outlet pressure is activated. */
su2double FinalOutletMassFlow; /*!< \brief Final outlet mass flow rate if Ramp outlet mass flow rate is activated */
su2double MonitorOutletPressure; /*!< \brief Monitor outlet pressure if Ramp outlet pressure is activated. */
su2double MonitorOutletMassFlow; /*!< \brief Monitor outlet mass flow rate if ramp outlet mass flow rate is activated. */
array<su2double, N_POLY_COEFFS> cp_polycoeffs{{0.0}}; /*!< \brief Array for specific heat polynomial coefficients. */
array<su2double, N_POLY_COEFFS> mu_polycoeffs{{0.0}}; /*!< \brief Array for viscosity polynomial coefficients. */
array<su2double, N_POLY_COEFFS> kt_polycoeffs{{0.0}}; /*!< \brief Array for thermal conductivity polynomial coefficients. */
Expand Down Expand Up @@ -1122,7 +1127,9 @@ class CConfig {
ffd_coeff[3], /*!< \brief artificial dissipation (flow) array for the COption class. */
mixedout_coeff[3], /*!< \brief default mixedout algorithm coefficients for the COption class. */
rampRotFrame_coeff[3], /*!< \brief ramp rotating frame coefficients for the COption class. */
rampTransFrame_coeff[3],/*!< \brief ramp translating frame coefficients for the COption class. */
rampOutPres_coeff[3], /*!< \brief ramp outlet pressure coefficients for the COption class. */
rampOutMassFlow_coeff[3], /*< \brief ramp outlet mass flow coefficients for the COption class. */
jst_adj_coeff[2], /*!< \brief artificial dissipation (adjoint) array for the COption class. */
mesh_box_length[3], /*!< \brief mesh box length for the COption class. */
mesh_box_offset[3], /*!< \brief mesh box offset for the COption class. */
Expand Down Expand Up @@ -5169,6 +5176,18 @@ class CConfig {
*/
bool GetRampRotatingFrame(void) const { return RampRotatingFrame;}

/*!
* \brief Get coeff for Rotating Frame Ramp.
* \return coeff Ramp Rotating Frame.
*/
su2double GetRampTranslationFrame_Coeff(unsigned short iCoeff) const { return rampTransFrame_coeff[iCoeff];}

/*!
* \brief Get Rotating Frame Ramp option.
* \return Ramp Rotating Frame option.
*/
bool GetRampTranslationFrame(void) const { return RampTranslationFrame;}

/*!
* \brief Get coeff for Outlet Pressure Ramp.
* \return coeff Ramp Outlet Pressure.
Expand Down Expand Up @@ -5198,6 +5217,35 @@ class CConfig {
*/
bool GetRampOutletPressure(void) const { return RampOutletPressure;}

/*!
* \brief Get Outlet Mass Flow Ramp option.
* \return Ramp Outlet Mass flow rate option.
*/
bool GetRampOutletMassFlow(void) const { return RampOutletMassFlow;}

/*!
* \brief Get coeff for Outlet Mass flow rate Ramp.
* \return coeff Ramp Outlet Mass flow rate.
*/
su2double GetRampOutletMassFlow_Coeff(unsigned short iCoeff) const { return rampOutMassFlow_coeff[iCoeff];}

/*!
* \brief Get final Outlet Mass flow rate value for the ramp.
* \return final Outlet Mass flow rate value.
*/
su2double GetFinalOutletMassFlow(void) const { return FinalOutletMassFlow; }

/*!
* \brief Get final Outlet Mass flow rate value for the ramp.
* \return Monitor Outlet Mass flow value.
*/
su2double GetMonitorOutletMassFlow(void) const { return MonitorOutletMassFlow; }

/*!
* \brief Set Monitor Outlet Mass flow rate value for the ramp.
*/
void SetMonitorOutletMassFlow(su2double newMonMassFlow) { MonitorOutletMassFlow= newMonMassFlow;}

/*!
* \brief Get mixedout coefficients.
* \return mixedout coefficient.
Expand Down Expand Up @@ -6073,6 +6121,12 @@ class CConfig {
MarkerRotation_Rate[3 * iMarkerMoving + iDim] = val;
}

/*!
* \brief Get the final translation velocity of the mesh in the y-direction
* \return Velocity of the mesh in the y-direction
*/
su2double GetFinalTranslation_Rate_Y() const { return FinalTranslation_Rate_Y;}

/*!
* \brief Get the pitching rate of the mesh.
* \param[in] iDim - spatial component
Expand Down
5 changes: 5 additions & 0 deletions Common/include/option_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1886,6 +1886,11 @@ enum TURBO_MARKER_TYPE{
OUTFLOW = 2 /*!< \brief flag for outflow marker for compute turboperformance. */
};

enum TURBO_RAMP_TYPE{
GRID = 1, /*!< \brief flag for rotational/translational ramps */
BOUNDARY = 2 /*!< \brief flag for pressure/mass flow ramps*/
};

/*!
* \brief Types inlet boundary treatments
*/
Expand Down
28 changes: 28 additions & 0 deletions Common/src/CConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1627,6 +1627,12 @@ void CConfig::SetConfig_Options() {
/*!\brief RAMP_ROTATING_FRAME_COEFF \n DESCRIPTION: the 1st coeff is the staring velocity,
* the 2nd coeff is the number of iterations for the update, 3rd is the number of iteration */
addDoubleArrayOption("RAMP_ROTATING_FRAME_COEFF", 3, rampRotFrame_coeff);
/*!\brief RAMP_TRANSLATION_FRAME\n DESCRIPTION: option to ramp up or down the translating frame velocity value*/
addBoolOption("RAMP_TRANSLATION_FRAME", RampTranslationFrame, false);
rampTransFrame_coeff[0] = 0; rampTransFrame_coeff[1] = 1.0; rampTransFrame_coeff[2] = 1000.0;
/*!\brief RAMP_TRANSLATION_FRAME\n DESCRIPTION: the 1st coeff is the staring velocity,
* the 2nd coeff is the number of iterations for the update, 3rd is the number of iteration */
addDoubleArrayOption("RAMP_TRANSLATION_FRAME_COEFF", 3, rampTransFrame_coeff);
/* DESCRIPTION: AVERAGE_MACH_LIMIT is a limit value for average procedure based on the mass flux. */
addDoubleOption("AVERAGE_MACH_LIMIT", AverageMachLimit, 0.03);
/*!\brief RAMP_OUTLET_PRESSURE\n DESCRIPTION: option to ramp up or down the rotating frame velocity value*/
Expand All @@ -1635,6 +1641,12 @@ void CConfig::SetConfig_Options() {
/*!\brief RAMP_OUTLET_PRESSURE_COEFF \n DESCRIPTION: the 1st coeff is the staring outlet pressure,
* the 2nd coeff is the number of iterations for the update, 3rd is the number of total iteration till reaching the final outlet pressure value */
addDoubleArrayOption("RAMP_OUTLET_PRESSURE_COEFF", 3, rampOutPres_coeff);
/*!\brief RAMP_OUTLET_MASS_FLOW\n DESCRIPTION: option to ramp up or down the outlet mass flow rate value*/
addBoolOption("RAMP_OUTLET_MASS_FLOW", RampOutletMassFlow, false);
rampOutMassFlow_coeff[0] = 1.0; rampOutMassFlow_coeff[1] = 1.0; rampOutPres_coeff[2] = 1000.0;
/*!\brief RAMP_OUTLET_MASS_FLOW_COEFF \n DESCRIPTION: the 1st coeff is the staring mass flow rate,
* the 2nd coeff is the number of iterations for the update, 3rd is the number of total iteration till reaching the final outlet mass flow rate value */
addDoubleArrayOption("RAMP_OUTLET_MASS_FLOW_COEFF", 3, rampOutMassFlow_coeff);
/*!\brief MARKER_MIXINGPLANE \n DESCRIPTION: Identify the boundaries in which the mixing plane is applied. \ingroup Config*/
addStringListOption("MARKER_MIXINGPLANE_INTERFACE", nMarker_MixingPlaneInterface, Marker_MixingPlaneInterface);
/*!\brief TURBULENT_MIXINGPLANE \n DESCRIPTION: Activate mixing plane also for turbulent quantities \ingroup Config*/
Expand Down Expand Up @@ -4363,6 +4375,13 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
}
}

if(GetGrid_Movement() && RampTranslationFrame && !DiscreteAdjoint){
FinalTranslation_Rate_Y = Translation_Rate[1];
if(abs(FinalTranslation_Rate_Y) > 0.0){
Translation_Rate[1] = rampTransFrame_coeff[0];
}
}

if(RampOutletPressure && !DiscreteAdjoint){
for (iMarker = 0; iMarker < nMarker_Giles; iMarker++){
if (Kind_Data_Giles[iMarker] == STATIC_PRESSURE || Kind_Data_Giles[iMarker] == STATIC_PRESSURE_1D || Kind_Data_Giles[iMarker] == RADIAL_EQUILIBRIUM ){
Expand All @@ -4378,6 +4397,15 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
}
}

if(RampOutletMassFlow && !DiscreteAdjoint){
for (iMarker = 0; iMarker < nMarker_Giles; iMarker++){
if (Kind_Data_Giles[iMarker] == MASS_FLOW_OUTLET){
FinalOutletMassFlow = Giles_Var1[iMarker];
Giles_Var1[iMarker] = rampOutMassFlow_coeff[0];
}
}
}

/*--- Check on extra Relaxation factor for Giles---*/
if(extrarelfac[1] > 0.5){
extrarelfac[1] = 0.5;
Expand Down
5 changes: 3 additions & 2 deletions SU2_CFD/include/iteration/CFluidIteration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,14 @@ class CFluidIteration : public CIteration {
unsigned short val_iInst) override;

/*!
* \brief Monitors turbo computation (pressure and turbo ramps).
* \brief Monitors turbo computation ramps
* \param[in] geometry_container - Geometrical definition of the problem
* \param[in] config_container - Defintion of the particular problem
* \param[in] ExtIter - The current iteration of the problem
* \param[in] iZone - The current zone
* \param[in] ramp_flag - Flag indicating type of ramp (grid or boundary)
*/
void TurboMonitor(CGeometry**** geometry_container, CConfig** config_container, unsigned long ExtIter, unsigned short iZone);
virtual void TurboRamp(CGeometry**** geometry_container, CConfig** config_container, unsigned long iter, unsigned short iZone, unsigned short ramp_flag) {};

/*!
* \brief Computes turboperformance.
Expand Down
10 changes: 10 additions & 0 deletions SU2_CFD/include/iteration/CTurboIteration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,14 @@ class CTurboIteration : public CFluidIteration {
* \brief Initialises turboperformance classes.
*/
void InitTurboPerformance(CGeometry *geometry, CConfig** config, CFluidModel *fluid);

/*!
* \brief Monitors turbo computation ramps
* \param[in] geometry_container - Geometrical definition of the problem
* \param[in] config_container - Defintion of the particular problem
* \param[in] ExtIter - The current iteration of the problem
* \param[in] iZone - The current zone
* \param[in] ramp_flag - Flag indicating type of ramp (grid or boundary)
*/
void TurboRamp(CGeometry**** geometry_container, CConfig** config_container, unsigned long iter, unsigned short iZone, unsigned short ramp_flag) override;
};
76 changes: 3 additions & 73 deletions SU2_CFD/src/iteration/CFluidIteration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,9 @@ bool CFluidIteration::Monitor(COutput* output, CIntegration**** integration, CGe
config, TurbomachineryStagePerformance, TurbomachineryPerformance, val_iZone, config[val_iZone]->GetTimeIter(), config[val_iZone]->GetOuterIter(),
config[val_iZone]->GetInnerIter(), val_iInst);
}

TurboMonitor(geometry, config, config[val_iZone]->GetInnerIter(), val_iZone);
/*--- Update ramps, grid first then outlet boundary ---*/
TurboRamp(geometry, config, config[val_iZone]->GetInnerIter(), val_iZone, TURBO_RAMP_TYPE::GRID);
TurboRamp(geometry, config, config[val_iZone]->GetInnerIter(), val_iZone, TURBO_RAMP_TYPE::BOUNDARY);
}
output->SetHistoryOutput(geometry[val_iZone][val_iInst][MESH_0], solver[val_iZone][val_iInst][MESH_0],
config[val_iZone], config[val_iZone]->GetTimeIter(), config[val_iZone]->GetOuterIter(),
Expand All @@ -251,77 +252,6 @@ bool CFluidIteration::Monitor(COutput* output, CIntegration**** integration, CGe
return StopCalc;
}

void CFluidIteration::TurboMonitor(CGeometry**** geometry_container, CConfig** config_container, unsigned long iter, unsigned short iZone) {
auto* config = config_container[iZone];

if (config_container[ZONE_0]->GetMultizone_Problem())
iter = config_container[ZONE_0]->GetOuterIter();
/*--- ROTATING FRAME Ramp: Compute the updated rotational velocity. ---*/
if (config->GetGrid_Movement() && config->GetRampRotatingFrame()) {
const unsigned long rampFreq = SU2_TYPE::Int(config->GetRampRotatingFrame_Coeff(1));
const unsigned long finalRamp_Iter = SU2_TYPE::Int(config->GetRampRotatingFrame_Coeff(2));
const su2double rot_z_ini = config->GetRampRotatingFrame_Coeff(0);
const bool print = (config->GetComm_Level() == COMM_FULL);

if(iter % rampFreq == 0 && iter <= finalRamp_Iter){

const su2double rot_z_final = config->GetFinalRotation_Rate_Z();

if (fabs(rot_z_final) > 0.0) {
const su2double rot_z = rot_z_ini + iter * ( rot_z_final - rot_z_ini) / finalRamp_Iter;
config->SetRotation_Rate(2, rot_z);
if (rank == MASTER_NODE && iter > 0) {
cout << "\nUpdated rotating frame grid velocities for zone " << iZone << ".\n";
}
geometry_container[iZone][INST_0][MESH_0]->SetRotationalVelocity(config, print);
geometry_container[iZone][INST_0][MESH_0]->SetShroudVelocity(config);
}

geometry_container[iZone][INST_0][MESH_0]->SetAvgTurboValue(config, iZone, INFLOW, false);
geometry_container[iZone][INST_0][MESH_0]->SetAvgTurboValue(config, iZone, OUTFLOW, false);
geometry_container[iZone][INST_0][MESH_0]->GatherInOutAverageValues(config, false);

if (iZone < nZone - 1) {
geometry_container[nZone-1][INST_0][MESH_0]->SetAvgTurboGeoValues(config ,geometry_container[iZone][INST_0][MESH_0], iZone);
}
}
}

/*--- Outlet Pressure Ramp: Compute the updated pressure. ---*/
if (config->GetRampOutletPressure()) {
const unsigned long rampFreq = SU2_TYPE::Int(config->GetRampOutletPressure_Coeff(1));
const unsigned long finalRamp_Iter = SU2_TYPE::Int(config->GetRampOutletPressure_Coeff(2));
const su2double outPres_ini = config->GetRampOutletPressure_Coeff(0);
const su2double outPres_final = config->GetFinalOutletPressure();

if (iter % rampFreq == 0 && iter <= finalRamp_Iter) {
const su2double outPres = outPres_ini + iter * (outPres_final - outPres_ini) / finalRamp_Iter;
if (rank == MASTER_NODE) config->SetMonitorOutletPressure(outPres);

for (auto iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) {
const auto KindBC = config->GetMarker_All_KindBC(iMarker);
const auto Marker_Tag = config->GetMarker_All_TagBound(iMarker);
unsigned short KindBCOption;
switch (KindBC) {
case RIEMANN_BOUNDARY:
KindBCOption = config->GetKind_Data_Riemann(Marker_Tag);
if (KindBCOption == STATIC_PRESSURE || KindBCOption == RADIAL_EQUILIBRIUM) {
SU2_MPI::Error("Outlet pressure ramp only implemented for NRBC", CURRENT_FUNCTION);
}
break;
case GILES_BOUNDARY:
KindBCOption = config->GetKind_Data_Giles(Marker_Tag);
if (KindBCOption == STATIC_PRESSURE || KindBCOption == STATIC_PRESSURE_1D ||
KindBCOption == RADIAL_EQUILIBRIUM ) {
config->SetGiles_Var1(outPres, Marker_Tag);
}
break;
}
}
}
}
}

void CFluidIteration::ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container, unsigned long ExtIter) {
unsigned short nDim = geometry_container[ZONE_0][INST_0][MESH_0]->GetnDim();
unsigned short nBladesRow = config_container[ZONE_0]->GetnMarker_Turbomachinery();
Expand Down
Loading

0 comments on commit 2b74501

Please sign in to comment.