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

Refactoring of interpolation functions for blinds Prof and Slat Angle #8591

Merged
merged 30 commits into from
Mar 25, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2532651
partial commit
xuanluo113 Mar 4, 2021
57aa34f
slat angle
xuanluo113 Mar 5, 2021
04c0cbe
merge conflicts
xuanluo113 Mar 5, 2021
8e8c211
test remote
xuanluo113 Mar 6, 2021
34957ce
profile ang
xuanluo113 Mar 7, 2021
1d74547
prof-slat angle
xuanluo113 Mar 7, 2021
c100766
Merge branch 'develop' of https://github.com/NREL/EnergyPlus into int…
xuanluo113 Mar 9, 2021
242f33c
Merge branch 'develop' of https://github.com/NREL/EnergyPlus into int…
xuanluo113 Mar 11, 2021
30c6570
merge
xuanluo113 Mar 16, 2021
5cd3283
Merge branch 'develop' of https://github.com/NREL/EnergyPlus into int…
xuanluo113 Mar 17, 2021
8a1a02b
floating point
xuanluo113 Mar 18, 2021
7a17319
merge
xuanluo113 Mar 18, 2021
40e7d68
Merge branch 'develop' of https://github.com/NREL/EnergyPlus into int…
xuanluo113 Mar 19, 2021
c8c506d
more functions cleaning up
xuanluo113 Mar 19, 2021
e15f581
array ordering
xuanluo113 Mar 20, 2021
1c3f2e5
Merge branch 'develop' of https://github.com/NREL/EnergyPlus into int…
xuanluo113 Mar 20, 2021
75cb7f1
Merge branch 'develop' of https://github.com/NREL/EnergyPlus into int…
xuanluo113 Mar 20, 2021
0bb86d5
merge
xuanluo113 Mar 20, 2021
a0adce1
Merge branch 'develop' of https://github.com/NREL/EnergyPlus into int…
xuanluo113 Mar 21, 2021
4bf5a48
debug and clean up
xuanluo113 Mar 22, 2021
c155311
Merge branch 'develop' of https://github.com/NREL/EnergyPlus into int…
xuanluo113 Mar 22, 2021
00ec6a3
Merge branch 'develop' of https://github.com/NREL/EnergyPlus into int…
xuanluo113 Mar 22, 2021
1e9f393
constexpr
xuanluo113 Mar 22, 2021
230c5ef
clean up
xuanluo113 Mar 23, 2021
66b0ee8
clean up
xuanluo113 Mar 23, 2021
ade8f89
merge
xuanluo113 Mar 23, 2021
c96898b
Merge remote-tracking branch 'remotes/NRELEnergyPlus/develop' into in…
mjwitte Mar 24, 2021
01c3e0b
merge cleanup
mjwitte Mar 25, 2021
4b5e824
Merge remote-tracking branch 'remotes/NRELEnergyPlus/develop' into in…
mjwitte Mar 25, 2021
57070ce
address comments
xuanluo113 Mar 25, 2021
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
1 change: 0 additions & 1 deletion src/EnergyPlus/DataSurfaces.cc
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,6 @@ namespace EnergyPlus::DataSurfaces {
}

// Functions

void SetSurfaceOutBulbTempAt(EnergyPlusData &state)
{
for (auto &surface : state.dataSurface->Surface) {
Expand Down
11 changes: 11 additions & 0 deletions src/EnergyPlus/DataSurfaces.hh
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ namespace DataSurfaces {

// MODULE PARAMETER DEFINITIONS:
constexpr int MaxSlatAngs(19);
constexpr int MaxProfAngs(37);

// Parameters to indicate surface shape for use with the Surface
// derived type (see below):
Expand Down Expand Up @@ -1485,6 +1486,11 @@ struct SurfacesData : BaseGlobalStruct
Array1D<bool> SurfWinSlatAngThisTSDegEMSon; // flag that indicate EMS system is actuating SlatAngThisTSDeg
Array1D<Real64> SurfWinSlatAngThisTSDegEMSValue; // value that EMS sets for slat angle in degrees
Array1D<bool> SurfWinSlatsBlockBeam; // True if blind slats block incident beam solar
Array1D<int> SurfWinSlatsAngIndex;
Copy link
Contributor

Choose a reason for hiding this comment

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

6 new SurfWin* arrays to avoid recomputing values.

Array1D<Real64> SurfWinSlatsAngInterpFac;
Array1D<Real64> SurfWinProfileAng;
Array1D<int> SurfWinProfAngIndex;
Array1D<Real64> SurfWinProfAngInterpFac;
Array1D<Real64> SurfWinBlindAirFlowPermeability; // Blind air-flow permeability for calculation of convective flow in gap between blind and glass
Array1D<Real64> SurfWinTotGlazingThickness; // Total glazing thickness from outside of outer glass to inside of inner glass (m)
Array1D<Real64> SurfWinTanProfileAngHor; // Tangent of horizontal profile angle
Expand Down Expand Up @@ -1750,6 +1756,11 @@ struct SurfacesData : BaseGlobalStruct
this->SurfWinSlatAngThisTSDegEMSon.deallocate();
this->SurfWinSlatAngThisTSDegEMSValue.deallocate();
this->SurfWinSlatsBlockBeam.deallocate();
this->SurfWinSlatsAngIndex.deallocate();
this->SurfWinSlatsAngInterpFac.deallocate();
this->SurfWinProfileAng.deallocate();
this->SurfWinProfAngIndex.deallocate();
this->SurfWinProfAngInterpFac.deallocate();
this->SurfWinBlindAirFlowPermeability.deallocate();
this->SurfWinTotGlazingThickness.deallocate();
this->SurfWinTanProfileAngHor.deallocate();
Expand Down
289 changes: 80 additions & 209 deletions src/EnergyPlus/DaylightingManager.cc

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions src/EnergyPlus/General.cc
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,7 @@ namespace General {
XX_1 = X1;
}


Real64 InterpSw(Real64 const SwitchFac, // Switching factor: 0.0 if glazing is unswitched, = 1.0 if fully switched
Real64 const A, // Glazing property in unswitched state
Real64 const B // Glazing property in fully switched state
Expand Down Expand Up @@ -1305,6 +1306,21 @@ namespace General {
IAlpha = int((ProfAng1 + DataGlobalConstants::PiOvr2) / DeltaProfAng) + 1;
ProfAngRatio = (ProfAng1 + DataGlobalConstants::PiOvr2 - (IAlpha - 1) * DeltaProfAng) / DeltaProfAng;

// Real64 const DeltaAngRad(DataGlobalConstants::Pi / 36.0); // Profile angle increment (rad)
//
// // FUNCTION LOCAL VARIABLE DECLARATIONS:
// Real64 InterpFac; // Interpolation factor
// int IAlpha; // Profile angle index
//
// // DeltaAng = Pi/36
// if (ProfAng > DataGlobalConstants::PiOvr2 || ProfAng < -DataGlobalConstants::PiOvr2) {
// InterpProfAng = 0.0;
// } else {
// IAlpha = 1 + int((ProfAng + DataGlobalConstants::PiOvr2) / DeltaAngRad);
// InterpFac = (ProfAng - (-DataGlobalConstants::PiOvr2 + DeltaAngRad * (IAlpha - 1))) / DeltaAngRad;
// InterpProfAng = (1.0 - InterpFac) * PropArray(IAlpha) + InterpFac * PropArray(IAlpha + 1);
// }

if (VarSlats) { // Variable-angle slats: interpolate in profile angle and slat angle
IBeta = int(SlatAng1 / DeltaSlatAng) + 1;
SlatAngRatio = (SlatAng1 - (IBeta - 1) * DeltaSlatAng) / DeltaSlatAng;
Expand Down
21 changes: 21 additions & 0 deletions src/EnergyPlus/General.hh
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,27 @@ namespace General {
Real64 &XX_1 // Hign bound obtained with maximum number of allowed iterations
);

constexpr Real64 InterpGeneral(Real64 const Lower,
Real64 const Upper,
Real64 const InterpFac
)
{
return Lower + InterpFac * (Upper - Lower);
};

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm sure declaring this function constexpr vs. just inline doesn't hurt anything, but I doubt any of the arguments will actually be constexpr and enable any compile-time reduction. Same for InterpProfSlat.

constexpr Real64 InterpProfSlat(Real64 const SlatLower,
Real64 const SlatUpper,
Real64 const ProfLower,
Real64 const ProfUpper,
Real64 const SlatInterpFac,
Real64 const ProfInterpFac
)
{
Real64 ValA = SlatLower + SlatInterpFac * (SlatUpper - SlatLower);
Real64 ValB = ProfLower + SlatInterpFac * (ProfUpper - ProfLower);
return ValA + ProfInterpFac * (ValB - ValA);
};

Real64 InterpSw(Real64 const SwitchFac, // Switching factor: 0.0 if glazing is unswitched, = 1.0 if fully switched
Real64 const A, // Glazing property in unswitched state
Real64 const B // Glazing property in fully switched state
Expand Down
9 changes: 2 additions & 7 deletions src/EnergyPlus/HeatBalanceIntRadExchange.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ namespace HeatBalanceIntRadExchange {
typedef Array1D<Real64>::size_type size_type;

// Using/Aliasing
using General::InterpSlatAng; // Function for slat angle interpolation
using HeatBalanceMovableInsulation::EvalInsideMovableInsulation;
using WindowEquivalentLayer::EQLWindowInsideEffectiveEmiss;

Expand Down Expand Up @@ -288,11 +287,8 @@ namespace HeatBalanceIntRadExchange {
int const SurfNum = zone_SurfacePtr(ZoneSurfNum);
int const ConstrNum = state.dataSurface->Surface(SurfNum).Construction;
zone_info.Emissivity(ZoneSurfNum) = state.dataConstruction->Construct(ConstrNum).InsideAbsorpThermal;
auto const &surface_window(state.dataSurface->SurfaceWindow(SurfNum));
if (state.dataConstruction->Construct(ConstrNum).TypeIsWindow && ANY_INTERIOR_SHADE_BLIND(state.dataSurface->SurfWinShadingFlag(SurfNum))) {
zone_info.Emissivity(ZoneSurfNum) =
InterpSlatAng(state.dataSurface->SurfWinSlatAngThisTS(SurfNum), state.dataSurface->SurfWinMovableSlats(SurfNum), surface_window.EffShBlindEmiss) +
InterpSlatAng(state.dataSurface->SurfWinSlatAngThisTS(SurfNum), state.dataSurface->SurfWinMovableSlats(SurfNum), surface_window.EffGlassEmiss);
zone_info.Emissivity(ZoneSurfNum) = state.dataHeatBal->ITABSF(SurfNum);
Comment on lines -266 to +264
Copy link
Contributor

Choose a reason for hiding this comment

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

So, if I'm following correctly, ITABSF is set in HeatBalanceSurfaceManager::ComputeIntThermalAbsorpFactors (same as before, with some adjustments in this branch) so no need to recompute it here.

}
if (state.dataSurface->Surface(SurfNum).MovInsulIntPresent) {
HeatBalanceMovableInsulation::EvalInsideMovableInsulation(state, SurfNum, HMovInsul, AbsInt);
Expand Down Expand Up @@ -345,8 +341,7 @@ namespace HeatBalanceIntRadExchange {
// and emiss is used here that is a weighted combination of shade/blind and glass temp and emiss.
} else if (ANY_INTERIOR_SHADE_BLIND(state.dataSurface->SurfWinShadingFlag(SurfNum))) {
SurfaceTempRad[ZoneSurfNum] = state.dataSurface->SurfWinEffInsSurfTemp(SurfNum);
SurfaceEmiss[ZoneSurfNum] = InterpSlatAng(state.dataSurface->SurfWinSlatAngThisTS(SurfNum), state.dataSurface->SurfWinMovableSlats(SurfNum), surface_window.EffShBlindEmiss) +
InterpSlatAng(state.dataSurface->SurfWinSlatAngThisTS(SurfNum), state.dataSurface->SurfWinMovableSlats(SurfNum), surface_window.EffGlassEmiss);
SurfaceEmiss[ZoneSurfNum] = state.dataHeatBal->ITABSF(SurfNum);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, just use ITABSF directly. Ok.

} else {
SurfaceTempRad[ZoneSurfNum] = SurfaceTemp(SurfNum);
SurfaceEmiss[ZoneSurfNum] = construct.InsideAbsorpThermal;
Expand Down
Loading