Skip to content

Commit

Permalink
make MaxCap and MaxCoolCap a default argument, move constant declare
Browse files Browse the repository at this point in the history
move the MaxCap(1e+20) to DataGlobalConstants, to avoid circular inclusion issue
  • Loading branch information
Yujie Xu authored and Yujie Xu committed Jul 1, 2024
1 parent cbaa5d5 commit 0b22d9f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 35 deletions.
24 changes: 6 additions & 18 deletions src/EnergyPlus/DXCoils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -232,21 +232,7 @@ void SimDXCoil(EnergyPlusData &state,
} break;
case HVAC::CoilVRF_FluidTCtrl_Cooling: {
// fixme: this redefines the MaxCap, how should I go about changing it from optional arg to non-optional?
if (present(MaxCap)) {
CalcVRFCoolingCoil_FluidTCtrl(
state, DXCoilNum, HVAC::CompressorOp::On, FirstHVACIteration, PartLoadRatio, fanOp, CompCycRatio, MaxCap, _, _);
} else {
CalcVRFCoolingCoil_FluidTCtrl(state,
DXCoilNum,
HVAC::CompressorOp::On,
FirstHVACIteration,
PartLoadRatio,
fanOp,
CompCycRatio,
HVACVariableRefrigerantFlow::MaxCap,
_,
_);
}
CalcVRFCoolingCoil_FluidTCtrl(state, DXCoilNum, HVAC::CompressorOp::On, FirstHVACIteration, PartLoadRatio, fanOp, CompCycRatio, _, _, MaxCap);
} break;
case HVAC::CoilVRF_FluidTCtrl_Heating: {
CalcVRFHeatingCoil_FluidTCtrl(state, compressorOp, DXCoilNum, PartLoadRatio, fanOp, _, MaxCap);
Expand Down Expand Up @@ -6887,7 +6873,7 @@ void InitDXCoil(EnergyPlusData &state, int const DXCoilNum) // number of the cur
CalcVRFCoolingCoil(state, DXCoilNum, HVAC::CompressorOp::On, false, 1.0, HVAC::FanOp::Cycling, 1.0, _, _, _);
} else if (thisDXCoil.DXCoilType_Num == HVAC::CoilVRF_FluidTCtrl_Cooling) {
CalcVRFCoolingCoil_FluidTCtrl(
state, DXCoilNum, HVAC::CompressorOp::On, false, 1.0, HVAC::FanOp::Cycling, 1.0, HVACVariableRefrigerantFlow::MaxCap, _, _);
state, DXCoilNum, HVAC::CompressorOp::On, false, 1.0, HVAC::FanOp::Cycling, 1.0, _, _, Constant::MaxCap);
}

// coil outlets
Expand Down Expand Up @@ -16525,9 +16511,9 @@ void CalcVRFCoolingCoil_FluidTCtrl(EnergyPlusData &state,
Real64 const PartLoadRatio, // sensible cooling load / full load sensible cooling capacity
HVAC::FanOp const fanOp, // Allows parent object to control fan operation
Real64 const CompCycRatio, // cycling ratio of VRF condenser
Real64 MaxCoolCap, // maximum allowed cooling capacity
ObjexxFCL::Optional_int_const PerfMode, // Performance mode for MultiMode DX coil; Always 1 for other coil types
ObjexxFCL::Optional<Real64 const> OnOffAirFlowRatio // ratio of compressor on airflow to compressor off airflow
ObjexxFCL::Optional<Real64 const> OnOffAirFlowRatio, // ratio of compressor on airflow to compressor off airflow
Real64 MaxCoolCap // maximum allowed cooling capacity
)
{
// SUBROUTINE INFORMATION:
Expand Down Expand Up @@ -17356,6 +17342,8 @@ void ControlVRFIUCoil(EnergyPlusData &state,
Garate = state.dataDXCoils->DXCoil(CoilIndex).RatedAirMassFlowRate(1);
// why always limit the minimum fan speed ratio to 0.65?
FanSpdRatioMin = min(max(OAMassFlow / Garate, 0.65), 1.0); // ensure that coil flow rate is higher than OA flow rate
// yujie: temporary remove this
FanSpdRatioMin = 0.0;

if (QCoil == 0) {
// No Heating or Cooling
Expand Down
6 changes: 3 additions & 3 deletions src/EnergyPlus/DXCoils.hh
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ namespace DXCoils {
ObjexxFCL::Optional<Real64 const> PartLoadRatio = _, // part load ratio (for single speed cycling unit)
ObjexxFCL::Optional<Real64 const> OnOffAFR = _, // ratio of compressor on airflow to compressor off airflow
ObjexxFCL::Optional<Real64 const> CoilCoolingHeatingPLRRatio = _, // used for cycling fan RH control
ObjexxFCL::Optional<Real64 const> MaxCap = _, // maximum cooling capacity of VRF terminal units
ObjexxFCL::Optional<Real64 const> MaxCap = Constant::MaxCap, // maximum cooling capacity of VRF terminal units
ObjexxFCL::Optional<Real64 const> CompCyclingRatio = _ // cycling ratio of VRF condenser connected to this TU
);

Expand Down Expand Up @@ -877,9 +877,9 @@ namespace DXCoils {
Real64 const PartLoadRatio, // sensible cooling load / full load sensible cooling capacity
HVAC::FanOp const fanOp, // Allows parent object to control fan operation
Real64 const CompCycRatio, // cycling ratio of VRF condenser
Real64 MaxCoolCap, // maximum allowed cooling capacity
ObjexxFCL::Optional_int_const PerfMode, // Performance mode for MultiMode DX coil; Always 1 for other coil types
ObjexxFCL::Optional<Real64 const> OnOffAirFlowRatio // ratio of compressor on airflow to compressor off airflow
ObjexxFCL::Optional<Real64 const> OnOffAirFlowRatio, // ratio of compressor on airflow to compressor off airflow
Real64 MaxCoolCap = Constant::MaxCap // maximum allowed cooling capacity
);

void
Expand Down
2 changes: 2 additions & 0 deletions src/EnergyPlus/DataGlobalConstants.hh
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,8 @@ namespace Constant {
Real64 constexpr UniversalGasConst = 8314.462175; // Universal Gas Constant (J/mol*K)
Real64 constexpr convertJtoGJ = 1.0E-9; // Conversion factor for J to GJ

Real64 constexpr MaxCap(1.0e+20); // limit of zone terminal unit capacity

} // namespace Constant

} // namespace EnergyPlus
Expand Down
24 changes: 12 additions & 12 deletions src/EnergyPlus/HVACVariableRefrigerantFlow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1493,8 +1493,8 @@ void GetVRFInputData(EnergyPlusData &state, bool &ErrorsFound)
state.dataHVACVarRefFlow->MaxHeatingCapacity.allocate(state.dataHVACVarRefFlow->NumVRFCond);
state.dataHVACVarRefFlow->CoolCombinationRatio.allocate(state.dataHVACVarRefFlow->NumVRFCond);
state.dataHVACVarRefFlow->HeatCombinationRatio.allocate(state.dataHVACVarRefFlow->NumVRFCond);
state.dataHVACVarRefFlow->MaxCoolingCapacity = MaxCap;
state.dataHVACVarRefFlow->MaxHeatingCapacity = MaxCap;
state.dataHVACVarRefFlow->MaxCoolingCapacity = Constant::MaxCap;
state.dataHVACVarRefFlow->MaxHeatingCapacity = Constant::MaxCap;
state.dataHVACVarRefFlow->CoolCombinationRatio = 1.0;
state.dataHVACVarRefFlow->HeatCombinationRatio = 1.0;
}
Expand Down Expand Up @@ -6608,8 +6608,8 @@ void InitVRF(EnergyPlusData &state, int const VRFTUNum, int const ZoneNum, bool
// terminal unit will be limited to 3-tons (see SimVRFCondenser where this variable is calculated).
if (CurrentEndTime > state.dataHVACVarRefFlow->CurrentEndTimeLast || TimeStepSysLast > state.dataHVACGlobal->TimeStepSys ||
(FirstHVACIteration && state.dataHVACVarRefFlow->MyBeginTimeStepFlag(VRFCond))) {
state.dataHVACVarRefFlow->MaxCoolingCapacity(VRFCond) = MaxCap;
state.dataHVACVarRefFlow->MaxHeatingCapacity(VRFCond) = MaxCap;
state.dataHVACVarRefFlow->MaxCoolingCapacity(VRFCond) = Constant::MaxCap;
state.dataHVACVarRefFlow->MaxHeatingCapacity(VRFCond) = Constant::MaxCap;
state.dataHVACVarRefFlow->MyBeginTimeStepFlag(VRFCond) = false;
}

Expand Down Expand Up @@ -10596,15 +10596,15 @@ void LimitCoilCapacity(int const NumTUInList, // Number of terminal un

// sort TU capacity from lowest to highest
for (TempTUIndex = 1; TempTUIndex <= NumTUInList; ++TempTUIndex) {
MinOutput = MaxCap;
MinOutput = Constant::MaxCap;
for (NumTU = 1; NumTU <= NumTUInList; ++NumTU) {
if (Temp2(NumTU) < MinOutput) {
MinOutput = Temp2(NumTU);
Temp(TempTUIndex) = MinOutput;
MinOutputIndex = NumTU;
}
}
Temp2(MinOutputIndex) = MaxCap;
Temp2(MinOutputIndex) = Constant::MaxCap;
}

// find limit of "terminal unit" capacity so that sum of all TU's does not exceed condenser capacity
Expand Down Expand Up @@ -11784,7 +11784,7 @@ void VRFCondenserEquipment::CalcVRFCondenser_FluidTCtrl(EnergyPlusData &state)

this->CoolingCapacity = 0.0; // Include the piping loss
this->PipingCorrectionCooling = 0.0;
state.dataHVACVarRefFlow->MaxCoolingCapacity(VRFCond) = MaxCap; // for report . yujie: might be wrong here too, should be MaxCap = 1e+20
state.dataHVACVarRefFlow->MaxCoolingCapacity(VRFCond) = Constant::MaxCap; // for report

this->OUCondHeatRate = 0;
this->OUEvapHeatRate = Q_c_OU;
Expand Down Expand Up @@ -12031,13 +12031,13 @@ void VRFCondenserEquipment::CalcVRFCondenser_FluidTCtrl(EnergyPlusData &state)
this->OUFanPower = 0.0;
this->VRFCondCyclingRatio = 0.0;

this->HeatingCapacity = 0.0; // Include the piping loss
this->PipingCorrectionHeating = 1.0; // 1 means no piping loss
state.dataHVACVarRefFlow->MaxHeatingCapacity(VRFCond) = MaxCap; // yujie: default value is MaxCap = 1e+20, not 0
this->HeatingCapacity = 0.0; // Include the piping loss
this->PipingCorrectionHeating = 1.0; // 1 means no piping loss
state.dataHVACVarRefFlow->MaxHeatingCapacity(VRFCond) = Constant::MaxCap; // yujie: default value is MaxCap = 1e+20, not 0

this->CoolingCapacity = 0.0; // Include the piping loss
this->PipingCorrectionCooling = 1.0;
state.dataHVACVarRefFlow->MaxCoolingCapacity(VRFCond) = MaxCap; // for report
state.dataHVACVarRefFlow->MaxCoolingCapacity(VRFCond) = Constant::MaxCap; // for report

this->CondensingTemp = state.dataEnvrn->OutDryBulbTemp;
this->EvaporatingTemp = state.dataEnvrn->OutDryBulbTemp;
Expand Down Expand Up @@ -12774,7 +12774,7 @@ void VRFTerminalUnitEquipment::CalcVRF_FluidTCtrl(EnergyPlusData &state,
state.dataHVACVarRefFlow->CompOffMassFlow = state.dataHVACVarRefFlow->OACompOffMassFlow;
} else {
// identify the air flow rate corresponding to the coil load
if (this->HeatingCoilPresent && state.dataHVACVarRefFlow->MaxHeatingCapacity(VRFCond) < MaxCap) {
if (this->HeatingCoilPresent && state.dataHVACVarRefFlow->MaxHeatingCapacity(VRFCond) < Constant::MaxCap) {
// Only fix heating only mode for now
state.dataHVACVarRefFlow->CompOnMassFlow = CalVRFTUAirFlowRate_FluidTCtrl(
state, VRFTUNum, PartLoadRatio, FirstHVACIteration, state.dataHVACVarRefFlow->MaxHeatingCapacity(VRFCond));
Expand Down
2 changes: 0 additions & 2 deletions src/EnergyPlus/HVACVariableRefrigerantFlow.hh
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ namespace HVACVariableRefrigerantFlow {
Num
};

constexpr Real64 MaxCap(1.0e+20); // limit of zone terminal unit capacity

// VRF Algorithm Type
enum class AlgorithmType
{
Expand Down

4 comments on commit 0b22d9f

@nrel-bot
Copy link

Choose a reason for hiding this comment

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

VRFFluidFixCoolingTUCap (Unknown) - Win64-Windows-10-VisualStudio-16: OK (2835 of 2838 tests passed, 0 test warnings)

Failures:\n

EnergyPlusFixture Test Summary

  • Passed: 1550
  • Failed: 3

Build Badge Test Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

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

VRFFluidFixCoolingTUCap (Unknown) - x86_64-Linux-Ubuntu-22.04-gcc-11.4: OK (3660 of 3669 tests passed, 0 test warnings)

Messages:\n

  • 6 tests had: Table big diffs.
  • 6 tests had: Table string diffs.
  • 4 tests had: EIO diffs.
  • 4 tests had: ESO big diffs.
  • 3 tests had: ERR diffs.
  • 2 tests had: MTR big diffs.

Failures:\n

EnergyPlusFixture Test Summary

  • Passed: 1552
  • Failed: 3

regression Test Summary

  • Passed: 803
  • Failed: 6

Build Badge Test Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

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

VRFFluidFixCoolingTUCap (Unknown) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-UnitTestsCoverage-Debug: OK (2045 of 2048 tests passed, 0 test warnings)

Failures:\n

EnergyPlusFixture Test Summary

  • Passed: 1552
  • Failed: 3

Build Badge Test Badge Coverage Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

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

VRFFluidFixCoolingTUCap (Unknown) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-IntegrationCoverage-Debug: OK (793 of 793 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

Please sign in to comment.