<MorpheusModel version="4">
    <Description>
        <Title>Example-ExcitableMedium-3D</Title>
        <Details>Simulates the Barkley model of an excitable medium, see: http://www.scholarpedia.org/article/Barkley_model
Derived from FitzHugh-Nagumo model and Hogdkin-Huxley model.

TIFF images can be viewed with external tools such as Fiji / ImageJ (http://fiji.sc/Fiji) or BioView3D (http://www.dimin.net/software/bioview3d/). The latter also reads the OME header for 3D, 4D and 5D images.
VTK filed can be viewed with external tools such as ParaView  (https://www.paraview.org/).</Details>
    </Description>
    <Global>
        <!--    <Disabled>
        <Field value="if( l.x>=s.x/2-5 and l.x&lt;=s.x/2+5, 1, 0 )" symbol="u">
            <Diffusion rate="0.5"/>
        </Field>
    </Disabled>
-->
        <!--    <Disabled>
        <Field value="if(l.x&lt;=s.x/2 , 1, 0)" symbol="v">
            <Diffusion rate="0.5"/>
        </Field>
    </Disabled>
-->
        <!--    <Disabled>
        <System time-step="0.05" solver="Runge-Kutta [fixed, O(4)]">
            <DiffEqn symbol-ref="u">
                <Expression>(1/e)*u*(1-u)*(u-((v+b)/a))</Expression>
            </DiffEqn>
            <DiffEqn symbol-ref="v">
                <Expression>u-v</Expression>
            </DiffEqn>
            <Constant value="0.02" symbol="e"/>
            <Constant value="0.8" symbol="a"/>
            <Constant value="0.01" symbol="b"/>
        </System>
    </Disabled>
-->
        <Constant value="0.0" symbol="u"/>
        <Constant value="0.0" symbol="v"/>
    </Global>
    <Space>
        <Lattice class="square">
            <Size value="300, 300,  0" symbol="s"/>
            <BoundaryConditions>
                <Condition type="periodic" boundary="-x"/>
                <Condition type="periodic" boundary="x"/>
                <Condition type="periodic" boundary="-y"/>
                <Condition type="periodic" boundary="y"/>
            </BoundaryConditions>
            <NodeLength value="1.0"/>
            <Neighborhood>
                <Order>1</Order>
            </Neighborhood>
        </Lattice>
        <SpaceSymbol name="position in space" symbol="l"/>
    </Space>
    <Time>
        <StartTime value="0"/>
        <StopTime value="100"/>
        <SaveInterval value="0"/>
        <TimeSymbol symbol="time"/>
    </Time>
    <Analysis>
        <!--    <Disabled>
        <Gnuplotter time-step="5">
            <Terminal size="600 600 0" name="png"/>
            <Plot>
                <Field symbol-ref="u"/>
            </Plot>
        </Gnuplotter>
    </Disabled>
-->
        <!--    <Disabled>
        <TiffPlotter OME-header="true" time-step="0.5" format="32bit" timelapse="true" compression="false">
            <Channel symbol-ref="u"/>
            <Channel symbol-ref="v"/>
        </TiffPlotter>
    </Disabled>
-->
        <!--    <Disabled>
        <VtkPlotter time-step="0.5" mode="binary">
            <Channel symbol-ref="u"/>
            <Channel symbol-ref="v"/>
        </VtkPlotter>
    </Disabled>
-->
        <Logger time-step="1">
            <Input>
                <Symbol symbol-ref="u"/>
                <Symbol symbol-ref="v"/>
            </Input>
            <Output>
                <TextOutput/>
            </Output>
        </Logger>
        <Gnuplotter time-step="1.0">
            <Plot>
                <Cells value="u">
                    <ColorMap>
                        <Color value="0" color="white"/>
                        <Color value="0.5" color="yellow"/>
                        <Color value="2" color="red"/>
                    </ColorMap>
                </Cells>
            </Plot>
            <Terminal size="1200,1200,0" name="png"/>
            <Plot>
                <Cells value="v">
                    <ColorMap>
                        <Color value="0" color="white"/>
                        <Color value="0.5" color="yellow"/>
                        <Color value="1" color="red"/>
                    </ColorMap>
                </Cells>
            </Plot>
        </Gnuplotter>
        <ModelGraph reduced="false" format="svg" include-tags="#untagged"/>
    </Analysis>
    <CellTypes>
        <CellType name="cells" class="biological">
            <Property value="if( cell.center.x>=s.x/2-10 and cell.center.x&lt;=s.x/2+10&#xa;and cell.center.y>=s.y/2-10 and cell.center.y&lt;=s.y/2+10, 1, 0 )" symbol="u"/>
            <Property value="if(  cell.center.x>=s.x/2 and cell.center.y>=s.y/2, 1, 0 )&#xa;" symbol="v"/>
            <Property value="0.0" symbol="u_n"/>
            <Property value="0.5" symbol="Du"/>
            <NeighborhoodReporter>
                <Input value="u" scaling="cell"/>
                <Output mapping="average" symbol-ref="u_n"/>
            </NeighborhoodReporter>
            <System time-step="0.05" solver="Runge-Kutta [fixed, O(4)]">
                <DiffEqn symbol-ref="u">
                    <Expression>(1/e)*u*(1-u)*(u-((v+b)/a)) + Du*(0.5*u_n-0.5*u)</Expression>
                </DiffEqn>
                <DiffEqn symbol-ref="v">
                    <Expression>u-v</Expression>
                </DiffEqn>
                <Constant value="0.02" symbol="e"/>
                <Constant value="0.8" symbol="a"/>
                <Constant value="0.01" symbol="b"/>
                <!--    <Disabled>
        <DiffEqn symbol-ref="u">
            <Expression>Du*(0.5*u_n-0.5*u)</Expression>
        </DiffEqn>
    </Disabled>
-->
            </System>
            <VolumeConstraint target="100-80*v" strength="1"/>
            <!--    <Disabled>
        <SurfaceConstraint target="1" strength="1" mode="aspherity"/>
    </Disabled>
-->
        </CellType>
        <CellType name="medium" class="medium"/>
    </CellTypes>
    <CellPopulations>
        <Population type="cells" size="700">
            <InitRectangle number-of-cells="700" mode="regular">
                <Dimensions size="s.x*0.6, s.y*0.6,0" origin="s.x*0.2,s.y*0.2,0"/>
            </InitRectangle>
            <!--    <Disabled>
        <InitVoronoi/>
    </Disabled>
-->
        </Population>
    </CellPopulations>
    <CPM>
        <Interaction>
            <Contact type2="cells" value="10-5*u" type1="cells"/>
            <Contact type2="medium" value="10" type1="cells"/>
        </Interaction>
        <ShapeSurface scaling="norm">
            <Neighborhood>
                <Order>1</Order>
            </Neighborhood>
        </ShapeSurface>
        <MonteCarloSampler stepper="edgelist">
            <MCSDuration value="0.1"/>
            <MetropolisKinetics temperature="5"/>
            <Neighborhood>
                <Order>2</Order>
            </Neighborhood>
        </MonteCarloSampler>
    </CPM>
</MorpheusModel>
