This page will look better in a graphical browser that supports web standards, but is accessible to any browser or internet device.

Served by Samwise.

Cardiac Physiome Society workshop: November 6-9, 2017 , Toronto

Miscellaneous Short Topics in MML

This page is for the current JSim version 2.0. Click here for the earlier JSim 1.6 version.



Public, Private and Extern variables

To make models adequately general, JSim allows some variables to be specified as "extern", which means they are not calculated by the model, but are provided to the model externally by the JSim user environment. The run-time environment requires that explicit values be assigned to all externs before a model can be run. Extern variables are considered completely constrained, so no additional MML constraints are required. A sample voltage inverter follows:

(Java plugin required)

MML variables may be designated as "private", which means they are not visible to the run-time interface. This can be useful in reducing clutter if a variable is uninteresting at run-time. Extern variables may not be private. Variable neither private nor extern are considered public.:

(Java plugin required)

Run-time output:


Public variables may be redeclared as extern or private. This is accomplished with the keywords extern or private followed immediately by the variable name and can be useful when sub-variables are created automatically as public, as with domains. The following example makes t.min private, making it unchangable at run-time (see following section).:

(Java plugin required)

Choice variables

Choice variables are integer variables whose value is set by the user via a menu of defined values. For example:

choice fruit("apple", "banana", "cherry") = 2;

Above, the label "apple" is associated with the value 1, "banana" with 2, and "cherry" with 3. "banana" will be the default value.

You may arbitrarily assign associated numeric values by using integers as arguments:

choice zork(0, "zero", "one", "two", 10, "ten", "eleven") = 10;

Here the numeric values correspond in the natural way to the text labels. Only the values 0, 1, 2, 10 and 11 will be allowed.

If a choice variable is calculated from other variables, it becomes an output variable. In this case, it behaves no differently than any other integer variable. Example:

int n = 3;
choice fruit("apple", "banana", "cherry");
fruit = n;

At this time, choice variables are all scalars, and have no associated domains.

Symbolic Derivatives

JSim can solve some variables via symbolic differentiation of other fully constrained variables.:

(Java plugin required)

JSim currently can only differentiate variables which are constrained by explicit algebraic constraints. It cannot take derivatives of extern variables, implicitly constrained variables, ODE variables, etc. Since the chain rule from calculus is used, the differentiated variable must depend only on other variables with explicit algebraic constraints. In the following example, the attempt to differentiate c would generate an error due to c's nested dependence upon the extern variable a:

math deriv2 {
  realDomain t;
  t.min=0; t.max=10;;
  extern a(t);
  real b(t) = a^2 + t;
  real c(t) = exp(b);
  real d(t) = c:t;      // solve d by differentiating c

The colon (derivative) operator may also be applied to expressions. It has high precedence, so this requires the use of paretheses:

(Java plugin required)

Variable Properties

Properties allow tagged values to be associated with a variable. Currently, only string values are supported. The "desc" and "help" properties are defined by default. The "desc" property is a concise one-line description of the variable. The "help" property is free-form text that may extend to multiple lines. Additional properties may be specified on a model-by-model basis with the MML "property" command. Additional properties, if defined, may be used to label variables for various automated analyses currently under development. For example, the additional property "fma" might be defined that connects a variable the Foundational Model of Anatomy ontology. Properties are assigned by optional assignments that should be clear from the following example:

(Java plugin required)

If defined, the "desc" and "help" property values will appear in the help popup for a variable in the GUI. The "desc" and "help" properties are normally defined as double-quoted strings, with "\n" being interpreted as a line separator for

If a property value text is extensive, it may be simpler to use the alternative double-brace specification for multi-line text:

(Java plugin required)

When adding customizable help to a model, remember that model help automatically includes the default value and unit (if any) for input variables and the relevant equations and unit (if any) for output variables. Including such information in the customizable help is strongly discouraged.

Comments or Questions?

[This page was last modified 06Jul12, 3:14 pm.]

Model development and archiving support at provided by the following grants: NIH/NIBIB BE08407 Software Integration, JSim and SBW 6/1/09-5/31/13; NIH/NHLBI T15 HL88516-01 Modeling for Heart, Lung and Blood: From Cell to Organ, 4/1/07-3/31/11; NSF BES-0506477 Adaptive Multi-Scale Model Simulation, 8/15/05-7/31/08; NIH/NHLBI R01 HL073598 Core 3: 3D Imaging and Computer Modeling of the Respiratory Tract, 9/1/04-8/31/09; as well as prior support from NIH/NCRR P41 RR01243 Simulation Resource in Circulatory Mass Transport and Exchange, 12/1/1980-11/30/01 and NIH/NIBIB R01 EB001973 JSim: A Simulation Analysis Platform, 3/1/02-2/28/07.