Core Facilities


Physiology and Biophysics AcademicsJingle Bell JogZippity Doo Dah gives to BCHJackson Free Clinic
  • XML Document

    Models typically have one more elements named structure describing model structure, one element named control setting up interactive solution control, and one or more elements named display defining the panels that display the solution.

    The root or document element is named model.

    After some preliminaries, we start the structure element. This element holds child elements named variables, equations and definitions.

    We declare two variables to be used in the calculation of the derivatives and define a parameter that scales contagion.

    <?xml version = '1.0' ?>

    <model>

    <schema> 2005.0 </schema>
    <modeltitle> An Example - Epidemic </modeltitle>

    <structure><name> Model </name>

    <variables>
        <var><name> HtoC </name></var>
        <var><name> CtoR </name></var>
        <parm><name> Contagion </name><val> 0.001 </val></parm>
    </variables>

    Next we define the model's three integrals. This implicitly declares a derivative for each integral. The derivatives are defined later in the definitions element.

    <equations>

    <diffeq>
        <name> H </name>
        <integralname> H </integralname>
        <initialval> 1000.0 </initialval>
        <dervname> dH/dt </dervname>
        <errorlim> 1.0 </errorlim>
    </diffeq>

    <diffeq>
        <name> C </name>
        <integralname> C </integralname>
        <initialval> 5.0 </initialval>
        <dervname> dC/dt </dervname>
        <errorlim> 1.0 </errorlim>
    </diffeq>

    <diffeq>
        <name> C </name>
        <integralname> R </integralname>
        <initialval> 0.0 </initialval>
        <dervname> dR/dt </dervname>
        <errorlim> 1.0 </errorlim>
    </diffeq>

    </equations>

    Next we complete the defintions element by creating a math block to calcuate the derivatives. This completes definitions and structure so these elements are closed.

    <definitions>

    <block><name> CalcDervs </name>

    <def><name> HtoC </name><val> Contagion * H * C </val></def>
    <def><name> CtoR </name><val> 0.1 * C </val></def>

    <def><name> dH/dt </name><val> - HtoC </val></def>
    <def><name> dC/dt </name><val> HtoC - CtoR </val></def>
    <def><name> dR/dt </name><val> CtoR </val></def>

    </block>

    </definitions>
    </structure>

    We next complete a bit of housekeeping by telling DESolver that the math block defined above is to be used to calculate the derivatives.

    <math><dervs> Model.CalcDervs </dervs></math>

    Next we define solution intervals of 10 and 20 days. These intervals will appear in the Go menu, as shown below.

    <control>
    <interactive>

    <gofor>
        <solutionint> 10 </solutionint>
        <displayint> 0.5 </displayint>
        <menuitem> 10 Days </menuitem>
    </gofor>

    <gofor>
        <solutionint> 20 </solutionint>
        <displayint> 0.5 </displayint>
        <menuitem> 20 Days </menuitem>
    </gofor>

    </interactive>
    </control>

    The final step is to define the display element, which has one panel child element. The position of a display object in the panel is defined in terms of rows and columns, from the upper-left corner. We displayed the panel name up in the corner.

    <display>
    <panel>

    <name> An Example - Epidemic </name>

    <at><row> 0.5 </row><col> 1 </col></at>
    <showpanelname/>

    Next we defined a bargraph to dislay the group counts for the healthy (H), contagious (C) and recovered (R) groups.

    <at><row> 2.4 </row><col> 1 </col></at>
    <showbargraph>
        <high> 4.8 </high><wide> 24 </wide><leftmargin> 1 </leftmargin>
        <title> People </title>
        <showinitialvalues/>
        <bar>
            <name> Model.H </name> <label> H </label> <color> BLUE </color>
        </bar>
        <bar>
            <name> Model.C </name> <label> C </label> <color> RED </color>
        </bar>
        <bar>
            <name> Model.R </name> <label> R </label> <color> BLACK </color>
        </bar>
        <scale><min> 0 </min><max> 1000 </max></scale>
    </showbargraph>

    Next on the panel are numerical values for the H, C and R groups.

    <at><row> 8.0 </row><col> 1 </col></at>
    <showvalue>
        <name> Model.H </name> <label> Healthy </label> <format> <integer/> </format>
    </showvalue>

    <at><row> 9.0 </row><col> 1 </col></at>
    <showvalue>
        <name> Model.C </name> <label> Contagious </label> <format> <integer/> </format>
    </showvalue>

    <at><row> 10.0 </row><col> 1 </col></at>
    <showvalue>
        <name> Model.R </name> <label> Recovered </label> <format> <integer/> </format>
    </showvalue>

    Then a slidebar to adjust the contagion parameter.

    <maplist>
        <name> Model.Contagion </name>
        <map><val> 0.0005 </val><img> Low </img></map>
        <map><val> 0.001 </val><img> Normal </img></map>
        <map><val> 0.01 </val><img> High </img></map>
    </maplist>

    <at><row> 11.5 </row><col> 1 </col></at>
    <slidebar>
        <name> Model.Contagion </name><listname> Model.Contagion </listname>
        <label> Contagion </label>
    </slidebar>

    On to the right-hand side of the panel. First we creat a clock to show the value of the independent variable.

    <at><row> 0.5 </row><col> 30 </col></at>
    <showclock>
        <name> System.X </name><timebase> DAY </timebase><showdays/>
    </showclock>

    Then we create a graph to show the changes in the H, C and R groups as a function of time.

    <at><row> 2.0 </row><col> 30 </col></at>
    <showgraph>
        <high> 12 </high><wide> 30 </wide><leftmargin> 5 </leftmargin>
        <xaxis>
            <name> System.X </name> <label> Days </label>
            <scale><min> 0 </min><max> 20 </max></scale>
        </xaxis>
        <yaxis>
        <yvar>
            <name> Model.H </name> <label> H </label> <linecolor> BLUE </linecolor>
        </yvar>
        <yvar>
            <name> Model.C </name> <label> C </label> <linecolor> RED </linecolor>
        </yvar>
        <yvar>
            <name> Model.R </name> <label> R </label> <linecolor> BLACK </linecolor>
        </yvar>
        <scale><min> 0 </min><max> 1000 </max></scale>
        </yaxis>
    </showgraph>

    The last element on the panel is an information button that explains what the H, C and R labels mean.

    <at><row> 14.5 </row><col> 28 </col></at>

    <at><row> 14.5 </row><col> 28 </col></at>
    <infobutton>
        <label> Populations </label>
        <line> H - Healthy </line>
        <line> C - Contagious </line>
        <line> R - Recovered and Immune </line>
    </infobutton>

    This completes the panel, display and model elements so we'll add the close tags for these elements.

    </panel>
    </display>

    </model>

    The XML document is complete.