Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support of JavaScript-Model from JModelica #55

Open
Elfangor93 opened this issue Aug 21, 2019 · 1 comment
Open

Support of JavaScript-Model from JModelica #55

Elfangor93 opened this issue Aug 21, 2019 · 1 comment
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@Elfangor93
Copy link

I created a JavaScript of the BouncingBall.mo modelica model by exporting the FMU with JModelica. It now looks like Composer can't call this model. After inserting the zip with the model and review the simulator the error message "ReferenceError: BouncingBall is not defined" appears in the browser console.

What is missing/wrong with the JavaScript, that it doesnt work with composer?


The original modelica model:
BouncingBall.mo.zip

The compiled JavaScript:
BouncingBall.zip

How I created the JavaScript:

  1. Environment: Ubuntu 18.10, 64-bit
  2. Installing JModelica (https://jmodelica.org/downloads/UsersGuide.pdf#%5B%7B%22num%22%3A30%2C%22gen%22%3A0%7D%2C%7B%22name%22%3A%22XYZ%22%7D%2C70.866%2C515.219%2Cnull%5D)
  3. Installing Emscripten (https://emscripten.org/docs/getting_started/downloads.html#installation-instructions)
  4. Start the JModelica iPython Shell using the command /home/<user_name>/<jmodelica_install_location>/bin/jm_ipython.sh and export the FMU with the following commands
from pymodelica import compile_fmu
file = '/<path_to_file>/BouncingBall.mo'
model = 'BouncingBall'
options = {"copy_source_files_to_fmu":True, "cs_solver":0}
fmu = compile_fmu(model, file, target='cs', version='2.0', compiler_options=options)

(FMU version 2.0, co-simulation, source code, solver: CVODE)
5. Change directory to /<path_to_FMU>/sources/
6. Compile the model to JavaScript using emcc

emcc -I /<jmodelica_install_location>/include/RuntimeLibrary/ -I /<jmodelica_install_location>/ThirdParty/FMI/2.0/ BouncingBall.c -DRT -o BouncingBall.js -s WASM=0

(define RT to avoid errors during compilation see StackOverflow
7. Pack the JavaScript together with the manifest (XML) of the FMU to a zip

@Elfangor93 Elfangor93 changed the title Support of JavaScript-Model from JModelica Support of JavaScript-Model from JModelica #enhancement Aug 21, 2019
@Elfangor93 Elfangor93 changed the title Support of JavaScript-Model from JModelica #enhancement Support of JavaScript-Model from JModelica Aug 21, 2019
@TomasKulhanek TomasKulhanek self-assigned this Mar 12, 2020
@TomasKulhanek TomasKulhanek added the enhancement New feature or request label Mar 12, 2020
@TomasKulhanek TomasKulhanek added this to the 2.0 milestone Mar 12, 2020
@TomasKulhanek
Copy link
Member

Will consider whether Jmodelica support will be added to v2.0. Cvode solver with sources is better alternative than commercial Dymola, or OpenModelica with Euler solver only. Btw., Jmodelica support is discontinued from Modelon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants