Skip to content

Commit

Permalink
Merge pull request #8668 from NREL/FinalGroundingAndDeglobalizing
Browse files Browse the repository at this point in the history
Final grounding and deglobalizing
  • Loading branch information
Myoldmopar committed Mar 30, 2021
2 parents d9eaa42 + 8c9dcac commit c38a032
Show file tree
Hide file tree
Showing 279 changed files with 3,836 additions and 4,328 deletions.
18 changes: 9 additions & 9 deletions src/EnergyPlus/AirLoopHVACDOAS.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ namespace AirLoopHVACDOAS {
std::string cCurrentModuleObject = "AirLoopHVAC:Mixer";
std::string cFieldName;

auto const instances = inputProcessor->epJSON.find(cCurrentModuleObject);
if (instances == inputProcessor->epJSON.end()) {
auto const instances = state.dataInputProcessing->inputProcessor->epJSON.find(cCurrentModuleObject);
if (instances == state.dataInputProcessing->inputProcessor->epJSON.end()) {
errorsFound = true;
} else {
int AirLoopMixerNum = 0;
Expand All @@ -153,7 +153,7 @@ namespace AirLoopHVACDOAS {

auto const &fields = instance.value();
auto const &thisObjectName = instance.key();
inputProcessor->markObjectAsUsed(cCurrentModuleObject, thisObjectName);
state.dataInputProcessing->inputProcessor->markObjectAsUsed(cCurrentModuleObject, thisObjectName);
++AirLoopMixerNum;
AirLoopMixer thisMixer;

Expand Down Expand Up @@ -298,8 +298,8 @@ namespace AirLoopHVACDOAS {
std::string cCurrentModuleObject = "AirLoopHVAC:Splitter";
std::string cFieldName;

auto const instances = inputProcessor->epJSON.find(cCurrentModuleObject);
if (instances == inputProcessor->epJSON.end()) {
auto const instances = state.dataInputProcessing->inputProcessor->epJSON.find(cCurrentModuleObject);
if (instances == state.dataInputProcessing->inputProcessor->epJSON.end()) {
errorsFound = true;
} else {
int AirLoopSplitterNum = 0;
Expand All @@ -308,7 +308,7 @@ namespace AirLoopHVACDOAS {

auto const &fields = instance.value();
auto const &thisObjectName = instance.key();
inputProcessor->markObjectAsUsed(cCurrentModuleObject, thisObjectName);
state.dataInputProcessing->inputProcessor->markObjectAsUsed(cCurrentModuleObject, thisObjectName);

++AirLoopSplitterNum;
AirLoopSplitter thisSplitter;
Expand Down Expand Up @@ -356,8 +356,8 @@ namespace AirLoopHVACDOAS {
std::string cCurrentModuleObject = "AirLoopHVAC:DedicatedOutdoorAirSystem";
std::string cFieldName;

auto const instances = inputProcessor->epJSON.find(cCurrentModuleObject);
if (instances == inputProcessor->epJSON.end()) {
auto const instances = state.dataInputProcessing->inputProcessor->epJSON.find(cCurrentModuleObject);
if (instances == state.dataInputProcessing->inputProcessor->epJSON.end()) {
errorsFound = true;
} else {
int AirLoopDOASNum = 0;
Expand All @@ -366,7 +366,7 @@ namespace AirLoopHVACDOAS {

auto const &fields = instance.value();
auto const &thisObjectName = instance.key();
inputProcessor->markObjectAsUsed(cCurrentModuleObject, thisObjectName);
state.dataInputProcessing->inputProcessor->markObjectAsUsed(cCurrentModuleObject, thisObjectName);
++AirLoopDOASNum;
AirLoopDOAS thisDOAS;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1613,10 +1613,6 @@ namespace AirflowNetwork {
}
};

// Object Data

void clear_state();

} // namespace AirflowNetwork

struct AirflowNetworkData : BaseGlobalStruct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@

// EnergyPlus Headers
#include <EnergyPlus/EnergyPlus.hh>
#include <EnergyPlus/Data/BaseData.hh>

namespace EnergyPlus {

Expand All @@ -79,9 +80,6 @@ struct EnergyPlusData;

namespace AirflowNetwork {

extern int lowerLimitErrIdx;
extern int upperLimitErrIdx;

Real64 airThermConductivity(EnergyPlusData &state, Real64 T // Temperature in Celsius
);

Expand All @@ -105,6 +103,15 @@ namespace AirflowNetwork {

} // namespace AirflowNetwork

struct DataAFNProps : BaseGlobalStruct {
int lowerLimitErrIdx = 0;
int upperLimitErrIdx = 0;
void clear_state() override {
lowerLimitErrIdx = 0;
upperLimitErrIdx = 0;
}
};

} // namespace EnergyPlus

#endif
88 changes: 73 additions & 15 deletions src/EnergyPlus/AirflowNetwork/include/AirflowNetwork/Solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@

#include "AirflowNetwork/Properties.hpp"

#include <EnergyPlus/Data/BaseData.hh>

namespace EnergyPlus {

// Forward declarations
Expand All @@ -66,6 +68,8 @@ struct EnergyPlusData;

namespace AirflowNetwork {

int constexpr NrInt = 20; // Number of intervals for a large opening

struct AirProperties
{
Real64 temperature{20.0};
Expand Down Expand Up @@ -167,18 +171,6 @@ namespace AirflowNetwork {
Array1D<Real64> SUMF;
};

// Data
extern int NetworkNumOfLinks;
extern int NetworkNumOfNodes;

extern int const NrInt; // Number of intervals for a large opening

// Large opening variables
extern Array1D<Real64> DpProf; // Differential pressure profile for Large Openings [Pa]
extern Array1D<Real64> RhoProfF; // Density profile in FROM zone [kg/m3]
extern Array1D<Real64> RhoProfT; // Density profile in TO zone [kg/m3]
extern Array2D<Real64> DpL; // Array of stack pressures in link

// Functions

int GenericCrack(EnergyPlusData &state, Real64 &coef, // Flow coefficient
Expand Down Expand Up @@ -209,7 +201,7 @@ namespace AirflowNetwork {
int const NSYM // symmetry: 0 = symmetric matrix, 1 = non-symmetric
);

void SLVSKY(const Array1D<Real64> &AU, // the upper triangle of [A] before and after factoring
void SLVSKY(EnergyPlusData &state, const Array1D<Real64> &AU, // the upper triangle of [A] before and after factoring
const Array1D<Real64> &AD, // the main diagonal of [A] before and after factoring
const Array1D<Real64> &AL, // the lower triangle of [A] before and after factoring
Array1D<Real64> &B, // "B" vector (input); "X" vector (output).
Expand All @@ -218,7 +210,7 @@ namespace AirflowNetwork {
int const NSYM // symmetry: 0 = symmetric matrix, 1 = non-symmetric
);

void FILSKY(const Array1D<Real64> &X, // element array (row-wise sequence)
void FILSKY(EnergyPlusData &state, const Array1D<Real64> &X, // element array (row-wise sequence)
std::array<int, 2> const LM, // location matrix
const Array1D_int &IK, // pointer to the top of column/row "K"
Array1D<Real64> &AU, // the upper triangle of [A] before and after factoring
Expand Down Expand Up @@ -280,7 +272,73 @@ namespace AirflowNetwork {

} // namespace AirflowNetwork

extern AirflowNetwork::Solver solver;
struct AirflowNetworkSolverData : BaseGlobalStruct {
AirflowNetwork::Solver solver;

// Data
int NetworkNumOfLinks = 0;
int NetworkNumOfNodes = 0;

// Common block AFEDAT
Array1D<Real64> AFECTL;
Array1D<Real64> AFLOW2;
Array1D<Real64> AFLOW;
Array1D<Real64> PS;
Array1D<Real64> PW;

// Common block CONTRL
Real64 PB = 0.0;
int LIST = 0;

// Common block ZONL
// Array1D<Real64> RHOZ;
// Array1D<Real64> SQRTDZ;
// Array1D<Real64> VISCZ;
Array1D<Real64> SUMAF;
// Array1D<Real64> TZ; // Temperature [C]
// Array1D<Real64> WZ; // Humidity ratio [kg/kg]
Array1D<Real64> PZ; // Pressure [Pa]

// Other array variables
Array1D_int ID;
Array1D_int IK;
Array1D<Real64> AD;
Array1D<Real64> AU;

#ifdef SKYLINE_MATRIX_REMOVE_ZERO_COLUMNS
Array1D_int newIK; // noel
Array1D<Real64> newAU; // noel
#endif

// REAL(r64), ALLOCATABLE, DIMENSION(:) :: AL
Array1D<Real64> SUMF;

// Large opening variables
Array1D<Real64> DpProf; // Differential pressure profile for Large Openings [Pa]
Array1D<Real64> RhoProfF; // Density profile in FROM zone [kg/m3]
Array1D<Real64> RhoProfT; // Density profile in TO zone [kg/m3]
Array2D<Real64> DpL; // Array of stack pressures in link

void clear_state() override {
NetworkNumOfLinks = 0;
NetworkNumOfNodes = 0;
AFECTL.clear();
AFLOW2.clear();
AFLOW.clear();
PS.clear();
PW.clear();
PB = 0.0;
LIST = 0;
SUMAF.clear();
PZ.clear();
ID.clear();
IK.clear();
AD.clear();
AU.clear();
solver.clear();
}

};

} // namespace EnergyPlus

Expand Down
40 changes: 15 additions & 25 deletions src/EnergyPlus/AirflowNetwork/src/Elements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ namespace AirflowNetwork {


// Crack standard condition from given inputs
if (i > NetworkNumOfLinks - state.dataAirflowNetwork->NumOfLinksIntraZone) {
if (i > state.dataAFNSolver->NetworkNumOfLinks - state.dataAirflowNetwork->NumOfLinksIntraZone) {
Corr = 1.0;
} else {
Corr = state.dataAirflowNetwork->MultizoneSurfaceData(i).Factor;
Expand Down Expand Up @@ -876,7 +876,7 @@ namespace AirflowNetwork {
// Check VAV termals with a damper
SumTermFlow = 0.0;
SumFracSuppLeak = 0.0;
for (k = 1; k <= NetworkNumOfLinks; ++k) {
for (k = 1; k <= state.dataAFNSolver->NetworkNumOfLinks; ++k) {
if (state.dataAirflowNetwork->AirflowNetworkLinkageData(k).VAVTermDamper && state.dataAirflowNetwork->AirflowNetworkLinkageData(k).AirLoopNum == AirLoopNum) {
k1 = state.dataAirflowNetwork->AirflowNetworkNodeData(state.dataAirflowNetwork->AirflowNetworkLinkageData(k).NodeNums[0]).EPlusNodeNum;
if (state.dataLoopNodes->Node(k1).MassFlowRate > 0.0) {
Expand Down Expand Up @@ -956,7 +956,7 @@ namespace AirflowNetwork {


int NumCur = n;

auto & solver = state.dataAFNSolver->solver;
if (solver.AFECTL(i) <= 0.0) {
// Speed = 0; treat fan as resistance.
return GenericCrack(state, FlowCoef, FlowExpo, LFLAG, PDROP, propN, propM, F, DF);
Expand Down Expand Up @@ -1201,7 +1201,7 @@ namespace AirflowNetwork {
// static gio::Fmt Format_901("(A5,I3,6X,4E16.7)");



auto & solver = state.dataAFNSolver->solver;
C = solver.AFECTL(i);
if (C < FlowMin) C = FlowMin;
if (C > FlowMax) C = FlowMax;
Expand Down Expand Up @@ -1631,7 +1631,7 @@ namespace AirflowNetwork {

// calculate DpProfNew
for (i = 1; i <= NrInt + 2; ++i) {
DpProfNew(i) = PDROP + DpProf(Loc + i) - DpL(IL, 1);
DpProfNew(i) = PDROP + state.dataAFNSolver->DpProf(Loc + i) - state.dataAFNSolver->DpL(IL, 1);
}

// Get opening data based on the opening factor
Expand Down Expand Up @@ -1787,20 +1787,20 @@ namespace AirflowNetwork {
for (i = 2; i <= NrInt + 1; ++i) {
if (DpProfNew(i) > 0) {
if (std::abs(DpProfNew(i)) <= DpZeroOffset) {
dfmasum = std::sqrt(RhoProfF(Loc + i) * DpZeroOffset) / DpZeroOffset;
dfmasum = std::sqrt(state.dataAFNSolver->RhoProfF(Loc + i) * DpZeroOffset) / DpZeroOffset;
fmasum = DpProfNew(i) * dfmasum;
} else {
fmasum = std::sqrt(RhoProfF(Loc + i) * DpProfNew(i));
fmasum = std::sqrt(state.dataAFNSolver->RhoProfF(Loc + i) * DpProfNew(i));
dfmasum = 0.5 * fmasum / DpProfNew(i);
}
fma12 += fmasum;
dp1fma12 += dfmasum;
} else {
if (std::abs(DpProfNew(i)) <= DpZeroOffset) {
dfmasum = -std::sqrt(RhoProfT(Loc + i) * DpZeroOffset) / DpZeroOffset;
dfmasum = -std::sqrt(state.dataAFNSolver->RhoProfT(Loc + i) * DpZeroOffset) / DpZeroOffset;
fmasum = DpProfNew(i) * dfmasum;
} else {
fmasum = std::sqrt(-RhoProfT(Loc + i) * DpProfNew(i));
fmasum = std::sqrt(-state.dataAFNSolver->RhoProfT(Loc + i) * DpProfNew(i));
dfmasum = 0.5 * fmasum / DpProfNew(i);
}
fma21 += fmasum;
Expand Down Expand Up @@ -1840,9 +1840,9 @@ namespace AirflowNetwork {
// Calculation of massflow and its derivative
for (i = 2; i <= NrInt + 1; ++i) {
if (DpProfNew(i) > 0) {
rholink = RhoProfF(Loc + i);
rholink = state.dataAFNSolver->RhoProfF(Loc + i);
} else {
rholink = RhoProfT(Loc + i);
rholink = state.dataAFNSolver->RhoProfT(Loc + i);
}

if ((EvalHghts(i) <= h2) || (EvalHghts(i) >= h4)) {
Expand Down Expand Up @@ -1897,9 +1897,9 @@ namespace AirflowNetwork {
for (i = 2; i <= NrInt + 1; ++i) {
rholink = 0.0;
if (DpProfNew(i) > 0) {
rholink = RhoProfF(Loc + i);
rholink = state.dataAFNSolver->RhoProfF(Loc + i);
} else {
rholink = RhoProfT(Loc + i);
rholink = state.dataAFNSolver->RhoProfT(Loc + i);
}
rholink /= NrInt;
rholink = 1.2;
Expand Down Expand Up @@ -2102,7 +2102,7 @@ namespace AirflowNetwork {

int n = state.dataAirflowNetwork->AirflowNetworkLinkageData(i).NodeNums[0];
int m = state.dataAirflowNetwork->AirflowNetworkLinkageData(i).NodeNums[1];

auto & solver = state.dataAFNSolver->solver;

// Get component properties
// A = Cross section area [m2]
Expand All @@ -2112,7 +2112,7 @@ namespace AirflowNetwork {
F[0] = std::sqrt(2.0 * propN.density) * A * std::sqrt(DP);
DF[0] = 0.5 * F[0] / DP;
} else {
for (k = 1; k <= NetworkNumOfLinks; ++k) {
for (k = 1; k <= state.dataAFNSolver->NetworkNumOfLinks; ++k) {
if (state.dataAirflowNetwork->AirflowNetworkLinkageData(k).NodeNums[1] == n) {
F[0] = solver.AFLOW(k);
break;
Expand Down Expand Up @@ -3671,16 +3671,6 @@ namespace AirflowNetwork {
return 1;
}

void clear_state()
{
//AirflowNetworkExchangeData.deallocate();
//AirflowNetworkMultiExchangeData.deallocate();
//AirflowNetworkLinkReport.deallocate();
//AirflowNetworkNodeReport.deallocate();
//AirflowNetworkLinkReport1.deallocate();
lowerLimitErrIdx = 0;
upperLimitErrIdx = 0;
}

} // namespace AirflowNetwork

Expand Down
Loading

5 comments on commit c38a032

@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.

develop (Myoldmopar) - x86_64-Linux-Ubuntu-18.04-gcc-7.5: OK (2378 of 2378 tests passed, 0 test warnings)

Build Badge Test Badge

@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.

develop (Myoldmopar) - x86_64-MacOS-10.15-clang-11.0.0: OK (2358 of 2358 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.

develop (Myoldmopar) - x86_64-Linux-Ubuntu-18.04-gcc-7.5-UnitTestsCoverage-Debug: OK (1634 of 1634 tests passed, 0 test warnings)

Build Badge Test Badge Coverage 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.

develop (Myoldmopar) - Win64-Windows-10-VisualStudio-16: OK (2329 of 2329 tests passed, 0 test warnings)

Build Badge Test 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.

develop (Myoldmopar) - x86_64-Linux-Ubuntu-18.04-gcc-7.5-IntegrationCoverage-Debug: OK (726 of 727 tests passed, 0 test warnings)

Failures:\n

integration Test Summary

  • Passed: 726
  • Timeout: 1

Build Badge Test Badge Coverage Badge

Please sign in to comment.