Does EnergyPlusToFMU can be simulated on Python?

217 views
Skip to first unread message

Chao Pan

unread,
Dec 30, 2019, 9:23:53 AM12/30/19
to energyplus-fmu
Hello,

I am working a project that trying to design a controller by Python than simulating with FMU model. I exported the example model (_fmu_export_schedule) to fmu. Then use fmpy to do simulation.
However it always shows this issue? Does EnergyPlusToFMU support simulating by Python?

Thanks,
Chao

Picture1.png


Thierry Nouidui

unread,
Dec 30, 2019, 9:37:15 AM12/30/19
to energyplus-fmu
I suggest trying to run it using PyFMI as well and see how it goes.
I unfortunately don't have experiences with fmpy.

Thanks!

Chao Pan

unread,
Dec 30, 2019, 10:56:55 AM12/30/19
to energyplus-fmu
Thanks, I will try to use PyFMI!
Chao

Chao Pan

unread,
Jan 7, 2020, 10:03:37 AM1/7/20
to energyplus-fmu
Hello Dr. Thierry Nouidui,

I tried to use PyFMI to simulate the EnergyPlusToFMU example, which I used is _fmu_export_schedule. I exported it as FMU, then try to set a custom input as the heat gain from HVAC. However, when I simulate, it shows the "The slave failed to initialize" like the picture. Can I ask help for this issue please?

Capture.JPG

Thierry Nouidui

unread,
Jan 7, 2020, 12:12:46 PM1/7/20
to Chao Pan, energyplus-fmu
Could you share the Python script you are using to run the FMU?
Is any Output_Export folder generated which may contain some log files? If such folder is created and not empty, then share it as well.
BTW: The final time needs to be at least a day (86400). You will need to adjust the number of communication points accordingly...

Thanks!

--
You received this message because you are subscribed to the Google Groups "energyplus-fmu" group.
To unsubscribe from this group and stop receiving emails from it, send an email to energyplus-fm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/energyplus-fmu/ea5a5548-5116-4b7a-abd0-4a8b0f9db005%40googlegroups.com.

Chao Pan

unread,
Jan 7, 2020, 9:10:12 PM1/7/20
to energyplus-fmu
Dear Prof. Nouidui,

Thanks for you help. 
Sorry for presenting issue unclearly. 
Your suggestion is very helpful. I checked the simulation period time and communication points. It should be set at least 86400 s and 96 points per day. After modification, it works.
Thanks again sincerely.

Best regards,
Chao

Could you share the Python script you are using to run the FMU?
Is any Output_Export folder generated which may contain some log files? If such folder is created and not empty, then share it as well.
BTW: The final time needs to be at least a day (86400). You will need to adjust the number of communication points accordingly...

Thanks!

On Tue, Jan 7, 2020 at 6:03 PM Chao Pan <dfpa...@gmail.com> wrote:
Hello Dr. Thierry Nouidui,

I tried to use PyFMI to simulate the EnergyPlusToFMU example, which I used is _fmu_export_schedule. I exported it as FMU, then try to set a custom input as the heat gain from HVAC. However, when I simulate, it shows the "The slave failed to initialize" like the picture. Can I ask help for this issue please?

Capture.JPG



I suggest trying to run it using PyFMI as well and see how it goes.
I unfortunately don't have experiences with fmpy.

Thanks!

On Monday, December 30, 2019 at 5:23:53 PM UTC+3, Chao Pan wrote:
Hello,

I am working a project that trying to design a controller by Python than simulating with FMU model. I exported the example model (_fmu_export_schedule) to fmu. Then use fmpy to do simulation.
However it always shows this issue? Does EnergyPlusToFMU support simulating by Python?

Thanks,
Chao

Picture1.png


--
You received this message because you are subscribed to the Google Groups "energyplus-fmu" group.
To unsubscribe from this group and stop receiving emails from it, send an email to energyp...@googlegroups.com.

Chao Pan

unread,
Jan 15, 2020, 10:45:14 PM1/15/20
to energyplus-fmu
Dear Prof. Nouidui,

Thanks for your help before. May I ask some more questions again?
I used the example EnergyPlus room model, which is "_fmu-export-schedule.idf" downloaded from the EnergyPlusToFMU to do the co-simulation. The simulation can be done successfully if I use the EnergyPlus example model to export the FMU without any modification. However, once I modify any setting in the EnergyPlus model. The simulation can't be done. For example, I only modify the timestep from 4 steps per hour (default) to 60 steps per hour like the figure.
Capture.JPG

Then an FMU is exported by this code: python  ...\EnergyPlusToFMU\Scripts\EnergyPlusToFMU.py  -i ...\Energy+.idd  -w ...\WeatherData\USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw  _fmu-export-schedule.idf.

Afterwards, I tried both simulate this FMU by Python with pyfmi and Dymola. They all failed. In the pyfmi, it shows "FMUException: The slave failed to initialize. See the log for possibly more information." like the following figure:

 Capture.JPG
while the Dymola will shows the following errors:
Capture.JPG

The following is the code for Python simulation which is modified by the example on pyfmi website: fmu_with_input.py
from pyfmi import load_fmu
import numpy.matlib
import matplotlib.pyplot as plt
import numpy as N

def run_demo(with_plots=True):
    """
    Demonstrates how to simulate an FMU with inputs.
    
    See also simulation_with_input.py
    """

    # Generate input
    t = N.linspace(0.,86400.,1440) 
    u = 1000*N.ones(1440)
    u_traj = N.transpose(N.vstack((t,u)))
    input_object = ('Q', u_traj)

    # Load the dynamic library and XML data
    model = load_fmu('_fmu_export_schedule.fmu')
    
    # Set the first input value to the model
    model.set('Q', u[0])
    # Simulate
    res = model.simulate(final_time=86400, input=input_object, options={'ncp':1440})

    x_sim = res['TRooMea']
    u_sim = res['Q']
    time_sim = res['time']

    if with_plots:
        fig = plt.figure(1) 
        plt.subplot(2,1,1)
        plt.plot(time_sim, x_sim) 
        plt.subplot(2,1,2)
        plt.plot(t, u[:])
        plt.show()
if __name__=="__main__":
    run_demo()
 
Thanks again for all your reply!

Best regards,
Chao

Thierry Nouidui

unread,
Jan 16, 2020, 5:28:09 AM1/16/20
to Chao Pan, energyplus-fmu
Dear Chao,

I can't reproduce your problem. You should maybe delete all auxiliary generated files prior to recreating the FMU. On my side, I have changed the IDF file, recompiled the FMU and was able to run it with PyMI. You should also check if one of your files is not in used by another process which prevents it from being re-run.

Thanks!

To unsubscribe from this group and stop receiving emails from it, send an email to energyplus-fm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/energyplus-fmu/6471ceba-8ad2-4c30-aaf0-92fcffc1e581%40googlegroups.com.

Chao Pan

unread,
Jan 16, 2020, 8:50:15 PM1/16/20
to energyplus-fmu
Dear Prof. Nouidui,

Thank you so much for your response. I will check these issues.

Best regards,
Chao


Esther Borkowski

unread,
Jan 18, 2020, 12:38:54 AM1/18/20
to energyplus-fmu
Hi Chao,
Can you run the co-simulation directly from Dymola (without Python)? Does it show the same error messages?
For me, it was sometimes helpful to get the EnergyPlus-Dymola communication working before integrating a third tool.
Cheers,
Esther

Pascal Yamb

unread,
May 30, 2024, 4:08:33 AM5/30/24
to energyplus-fmu

Buy your psychedelic products fast and safe delivery 


https://t.me/healingmeds

https://t.me/healingmeds

https://t.me/healingmeds


> ✔US-US Delivery 

> ✔Fast Shipping 

> ✔Secure Payment Options 

> ✔100% Satisfaction Guaranteed 

> ✔3 Days Refund Policy 

> ✔100% Money-Back if any issue with the product 

> ✔Shipping Service: Express/Standard/Economy 

> ✔Estimated Delivery Time: Express & 3-5  Days 

> ✔Discounts: Get up to 20% off 


https://t.me/healingmeds

https://t.me/healingmeds

https://t.me/healingmeds

Reply all
Reply to author
Forward
0 new messages