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

Fix opaque cloud cover #8762

Merged
merged 5 commits into from
May 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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/WeatherManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2035,7 +2035,7 @@ namespace WeatherManager {
state.dataWeatherManager->TodayDifSolarRad = state.dataWeatherManager->TomorrowDifSolarRad;
state.dataWeatherManager->TodayLiquidPrecip = state.dataWeatherManager->TomorrowLiquidPrecip;
state.dataWeatherManager->TodayTotalSkyCover = state.dataWeatherManager->TomorrowTotalSkyCover;
state.dataWeatherManager->TodayOpaqueSkyCover = state.dataWeatherManager->TomorrowTotalSkyCover;
state.dataWeatherManager->TodayOpaqueSkyCover = state.dataWeatherManager->TomorrowOpaqueSkyCover;
Copy link
Member

Choose a reason for hiding this comment

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

Yeah great fix!


// Update Global Data

Expand Down
4 changes: 4 additions & 0 deletions testfiles/1ZoneUncontrolled.idf
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,10 @@

Output:Variable,*,Site Outdoor Air Drybulb Temperature,hourly;

Output:Variable,*,Site Total Sky Cover,hourly;

Output:Variable,*,Site Opaque Sky Cover,hourly;

Copy link
Member

Choose a reason for hiding this comment

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

Ideally these would be added to the develop branch in a separate PR so you could see the diffs. But that's a lot of extra work, and the fix here is pretty obvious. Either way it's good to add them here at least.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! @Myoldmopar Since the testfiles' changes are in the last two commits, I can easily revert to the commit before the one before that (actually already did it locally and ready to push if needed). Then after merging of this one I can add back the two last ones in a new PR.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think it's necessary. This is an obvious fix, and adding the output variables to the IDFs is a nice bonus over the unit test. I think this is already ready to go. CI looks good too, with just the new output variables causing "diffs". I still need to run it locally but I think it's good.

Output:Variable,*,Site Daylight Saving Time Status,daily;

Output:Variable,*,Site Day Type Index,daily;
Expand Down
2 changes: 2 additions & 0 deletions testfiles/1ZoneUncontrolled.rvi
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
eplusout.eso
eplusout.csv
Site Outdoor Air Drybulb Temperature
Site Total Sky Cover
Site Opaque Sky Cover
ZONE ONE,Zone Mean Air Temperature
ZONE ONE,Electricity:Building
Other Equipment Total Heating Energy
Expand Down
4 changes: 4 additions & 0 deletions testfiles/1ZoneUncontrolled_DD2009.idf
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,10 @@

Output:Variable,*,Site Outdoor Air Barometric Pressure,Timestep;

Output:Variable,*,Site Total Sky Cover,Timestep;

Output:Variable,*,Site Opaque Sky Cover,Timestep;

Output:Variable,*,Site Sky Temperature,Timestep;

Output:Variable,*,Site Diffuse Solar Radiation Rate per Area,Timestep;
Expand Down
110 changes: 110 additions & 0 deletions tst/EnergyPlus/unit/WeatherManager.unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1148,3 +1148,113 @@ TEST_F(EnergyPlusFixture, Add_and_InterpolateWeatherInputOutputTest)
Real64 expected_SkyTemp = -20.8188538296;
EXPECT_NEAR(state->dataWeatherManager->TomorrowSkyTemp(2, 1), expected_SkyTemp, 1e-6);
}

// Test for Issue 8760: fix opaque sky cover weather values;
TEST_F(EnergyPlusFixture, Fix_OpaqueSkyCover_Test)
{
std::string const idf_objects = delimited_string({
"Timestep,4;"

"SimulationControl,",
" Yes, !- Do Zone Sizing Calculation",
" Yes, !- Do System Sizing Calculation",
" No, !- Do Plant Sizing Calculation",
" Yes, !- Run Simulation for Sizing Periods",
" No; !- Run Simulation for Weather File Run Periods",

"RunPeriod,",
" January, !- Name",
" 1, !- Begin Month",
" 1, !- Begin Day of Month",
" , !- Begin Year",
" 1, !- End Month",
" 31, !- End Day of Month",
" , !- End Year",
" Tuesday, !- Day of Week for Start Day",
" Yes, !- Use Weather File Holidays and Special Days",
" Yes, !- Use Weather File Daylight Saving Period",
" No, !- Apply Weekend Holiday Rule",
" Yes, !- Use Weather File Rain Indicators",
" Yes; !- Use Weather File Snow Indicators",

"Site:Location,",
" Univ_Of_Illinois_725315, !- Name",
" 40.06, !- Latitude {deg}",
" -88.37, !- Longitude {deg}",
" -6.0, !- Time Zone {hr}",
" 213.0; !- Elevation {m}",

"Output:Variable,*,Site Total Sky Cover,Timestep;",
"Output:Variable,*,Site Opaque Sky Cover,Timestep;",
});

ASSERT_TRUE(process_idf(idf_objects));

SimulationManager::PostIPProcessing(*state);
bool ErrorsFound(false);
ErrorsFound = false;

state->dataWeatherManager->WeatherFileExists = true;
state->files.inputWeatherFileName.fileName = configured_source_directory() + "/weather/USA_IL_University.of.Illinois-Willard.AP.725315_TMY3.epw";

state->dataGlobal->BeginSimFlag = true;
SimulationManager::GetProjectData(*state);

bool Available(true);
Available = true;

state->dataGlobal->BeginSimFlag = true;
WeatherManager::GetNextEnvironment(*state, Available, ErrorsFound);

// Test get output variables for Total Sky Cover and Opaque Sky Cover
EXPECT_EQ("Site Total Sky Cover", state->dataOutputProcessor->RVariableTypes(1).VarNameOnly);
EXPECT_EQ("Environment:Site Total Sky Cover", state->dataOutputProcessor->RVariableTypes(1).VarName);
EXPECT_EQ("Site Opaque Sky Cover", state->dataOutputProcessor->RVariableTypes(2).VarNameOnly);
EXPECT_EQ("Environment:Site Opaque Sky Cover", state->dataOutputProcessor->RVariableTypes(2).VarName);

EXPECT_EQ(7, state->dataOutputProcessor->RVariableTypes(1).ReportID);
EXPECT_EQ(8, state->dataOutputProcessor->RVariableTypes(2).ReportID);

state->dataWeatherManager->Envrn = 1;

state->dataGlobal->NumOfTimeStepInHour = 4;
state->dataWeatherManager->Environment.allocate(1);
state->dataWeatherManager->Environment(1).SkyTempModel = EmissivityCalcType::ClarkAllenModel;
state->dataWeatherManager->Environment(1).StartMonth = 1;
state->dataWeatherManager->Environment(1).StartDay = 1;

state->dataWeatherManager->Environment(1).UseWeatherFileHorizontalIR = false;

AllocateWeatherData(*state);
OpenWeatherFile(*state, ErrorsFound);
ReadWeatherForDay(*state, 1, 1, true);

// Test additional set of weather data on sky temp calc
Real64 expected_SkyTemp = -1.7901122977770569;
EXPECT_NEAR(state->dataWeatherManager->TomorrowSkyTemp(2, 1), expected_SkyTemp, 1e-6);

// Test Total Sky Cover and Opaque Sky Cover
Real64 expected_TSC = 9;
Real64 expected_OSC = 8;

EXPECT_NEAR(state->dataWeatherManager->TomorrowTotalSkyCover(4, 3), expected_TSC, 1e-6);
EXPECT_NEAR(state->dataWeatherManager->TomorrowOpaqueSkyCover(4, 3), expected_OSC, 1e-6);
EXPECT_NEAR(state->dataWeatherManager->TomorrowTotalSkyCover(3, 3), 9.25, 1e-6);
EXPECT_NEAR(state->dataWeatherManager->TomorrowOpaqueSkyCover(3, 3), 8.25, 1e-6);
EXPECT_NEAR(state->dataWeatherManager->TomorrowTotalSkyCover(2, 3), 9.5, 1e-6);
EXPECT_NEAR(state->dataWeatherManager->TomorrowOpaqueSkyCover(2, 3), 8.5, 1e-6);
EXPECT_NEAR(state->dataWeatherManager->TomorrowTotalSkyCover(1, 3), 9.75, 1e-6);
EXPECT_NEAR(state->dataWeatherManager->TomorrowOpaqueSkyCover(1, 3), 8.75, 1e-6);

expected_TSC = 8;
expected_OSC = 8;

EXPECT_NEAR(state->dataWeatherManager->TomorrowTotalSkyCover(4, 4), expected_TSC, 1e-6);
EXPECT_NEAR(state->dataWeatherManager->TomorrowOpaqueSkyCover(4, 4), expected_OSC, 1e-6);
EXPECT_NEAR(state->dataWeatherManager->TomorrowTotalSkyCover(3, 4), 8.25, 1e-6);
EXPECT_NEAR(state->dataWeatherManager->TomorrowOpaqueSkyCover(3, 4), 8.00, 1e-6);
EXPECT_NEAR(state->dataWeatherManager->TomorrowTotalSkyCover(2, 4), 8.50, 1e-6);
EXPECT_NEAR(state->dataWeatherManager->TomorrowOpaqueSkyCover(2, 4), 8.00, 1e-6);
EXPECT_NEAR(state->dataWeatherManager->TomorrowTotalSkyCover(1, 4), 8.75, 1e-6);
EXPECT_NEAR(state->dataWeatherManager->TomorrowOpaqueSkyCover(1, 4), 8.00, 1e-6);
}
Copy link
Member

Choose a reason for hiding this comment

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

Nice. 👍