Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Energyplus terminated and the program iteration stopped #433

Open
Split031 opened this issue Dec 26, 2023 · 4 comments
Open

Energyplus terminated and the program iteration stopped #433

Split031 opened this issue Dec 26, 2023 · 4 comments

Comments

@Split031
Copy link

Hi, I tried to run idf files using eppy for building envelope parameters optimization, combined EnergyPlus with Genetic Algorithm. Each parameter has its own boundary. GA program generates different parameter combinations within the boundary and uses them to run idf files with eppy.

During the iteration, the GA program often terminated because EnergyPlus detected the error and terminated. And that stopped the whole iteration. I can't fix this problem by changing the parameters' boundary.

My question is: Can I just jump over the wrong idf file running ( after EnergyPlus detects the error ) and let the Python program iteration keep going to do the other idf running?

I would appreciate it if you could help me solve this problem. Thank you!

The code is:
`import os
import pandas as pd
from eppy.modeleditor import IDF

def eppy_cal(para):
iddfile = "D:/EnergyPlus/EnergyPlusV8-7-0/Energy+.idd"
IDF.setiddname(iddfile)
idfname = "./SH.S.WWR0.3.3F.idf"
epwfile = "./CHN_Shanghai.Shanghai.583620_CSWD.epw"
idf = IDF(idfname, epwfile)

idf.run(output_directory='./', readvars=True, output_prefix='Result', output_suffix='C')

files = os.listdir(os.getcwd())
extensions_not_to_delete = ['.idf', '.epw', '.py', '.csv', '.png', '__pycache__']
for file in files:
    if not any(file.endswith(ext) for ext in extensions_not_to_delete):
        file_path = os.path.join(os.getcwd(), file)
        os.remove(file_path)

df = pd.read_csv("./Result.csv")
selected_data = df.iloc[:, [32, 33]]
energy_consumption = selected_data.sum().sum()

return energy_consumption`
@santoshphilip
Copy link
Owner

@Split031 ,

Here is my reframing of your issue:

  • You want you script to continue running even if an E+ run/simulation fails.
  • I am not sure if eppy does this right now.
  • Even if eppy does not do this, I think it is a worthwhile functionality to have

I'll start to look into this.
idf.run() is a tricky part of the code. So this is going to take a little attendion from me.

@santoshphilip
Copy link
Owner

for clarity, I have reformatted your function:

import os
import pandas as pd
from eppy.modeleditor import IDF

def eppy_cal(para):
    iddfile = "D:/EnergyPlus/EnergyPlusV8-7-0/Energy+.idd"
    IDF.setiddname(iddfile)
    idfname = "./SH.S.WWR0.3.3F.idf"
    epwfile = "./CHN_Shanghai.Shanghai.583620_CSWD.epw"
    idf = IDF(idfname, epwfile)

idf.run(output_directory='./', readvars=True, output_prefix='Result', output_suffix='C')

Let me know if I got it wrong.

santoshphilip pushed a commit that referenced this issue Dec 28, 2023
python i433.py
@santoshphilip
Copy link
Owner

I made a branch i433_run

take a look at script i433.py
run the script.
It will run from directory eppy

Is this a solution for your issue ?

@santoshphilip
Copy link
Owner

The code in i433.py:

import eppy
from eppy.runner.run_functions import EnergyPlusRunError

goodfile = "goodfile.idf"
badfile = "badfile.idf"
wfile = "USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw"
goodidf = eppy.openidf(goodfile, epw=wfile)
badidf = eppy.openidf(badfile, epw=wfile)

idfs = [badidf, goodidf]
for an_idf in idfs:
    try:    
        an_idf.run(verbose='s')
        print(f"sucessfully ran {an_idf.idfname}")
    except EnergyPlusRunError as e:
        print(f"error in running {an_idf.idfname}")        

This will run without the script stopping even though it has a bad file that E+ cannot simulate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants