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

Get Indoor Air Temperature of Thermal Zone (during Runtime)

asked 2020-12-24 19:19:29 -0500

Chelydrae's avatar

updated 2021-03-29 08:58:58 -0500

Dear all,

I am looking for a solution on a beginner problem:

I want to extract the indoor air temperature of one specific thermal zone during runtime (with the python api). I did not find a solution in the documentation yet. Any hint is highly welcome!

Best Regards, P

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
3

answered 2020-12-27 07:02:29 -0500

hermmanhender's avatar

updated 2020-12-27 07:04:11 -0500

Hello.

Here a possible solution to your problem.

import sys
sys.path.insert(0, 'C:/EnergyPlusV9-4-0')
from pyenergyplus.api import EnergyPlusAPI
api = EnergyPlusAPI()

#Define your function to execute in runtime
def my_function(state):
   if api.exchange.api_data_fully_ready(state): #Necessary condition
        if api.exchange.warmup_flag(state) == 0:
           # Handles
           To_handle = api.exchange.get_variable_handle(state, "Site Outdoor Air Drybulb Temperature", "Environment")
           Ti_handle = api.exchange.get_variable_handle(state, "Zone Mean Air Temperature", "Thermal Zone: Modelo_Simple")
           # Variable value
           To = api.exchange.get_variable_value(state, To_handle)      
           Ti = api.exchange.get_variable_value(state, Ti_handle)
           '''Here you can put Ti in a DataFrame, array, other'''

#After define you function, you must initializate the program
state = api.state_manager.new_state() #Necessary condition
api.state_manager.reset_state(state)
api.runtime.callback_begin_zone_timestep_after_init_heat_balance(state, my_function)
api.runtime.run_energyplus(state, ['-d', Folder_Output_path, '-w', Weather_file_path, IDF_file_path])

I hope that this code will be useful.

Best Regards, Germán Henderson

edit flag offensive delete link more

Comments

Thank you very much German! I found another solution using EMS but your approach is much better!

Chelydrae's avatar Chelydrae  ( 2020-12-27 14:51:33 -0500 )edit

I tried to put Ti in a DataFrame, but I do not manage to access the dataframe after the simulation complete. I got the error "python cannot be converted to pointer". What would be the best way the get these values ?

LeaGon's avatar LeaGon  ( 2021-06-30 10:21:59 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Careers

Question Tools

1 follower

Stats

Asked: 2020-12-24 19:19:29 -0500

Seen: 199 times

Last updated: Dec 27 '20