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

Using Delay Lines in MML

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


This document describes construction of delay lines in JSim MML. A delay line is a mechanism for delaying the delivery of a signal. Mathematically, this may be thought of as querying the value of a variable v(t) at an earlier time v(t-delay). While MML does not have an explicit "delay()" function currently (one is being planned), delay lines may be created in MML using several alternative methods which are described below.



Variable Function (VF) Delay Lines

This form of delay line uses MML VF syntax, which treats a dynamic variable v as a function v(expression). For a simple delay line, the appropriate VF call is v(t-delay) which is described below (those interested if the full generality of VFs, should see Using Variable Functions in MML). Consider the following example:

Note that the definition of udelayed uses an "if" clause to prevent u() queries for t less than 0. Such queries would cause a out-of-range error when the model is run.

While the above delay implementation is adequate in most circumstances, there are some subtleties that can sometimes cause problems:

  1. JSim calculates u(t-delay) by linearly interpolating u(t) values calculated from previous time points, that is, u's values on the defined time grid. This means the accuraccy of u(t-delay) depends upon the pseudo-linear behaviour of u. Normally, specifying an appropriately small time step ( will address this problem.
  2. The above interpolation behaviour means that if delay is less than, then u(t-delay) will return a NaN because the interpolated values will include u values not yet calculated. This means you must specify a delay value greater that to get acceptable results. In any case, delay must normally be large compared to in order to achieve acceptable interpolation accuraccy.
  3. Third, the "if" clause above is, strictly speaking, correct only for t.min=0. If t.min is not necessarily zero in your model, the correct "if" clause should be "if (t-t.min < delay) ..."

The following model incorporates two refinements of the previous one's "if" clause. First, udelayed is set equal to u if the delay is too small, allowing the case of the delay=0 to be handled correctly. Second, the case of non-zero t.min is handled correctly.

(Java plugin required)

PDE Delay Lines

To understand this section, you should first read Using PDEs in MML.

This section is currently under development.

ODE Series Delay Lines

To understand this section, you should first read Using ODEs in MML.

This section is currently under development.

06Jul12, 3:11 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.