RMagnolia is an R package that allows Magnolia ODE models (specified using the CSL simulation language) to be built, executed and scripted from within the R statistical computing environment.  Magnolia works by using the rJava package to expose various components of the Magnolia application to R.  The Magnolia translator and compiler, and the executable models created by Magnolia, are represented by R objects that can be manipulated using R statements.  This allows the wide variety of data analysis and visualization features available in R to be applied to Magnolia ODE models.


The Magnolia package can be downloaded by visiting the Magnolia registration page here.

Magnolia requires that a 64-bit version of Java Development Kit (JDK) be installed and configured on your computer.  Additionally, you’ll need the RTools addons, and the devtools and rJava packages.  The general steps for installation are as follows:

  1. Install the 64-bit Java JDK; installers are available here.  Set the JAVA_HOME environment variable to point to the installation directory for the JDK.
  2. Ensure that the 64-bit version of R is installed.  Magnolia works exclusively with the 64-bit version of R.
  3. Download and install the Magnolia source package using the normal package installation mechanisms.  IMPORTANT: because RMagnolia is exclusively a 64 bit package, you may need to use the following command to install it and avoid an error message:

Note that binary distributions of R packages for macOS typically have a file extension of “.tgz”.  If RMagnolia is being installed on R running on macOS, adjust the file name in the above command accordingly.


For usage details, see the “Build and Run a Model” vignette installed with the Magnolia package, which uses the Van der Pol oscillator model as an example.  Briefly, the following code can be used to specify and build the Van Der Pol model code within R, run the model, and generate and R plot showing the resulting trajectories:

Running the above script generates the following plots: