worlddynamics / Vensim2MTK.jl

A Julia package to import Vensim .xmile files as ModelingToolkit.jl models.
MIT License
2 stars 1 forks source link

Vensim.jl

DOI

This package provides a function Vensim2MTK that can produce a Julia file of a model using ModelingToolkit from an exported Vensim model.

Usage of the function: The function takes 3 arguments:

Example of use:

using Vensim2MTK

filepath= "path/to/a/vensim/model/model.xmile"
filename= "MTKmodel.jl"
overwrite = false
vensim2MTK(filepath, filename, overwrite) 

This code will write in the file MTKmodel.jl an implementation in ModelingToolkit of the model exported in model.xmile from the Vensim app.

Examples of models used

There are currently 4 models used as examples for the parser: DICE, lotka, commitment and community corona 8. Here is a quick explanation of each as well as where we found them:

List of Vensim functions currently implemented

Issue #12

If some variables need to be initialised by other variables that are not directly initialised, the program automatically initialises them with a default value (42). It is necessary to replace these with values that are at least not too far away from the real ones; just so that the model runs correctly without failing. It is then possible to obtain the true initial value and replace these arbitrary values with those calculated by ModelingToolkit; then re-run the model, obtaining from now on the real values for the whole model.

Issue #33

It is necessary to make sure the model that is to be parsed does not contain special characters in it's variable name. The special characters mentioned are: ",-,(,),+,/,*,^,=,!,{,[,],} and ,.

How to cite this work

@software{emanuele_natale_vensim2mtk_2023,
  author       = {Emanuele Natale and
                  Maël Clergue},
  title        = {Vensim2MTK.jl: v0.1.0},
  month        = july,
  year         = 2023,
  publisher    = {Zenodo},
  version      = {v0.1.0},
  doi          = {10.5281/zenodo.8179079},
  url          = {https://doi.org/10.5281/zenodo.8179079}
}