lbl-srg / EnergyPlusToFMU

EnergyPlus export as a Functional Mockup Unit for co-simulation
38 stars 17 forks source link

Add .reset() to fmu #57

Open ChristophGehbauer opened 3 years ago

ChristophGehbauer commented 3 years ago

For users who want to conduct multiple simulation runs usually the fmu (or coupled system) is reset to its original state after each run by calling the .reset() function, which is currently not implemented in EnergyPlusToFMU (I'm using version 3.1.0). If a consecutive run is conducted without resetting the EnergyPlus fmu, the following error might occur:

Error: No digits were found in getIntCheckErrorFMU.
Further characters after number: p%}(V2 -10

Sending EXIT_FAILURE = : 1
Error: No digits were found in getIntCheckErrorFMU.
Further characters after number: p%}(V2 -10

Sending EXIT_FAILURE = : 1
**FATAL:Error in ExternalInterface: Check EnergyPlus *.err file.
EnergyPlus Run Time=00hr 00min  1.17sec
Program terminated: EnergyPlus Terminated--Error(s) Detected.
Error: No digits were found in getIntCheckErrorFMU.
Further characters after number: P{�z(V2 -1

Sending EXIT_FAILURE = : 1

Error file: RefBldgMediumOfficeNew2004_v1_4_7_2_4B_USA_NM_ALBUQUERQUE.err.txt

A workaround is to delete the EnergyPlus fmu object and reload:

del energyplus_fmu # Delete the object
energyplus_fmu = load_fmu(....) # Relaod the object

By doing so EnergyPlusToFMU flushes the results files and closes the object:

Writing tabular output file results using HTML format.
Writing Tariff Reports
Writing final SQL reports
 ReadVarsESO program starting.
 ReadVars Run Time=00hr 00min  0.08sec
 ReadVarsESO program completed successfully.
 ReadVarsESO program starting.
 ReadVars Run Time=00hr 00min  0.07sec
 ReadVarsESO program completed successfully.
EnergyPlus Run Time=00hr 00min 15.74sec
EnergyPlus Completed Successfully.

Thank you, Christoph

meiguozhendelaji commented 2 years ago

However, when I try to do like that, sometime it is work great, but the most of time the process will return -1073740940 (0xC0000374) Do it like this way will make a great work:

model = load_fmu(XXXX)
opts = model.simulate_options()
opts['ncp'] = XXXX  # set number of TimeSteps
opts['initialize'] = False
model.setup_experiment(stop_time=XXXX)#this is the key of the code
model.initialize(start_time=XXXX, stop_time=XXXX, stop_time_defined=True)

#new loop
model.setup_experiment(stop_time=XXXX)#this is the key of the code
model.initialize(start_time=XXXX, stop_time=XXXX, stop_time_defined=True)

PS: If your idf file made by openstudio, you need to delete the part of your idf file of SQL, otherwise, your process will be locked by SQL process.

jiahuizi commented 6 months ago

And so it was with my mistakes, but I tried your approach and it still didn't work @meiguozhendelaji