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 the Thermal Comfort CEN 15251 Running Mean Temperature Calculation #8175

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
e62502d
Initial bugs fix
airallergy Jul 26, 2020
da1fdc8
Merge branch 'develop' into i8174_cen15251_running_mean_temperature
airallergy Jul 26, 2020
047e3d1
Add unit tests
airallergy Jul 27, 2020
e334b84
Change expected values to match the validation
airallergy Jul 28, 2020
440c0ae
Clarify the epw header skipping
airallergy Jul 28, 2020
a33eb9f
Merge branch 'develop' into i8174_cen15251_running_mean_temperature
airallergy Aug 3, 2020
e27106c
Rewrite the unit test to avoid additional globals
airallergy Aug 3, 2020
eeed712
Merge branch 'develop' into i8174_cen15251_running_mean_temperature
airallergy Sep 20, 2020
33d8a62
Merge branch 'develop' into i8174_cen15251_running_mean_temperature
airallergy May 5, 2021
50c183d
Update to match 'develop'
airallergy May 6, 2021
dcd6271
Use 'SkipEPlusWFHeader'
airallergy May 6, 2021
0613cd4
Merge branch 'develop' into i8174_cen15251_running_mean_temperature
airallergy Jun 14, 2021
c8232b8
Update unit test to match NREL/EnergyPlus#8480
airallergy Jun 15, 2021
d500677
Fix the filepath operator
airallergy Jun 23, 2021
73ed5e6
Merge branch 'develop' into i8174_cen15251_running_mean_temperature
airallergy Aug 24, 2021
b27d75a
Delete commented alternatives to epw header skipping
airallergy Aug 27, 2021
7c08bf9
Merge branch 'develop' into i8174_cen15251_running_mean_temperature
airallergy Aug 30, 2021
ce2b14c
Merge branch 'develop' into i8174_cen15251_running_mean_temperature
airallergy Sep 7, 2021
5bed1ff
Revert to minimum changes
airallergy Sep 7, 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
23 changes: 15 additions & 8 deletions src/EnergyPlus/ThermalComfort.cc
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ namespace ThermalComfort {
Array1D<Real64> ZoneOccHrs;
bool useEpwData(false);
Array1D<Real64> DailyAveOutTemp(30, 0.0);
Real64 avgDryBulbCEN(0.0);
airallergy marked this conversation as resolved.
Show resolved Hide resolved

// Subroutine Specifications for the Thermal Comfort module

Expand All @@ -253,13 +254,15 @@ namespace ThermalComfort {
Array1D<AngleFactorData> AngleFactorList; // Angle Factor List data for each Angle Factor List

Real64 runningAverageASH(0.0);
Real64 runningAverageCEN(0.0);

// Functions
void clear_state()
{
FirstTimeFlag = true;
FirstTimeSurfaceWeightedFlag = true;
runningAverageASH = 0.0;
runningAverageCEN = 0.0;
AbsAirTemp = 0.0;
AbsCloSurfTemp = 0.0;
AbsRadTemp = 0.0;
Expand Down Expand Up @@ -2853,13 +2856,10 @@ namespace ThermalComfort {

// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
std::string epwLine;
static Real64 avgDryBulbCEN(0.0);
Real64 dryBulb;
Real64 tComf;
Real64 tComfLow;
static Real64 runningAverageCEN(0.0);
Real64 numOccupants;
static bool useEpwData(false);
airallergy marked this conversation as resolved.
Show resolved Hide resolved
static bool firstDaySet(false); // first day is set with initiate -- so do not update
int readStat;
int jStartDay;
Expand Down Expand Up @@ -2888,14 +2888,21 @@ namespace ThermalComfort {
const bool epwFileExists = FileSystem::fileExists(ioFiles.inputWeatherFileName.fileName);
readStat = 0;
if (epwFileExists) {
// determine number of days in year
int DaysInYear;
if (DataEnvironment::CurrentYearIsLeapYear) {
DaysInYear = 366;
} else {
DaysInYear = 365;
Copy link
Member

Choose a reason for hiding this comment

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

This is still a good change.

}
airallergy marked this conversation as resolved.
Show resolved Hide resolved
auto epwFile = ioFiles.inputWeatherFileName.open("CalcThermalComfortAdaptiveCEN15251");
for (i = 1; i <= 9; ++i) { // Headers
for (i = 1; i <= 8; ++i) { // Headers
airallergy marked this conversation as resolved.
Show resolved Hide resolved
epwFile.readLine();
}
jStartDay = DayOfYear - 1;
calcStartDay = jStartDay - 7;
if (calcStartDay > 0) {
calcStartHr = 24 * (calcStartDay - 1) + 1;
calcStartHr = 24 * calcStartDay + 1;
Copy link
Member

Choose a reason for hiding this comment

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

So I guess the - 1 wasn't needed because we already offset DayOfYear by 1 a couple lines up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure about the original intent, but I think this could be one explanation.

Copy link
Contributor

Choose a reason for hiding this comment

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

24 * (calcStartDay - 1) is a conversion to hours. Why exactly was this changed when calcStartDay wasn't changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because it was wrong by offsetting one excessive day here. This was also an issue with the ASHRAE comfort calculation function above, which was fixed in #6474.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, this code is wrapping the epw to 24*calcStartDay as the number of hours last year and +1 is the first hour of this year. If you pulled develop this would not show as a diff. Never mind that right now.

Copy link
Member

Choose a reason for hiding this comment

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

This whole thing appears to be built around an assumption that the weather file has hourly data, which makes me feel funny. This PR isn't changing it, just handling this part better, and that is acceptable here.

for (i = 1; i <= calcStartHr - 1; ++i) {
epwFile.readLine();
}
Expand All @@ -2916,9 +2923,9 @@ namespace ThermalComfort {
}
} else { // Do special things for wrapping the epw
calcEndDay = jStartDay;
calcStartDay += 365;
calcStartDay += DaysInYear;
Copy link
Member

Choose a reason for hiding this comment

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

Using the new dynamically determined days in year is great.

calcEndHr = 24 * calcEndDay;
calcStartHr = 24 * (calcStartDay - 1) + 1;
calcStartHr = 24 * calcStartDay + 1;
Copy link
Member

Choose a reason for hiding this comment

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

I'm willing to accept this as the corrected start by shifting a day.

for (i = 1; i <= calcEndDay; ++i) {
avgDryBulbCEN = 0.0;
for (j = 1; j <= 24; ++j) {
Expand Down Expand Up @@ -2964,7 +2971,7 @@ namespace ThermalComfort {

if (BeginDayFlag && !firstDaySet) {
// Update the running average, reset the daily avg
runningAverageCEN = 0.2 * runningAverageCEN + 0.8 * avgDryBulbCEN;
runningAverageCEN = alpha * runningAverageCEN + (1.0 - alpha) * avgDryBulbCEN;
airallergy marked this conversation as resolved.
Show resolved Hide resolved
avgDryBulbCEN = 0.0;
}

Expand Down
2 changes: 2 additions & 0 deletions src/EnergyPlus/ThermalComfort.hh
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,10 @@ namespace ThermalComfort {
extern Array1D<Real64> ZoneOccHrs;
extern bool useEpwData;
extern Array1D<Real64> DailyAveOutTemp;
extern Real64 avgDryBulbCEN;

extern Real64 runningAverageASH;
extern Real64 runningAverageCEN;

// Subroutine Specifications for the Thermal Comfort module

Expand Down
Loading