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.

Installation

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

Magnolia requires that the 64-bit version of Java 8 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 (version 8u192), 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.  IMPORTANT: because RMagnolia is exclusively a 64 bit package, you’ll need to use the following command to install it and avoid an error message:

Note that on macOS, the downloaded package may be automatically uncompressed, resulting in a file with a name like “RMagnolia_1.1.2.tar”.  If this is the case, adjust the file name in the above command accordingly.

Usage

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: