Skip to content
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

Exclude air boundaries and non-used constructions in conduction finite difference #8594

Merged
merged 6 commits into from
Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/EnergyPlus/EvaporativeCoolers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2801,7 +2801,7 @@ namespace EvaporativeCoolers {
auto &EvapCond(state.dataEvapCoolers->EvapCond);

EvapCoolIndex = int(Par(1));
DryOrWetOperatingMode = OperatingMode(Par(2));
DryOrWetOperatingMode = OperatingMode(int(Par(2)));
SysTempSetPoint = Par(3);
EDBTSecAirSide = Par(4);
EWBTSecAirSide = Par(5);
Expand Down
3 changes: 3 additions & 0 deletions src/EnergyPlus/HeatBalFiniteDiffManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,7 @@ namespace HeatBalFiniteDiffManager {
for (ConstrNum = 1; ConstrNum <= state.dataHeatBal->TotConstructs; ++ConstrNum) {
// Need to skip window constructions and eventually window materials
if (state.dataConstruction->Construct(ConstrNum).TypeIsWindow) continue;
if (!state.dataConstruction->Construct(ConstrNum).IsUsed) continue;

ConstructFD(ConstrNum).Name.allocate(state.dataConstruction->Construct(ConstrNum).TotLayers);
ConstructFD(ConstrNum).Thickness.allocate(state.dataConstruction->Construct(ConstrNum).TotLayers);
Expand Down Expand Up @@ -1293,6 +1294,8 @@ namespace HeatBalFiniteDiffManager {

if (state.dataConstruction->Construct(ThisNum).TypeIsWindow) continue;
if (state.dataConstruction->Construct(ThisNum).TypeIsIRT) continue;
if (state.dataConstruction->Construct(ThisNum).TypeIsAirBoundary) continue;
if (!state.dataConstruction->Construct(ThisNum).IsUsed) continue;
Copy link
Member

Choose a reason for hiding this comment

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

The logic changes seem fine.


static constexpr auto Format_700(" Construction CondFD,{},{},{},{},{:.6R}\n");
print(state.files.eio,
Expand Down
116 changes: 115 additions & 1 deletion tst/EnergyPlus/unit/HeatBalFiniteDiffManager.unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,19 @@
#include <gtest/gtest.h>

// EnergyPlus Headers
#include <EnergyPlus/Construction.hh>
#include <EnergyPlus/Data/EnergyPlusData.hh>
#include <EnergyPlus/DataHeatBalSurface.hh>
#include <EnergyPlus/HeatBalFiniteDiffManager.hh>
#include <EnergyPlus/HeatBalanceManager.hh>
#include <EnergyPlus/Material.hh>
#include <EnergyPlus/PhaseChangeModeling/HysteresisModel.hh>

#include "Fixtures/EnergyPlusFixture.hh"

using namespace EnergyPlus::HeatBalFiniteDiffManager;
using namespace EnergyPlus::HeatBalanceManager;


namespace EnergyPlus {

Expand Down Expand Up @@ -188,7 +192,7 @@ TEST_F(EnergyPlusFixture, HeatBalFiniteDiffManager_CalcNodeHeatFluxTest)
}

TEST_F(EnergyPlusFixture, HeatBalFiniteDiffManager_adjustPropertiesForPhaseChange)
{
{
// create a single PCM object in the input and process it
std::string const idf_objects = delimited_string(
{" MaterialProperty:PhaseChangeHysteresis,", " PCMNAME, !- Name",
Expand Down Expand Up @@ -233,4 +237,114 @@ TEST_F(EnergyPlusFixture, HeatBalFiniteDiffManager_adjustPropertiesForPhaseChang
SurfaceFD.deallocate();
}



TEST_F(EnergyPlusFixture, HeatBalFiniteDiffManager_skipNotUsedConstructionAndAirLayer)
{
bool ErrorsFound(false);
int thisConstructNum;
int thisTotalLayers;
// create three construction objects with one object not in use and another object assigned to surfaces, and one object as air wall.
std::string const idf_objects = delimited_string(
{
"Material,",
" MAT - CC05 4 HW CONCRETE, !- Name",
" Rough, !- Roughness",
" 0.1016, !- Thickness{ m }",
" 1.311, !- Conductivity{ W / m - K }",
" 2240, !- Density{ kg / m3 }",
" 836.800000000001, !- Specific Heat{ J / kg - K }",
" 0.9, !- Thermal Absorptance",
" 0.85, !- Solar Absorptance",
" 0.85; !- Visible Absorptance",
"Material:AirGap,",
" F05 Ceiling air space resistance, !- Name",
" 0.18; !- Thermal Resistance{ m2 - K / W }",
"Material:NoMass,",
" CP02 CARPET PAD, !- Name",
" Smooth, !- Roughness",
" 0.1, !- Thermal Resistance{ m2 - K / W }",
" 0.9, !- Thermal Absorptance",
" 0.8, !- Solar Absorptance",
" 0.8; !- Visible Absorptance",

"Material,",
" F16 Acoustic tile, !- Name",
" MediumSmooth, !- Roughness",
" 0.0191, !- Thickness{ m }",
" 0.06, !- Conductivity{ W / m - K }",
" 368, !- Density{ kg / m3 }",
" 590.000000000002, !- Specific Heat{ J / kg - K }",
" 0.9, !- Thermal Absorptance",
" 0.3, !- Solar Absorptance",
" 0.3; !- Visible Absorptance",

"Material,",
" M11 100mm lightweight concrete, !- Name",
" MediumRough, !- Roughness",
" 0.1016, !- Thickness{ m }",
" 0.53, !- Conductivity{ W / m - K }",
" 1280, !- Density{ kg / m3 }",
" 840.000000000002, !- Specific Heat{ J / kg - K }",
" 0.9, !- Thermal Absorptance",
" 0.5, !- Solar Absorptance",
" 0.5; !- Visible Absorptance",

"Construction,",
" ExtSlabCarpet 4in ClimateZone 1 - 8, !- Name",
" MAT - CC05 4 HW CONCRETE, !- Outside Layer",
" CP02 CARPET PAD; !- Layer 2",
"Construction,",
" Interior Floor, !- Name",
" F16 Acoustic tile, !- Outside Layer",
" F05 Ceiling air space resistance, !- Layer 2",
" M11 100mm lightweight concrete; !- Layer 3",
"Construction:AirBoundary,",
" Air Wall_ConstructionAirBoundary, !- Name",
" None, !- Air Exchange Method",
" 0; !- Simple Mixing Air Changes per Hour {1 / hr}", });


ASSERT_TRUE(process_idf(idf_objects));


ErrorsFound = false;
GetMaterialData(*state, ErrorsFound); // read material data
EXPECT_FALSE(ErrorsFound); // expect no errors

ErrorsFound = false;
GetConstructData(*state, ErrorsFound); // read construction data
EXPECT_FALSE(ErrorsFound); // expect no errors

// allocate properties for construction objects when it is used or not for building surfaces in the model

state->dataConstruction->Construct(1).IsUsed=false;
state->dataConstruction->Construct(2).IsUsed = true;
state->dataConstruction->Construct(3).IsUsed = true;

ConstructFD.allocate(1);

// verify whether air wall or construction not in use was excluded from finite difference method.
for (int ConstrNum = 1; ConstrNum <= 3; ++ConstrNum) {

if (state->dataConstruction->Construct(ConstrNum).TypeIsWindow) continue;
if (state->dataConstruction->Construct(ConstrNum).TypeIsIRT) continue;
if (state->dataConstruction->Construct(ConstrNum).TypeIsAirBoundary) continue;
if (!state->dataConstruction->Construct(ConstrNum).IsUsed) continue;
thisConstructNum = ConstrNum;
ConstructFD(1).Name.allocate(state->dataConstruction->Construct(ConstrNum).TotLayers);
thisTotalLayers = state->dataConstruction->Construct(thisConstructNum).TotLayers;

}
Copy link
Member

Choose a reason for hiding this comment

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

What is happening here? Where are you calling the E+ code to exercise your changes? It almost looks like you copied the code from inside E+ and put it in here. If that were the case, you'd need to modify this to just call the E+ code instead. If you have trouble calling the E+ code because it requires too much data to be set up prior to calling the function, then just put some of the modified logic into a smaller function that is easier to call.

Copy link
Contributor Author

@LipingWang LipingWang Mar 16, 2021

Choose a reason for hiding this comment

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

Thank you for your comments. I agree that directly calling the function for unit test is a better choice. The function under modification is ReportFiniteDiffInits(EnergyPlusData &state) for initialization of the finite difference calculation of each construction. I cannot figure out a way to directly call this function. So I put part of the code from the original function to run the test. Please feel free to suggest methods of calling this function or modification.

Copy link
Member

Choose a reason for hiding this comment

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

Take these four lines that are used to determine if a layer should be included or not:

image

  • Create a small method on the construction object named "shouldSkipForFiniteDifference". It performs the same series of checks and returns true if the construction should be skipped.
  • In the finite difference manager, replace all those lines with a call to that method on the construction object:
if (state.dataConstruction->Construct(ThisNum).shouldSkipForFiniteDifference()) continue;
  • Then your unit test can really just set up a construction object, no input objects required, and call that tiny little worker function under a series of cases and see if it returns true or not.

Done.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Edwin, after further looking into this, I was able to call and test the original function InitialInitHeatBalFiniteDiff. Please see the updated unit test. Thank you for your comments.


// check the values are correct

EXPECT_EQ(2, thisConstructNum);
EXPECT_EQ(3, thisTotalLayers);

// deallocate
ConstructFD.deallocate();
state->dataConstruction->Construct.deallocate();
}

} // namespace EnergyPlus