-
Notifications
You must be signed in to change notification settings - Fork 396
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
Fan:SystemModel with discrete speed flow fractions crashes when speeds >= 2 #10846
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4380,21 +4380,11 @@ void GetVRFInputData(EnergyPlusData &state, bool &ErrorsFound) | |
vrfTU.NumOfSpeedCooling = fanSystem->numSpeeds; | ||
vrfTU.CoolVolumeFlowRate.resize(fanSystem->numSpeeds + 1); | ||
vrfTU.CoolMassFlowRate.resize(fanSystem->numSpeeds + 1); | ||
if (vrfTU.MaxCoolAirVolFlow != DataSizing::AutoSize) { | ||
for (int i = 1; i <= vrfTU.NumOfSpeedCooling; ++i) { | ||
vrfTU.CoolMassFlowRate[i] = fanSystem->massFlowAtSpeed[i - 1]; | ||
} | ||
} | ||
} | ||
if (vrfTU.DXHeatCoilType_Num == HVAC::CoilVRF_Heating) { | ||
vrfTU.NumOfSpeedHeating = fanSystem->numSpeeds; | ||
vrfTU.HeatVolumeFlowRate.resize(fanSystem->numSpeeds + 1); | ||
vrfTU.HeatMassFlowRate.resize(fanSystem->numSpeeds + 1); | ||
if (vrfTU.MaxHeatAirVolFlow != DataSizing::AutoSize) { | ||
for (int i = 1; i <= vrfTU.NumOfSpeedCooling; ++i) { | ||
vrfTU.HeatMassFlowRate[i] = fanSystem->massFlowAtSpeed[i - 1]; | ||
} | ||
} | ||
} | ||
ShowWarningError(state, | ||
cCurrentModuleObject + " = " + thisVrfTU.Name + " with Fan:SystemModel is used in " + cAlphaArgs(8) + "\""); | ||
|
@@ -6421,8 +6411,32 @@ void InitVRF(EnergyPlusData &state, int const VRFTUNum, int const ZoneNum, bool | |
// one-time checks of flow rate vs fan flow rate | ||
if (state.dataHVACVarRefFlow->MyVRFFlag(VRFTUNum)) { | ||
if (!state.dataGlobal->ZoneSizingCalc && !state.dataGlobal->SysSizingCalc) { | ||
if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanPlace != HVAC::FanPlace::Invalid) { // was > 0 (is 0 invalid?) | ||
if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ActualFanVolFlowRate != AutoSize) { | ||
auto &vrfTU = state.dataHVACVarRefFlow->VRFTU(VRFTUNum); | ||
if (vrfTU.fanPlace != HVAC::FanPlace::Invalid) { // was > 0 (is 0 invalid?) | ||
if (vrfTU.ActualFanVolFlowRate != AutoSize) { | ||
|
||
if (vrfTU.fanType == HVAC::FanType::SystemModel) { | ||
auto *fanSystem = dynamic_cast<Fans::FanSystem *>(state.dataFans->fans(vrfTU.FanIndex)); | ||
if (fanSystem->speedControl == Fans::SpeedControl::Discrete && | ||
state.dataHVACVarRefFlow->VRFTU(VRFTUNum).DesignSpecMSHPIndex < 0) { | ||
if (fanSystem->numSpeeds > 1) { | ||
if (vrfTU.DXCoolCoilType_Num == HVAC::CoilVRF_Cooling) { | ||
if (vrfTU.MaxCoolAirVolFlow != DataSizing::AutoSize) { | ||
for (int i = 1; i <= vrfTU.NumOfSpeedCooling; ++i) { | ||
vrfTU.CoolMassFlowRate[i] = fanSystem->massFlowAtSpeed[i - 1]; | ||
} | ||
} | ||
} | ||
if (vrfTU.DXHeatCoilType_Num == HVAC::CoilVRF_Heating) { | ||
if (vrfTU.MaxHeatAirVolFlow != DataSizing::AutoSize) { | ||
for (int i = 1; i <= vrfTU.NumOfSpeedCooling; ++i) { | ||
vrfTU.HeatMassFlowRate[i] = fanSystem->massFlowAtSpeed[i - 1]; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So moved these initializations to Init where the code waits for the fan to size before setting up air flow variables. |
||
|
||
if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirVolFlow > | ||
state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ActualFanVolFlowRate) { | ||
|
@@ -7351,11 +7365,10 @@ void InitVRF(EnergyPlusData &state, int const VRFTUNum, int const ZoneNum, bool | |
SetAverageAirFlow(state, VRFTUNum, 0.0, OnOffAirFlowRatio); | ||
|
||
if (ErrorsFound) { | ||
ShowFatalError( | ||
state, | ||
format( | ||
"{}: Errors found in getting ZoneHVAC:TerminalUnit:VariableRefrigerantFlow system input. Preceding condition(s) causes termination.", | ||
RoutineName)); | ||
ShowFatalError(state, | ||
format("{}: Errors found in getting ZoneHVAC:TerminalUnit:VariableRefrigerantFlow system input. Preceding condition(s) " | ||
"causes termination.", | ||
RoutineName)); | ||
} | ||
} | ||
|
||
|
@@ -7728,7 +7741,7 @@ void SizeVRF(EnergyPlusData &state, int const VRFTUNum) | |
} else { | ||
auto *fanSystem = dynamic_cast<Fans::FanSystem *>(state.dataFans->fans(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex)); | ||
assert(fanSystem != nullptr); | ||
if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolMassFlowRate[i] == 0.0) { | ||
if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolMassFlowRate[i] == 0.0 && !fanSystem->massFlowAtSpeed.empty()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just in case the fan has not yet been sized. |
||
state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolMassFlowRate[i] = fanSystem->massFlowAtSpeed[i - 1]; | ||
state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolVolumeFlowRate[i] = | ||
state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolMassFlowRate[i] / state.dataEnvrn->StdRhoAir; | ||
|
@@ -7814,7 +7827,7 @@ void SizeVRF(EnergyPlusData &state, int const VRFTUNum) | |
} else { | ||
auto *fanSystem = dynamic_cast<Fans::FanSystem *>(state.dataFans->fans(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex)); | ||
assert(fanSystem != nullptr); | ||
if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatMassFlowRate[i] == 0.0) { | ||
if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatMassFlowRate[i] == 0.0 && !fanSystem->massFlowAtSpeed.empty()) { | ||
state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatMassFlowRate[i] = fanSystem->massFlowAtSpeed[i - 1]; | ||
state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatVolumeFlowRate[i] = | ||
state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatMassFlowRate[i] / state.dataEnvrn->StdRhoAir; | ||
|
@@ -7978,7 +7991,7 @@ void SizeVRF(EnergyPlusData &state, int const VRFTUNum) | |
} else { | ||
auto *fanSystem = dynamic_cast<Fans::FanSystem *>(state.dataFans->fans(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex)); | ||
assert(fanSystem != nullptr); | ||
if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolMassFlowRate[i] == 0.0) { | ||
if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolMassFlowRate[i] == 0.0 && !fanSystem->massFlowAtSpeed.empty()) { | ||
state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolMassFlowRate[i] = fanSystem->massFlowAtSpeed[i - 1]; | ||
state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolVolumeFlowRate[i] = | ||
state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolMassFlowRate[i] / state.dataEnvrn->StdRhoAir; | ||
|
@@ -8017,7 +8030,7 @@ void SizeVRF(EnergyPlusData &state, int const VRFTUNum) | |
} else { | ||
auto *fanSystem = dynamic_cast<Fans::FanSystem *>(state.dataFans->fans(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex)); | ||
assert(fanSystem != nullptr); | ||
if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatMassFlowRate[i] == 0.0) { | ||
if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatMassFlowRate[i] == 0.0 && !fanSystem->massFlowAtSpeed.empty()) { | ||
state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatMassFlowRate[i] = fanSystem->massFlowAtSpeed[i - 1]; | ||
state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatVolumeFlowRate[i] = | ||
state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatMassFlowRate[i] / state.dataEnvrn->StdRhoAir; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Crashes in these places in VRF GetInput because massFlowAtSpeed is allocated in the fan's set_size function and that has not been called yet.