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

Failing or hanging initialization with DOE reference building #2512

Closed
AntoineGautier opened this issue May 27, 2021 · 6 comments · Fixed by #2527
Closed

Failing or hanging initialization with DOE reference building #2512

AntoineGautier opened this issue May 27, 2021 · 6 comments · Fixed by #2527
Labels
spawn Development for Spawn of EnergyPlus
Milestone

Comments

@AntoineGautier
Copy link
Contributor

The following model fails to initialize: Dymola stalls and OCT returns the attached error log.
https://github.com/AntoineGautier/ldrd/blob/master/LDRD/Examples/DebugRefMed.mo

oct.log

The model uses the DOE reference model for medium office at https://www.energy.gov/eere/downloads/reference-buildings-building-type-medium-office. Version v1-4_7-2 was selected and converted (on Windows) to EnergyPlus v9.5. Simulating the model with EnergyPlus v9.5 (on Linux) is successful, see attached error log.

eplusout.err.txt

There is no issue when using another reference building, for instance with the following parameter values in LDRD.Loads.BaseClasses.BuildingSpawnRefMed1.

parameter String idfName="modelica://Buildings/Resources/Data/ThermalZones/EnergyPlus/Examples/RefBldgSmallOffice/RefBldgSmallOfficeNew2004_Chicago.idf"
...
Buildings.ThermalZones.EnergyPlus.ThermalZone zon(zoneName="Core_ZN", ...)
@AntoineGautier AntoineGautier added the spawn Development for Spawn of EnergyPlus label May 27, 2021
@AntoineGautier
Copy link
Contributor Author

@kbenne The issue can be isolated to the Spawn binaries. See attached the idf epw and json and let me know if you can reproduce it.

RefBldgMediumOfficeNew2004_v1.4_7.2_5A_USA_IL_CHICAGO-OHARE.idf.txt

USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw.txt

ModelicaBuildingsEnergyPlus.json.txt

@AntoineGautier AntoineGautier changed the title Failing or stalled initialization with DOE reference building Failing or hanged initialization with DOE reference building May 27, 2021
@AntoineGautier AntoineGautier changed the title Failing or hanged initialization with DOE reference building Failing or hanging initialization with DOE reference building May 27, 2021
@mwetter
Copy link
Member

mwetter commented Jun 1, 2021

It turns out that there are other idf files that cause a crash. For example,

model TestModel
  extends Buildings.ThermalZones.EnergyPlus.Validation.OutputVariable.OneEnvironmentOutputVariable(
  building(
    idfName=Modelica.Utilities.Files.loadResource(
      "file:////home/mwetter/test/mbl-2512/tmp_idf_files/ASHRAE9012016_OfficeSmall_Denver.idf")));
  annotation (
    experiment(
      StopTime=86400,
      Tolerance=1e-06));
end TestModel;

causes

FMUException                              Traceback (most recent call last)
~/test/mbl-2512/jmodelica.py in <module>
    124 
    125 if math.isnan(final_time):
--> 126   res = mod.simulate(options=opts)
    127 else:
    128   res = mod.simulate(options=opts, final_time=final_time)

src/pyfmi/fmi.pyx in pyfmi.fmi.FMUModelME2.simulate()

src/pyfmi/fmi.pyx in pyfmi.fmi.ModelBase._exec_simulate_algorithm()

src/pyfmi/fmi.pyx in pyfmi.fmi.ModelBase._exec_simulate_algorithm()

/opt/oct/Python/pyfmi/fmi_algorithm_drivers.py in __init__(self, start_time, final_time, input, model, options)
    316             elif isinstance(self.model, fmi.FMUModelME2) or isinstance(self.model, fmi_coupled.CoupledFMUModelME2):
    317                 self.model.setup_experiment(tolerance=rtol, start_time=self.start_time, stop_time=self.final_time)
--> 318                 self.model.initialize()
    319                 self.model.event_update()
    320                 self.model.enter_continuous_time_mode()

src/pyfmi/fmi.pyx in pyfmi.fmi.FMUModelBase2.initialize()

src/pyfmi/fmi.pyx in pyfmi.fmi.FMUModelBase2.initialize()

src/pyfmi/fmi.pyx in pyfmi.fmi.FMUModelBase2.enter_initialization_mode()

FMUException: Enter Initialize returned with an error. Enable logging for more information, (load_fmu(..., log_level=4)).
^C

Note that the process had to be killed, it did not terminate on its own. In this case, EnergyPlus does not write output files:

$ tree tmp-simulation-TestModel.building/
tmp-simulation-TestModel.building/
├── binaries
│   └── linux64
│       └── epfmi.so
├── modelDescription.xml
├── ModelicaBuildingsEnergyPlus.json
├── resources
│   ├── ASHRAE9012016_OfficeSmall_Denver.idf
│   ├── Energy+.idd
│   ├── model.spawn
│   └── USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw
└── TestModel.building.fmu

3 directories, 8 files

The same happens for ASHRAE9012016_OfficeSmall_Denver.idf

I will work further on a script that runs all EnergyPlus examples to check for errors.

@mwetter mwetter added this to the Release 8.0 milestone Jun 1, 2021
mwetter added a commit that referenced this issue Jun 1, 2021
mwetter added a commit that referenced this issue Jun 1, 2021
@bravache
Copy link
Contributor

bravache commented Jun 1, 2021

So, I've tracked down the issue, and it occurs when there are no Output:Variable object in the IDF file. Without at least one of these object, EnergyPlus does not create an output file.

You can go around this issue by adding any Output:Variable to the idf, even one that is not valid, as long as it is syntactically correct, such as:

Output:Variable,*,NONE,;

Alternatively, any working example models will fail if you remove all Output:Variable objects from their idf, as exemplified in this branch: https://github.com/lbl-srg/modelica-buildings/tree/issue2512_no_output_idf where I duplicated two examples but by changing the referenced idf to have no Output:Variable, with all other objects unchanged.

Buildings.ThermalZones.EnergyPlus.Examples.SingleFamilyHouse.Unconditioned -> UnconditionedNoOutput
Buildings.ThermalZones.EnergyPlus.Validation.OutputVariable.OneZoneOneOutputVariable -> OneZoneOneOutputVariableNoOutput

The fact that the error also occurs when the MBL OutputVariable object is used (like in the duplicated OneZoneOneOutputVariable example), show that this issue intervenes before the IDF modification that would add additional output variables.

mwetter added a commit that referenced this issue Jun 1, 2021
@mwetter
Copy link
Member

mwetter commented Jun 1, 2021

@bravache : Thanks for the analysis.
Commit 5e7ea7f adds a file to run all idf files of EnergyPlus 9.5.0 which shows that there are several problematic files. The statistics is

Number of successful simulation: 580
Number of fatal error messages : 73
Number of nonhandled errors    : 32

The cases with "fatal error" are likely fine as confirmed by individual inspection of some files. These are typically cases where the idf becomes invalid, possibly because the HVAC system has been removed.
The cases with "Nonhandled error" are cases -- at least for some -- where EnergyPlus is not writing any output and the simulation may just hang. See for example "ASHRAE9012016_SchoolSecondary_Denver.idf"

@Helarga
Copy link
Collaborator

Helarga commented Jun 2, 2021

@mwetter

Reminder: I have highlighted the necessity of having at least a single output variable listed on the idf "file"
back in the 29th of Jan 2021 as shown here at

issue #2088 ,however the issue was closed "premature i guess".

See also below the question I asked you and @kbenne 's reply regarding this issue
#2088 (comment)
#2088 (comment)

and the comparative analysis I executed in :
#2088 (comment)

@AntoineGautier
Copy link
Contributor Author

@bravache Thanks! Adding

Output:Variable,*,NONE,;

to the idf solves the issue.

kbenne added a commit to NREL/Spawn that referenced this issue Jun 3, 2021
The "idf preparation" which removes unsupported output variables (in an
effort to prevent warnings) was accessing the array of output variables using
unchecked methods. Here is the fix.

Thank you @Helarga for originally reporting this. I think the reason we didn't
reproduce this back when it was first reported, is because it requires
both an idf file that does not request output variables, AND a spawn
model that does not request output. Spawn will automatically inject output requests
that are made from the Modelica side. That is my theory anyway. I'm
pretty sure it is squashed now.

ref lbl-srg/modelica-buildings#2088
ref lbl-srg/modelica-buildings#2512
mwetter added a commit that referenced this issue Jun 7, 2021
* Added script to run all idf files

For #2512

* Merge validation case that has no output variables (#2526)

* Updated reference results and hash code of Spawn

* Renamed E+ working directory to EnergyPlus-simulation

* Updated reference results

Co-authored-by: bravache <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spawn Development for Spawn of EnergyPlus
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants