<?xml version='1.0' encoding='UTF-8'?>
<model name="periodic_electrical_stim" xmlns="http://www.cellml.org/cellml/1.1#" xmlns:cellml="http://www.cellml.org/cellml/1.1#" xmlns:xlink="http://www.w3.org/1999/xlink">
    <import xlink:href="../../units.cellml">
        <units name="ms" units_ref="ms"/>
        <units name="nA_per_nF" units_ref="nA_per_nF"/>
    </import>
    <component name="stimulus_protocol">
        <variable name="time" public_interface="in" units="ms"/>
        <variable name="current" public_interface="out" units="nA_per_nF"/>
        <variable initial_value="0" name="stim_offset" public_interface="in" units="ms"/>
        <variable initial_value="9999999999" name="stim_t_end" public_interface="in" units="ms"/>
        <variable initial_value="400" name="stim_period" public_interface="in" units="ms"/>
        <variable initial_value="3" name="stim_duration" public_interface="in" units="ms"/>
        <variable initial_value="-15" name="stim_amplitude" public_interface="in" units="nA_per_nF"/>
        <variable initial_value="1" name="N_period_total" public_interface="in" units="dimensionless"/>
        <variable initial_value="1" name="N_period_applied" public_interface="in" units="dimensionless"/>
        <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
                <eq/>
                <ci>current</ci>
                <piecewise>
                    <piece>
                        <ci>stim_amplitude</ci>
                        <apply>
                            <and/>
                            <apply>
                                <geq/>
                                <ci>time</ci>
                                <ci>stim_offset</ci>
                            </apply>
                            <apply>
                                <lt/>
                                <ci>time</ci>
                                <ci>stim_t_end</ci>
                            </apply>
                            <apply>
                                <leq/>
                                <apply>
                                    <rem/>
                                    <apply>
                                        <minus/>
                                        <ci>time</ci>
                                        <ci>stim_offset</ci>
                                    </apply>
                                    <ci>stim_period</ci>
                                </apply>
                                <ci>stim_duration</ci>
                            </apply>
                            <apply>
                                <lt/>
                                <apply>
                                    <rem/>
                                    <apply>
                                        <minus/>
                                        <ci>time</ci>
                                        <ci>stim_offset</ci>
                                    </apply>
                                    <apply>
                                        <times/>
                                        <ci>N_period_total</ci>
                                        <ci>stim_period</ci>
                                    </apply>
                                </apply>
                                <apply>
                                    <times/>
                                    <ci>N_period_applied</ci>
                                    <ci>stim_period</ci>
                                </apply>
                            </apply>
                        </apply>
                    </piece>
                    <otherwise>
                        <cn cellml:units="nA_per_nF">0</cn>
                    </otherwise>
                </piecewise>
            </apply>
        </math>
        <!-- Check that 1. a certain amount of time (stim_offset) has passed before applying the first stim, 2. We are within a stimulation window and 3. We do not have to skip the stimulus.-->
    </component>
    <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
        <rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="">
            <dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/" rdf:parseType="Resource" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
                <vCard:N xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#" rdf:parseType="Resource" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
                    <vCard:Family xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#">Nickerson</vCard:Family>
                    <vCard:Given xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#">David</vCard:Given>
                </vCard:N>
                <vCard:EMAIL xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#" rdf:parseType="Resource" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
                    <rdf:value xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">david.nickerson@nus.edu.sg</rdf:value>
                    <rdf:type xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:resource="http://imc.org/vCard/3.0#internet"/>
                </vCard:EMAIL>
                <vCard:ORG xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#" rdf:parseType="Resource" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
                    <vCard:Orgname xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#">National University of Singapore</vCard:Orgname>
                    <vCard:Orgunit xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#">Division of Bioengineering</vCard:Orgunit>
                </vCard:ORG>
            </dc:creator>
            <dcterms:created xmlns:dcterms="http://purl.org/dc/terms/" rdf:parseType="Resource" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
                <dcterms:W3CDTF xmlns:dcterms="http://purl.org/dc/terms/">2008-03-12</dcterms:W3CDTF>
            </dcterms:created>
        </rdf:Description>
        <rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="#periodic_IStim">
            <dc:title xmlns:dc="http://purl.org/dc/elements/1.1/">
        Protocol defining a periodic stimulus current.
      </dc:title>
            <cmeta:comment xmlns:cmeta="http://www.cellml.org/metadata/1.0#" rdf:parseType="Resource" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
                <rdf:value xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
          This CellML file describes the protocol for the application of
          a periodic stimulus current.
        </rdf:value>
                <dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/" rdf:parseType="Resource" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
                    <vCard:FN xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#">David Nickerson</vCard:FN>
                </dc:creator>
                <dc:publisher xmlns:dc="http://purl.org/dc/elements/1.1/">
          Division of Bioengineering, National University of Singapore
      </dc:publisher>
            </cmeta:comment>
        </rdf:Description>
    </rdf:RDF>
    <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
        <rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="#stimulus_protocol">
            <cmeta:comment xmlns:cmeta="http://www.cellml.org/metadata/1.0#" rdf:parseType="Resource" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
                <rdf:value xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
            Here we define the periodic stimulus protocol.
          </rdf:value>
            </cmeta:comment>
        </rdf:Description>
    </rdf:RDF>
</model>
