NREL / EnergyPlus

EnergyPlus™ is a whole building energy simulation program that engineers, architects, and researchers use to model both energy consumption and water use in buildings.
https://energyplus.net
Other
1.12k stars 390 forks source link

Parsing for precipitation values fails for some weather stat files #9420

Closed mjwitte closed 2 years ago

mjwitte commented 2 years ago

Issue overview

User file fails with this cryptic error:

   ************* Beginning Simulation
   ** Severe  ** invalid stoi argument
   ************* EnergyPlus Warmup Error Summary. During Warmup: 0 Warning; 0 Severe Errors.

There are two places where std::stoi is used to parse lines from the weather stat file for reporting monthly total and max precipitation.

The line being parsed when it fails is this header under - Wind Frequency (m/s) by Direction {Interval 11.25 deg from displayed deg) [%]: <=.5 <=2 <=4 <=6 <=8 <=10 <=12 <=14 <=16 <=18 >18 Total

This is a newer block that does not exist in the stat files distributed with EnergyPlus.

The root of the problem is here in parseStatLine which assumes that any line containing "Max Hourly" will be for - Monthly Statistics for Liquid Precipitation [mm]. The stat file for this defect has two lines with "Max Hourly" one for liquid precipitation and one for snow depth.

parseStatLine also assumes that there will be only 2 occurences of "Total" in the entire stat file, once for Average Hourly Statistics for Total Sky Cover and once for liquid precipitation. The stat file for this defect has 4 occurences of "Total".

  1. parseStatLine needs to be more robust to ensure that values are being pulled from the correct block of statistics. The loop that calls parseStatLine needs to be modified to search for " - Monthly Statistics for Liquid Precipitation [mm]" first, then look for "Total" and "Max Hourly".
  2. std::stoi is fragile and needs to be protected to produce a useful error message, or ignore exceptions and move on to the next statistic, or be replaced with a more robust function such as UtilityRoutines::ProcessNumber.

Workaround

Rename the stat file so that EnergyPlus cannot find it. The simulation will complete, but the Weather Statistics File subtable of the Climatic Data Summary table output will be empty.

Details

Some additional details for this issue (if relevant):

Checklist

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

lklawrie commented 2 years ago

Am glad to supply any files to help test this defect but cannot commit to changing some 20,000 files on climate.onebuilding.org at this time.

Linda

jmarrec commented 2 years ago

@lklawrie completely understandable :).

I'll fix it on this side. I would suggest making some unit tests on your side to ensure this doesn't creep up again if you make change to your code generation though (or run the ones I added in https://github.com/NREL/EnergyPlus/commit/243ba2ef9dc2219e194b5d9b7cad1f5a5d3ecec3 with some of your files or something)

chriswmackey commented 2 years ago

It took me a while to figure out why I wasn't getting any summary reports for my simulations with OneBuilding EPW files but this seems to be the reason. I appreciate the suggested workaround, @mjwitte , and I plan to make use of it until the next stable EnergyPlus release.