Skip to content

Commit

Permalink
apply the curve in the main code, add test idf
Browse files Browse the repository at this point in the history
  • Loading branch information
Yujie Xu committed Nov 6, 2023
1 parent d491a05 commit c2c4123
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 91 deletions.
105 changes: 27 additions & 78 deletions src/EnergyPlus/HeatRecovery.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#include <EnergyPlus/Autosizing/SystemAirFlowSizing.hh>
#include <EnergyPlus/BranchNodeConnections.hh>
#include <EnergyPlus/Coils/CoilCoolingDX.hh>
#include <EnergyPlus/CurveManager.hh>
#include <EnergyPlus/DXCoils.hh>
#include <EnergyPlus/Data/EnergyPlusData.hh>
#include <EnergyPlus/DataContaminantBalance.hh>
Expand Down Expand Up @@ -428,40 +429,8 @@ namespace HeatRecovery {
thisExchanger.NomSupAirVolFlow = state.dataIPShortCut->rNumericArgs(1);
thisExchanger.HeatEffectSensible100 = state.dataIPShortCut->rNumericArgs(2);
thisExchanger.HeatEffectLatent100 = state.dataIPShortCut->rNumericArgs(3);
thisExchanger.HeatEffectSensible75 = state.dataIPShortCut->rNumericArgs(4);
thisExchanger.HeatEffectLatent75 = state.dataIPShortCut->rNumericArgs(5);
if (thisExchanger.HeatEffectSensible75 < thisExchanger.HeatEffectSensible100) {
ShowWarningError(state,
format("{} \"{}\" sensible heating effectiveness at 75% rated flow is less than at 100% rated flow.",
cCurrentModuleObject,
thisExchanger.Name));
ShowContinueError(state, "Sensible heating effectiveness at 75% rated flow is usually greater than at 100% rated flow.");
}
if (thisExchanger.HeatEffectLatent75 < thisExchanger.HeatEffectLatent100) {
ShowWarningError(state,
format("{} \"{}\" latent heating effectiveness at 75% rated flow is less than at 100% rated flow.",
cCurrentModuleObject,
thisExchanger.Name));
ShowContinueError(state, "Latent heating effectiveness at 75% rated flow is usually greater than at 100% rated flow.");
}
thisExchanger.CoolEffectSensible100 = state.dataIPShortCut->rNumericArgs(6);
thisExchanger.CoolEffectLatent100 = state.dataIPShortCut->rNumericArgs(7);
thisExchanger.CoolEffectSensible75 = state.dataIPShortCut->rNumericArgs(8);
thisExchanger.CoolEffectLatent75 = state.dataIPShortCut->rNumericArgs(9);
if (thisExchanger.CoolEffectSensible75 < thisExchanger.CoolEffectSensible100) {
ShowWarningError(state,
format("{} \"{}\" sensible cooling effectiveness at 75% rated flow is less than at 100% rated flow.",
cCurrentModuleObject,
thisExchanger.Name));
ShowContinueError(state, "Sensible cooling effectiveness at 75% rated flow is usually greater than at 100% rated flow.");
}
if (thisExchanger.CoolEffectLatent75 < thisExchanger.CoolEffectLatent100) {
ShowWarningError(state,
format("{} \"{}\" latent cooling effectiveness at 75% rated flow is less than at 100% rated flow.",
cCurrentModuleObject,
thisExchanger.Name));
ShowContinueError(state, "Latent cooling effectiveness at 75% rated flow is usually greater than at 100% rated flow.");
}
thisExchanger.CoolEffectSensible100 = state.dataIPShortCut->rNumericArgs(4);
thisExchanger.CoolEffectLatent100 = state.dataIPShortCut->rNumericArgs(5);
thisExchanger.SupInletNode = GetOnlySingleNode(state,
state.dataIPShortCut->cAlphaArgs(3),
ErrorsFound,
Expand Down Expand Up @@ -499,7 +468,7 @@ namespace HeatRecovery {
NodeInputManager::CompFluidStream::Secondary,
DataLoopNode::ObjectIsNotParent);

thisExchanger.NomElecPower = state.dataIPShortCut->rNumericArgs(10);
thisExchanger.NomElecPower = state.dataIPShortCut->rNumericArgs(6);

if (UtilityRoutines::SameString(state.dataIPShortCut->cAlphaArgs(7), "Yes")) {
thisExchanger.ControlToTemperatureSetPoint = true;
Expand Down Expand Up @@ -529,9 +498,9 @@ namespace HeatRecovery {
}

if (!UtilityRoutines::SameString(state.dataIPShortCut->cAlphaArgs(9), "None")) {
thisExchanger.ThresholdTemperature = state.dataIPShortCut->rNumericArgs(11);
thisExchanger.InitialDefrostTime = state.dataIPShortCut->rNumericArgs(12);
thisExchanger.RateofDefrostTimeIncrease = state.dataIPShortCut->rNumericArgs(13);
thisExchanger.ThresholdTemperature = state.dataIPShortCut->rNumericArgs(7);
thisExchanger.InitialDefrostTime = state.dataIPShortCut->rNumericArgs(8);
thisExchanger.RateofDefrostTimeIncrease = state.dataIPShortCut->rNumericArgs(9);
}

if (state.dataIPShortCut->lAlphaFieldBlanks(10)) {
Expand All @@ -544,6 +513,12 @@ namespace HeatRecovery {
thisExchanger.EconoLockOut = static_cast<bool>(toggle);
}

// yujie: read new curves here
thisExchanger.HeatEffectSensibleCurveIndex = Curve::GetCurveIndex(state, state.dataIPShortCut->cAlphaArgs(11)); // convert curve name to number
thisExchanger.HeatEffectLatentCurveIndex = Curve::GetCurveIndex(state, state.dataIPShortCut->cAlphaArgs(12)); // convert curve name to number
thisExchanger.CoolEffectSensibleCurveIndex = Curve::GetCurveIndex(state, state.dataIPShortCut->cAlphaArgs(13)); // convert curve name to number
thisExchanger.CoolEffectLatentCurveIndex = Curve::GetCurveIndex(state, state.dataIPShortCut->cAlphaArgs(14)); // convert curve name to number

BranchNodeConnections::TestCompSet(state,
DataHVACGlobals::cHXTypes(thisExchanger.ExchType),
thisExchanger.Name,
Expand Down Expand Up @@ -2097,16 +2072,12 @@ namespace HeatRecovery {

if (this->SupInTemp < this->SecInTemp) {
// Use heating effectiveness values
this->SensEffectiveness = this->HeatEffectSensible75 +
(this->HeatEffectSensible100 - this->HeatEffectSensible75) * (HXAirVolFlowRatio - 0.75) / (1.0 - 0.75);
this->LatEffectiveness =
this->HeatEffectLatent75 + (this->HeatEffectLatent100 - this->HeatEffectLatent75) * (HXAirVolFlowRatio - 0.75) / (1.0 - 0.75);
this->SensEffectiveness = Curve::CurveValue(state, this->HeatEffectSensibleCurveIndex, HXAirVolFlowRatio) * this->HeatEffectSensible100;
this->LatEffectiveness = Curve::CurveValue(state, this->HeatEffectLatentCurveIndex, HXAirVolFlowRatio) * this->HeatEffectLatent100 ;
} else {
// Use cooling effectiveness values
this->SensEffectiveness = this->CoolEffectSensible75 +
(this->CoolEffectSensible100 - this->CoolEffectSensible75) * (HXAirVolFlowRatio - 0.75) / (1.0 - 0.75);
this->LatEffectiveness =
this->CoolEffectLatent75 + (this->CoolEffectLatent100 - this->CoolEffectLatent75) * (HXAirVolFlowRatio - 0.75) / (1.0 - 0.75);
this->SensEffectiveness = Curve::CurveValue(state, this->CoolEffectSensibleCurveIndex, HXAirVolFlowRatio) * this->CoolEffectSensible100;
this->LatEffectiveness = Curve::CurveValue(state, this->CoolEffectLatentCurveIndex, HXAirVolFlowRatio) * this->CoolEffectLatent100 ;
}

// Keep effectiveness between 0 and 1.0 ??
Expand All @@ -2123,11 +2094,9 @@ namespace HeatRecovery {
this->Name));
if (this->SupInTemp < this->SecInTemp) {
ShowContinueError(state, format("...Sensible Effectiveness at 100% Heating Air Flow = {:.2R}", this->HeatEffectSensible100));
ShowContinueError(state, format("...Sensible Effectiveness at 75% Heating Air Flow = {:.2R}", this->HeatEffectSensible75));
ShowContinueError(state, "...Sensible effectiveness reset to zero and the simulation continues.");
} else {
ShowContinueError(state, format("...Sensible Effectiveness at 100% Cooling Air Flow = {:.2R}", this->CoolEffectSensible100));
ShowContinueError(state, format("...Sensible Effectiveness at 75% Cooling Air Flow = {:.2R}", this->CoolEffectSensible75));
ShowContinueError(state, "...Sensible effectiveness reset to zero and the simulation continues.");
}
ShowContinueError(state, format("...Heat Exchanger Air Volume Flow Ratio = {:.2R}", HXAirVolFlowRatio));
Expand All @@ -2144,11 +2113,9 @@ namespace HeatRecovery {
this->Name));
if (this->SupInTemp < this->SecInTemp) {
ShowContinueError(state, format("...Latent Effectiveness at 100% Heating Air Flow = {:.2R}", this->HeatEffectLatent100));
ShowContinueError(state, format("...Latent Effectiveness at 75% Heating Air Flow = {:.2R}", this->HeatEffectLatent75));
ShowContinueError(state, "...Latent effectiveness reset to zero and the simulation continues.");
} else {
ShowContinueError(state, format("...Latent Effectiveness at 100% Cooling Air Flow = {:.2R}", this->CoolEffectLatent100));
ShowContinueError(state, format("...Latent Effectiveness at 75% Cooling Air Flow = {:.2R}", this->CoolEffectLatent75));
ShowContinueError(state, "...Latent effectiveness reset to zero and the simulation continues.");
}
ShowContinueError(state, format("...Heat Exchanger Air Volume Flow Ratio = {:.2R}", HXAirVolFlowRatio));
Expand Down Expand Up @@ -2219,16 +2186,12 @@ namespace HeatRecovery {
CMin = min(CSup, CSec);
if (TempSupIn < TempSecIn) {
// Use heating effectiveness values
this->SensEffectiveness = this->HeatEffectSensible75 + (this->HeatEffectSensible100 - this->HeatEffectSensible75) *
(HXAirVolFlowRatio - 0.75) / (1.0 - 0.75);
this->LatEffectiveness = this->HeatEffectLatent75 + (this->HeatEffectLatent100 - this->HeatEffectLatent75) *
(HXAirVolFlowRatio - 0.75) / (1.0 - 0.75);
this->SensEffectiveness = Curve::CurveValue(state, this->HeatEffectSensibleCurveIndex, HXAirVolFlowRatio) * this->HeatEffectSensible100;
this->LatEffectiveness = Curve::CurveValue(state, this->HeatEffectLatentCurveIndex, HXAirVolFlowRatio) * this->HeatEffectLatent100 ;
} else {
// Use cooling effectiveness values
this->SensEffectiveness = this->CoolEffectSensible75 + (this->CoolEffectSensible100 - this->CoolEffectSensible75) *
(HXAirVolFlowRatio - 0.75) / (1.0 - 0.75);
this->LatEffectiveness = this->CoolEffectLatent75 + (this->CoolEffectLatent100 - this->CoolEffectLatent75) *
(HXAirVolFlowRatio - 0.75) / (1.0 - 0.75);
this->SensEffectiveness = Curve::CurveValue(state, this->CoolEffectSensibleCurveIndex, HXAirVolFlowRatio) * this->CoolEffectSensible100;
this->LatEffectiveness = Curve::CurveValue(state, this->CoolEffectLatentCurveIndex, HXAirVolFlowRatio) * this->CoolEffectLatent100 ;
}

if (this->SensEffectiveness < 0.0) {
Expand All @@ -2242,14 +2205,10 @@ namespace HeatRecovery {
if (this->SupInTemp < this->SecInTemp) {
ShowContinueError(
state, format("...Sensible Effectiveness at 100% Heating Air Flow = {:.2R}", this->HeatEffectSensible100));
ShowContinueError(
state, format("...Sensible Effectiveness at 75% Heating Air Flow = {:.2R}", this->HeatEffectSensible75));
ShowContinueError(state, "...Sensible effectiveness reset to zero and the simulation continues.");
} else {
ShowContinueError(
state, format("...Sensible Effectiveness at 100% Cooling Air Flow = {:.2R}", this->CoolEffectSensible100));
ShowContinueError(
state, format("...Sensible Effectiveness at 75% Cooling Air Flow = {:.2R}", this->CoolEffectSensible75));
ShowContinueError(state, "...Sensible effectiveness reset to zero and the simulation continues.");
}
ShowContinueError(state, format("...Heat Exchanger Air Volume Flow Ratio = {:.2R}", HXAirVolFlowRatio));
Expand All @@ -2267,14 +2226,10 @@ namespace HeatRecovery {
if (this->SupInTemp < this->SecInTemp) {
ShowContinueError(state,
format("...Latent Effectiveness at 100% Heating Air Flow = {:.2R}", this->HeatEffectLatent100));
ShowContinueError(state,
format("...Latent Effectiveness at 75% Heating Air Flow = {:.2R}", this->HeatEffectLatent75));
ShowContinueError(state, "...Latent effectiveness reset to zero and the simulation continues.");
} else {
ShowContinueError(state,
format("...Latent Effectiveness at 100% Cooling Air Flow = {:.2R}", this->CoolEffectLatent100));
ShowContinueError(state,
format("...Latent Effectiveness at 75% Cooling Air Flow = {:.2R}", this->CoolEffectLatent75));
ShowContinueError(state, "...Latent effectiveness reset to zero and the simulation continues.");
}
ShowContinueError(state, format("...Heat Exchanger Air Volume Flow Ratio = {:.2R}", HXAirVolFlowRatio));
Expand Down Expand Up @@ -2803,10 +2758,8 @@ namespace HeatRecovery {
HXSecAirVolFlowRate = this->SecOutMassFlow / RhoSec;
HXAvgAirVolFlowRate = (HXSecAirVolFlowRate + HXSupAirVolFlowRate) / 2.0;
HXAirVolFlowRatio = HXAvgAirVolFlowRate / this->NomSupAirVolFlow;
this->SensEffectiveness =
this->HeatEffectSensible75 + (this->HeatEffectSensible100 - this->HeatEffectSensible75) * (HXAirVolFlowRatio - 0.75) / (1.0 - 0.75);
this->LatEffectiveness =
this->HeatEffectLatent75 + (this->HeatEffectLatent100 - this->HeatEffectLatent75) * (HXAirVolFlowRatio - 0.75) / (1.0 - 0.75);
this->SensEffectiveness = Curve::CurveValue(state, this->HeatEffectSensibleCurveIndex, HXAirVolFlowRatio) * this->HeatEffectSensible100;
this->LatEffectiveness = Curve::CurveValue(state, this->HeatEffectLatentCurveIndex, HXAirVolFlowRatio) * this->HeatEffectLatent100 ;
this->SupOutTemp = this->SupInTemp + this->SensEffectiveness * CMin / CSup * (this->SecInTemp - this->SupInTemp);
this->SupOutHumRat = this->SupInHumRat + this->LatEffectiveness * CMin / CSup * (this->SecInHumRat - this->SupInHumRat);
this->SupOutEnth = Psychrometrics::PsyHFnTdbW(this->SupOutTemp, this->SupOutHumRat);
Expand Down Expand Up @@ -2859,16 +2812,12 @@ namespace HeatRecovery {
CMin = min(CSup, CSec);
if (TempSupIn < TempSecIn) {
// Use heating effectiveness values
this->SensEffectiveness = this->HeatEffectSensible75 + (this->HeatEffectSensible100 - this->HeatEffectSensible75) *
(HXAirVolFlowRatio - 0.75) / (1.0 - 0.75);
this->LatEffectiveness = this->HeatEffectLatent75 +
(this->HeatEffectLatent100 - this->HeatEffectLatent75) * (HXAirVolFlowRatio - 0.75) / (1.0 - 0.75);
this->SensEffectiveness = Curve::CurveValue(state, this->HeatEffectSensibleCurveIndex, HXAirVolFlowRatio) * this->HeatEffectSensible100;
this->LatEffectiveness = Curve::CurveValue(state, this->HeatEffectLatentCurveIndex, HXAirVolFlowRatio) * this->HeatEffectLatent100 ;
} else {
// Use cooling effectiveness values
this->SensEffectiveness = this->CoolEffectSensible75 + (this->CoolEffectSensible100 - this->CoolEffectSensible75) *
(HXAirVolFlowRatio - 0.75) / (1.0 - 0.75);
this->LatEffectiveness = this->CoolEffectLatent75 +
(this->CoolEffectLatent100 - this->CoolEffectLatent75) * (HXAirVolFlowRatio - 0.75) / (1.0 - 0.75);
this->SensEffectiveness = Curve::CurveValue(state, this->CoolEffectSensibleCurveIndex, HXAirVolFlowRatio) * this->CoolEffectSensible100;
this->LatEffectiveness = Curve::CurveValue(state, this->CoolEffectLatentCurveIndex, HXAirVolFlowRatio) * this->CoolEffectLatent100 ;
}
// calculation of local variable Csup can be 0, gaurd against divide by 0.
TempSupOut = TempSupIn + this->SensEffectiveness * SafeDiv(CMin, CSup) * (TempSecIn - TempSupIn);
Expand Down
Loading

0 comments on commit c2c4123

Please sign in to comment.