Skip to content

Commit

Permalink
Merge pull request #4623 from NREL/74715116-CrashIssue4277
Browse files Browse the repository at this point in the history
Fix ShadowCalculation with TimestepFrequency hourly init in SolarShading
  • Loading branch information
Myoldmopar committed Jan 16, 2015
2 parents 35ac314 + 2c07d60 commit 777c1f8
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/EnergyPlus/SolarShading.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3336,8 +3336,10 @@ namespace SolarShading {
AOSurf( {1,TotSurfaces} ) = 0.0;
BackSurfaces( {1,TotSurfaces}, {1,MaxBkSurf}, HourOfDay, TimeStep ) = 0;
OverlapAreas( {1,TotSurfaces}, {1,MaxBkSurf}, HourOfDay, TimeStep ) = 0.0;
SurfaceWindow.OutProjSLFracMult()( HourOfDay ) = 1.0;
SurfaceWindow.InOutProjSLFracMult()( HourOfDay ) = 1.0;
for ( int SurfNum = 1; SurfNum <= TotSurfaces; ++SurfNum ) {
SurfaceWindow( SurfNum ).OutProjSLFracMult( HourOfDay ) = 1.0;
SurfaceWindow( SurfNum ).InOutProjSLFracMult( HourOfDay ) = 1.0;
}
}

if ( ! DetailedSolarTimestepIntegration ) {
Expand Down
1 change: 1 addition & 0 deletions tst/EnergyPlus/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ set( test_src
DataPlant.unit.cc
ExteriorEnergyUse.unit.cc
HeatBalanceManager.unit.cc
SolarShading.unit.cc
SortAndStringUtilities.unit.cc
Vectors.unit.cc
Vector.unit.cc
Expand Down
93 changes: 93 additions & 0 deletions tst/EnergyPlus/unit/SolarShading.unit.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// EnergyPlus::SolarShading Unit Tests

// Google Test Headers
#include <gtest/gtest.h>

// EnergyPlus Headers
#include <SolarShading.hh>
#include <DataSurfaces.hh>
#include <DataGlobals.hh>
#include <DataSystemVariables.hh>
#include <DataHeatBalance.hh>
#include <DataBSDFWindow.hh>

using namespace EnergyPlus;
using namespace EnergyPlus::SolarShading;
using namespace EnergyPlus::DataSurfaces;
using namespace EnergyPlus::DataGlobals;
using namespace EnergyPlus::DataSystemVariables;
using namespace EnergyPlus::DataHeatBalance;
using namespace EnergyPlus::DataBSDFWindow;
using namespace ObjexxFCL;

TEST( CalcPerSolarBeamTest, Test1 )
{
// Test inits for integrated and non-integrated shading calcs

// static bool ErrorsFound( false ); // If errors detected in input
// static int ZoneNum( 0 ); // Zone number
// int NumAlphas ( 2 );
// int NumNumbers ( 9 );
Real64 AvgEqOfTime ( 0.0 ); // Average value of Equation of Time for period
Real64 AvgSinSolarDeclin ( 1.0 ); // Average value of Sine of Solar Declination for period
Real64 AvgCosSolarDeclin ( 0.0 ); // Average value of Cosine of Solar Declination for period
int NumTimeSteps( 6 );

TimeStep = 1;
TotSurfaces = 3;
MaxBkSurf = 3;
SurfaceWindow.allocate( TotSurfaces );
SunlitFracHR.allocate( TotSurfaces, 24 );
SunlitFrac.allocate( TotSurfaces, 24, NumTimeSteps );
SunlitFracWithoutReveal.allocate( TotSurfaces, 24, NumTimeSteps );
CTHETA.allocate( TotSurfaces );
CosIncAngHR.allocate( TotSurfaces, 24 );
CosIncAng.allocate( TotSurfaces, 24, NumTimeSteps );
AOSurf.allocate( TotSurfaces );
BackSurfaces.allocate( TotSurfaces, MaxBkSurf, 24, NumTimeSteps );
OverlapAreas.allocate( TotSurfaces, MaxBkSurf, 24, NumTimeSteps );

// Test non-integrated option first, CalcPerSolarBeam should set OutProjSLFracMult and InOutProjSLFracMult to 1.0 for all hours
for ( int SurfNum = 1; SurfNum <= TotSurfaces; ++SurfNum ) {
for ( int Hour = 1; Hour <= 24; ++Hour ) {
SurfaceWindow( SurfNum).OutProjSLFracMult( Hour ) = 999.0;
SurfaceWindow( SurfNum ).InOutProjSLFracMult( Hour ) = 888.0;
}
}

DetailedSolarTimestepIntegration = false;
CalcPerSolarBeam( AvgEqOfTime, AvgSinSolarDeclin, AvgCosSolarDeclin );

for ( int SurfNum = 1; SurfNum <= TotSurfaces; ++SurfNum ) {
for ( int Hour = 1; Hour <= 24; ++Hour ) {
EXPECT_EQ( 1.0, SurfaceWindow( SurfNum ).OutProjSLFracMult( Hour ) );
EXPECT_EQ( 1.0, SurfaceWindow( SurfNum ).InOutProjSLFracMult( Hour ) );
}
}

// Test integrated option, CalcPerSolarBeam should set OutProjSLFracMult and InOutProjSLFracMult to 1.0 only for the specified hour
// Re-initialize to new values
for ( int SurfNum = 1; SurfNum <= TotSurfaces; ++SurfNum ) {
for ( int Hour = 1; Hour <= 24; ++Hour ) {
SurfaceWindow( SurfNum ).OutProjSLFracMult( Hour ) = 555.0;
SurfaceWindow( SurfNum ).InOutProjSLFracMult( Hour ) = 444.0;
}
}

DetailedSolarTimestepIntegration = true;
HourOfDay = 23;
CalcPerSolarBeam( AvgEqOfTime, AvgSinSolarDeclin, AvgCosSolarDeclin );

for ( int SurfNum = 1; SurfNum <= TotSurfaces; ++SurfNum ) {
for ( int Hour = 1; Hour <= 24; ++Hour ) {
if ( Hour == HourOfDay ) {
EXPECT_EQ( 1.0, SurfaceWindow( SurfNum ).OutProjSLFracMult( Hour ) );
EXPECT_EQ( 1.0, SurfaceWindow( SurfNum ).InOutProjSLFracMult( Hour ) );
} else {
EXPECT_EQ( 555.0, SurfaceWindow( SurfNum ).OutProjSLFracMult( Hour ) );
EXPECT_EQ( 444.0, SurfaceWindow( SurfNum ).InOutProjSLFracMult( Hour ) );
}
}
}

}

7 comments on commit 777c1f8

@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) - x86_64-MacOS-10.9-clang: OK (1092 of 1092 tests passed)

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.

develop (Myoldmopar) - x86_64-Linux-Ubuntu-14.04-gcc-4.8: OK (1095 of 1095 tests passed)

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.

develop (Myoldmopar) - x86_64-Linux-Ubuntu-14.04-cppcheck-1.61: OK (0 of 0 tests passed)

Build 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) - i386-Windows-7-VisualStudio-12: OK (1095 of 1095 tests passed)

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.

develop (Myoldmopar) - x86_64-Linux-Ubuntu-14.04-gcc-4.8-UnitTestsCoverage-Debug: OK (597 of 597 tests passed)

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-7-VisualStudio-12: OK (1095 of 1095 tests passed)

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.

develop (Myoldmopar) - x86_64-Linux-Ubuntu-14.04-gcc-4.8-IntegrationCoverage-Debug: OK (1095 of 1095 tests passed)

Build Badge Test Badge Coverage Badge

Please sign in to comment.