Created
May 17, 2018 20:41
-
-
Save TStesco/d02d19e7e382ab8c37d51c96d7891f6d to your computer and use it in GitHub Desktop.
Example usage of energyplus.fmu with JModelica and PyFMI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from pymodelica import compile_fmu | |
from pyfmi import load_fmu | |
import matplotlib.pyplot as plt | |
# add energyplus cli script to $PATH, not needed if already in $PATH | |
os.environ['PATH'] = os.environ['PATH'] +":/opt/EnergyPlus/EnergyPlus-8-9-0" | |
# load .fmu with pyfmi | |
fmu_path = '<path>/_fmu_export_variable.fmu' | |
model = load_fmu(fmu=fmu_path) | |
# change input variable (default in .idf is given to be 6) | |
model.set('yShadeFMU', 1) | |
# get options object | |
opts = model.simulate_options() | |
# set number of communication points dependent on final_time and .idf steps per hour | |
final_time = 60*60*72. # 72 hour simulation | |
idf_steps_per_hour = 6 | |
ncp = final_time/(3600./idf_steps_per_hour) | |
opts['ncp'] = ncp | |
# run simulation and return results | |
res = model.simulate(start_time=0., final_time=final_time, options=opts) | |
print(res.keys()) # show result variables names | |
# plot results | |
fig, ax1 = plt.subplots() | |
ax1.plot(res['time'], res['TRoo'], 'b-') | |
ax1.set_xlabel('time (s)') | |
ax1.set_ylabel('Room Temperature', color='b') | |
ax1.tick_params('y', colors='b') | |
ax2 = ax1.twinx() | |
ax2.plot(res['time'], res['ISolExt'], 'r.') | |
ax2.set_ylabel('Solar Radiation', color='r') | |
ax2.tick_params('y', colors='r') | |
fig.tight_layout() | |
plt.show() |
Hi @stef-papathan and @lymereJ , I am wondering if you have solved this issue. I am struggling with the same issue. I am working with this EnergyPlusToFMU (v.3.1.0, latest version) example file: https://raw.githubusercontent.com/lbl-srg/EnergyPlusToFMU/master/Examples/Actuator/_fmu-export-actuator.idf
My version of EnergyPlus is v.9.4.0 which is the same as the version of the IDF file. Thank you.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Seems like 0s are expected, see here. The IDF should be the ones that come as examples with EnergyPlusToFMU.