Electrophysiology Equation Editor Example


  • This example guides the user through the process of using the Electrophysiology Ionic Model Editor to create an ionic model that uses the modified Fitz-Hugh Nagumo equations for excitable media. Once created, the model is used to simulate cardiac action potential propagation in a 2-D mesh.

Start Continuity

Load Problem

Create the Ionic Model

  • Electrophysiology→Edit→Ionic Model…

    • In the Select Model tab, make sure that <<add new model>> is selected.

    • Proceed to the next tab, Edit Properties

      • In the File Name box, type a name for the model, something like EP_my_MFHN. DO NOT NAME IT EP_MFHN, as this file already exists.

      • Enter a short model description if you wish
    • Proceed to the next tab, Edit Equations

      • The equations for the MFHN model are as follows, note that we will only be putting the ODE’s in the equation editor, the PDE is of the general form that is solved by Continuity’s FE routines.

    • To start, we will insert stimulus information that will allow time- and location-dependent stimulus of the tissue
      • To insert an equation, click Insert Variable on the lower left of the form.

      • Change the variable name to stim_end in the Name box and press ENTER (click OK in the dialog box that pops up)

      • Change the button that says Constant to Temporary Variable

      • Click Insert→Template on the upper left menu bar, note that in the equation box the following appears: stim_end = t

      • Copy and paste the following expression into the equation box: stim_end = <stim_start> + <stim_dur>

      • Click Insert Variable again

      • In the Name box, type i_stim and press ENTER

      • In the equation box, replace the existing contents with the following (it might be best to maximize your browser window to see the correct line break formatting):

        • IF(t.GE.<stim_start> .AND. t.LE.stim_end .AND. <stim_dur>.ne.0.d0) THEN
             i_stim = <stim_mag> 


    • In the Variable List, click on V. This variable is predefined automatically to be the the Spatially Coupled Variable, and in this case is analogous to the transmembrane voltage. To match with the literature, we will change the variable name to u:

      • In the Name box, change V to u and press ENTER, click OK if a dialog box pops up.

      • In the Equation box, type in the first ODE shown above, but adding an additional term for the stimulus current as follows: du_dt = c1*u*(u-a)*(1-u)-c2*u*v+i_stim

      • Now we’ll add the second equation. Click on Insert Variable

      • In the Name box, type v

      • Change the box that says Spatially-Coupled Variable to State Variable

      • Go to Insert→Template and click OK if a dialog box pops up

      • In the Equation box, type the second ODE: dv_dt = b*(u-d*v)

    • Now we must add the necessary constants contained in the equations, namely a, b, c1, c2, and d:

    • Click the Insert Variable button.

    • Change the button that says Independent Variable to Constant

    • In the Name box, enter a and press ENTER

    • Select Insert→Template. You will see the entry parameter(a = 0.0) appear in the equation box

    • In the equation box change a=0.0 to a=0.13

    • Type a description in the description box if you wish

    • To add the remaining constants, repeat the above steps starting with clicking on Insert Variable.

    • The order that the variables appear in the list is important. Since u and v depend on all the constants and temporary variables, they should appear after those variables. Select u, and click Shift down to move u to the very bottom. Then do the same with v.

    • Now click the View code tab to see the automatically-generated FORTRAN subroutine containing the model equations.

    • Click on the Compile tab

      • Click the Save file button to save your work up to this point

      • In the drop-down menu to the right of the Compile button, change the server to be-5511-2.ucsd.edu (webservice)

      • Click on the Compile button. Compiling will take about 35 seconds to complete

    • Click on the Set Initial Values tab. In this tab, we’ll set up the initial values for the state variables.

      • In the Variable List click on u

      • Find the button next to For default values use and change it from Value to Field 5

      • In the Variable List click on v

      • Change the number in the box next to the button that says Value from 1 to 0.0

    • Now proceed to the Set parameters tab. Notice that the parameters tab contains six values. The first three are automatically generated and represent the diffusion coefficients for the problem, one for each of the fiber coordinate directions. The other three were automatically generated from the equations we entered – anything in the equations tab contained in angle brackets (<stim_start> for example) is generated in this list as a parameter automatically.

      • For each of the diffusion coefficients, change their default value to field 1

      • Click on stim_start in the list of parameters. This specifies the time in ms of the start of the stimulus current. Change its value to be 1.0

      • Click on stim_dur in the list of parameters. This specifies the duration of the stimulus in ms. Change its value to be 3.0

      • Click on stim_mag in the list of parameters. This specifies the magnitude of the stimulus current. In this case, we want the stimulus to be non-zero for certain nodes, and zero everywhere else. We have already defined a field in the nodes form containing this spatially-varying property. This is contained in field 4, so change the button next to For default values use to be field 4

    • At this point, the model is completely defined, but must be saved before submitting.
      • Return to the Compile tab, and click the Save file button

    • Finally, go to the last tab, Submit and click the Submit button to close the form.

Send and calculate mesh

Solve for action potential propagation

  • Electriophysiology→Calculate→Constraints…
    • Click OK

  • At this point you should save the file for future modifications
  • Electriophysiology→Solve→Initialize…
  • Electriophysiology→Solve→Integration…

    • Verify that Start Time is 0.0

    • Set Duration to 50

    • Set Step Size to 0.1

    • Go to the Solutions tab

      • For Display solution every, choose 10 steps

    • Click OK and wait for the solver to complete its job (observe progress in the Python shell)

Rendering and output

  • Electriophysiology→Render→Solution…

    • Change the Min Value to 0.0 and Max Value to 1.0

    • Click OK

    • Wait for the rendering to complete all frames before proceeding (observe status in Python shell)
  • When the 50 animation frames have been computed, you should see an animation in Continuity of the action propagation.