Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


The majority of the BIM2Modelica examples are also running with JModelica.

To perform a simulation experiment with JModelica following preparation steps have to be done:

Installation of JModelica

Download JModelica from The easiest way is to install the Windows installer.

Running a simulation experiment

The folder BIM2Modelica/Resources/Scripts/JModelica contains Python Scripts which define exactly the same simulation experiments as in the folder with the mos-files for simulation experiments with Dymola.

The following Python script defines a JModelica simulation experiment for the example ModelicaModels.IFC2X3.SBT_Unit_Test_Cases.AWS1_SB:

# paths and info
import os, sys
homeDir = os.environ['HOMEPATH']
jmodDir = os.environ['JMODELICA_HOME']
workDir = "Desktop" # has to be adapted by the user !!!
moLiDir = os.path.join(homeDir, workDir, "BIM2Modelica")

# give the path to directory where is stored
moLibs = [os.path.join(jmodDir, "ThirdParty\MSL\Modelica"),

print(all(os.path.isfile(os.path.join(moLib, "")) for moLib in moLibs))

# compile model to fmu
from pymodelica import compile_fmu
model_name = 'ModelicaModels.IFC2X3.SBT_Unit_Test_Cases.AWS1_SB'
my_fmu = compile_fmu(model_name, moLibs)

# simulate the fmu and store results
from pyfmi import load_fmu

myModel = load_fmu(my_fmu)

opts = myModel.simulate_options()
opts['solver'] = "CVode"
opts['ncp'] = 8760
opts["CVode_options"]['discr'] = 'BDF'
opts['CVode_options']['iter'] = 'Newton'
opts['CVode_options']['maxord'] = 5
opts['CVode_options']['atol'] = 1e-5
opts['CVode_options']['rtol'] = 1e-5

res = myModel.simulate(start_time=0.0, final_time=31536000.0, options=opts)

# plotting of the results
import pylab as P
fig = P.figure(1)
# building
# temperatures
y1 = res['ambient.TAirRef']
y2 = res['building.zone_1.TAir']
y3 = res['building.zone_2.TAir']
y4 = res['building.zone_3.TAir']
y5 = res['building.zone_1.TOperative']
t = res['time']
P.plot(t, y1, t, y2, t, y3, t, y4, t, y5)
P.ylabel('Temperature (K)')
P.xlabel('Time (s)')
# Heating load
y1 = res['building.zone_1.Q_flow_heating']
y2 = res['building.zone_2.Q_flow_heating']
y3 = res['building.zone_3.Q_flow_heating']
P.plot(t, y1, t, y2, t, y3)
P.ylabel('power (W)')
P.xlabel('Time (s)')

This script can be executed with the IPython shell of JModelica:


When the simulation experiment with JModelica is finished the results are displayed in two plots (compare their definitions in the Python code):

Simulation results