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

Simulation using eppy fails after modifying materials in IDF file #420

Open
giovanna99zz opened this issue May 2, 2023 · 4 comments
Open

Comments

@giovanna99zz
Copy link

Hi Santosh,
I'm running into an issue with my eppy scripts when trying to run .idf files after modifying the materials.

Initially, I created an IDF file named "practice-2.idf" using DesignBuilder and ran a successful energyplus simulation in Python using eppy. The simulation produced an HTM file, which I was able to read and extract values from.
However, when I modified the materials in the original IDF file and tried to run a new simulation using Python with eppy, I encountered an error message: "Fatal error -- final processing. Program exited before simulations began."
Could you please suggest any solutions to help me overcome this error?

Here are some details:
Energyplus version of 9.4.0
DesignBuilder version of 7.0.1.006

And here is the code I wrote:

import copy
import numpy as np
import pandas as pd
import random
import os

import sys

from eppy import modeleditor
from eppy.modeleditor import IDF
import witheppy.runner
import eppy
import witheppy.runandget as runandget
import pprint
import witheppy.runandget as runandget
from eppy.results import readhtml
from eppy.runner.run_functions import runIDFs
import concurrent.futures
import multiprocessing
import random
import subprocess
def worker(workerid):
print(f"start {workerid}")
p = subprocess.Popen(["sleep", f"{random.randint(1,30)}"])
p.wait()
print(f"stop {workerid}")
return workerid

def main():
tasks = []
with concurrent.futures.ThreadPoolExecutor(max_workers=20) as pool:
for i in range(20):
tasks.append(pool.submit(worker, i))

    print("waiting for tasks...", flush=True)
    for task in concurrent.futures.as_completed(tasks):
        print(f"completed {task.result()}", flush=True)
    print("done.")

main()

pathnameto_eppy = "C:/Energypl"
sys.path.append(pathnameto_eppy)
iddfile = "C:/Energypl/Energy+.idd"
fname1 = r"D:/Designbuilder/Project eptry/practice-3.idf"
IDF.setiddname(iddfile)
idf1 = IDF(fname1)
idf1.printidf()
building = idf1.idfobjects['BUILDING'][0]
building.Name = "Empire State Building"

materials = idf1.idfobjects["MATERIAL"]
firstmaterial = materials[0]
materials.append(materials[0])
print(len(materials))
idf1.saveas(r'D://Designbuilder/Project eptry/practice-4.idf')
epwfile = r"D://Designbuilder/Project eptry/AUS_VIC.Melbourne.948660_IWEC.epw"
idfname = r"D://Designbuilder/Project eptry/practice-4.idf"

idf = IDF(idfname, epwfile)
idf.runfile()

And I am getting the below error. Could you help me with this error?

CalledProcessError Traceback (most recent call last)
File c:\Users\zhang\anaconda3\lib\site-packages\eppy\runner\run_functions.py:381, in run(idf, weather, output_directory, annual, design_day, idd, epmacro, expandobjects, readvars, output_prefix, output_suffix, version, verbose, ep_version)
380 print("\r\n" + " ".join(cmd) + "\r\n")
--> 381 check_call(cmd)
382 elif verbose == "q":

File c:\Users\zhang\anaconda3\lib\subprocess.py:369, in check_call(*popenargs, **kwargs)
368 cmd = popenargs[0]
--> 369 raise CalledProcessError(retcode, cmd)
370 return 0

CalledProcessError: Command '['C:\Energypl\energyplus.exe', '--weather', 'D:\Designbuilder\Project eptry\AUS_VIC.Melbourne.948660_IWEC.epw', '--output-directory', 'd:\Pycharm projects', '--idd', 'C:\Energypl\Energy+.idd', 'D:\Designbuilder\Project eptry\practice-4.idf']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

EnergyPlusRunError Traceback (most recent call last)
Cell In[31], line 1
----> 1 idf.runfile()

File c:\Users\zhang\anaconda3\lib\site-packages\eppy\modeleditor.py:1132, in IDF.runfile(self, **kwargs)
1130 epw = kwargs.pop("weather", self.epw)
1131 try:
-> 1132 run(self, weather=epw, idd=idd, **kwargs)
1133 finally:
...
************* Fatal error -- final processing. Program exited before simulations began. See previous error messages.
************* EnergyPlus Warmup Error Summary. During Warmup: 0 Warning; 0 Severe Errors.
************* EnergyPlus Sizing Error Summary. During Sizing: 0 Warning; 0 Severe Errors.
************* EnergyPlus Terminated--Fatal Error Detected. 0 Warning; 4 Severe Errors; Elapsed Time=00hr 00min 0.47sec

Thanks in advance.

@santoshphilip
Copy link
Owner

@giovanna99zz , I am looking at the issue right now.
If you are still online, I may have some responses/questions

@santoshphilip
Copy link
Owner

@giovanna99zz ,

when you type code in the comments, put 4 spaces before the code. It will show up as code. You can hit. the preview tab to ensure that your comment is formatted well


I am not yet seeing where the probelm is occuring. In the meantime,

Two questions:

Question 1. What is your intent with this code

materials = idf1.idfobjects["MATERIAL"]
firstmaterial = materials[0]
materials.append(materials[0])

I can see a potential problem in the code. Let me show through a simple example.

l = [[1,2], [3,4]]
first_l = l[0]
l.append(l[0])
print(l)

>> [[1, 2], [3, 4], [1, 2]]


l[0][0] = 3
print(l)

>> [[3, 2], [3, 4], [3, 2]]

# Note that l[0] and l[2] have changed, even though you changed only l[0]
# something similar happens in your code
# you may wind up with two materials with the same `Name`

Question 2. Use idf.run() instead of idf.runfile(). Well .. this was not really a question :-)

Make these changes, rerun your code and see what happens.

@giovanna99zz
Copy link
Author

@santoshphilip
Hi Santosh,
sorry for reply to you a little bit late. I tried your solutions and reset the EnergyPlus model, and it works.

But when I modified the thickness of the insulation material, it reports error again. Could you help me with this new problem?
I have written this:
material
material1 = materials[10]
material.Thickness = 0.5
print(materials)

At this stage, the thickness of the materials has been modified successfully (I've checked the idf file in EnergyPlus idf editor).
Then I tried to save this file and launch energyplus simulation again to test if increasing thickness of insulation affect the energy consumption.

idf1.saveas(r'D://Designbuilder/Project eptry/practice-5.idf')
def make_eplaunch_options(idf):
"""Make options for run, so that it runs like EPLaunch on Windows"""
idfversion = idf.idfobjects['version'][0].Version_Identifier.split('.')
idfversion.extend([0] * (3 - len(idfversion)))
idfversionstr = '-'.join([str(item) for item in idfversion])
fname = idf.idfname
options = {
# 'ep_version':idfversionstr, # runIDFs needs the version number
# idf.run does not need the above arg
# you can leave it there and it will be fine :-)
'output_prefix':r'D:/Designbuilder/Project eptry/1',
'output_suffix':r'D:/Designbuilder/Project eptry/1',
'output_directory':r'D:/Designbuilder/Project eptry',
'readvars':True,
'expandobjects':True
}
return options
options = {
# 'ep_version':idfversionstr, # runIDFs needs the version number
# idf.run does not need the above arg
# you can leave it there and it will be fine :-)
'output_prefix':r'D:/Designbuilder/Project eptry/1.csv',
'output_suffix':r'D:/Designbuilder/Project eptry/1.htm',
'output_directory':r'D:/Designbuilder/Project eptry',
'readvars':True,
'expandobjects':True
}
epwfile = r"D://Designbuilder/Project eptry/AUS_VIC.Melbourne.948660_IWEC.epw"
idfname = r"D://Designbuilder/Project eptry/practice-5.idf"
idf = IDF(idfname, epwfile)
idf.run()

And this time it reports errors:
CalledProcessError Traceback (most recent call last)
File c:\Users\zhang\anaconda3\lib\site-packages\eppy\runner\run_functions.py:381, in run(idf, weather, output_directory, annual, design_day, idd, epmacro, expandobjects, readvars, output_prefix, output_suffix, version, verbose, ep_version)
380 print("\r\n" + " ".join(cmd) + "\r\n")
--> 381 check_call(cmd)
382 elif verbose == "q":

File c:\Users\zhang\anaconda3\lib\subprocess.py:369, in check_call(*popenargs, **kwargs)
368 cmd = popenargs[0]
--> 369 raise CalledProcessError(retcode, cmd)
370 return 0

CalledProcessError: Command '['C:\Energypl\energyplus.exe', '--weather', 'D:\Designbuilder\Project eptry\AUS_VIC.Melbourne.948660_IWEC.epw', '--output-directory', 'd:\Pycharm projects', '--idd', 'C:\Energypl\Energy+.idd', 'D:\Designbuilder\Project eptry\practice-5.idf']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

EnergyPlusRunError Traceback (most recent call last)
Cell In[206], line 1
----> 1 idf.runfile()

File c:\Users\zhang\anaconda3\lib\site-packages\eppy\modeleditor.py:1132, in IDF.runfile(self, **kwargs)
1130 epw = kwargs.pop("weather", self.epw)
1131 try:
-> 1132 run(self, weather=epw, idd=idd, **kwargs)
1133 finally:
...
************* Fatal error -- final processing. Program exited before simulations began. See previous error messages.
************* EnergyPlus Warmup Error Summary. During Warmup: 0 Warning; 0 Severe Errors.
************* EnergyPlus Sizing Error Summary. During Sizing: 0 Warning; 0 Severe Errors.
************* EnergyPlus Terminated--Fatal Error Detected. 0 Warning; 2 Severe Errors; Elapsed Time=00hr 00min 0.36sec

@giovanna99zz
Copy link
Author

@giovanna99zz ,

when you type code in the comments, put 4 spaces before the code. It will show up as code. You can hit. the preview tab to ensure that your comment is formatted well

I am not yet seeing where the probelm is occuring. In the meantime,

Two questions:

Question 1. What is your intent with this code

materials = idf1.idfobjects["MATERIAL"]
firstmaterial = materials[0]
materials.append(materials[0])

I can see a potential problem in the code. Let me show through a simple example.

l = [[1,2], [3,4]]
first_l = l[0]
l.append(l[0])
print(l)

>> [[1, 2], [3, 4], [1, 2]]


l[0][0] = 3
print(l)

>> [[3, 2], [3, 4], [3, 2]]

# Note that l[0] and l[2] have changed, even though you changed only l[0]
# something similar happens in your code
# you may wind up with two materials with the same `Name`

Question 2. Use idf.run() instead of idf.runfile(). Well .. this was not really a question :-)

Make these changes, rerun your code and see what happens.

For the question 1: I've just followed the eppy tutorial to see what kind of materials in this idf.
For the question 2: I modified the new material's name, used idf.run() and it worked through well, thanks.

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