hongyuanjia / eplusr

A Toolkit for Using EnergyPlus in R.
https://hongyuanjia.github.io/eplusr
Other
71 stars 13 forks source link

Different running status between single run and param run #25

Closed yatingchen closed 5 years ago

yatingchen commented 5 years ago

I applied some changes to one IDF model with parallel running and choosing one of them as my result IDF file. But when I use the result IDF model, it can not work with a severe error. Do the package have any difference in running between single work and parallel work?

Thanks

hongyuanjia commented 5 years ago

Same EnergyPlus call is used in both single simulation and parallel simulations.

Please share more info in order to make it possible to debug.

Did you use ParametricJob class to create parallel simulation jobs? Is there any errors in that specific job when you use $errors()? What kind of severe error it gave you when you run it separately?

yatingchen commented 5 years ago

It shows the same errors, but the parallel running one can produce a result but the single running one will stop and won't give out any result.

hongyuanjia commented 5 years ago

So it means that even though there was a severe error in that simulation, ParametricJob still read output of that simulation without giving any message?

yatingchen commented 5 years ago

Yes

yatingchen commented 5 years ago

And when I run that IDF file in EnergyPlus Launch, it can give me a result with the severe error.

hongyuanjia commented 5 years ago

Thanks for this info.

Can you paste the contents of .err file of that simulation?

yatingchen commented 5 years ago

Program Version,EnergyPlus, Version 8.9.0-eba93e8e1b, YMD=2019.01.21 11:35, Beginning Zone Sizing Calculations Warning Weather file location will be used rather than entered (IDF) Location object. ~~~ ..Location object=USA IL-CHICAGO-OHARE ~~~ ..Weather File Location=DES-MOINES-IAP IA TMY2-72546 WMO#= ~~~ ..due to location differences, Latitude difference=[0.25] degrees, Longitude difference=[5.92] degrees. ~~~ ..Time Zone difference=[0.0] hour(s), Elevation difference=[53.68] percent, [102.00] meters. Warning CheckUsedConstructions: There are 2 nominally unused constructions in input. ~~~ For explicit details on each unused construction, use Output:Diagnostics,DisplayExtraWarnings; Beginning System Sizing Calculations Beginning Plant Sizing Calculations Warning CalcTwoSpeedDXCoilStandardRating: Did not find an appropriate fan associated with DX coil named = "PSZ-AC_1:1_COOLC DXCOIL". Standard Ratings will not be calculated. Severe Water heater = SWHSYS1 WATER HEATER: Water heater tank set point temperature is greater than the maximum tank temperature limit. ~~~ Water heater tank set point temperature is reset to Tank Temperature Limit minus 1 C (81.22) and simulation continues. ~~~ During Warmup, Environment=CHICAGO ANN HTG 99.6% CONDNS DB, at Simulation time=01/21 00:00 - 00:15 Testing Individual Branch Integrity All Branches passed integrity testing Testing Individual Supply Air Path Integrity All Supply Air Paths passed integrity testing Testing Individual Return Air Path Integrity All Return Air Paths passed integrity testing No node connection errors were found. Beginning Simulation Warning CalcDoe2DXCoil: Coil:Cooling:DX:SingleSpeed "PSZ-AC_2:2_COOLC DXCOIL" - Air-cooled condenser inlet dry-bulb temperature below 0 C. Outdoor dry-bulb temperature = -15.90 ~~~ ... Occurrence info = DES-MOINES-IAP IA TMY2-72546 WMO#=, 01/01 07:45 - 08:00 ~~~ ... Operation at low ambient temperatures may require special performance curves. Warning CalcDoe2DXCoil: Coil:Cooling:DX:SingleSpeed "PSZ-AC_2:2_COOLC DXCOIL" - Full load outlet air dry-bulb temperature < 2C. This indicates the possibility of coil frost/freeze. Outlet temperature = -3.21 C. ~~~ ...Occurrence info = DES-MOINES-IAP IA TMY2-72546 WMO#=, 01/01 07:45 - 08:00 ~~~ ... Possible reasons for low outlet air dry-bulb temperatures are: This DX coil ~~~ 1) may have a low inlet air dry-bulb temperature. Inlet air temperature = 17.522 C. ~~~ 2) may have a low air flow rate per watt of cooling capacity. Check inputs. ~~~ 3) is used as part of a HX assisted cooling coil which uses a high sensible effectiveness. Check inputs. Simulation Error Summary *****


===== Recurring Error Summary ===== The following recurring error messages occurred.


Warning Plant loop exceeding upper temperature limit, PlantLoop="SWHSYS1" ~~~ This error occurred 55931 total times; ~~~ during Warmup 1135 times; ~~~ during Sizing 0 times. ***** ~~~ Max=82.628713


Warning CalcDoe2DXCoil: Coil:Cooling:DX:SingleSpeed="PSZ-AC_2:2_COOLC DXCOIL" - Low condenser dry-bulb temperature error continues... ~~~ This error occurred 2117 total times; ~~~ during Warmup 0 times; ~~~ during Sizing 0 times. ***** ~~~ Max=-5.000000E-002 [C] Min=-24.9 [C]


Warning CalcDoe2DXCoil: Coil:Cooling:DX:SingleSpeed="PSZ-AC_2:2_COOLC DXCOIL" - Full load outlet temperature indicates a possibility of frost/freeze error continues. Outlet air temperature statistics follow: ~~~ This error occurred 2372 total times; ~~~ during Warmup 0 times; ~~~ during Sizing 0 times. ***** ~~~ Max=1.999341 Min=-3.817438



===== Final Error Summary ===== The following error categories occurred. Consider correcting or noting. Nominally Unused Constructions ..The nominally unused constructions warning is provided to alert you to potential conditions that can cause ..extra time during simulation. Each construction is calculated by the algorithm indicated in the HeatBalanceAlgorithm ..object. You may remove the constructions indicated (when you use the DisplayExtraWarnings option).


EnergyPlus Warmup Error Summary. During Warmup: 0 Warning; 0 Severe Errors. EnergyPlus Sizing Error Summary. During Sizing: 2 Warning; 0 Severe Errors. ***** EnergyPlus Completed Successfully-- 60423 Warning; 1 Severe Errors; Elapsed Time=00hr 00min 17.71sec

hongyuanjia commented 5 years ago

Thanks!

eplusr uses this exit code to determine if the simulation completed successfully in EplusJob

https://github.com/hongyuanjia/eplusr/blob/89044ec0a7e980ab8fe7a3099ea1ce25117c12dc/R/job.R#L576-L578

eplusr will stop reading simulation output on conditions:

  1. Simulation never runs;
  2. EnergyPlus terminated (killed);
  3. Simulation is still running.

Obviously, none of those match your case. In your case, this is an non-stop severe error, which means that EnergyPlus still could complete that simulation, as it saying that "EnergyPlus Completed Successfully". In this case, EnergyPlus may still gave a 0 exit code.

Currently, for parallel jobs, eplusr only checks the exit code of the parent background R process which calls EnergyPlus, but not the exit code of each simulation. This is not a very safe check. I will change the logic to ensure the same behavior as the single run.

Even it gave an non-zero exit code, EplusJob class will only issue a warning but will not stop you from reading that simulation output but ParametricJob will fail.

I have no idea why $report_data() stopped when you did a single run. What is the error message of $report_data()?

yatingchen commented 5 years ago

job$report_data() Empty data.table (0 rows) of 6 cols: Case,DateTime,KeyValue,Name,Units,Value Warning message: Simulation ended with errors. Simulation results may not be correct.

hongyuanjia commented 5 years ago

Interesting.

Could you paste the traceback() message? (Just run traceback() after job$report_data()'s error)

And also, have you checked corresponding output .csv file of that simulation? Is it empty?

yatingchen commented 5 years ago

job$report_data() Empty data.table (0 rows) of 6 cols: Case,DateTime,KeyValue,Name,Units,Value Warning message: Simulation ended with errors. Simulation results may not be correct. traceback() No traceback available

The Ssz.csv and Zsz.csv file are not empty. But I don't have *Meter.csv file

hongyuanjia commented 5 years ago

It turns out that job$report_data() ran as expected. It detected that EnergyPlus exited with a non-zero code and issued a warning, and it tried to extract all output associated in Output:Variable (corresponding to output file *.csv) and Output:Meter* (corresponding to output file *Meter.csv) in the IDF using the *.sql file. But there is no output.

If there is no *.csv or *Meter.csv file generated from EnergyPlus, then it is highly possible that *.sql file does not have any report data and meter data. If so, eplusr just did its job. It returns an empty data.table object, because there is no output.

Was the *.csv or *Meter.csv file generated when you run this model using EP-Launch and also using ParametricJob class?

yatingchen commented 5 years ago

Yes, they both exist.

hongyuanjia commented 5 years ago

That's wired... Without any reproducible example, it is hard for me to move any further.

Please paste the R code and also the model if there is no confidential issue. This will make it much more easier for me to discover what was going on.

yatingchen commented 5 years ago

IssueReport_Case#25_YatingChen.zip

There are three files in the Zip file. The "model.idf" is the test model I use in the single running which also is chosen from the parallel running No. 64 model. For convenience, I attached the parallel parameters in the *.csv file if you need.

Thanks for your help!

hongyuanjia commented 5 years ago

Thanks for this nice use case of eplusr!

Unfortunately, I could not reproduce the issue. For me, model.idf ran without any problem and job$report_data() could successfully return the meter data. There is no warning or error, as the exit code of EnergyPlus is 0.

packageVersion("eplusr")
# [1] ‘0.9.4’

job <- model$run(epw_commercial, dir = NULL)

eplusr:::._get_private(job)$m_job$exit_status
# [1] 0

job$report_data()
#      Case   DateTime KeyValue                 Name Units        Value
#  1: model 2019-02-01          Electricity:Facility     J  59176919888
#  2: model 2019-03-01          Electricity:Facility     J  53176619415
#  3: model 2019-04-01          Electricity:Facility     J  58565438065
#  4: model 2019-05-01          Electricity:Facility     J  56294063824
#  5: model 2019-06-01          Electricity:Facility     J  58655975455
#  6: model 2019-07-01          Electricity:Facility     J  57875617529
#  7: model 2019-08-01          Electricity:Facility     J  59362728810
#  8: model 2019-09-01          Electricity:Facility     J  61350264848
#  9: model 2019-10-01          Electricity:Facility     J  59497545485
# 10: model 2019-11-01          Electricity:Facility     J  60165869679
# 11: model 2019-12-01          Electricity:Facility     J  57376150770
# 12: model 2020-01-01          Electricity:Facility     J  59353231045
# 13: model 2019-02-01                  Gas:Facility     J 341312267630
# 14: model 2019-03-01                  Gas:Facility     J 290245692409
# 15: model 2019-04-01                  Gas:Facility     J 306992945716
# 16: model 2019-05-01                  Gas:Facility     J 285816791935
# 17: model 2019-06-01                  Gas:Facility     J 284110757942
# 18: model 2019-07-01                  Gas:Facility     J 269801946779
# 19: model 2019-08-01                  Gas:Facility     J 268939402730
# 20: model 2019-09-01                  Gas:Facility     J 267552129098
# 21: model 2019-10-01                  Gas:Facility     J 259886876915
# 22: model 2019-11-01                  Gas:Facility     J 281138154101
# 23: model 2019-12-01                  Gas:Facility     J 291430674480
# 24: model 2020-01-01                  Gas:Facility     J 326845351783
#      Case   DateTime KeyValue                 Name Units        Value

The "model.idf" is the test model I use in the single running which also is chosen from the parallel running No. 64 model.

I believe you mean No.65. As shown in the pic below, model.idf and set_parameter_65.idf is the same but not set_parameter_64.idf.

2019-01-23-112302_2560x1080_scrot1

Besides, I simplify your measure a little bit which makes it more clear. Hope it help.

set_parameters <- function(model, x) {
    set_value_in_class <- function (class, ..., .search = NULL) {
        # get all values in a list
        value <- list(...)

        # check if class exists
        if (!model$is_valid_class(class)) {
            message("Class ", class, " does not exist in current model. Skip...")
            return(invisible())
        }

        # get all IDs in class
        ids <- model$object_id(class, simplify = TRUE)

        # search for names and get corresponding IDs
        if (!is.null(.search)) {
            # get all names in class
            nms <- model$object_name(class, simplify = TRUE)
            ids <- ids[grepl(.search, nms)]

            # if no result found
            if (!length(ids)) {
                message("Failed to find objects that match regex `", .search, "` in class ", class, ". Skip...")
                return(invisible())
            }
        }

        # format input values accordingly
        if (length(ids) == 1) {
            model$set_object(ids, value)
        } else {
            model$set_object(ids, rep(list(value), length(ids)))
        }

    }

    #Lights
    set_value_in_class("Lights", Watts_per_Zone_Floor_Area = as.numeric(x[1]))

    #ElectricEquipment
    set_value_in_class("ElectricEquipment", Watts_per_Zone_Floor_Area = as.numeric(x[2]), Design_level = as.numeric(x[3]))

    # Extreror Lights
    set_value_in_class("Exterior:Lights", Design_level = as.numeric(x[4]))

    # Elec schedule
    set_value_in_class("Schedule:Compact", Field_4 = as.character(x[5]), .search = "CW")

    # GasEquipment
    set_value_in_class("GasEquipment", Design_level = as.numeric(x[6]))

    # Gas Schedule
    set_value_in_class("Schedule:Compact", Field_4 = as.character(x[7]), .search = "SWHSys1|HW_Loop")

    model
}
yatingchen commented 5 years ago

Thanks a lot! I can run the single model today too.

The simplification is very helpful! It makes me more clear about how to write and read other's code.

Thanks for your help again!

hongyuanjia commented 5 years ago

Glad it helps ;)