Following this question, I'm trying to compare the results of the simulation between JModelica and OpenModelica. The Modelica file is identical to the above-mentioned post and the JModelica wrapper is the corrected version:
#%%
from pymodelica import compile_fmu
from pyfmi import load_fmu
import matplotlib.pylab as plt
#%%
model_name = 'friction1D.fricexample_1'
mofile = 'friction1D.mo'
#%%
fmu_name = compile_fmu(model_name, mofile)
sim = load_fmu(fmu_name)
#%%
opts = sim.simulate_options()
opts["ncp"] = 500
opts['CVode_options']['rtol'] = 1.0e-8
res = sim.simulate(final_time=10, options=opts)
#%%
time = res['time']
vel = res['v']
ffo = res['ffo']
sfo = res['sfo']
#%%
plt.plot(time, vel)
plt.xlabel("Time (s)")
plt.ylabel("Velocity (m/s)")
plt.show()
#%%
plt.plot(time, ffo, label="friction force")
plt.plot(time, sfo, label="shear force")
plt.xlabel("Time (s)")
plt.ylabel("Force (N)")
plt.legend()
plt.show()
resulting in:
Fig.1 - Velocity versus time solved by JModelica.
and
Fig.2 - Friction and shear force versus time solved by JModelica.
but if I set the simulation options in OpenModelica as:
Fig.3 - Simulation options in OpenModelica.
which results in:
Fig.4 - Velocity versus time solved by OpenModelica.
and
Fig.5 - Friction and shear force versus time solved by OpenModelica.
I would appreciate it if you could help me know why the results are so different and how I can achieve a similar simulation with these two different compilers.
P.S. posted a follow-up question here on the OpenModelica forum.