Skip to content

Commit

Permalink
moving DataEnvironment to state
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchute committed Dec 1, 2020
1 parent 4ee0928 commit 9064783
Show file tree
Hide file tree
Showing 175 changed files with 1,017 additions and 1,050 deletions.
4 changes: 2 additions & 2 deletions src/EnergyPlus/AirLoopHVACDOAS.cc
Original file line number Diff line number Diff line change
Expand Up @@ -930,14 +930,14 @@ namespace AirLoopHVACDOAS {
this->GetDesignDayConditions(state);

if (this->m_FanIndex > -1 && this->m_FanTypeNum == SimAirServingZones::Fan_System_Object) {
HVACFan::fanObjs[this->m_FanIndex]->designAirVolFlowRate = sizingMassFlow / DataEnvironment::StdRhoAir;
HVACFan::fanObjs[this->m_FanIndex]->designAirVolFlowRate = sizingMassFlow / state.dataEnvrn->StdRhoAir;
DataLoopNode::Node(this->m_FanInletNodeNum).MassFlowRateMaxAvail = sizingMassFlow;
DataLoopNode::Node(this->m_FanOutletNodeNum).MassFlowRateMaxAvail = sizingMassFlow;
DataLoopNode::Node(this->m_FanOutletNodeNum).MassFlowRateMax = sizingMassFlow;
}
bool errorsFound = false;
if (this->m_FanIndex > 0 && this->m_FanTypeNum == SimAirServingZones::Fan_ComponentModel) {
Fans::SetFanData(state, this->m_FanIndex, errorsFound, Name, sizingMassFlow / DataEnvironment::StdRhoAir, 0);
Fans::SetFanData(state, this->m_FanIndex, errorsFound, Name, sizingMassFlow / state.dataEnvrn->StdRhoAir, 0);
Fans::Fan(this->m_FanIndex).MaxAirMassFlowRate = sizingMassFlow;
DataLoopNode::Node(this->m_FanInletNodeNum).MassFlowRateMaxAvail = sizingMassFlow;
DataLoopNode::Node(this->m_FanOutletNodeNum).MassFlowRateMaxAvail = sizingMassFlow;
Expand Down
5 changes: 2 additions & 3 deletions src/EnergyPlus/AirflowNetwork/src/Solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ namespace AirflowNetwork {
// USE STATEMENTS:

// Using/Aliasing
using DataEnvironment::StdBaroPress;
using DataSurfaces::Surface;

//std::vector<AirProperties> properties;
Expand Down Expand Up @@ -510,10 +509,10 @@ namespace AirflowNetwork {
}
// Compute zone air properties.
for (n = 1; n <= NetworkNumOfNodes; ++n) {
properties[n].density = AIRDENSITY(state, StdBaroPress + PZ(n), properties[n].temperature, properties[n].humidityRatio);
properties[n].density = AIRDENSITY(state, state.dataEnvrn->StdBaroPress + PZ(n), properties[n].temperature, properties[n].humidityRatio);
// RHOZ(n) = PsyRhoAirFnPbTdbW(StdBaroPress + PZ(n), TZ(n), WZ(n));
if (AirflowNetworkNodeData(n).ExtNodeNum > 0) {
properties[n].density = AIRDENSITY(state, StdBaroPress + PZ(n), state.dataEnvrn->OutDryBulbTemp, state.dataEnvrn->OutHumRat);
properties[n].density = AIRDENSITY(state, state.dataEnvrn->StdBaroPress + PZ(n), state.dataEnvrn->OutDryBulbTemp, state.dataEnvrn->OutHumRat);
properties[n].temperature = state.dataEnvrn->OutDryBulbTemp;
properties[n].humidityRatio = state.dataEnvrn->OutHumRat;
}
Expand Down
22 changes: 10 additions & 12 deletions src/EnergyPlus/AirflowNetworkBalanceManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ namespace AirflowNetworkBalanceManager {
using DataEnvironment::CurMnDy;
using DataEnvironment::EnvironmentName;
using DataEnvironment::OutDryBulbTempAt;
using DataEnvironment::StdBaroPress;
using DataEnvironment::StdRhoAir;
using DataHeatBalance::TotCrossMixing;
using DataHeatBalance::TotInfiltration;
using DataHeatBalance::TotMixing;
Expand Down Expand Up @@ -305,7 +303,7 @@ namespace AirflowNetworkBalanceManager {
if (AirflowNetworkFanActivated && SimulateAirflowNetwork > AirflowNetworkControlMultizone) {
if (state.dataAirflowNetworkBalanceManager->ValidateDistributionSystemFlag) {
ValidateDistributionSystem(state);
ValidateFanFlowRate();
ValidateFanFlowRate(state);
state.dataAirflowNetworkBalanceManager->ValidateDistributionSystemFlag = false;
}
}
Expand Down Expand Up @@ -363,13 +361,13 @@ namespace AirflowNetworkBalanceManager {
Real64 pressure(101325.0);
if (fields.find("reference_barometric_pressure") != fields.end()) { // not required field, has default value
pressure = fields.at("reference_barometric_pressure");
if (std::abs((pressure - StdBaroPress) / StdBaroPress) > 0.1) { // 10% off
if (std::abs((pressure - state.dataEnvrn->StdBaroPress) / state.dataEnvrn->StdBaroPress) > 0.1) { // 10% off
ShowWarningError(state,
format("{}: {}: Pressure = {:.0R} differs by more than 10% from Standard Barometric Pressure = {:.0R}.",
RoutineName,
CurrentModuleObject,
pressure,
StdBaroPress));
state.dataEnvrn->StdBaroPress));
ShowContinueError(state, "...occurs in " + CurrentModuleObject + " = " + thisObjectName);
}
if (pressure <= 31000.0) {
Expand Down Expand Up @@ -480,7 +478,7 @@ namespace AirflowNetworkBalanceManager {
Real64 flowRate;

GetFanVolFlow(fanIndex, flowRate);
flowRate *= StdRhoAir;
flowRate *= state.dataEnvrn->StdRhoAir;
bool nodeErrorsFound{false};
int inletNode = GetFanInletNode(state, "Fan:ZoneExhaust", thisObjectName, nodeErrorsFound);
int outletNode = GetFanOutletNode(state, "Fan:ZoneExhaust", thisObjectName, nodeErrorsFound);
Expand Down Expand Up @@ -1141,7 +1139,7 @@ namespace AirflowNetworkBalanceManager {

DisSysCompELRData(i).name = thisObjectName; // Name of duct effective leakage ratio component
DisSysCompELRData(i).ELR = elr; // Value of effective leakage ratio
DisSysCompELRData(i).FlowRate = maxflow * StdRhoAir; // Maximum airflow rate
DisSysCompELRData(i).FlowRate = maxflow * state.dataEnvrn->StdRhoAir; // Maximum airflow rate
DisSysCompELRData(i).RefPres = dp; // Reference pressure difference
DisSysCompELRData(i).FlowExpo = expnt; // Air Mass Flow exponent

Expand Down Expand Up @@ -1273,7 +1271,7 @@ namespace AirflowNetworkBalanceManager {
success = false;
} else {
flowRate = HVACFan::fanObjs[fanIndex]->designAirVolFlowRate;
flowRate *= StdRhoAir;
flowRate *= state.dataEnvrn->StdRhoAir;
DisSysCompCVFData(i).FanModelFlag = true;
inletNode = HVACFan::fanObjs[fanIndex]->inletNodeNum;
outletNode = HVACFan::fanObjs[fanIndex]->outletNodeNum;
Expand All @@ -1296,7 +1294,7 @@ namespace AirflowNetworkBalanceManager {
}

GetFanVolFlow(fanIndex, flowRate);
flowRate *= StdRhoAir;
flowRate *= state.dataEnvrn->StdRhoAir;

GetFanType(state, fan_name, fanType_Num, FanErrorFound);
state.dataAirflowNetworkBalanceManager->SupplyFanType = fanType_Num;
Expand Down Expand Up @@ -10284,7 +10282,7 @@ namespace AirflowNetworkBalanceManager {
}
}

void ValidateFanFlowRate()
void ValidateFanFlowRate(EnergyPlusData &state)
{

// Catch a fan flow rate from EPlus input file and add a flag for VAV terminal damper
Expand All @@ -10296,11 +10294,11 @@ namespace AirflowNetworkBalanceManager {
if (DisSysCompCVFData(typeNum).FanTypeNum == FanType_SimpleVAV) {
if (DisSysCompCVFData(typeNum).FanModelFlag) {
DisSysCompCVFData(typeNum).MaxAirMassFlowRate =
HVACFan::fanObjs[DisSysCompCVFData(typeNum).FanIndex]->designAirVolFlowRate * StdRhoAir;
HVACFan::fanObjs[DisSysCompCVFData(typeNum).FanIndex]->designAirVolFlowRate * state.dataEnvrn->StdRhoAir;
} else {
Real64 FanFlow; // Return type
GetFanVolFlow(DisSysCompCVFData(typeNum).FanIndex, FanFlow);
DisSysCompCVFData(typeNum).MaxAirMassFlowRate = FanFlow * StdRhoAir;
DisSysCompCVFData(typeNum).MaxAirMassFlowRate = FanFlow * state.dataEnvrn->StdRhoAir;
}
}
} else if (SELECT_CASE_var == CompTypeNum_FAN) { //'FAN'
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/AirflowNetworkBalanceManager.hh
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ namespace AirflowNetworkBalanceManager {

void ValidateDistributionSystem(EnergyPlusData &state);

void ValidateFanFlowRate(); // Catch a fan flow rate from EPlus input file and add a flag for VAV terminal damper
void ValidateFanFlowRate(EnergyPlusData &state); // Catch a fan flow rate from EPlus input file and add a flag for VAV terminal damper

void ValidateExhaustFanInput(EnergyPlusData &state);

Expand Down
9 changes: 5 additions & 4 deletions src/EnergyPlus/Autosizing/All_Simple_Sizing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
// POSSIBILITY OF SUCH DAMAGE.

#include <EnergyPlus/Autosizing/All_Simple_Sizing.hh>
#include <EnergyPlus/Data/EnergyPlusData.hh>
#include <EnergyPlus/DataEnvironment.hh>
#include <EnergyPlus/DesiccantDehumidifiers.hh>
#include <EnergyPlus/General.hh>
Expand Down Expand Up @@ -160,7 +161,7 @@ Real64 ASHRAEMinSATCoolingSizer::size(EnergyPlusData &state, Real64 _originalVal
if (this->dataCapacityUsedForSizing > 0.0 && this->dataFlowUsedForSizing > 0.0) {
this->autoSizedValue =
this->finalZoneSizing(this->curZoneEqNum).ZoneTempAtCoolPeak -
(this->dataCapacityUsedForSizing / (this->dataFlowUsedForSizing * DataEnvironment::StdRhoAir *
(this->dataCapacityUsedForSizing / (this->dataFlowUsedForSizing * state.dataEnvrn->StdRhoAir *
Psychrometrics::PsyCpAirFnW(this->finalZoneSizing(this->curZoneEqNum).ZoneHumRatAtCoolPeak)));
} else {
this->errorType = AutoSizingResultType::ErrorType1;
Expand All @@ -183,7 +184,7 @@ Real64 ASHRAEMinSATCoolingSizer::size(EnergyPlusData &state, Real64 _originalVal
if (this->dataCapacityUsedForSizing > 0.0 && this->dataFlowUsedForSizing > 0.0 && this->dataZoneUsedForSizing > 0) {
this->autoSizedValue = this->finalZoneSizing(this->dataZoneUsedForSizing).ZoneTempAtCoolPeak -
(this->dataCapacityUsedForSizing /
(this->dataFlowUsedForSizing * DataEnvironment::StdRhoAir *
(this->dataFlowUsedForSizing * state.dataEnvrn->StdRhoAir *
Psychrometrics::PsyCpAirFnW(this->finalZoneSizing(this->dataZoneUsedForSizing).ZoneHumRatAtCoolPeak)));
} else {
this->errorType = AutoSizingResultType::ErrorType1;
Expand Down Expand Up @@ -219,7 +220,7 @@ Real64 ASHRAEMaxSATHeatingSizer::size(EnergyPlusData &state, Real64 _originalVal
if (this->dataCapacityUsedForSizing > 0.0 && this->dataFlowUsedForSizing > 0.0) {
this->autoSizedValue =
this->finalZoneSizing(this->curZoneEqNum).ZoneTempAtHeatPeak +
(this->dataCapacityUsedForSizing / (this->dataFlowUsedForSizing * DataEnvironment::StdRhoAir *
(this->dataCapacityUsedForSizing / (this->dataFlowUsedForSizing * state.dataEnvrn->StdRhoAir *
Psychrometrics::PsyCpAirFnW(this->finalZoneSizing(this->curZoneEqNum).ZoneHumRatAtHeatPeak)));
} else {
this->errorType = AutoSizingResultType::ErrorType1;
Expand All @@ -242,7 +243,7 @@ Real64 ASHRAEMaxSATHeatingSizer::size(EnergyPlusData &state, Real64 _originalVal
if (this->dataCapacityUsedForSizing > 0.0 && this->dataFlowUsedForSizing > 0.0 && this->dataZoneUsedForSizing > 0) {
this->autoSizedValue = this->finalZoneSizing(this->dataZoneUsedForSizing).ZoneTempAtHeatPeak +
(this->dataCapacityUsedForSizing /
(this->dataFlowUsedForSizing * DataEnvironment::StdRhoAir *
(this->dataFlowUsedForSizing * state.dataEnvrn->StdRhoAir *
Psychrometrics::PsyCpAirFnW(this->finalZoneSizing(this->dataZoneUsedForSizing).ZoneHumRatAtHeatPeak)));
} else {
this->errorType = AutoSizingResultType::ErrorType1;
Expand Down
4 changes: 4 additions & 0 deletions src/EnergyPlus/Autosizing/All_Simple_Sizing.hh
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,13 @@
#define All_Simple_Sizing_hh_INCLUDED

#include <EnergyPlus/Autosizing/Base.hh>
#include <EnergyPlus/Data/BaseData.hh>

namespace EnergyPlus {

// Forward declarations
struct EnergyPlusData;

struct AutoCalculateSizer : BaseSizer
{
AutoCalculateSizer()
Expand Down
8 changes: 4 additions & 4 deletions src/EnergyPlus/Autosizing/Base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void BaseSizer::initializeWithinEP(EnergyPlusData &state,
this->isEpJSON = state.dataGlobal->isEpJSON;
this->printWarningFlag = _printWarningFlag;
this->callingRoutine = _callingRoutine;
this->stdRhoAir = DataEnvironment::StdRhoAir;
this->stdRhoAir = state.dataEnvrn->StdRhoAir;
this->sysSizingRunDone = DataSizing::SysSizingRunDone;
this->zoneSizingRunDone = DataSizing::ZoneSizingRunDone;
this->curSysNum = DataSizing::CurSysNum;
Expand Down Expand Up @@ -620,16 +620,16 @@ void BaseSizer::overrideSizingString(std::string &string)
this->overrideSizeString = false;
}

Real64 BaseSizer::setOAFracForZoneEqSizing(Real64 const &desMassFlow, DataSizing::ZoneEqSizingData const &zoneEqSizing)
Real64 BaseSizer::setOAFracForZoneEqSizing(EnergyPlusData &state, Real64 const &desMassFlow, DataSizing::ZoneEqSizingData const &zoneEqSizing)
{
Real64 outAirFrac = 0.0;
if (desMassFlow <= 0.0) return outAirFrac;

if (zoneEqSizing.ATMixerVolFlow > 0.0) {
// set central DOAS AT mixer OA fraction
outAirFrac = min(DataEnvironment::StdRhoAir * zoneEqSizing.ATMixerVolFlow / desMassFlow, 1.0);
outAirFrac = min(state.dataEnvrn->StdRhoAir * zoneEqSizing.ATMixerVolFlow / desMassFlow, 1.0);
} else if (zoneEqSizing.OAVolFlow > 0.0) { // set zone equipment OA fraction
outAirFrac = min(DataEnvironment::StdRhoAir * zoneEqSizing.OAVolFlow / desMassFlow, 1.0);
outAirFrac = min(state.dataEnvrn->StdRhoAir * zoneEqSizing.OAVolFlow / desMassFlow, 1.0);
}
return outAirFrac;
}
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/Autosizing/Base.hh
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public:
Optional_string_const UsrDesc = _,
Optional<Real64 const> UsrValue = _);

Real64 setOAFracForZoneEqSizing(Real64 const &desMassFlow, DataSizing::ZoneEqSizingData const &zoneEqSizing);
Real64 setOAFracForZoneEqSizing(EnergyPlusData &state, Real64 const &desMassFlow, DataSizing::ZoneEqSizingData const &zoneEqSizing);
Real64 setHeatCoilInletTempForZoneEqSizing(Real64 const &outAirFrac,
DataSizing::ZoneEqSizingData const &zoneEqSizing,
DataSizing::ZoneSizingData const &finalZoneSizing);
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/Autosizing/CoolingAirFlowSizing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ Real64 CoolingAirFlowSizer::size(EnergyPlusData &state, Real64 _originalValue, b
this->autoSizedValue = this->oaSysEqSizing(this->curOASysNum).CoolingAirVolFlow;
} else if (outsideAirSys(this->curOASysNum).AirLoopDOASNum > -1) {
this->autoSizedValue = this->airloopDOAS[outsideAirSys(this->curOASysNum).AirLoopDOASNum].SizingMassFlow /
DataEnvironment::StdRhoAir;
state.dataEnvrn->StdRhoAir;
} else {
this->autoSizedValue = this->finalSysSizing(this->curSysNum).DesOutAirVolFlow;
}
Expand Down
Loading

5 comments on commit 9064783

@nrel-bot-3
Copy link

Choose a reason for hiding this comment

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

global_dataEnvironment (mitchute) - x86_64-MacOS-10.15-clang-11.0.0: OK (2994 of 2994 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

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

global_dataEnvironment (mitchute) - x86_64-Linux-Ubuntu-18.04-gcc-7.5-UnitTestsCoverage-Debug: OK (1558 of 1558 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

@nrel-bot-2b
Copy link

Choose a reason for hiding this comment

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

global_dataEnvironment (mitchute) - x86_64-Linux-Ubuntu-18.04-gcc-7.5: OK (3034 of 3034 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

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

global_dataEnvironment (mitchute) - Win64-Windows-10-VisualStudio-16: OK (2250 of 2250 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

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

global_dataEnvironment (mitchute) - x86_64-Linux-Ubuntu-18.04-gcc-7.5-IntegrationCoverage-Debug: Coverage Too Low

Failures:\n

integration Test Summary

  • Passed: 721
  • Timeout: 1

Build Badge Test Badge Coverage Badge

Please sign in to comment.