Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Updated Variable Values Not Reflecting in EnergyPlus Output Files

Description:
I'm relatively new to working with EnergyPlus and the EnergyPlus API. I've implemented a custom logic in Python to update the value of actuators during the runtime of a simulation. However, despite observing these updates during runtime, the generated output files (e.g., <Prefix>out.csv, <Prefix>ssz.csv, <Prefix>szsz.csv) do not reflect these changes. I've also tried using ReadVarsESO.exe to generate a CSV file of output, but the changes are not captured there either.

Efforts Made:
I've thoroughly debugged the code and confirmed that during runtime, the values of the actuators are indeed being updated as expected. Here's a snippet of the output showing the actuator values being updated:

...

zone_air_temp : 17.19054414796448

actuator_value : 13.249069956310262

actuator_updated_value : 13.19054414796448

zone_air_temp : 17.13274368005318

actuator_value : 13.19054414796448

actuator_updated_value : 13.132743680053181

...

Code Snippet:

import sys
from pyenergyplus.api import EnergyPlusAPI

one_time = True
zone_air_temp = 0
fan_actuator = 0

def my_callback(state):
  global one_time, zone_air_temp, fan_actuator

  if one_time:
    if not api.exchange.api_data_fully_ready(state):
      return
    zone_air_temp = api.exchange.get_variable_handle(state, "Zone Air Temperature", "Thermal Zone 1")
    fan_actuator = api.exchange.get_actuator_handle(state, "Fan", "Fan Air Mass Flow Rate", "Standard Fan")
    one_time = False

  zone_air_temp_value = api.exchange.get_variable_value(state, zone_air_temp)
  print("zone_air_temp :  ", zone_air_temp_value)
  fan_actuator_value = api.exchange.get_actuator_value(state, fan_actuator)
  print("actuator_value : ",fan_actuator_value)

  # Custom logic is here:
  api.exchange.set_actuator_value(state, fan_actuator, zone_air_temp_value-4)

  fan_actuator_value = api.exchange.get_actuator_value(state,fan_actuator)
  print("actuator_updated_value : ",fan_actuator_value)

api = EnergyPlusAPI()
state = api.state_manager.new_state()

api.runtime.callback_end_zone_timestep_after_zone_reporting(state, my_callback)
api.exchange.request_variable(state, "Fan Air Mass Flow Rate", "Thermal Zone 1")

api.runtime.run_energyplus(state, sys.argv[1:])

Request for Assistance:
I would appreciate any insights or suggestions on why the updated variable values are not being reflected in the output files. Additionally, if there are any alternative methods to capture these changes effectively, I'm open to exploring those as well.

Thank you for your assistance.

Updated Variable Values Not Reflecting in EnergyPlus Output Files

Description:
I'm relatively new to working with EnergyPlus and the EnergyPlus API. I've implemented a custom logic in Python to update the value of actuators during the runtime of a simulation. However, despite observing these updates during runtime, the generated output files (e.g., <Prefix>out.csv, <Prefix>ssz.csv, <Prefix>szsz.csv) do not reflect these changes. I've also tried using ReadVarsESO.exe to generate a CSV file of output, but the changes are not captured there either.

Efforts Made:
I've thoroughly debugged the code and confirmed that during runtime, the values of the actuators are indeed being updated as expected. Here's a snippet of the output showing the actuator values being updated:

...

zone_air_temp : 17.19054414796448

actuator_value : 13.249069956310262

actuator_updated_value : 13.19054414796448

zone_air_temp : 17.13274368005318

actuator_value : 13.19054414796448

actuator_updated_value : 13.132743680053181

...

Code Snippet:

import sys
from pyenergyplus.api import EnergyPlusAPI

one_time = True
zone_air_temp = 0
fan_actuator = 0

def my_callback(state):
  global one_time, zone_air_temp, fan_actuator

  if one_time:
    if not api.exchange.api_data_fully_ready(state):
      return
    zone_air_temp = api.exchange.get_variable_handle(state, "Zone Air Temperature", "Thermal Zone 1")
    fan_actuator = api.exchange.get_actuator_handle(state, "Fan", "Fan Air Mass Flow Rate", "Standard Fan")
    one_time = False

  zone_air_temp_value = api.exchange.get_variable_value(state, zone_air_temp)
  print("zone_air_temp :  ", zone_air_temp_value)
  fan_actuator_value = api.exchange.get_actuator_value(state, fan_actuator)
  print("actuator_value : ",fan_actuator_value)

  # Custom logic is here:
  api.exchange.set_actuator_value(state, fan_actuator, zone_air_temp_value-4)

  fan_actuator_value = api.exchange.get_actuator_value(state,fan_actuator)
  print("actuator_updated_value : ",fan_actuator_value)

api = EnergyPlusAPI()
state = api.state_manager.new_state()

api.runtime.callback_end_zone_timestep_after_zone_reporting(state, my_callback)
api.exchange.request_variable(state, "Fan Air Mass Flow Rate", "Thermal Zone 1")

api.runtime.run_energyplus(state, sys.argv[1:])

Request for Assistance:
I would appreciate any insights or suggestions on why the updated variable values are not being reflected in the output files. Additionally, if there are any alternative methods to capture these changes effectively, I'm open to exploring those as well.

Thank you for your assistance.

Updated Variable Values Not Reflecting in EnergyPlus Output Files

Description:
I'm relatively new to working with EnergyPlus and the EnergyPlus API. I've implemented a custom logic in Python to update the value of actuators during the runtime of a simulation. However, despite observing these updates during runtime, the generated output files (e.g., <Prefix>out.csv, <Prefix>ssz.csv, <Prefix>szsz.csv) do not reflect these changes. I've also tried using ReadVarsESO.exe to generate a CSV file of output, but the changes are not captured there either.

Efforts Made:
I've thoroughly debugged the code and confirmed that during runtime, the values of the actuators are indeed being updated as expected. Here's a snippet of the output showing the actuator values being updated:

...

zone_air_temp : 17.19054414796448

actuator_value : 13.249069956310262

actuator_updated_value : 13.19054414796448

zone_air_temp : 17.13274368005318

actuator_value : 13.19054414796448

actuator_updated_value : 13.132743680053181

...

Code Snippet:

import sys
from pyenergyplus.api import EnergyPlusAPI

one_time = True
zone_air_temp = 0
fan_actuator = 0

def my_callback(state):
  global one_time, zone_air_temp, fan_actuator

  if one_time:
    if not api.exchange.api_data_fully_ready(state):
      return
    zone_air_temp = api.exchange.get_variable_handle(state, "Zone Air Temperature", "Thermal Zone 1")
    fan_actuator = api.exchange.get_actuator_handle(state, "Fan", "Fan Air Mass Flow Rate", "Standard Fan")
    one_time = False

  zone_air_temp_value = api.exchange.get_variable_value(state, zone_air_temp)
  print("zone_air_temp :  ", zone_air_temp_value)
  fan_actuator_value = api.exchange.get_actuator_value(state, fan_actuator)
  print("actuator_value : ",fan_actuator_value)

  # Custom logic is here:
  api.exchange.set_actuator_value(state, fan_actuator, zone_air_temp_value-4)

  fan_actuator_value = api.exchange.get_actuator_value(state,fan_actuator)
  print("actuator_updated_value : ",fan_actuator_value)

api = EnergyPlusAPI()
state = api.state_manager.new_state()

api.runtime.callback_end_zone_timestep_after_zone_reporting(state, my_callback)
api.exchange.request_variable(state, "Fan Air Mass Flow Rate", "Thermal Zone 1")

api.runtime.run_energyplus(state, sys.argv[1:])

Request for Assistance:
I would appreciate any insights or suggestions on why the updated variable values are not being reflected in the output files. Additionally, if there are any alternative methods to capture these changes effectively, I'm open to exploring those as well.

Thank you for your assistance.