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

Revision history [back]

click to hide/show revision 1
initial version

How to set different working directories for parallel simulations?

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  = 'file.fmu'
model2_fmu  = 'file.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

How to set different working directories for parallel simulations?

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  = 'file.fmu'
'file1.fmu'
model2_fmu  = 'file.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