Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash with new Multi-speed Fans for WSHP Zone Equipment #10249

Merged
merged 2 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/EnergyPlus/HVACFan.hh
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ namespace HVACFan {
bool AirPathFlag; // Yes, this fan is a part of airpath
int m_numSpeeds; // input for how many speed levels for discrete fan
std::vector<Real64> m_massFlowAtSpeed;
std::vector<Real64> m_flowFractionAtSpeed; // array of flow fractions for speed levels
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved to public access


// Mass Flow Rate Control Variables
bool fanIsSecondaryDriver; // true if this fan is used to augment flow and may pass air when off.
Expand Down Expand Up @@ -207,7 +208,6 @@ namespace HVACFan {
Real64 m_qdotConvZone; // fan power lost to surrounding zone by convection to air (W)
Real64 m_qdotRadZone; // fan power lost to surrounding zone by radiation to zone surfaces(W)
std::string m_endUseSubcategoryName;
std::vector<Real64> m_flowFractionAtSpeed; // array of flow fractions for speed levels
std::vector<Real64> m_powerFractionAtSpeed; // array of power fractions for speed levels
std::vector<bool> m_powerFractionInputAtSpeed;
// calculation variables
Expand Down
79 changes: 48 additions & 31 deletions src/EnergyPlus/UnitarySystem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6791,55 +6791,72 @@ namespace UnitarySystems {
if (state.dataHVACFan->fanObjs[FanIndex]->speedControl == HVACFan::FanSystem::SpeedControlMethod::Discrete) {
int NumSpeeds = state.dataHVACFan->fanObjs[FanIndex]->m_numSpeeds;
if (NumSpeeds > 1) {
Copy link
Contributor Author

@rraustad rraustad Sep 28, 2023

Choose a reason for hiding this comment

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

Made the following very targeted to these coil types, only for WSHP, only if air flow is not autoszied for both WSHP parent and accompanied fan object. Also, mass flow should not need to be set here but I left those lines of code, mass flow should get overwritten later unless that is somehow protected. Notice here too that the fan's m_flowFractionAtSpeed had to be made public.

if (this->m_CoolingCoilType_Num == DataHVACGlobals::Coil_CoolingWaterToAirHPSimple ||
this->m_CoolingCoilType_Num == DataHVACGlobals::Coil_CoolingWaterToAirHPVSEquationFit) {
if ((this->m_CoolingCoilType_Num == DataHVACGlobals::Coil_CoolingWaterToAirHPSimple ||
this->m_CoolingCoilType_Num == DataHVACGlobals::Coil_CoolingWaterToAirHPVSEquationFit) &&
this->m_sysType == SysType::PackagedWSHP) {
this->m_NumOfSpeedCooling = NumSpeeds;
this->m_CoolVolumeFlowRate.resize(NumSpeeds + 1);
this->m_CoolMassFlowRate.resize(NumSpeeds + 1);
this->m_MSCoolingSpeedRatio.resize(NumSpeeds + 1);
this->m_MultiOrVarSpeedCoolCoil = true;
this->m_DiscreteSpeedCoolingCoil = true;
if (this->m_MaxCoolAirVolFlow != DataSizing::AutoSize) {
for (int i = 1; i <= this->m_NumOfSpeedCooling; ++i) {
this->m_CoolMassFlowRate[i] = state.dataHVACFan->fanObjs[FanIndex]->m_massFlowAtSpeed[i - 1];
this->m_CoolVolumeFlowRate[i] = this->m_CoolMassFlowRate[i] / state.dataEnvrn->StdRhoAir;
this->m_MSCoolingSpeedRatio[i] = 1.0;
}
} else {
for (int i = 1; i <= this->m_NumOfSpeedCooling; ++i) {
this->m_CoolMassFlowRate[i] = 0.0;
this->m_CoolVolumeFlowRate[i] = 0.0;
this->m_MSCoolingSpeedRatio[i] = 1.0;
if (state.dataHVACFan->fanObjs[FanIndex]->designAirVolFlowRate > 0.0) {
if (this->m_MaxCoolAirVolFlow != DataSizing::AutoSize) {
for (int i = 1; i <= this->m_NumOfSpeedCooling; ++i) {
this->m_CoolVolumeFlowRate[i] = state.dataHVACFan->fanObjs[FanIndex]->designAirVolFlowRate *
state.dataHVACFan->fanObjs[FanIndex]->m_flowFractionAtSpeed[i - 1];
this->m_CoolMassFlowRate[i] = this->m_CoolVolumeFlowRate[i] * state.dataEnvrn->StdRhoAir;
this->m_MSCoolingSpeedRatio[i] = 1.0;
}
} else {
for (int i = 1; i <= this->m_NumOfSpeedCooling; ++i) {
this->m_CoolMassFlowRate[i] = 0.0;
this->m_CoolVolumeFlowRate[i] = 0.0;
this->m_MSCoolingSpeedRatio[i] = 1.0;
}
}
}
}
if (this->m_HeatingCoilType_Num == DataHVACGlobals::Coil_HeatingWaterToAirHPSimple ||
this->m_HeatingCoilType_Num == DataHVACGlobals::Coil_HeatingWaterToAirHPVSEquationFit) {
if ((this->m_HeatingCoilType_Num == DataHVACGlobals::Coil_HeatingWaterToAirHPSimple ||
this->m_HeatingCoilType_Num == DataHVACGlobals::Coil_HeatingWaterToAirHPVSEquationFit) &&
this->m_sysType == SysType::PackagedWSHP) {
this->m_NumOfSpeedHeating = NumSpeeds;
this->m_HeatVolumeFlowRate.resize(NumSpeeds + 1);
this->m_HeatMassFlowRate.resize(NumSpeeds + 1);
this->m_MSHeatingSpeedRatio.resize(NumSpeeds + 1);
this->m_MultiSpeedHeatingCoil = true;
this->m_MultiOrVarSpeedHeatCoil = true;
if (this->m_MaxHeatAirVolFlow != DataSizing::AutoSize) {
for (int i = 1; i <= this->m_NumOfSpeedHeating; ++i) {
this->m_HeatMassFlowRate[i] = state.dataHVACFan->fanObjs[FanIndex]->m_massFlowAtSpeed[i - 1];
this->m_HeatVolumeFlowRate[i] = this->m_HeatMassFlowRate[i] / state.dataEnvrn->StdRhoAir;
this->m_MSHeatingSpeedRatio[i] = 1.0;
}
} else {
for (int i = 1; i <= this->m_NumOfSpeedCooling; ++i) {
this->m_HeatMassFlowRate[i] = 0.0;
this->m_HeatVolumeFlowRate[i] = 0.0;
this->m_MSHeatingSpeedRatio[i] = 1.0;
if (state.dataHVACFan->fanObjs[FanIndex]->designAirVolFlowRate > 0.0) {
if (this->m_MaxHeatAirVolFlow != DataSizing::AutoSize) {
for (int i = 1; i <= this->m_NumOfSpeedHeating; ++i) {
this->m_HeatVolumeFlowRate[i] = state.dataHVACFan->fanObjs[FanIndex]->designAirVolFlowRate *
state.dataHVACFan->fanObjs[FanIndex]->m_flowFractionAtSpeed[i - 1];
this->m_HeatMassFlowRate[i] = this->m_HeatVolumeFlowRate[i] * state.dataEnvrn->StdRhoAir;
this->m_MSHeatingSpeedRatio[i] = 1.0;
}
} else {
for (int i = 1; i <= this->m_NumOfSpeedCooling; ++i) {
this->m_HeatMassFlowRate[i] = 0.0;
this->m_HeatVolumeFlowRate[i] = 0.0;
this->m_MSHeatingSpeedRatio[i] = 1.0;
}
}
}
}
ShowWarningError(state,
cCurrentModuleObject + " = " + this->Name + " with Fan:SystemModel is used in " +
this->input_specs.supply_fan_name + "\"");
ShowContinueError(state, format("...The number of speed = {:.0R}.", double(NumSpeeds)));
ShowContinueError(state, "...Multiple speed fan will be applied to this unit. The speed number is determined by load.");
if (((this->m_CoolingCoilType_Num == DataHVACGlobals::Coil_CoolingWaterToAirHPSimple ||
this->m_CoolingCoilType_Num == DataHVACGlobals::Coil_CoolingWaterToAirHPVSEquationFit) &&
this->m_sysType == SysType::PackagedWSHP) ||
((this->m_HeatingCoilType_Num == DataHVACGlobals::Coil_HeatingWaterToAirHPSimple ||
this->m_HeatingCoilType_Num == DataHVACGlobals::Coil_HeatingWaterToAirHPVSEquationFit) &&
this->m_sysType == SysType::PackagedWSHP)) {
ShowWarningError(state,
format("{} = {} with Fan:SystemModel is used in \"{}\"",
cCurrentModuleObject,
this->Name,
this->input_specs.supply_fan_name));
ShowContinueError(state, format("...The number of speed = {:.0R}.", double(NumSpeeds)));
ShowContinueError(state, "...Multiple speed fan will be applied to this unit. The speed number is determined by load.");
}
}
}
}
Expand Down