Logical Operators

Open in Morpheus History

Persistent Identifier

Use this permanent link to cite or share this Morpheus model:


Use logical operators and, or and xor in Condition for ChangeCellType.

Introduction

This example model demonstrates the use of logical operators. Please also see the built-in docu at GUI/Documentation/MathematicalExpressions. Beyond conditions, logical operator anywhere evaluate to 0 or 1, which can be included as numerical terms in any formula. The latter may be useful as a shorter alternative notation of if() statements. This example was motivated by Erwin in the Morpheus user forum.

Description

Derived from the built-in model CellSorting-2D, the added plugin ChangeCellType in ct1 now gradually creates cells of ct2 (shown yellow) from initially 100 cells of ct1. The Condition

(rand_uni(0,1)<p) 
and ((cell.center.x<0.4*size.x) or (cell.center.x>0.6*size.x)) 
and ((time>200) xor (celltype.ct2.size>50))

combines the logical operators and, or and xor to probabilistically (p=0.1% per ct1 cell per MCS, as defined in Global) change cell type after t>200 and only to the left or right and only until 50 yellow cells were created (just to demo the use of xor).

Movie visualising the condition-dependent ChangeCellType after t>200 and only to the left or right and only until 50 yellow cells were created. The left panel shows cell type ct1 (red) and ct2 (yellow), the middle panel for each cell shows the number of neighbors of a different cell type and the right panel for each cell shows the length of contact to all neighbors of a different cell type.

Model

Get this model via:

XML Preview

<MorpheusModel version="4">
    <Description>
        <Title>Example-CellSorting-2D-LogicalOperators</Title>
        <Details>The condition in ChangeCellType in ct1 demonstrates the use of logical operators.

Reference for the cell sorting model: Graner and Glazier, Simulation of biological cell sorting using a two-dimensional extended Potts model, Phys. Rev. Lett. 69, 2013–2016 (1992) </Details> </Description> <Global> <Variable value="0.0" name="Boundary length of CT1 with other cell types" symbol="boundary"/> <Constant value="0.0" symbol="b"/> <Constant value="0.0" symbol="b2"/> <Constant value="0.001" name="0.1% ChangeCellType" symbol="p"/> </Global> <Space> <SpaceSymbol symbol="l"/> <Lattice class="square"> <Size value="200, 200, 0" symbol="size"/> <BoundaryConditions> <Condition type="periodic" boundary="x"/> <Condition type="periodic" boundary="y"/> </BoundaryConditions> <Neighborhood> <Order>2</Order> </Neighborhood> </Lattice> </Space> <Time> <StartTime value="0"/> <StopTime value="5000"/> <RandomSeed value="0"/> <TimeSymbol symbol="time"/> </Time> <CellTypes> <CellType class="biological" name="ct1"> <VolumeConstraint target="200" strength="1"/> <NeighborhoodReporter> <Input scaling="length" value="cell.type == celltype.ct2.id"/> <Output symbol-ref="boundary" mapping="sum"/> </NeighborhoodReporter> <Property value="0" symbol="b"/> <NeighborhoodReporter> <Input scaling="cell" value="cell.type == celltype.ct2.id"/> <Output symbol-ref="b" mapping="sum"/> </NeighborhoodReporter> <NeighborhoodReporter> <Input scaling="length" value="cell.type == celltype.ct2.id"/> <Output symbol-ref="b2" mapping="sum"/> </NeighborhoodReporter> <Property value="0" name="Interface with ct2" symbol="b2"/> <ChangeCellType name="to ct2" newCellType="ct2"> <Condition>(rand_uni(0,1)&lt;p) and ((cell.center.x&lt;0.4size.x) or (cell.center.x>0.6size.x)) and ((time>200) xor (celltype.ct2.size>50))</Condition> </ChangeCellType> </CellType> <CellType class="biological" name="ct2"> <VolumeConstraint target="200" strength="1"/> <Property value="0" symbol="b"/> <NeighborhoodReporter> <Input scaling="cell" value="cell.type == celltype.ct1.id"/> <Output symbol-ref="b" mapping="sum"/> </NeighborhoodReporter> <Property value="0" name="Interface with ct1" symbol="b2"/> <NeighborhoodReporter> <Input scaling="length" value="cell.type == celltype.ct1.id"/> <Output symbol-ref="b2" mapping="sum"/> </NeighborhoodReporter> </CellType> <CellType class="medium" name="medium"/> </CellTypes> <CPM> <Interaction default="0.0"> <Contact value="12" type2="medium" type1="ct1"/> <Contact value="6" type2="medium" type1="ct2"/> <Contact value="6" type2="ct1" type1="ct1"/> <Contact value="6" type2="ct2" type1="ct2"/> <Contact value="16" type2="ct2" type1="ct1"/> </Interaction> <MonteCarloSampler stepper="edgelist"> <MCSDuration value="1"/> <Neighborhood> <Order>2</Order> </Neighborhood> <MetropolisKinetics temperature="2"/> </MonteCarloSampler> <ShapeSurface scaling="norm"> <Neighborhood> <Order>6</Order> </Neighborhood> </ShapeSurface> </CPM> <CellPopulations> <Population type="ct1" size="0"> <InitCircle mode="random" number-of-cells="100"> <Dimensions radius="size.x/3" center="size.x/2, size.y/2, 0"/> </InitCircle> </Population> <!– <Disabled> <Population type="ct2" size="0"> <InitCircle mode="random" number-of-cells="50"> <Dimensions radius="size.x/3" center="size.x/2, size.y/2, 0"/> </InitCircle> </Population> </Disabled> –> </CellPopulations> <Analysis> <Gnuplotter time-step="100" decorate="false"> <Terminal name="png"/> <Plot> <Cells value="cell.type" flooding="true"/> </Plot> <Plot> <Cells value="b" flooding="true"> <ColorMap> <Color value="2" color="red"/> <Color value="1" color="yellow"/> <Color value="0" color="white"/> </ColorMap> </Cells> <CellLabels fontsize="10" value="b" precision="0"/> </Plot> <Plot> <Cells value="b2" per-frame-range="true"> <ColorMap> <Color value="2" color="red"/> <Color value="1" color="yellow"/> <Color value="0" color="white"/> </ColorMap> </Cells> <CellLabels fontsize="10" value="b2" precision="0"/> </Plot> </Gnuplotter> <Logger time-step="10.0"> <Input> <Symbol symbol-ref="boundary"/> <Symbol symbol-ref="b"/> <Symbol symbol-ref="b2"/> </Input> <Output> <TextOutput/> </Output> <Plots> <Plot time-step="500"> <Style style="linespoints"/> <Terminal terminal="png"/> <X-axis> <Symbol symbol-ref="time"/> </X-axis> <Y-axis> <Symbol symbol-ref="boundary"/> </Y-axis> </Plot> </Plots> </Logger> <ModelGraph format="dot" reduced="false" include-tags="#untagged"/> </Analysis> </MorpheusModel>

Model Graph
Model Graph

Downloads

Files associated with this model:

Next