Co-simulation Issue - CONTAM + EP + PyEMS
Hi there,
An ongoing project of mine is about controlling the building ventilation system with the customized EMS code. The required inputs (EMS sensors) include the zone occupant, zone supply airflow, system supply airflow, and system supply airflow. The required outputs (EMS actutors)are the zone air terminal schedule and system min OA schedule.
Recently, I decided to move the built-in EMS control to the PyEMS framework, and also couple the E+ model with a CONTAM model so the airflow calculation is more accurate. I have tested the EP and CONTAM co-simulation - it worked fine. However, I encountered the following issues when I tried to add PyEMS to the framework.
The ventilation-related sensorhandles, e.g., the zone terminal outlet node flow rate could be created in Python using self.api.exchange.get_variable_handle (i.e., simulated successfully and not an error reported), but its sensor value could not be retrieved using self.api.exchange.get_variable_value. The simulation would crash and the error message is
*** Beginning Simulation * Severe * Data Exchange API: Index error in getVariableValue; received handle: -1 * ~~~ * The getVariableValue function will return 0 for now to allow the plugin to finish, then EnergyPlus will abort * Fatal * API problems encountered while running plugin cause program termination. ...Summary of Errors that led to program termination: ..... Reference severe error count=1 ..... Last severe error=Data Exchange API: Index error in getVariableValue; received handle: -1
The occupant number sensor handle could be created, and its value could be retrieved. However, the simulation crashed after two days of simulation. The error is
*** Beginning Simulation * Severe * ExternalInterface/CalcExternalInterfaceFMUImport: Error when trying to initialize * ~~~ * instance "ContamFMU" of FMU "ContamFMU.fmu" * ~~~ * Error Code = "3" * Fatal * ExternalInterface/StopExternalInterfaceIfError: Error in ExternalInterface: Check EnergyPlus *.err file. ...Summary of Errors that led to program termination: ..... Reference severe error count=1 ..... Last severe error=ExternalInterface/CalcExternalInterfaceFMUImport: Error when trying to initialize
I have no clue about the reason for this. My assumption is that PyEMS is served as a master in this framework while (E+ & CONTAM as a whole) is supposed to serve as a slave. However, E+ would not allow it to happen since it serves as a master itself in the E+/CONTAM co-simulation. The two roles contradicted each other hence the simulation crashed.
Any help would be greatly appreciated.