First time here? Check out the Help page!

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

Problem running an E+ simulation with Python

asked 4 years ago

updated 4 years ago

I'm trying to run a simulation using Python. This is my code, after trying several times, but I get an error. Can you help me to solve it?:

import sys
sys.path.insert(0, 'C:\EnergyPlusV9-3-0') #sys.path.insert(0, '/path/to/EnergyPlusInstallRoot')
from pyenergyplus import api
from pyenergyplus.api import EnergyPlusAPI
from runtime import Runtime


"""
run_energyplus(['-d', '/path/to/output/directory', '-w', '/path/to/weather.epw', '/path/to/input.idf'])
"""
test = Runtime(api)

test.run_energyplus(
  [
    '-d',
    'C:/Users/vicente.castillo/Documents/24_PROYECTO SERGIO/prueba Pyenergyplus/output_prueba',
    '-w',
    'C:/EnergyPlusV9-3-0/ejemplo ENERGY PLUS test_2/USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw',
    'C:/EnergyPlusV9-3-0/ejemplo ENERGY PLUS test_2/5ZoneAirCooled.idf'
  ]
)

Output:

Traceback (most recent call last):
  File "prueba.py", line 15, in <module>
    test = Runtime(api)
  File "C:\Users\vicente.castillo\Documents\24_PROYECTO SERGIO\prueba Pyenergyplus\runtime.py", line 26, in __init__
    self.api.energyplus.restype = c_int
AttributeError: module 'pyenergyplus.api' has no attribute 'energyplus'
Preview: (hide)

Comments

1

Are you using the initial release or the latest bug fix release for EnergyPlus v9.3? There were some issues with the Python modules and APIs that were fixed in the bug fix release.

Aaron Boranian's avatar Aaron Boranian  ( 4 years ago )

First I used the initial release, and now (after your comment) I tried it with the latest bug fix release, and still got the same problem.

VicenteCastilloGuillen's avatar VicenteCastilloGuillen  ( 4 years ago )

1 Answer

Sort by » oldest newest most voted
2

answered 4 years ago

leijerry888's avatar

The following works for me:

from pyenergyplus.api import EnergyPlusAPI
api = EnergyPlusAPI()
api.runtime.run_energyplus(["your", "params", "here"])

I did not get why you need to from runtime import Runtime.

Preview: (hide)
link

Comments

This gives me the error TypeError: run_energyplus() missing 1 required positional argument: 'command_line_args', have you come across this?

sajithwjay's avatar sajithwjay  ( 4 years ago )

You probably have solved this question by now but I came across it when I am trying to get info on Python plugins and I thought I should post this comment while passing through.

In your api.runtime.run_energyplus call, You need to include "state" as the first argument. You create it by:

state = api.state_manager.new_state()
api.runtime.run_energyplus(state, ["your", "params", "here"])

The above syntax works for me for normal IDF files. However, it fails when I try to use python plugins. This is what I am trying to sort out now.

My EP version is 9.5.0

halimgur's avatar halimgur  ( 3 years ago )

Your Answer

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

Add Answer

Training Workshops

Careers

Question Tools

1 follower

Stats

Asked: 4 years ago

Seen: 435 times

Last updated: Jul 30 '20