User Tools

Site Tools


examples:miscellaneous

Miscellaneous models

Minimal model

Minimal valid XML model

Introduction

This example does nothing - expect being the minimal valid Morpheus model.

Such a model is generated when choosing File → New.

Model description

The basic model only includes the required nodes MorpheusModel, Description, Space and Time. Their required nodes and attributes are added recursively, such as Lattice class and StopTime value.

Things to try

  • Invalidate this minimal model by editing it (but keeping it well-formed). When opening this model in morpheus-gui, it triggers a warning saying that what went wrong, and how it was solved. Check the Fixboard to see the changes that are made to model.

Model

Minimal.xml

<?xml version='1.0' encoding='UTF-8'?>
<MorpheusModel version="1">
    <Description>
        <Title></Title>
    </Description>
    <Space>
        <Lattice class="linear">
            <Size value="0 0 0"/>
        </Lattice>
    </Space>
    <Time>
        <StartTime value="1.0"/>
        <StopTime value="1.0"/>
    </Time>
</MorpheusModel>

In Morpheus GUI: File → New.


Game of Life: Cellular Automata

Conway's Game of Life

Introduction

This example models probably the best-known classic cellular automaton (CA) model: Conway's Game of Life.

It shows an alternative use of System for synchronous updating of Equations.

Model description

In this model, the lattice is filled with cells of size 1. Each cell counts the number of neighboring cells that are 'alive' and acts accordingly. The rules that make up the Game of Life are implemented in a System of Equations in which all Equations are updated synchronously.

Things to try

  • Change the Neighborhood from a Moore (2nd order) to von Neumann (1st order).

Model

GameOfLife.xml

<MorpheusModel version="3">
    <Description>Conway's Game of Life
---------------------

Classical Cellular Automaton with synchronized updates.


Rules:
- If alive, die when less than 2 live neighbors
- If alive, survive when 2 or 3 live neighbors (no change)
- If alive, die when more than 3 live neighbors
- If dead, become alive when exactly 3 live neighbors

<Title>Example-GameOfLife</Title>
        <Details>Simulates Conway's cellular automata model "Game of Life" by

1. summing the states of neighboring cells with NeighborhoodReporter
2. based on this sum, setting the cell state using a System of (synchronously updated) Rules.</Details>
    </Description>
    <Global>
        <Constant symbol="s" value="0"/>
    </Global>
    <Space>
        <Lattice class="square">
            <Size symbol="size" value="50 50 0"/>
            <BoundaryConditions>
                <Condition boundary="x" type="periodic"/>
                <Condition boundary="y" type="periodic"/>
            </BoundaryConditions>
            <Neighborhood>
                <Order>2</Order>
            </Neighborhood>
        </Lattice>
        <SpaceSymbol symbol="space"/>
    </Space>
    <Time>
        <StartTime value="0"/>
        <StopTime value="500"/>
        <SaveInterval value="0"/>
        <TimeSymbol symbol="time"/>
    </Time>
    <CellTypes>
        <CellType class="biological" name="cell">
            <Property symbol="s" value="0.0" name="State_Living"/>
            <Property symbol="sum" value="0.0" name="Sum_Neighbors"/>
            <System solver="euler" time-step="1.0" name="Rules of life">
                <Rule symbol-ref="s">
                    <Expression>if((s == 1 and sum &lt;  2), 0,
  if((s == 1 and sum >  3), 0,
    if((s == 0 and sum == 3), 1, s)
  )
)
                    </Expression>
                </Rule>
            </System>
            <NeighborhoodReporter>
                <Input scaling="cell" value="s"/>
                <Output symbol-ref="sum" mapping="sum"/>
            </NeighborhoodReporter>
        </CellType>
    </CellTypes>
    <CellPopulations>
        <Population size="0" type="cell">
            <InitProperty symbol-ref="s">
                <Expression>if(rand_uni(0,1) > 0.75, 1, 0)</Expression>
            </InitProperty>
            <InitCellLattice/>
        </Population>
    </CellPopulations>
    <Analysis>
        <Gnuplotter time-step="20" decorate="false">
            <Terminal name="png"/>
            <Plot>
                <Cells value="s">
                    <ColorMap>
                        <Color value="1" color="black"/>
                        <Color value="0.0" color="white"/>
                    </ColorMap>
                </Cells>
            </Plot>
        </Gnuplotter>
    </Analysis>
</MorpheusModel>

In Morpheus GUI: Examples → Miscellaneous → GameOfLife.xml


French Flag: Morphogen gradient

Wolpert's French Flag

Introduction

This example shows Wolpert's classical French Flag model. Depending on the local concentration of a morphogen, cells adopt one of three cell types based on internal thresholds.

Model description

The model sets up a morphogen gradient in the x direction PDE. Note that no diffusion is used, since we use the steady-state solution of diffusion.

The cells in CellType register the (average) local morphogen concentration using PDEReporter. Based on the specified threshold values, they choose an identity I as defined in the Equation.

Note that this model is not time-dependent. Time is therefore set from StartTime 0 to StopTime 0.

Things to try

  • Change the physical length of the domain by editing Space → NodeLength that controls the physical size per lattice site.
  • Change the model such that the morphogen gradient is set up by production and diffusion, using Diffusion and a System with DiffEqn. That is, change the model into a time-dependent model.

Model

FrenchFlag.xml

<MorpheusModel version="3">
    <Description>
        <Title>Example-FrenchFlag</Title>
        <Details>Wolpert L (1969). "Positional information and the spatial pattern of cellular differentiation". J. Theor. Biol. 25 (1): 1–47.</Details>
    </Description>
    <Global>
        <Field symbol="m" value="c_0*exp(-k/D*(l.x/size.x))" name="morphogen gradient">
            <Diffusion rate="0.0"/>
        </Field>
        <Constant symbol="c_0" value="1.0"/>
        <Constant symbol="D" value="0.75"/>
        <Constant symbol="k" value="1"/>
        <Constant symbol="celltype" value="0.0"/>
    </Global>
    <Space>
        <Lattice class="square">
            <Size symbol="size" value="20 20 0"/>
            <NodeLength value="1"/>
            <BoundaryConditions>
                <Condition boundary="x" type="constant"/>
                <Condition boundary="y" type="constant"/>
            </BoundaryConditions>
            <Neighborhood>
                <Order>1</Order>
            </Neighborhood>
        </Lattice>
        <SpaceSymbol symbol="l" name="location"/>
    </Space>
    <Time>
        <StartTime value="0"/>
        <StopTime value="0"/>
        <TimeSymbol symbol="time"/>
    </Time>
    <CellTypes>
        <CellType class="biological" name="cells">
            <Property symbol="p" value="0.0" name="p"/>
            <Property symbol="celltype" value="0.0" name="cell type"/>
            <Constant symbol="t1" value="0.7"/>
            <Constant symbol="t2" value="0.4"/>
            <Equation symbol-ref="celltype">
                <Expression>if(p>t1,3, if(p>t2, 2, 1))</Expression>
            </Equation>
            <Mapper name="report morphogen concentration">
                <Input value="m"/>
                <Output symbol-ref="p" mapping="average"/>
            </Mapper>
        </CellType>
    </CellTypes>
    <CellPopulations>
        <Population size="0" type="cells">
            <InitCellLattice/>
        </Population>
    </CellPopulations>
    <Analysis>
        <Gnuplotter time-step="0">
            <Terminal opacity="0.5" persist="true" name="png"/>
            <Plot>
                <Cells value="celltype">
                    <ColorMap>
                        <Color value="3" color="blue"/>
                        <Color value="2" color="white"/>
                        <Color value="1" color="red"/>
                    </ColorMap>
                </Cells>
                <Field symbol-ref="m"/>
            </Plot>
        </Gnuplotter>
        <Logger time-step="0.0">
            <Input>
                <Symbol symbol-ref="m"/>
                <Symbol symbol-ref="celltype"/>
            </Input>
            <Output>
                <TextOutput/>
            </Output>
            <Restriction>
                <Slice value="size.y/2" axis="y"/>
            </Restriction>
            <Plots>
                <Plot>
                    <Style style="linespoints"/>
                    <Terminal terminal="png"/>
                    <X-axis>
                        <Symbol symbol-ref="l.x"/>
                    </X-axis>
                    <Y-axis>
                        <Symbol symbol-ref="m"/>
                        <Symbol symbol-ref="celltype"/>
                    </Y-axis>
                </Plot>
            </Plots>
        </Logger>
    </Analysis>
</MorpheusModel>

In Morpheus GUI: Examples → Miscellaneous → FrenchFlag.xml.


Particle Aggregation: FlipCells

Aggregation of moving particles

Introduction

This models approximates an interacting particle system (IPS) model of particle aggregation. Each black dot represents a particle that moved due to spin flips with random neighbors. The particles perform random walks in which the probability of moving depends on the number of neighboring cells.

Model description

Each lattice site (white or black) counts the number of particles (black neighboring sites) using a NeighborsReporter.

The probability of movement of each particle is made dependent on its number of neighbors by using it in the Condition of FlipCells. When this condition is satisfied, the particle changes positions with a random neighboring lattice site.

A PopulationReporter is used to return the fraction of isolated black particles. This number is logged and plotted using the Logger.

Things to try

  • Change the parameter p.

Model

ParticleAggregation.xml

<?xml version='1.0' encoding='UTF-8'?>
<MorpheusModel version="3">
    <Description>
        <Title>Example-ParticleAggregation</Title>
        <Details>Shows new FlipCells plugin
</Details>
    </Description>
    <Global>
        <Variable symbol="sn" value="0" name="Sum of non-isolated cells"/>
        <Constant symbol="s" value="0"/>
    </Global>
    <Space>
        <Lattice class="hexagonal">
            <Size symbol="size" value="40, 40, 0"/>
            <Neighborhood>
                <Order>2</Order>
            </Neighborhood>
            <BoundaryConditions>
                <Condition boundary="x" type="periodic"/>
                <Condition boundary="y" type="periodic"/>
            </BoundaryConditions>
        </Lattice>
        <SpaceSymbol symbol="l"/>
    </Space>
    <Time>
        <StartTime value="0"/>
        <StopTime value="5000"/>
        <!--    <Disabled>
        <RandomSeed value="1415712648"/>
    </Disabled>
-->
        <TimeSymbol symbol="time"/>
    </Time>
    <CellTypes>
        <CellType class="biological" name="spins">
            <Property symbol="s" value="0.0" name="state"/>
            <DelayProperty symbol="s_n" value="0.0" delay="1" name="state_neighbors"/>
            <Property symbol="p" value="2.25" name="probability"/>
            <Function symbol="ni" name="non-isolated">
                <Expression>if(s==1 and s_n > 1, 1, 0)</Expression>
            </Function>
            <NeighborhoodReporter>
                <Input scaling="cell" value="s"/>
                <Output symbol-ref="s_n" mapping="sum"/>
            </NeighborhoodReporter>
            <FlipCellMotion neighborhood="2" time-step="1">
                <Condition>s > 0 and rand_uni(0,1) &lt; (1-(s_n/12)*p)</Condition>
            </FlipCellMotion>
            <Mapper>
                <Input value="ni"/>
                <Output symbol-ref="sn" mapping="sum"/>
            </Mapper>
        </CellType>
    </CellTypes>
    <CellPopulations>
        <Population size="0" type="spins">
            <InitProperty symbol-ref="s">
                <Expression>if(rand_uni(0,1) &lt; 0.10, 1, 0)</Expression>
            </InitProperty>
            <InitCellLattice/>
        </Population>
    </CellPopulations>
    <Analysis>
        <Gnuplotter time-step="100" decorate="false">
            <Terminal name="png"/>
            <Plot>
                <Cells value="s">
                    <ColorMap>
                        <Color value="1" color="black"/>
                        <Color value="0.0" color="white"/>
                    </ColorMap>
                </Cells>
            </Plot>
        </Gnuplotter>
        <Logger time-step="25">
            <Input>
                <Symbol symbol-ref="sn"/>
            </Input>
            <Output>
                <TextOutput/>
            </Output>
            <Plots>
                <Plot time-step="250">
                    <Style style="lines" line-width="3.0"/>
                    <Terminal terminal="png"/>
                    <X-axis>
                        <Symbol symbol-ref="time"/>
                    </X-axis>
                    <Y-axis>
                        <Symbol symbol-ref="sn"/>
                    </Y-axis>
                </Plot>
            </Plots>
        </Logger>
    </Analysis>
</MorpheusModel>

In Morpheus GUI: Examples → Miscellaneous → ParticleAggregation.xml


examples/miscellaneous.txt · Last modified: 16:53 11.11.2014 by Walter