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 Function Generators in JSim

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

Function generators allow JSim models to be driven by test signals or experimental reference data.

Prerequisites:

Contents:

Adding a Function Generator to a model

Here is a simple example of a JSim model to which we will add a Function Generator:


(Java plugin required)

First select the model tab. The main "Run Time" page will appear which shows all input and output variables. The variable Cin is eligible for function generator assignment, as denoted by the icon to the right of the assigment field. Click on this icon. A dialog will open allowing you create a function generator and assign it to Cin. Modify the default name (fgen_1) if you desire, then press OK. The new function generator page will appear. Modify parameters of the function as you desire. Clicking on the "Function" control, whose default value is "Pulse1", will show a complete list of available functions. Functions and parameters are described in the remainder of this document. After you have set the function generator to a desirable wave-shape, return to the main run-time page by using the "Pages" menu, or the "Next" button. You will note that Cin assignment box now contains the name of the new function generator. From now on, clicking on the icon next to Cin will take you directly to the associated function generator page.

Completed version: If you follow the above instructions correctly, the result will be similar to the model below:

(Java plugin required)

Function Generator Preview

In the JSim GUI, a preview graph is provided with JSim best guess as to the shape of the curve to be generated at run-time. This allows the user to get quick feedback from changes in parameter settings without having to wait for a full model run. However, the proper domain range is only available to the preview graph if the domain minimum and maximum values are model input variables, that is, they are neither private nor calculated from other variables. If the domain minimum or maximum is not available to the preview graph, the graph makes a arbitrary choice for them, and so the graph may differ in shape from that calculated during a subsequent model run.

Advanced Usage

Function are described with reference to the time domain, but they can be used for any independent variable domain (length, voltage, etc.) Example:

Each function generator can also generate a train of the same function--i.e.,the function can be repeated after some specified interval as many times as necessary.

You may create any number of function generators in a model. If you have more than one when you click on the function generator icon for an unassigned variable, you will be asked if you wish to reuse one of the existing generators, or create a new one.

Input variables may be assigned to any algebraic expression involving function generators, e.g. "fgen_1", "2*(fgen_1-3)", "fgen_1+fgen_2". This allows you to build very complex input functions, should you so desire. You may create additional function generators for this purpose with the "New function generator" item in the "Pages" menu. If there are multiple domains in your model (e.g. time and length), you will need to make sure function generator "Domain" control is set appropriately.

Function generators available under JSim

Pulses and Wave Trains:

A variety of Probability Density Functions (PDFs) are available in the JSim function generator. They can be used to generate a train of such functions. All are unimodal (with the exception of Longtail). The PDF provides the shape of the function which is then scaled to be an appropriate model input.

Pulse 1

This function is a single pulse or a train of pulses.

Parameters:

Pulse 2

This function is a double pulse or mixed pulse train. It is similar to Pulse1 with two sets of parameters, but only one offset parameter.

Parameters:

Pulse 3

This function is a triple pulse or mixed pulse train. It is similar to Pulse2, but has three sets of parameters, but only one offset parameter.

Parameters:

Extended Pulse 3

This function is used to generate up to three different pulses in a set. When the set is repeated, the amplitude of each pulse can be increased or decreased. The amplitudes of the pulses in each set depend on all the parameters.

Parameters:

Ramp

This function is a power function ramp of the form:

Value=offset+amplitude*[(startTime-t)/(tdur)]^exponent

when t is greater than startTime and less than or equal to duration.

Parameters:

Square Wave Train

This function is generates a train of square waves and can be used to generate a single pulse. It's usage overlaps with Pulse1, but has some significant differences as noted below.

Parameters:

Sawtooth Wave Train

This function is generates a train of sawtooths. It's parameters are the same as the Square Wave , where shapeFactor controls the fraction of the period the sawtooth is rising and falling.

Parameters:

Sine Wave Train

This function generates a train of sine waves. It has all but one of the parameters used for the square and sawtooth wave trains (doesn't use ShapeFactor.)

Parameters:

Common Parameters for PDF's

There are several parameters that are used for most of the PDF's. They include area, tMean, rd, skewn, frPeak, and timeToRepeat.

Exponential

This function generates an exponential PDF which abruptly rises from zero to its maximum value, then decays.

Parameters:

Gaussian

This function generates a Gaussian PDF.

Parameters:

LagNormal

This function generates a Lagged Normal PDF. It is similar to a Gaussian , but with positive skewness (skewness of a Gaussian is zero.) See model lndc (lagged normal density curve) model for more information.

Parameters:

Longtail

This function is a combination of one of the several of the other PDFs to which on the down slope side of the PDF is joined either a sum of decaying exponentials or power law functions.

Parameters:

GammaVar

This function generates a gamma variate PDF. It has some similarities to the LagNormal PDF.

Parameters:

Poisson

This function generates a Poisson-like PDF using a scaled Poisson equation in which lambda is allowed to vary continuously and n is fixed. This curve represents the transport of a tracer through n identical well mixed compartments.

Parameters:

Random Walk

This function generates a first traversal of a random walk PDF.

Parameters:

Data Curve

This function is an interpolation of a Data Curve. It is imported as a file using the Project tab, then the Add button, selecting Import data file (.tac +).

Parameters:

Comments or Questions?

[This page was last modified 14Feb17, 3:19 pm.]

Model development and archiving support at physiome.org 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.