-
Notifications
You must be signed in to change notification settings - Fork 398
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
Open
rraustad
wants to merge
3
commits into
develop
Choose a base branch
from
10845-VRF-crash-with-discrete-system-fan
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} | ||
|
||
|
@@ -7725,14 +7738,6 @@ void SizeVRF(EnergyPlusData &state, int const VRFTUNum) | |
} | ||
state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolMassFlowRate[i] = | ||
state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolVolumeFlowRate[i] * state.dataEnvrn->StdRhoAir; | ||
} 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) { | ||
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; | ||
} | ||
} | ||
} | ||
} | ||
|
@@ -7811,14 +7816,6 @@ void SizeVRF(EnergyPlusData &state, int const VRFTUNum) | |
} | ||
state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatMassFlowRate[i] = | ||
state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatVolumeFlowRate[i] * state.dataEnvrn->StdRhoAir; | ||
} 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) { | ||
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; | ||
} | ||
} | ||
} | ||
} | ||
|
@@ -7975,14 +7972,6 @@ void SizeVRF(EnergyPlusData &state, int const VRFTUNum) | |
} | ||
state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolMassFlowRate[i] = | ||
state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolVolumeFlowRate[i] * state.dataEnvrn->StdRhoAir; | ||
} 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) { | ||
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; | ||
} | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.