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

How to set different working directories for parallel simulations?

asked 2019-10-24 01:20:48 -0600

scrox gravatar image

updated 2019-11-27 21:59:06 -0600

Hi!

I want to run simultaneously multiple simulations. The problem is that every simulation exports its files to the same folder, "Output_EPExport_Slave", in the current working directory. It therefore overwrites variables.cfg file and the first simulation fails since it cannot find the corresponding variables.

Is there are way to set different working directories? In my code you can see a work-around. I would like to avoid that. The different folder paths in the load_fmu seems not to set the working directory. Not sure whether that is a Energyplus or PyFMI problem.

from   pyfmi import load_fmu,fmi
import numpy as np
import os      
model1_fmu  = 'file1.fmu'
model2_fmu  = 'file2.fmu'
model1_path = 'path'
model2_path = 'path'
os.chdir(model1_path)
model1      = load_fmu(model1_fmu,model1_path)
os.chdir(model2_path)
model2      = load_fmu(model2_fmu,model2_path)
final_time  = 60*60*24*3
step_size   = 60*10
start_time  = 0
os.chdir(model1_path)
model1.initialize(start_time,final_time)
os.chdir(model2_path)    
model2.initialize(start_time,final_time)
t_step      = start_time
res_heat1 = []
res_heat2 = []
while t_step < final_time:
    print(t_step)
    temperature = 15.
    shading     = 6
    model1.set('drybulbtemp',temperature)
    model2.set('yShade', shading)
    os.chdir(model1_path)
    status1 = model1.do_step(current_t=t_step, step_size=step_size)
    os.chdir(model2_path)
    status2 = model2.do_step(current_t=t_step, step_size=step_size)
    print('Status: ',status1,' ',status2)

    res_heat1.append(model1.get('heat')[0])
    res_heat2.append(model2.get('heat')[0])

    t_step += step_size
edit retag flag offensive close merge delete

Comments

I know it is not what you are looking for, but you could run two different python instances pointing two different folders: you could avoid all those "chdir" commands.

Gio gravatar imageGio ( 2019-10-25 01:43:30 -0600 )edit

that is possible, maybe with acron in linux. but it would make the simulation set-up not easier and I would lose central steering options with PyFMI

scrox gravatar imagescrox ( 2019-10-27 00:29:04 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-11-25 07:39:08 -0600

Thierry Nouidui gravatar image

updated 2019-11-25 07:40:04 -0600

The output folder of an EnergyplusFMU is defined as Output_EPExport_+ the FMU instanceName (e.g. Output_EPExport_Slave1, Output_EPExport_Slave2). In a co-simulation scenario, the instanceName of an FMU is supposed to be unique across the FMUs. So if your FMUs have unique instance names then, their outputs should be written in different folders.

edit flag offensive delete link more

Comments

Unfortunately, I cannot concur. Although my fmu files have unique names (there was a mistake in the example, sorry), the load_fmu function of pyfmi only creates a 'Output_EPExport_Slave' folder in the working directory. It neither creates a 'Output_EPExport_file1' nor a 'Output_EPExport_file2'. The function get_identifier() also provides me with different names.

scrox gravatar imagescrox ( 2019-11-27 22:17:19 -0600 )edit

This sounds to me like a potential PyFMI issue then. The fmiInstantiateSlave() function of EnergyPlusToFMU gets the instanceName from the master as argument of the fmiInstantiateSlave(). It then uses that name to write a unique Output folder. Now the question will be to know the string which is passed to the function by PyFMI. If PyFMI doesn't pass the correct instanceName then the FMU will not be able to write a unique folder...You may want to check with PyFMI and figure out the string which is passed asinstanceName at the invocation of fmiInstantiateSlave().

Thierry Nouidui gravatar imageThierry Nouidui ( 2019-11-27 23:42:50 -0600 )edit

Your Answer

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

Add Answer

 



Question Tools

1 follower

Stats

Asked: 2019-10-24 01:20:48 -0600

Seen: 141 times

Last updated: Nov 27