Modelica 2023 - Bodylight.js presentation
Created by Tomas Kulhanek

Bodylight.js 2.0 - Web components for FMU simulation,visualisation and animation in standard web browser.

acknowledgment:
Rene Just Nielsen, Matthis Thorade
Ministry of Industry and Trade Czech Republic

team current and past

What language/technology do you use for modeling in computational biology and medicine?

equations

Elena Zappon Efficient Reduced Order Modeling for Coupled Problems in Cardiac Electrophysiology, CompBioMed2023, 13th September 2023
Model
block schema

A C Guyton, T G Coleman, H J Granger, Circulation: overall regulation, Annu Rev Physiol.1972;34:13-46.doi: 10.1146/annurev.ph.34.030172.000305.
model code - Fortran
Correction after reimplementation in 2010

J.Kofránek, et al., Restoration of Guyton‘s Diagram for Regulation of the Circulation ...Physiol Res. 2010;59(6):897-908.doi: 10.33549/physiolres.931838.
model reimplementation code Matlab Simulink
component diagram

Magdalena Otta et al. A 0D model of lower limb haemodynamics: sensitivity analysis, CompBioMed2023, 13th September 2023
explanatory model
to explain:
- equations
- way of computation
- physical reality
who is the audience?
- mathematician/computer scientist
- biomedical engineer
- other domain expert
- clinicians, physicians
- healthcare staff
- students of medicine
- patient
model of glucose insulin regulation - equations



model of glucose insulin regulation - block schema

model of glucose insulin regulation - acausal and component modeling (compartment modeling)

components




Tomas Kulhanek, Jiri Kofranek. Experience with Teaching Different Modeling Techniques on the example of Glucose Insulin Regulation Model,
Annu Int Conf IEEE Eng Med Biol Soc. 2020 Jul;2020:6024-6027. doi: 10.1109/EMBC44109.2020.9176535
model of circulation and its regulation
Guyton's original scheme

implementation in component and acausal modeling language

Frank-Starling law
Frank-Starling law is much more visible in component model - "force of the heart muscle depends on pressure of incoming blood".
Physiolibrary
https://physiolibrary.org
Marek Mateják, Tomáš Kulhánek, Jan Šilar, Pavol Privitzer, Filip Ježek, Jiří Kofránek: Physiolibrary - Modelica library for Physiology, In Conference Proceeding, 10th International Modelica Conference, March 12, 2014, Lund, Sweden, (DOI:10.3384/ECP14096499)
Physiomodel

https://physiomodel.org
>60 000 equations
Mateják, M., Kofránek, J. (2015), Physiomodel – An Integrative Physiology in Modelica, Proceedings of 37th AnnualInternational Conference of the IEEE Engineering in Medicine and Biology Society, IEEE, Milano (It), pp. 1464-1467, ISSN: 1557- 170X.
who is the audience?
- mathematician/computer scientist
- biomedical engineer
- other domain expert
- clinicians, physicians
- healthcare staff
- students of medicine
- patient
missing pieces for reusable components

1. export model to FMU with C source code

2.compile to WebAssembly

Configuration and scripts to facilitate compilation with emscripten
emcc … -O3 –closure 0 …
https://github.com/creative-connections/Bodylight.js-FMU-Compiler
explanatory simulator
- to explain behavior
- to explain prediction
- ...
Simulator
bodylight.js
- scripts to translate model from FMU (co-simulation mode with C source code) to WebAssembly
- webcomponents - javascript library with reusable and configurable custom elements
- for model simulation
- for animation
- for other visualisation/communication etc.
- optional tools (composer, editor) to simplify creating and deploying web simulators
3. download JS with WebAssembly and use it in <bdl-fmi> web component

webcomponents - HTML elements

webcomponents - custom elements


- custom tag for model: fmi


- custom tag for chart


webcomponents - custom elements animation
- export animation from Adobe Animate to JS library
- follows CreateJS API
- custom tag for animation


HTML + webcompontens = in-browser simulator
M.Tiller - Modelica by Example

J.Šilar et al. - Kidney Simulator

webcomponents - implementation and registration


in-browser simulator - INDEX.HTML
1. download or refer bodylight.bundle.js
- EITHER <script src=" bodylight.bundle.js" ></script>
- OR
npm -i bodylight-components
2.include web components in HTML source:
<body aurelia-app="webcomponents">
...


we can put HTML/CSS styling


supported FMI export
performance - WASM 12% slower than native code


WASM1 ~ requestAnimationFrame( () -> {
...
fmiDoStep();
...
})
WASM3 ~ requestAnimationFrame( () -> {
...
fmiDoStep();
fmiDoStep();
fmiDoStep();
...
})hemodynamics
simulator of circulation
simulator of glucose/insulin

co-simulation of multiple models

blood-gas exchange

respiration

hemodynamics of cardiovascular system

static HTML pages - GITHUB pages
digital appendix of scientific paper

simulators in digital textbook - https://egolem.online

native mobile apps





give life to VR/AR




control HW mannequin

simulator of cardiorespiratory treated with ECMO

REST API
Supporting tools
Bodylight.js-FMU-Compiler

Configuration and scripts to facilitate compilation with emscripten
emcc … -O3 –closure 0 …
https://github.com/creative-connections/Bodylight.js-FMU-Compiler
Bodylight Editor

Bodylight VirtualMachine

summary
Bodylight.js - free open-source library to enable in-browser simulation
with reusable and configurable webcomponents
no plugin, no server, no addons

bodylight.physiome.cz
source codes at GITHUB


+
or
+
+

Physiolibrary
https://physiolibrary.org