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

Simplify the moist air specific heat capacity psychrometric function #7479

Merged
merged 16 commits into from
Feb 7, 2020

Conversation

Nigusse
Copy link
Contributor

@Nigusse Nigusse commented Aug 29, 2019

Pull request overview

Addresses issue #7476. This fix replaces moist air specific heat calculating numerical function by analytical function. The temperature argument is redundant if the analytical function is used per the definition of moist air enthalpy currently used. This is not a defect but anticipates reducing the computation burden of moist air specific heat calculation. The diffs observed are may be rounding numerical error.

Work Checklist

Add to this list or remove from it as applicable. This is a simple templated set of guidelines.

  • Title of PR should be user-synopsis style (clearly understandable in a standalone changelog context)
  • At least one of the following appropriate labels must be added to this PR to be consumed into the changelog:
    • Defect: This pull request repairs a github defect issue. The github issue should be referenced in the PR description
    • Performance: This pull request includes code changes that are directed at improving the runtime performance of EnergyPlus
    • DoNoPublish: This pull request includes changes that shouldn't be included in the changelog

Review Checklist

This will not be exhaustively relevant to every PR.

  • Functional code review (it has to work!)
  • If defect, results of running current develop vs this branch should exhibit the fix
  • CI status: all green or justified
  • Performance: CI Linux results include performance check
  • Unit Test(s)
  • C++ checks:
    • Argument types
    • If any virtual classes, ensure virtual destructor included, other things
  • Required documentation updates?

@Nigusse Nigusse added the DoNotPublish Includes changes that shouldn't be reported in the changelog label Aug 29, 2019
@Myoldmopar
Copy link
Member

@Nigusse I like the simplification here, but as a starter, you'll need to address the failing unit tests. It will be interesting to see what kind of changes you need to make to get them passing again. Hopefully it is just very small rounding differences.

inline Real64 PsyCpAirFnWTdb(Real64 const dw, // humidity ratio {kgWater/kgDryAir}
Real64 const T // input temperature {Celsius}
inline Real64 PsyCpAirFnWTdb(Real64 const dw, // humidity ratio {kgWater/kgDryAir}
Real64 const EP_UNUSED(T) // input temperature {Celsius}
Copy link
Member

Choose a reason for hiding this comment

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

My preference would be to go ahead and just remove this argument entirely if it isn't used anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the unused argument (TEMPERATURE) from PsyCpAirFnWTdb() function. Run unit tests locally. All happy.


// compute heat capacity of air
Real64 const w(max(dw, 1.0e-5));
Real64 const cpa((PsyHFnTdbW(T + 0.1, w) - PsyHFnTdbW(T, w)) * 10.0); // result => heat capacity of air {J/kg-C}
Real64 const cpa((1.00484e3 + w * 1.85895e3)); // result => heat capacity of moist air {J/kg-C}
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reference for this change? The PR description is empty, and with lots of diffs to work through, it will be important to document where this change came from.

@nrel-bot-3
Copy link

@Nigusse @lgentile it has been 30 days since this pull request was last updated.

@Nigusse
Copy link
Contributor Author

Nigusse commented Nov 1, 2019

Updated branch and resolved merge conflict.

@Nigusse
Copy link
Contributor Author

Nigusse commented Nov 5, 2019

The diffs / failed test observed between develop and this branch is caused by difference in moist air cp value calculation method. Develop uses numerical function (delta_h/delta_t = PsyCpAirFnWTdb(W, T)) to determine Cp value while this branch uses analytical function (PsyCpAirFnW(W)). The analytical function requires humidity ratio only as an input while the numerical function requires two parameters Humidity Ratio and Temperature. Furthermore, the numerical function computes enthalpy first to determine the Cp value while the analytical function determines the cp value directly.

@Nigusse
Copy link
Contributor Author

Nigusse commented Nov 5, 2019

The difference in cp values observed in wide range of test conditions is in the order of 1.0e-10 kgWater/kgDryAir. Error stats determined between the analytical and numerical function over a wide range of humidity ratio and temperature range that covers the entire psychometric chart grid is summarized below:
EXPECT_DOUBLE_EQ(Error_min, -2.8808244678657502e-10);
EXPECT_DOUBLE_EQ(Error_max, 2.5875124265439808e-10);
EXPECT_DOUBLE_EQ(Error_avg, 1.5508032789728189e-09);
EXPECT_DOUBLE_EQ(StdError, 6.7111413639467468e-10);

Positive MBE (Error_avg) indicates the numerical method slightly over predicts the cp values. However, I am puzzled why the simplified analytical solution used in this branch does not improve computational performance. Some of the regression test suite files show increased warmup errors. This could be one of the explanation for increased computational time in the regression results and the large diffs reported for some of test files. Needs further investigation to find out what causes the increased warmup errors for a few of the regression test files.

@Nigusse
Copy link
Contributor Author

Nigusse commented Nov 13, 2019

Investigated one of the test files failed (5ZoneCoolingPanelBaseboard.idf). This test file has a humidity control (SetpointManager:SingleZone:Humidity:Maximum) based on thermal zone, SPACE2-1. The Zone Air Temperatures and Zone Predicted Loads align very well between develop and this branch even though diffs were reported for other variables. The large diffs were reported for the main heating and cooling coils due to shift in coils operation timestep around 3 am on July 21 (07/21) run period caused by changing predicted moisture loads. Note that there is no predicted sensible loads around this time.

ZoneAirTemp_PredictedLoad

See below the main air loop heating and coiling water coils heat transfer rates. Note that around 3 am 07/21 shows large diffs in the heating and cooling rates between develop and this branch (#7476). It is clearly evident that the diffs oscillate between negative and positive values. This oscillation can be directly explained by changing predicted moisture loads in the csv file snapshots around 3 am.

MainHeating_CoolingCoils_HeatRate

See changing predicted moisture loads around 3 am 07/21.

ZonesPredicedLoads

Also see how the coils operation shifted between develop and this branch as reported in the CSV output file, snapshot round 3 am 07/21.

CoilsHeatRateCSVOutput

@Nigusse
Copy link
Contributor Author

Nigusse commented Nov 13, 2019

Annual energy use comparison for failed test file 5ZoneCoolingPanelBaseboard.idf does not show diffs.

AnnualEnergyUse

@Nigusse Nigusse requested a review from Myoldmopar November 13, 2019 19:19
@Nigusse
Copy link
Contributor Author

Nigusse commented Nov 13, 2019

@Myoldmopar This branch is ready for review.

@nrel-bot-3
Copy link

@Nigusse @lgentile it has been 28 days since this pull request was last updated.

1 similar comment
@nrel-bot-2b
Copy link

@Nigusse @lgentile it has been 28 days since this pull request was last updated.

@mitchute
Copy link
Collaborator

@Nigusse It looked like most of the conflicts here were due to my recent refactoring tasks, so I went ahead and pulled in develop and resolved the conflicts. Let's see what the results look like after CI has had a chance to run.

@Myoldmopar
Copy link
Member

@Nigusse I agree that the changes are looking better. There are 17 files with big ESO diffs and 8 with big MTR diffs. The files with big MTR diffs are the ones I am most concerned with. As long as they are actually small then the oscillatory time series diffs are acceptable. The branch is again conflicted so I'll pull develop in here soon.

@Myoldmopar Myoldmopar added this to the EnergyPlus 9.3.0 milestone Jan 23, 2020
@Nigusse
Copy link
Contributor Author

Nigusse commented Jan 28, 2020

@Myoldmopar @mitchute would you please resolve this conflicts so that I can look at the big MTR diffs?

@mitchute
Copy link
Collaborator

@Nigusse ready for you again.

@Nigusse
Copy link
Contributor Author

Nigusse commented Jan 28, 2020

@mitchute Thanks.

@Nigusse
Copy link
Contributor Author

Nigusse commented Jan 28, 2020

I run one of the test suite file (5ZoneCoolingPanelBaseboard.idf) with big MTR diffs. The annual run shows that the Energy End Uses in html outputs files of this branch and develop are identical. Similary the meter variables sum (at detailed timestep reporting frequency) are almost the same as shown below. The absolute difference for Electricity:Facility [J] is about 119.5J and the percent diffs is tiny (in the order of 1.0E-8).

AnnualEnergyUseNew

Note that all the eight test files with big MTR diffs has 2 days run period (one in winter and another in Summer). Next I will compare meter outputs at detailed time step for the two days run period only.

@Nigusse
Copy link
Contributor Author

Nigusse commented Jan 28, 2020

I traced back the big MTR energy use difference in the cooling and heating energy end uses, i.e, cooling energy use of the chiller and heating energy use of the gas heating coils. This problem happens during summer design day run only (07/21, 2am - 5am) while the other three days run show very good match. The chiller energy use difference is caused by time shift in the main water cooling coil operation and the heating energy end use difference is caused by the shift in the gas heating coil operation. This time shift is documented in my earlier comments and is caused by predicted moisture load shifts in magnitude and sign for late night hours of summer sizing period run. The cooling and heating coils operation is triggered by a humidistat. Seven of the eight files with big MTR diffs have humidistat.

ElectricFacility

@Nigusse
Copy link
Contributor Author

Nigusse commented Jan 29, 2020

See below the chiller cooling rate and heating coil operation shift during early morning hour of summer sizing period run.

CoolingHeatingCoils

@Nigusse
Copy link
Contributor Author

Nigusse commented Jan 29, 2020

Figures below show the predicted moisture load around the time shift and the predicted sensible load for summer sizing period run. It is evident that there is no sensible heating and cooling load around the time shift. The predicted moisture load shift and sometimes the change from de-humidification to humidification is the one that triggers the main cooling and heating coils operation to shift and hence the MTR energy use diffs. Note that I did not not see the time shift anomaly or the MTR energy use big diffs during annual run.

PredictedLoad

@Nigusse
Copy link
Contributor Author

Nigusse commented Jan 29, 2020

Review summary of the BIG MTR diffs:

  • the big MTR diffs is caused by the time shift in predicted moisture load. The shift in predicted moisture load and hence the diffs in MTR chiller energy use and heating coil gas use were observed only during 2am to 5am hours of summer sizing period run.
  • this BIG MTR diffs wash out during annual run. Also, MTR diffs are tiny if the test file is run for the two days run period only. The trigger for the BIG MTR diffs is the summer sizing period run.

@Nigusse
Copy link
Contributor Author

Nigusse commented Jan 29, 2020

I stumbled into @mjwitte comment regarding increasing plant minimum iteration limit (changing from default value of 2 to 10) impact described in issue #7653. Out of curiosity I run one of the test files (5ZoneCoolingPanelBaseboard.idf) with big MTR diffs by increasing the plant minimum iteration limit to 10 from default value of 2. Now this branch and develop show almost now diffs. See in figures below, diffs for facility electricity and heating gas energy uses vanished. See also the facility electricity energy end uses in my earlier plot with default plant minimum iteration limit of 2. It is clearly evident that convergence problem at the plant min iteration limit affected this branch and develop.

FacilityELectricAndGasUse

@mitchute
Copy link
Collaborator

mitchute commented Feb 3, 2020

@Nigusse Excellent find with regard to the plant iterations. @mjwitte @Myoldmopar any thoughts on how to proceed with this? Perhaps potentially bump the plant iterations up on the files with diffs and let CI take a pass, then revert them back out so we can clearly show the issues?

This has fallen behind develop again. I'll pull develop in one more time and let CI take one more pass, but I think this should be able to go in soon.

@Myoldmopar Myoldmopar changed the title Simplify the moist air specific heat capacity psychometric function Simplify the moist air specific heat capacity psychrometric function Feb 4, 2020
@mitchute
Copy link
Collaborator

mitchute commented Feb 4, 2020

@Nigusse @mjwitte @Myoldmopar

I spent some time this morning looking at the latest CI results on this. It looks like the plant iterations issue referenced in #7653 may be at least partially causing the diffs, but that doesn't totally explain it. I ran the following files (which have big meter diffs) locally and looked at the results before and after Min Plant Iterations was set to 10.

  • 5ZoneCoolingPanelBaseboard
  • 5ZoneCoolingPanelBaseboardAuto
  • 5ZoneCoolingPanelBaseboardTotalLoad
  • 5ZoneCoolingPanelBaseboardVarOff
  • 5ZoneWaterCooled_Baseboard
  • 5ZoneWaterCooled_BaseboardScalableSizing
  • MultiSpeedHP_StagedThermostat

With Min Plant Iterations set to 10, the MultSpeedHP_StagedThermostat is the one with the largest relative meter diffs of about 0.2% on the Electricity:HVAC [J](Monthly) meter. See the following plots from this file.

Var_16
Var_17
Var_18
Var_19
Var_20
Var_21
Var_22
Var_23

It looks like the reported variables for this zone, with the minor exception of the humidity ratio, are all behaving nearly identical to the develop branch. The humidity ratio during a portion of the interval plotted is off by about 1%. That seems a little odd, however, this psychrometric function is used all over the place and this is the file with the biggest difference. So, IMO, if this is the biggest problem this work is ready to be merged.

Take a look and let me know. Unless I hear objections, I'll merge this in by the end of the week.

@mitchute mitchute added Refactoring Includes code changes that don't change the functionality of the program, just perform refactoring and removed DoNotPublish Includes changes that shouldn't be reported in the changelog labels Feb 6, 2020
@mitchute mitchute linked an issue Feb 6, 2020 that may be closed by this pull request
@mitchute
Copy link
Collaborator

mitchute commented Feb 7, 2020

This is ready to go. Merging.

@mitchute mitchute merged commit 7e75661 into develop Feb 7, 2020
@mitchute mitchute deleted the 168168673_Issue7476 branch February 7, 2020 21:08
@mitchute mitchute mentioned this pull request Feb 10, 2020
20 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactoring Includes code changes that don't change the functionality of the program, just perform refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Simplify the moist air specific heat capacity psychometric function
8 participants