Skip to content

Commit

Permalink
remove statics WindowAC, WaterToAirHeatPumpSimple
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchute committed Mar 23, 2021
1 parent 8c1ed64 commit 6799a8c
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 101 deletions.
116 changes: 35 additions & 81 deletions src/EnergyPlus/WaterToAirHeatPumpSimple.cc
Original file line number Diff line number Diff line change
Expand Up @@ -285,15 +285,15 @@ namespace WaterToAirHeatPumpSimple {
static std::string const RoutineName("GetSimpleWatertoAirHPInput: "); // include trailing blank space

// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
int HPNum; // The Water to Air HP that you are currently loading input into
int NumCool; // Counter for cooling coil
int NumHeat; // Counter for heating coil
int WatertoAirHPNum; // Counter
int NumAlphas; // Number of variables in String format
int NumNums; // Number of variables in Numeric format
int NumParams; // Total number of input fields
static int MaxNums(0); // Maximum number of numeric input fields
static int MaxAlphas(0); // Maximum number of alpha input fields
int HPNum; // The Water to Air HP that you are currently loading input into
int NumCool; // Counter for cooling coil
int NumHeat; // Counter for heating coil
int WatertoAirHPNum; // Counter
int NumAlphas; // Number of variables in String format
int NumNums; // Number of variables in Numeric format
int NumParams; // Total number of input fields
int MaxNums(0); // Maximum number of numeric input fields
int MaxAlphas(0); // Maximum number of alpha input fields
int IOStat;
bool ErrorsFound(false); // If errors detected in input
std::string CurrentModuleObject; // for ease in getting objects
Expand Down Expand Up @@ -806,8 +806,6 @@ namespace WaterToAirHeatPumpSimple {
// METHODOLOGY EMPLOYED:
// Uses the status flags to trigger initializations.

// REFERENCES:

// Using/Aliasing
using FluidProperties::GetDensityGlycol;
using FluidProperties::GetSpecificHeatGlycol;
Expand All @@ -816,43 +814,28 @@ namespace WaterToAirHeatPumpSimple {
using PlantUtilities::SetComponentFlowRate;
using Psychrometrics::PsyRhoAirFnPbTdbW;

// Locals
static Array1D_bool MySizeFlag; // used for sizing PTHP inputs one time

// SUBROUTINE ARGUMENT DEFINITIONS:

// shut off after compressor cycle off [s]

// SUBROUTINE PARAMETER DEFINITIONS:
static std::string const RoutineName("InitSimpleWatertoAirHP");

// INTERFACE BLOCK SPECIFICATIONS
// na

// DERIVED TYPE DEFINITIONS
// na

// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
int AirInletNode; // Node Number of the air inlet
int WaterInletNode; // Node Number of the Water inlet
static Array1D_bool MyEnvrnFlag; // used for initializations each begin environment flag
static Array1D_bool MyPlantScanFlag;
Real64 rho; // local fluid density
Real64 Cp; // local fluid specific heat
bool errFlag;

if (state.dataWaterToAirHeatPumpSimple->MyOneTimeFlag) {
// initialize the environment and sizing flags
MySizeFlag.allocate(state.dataWaterToAirHeatPumpSimple->NumWatertoAirHPs);
MyEnvrnFlag.allocate(state.dataWaterToAirHeatPumpSimple->NumWatertoAirHPs);
MyPlantScanFlag.allocate(state.dataWaterToAirHeatPumpSimple->NumWatertoAirHPs);
MySizeFlag = true;
MyEnvrnFlag = true;
MyPlantScanFlag = true;
state.dataWaterToAirHeatPumpSimple->MySizeFlag.allocate(state.dataWaterToAirHeatPumpSimple->NumWatertoAirHPs);
state.dataWaterToAirHeatPumpSimple->MyEnvrnFlag.allocate(state.dataWaterToAirHeatPumpSimple->NumWatertoAirHPs);
state.dataWaterToAirHeatPumpSimple->MyPlantScanFlag.allocate(state.dataWaterToAirHeatPumpSimple->NumWatertoAirHPs);
state.dataWaterToAirHeatPumpSimple->MySizeFlag = true;
state.dataWaterToAirHeatPumpSimple->MyEnvrnFlag = true;
state.dataWaterToAirHeatPumpSimple->MyPlantScanFlag = true;
state.dataWaterToAirHeatPumpSimple->MyOneTimeFlag = false;
}

if (MyPlantScanFlag(HPNum) && allocated(state.dataPlnt->PlantLoop)) {
if (state.dataWaterToAirHeatPumpSimple->MyPlantScanFlag(HPNum) && allocated(state.dataPlnt->PlantLoop)) {
errFlag = false;
ScanPlantLoopsForObject(state,
state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(HPNum).Name,
Expand All @@ -870,14 +853,14 @@ namespace WaterToAirHeatPumpSimple {
if (errFlag) {
ShowFatalError(state, "InitSimpleWatertoAirHP: Program terminated for previous conditions.");
}
MyPlantScanFlag(HPNum) = false;
state.dataWaterToAirHeatPumpSimple->MyPlantScanFlag(HPNum) = false;
}

if (!state.dataGlobal->SysSizingCalc && MySizeFlag(HPNum) && !MyPlantScanFlag(HPNum)) {
if (!state.dataGlobal->SysSizingCalc && state.dataWaterToAirHeatPumpSimple->MySizeFlag(HPNum) && !state.dataWaterToAirHeatPumpSimple->MyPlantScanFlag(HPNum)) {
// for each furnace, do the sizing once.
SizeHVACWaterToAir(state, HPNum);

MySizeFlag(HPNum) = false;
state.dataWaterToAirHeatPumpSimple->MySizeFlag(HPNum) = false;
}

if (FirstHVACIteration) {
Expand Down Expand Up @@ -929,7 +912,7 @@ namespace WaterToAirHeatPumpSimple {
}

// Do the Begin Environment initializations
if (state.dataGlobal->BeginEnvrnFlag && MyEnvrnFlag(HPNum) && !MyPlantScanFlag(HPNum)) {
if (state.dataGlobal->BeginEnvrnFlag && state.dataWaterToAirHeatPumpSimple->MyEnvrnFlag(HPNum) && !state.dataWaterToAirHeatPumpSimple->MyPlantScanFlag(HPNum)) {
// Do the initializations to start simulation

AirInletNode = state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(HPNum).AirInletNodeNum;
Expand Down Expand Up @@ -987,12 +970,12 @@ namespace WaterToAirHeatPumpSimple {

state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(HPNum).SimFlag = true;

MyEnvrnFlag(HPNum) = false;
state.dataWaterToAirHeatPumpSimple->MyEnvrnFlag(HPNum) = false;

} // End If for the Begin Environment initializations

if (!state.dataGlobal->BeginEnvrnFlag) {
MyEnvrnFlag(HPNum) = true;
state.dataWaterToAirHeatPumpSimple->MyEnvrnFlag(HPNum) = true;
}

// Do the following initializations (every time step): This should be the info from
Expand Down Expand Up @@ -2082,34 +2065,20 @@ namespace WaterToAirHeatPumpSimple {
using Psychrometrics::PsyWFnTdbTwbPb;
using CurveManager::CurveValue;

// Locals
// SUBROUTINE ARGUMENT DEFINITIONS:

// SUBROUTINE PARAMETER DEFINITIONS:
Real64 const Tref(283.15); // Reference Temperature for performance curves,10C [K]
constexpr Real64 Tref(283.15); // Reference Temperature for performance curves,10C [K]
static std::string const RoutineName("CalcHPCoolingSimple");
static std::string const RoutineNameSourceSideInletTemp("CalcHPCoolingSimple:SourceSideInletTemp");

// INTERFACE BLOCK SPECIFICATIONS
// na

// DERIVED TYPE DEFINITIONS
// na

// SUBROUTINE LOCAL VARIABLE DECLARATIONS:

Real64 TotalCapRated; // Rated Total Cooling Capacity [W]
Real64 SensCapRated; // Rated Sensible Cooling Capacity [W]
Real64 CoolPowerRated; // Rated Cooling Power Input[W]
Real64 AirVolFlowRateRated; // Rated Air Volumetric Flow Rate [m3/s]
Real64 WaterVolFlowRateRated; // Rated Water Volumetric Flow Rate [m3/s]
Real64 Twet_Rated; // Twet at rated conditions (coil air flow rate and air temperatures), sec
Real64 Gamma_Rated; // Gamma at rated conditions (coil air flow rate and air temperatures)

Real64 SHRss; // Sensible heat ratio at steady state
Real64 SHReff; // Effective sensible heat ratio at part-load condition
// REAL(r64) :: PartLoadRatio ! Part load ratio

Real64 ratioTDB; // Ratio of the inlet air dry bulb temperature to the rated conditions
Real64 ratioTWB; // Ratio of the inlet air wet bulb temperature to the rated conditions
Real64 ratioTS; // Ratio of the source side(water) inlet temperature to the rated conditions
Expand All @@ -2119,19 +2088,18 @@ namespace WaterToAirHeatPumpSimple {
Real64 CpAir; // Specific heat of air [J/kg_C]
Real64 ReportingConstant;

bool LatDegradModelSimFlag; // Latent degradation model simulation flag
int NumIteration; // Iteration Counter
static int Count(0); // No idea what this is for.
static Real64 LoadSideInletDBTemp_Init; // rated conditions
static Real64 LoadSideInletWBTemp_Init; // rated conditions
static Real64 LoadSideInletHumRat_Init; // rated conditions
static Real64 LoadSideInletEnth_Init; // rated conditions
static Real64 CpAir_Init; // rated conditions
Real64 LoadSideInletDBTemp_Unit; // calc conditions for unit
Real64 LoadSideInletWBTemp_Unit; // calc conditions for unit
Real64 LoadSideInletHumRat_Unit; // calc conditions for unit
Real64 LoadSideInletEnth_Unit; // calc conditions for unit
Real64 CpAir_Unit; // calc conditions for unit
bool LatDegradModelSimFlag; // Latent degradation model simulation flag
int NumIteration; // Iteration Counter
Real64 LoadSideInletDBTemp_Init; // rated conditions
Real64 LoadSideInletWBTemp_Init; // rated conditions
Real64 LoadSideInletHumRat_Init; // rated conditions
Real64 LoadSideInletEnth_Init; // rated conditions

This comment has been minimized.

Copy link
@mjwitte

mjwitte Mar 26, 2021

Contributor

@mitchute @Myoldmopar These are initialized a few lines down inside if (state.dataWaterToAirHeatPumpSimple->firstTime). By the time these are actually used, they are uninitialized again. Here's a file that demonstrates the problem.
GHX-in-fix.zip.

This comment has been minimized.

Copy link
@mitchute

mitchute Mar 27, 2021

Author Collaborator

Thanks @mjwitte. I'll push a fix here shortly.

Real64 CpAir_Init; // rated conditions
Real64 LoadSideInletDBTemp_Unit; // calc conditions for unit
Real64 LoadSideInletWBTemp_Unit; // calc conditions for unit
Real64 LoadSideInletHumRat_Unit; // calc conditions for unit
Real64 LoadSideInletEnth_Unit; // calc conditions for unit
Real64 CpAir_Unit; // calc conditions for unit

if (state.dataWaterToAirHeatPumpSimple->firstTime) {
// Set indoor air conditions to the rated condition
Expand Down Expand Up @@ -2259,7 +2227,6 @@ namespace WaterToAirHeatPumpSimple {
state.dataWaterToAirHeatPumpSimple->LoadSideOutletEnth = state.dataWaterToAirHeatPumpSimple->LoadSideInletEnth - state.dataWaterToAirHeatPumpSimple->QLoadTotal / state.dataWaterToAirHeatPumpSimple->LoadSideMassFlowRate;
state.dataWaterToAirHeatPumpSimple->LoadSideOutletDBTemp = state.dataWaterToAirHeatPumpSimple->LoadSideInletDBTemp - state.dataWaterToAirHeatPumpSimple->QSensible / (state.dataWaterToAirHeatPumpSimple->LoadSideMassFlowRate * CpAir);
state.dataWaterToAirHeatPumpSimple->LoadSideOutletHumRat = PsyWFnTdbH(state, state.dataWaterToAirHeatPumpSimple->LoadSideOutletDBTemp, state.dataWaterToAirHeatPumpSimple->LoadSideOutletEnth, RoutineName);
++Count;
// Actual outlet conditions are "average" for time step
if (CyclingScheme == ContFanCycCoil) {
// continuous fan, cycling compressor
Expand Down Expand Up @@ -2397,28 +2364,15 @@ namespace WaterToAirHeatPumpSimple {
using Psychrometrics::PsyWFnTdbTwbPb;
using CurveManager::CurveValue;

// Locals
// SUBROUTINE ARGUMENT DEFINITIONS:

// SUBROUTINE PARAMETER DEFINITIONS:
Real64 const Tref(283.15); // Reference Temperature for performance curves,10C [K]
static std::string const RoutineName("CalcHPHeatingSimple");
static std::string const RoutineNameSourceSideInletTemp("CalcHPHeatingSimple:SourceSideInletTemp");

// INTERFACE BLOCK SPECIFICATIONS
// na

// DERIVED TYPE DEFINITIONS
// na

// SUBROUTINE LOCAL VARIABLE DECLARATIONS:

Real64 HeatCapRated; // Rated Heating Capacity [W]
Real64 HeatPowerRated; // Rated Heating Power Input[W]
Real64 AirVolFlowRateRated; // Rated Air Volumetric Flow Rate [m3/s]
Real64 WaterVolFlowRateRated; // Rated Water Volumetric Flow Rate [m3/s]

// REAL(r64) :: PartLoadRatio ! Part load ratio
Real64 ratioTDB; // Ratio of the inlet air dry bulb temperature to the rated conditions
Real64 ratioTS; // Ratio of the source side (water) inlet temperature to the rated conditions
Real64 ratioVL; // Ratio of the load side flow rate to the rated conditions
Expand Down
13 changes: 9 additions & 4 deletions src/EnergyPlus/WaterToAirHeatPumpSimple.hh
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ namespace WaterToAirHeatPumpSimple {
OutletWaterEnthalpy(0.0), Power(0.0), QLoadTotal(0.0), QSensible(0.0), QLatent(0.0), QSource(0.0), Energy(0.0), EnergyLoadTotal(0.0),
EnergySensible(0.0), EnergyLatent(0.0), EnergySource(0.0), COP(0.0), RunFrac(0.0), PartLoadRatio(0.0), RatedWaterVolFlowRate(0.0),
RatedAirVolFlowRate(0.0), RatedCapHeat(0.0), RatedPowerHeat(0.0), RatedCOPHeat(0.0), RatedCapCoolTotal(0.0), RatedCapCoolSens(0.0),
RatedPowerCool(0.0), RatedCOPCool(0.0), HeatCapCurveIndex(0), HeatPowCurveIndex(0), TotalCoolCapCurveIndex(0),
SensCoolCapCurveIndex(0),CoolPowCurveIndex(0), AirInletNodeNum(0), AirOutletNodeNum(0), WaterInletNodeNum(0), WaterOutletNodeNum(0),
LoopNum(0), LoopSide(0), BranchNum(0), CompNum(0), WaterCyclingMode(0), LastOperatingMode(WaterCycling), WaterFlowMode(false),
CompanionCoolingCoilNum(0), CompanionHeatingCoilNum(0), Twet_Rated(0.0), Gamma_Rated(0.0), MaxONOFFCyclesperHour(0.0),
RatedPowerCool(0.0), RatedCOPCool(0.0), HeatCapCurveIndex(0), HeatPowCurveIndex(0), TotalCoolCapCurveIndex(0),
SensCoolCapCurveIndex(0),CoolPowCurveIndex(0), AirInletNodeNum(0), AirOutletNodeNum(0), WaterInletNodeNum(0), WaterOutletNodeNum(0),
LoopNum(0), LoopSide(0), BranchNum(0), CompNum(0), WaterCyclingMode(0), LastOperatingMode(WaterCycling), WaterFlowMode(false),
CompanionCoolingCoilNum(0), CompanionHeatingCoilNum(0), Twet_Rated(0.0), Gamma_Rated(0.0), MaxONOFFCyclesperHour(0.0),
HPTimeConstant(0.0), FanDelayTime(0.0), reportCoilFinalSizes(true)
{
}
Expand Down Expand Up @@ -299,6 +299,9 @@ namespace WaterToAirHeatPumpSimple {

Array1D<WaterToAirHeatPumpSimple::SimpleWatertoAirHPConditions> SimpleWatertoAirHP;

Array1D_bool MyEnvrnFlag; // used for initializations each begin environment flag
Array1D_bool MyPlantScanFlag;

void clear_state() override
{
this->NumWatertoAirHPs = 0;
Expand All @@ -308,6 +311,8 @@ namespace WaterToAirHeatPumpSimple {
this->SimpleHPTimeStepFlag.clear();
this->SimpleWatertoAirHP.deallocate();
this->firstTime = true;
this->MyEnvrnFlag.deallocate();
this->MyPlantScanFlag.deallocate();
}

// Default Constructor
Expand Down
29 changes: 13 additions & 16 deletions src/EnergyPlus/WindowAC.cc
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,10 @@ namespace WindowAC {
Array1D<Real64> Numbers; // Numeric input items for object
Array1D_bool lAlphaBlanks; // Logical array, alpha field input BLANK = .TRUE.
Array1D_bool lNumericBlanks; // Logical array, numeric field input BLANK = .TRUE.
static int TotalArgs(0); // Total number of alpha and numeric arguments (max) for a
// INTEGER :: FanType ! Integer index for Fan type
int CtrlZone; // index to loop counter
int NodeNum; // index to loop counter
bool ZoneNodeNotFound; // used in error checking
int TotalArgs(0); // Total number of alpha and numeric arguments (max) for a
int CtrlZone; // index to loop counter
int NodeNum; // index to loop counter
bool ZoneNodeNotFound; // used in error checking

// find the number of each type of window AC unit
CurrentModuleObject = "ZoneHVAC:WindowAirConditioner";
Expand Down Expand Up @@ -763,28 +762,26 @@ namespace WindowAC {
int AirRelNode; // relief air node number in window AC loop
Real64 RhoAir; // air density at InNode
int Loop; // loop counter
static Array1D_bool MyEnvrnFlag; // one time initialization flag
static Array1D_bool MyZoneEqFlag; // used to set up zone equipment availability managers
Real64 QToCoolSetPt; // sensible load to cooling setpoint (W)
Real64 NoCompOutput; // sensible load delivered with compressor off (W)

// Do the one time initializations
if (state.dataWindowAC->MyOneTimeFlag) {

MyEnvrnFlag.allocate(state.dataWindowAC->NumWindAC);
state.dataWindowAC->MyEnvrnFlag.allocate(state.dataWindowAC->NumWindAC);
state.dataWindowAC->MySizeFlag.allocate(state.dataWindowAC->NumWindAC);
MyZoneEqFlag.allocate(state.dataWindowAC->NumWindAC);
MyEnvrnFlag = true;
state.dataWindowAC->MyZoneEqFlag.allocate(state.dataWindowAC->NumWindAC);
state.dataWindowAC->MyEnvrnFlag = true;
state.dataWindowAC->MySizeFlag = true;
MyZoneEqFlag = true;
state.dataWindowAC->MyZoneEqFlag = true;
state.dataWindowAC->MyOneTimeFlag = false;
}

if (allocated(ZoneComp)) {
if (MyZoneEqFlag(WindACNum)) { // initialize the name of each availability manager list and zone number
if (state.dataWindowAC->MyZoneEqFlag(WindACNum)) { // initialize the name of each availability manager list and zone number
ZoneComp(WindowAC_Num).ZoneCompAvailMgrs(WindACNum).AvailManagerListName = state.dataWindowAC->WindAC(WindACNum).AvailManagerListName;
ZoneComp(WindowAC_Num).ZoneCompAvailMgrs(WindACNum).ZoneNum = ZoneNum;
MyZoneEqFlag(WindACNum) = false;
state.dataWindowAC->MyZoneEqFlag(WindACNum) = false;
}
state.dataWindowAC->WindAC(WindACNum).AvailStatus = ZoneComp(WindowAC_Num).ZoneCompAvailMgrs(WindACNum).AvailStatus;
}
Expand All @@ -809,7 +806,7 @@ namespace WindowAC {
}

// Do the Begin Environment initializations
if (state.dataGlobal->BeginEnvrnFlag && MyEnvrnFlag(WindACNum)) {
if (state.dataGlobal->BeginEnvrnFlag && state.dataWindowAC->MyEnvrnFlag(WindACNum)) {
InNode = state.dataWindowAC->WindAC(WindACNum).AirInNode;
OutNode = state.dataWindowAC->WindAC(WindACNum).AirOutNode;
OutsideAirNode = state.dataWindowAC->WindAC(WindACNum).OutsideAirNode;
Expand All @@ -824,11 +821,11 @@ namespace WindowAC {
state.dataLoopNodes->Node(OutNode).MassFlowRateMin = 0.0;
state.dataLoopNodes->Node(InNode).MassFlowRateMax = state.dataWindowAC->WindAC(WindACNum).MaxAirMassFlow;
state.dataLoopNodes->Node(InNode).MassFlowRateMin = 0.0;
MyEnvrnFlag(WindACNum) = false;
state.dataWindowAC->MyEnvrnFlag(WindACNum) = false;
} // end one time inits

if (!state.dataGlobal->BeginEnvrnFlag) {
MyEnvrnFlag(WindACNum) = true;
state.dataWindowAC->MyEnvrnFlag(WindACNum) = true;
}

if (state.dataWindowAC->WindAC(WindACNum).FanSchedPtr > 0) {
Expand Down
Loading

0 comments on commit 6799a8c

Please sign in to comment.