NREL / Spawn

Other
16 stars 3 forks source link

Simulating multiple instances of the same FMU fails #65

Open ThoreWietzke opened 3 months ago

ThoreWietzke commented 3 months ago

I use a standalone FMU which is based on Spawn of EnergyPlus. Simulating the FMU with FMPy works fine. Since the simulation takes a long time and I want to compare different controllers, I want to use Python multiprocessing to do the simulations in parallel.

One instance is created and simulated, but the other fail with the following error message:

"remove_all: The process cannot access the file because it is being used by another process.: 
"C:/.../spawn-MultizoneModel_v2_final_closedDoors.flo\EnergyPlus""
[ERROR] Error: The following error was detected at time: 15552000
[ERROR] 15552000.000 MultizoneModel_v2_final_closedDoors.flo.building: Executing 
'""C:\Spawn-light-0.4.3-7048a72798-win64\bin/spawn-0.4.3-7048a72798.exe" energyplus create-fmu  
--output-path "C:/.../spawn-MultizoneModel_v2_final_closedDoors.flo/EnergyPlus.fmu" 
"C:/.../spawn-MultizoneModel_v2_final_closedDoors.flo/ModelicaBuildingsEnergyPlus.json""' 
failed to generate fmu 'C:/.../spawn-MultizoneModel_v2_final_closedDoors.flo/EnergyPlus.fmu'.
[ERROR] The stack of functions is:
[ERROR] Buildings.ThermalZones.EnergyPlus_9_6_0.BaseClasses.initialize
[ERROR] Buildings.ThermalZones.EnergyPlus_9_6_0.BaseClasses.initialize(
flo.wes.fmuZon.adapter, 
flo.building.isSynchronized)
[ERROR] 

Setting an instance name has no effect, as only the output folder spawn-MultizoneModel_v2_final_closedDoors.flo is created. I already used FMUs created from EnergyPlusToFMU and they create their own output folder and multiprocessing works fine.

Also, I can't help with the exact settings used to create the FMU as I don't have a Dymola lincense.

mwetter commented 3 months ago

I suspect when you set up the Python multi-processing, you do not assign a separate working directory to each process. I am not sure however if that is indeed the case as your error message shows C:/.../spawn-MultizoneModel_v2_final_closedDoors.flo and the ... that is not shown in your message is what should be unique for each process.

ThoreWietzke commented 3 months ago

Yes, a separate wkdir solves the issue. My expactation with the instance_name in FMPy was, that it takes care of this.