(* Content-type: application/vnd.wolfram.cdf.text *) (*** Wolfram CDF File ***) (* http://www.wolfram.com/cdf *) (* CreatedBy='Mathematica 8.0' *) (*************************************************************************) (* *) (* The Mathematica License under which this file was created prohibits *) (* restricting third parties in receipt of this file from republishing *) (* or redistributing it by any means, including but not limited to *) (* rights management or terms of use, without the express consent of *) (* Wolfram Research, Inc. *) (* *) (*************************************************************************) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 835, 17] NotebookDataLength[ 63053, 1486] NotebookOptionsPosition[ 63298, 1475] NotebookOutlinePosition[ 63661, 1491] CellTagsIndexPosition[ 63618, 1488] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell[TextData[{ StyleBox["Simulating contact inhibition and pattern formation in the early ", FontFamily->"Comic Sans MS", FontSize->24], StyleBox["Drosophila", FontFamily->"Comic Sans MS", FontSize->24, FontSlant->"Italic"], StyleBox[" embryo", FontFamily->"Comic Sans MS", FontSize->24] }], "Title", CellChangeTimes->{{3.4728297011966*^9, 3.4728297048314*^9}, { 3.4737712533095837`*^9, 3.4737712630595837`*^9}, {3.4738697659693923`*^9, 3.473869771413792*^9}, {3.474037338014572*^9, 3.474037340869372*^9}, { 3.474721411325*^9, 3.4747214226818*^9}, {3.4750180295754952`*^9, 3.475018049573495*^9}, {3.477315425828125*^9, 3.477315436671875*^9}, { 3.5275888809133997`*^9, 3.5275889132098*^9}, {3.5276010751122*^9, 3.5276010825182*^9}, 3.528210314895305*^9}], Cell[CellGroupData[{ Cell[BoxData[{ StyleBox[ RowBox[{ RowBox[{ RowBox[{ RowBox[{"embryo", "[", RowBox[{"wid_", ",", "len_", ",", "elon_"}], "]"}], ":=", RowBox[{"Flatten", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"wid", "/", "2"}], "*", RowBox[{"Cos", "[", "ang", "]"}]}], ",", RowBox[{ RowBox[{"len", "/", "2"}], "*", RowBox[{"Sin", "[", "ang", "]"}]}]}], "}"}], ",", RowBox[{"{", RowBox[{"ang", ",", "0.", ",", "Pi", ",", RowBox[{"Pi", "/", "20."}]}], "}"}]}], "]"}], "/.", RowBox[{ RowBox[{"{", RowBox[{"x_Real", ",", "y_"}], "}"}], "->", RowBox[{"{", RowBox[{"x", ",", RowBox[{"y", "+", "elon"}]}], "}"}]}]}], ",", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"-", "wid"}], "/", "2"}], ",", "y"}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", RowBox[{"elon", "-", "10"}], ",", RowBox[{ RowBox[{"-", "elon"}], "+", "10"}], ",", RowBox[{"-", "10"}]}], "}"}]}], "]"}], ",", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"wid", "/", "2"}], "*", RowBox[{"Cos", "[", "ang", "]"}]}], ",", RowBox[{ RowBox[{"len", "/", "2"}], "*", RowBox[{"Sin", "[", "ang", "]"}]}]}], "}"}], ",", RowBox[{"{", RowBox[{"ang", ",", "Pi", ",", RowBox[{"2", "*", "Pi"}], ",", RowBox[{"Pi", "/", "20."}]}], "}"}]}], "]"}], "/.", RowBox[{ RowBox[{"{", RowBox[{"x_Real", ",", "y_"}], "}"}], "->", RowBox[{"{", RowBox[{"x", ",", RowBox[{"y", "-", "elon"}]}], "}"}]}]}], ",", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"wid", "/", "2"}], ",", "y"}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", RowBox[{ RowBox[{"-", "elon"}], "+", "10"}], ",", RowBox[{"elon", "-", "10"}], ",", "10"}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"{", RowBox[{ RowBox[{"wid", "/", "2"}], ",", "elon"}], "}"}], "}"}]}], "}"}], ",", "1"}], "]"}]}], ";"}], "\[IndentingNewLine]"}], FontColor->RGBColor[0, 0, 1]], "\[IndentingNewLine]", StyleBox[ RowBox[{ RowBox[{ RowBox[{ RowBox[{"noise2D", "[", "sd_", "]"}], ":=", RowBox[{"{", RowBox[{ RowBox[{"RandomReal", "[", RowBox[{"NormalDistribution", "[", RowBox[{"0", ",", "sd"}], "]"}], "]"}], ",", RowBox[{"RandomReal", "[", RowBox[{"NormalDistribution", "[", RowBox[{"0", ",", "sd"}], "]"}], "]"}]}], "}"}]}], ";"}], "\[IndentingNewLine]"}], FontColor->RGBColor[0, 0, 1]], "\[IndentingNewLine]", StyleBox[ RowBox[{ RowBox[{ RowBox[{ RowBox[{"nearestNPos", "[", "pos_", "]"}], ":=", RowBox[{ RowBox[{"Nearest", "[", RowBox[{ RowBox[{"Join", "[", RowBox[{"embo", ",", RowBox[{ RowBox[{"Transpose", "[", "posvel", "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], "]"}], ",", "pos", ",", "2"}], "]"}], "[", RowBox[{"[", "2", "]"}], "]"}]}], ";"}], "\[IndentingNewLine]"}], FontColor->RGBColor[0, 0, 1]], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ StyleBox[ RowBox[{"ranCollStep", "[", RowBox[{ RowBox[{"{", RowBox[{"pos_", ",", "vel_"}], "}"}], ",", "phi_", ",", "sdn_", ",", "collisionDistance_", ",", "nnPos_", ",", "phi2_", ",", "sdn2_", ",", "psi_", ",", RowBox[{"{", RowBox[{"lowX_", ",", "highX_"}], "}"}]}], "]"}], FontColor->RGBColor[0, 0, 1]], StyleBox[":=", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox["\[IndentingNewLine]", FontColor->RGBColor[0, 0, 1]], RowBox[{ StyleBox["Module", FontColor->RGBColor[0, 0, 1]], StyleBox["[", FontColor->RGBColor[0, 0, 1]], RowBox[{ StyleBox[ RowBox[{"{", RowBox[{"vt", ",", RowBox[{"nnVec", "=", RowBox[{"pos", "-", "nnPos"}]}]}], "}"}], FontColor->RGBColor[0, 0, 1]], StyleBox[",", FontColor->RGBColor[0, 0, 1]], StyleBox["\[IndentingNewLine]", FontColor->RGBColor[0, 0, 1]], RowBox[{ RowBox[{ StyleBox["If", FontColor->RGBColor[0, 0, 1]], StyleBox["[", FontColor->RGBColor[0, 0, 1]], RowBox[{ StyleBox[ RowBox[{ RowBox[{"Norm", "[", "nnVec", "]"}], ">", "collisionDistance"}], FontColor->RGBColor[0, 0, 1]], StyleBox[",", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{ StyleBox[ " \ ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->GrayLevel[0]]}]], StyleBox[ RowBox[{"(*", RowBox[{ RowBox[{ "If", " ", "the", " ", "nearest", " ", "neighbour", " ", "is", " ", "further", " ", "than", " ", "the", " ", "collison", " ", "distance"}], " ", " ", "..."}], " ", "*)"}], FontColor->GrayLevel[0]], StyleBox["\[IndentingNewLine]", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"vt", "=", RowBox[{ RowBox[{"phi", "*", "vel"}], "+", RowBox[{"noise2D", "[", "sdn", "]"}]}]}], FontColor->RGBColor[0, 0, 1]], StyleBox[",", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"(*", " ", RowBox[{ RowBox[{"...", " ", "use", " ", "the", " ", "free"}], "-", RowBox[{"moving", " ", "model"}]}], " ", "*)"}], FontColor->GrayLevel[0]], StyleBox["\[IndentingNewLine]", FontColor->RGBColor[0, 0, 1]], RowBox[{ StyleBox["vt", FontColor->RGBColor[0, 0, 1]], StyleBox["=", FontColor->RGBColor[0, 0, 1]], RowBox[{"nnVec", StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox["/", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"Norm", "[", "nnVec", "]"}], FontColor->RGBColor[0, 0, 1]]}]}]}], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"(*", " ", RowBox[{"otherwise", " ", "use", " ", "the", " ", "contact", " ", RowBox[{"model", "."}]}], " ", "*)"}], FontColor->GrayLevel[0]], StyleBox["\[IndentingNewLine]", FontColor->RGBColor[0, 0, 1]], StyleBox["]", FontColor->RGBColor[0, 0, 1]]}], StyleBox[";", FontColor->RGBColor[0, 0, 1]], StyleBox["\[IndentingNewLine]", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"pt", "=", RowBox[{"pos", "+", "vt"}]}], FontColor->RGBColor[0, 0, 1]], StyleBox[";", FontColor->RGBColor[0, 0, 1]], StyleBox[ " \ ", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"(*", RowBox[{"Update", " ", "the", " ", "cell", " ", "position"}], "*)"}], FontColor->GrayLevel[0]], StyleBox["\[IndentingNewLine]", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"pt", "[", RowBox[{"[", "1", "]"}], "]"}], "<", "lowX"}], ",", RowBox[{ RowBox[{ RowBox[{"pt", "[", RowBox[{"[", "1", "]"}], "]"}], "=", RowBox[{ RowBox[{"2", "*", "lowX"}], "-", RowBox[{"pt", "[", RowBox[{"[", "1", "]"}], "]"}]}]}], ";", RowBox[{"vt", "=", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", "1"}], "}"}], "*", "vt"}]}]}]}], "]"}], FontColor->RGBColor[0, 0, 1]], StyleBox[";", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->GrayLevel[0]], StyleBox[ RowBox[{"(*", RowBox[{ RowBox[{ "If", " ", "the", " ", "cell", " ", "lies", " ", "outside", " ", "the", " ", "low", " ", "X", " ", "and", " ", "highX", " ", "limits"}], " ", "..."}], "*)"}], FontColor->GrayLevel[0]], StyleBox["\[IndentingNewLine]", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"pt", "[", RowBox[{"[", "1", "]"}], "]"}], ">", "highX"}], ",", RowBox[{ RowBox[{ RowBox[{"pt", "[", RowBox[{"[", "1", "]"}], "]"}], "=", RowBox[{ RowBox[{"2", "*", "highX"}], "-", RowBox[{"pt", "[", RowBox[{"[", "1", "]"}], "]"}]}]}], ";", RowBox[{"vt", "=", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", "1"}], "}"}], "*", "vt"}]}]}]}], "]"}], FontColor->RGBColor[0, 0, 1]], StyleBox[";", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"(*", " ", RowBox[{ "...", " ", "then", " ", "reflect", " ", "its", " ", "displacement", " ", "from", " ", "the", " ", "appropriate", " ", RowBox[{"limit", "."}]}], "*)"}], FontColor->GrayLevel[0]], StyleBox["\[IndentingNewLine]", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"{", RowBox[{"pt", ",", "vt"}], "}"}], FontColor->RGBColor[0, 0, 1]]}]}], StyleBox["\[IndentingNewLine]", FontColor->RGBColor[0, 0, 1]], StyleBox["]", FontColor->RGBColor[0, 0, 1]]}]}], StyleBox[";", FontColor->RGBColor[0, 0, 1]]}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"embwid", "=", StyleBox["110", FontColor->RGBColor[0, 1, 0]]}], ";", RowBox[{"embht", "=", StyleBox["160", FontColor->RGBColor[0, 1, 0]]}], ";", RowBox[{"elon", "=", StyleBox["160", FontColor->RGBColor[0, 1, 0]]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"x", "=", StyleBox["65", FontColor->RGBColor[0, 1, 0]]}], ";", RowBox[{"y", "=", StyleBox["170", FontColor->RGBColor[0, 1, 0]]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"embo", "=", RowBox[{"embryo", "[", RowBox[{"embwid", ",", "embht", ",", RowBox[{"elon", "/", "2"}]}], "]"}]}], ";", RowBox[{"cellNumber", "=", StyleBox["1", FontColor->GrayLevel[0]]}], StyleBox[";", FontColor->GrayLevel[0]]}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"posvel", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0.", ",", "0."}], "}"}]}], "}"}], ",", RowBox[{"{", "cellNumber", "}"}]}], "]"}]}], ";", RowBox[{"walks", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{"posvel", "[", RowBox[{"[", RowBox[{"i", ",", "1"}], "]"}], "]"}], "}"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"Length", "[", "posvel", "]"}]}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"(*", "free", "*)"}], " ", RowBox[{ RowBox[{"phi", " ", "=", " ", StyleBox["0.73", FontColor->RGBColor[0, 1, 0]]}], ";", RowBox[{"sd", "=", StyleBox["1.25", FontColor->RGBColor[0, 1, 0]]}], ";"}], " "}], "\[IndentingNewLine]", RowBox[{ RowBox[{"(*", RowBox[{"collision", ":"}], "*)"}], " ", RowBox[{ RowBox[{"collisionDistance", "=", StyleBox[ StyleBox[ RowBox[{"3", "0."}]], FontColor->RGBColor[0, 1, 0]]}], ";", " ", RowBox[{"psi", "=", StyleBox["1.25", FontColor->RGBColor[0, 1, 0]]}], ";", RowBox[{"phi2", "=", StyleBox["0.51", FontColor->RGBColor[0, 1, 0]]}], ";", RowBox[{"sd2", "=", StyleBox[".7", FontColor->RGBColor[0, 1, 0]]}], ";"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"(*", " ", RowBox[{"simulation", " ", "parameters"}], " ", "*)"}], " ", RowBox[{ RowBox[{"cellNumber", "=", StyleBox["30", FontColor->RGBColor[0, 1, 0]]}], ";", RowBox[{"totalSimulationTime", "=", StyleBox["180", FontColor->RGBColor[0, 1, 0]]}], ";", RowBox[{"midlineHalfWidth", "=", StyleBox["4", FontColor->RGBColor[0, 1, 0]]}], ";", RowBox[{"midlineDelay", "=", StyleBox["40", FontColor->RGBColor[0, 1, 0]]}], ";", " ", RowBox[{"trackplotDelay", "=", StyleBox["30", FontColor->RGBColor[0, 1, 0]]}], StyleBox[";", FontColor->RGBColor[0, 1, 0]]}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"showP", "=", "True"}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{"Manipulate", "[", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"If", "[", RowBox[{"restore", ",", " ", RowBox[{ RowBox[{"phi", " ", "=", " ", StyleBox["0.73", FontColor->RGBColor[0, 1, 0]]}], ";", RowBox[{"sd", "=", StyleBox["1.25", FontColor->RGBColor[0, 1, 0]]}], ";", " ", RowBox[{"(*", RowBox[{"collision", ":"}], "*)"}], " ", RowBox[{"collisionDistance", "=", StyleBox["20.", FontColor->RGBColor[0, 1, 0]]}], ";", " ", RowBox[{"psi", "=", StyleBox["1.25", FontColor->RGBColor[0, 1, 0]]}], ";", RowBox[{"phi2", "=", StyleBox["0.51", FontColor->RGBColor[0, 1, 0]]}], ";", RowBox[{"sd2", "=", StyleBox[".7", FontColor->RGBColor[0, 1, 0]]}], ";", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"simulation", " ", "parameters"}], " ", "*)"}], " ", RowBox[{"cellNumber", "=", StyleBox["30", FontColor->RGBColor[0, 1, 0]]}], ";", RowBox[{"totalSimulationTime", "=", StyleBox["300", FontColor->RGBColor[0, 1, 0]]}], ";", RowBox[{"midlineHalfWidth", "=", StyleBox["4", FontColor->RGBColor[0, 1, 0]]}], ";", RowBox[{"midlineDelay", "=", StyleBox["40", FontColor->RGBColor[0, 1, 0]]}], ";", " ", RowBox[{"trackplotDelay", "=", StyleBox["30", FontColor->RGBColor[0, 1, 0]]}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"restore", "=", "False"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{"startsim", ",", RowBox[{ RowBox[{"posvel", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"RandomReal", "[", RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", "1"}], "}"}], "]"}], ",", RowBox[{"RandomReal", "[", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"-", RowBox[{"(", RowBox[{"embht", "+", "elon", "-", RowBox[{"2", "*", "collisionDistance"}]}], ")"}]}], "/", "2"}], ",", RowBox[{ RowBox[{"(", RowBox[{"embht", "+", "elon", "-", RowBox[{"2", "*", "collisionDistance"}]}], ")"}], "/", "2"}]}], "}"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"0.", ",", "0."}], "}"}]}], "}"}], ",", RowBox[{"{", "cellNumber", "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"walks", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{"posvel", "[", RowBox[{"[", RowBox[{"i", ",", "1"}], "]"}], "]"}], "}"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"Length", "[", "posvel", "]"}]}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Do", "[", RowBox[{ RowBox[{ RowBox[{"Pause", "[", ".05", "]"}], ";", RowBox[{"elapsedTime", "=", "t"}], ";", "\[IndentingNewLine]", RowBox[{"posvel", "=", RowBox[{ RowBox[{ RowBox[{"ranCollStep", "[", RowBox[{ "#", ",", "phi", ",", "sd", ",", "collisionDistance", ",", RowBox[{"nearestNPos", "[", "#", "]"}], ",", "phi2", ",", "sd2", ",", "psi", ",", RowBox[{"If", "[", RowBox[{ RowBox[{"t", "<", "midlineDelay"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "midlineHalfWidth"}], ",", "midlineHalfWidth"}], "}"}], ",", RowBox[{"{", RowBox[{"1000", ",", "1000"}], "}"}]}], "]"}]}], "]"}], "&"}], "/@", "posvel"}]}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"t", "==", "trackplotDelay"}], ",", RowBox[{"walks", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{"posvel", "[", RowBox[{"[", RowBox[{"i", ",", "1"}], "]"}], "]"}], "}"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"Length", "[", "posvel", "]"}]}], "}"}]}], "]"}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"t", ">", "trackplotDelay"}], ",", RowBox[{"Do", "[", RowBox[{ RowBox[{ RowBox[{"walks", "[", RowBox[{"[", "i", "]"}], "]"}], "=", RowBox[{"Join", "[", RowBox[{ RowBox[{"walks", "[", RowBox[{"[", "i", "]"}], "]"}], ",", RowBox[{"{", RowBox[{"posvel", "[", RowBox[{"[", RowBox[{"i", ",", "1"}], "]"}], "]"}], "}"}]}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"Length", "[", "posvel", "]"}]}], "}"}]}], "]"}]}], "]"}]}], "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{"t", ",", "totalSimulationTime"}], "}"}]}], "]"}]}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", RowBox[{"startsim", "=", "False"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{"simulate", ",", RowBox[{ RowBox[{"showP", "=", "True"}], ";", RowBox[{"startsim", "=", "True"}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"simulate", "=", "False"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{"showP", ",", "\[IndentingNewLine]", RowBox[{"Dynamic", "[", RowBox[{"GraphicsRow", "[", RowBox[{ RowBox[{"{", "\[IndentingNewLine]", RowBox[{ RowBox[{"Graphics", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"Line", "[", "embo", "]"}], ",", RowBox[{ RowBox[{ RowBox[{"Circle", "[", RowBox[{"#", ",", RowBox[{"collisionDistance", "/", "2"}]}], "]"}], "&"}], "/@", RowBox[{ RowBox[{"Transpose", "[", "posvel", "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}]}], "}"}], ",", RowBox[{"AspectRatio", "->", "Automatic"}], ",", RowBox[{"PlotLabel", "->", RowBox[{ RowBox[{"ToString", "[", "elapsedTime", "]"}], "<>", "\"\< min\>\""}]}], ",", RowBox[{"Frame", "->", "True"}], ",", RowBox[{"FrameTicks", "\[Rule]", "False"}], ",", RowBox[{"Axes", "->", "False"}], ",", RowBox[{"PlotRange", "->", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "x"}], ",", "x"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "y"}], ",", "y"}], "}"}]}], "}"}]}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"ListLinePlot", "[", RowBox[{ RowBox[{"Flatten", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"{", "embo", "}"}], ",", "walks"}], "}"}], ",", "1"}], "]"}], ",", RowBox[{"AspectRatio", "->", "Automatic"}], ",", RowBox[{"PlotLabel", "->", RowBox[{ RowBox[{"ToString", "[", "cellNumber", "]"}], "<>", "\"\< cells\>\""}]}], ",", RowBox[{"Frame", "->", "True"}], ",", RowBox[{"FrameTicks", "\[Rule]", "False"}], ",", RowBox[{"Axes", "->", "False"}], ",", RowBox[{"PlotRange", "->", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "x"}], ",", "x"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "y"}], ",", "y"}], "}"}]}], "}"}]}]}], "]"}]}], "}"}], ",", RowBox[{"AspectRatio", "\[Rule]", "1.56"}], ",", RowBox[{"ImageSize", "\[Rule]", "Large"}]}], "]"}], "\[IndentingNewLine]", "]"}], ",", "\[IndentingNewLine]", RowBox[{"GraphicsRow", "[", RowBox[{ RowBox[{"{", "\[IndentingNewLine]", RowBox[{ RowBox[{"Graphics", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"Line", "[", "embo", "]"}], ",", RowBox[{ RowBox[{ RowBox[{"Circle", "[", RowBox[{"#", ",", RowBox[{"collisionDistance", "/", "2"}]}], "]"}], "&"}], "/@", RowBox[{ RowBox[{"Transpose", "[", "posvel", "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}]}], "}"}], ",", RowBox[{"AspectRatio", "->", "Automatic"}], ",", RowBox[{"Frame", "->", "True"}], ",", RowBox[{"FrameTicks", "\[Rule]", "False"}], ",", RowBox[{"Axes", "->", "False"}], ",", RowBox[{"PlotRange", "->", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "x"}], ",", "x"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "y"}], ",", "y"}], "}"}]}], "}"}]}]}], "]"}], ",", RowBox[{"ListLinePlot", "[", RowBox[{ RowBox[{"Flatten", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"{", "embo", "}"}], ",", "walks"}], "}"}], ",", "1"}], "]"}], ",", RowBox[{"AspectRatio", "->", "Automatic"}], ",", RowBox[{"Frame", "->", "True"}], ",", RowBox[{"FrameTicks", "\[Rule]", "False"}], ",", RowBox[{"Axes", "->", "False"}], ",", RowBox[{"PlotRange", "->", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "x"}], ",", "x"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "y"}], ",", "y"}], "}"}]}], "}"}]}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Blur", "[", RowBox[{ RowBox[{"Graphics", "[", RowBox[{ RowBox[{"{", RowBox[{"Black", ",", RowBox[{"Rectangle", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "x"}], ",", RowBox[{"-", "y"}]}], "}"}], ",", RowBox[{"{", RowBox[{"x", ",", "y"}], "}"}]}], "]"}], ",", RowBox[{"Thickness", "[", "0.06", "]"}], ",", "White", ",", RowBox[{"Line", "[", "embo", "]"}], ",", RowBox[{"Thickness", "[", "0.02", "]"}], ",", RowBox[{"Opacity", "[", ".040", "]"}], ",", RowBox[{ RowBox[{ RowBox[{"Circle", "[", RowBox[{"#", ",", "4"}], "]"}], "&"}], "/@", RowBox[{"Flatten", "[", RowBox[{"walks", ",", "1"}], "]"}]}]}], "}"}], ",", RowBox[{"PlotRange", "->", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "x"}], ",", "x"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "y"}], ",", "y"}], "}"}]}], "}"}]}]}], "]"}], ",", "8"}], "]"}]}], "\[IndentingNewLine]", "}"}], ",", RowBox[{"AspectRatio", "\[Rule]", "1.2"}], ",", RowBox[{"ImageSize", "\[Rule]", "Large"}]}], "]"}]}], "\[IndentingNewLine]", "]"}]}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"Item", "[", RowBox[{"Style", "[", RowBox[{"\"\\"", ",", RowBox[{"FontFamily", "->", "\"\\""}], ",", "Bold", ",", "14", ",", "Black"}], "]"}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Item", "[", RowBox[{"Button", "[", RowBox[{"\"\< Restore defaults \>\"", ",", RowBox[{"restore", "=", "True"}], ",", RowBox[{"ImageSize", "\[Rule]", "Automatic"}], ",", RowBox[{"BaseStyle", "\[Rule]", RowBox[{"{", "16", "}"}]}]}], "]"}], " ", "]"}], ",", "\[IndentingNewLine]", RowBox[{"Item", "[", RowBox[{"Style", "[", RowBox[{"\"\<\>\"", ",", RowBox[{"FontFamily", "->", "\"\\""}], ",", "14", ",", "Black"}], "]"}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ "totalSimulationTime", ",", "1", ",", "\"\\""}], "}"}], ",", "10", ",", "400", ",", "1", ",", RowBox[{"Appearance", "\[Rule]", "\"\\""}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"cellNumber", ",", "1", ",", "\"\\""}], "}"}], ",", "1", ",", "60", ",", "1", ",", RowBox[{"Appearance", "\[Rule]", "\"\\""}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"collisionDistance", ",", "1", ",", "\"\\""}], "}"}], ",", "0", ",", "50", ",", RowBox[{"Appearance", "\[Rule]", "\"\\""}]}], "}"}], ",", "\[IndentingNewLine]", "Delimiter", ",", "\[IndentingNewLine]", RowBox[{"Item", "[", RowBox[{"Style", "[", RowBox[{"\"\\"", ",", RowBox[{"FontFamily", "->", "\"\\""}], ",", "Bold", ",", "14", ",", "Black"}], "]"}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"phi", ",", "1", ",", "\"\<\!\(\* StyleBox[\"\[Phi]\", FontFamily->\"Comic Sans MS\", FontSize->18]\)\>\""}], "}"}], ",", "0", ",", "1", ",", RowBox[{"Appearance", "\[Rule]", "\"\\""}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"sd", ",", "1", ",", "\"\<\!\(\* StyleBox[\"\[Sigma]\", FontFamily->\"Comic Sans MS\", FontSize->18]\)\>\""}], "}"}], ",", "0.01", ",", "2", ",", RowBox[{"Appearance", "\[Rule]", "\"\\""}]}], "}"}], ",", "\[IndentingNewLine]", "Delimiter", ",", "\[IndentingNewLine]", RowBox[{"Item", "[", RowBox[{"Style", "[", RowBox[{"\"\<\>\"", ",", RowBox[{"FontFamily", "->", "\"\\""}], ",", "18", ",", "Black"}], "]"}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Item", "[", RowBox[{"Button", "[", RowBox[{"\"\< RUN SIMULATION \>\"", ",", RowBox[{"simulate", "=", "True"}], ",", RowBox[{"ImageSize", "\[Rule]", "Automatic"}], ",", RowBox[{"Background", "\[Rule]", RowBox[{"Dynamic", "[", RowBox[{"If", "[", RowBox[{"startsim", ",", "Blue", ",", "White"}], "]"}], "]"}]}], ",", RowBox[{"BaseStyle", "\[Rule]", RowBox[{"{", RowBox[{"16", ",", "Bold", ",", "Blue"}], "}"}]}]}], "]"}], " ", "]"}], ",", "\[IndentingNewLine]", RowBox[{"Item", "[", RowBox[{"Style", "[", RowBox[{"\"\<\>\"", ",", RowBox[{"FontFamily", "->", "\"\\""}], ",", "14", ",", "Black"}], "]"}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Item", "[", RowBox[{"Style", "[", RowBox[{ "\"\<\nWait for simulation to finish to see domain map.\>\"", ",", RowBox[{"FontFamily", "->", "\"\\""}], ",", "16", ",", "Black"}], "]"}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Item", "[", RowBox[{"Button", "[", RowBox[{"\"\< Show domains \>\"", ",", RowBox[{"showP", "=", "False"}], ",", RowBox[{"ImageSize", "\[Rule]", "Automatic"}], ",", RowBox[{"BaseStyle", "\[Rule]", RowBox[{"{", "16", "}"}]}]}], "]"}], " ", "]"}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"FrameLabel", "\[Rule]", RowBox[{"{", RowBox[{"None", ",", "None", ",", RowBox[{"Style", "[", RowBox[{ "\"\\"", ",", RowBox[{"FontFamily", "->", "\"\\""}], ",", "Bold", ",", "Italic", ",", "20", ",", "Black"}], "]"}], ",", "None"}], "}"}]}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"SaveDefinitions", "\[Rule]", "True"}]}], "]"}]}], "Input", CellOpen->False, CellChangeTimes->{{3.52811492028125*^9, 3.5281150868125*^9}, { 3.52811516975*^9, 3.52811517034375*^9}, 3.5281154265*^9, { 3.528115495625*^9, 3.52811550840625*^9}, 3.52811581896875*^9, { 3.52811600475*^9, 3.52811601609375*^9}, {3.528116184921875*^9, 3.528116304046875*^9}, {3.528116355796875*^9, 3.528116399984375*^9}, { 3.52811648028125*^9, 3.52811650090625*^9}, {3.528116595421875*^9, 3.52811664834375*^9}, {3.528116758484375*^9, 3.52811678396875*^9}, { 3.52811684003125*^9, 3.52811691184375*^9}, {3.528116993625*^9, 3.5281169955*^9}, {3.52811703684375*^9, 3.528117079390625*^9}, { 3.52811715546875*^9, 3.52811716059375*^9}, {3.528117204390625*^9, 3.528117245671875*^9}, {3.528117278734375*^9, 3.52811728884375*^9}, { 3.52811735065625*^9, 3.528117368609375*^9}, {3.528117409328125*^9, 3.528117427140625*^9}, {3.528117472265625*^9, 3.528117626109375*^9}, { 3.528117657796875*^9, 3.5281176625625*^9}, {3.528117732703125*^9, 3.5281178066875*^9}, {3.5281489723772*^9, 3.5281489769161997`*^9}, { 3.5281491800102*^9, 3.5281492192042*^9}, {3.5281492839102*^9, 3.5281494123122*^9}, {3.5281494446492*^9, 3.5281494577462*^9}, { 3.5281494981612*^9, 3.5281496097892*^9}, {3.5281496539542*^9, 3.5281496981991997`*^9}, {3.5281498220931997`*^9, 3.5281498565952*^9}, 3.5281499264012003`*^9, {3.5281500071692*^9, 3.5281500150562*^9}, 3.5281500463361998`*^9, {3.5281501623342*^9, 3.5281501650582*^9}, { 3.5281502408092003`*^9, 3.5281502435822*^9}, 3.5281503866602*^9, { 3.5281504899941998`*^9, 3.5281505599332*^9}, {3.5281506227172003`*^9, 3.5281506560081997`*^9}, {3.5281507432932*^9, 3.5281507687562*^9}, { 3.5281508369812*^9, 3.5281508371832*^9}, {3.5281508677022*^9, 3.5281508743622*^9}, {3.5281509782802*^9, 3.5281509899102*^9}, { 3.5281510843032*^9, 3.5281511406542*^9}, {3.5281511987042*^9, 3.5281512550652*^9}, {3.5281518172462*^9, 3.5281518495962*^9}, { 3.5281520875762*^9, 3.5281521077992*^9}, {3.5281522215572*^9, 3.5281522257572002`*^9}, {3.5281523360782003`*^9, 3.5281523409052*^9}, { 3.5281523716692*^9, 3.5281524032492*^9}, {3.5281524787692003`*^9, 3.5281525139372*^9}, {3.5281525543232*^9, 3.5281525638852*^9}, { 3.528196604461605*^9, 3.5281966131508055`*^9}, {3.528236952524*^9, 3.528236996818*^9}, 3.528237048127*^9, {3.528237086882*^9, 3.528237090469*^9}, 3.5282371241879997`*^9, 3.528237166821*^9, { 3.52823720412*^9, 3.5282372195*^9}, {3.52823726204*^9, 3.5282372698199997`*^9}, 3.528237493398*^9, {3.5282375713450003`*^9, 3.528237634443*^9}, {3.528237895718*^9, 3.5282379015880003`*^9}, { 3.528237963199*^9, 3.5282380301470003`*^9}, {3.528238100105*^9, 3.528238106519*^9}, {3.528238220716*^9, 3.528238229207*^9}, { 3.528238265723*^9, 3.528238273197*^9}, {3.52823836315*^9, 3.5282383742869997`*^9}, {3.528238410017*^9, 3.528238439554*^9}, 3.528238531707*^9, {3.528238692321*^9, 3.528238702609*^9}, { 3.528238810017*^9, 3.52823882702*^9}, 3.528238890288*^9, { 3.528238932201*^9, 3.528239042825*^9}, 3.528239085058*^9, 3.528239156395*^9, 3.528239191487*^9, {3.5282392486540003`*^9, 3.528239282141*^9}, {3.52823939854*^9, 3.528239417918*^9}, { 3.528239579821*^9, 3.528239582975*^9}, 3.52823963662*^9, { 3.528239790039*^9, 3.528239812771*^9}, {3.528239854124*^9, 3.528239862076*^9}, {3.5282400781289997`*^9, 3.5282401552130003`*^9}, { 3.528240202699*^9, 3.528240203199*^9}, {3.528448579115624*^9, 3.528448596241624*^9}, {3.5284486534196243`*^9, 3.528448661348624*^9}, { 3.5284512748746243`*^9, 3.528451283473624*^9}, {3.528451330205624*^9, 3.528451337733624*^9}, {3.5284519121656237`*^9, 3.528451924840624*^9}, 3.528452711850624*^9, 3.528452744845624*^9, {3.528452808777624*^9, 3.528452818846624*^9}, {3.528453827520624*^9, 3.528453831265624*^9}, { 3.5284538851186237`*^9, 3.528453923862624*^9}, {3.5284543957826242`*^9, 3.5284544248276243`*^9}, {3.528454514065624*^9, 3.5284546621846237`*^9}, 3.528454747943624*^9, {3.528454793031624*^9, 3.528454817245624*^9}, { 3.5284549634416237`*^9, 3.528455022127624*^9}, {3.528455115119624*^9, 3.528455188911624*^9}, {3.528455306233624*^9, 3.528455310962624*^9}, { 3.528455345554624*^9, 3.528455361514624*^9}, 3.528455392598624*^9, 3.528455449734624*^9, {3.528455520766624*^9, 3.528455532902624*^9}, { 3.528455583539624*^9, 3.528455586455624*^9}, {3.528455729718624*^9, 3.528455735062624*^9}, {3.528455857980624*^9, 3.528455906410624*^9}, 3.528455952889624*^9, {3.528456139397624*^9, 3.528456183489624*^9}, 3.528456269751624*^9, {3.528456389142624*^9, 3.528456457780624*^9}, 3.528456577389624*^9, {3.528456664259624*^9, 3.528456679562624*^9}, { 3.528456928189624*^9, 3.528456939765624*^9}, {3.528457112246624*^9, 3.528457148458624*^9}, {3.528457193081624*^9, 3.528457193175624*^9}, 3.528457903479624*^9, {3.5284579791516237`*^9, 3.528458029720624*^9}, { 3.5284581250706244`*^9, 3.5284581691956244`*^9}, 3.528458200148624*^9, { 3.528458296891624*^9, 3.528458300075624*^9}, {3.528458357569624*^9, 3.528458358696624*^9}, 3.528458439188624*^9, {3.528459634936624*^9, 3.528459733455624*^9}, {3.5284598184606237`*^9, 3.528459821078624*^9}, { 3.528459931904624*^9, 3.528459944440624*^9}, {3.528460212061624*^9, 3.5284602754006243`*^9}, {3.528460313227624*^9, 3.528460317383624*^9}, { 3.528460373244624*^9, 3.5284603837836237`*^9}, 3.5284605428026237`*^9, { 3.5284607287946243`*^9, 3.528460738921624*^9}, {3.528463884727624*^9, 3.528463886880424*^9}, {3.528463968000424*^9, 3.528463970480824*^9}, { 3.528464042053624*^9, 3.528464070196024*^9}, {3.528464153328424*^9, 3.528464178896824*^9}, 3.528464421305224*^9, 3.528464492971624*^9, { 3.528464647661224*^9, 3.528464693899624*^9}, {3.528464816936824*^9, 3.528464829978424*^9}, 3.5284648889308243`*^9, 3.5284973424496*^9, 3.5284973805156*^9, {3.5284974152396*^9, 3.5284974333696003`*^9}, 3.5284974857616*^9, {3.528499405334*^9, 3.528499714166*^9}, 3.528499747083*^9, {3.528499808638*^9, 3.528499857072*^9}, { 3.528499904825*^9, 3.52849994135*^9}, {3.528499992913*^9, 3.528500022613*^9}, {3.528500091362*^9, 3.528500095406*^9}, 3.5285001255559998`*^9, {3.5285001647650003`*^9, 3.52850018801*^9}, 3.528500450367*^9, {3.528500783547*^9, 3.5285007880150003`*^9}, { 3.528500840347*^9, 3.5285008440369997`*^9}, 3.5481952155367403`*^9, { 3.548195444966343*^9, 3.5481954474779477`*^9}, {3.548195593400604*^9, 3.5481956253182597`*^9}, 3.548195667578734*^9, {3.548195721726429*^9, 3.5481957459376717`*^9}, {3.5481958285086164`*^9, 3.548195834171427*^9}, { 3.5481959838692894`*^9, 3.5481959945553083`*^9}, {3.5481960498574057`*^9, 3.548196050965008*^9}, {3.5481963643071575`*^9, 3.5481964286728706`*^9}, { 3.5481964956125884`*^9, 3.5481965229282365`*^9}, 3.5481966729068995`*^9, 3.548196719691382*^9, 3.5481969174529295`*^9, {3.548197076651209*^9, 3.548197078273612*^9}, 3.548197230373879*^9, {3.5481972784687634`*^9, 3.548197283788373*^9}, 3.548197325799247*^9, {3.548197423767419*^9, 3.548197509239969*^9}, 3.548197564635666*^9, {3.5481976159285564`*^9, 3.5481976320901847`*^9}, 3.5481976740854588`*^9, {3.548197773176832*^9, 3.548197782053248*^9}, {3.5481983177113886`*^9, 3.5481983293334093`*^9}, { 3.5481983915307183`*^9, 3.548198415710761*^9}, {3.54819844929762*^9, 3.5481984498748207`*^9}, {3.5481985038197155`*^9, 3.548198518795742*^9}, 3.552049040143381*^9}], Cell[BoxData[ TagBox[ StyleBox[ DynamicModuleBox[{$CellContext`cellNumber$$ = 30, $CellContext`collisionDistance$$ = 30., $CellContext`phi$$ = 0.73, $CellContext`sd$$ = 1.25, $CellContext`totalSimulationTime$$ = 180, Typeset`show$$ = True, Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = "\"untitled\"", Typeset`specs$$ = {{ Hold[ Item[ Style["ENTER PARAMETERS:", FontFamily -> "Helvetica", Bold, 14, GrayLevel[0]]]], Manipulate`Dump`ThisIsNotAControl}, { Hold[ Item[ Button[ " Restore defaults ", $CellContext`restore = True, ImageSize -> Automatic, BaseStyle -> {16}]]], Manipulate`Dump`ThisIsNotAControl}, { Hold[ Item[ Style["", FontFamily -> "Helvetica", 14, GrayLevel[0]]]], Manipulate`Dump`ThisIsNotAControl}, {{ Hold[$CellContext`totalSimulationTime$$], 1, "Total simulation time"}, 10, 400, 1}, {{ Hold[$CellContext`cellNumber$$], 1, "Number of cells"}, 1, 60, 1}, {{ Hold[$CellContext`collisionDistance$$], 1, "Cell diameter"}, 0, 50}, { Hold[ Item[ Style["Free motion:", FontFamily -> "Helvetica", Bold, 14, GrayLevel[0]]]], Manipulate`Dump`ThisIsNotAControl}, {{ Hold[$CellContext`phi$$], 1, "\!\(\*\nStyleBox[\"\[Phi]\",\nFontFamily->\"Comic Sans MS\",\n\ FontSize->18]\)"}, 0, 1}, {{ Hold[$CellContext`sd$$], 1, "\!\(\*\nStyleBox[\"\[Sigma]\",\nFontFamily->\"Comic Sans MS\",\n\ FontSize->18]\)"}, 0.01, 2}, { Hold[ Item[ Style["", FontFamily -> "Helvetica", 18, GrayLevel[0]]]], Manipulate`Dump`ThisIsNotAControl}, { Hold[ Item[ Button[ " RUN SIMULATION ", $CellContext`simulate = True, ImageSize -> Automatic, Background -> Dynamic[ If[$CellContext`startsim, Blue, White]], BaseStyle -> {16, Bold, RGBColor[0, 0, 1]}]]], Manipulate`Dump`ThisIsNotAControl}, { Hold[ Item[ Style["", FontFamily -> "Helvetica", 14, GrayLevel[0]]]], Manipulate`Dump`ThisIsNotAControl}, { Hold[ Item[ Style[ "\nWait for simulation to finish to see domain map.", FontFamily -> "Helvetica", 16, GrayLevel[0]]]], Manipulate`Dump`ThisIsNotAControl}, { Hold[ Item[ Button[ " Show domains ", $CellContext`showP = False, ImageSize -> Automatic, BaseStyle -> {16}]]], Manipulate`Dump`ThisIsNotAControl}}, Typeset`size$$ = {576., {237., 241.}}, Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ = False, $CellContext`totalSimulationTime$767$$ = 0, $CellContext`cellNumber$768$$ = 0, $CellContext`collisionDistance$769$$ = 0, $CellContext`phi$770$$ = 0, $CellContext`sd$771$$ = 0}, DynamicBox[Manipulate`ManipulateBoxes[ 1, StandardForm, "Variables" :> {$CellContext`cellNumber$$ = 1, $CellContext`collisionDistance$$ = 1, $CellContext`phi$$ = 1, $CellContext`sd$$ = 1, $CellContext`totalSimulationTime$$ = 1}, "ControllerVariables" :> { Hold[$CellContext`totalSimulationTime$$, \ $CellContext`totalSimulationTime$767$$, 0], Hold[$CellContext`cellNumber$$, $CellContext`cellNumber$768$$, 0], Hold[$CellContext`collisionDistance$$, \ $CellContext`collisionDistance$769$$, 0], Hold[$CellContext`phi$$, $CellContext`phi$770$$, 0], Hold[$CellContext`sd$$, $CellContext`sd$771$$, 0]}, "OtherVariables" :> { Typeset`show$$, Typeset`bookmarkList$$, Typeset`bookmarkMode$$, Typeset`animator$$, Typeset`animvar$$, Typeset`name$$, Typeset`specs$$, Typeset`size$$, Typeset`update$$, Typeset`initDone$$, Typeset`skipInitDone$$}, "Body" :> ( If[$CellContext`restore, $CellContext`phi$$ = 0.73; $CellContext`sd$$ = 1.25; $CellContext`collisionDistance$$ = 20.; $CellContext`psi = 1.25; $CellContext`phi2 = 0.51; $CellContext`sd2 = 0.7; $CellContext`cellNumber$$ = 30; $CellContext`totalSimulationTime$$ = 300; $CellContext`midlineHalfWidth = 4; $CellContext`midlineDelay = 40; $CellContext`trackplotDelay = 30]; $CellContext`restore = False; If[$CellContext`startsim, $CellContext`posvel = Table[{{ RandomReal[{-1, 1}], RandomReal[{(-($CellContext`embht + $CellContext`elon - 2 $CellContext`collisionDistance$$))/ 2, ($CellContext`embht + $CellContext`elon - 2 $CellContext`collisionDistance$$)/2}]}, {0., 0.}}, {$CellContext`cellNumber$$}]; $CellContext`walks = Table[{ Part[$CellContext`posvel, $CellContext`i, 1]}, {$CellContext`i, Length[$CellContext`posvel]}]; Do[Pause[ 0.05]; $CellContext`elapsedTime = $CellContext`t; \ $CellContext`posvel = Map[$CellContext`ranCollStep[#, $CellContext`phi$$, \ $CellContext`sd$$, $CellContext`collisionDistance$$, $CellContext`nearestNPos[#], $CellContext`phi2, \ $CellContext`sd2, $CellContext`psi, If[$CellContext`t < $CellContext`midlineDelay, \ {-$CellContext`midlineHalfWidth, $CellContext`midlineHalfWidth}, {1000, 1000}]]& , $CellContext`posvel]; If[$CellContext`t == $CellContext`trackplotDelay, \ $CellContext`walks = Table[{ Part[$CellContext`posvel, $CellContext`i, 1]}, {$CellContext`i, Length[$CellContext`posvel]}]]; If[$CellContext`t > $CellContext`trackplotDelay, Do[Part[$CellContext`walks, $CellContext`i] = Join[ Part[$CellContext`walks, $CellContext`i], { Part[$CellContext`posvel, $CellContext`i, 1]}], {$CellContext`i, Length[$CellContext`posvel]}]], {$CellContext`t, \ $CellContext`totalSimulationTime$$}]]; $CellContext`startsim = False; If[$CellContext`simulate, $CellContext`showP = True; $CellContext`startsim = True]; $CellContext`simulate = False; If[$CellContext`showP, Dynamic[ GraphicsRow[{ Graphics[{ Line[$CellContext`embo], Map[Circle[#, $CellContext`collisionDistance$$/2]& , Part[ Transpose[$CellContext`posvel], 1]]}, AspectRatio -> Automatic, PlotLabel -> StringJoin[ ToString[$CellContext`elapsedTime], " min"], Frame -> True, FrameTicks -> False, Axes -> False, PlotRange -> {{-$CellContext`x, $CellContext`x}, \ {-$CellContext`y, $CellContext`y}}], ListLinePlot[ Flatten[{{$CellContext`embo}, $CellContext`walks}, 1], AspectRatio -> Automatic, PlotLabel -> StringJoin[ ToString[$CellContext`cellNumber$$], " cells"], Frame -> True, FrameTicks -> False, Axes -> False, PlotRange -> {{-$CellContext`x, $CellContext`x}, \ {-$CellContext`y, $CellContext`y}}]}, AspectRatio -> 1.56, ImageSize -> Large]], GraphicsRow[{ Graphics[{ Line[$CellContext`embo], Map[Circle[#, $CellContext`collisionDistance$$/2]& , Part[ Transpose[$CellContext`posvel], 1]]}, AspectRatio -> Automatic, Frame -> True, FrameTicks -> False, Axes -> False, PlotRange -> {{-$CellContext`x, $CellContext`x}, \ {-$CellContext`y, $CellContext`y}}], ListLinePlot[ Flatten[{{$CellContext`embo}, $CellContext`walks}, 1], AspectRatio -> Automatic, Frame -> True, FrameTicks -> False, Axes -> False, PlotRange -> {{-$CellContext`x, $CellContext`x}, \ {-$CellContext`y, $CellContext`y}}], Blur[ Graphics[{Black, Rectangle[{-$CellContext`x, -$CellContext`y}, {$CellContext`x, \ $CellContext`y}], Thickness[0.06], White, Line[$CellContext`embo], Thickness[0.02], Opacity[0.04], Map[Circle[#, 4]& , Flatten[$CellContext`walks, 1]]}, PlotRange -> {{-$CellContext`x, $CellContext`x}, \ {-$CellContext`y, $CellContext`y}}], 8]}, AspectRatio -> 1.2, ImageSize -> Large]]), "Specifications" :> { Item[ Style["ENTER PARAMETERS:", FontFamily -> "Helvetica", Bold, 14, GrayLevel[0]]], Item[ Button[ " Restore defaults ", $CellContext`restore = True, ImageSize -> Automatic, BaseStyle -> {16}]], Item[ Style["", FontFamily -> "Helvetica", 14, GrayLevel[0]]], {{$CellContext`totalSimulationTime$$, 1, "Total simulation time"}, 10, 400, 1, Appearance -> "Labeled"}, {{$CellContext`cellNumber$$, 1, "Number of cells"}, 1, 60, 1, Appearance -> "Labeled"}, {{$CellContext`collisionDistance$$, 1, "Cell diameter"}, 0, 50, Appearance -> "Labeled"}, Delimiter, Item[ Style["Free motion:", FontFamily -> "Helvetica", Bold, 14, GrayLevel[0]]], {{$CellContext`phi$$, 1, "\!\(\*\nStyleBox[\"\[Phi]\",\nFontFamily->\"Comic Sans MS\",\n\ FontSize->18]\)"}, 0, 1, Appearance -> "Labeled"}, {{$CellContext`sd$$, 1, "\!\(\*\nStyleBox[\"\[Sigma]\",\nFontFamily->\"Comic Sans MS\",\n\ FontSize->18]\)"}, 0.01, 2, Appearance -> "Labeled"}, Delimiter, Item[ Style["", FontFamily -> "Helvetica", 18, GrayLevel[0]]], Item[ Button[ " RUN SIMULATION ", $CellContext`simulate = True, ImageSize -> Automatic, Background -> Dynamic[ If[$CellContext`startsim, Blue, White]], BaseStyle -> {16, Bold, RGBColor[0, 0, 1]}]], Item[ Style["", FontFamily -> "Helvetica", 14, GrayLevel[0]]], Item[ Style[ "\nWait for simulation to finish to see domain map.", FontFamily -> "Helvetica", 16, GrayLevel[0]]], Item[ Button[ " Show domains ", $CellContext`showP = False, ImageSize -> Automatic, BaseStyle -> {16}]]}, "Options" :> {FrameLabel -> {None, None, Style[ "Drosophila Haemocyte Simulation - Volume Exclusion Model", FontFamily -> "Helvetica", Bold, Italic, 20, GrayLevel[0]], None}}, "DefaultOptions" :> {}], ImageSizeCache->{1002., {279., 284.}}, SingleEvaluation->True], Deinitialization:>None, DynamicModuleValues:>{}, Initialization:>({$CellContext`restore = False, $CellContext`phi$$ = 0.73, $CellContext`sd$$ = 1.25, $CellContext`collisionDistance$$ = 30., $CellContext`psi = 1.25, $CellContext`phi2 = 0.51, $CellContext`sd2 = 0.7, $CellContext`cellNumber$$ = 30, $CellContext`totalSimulationTime$$ = 180, $CellContext`midlineHalfWidth = 4, $CellContext`midlineDelay = 40, $CellContext`trackplotDelay = 30, $CellContext`startsim = False, $CellContext`posvel = {{{0, 0}, {0., 0.}}}, $CellContext`embht = 160, $CellContext`elon = 160, $CellContext`walks = {{{0, 0}}}, $CellContext`elapsedTime = 180, $CellContext`ranCollStep[{ Pattern[$CellContext`pos, Blank[]], Pattern[$CellContext`vel, Blank[]]}, Pattern[$CellContext`phi, Blank[]], Pattern[$CellContext`sdn, Blank[]], Pattern[$CellContext`collisionDistance, Blank[]], Pattern[$CellContext`nnPos, Blank[]], Pattern[$CellContext`phi2, Blank[]], Pattern[$CellContext`sdn2, Blank[]], Pattern[$CellContext`psi, Blank[]], { Pattern[$CellContext`lowX, Blank[]], Pattern[$CellContext`highX, Blank[]]}] := Module[{$CellContext`vt, $CellContext`nnVec = $CellContext`pos - \ $CellContext`nnPos}, If[Norm[$CellContext`nnVec] > $CellContext`collisionDistance, \ $CellContext`vt = $CellContext`phi $CellContext`vel + \ $CellContext`noise2D[$CellContext`sdn], $CellContext`vt = $CellContext`nnVec/ Norm[$CellContext`nnVec]]; $CellContext`pt = $CellContext`pos + \ $CellContext`vt; If[Part[$CellContext`pt, 1] < $CellContext`lowX, Part[$CellContext`pt, 1] = 2 $CellContext`lowX - Part[$CellContext`pt, 1]; $CellContext`vt = {-1, 1} $CellContext`vt]; If[Part[$CellContext`pt, 1] > $CellContext`highX, Part[$CellContext`pt, 1] = 2 $CellContext`highX - Part[$CellContext`pt, 1]; $CellContext`vt = {-1, 1} $CellContext`vt]; {$CellContext`pt, $CellContext`vt}], \ $CellContext`noise2D[ Pattern[$CellContext`sd, Blank[]]] := { RandomReal[ NormalDistribution[0, $CellContext`sd]], RandomReal[ NormalDistribution[0, $CellContext`sd]]}, $CellContext`pt = { 13.233810043145013`, -92.8980992974029}, $CellContext`nearestNPos[ Pattern[$CellContext`pos, Blank[]]] := Part[ Nearest[ Join[$CellContext`embo, Part[ Transpose[$CellContext`posvel], 1]], $CellContext`pos, 2], 2], $CellContext`embo = {{55., 80.}, {54.32285873273258, 92.51475720321847}, {52.30810839623344, 104.7213595499958}, { 49.00535883036024, 116.31923997916374`}, {44.49593469062211, 127.02282018339785`}, {38.890872965260115`, 136.5685424949238}, { 32.328188876086024`, 144.72135954999578`}, {24.969477485675075`, 151.28052193506943`}, {16.99593469062211, 156.0845213036123}, { 8.6038955772127, 159.01506724761103`}, {3.3677786976552213`*^-15, 160.}, {-8.603895577212695, 159.01506724761103`}, {-16.995934690622104`, 156.0845213036123}, {-24.969477485675068`, 151.28052193506943`}, {-32.32818887608602, 144.72135954999578`}, {-38.89087296526011, 136.5685424949238}, {-44.49593469062211, 127.02282018339787`}, {-49.00535883036023, 116.31923997916374`}, {-52.30810839623344, 104.7213595499958}, {-54.32285873273257, 92.51475720321848}, {-55., 80.00000000000001}, {-55, 70}, {-55, 60}, {-55, 50}, {-55, 40}, {-55, 30}, {-55, 20}, {-55, 10}, {-55, 0}, {-55, -10}, {-55, -20}, {-55, -30}, {-55, -40}, {-55, -50}, \ {-55, -60}, {-55, -70}, {-55., -79.99999999999999}, {-54.32285873273258, \ -92.51475720321847}, {-52.30810839623345, -104.72135954999578`}, \ {-49.00535883036024, -116.31923997916374`}, {-44.495934690622114`, \ -127.02282018339784`}, {-38.89087296526012, -136.5685424949238}, \ {-32.32818887608603, -144.72135954999578`}, {-24.969477485675082`, \ -151.28052193506943`}, {-16.995934690622114`, -156.0845213036123}, \ {-8.603895577212707, -159.015067247611}, {-1.0103336092965664`*^-14, -160.}, { 8.603895577212688, -159.01506724761103`}, { 16.995934690622096`, -156.0845213036123}, { 24.969477485675064`, -151.28052193506943`}, { 32.32818887608601, -144.7213595499958}, { 38.8908729652601, -136.5685424949238}, { 44.49593469062211, -127.02282018339787`}, { 49.00535883036023, -116.31923997916375`}, { 52.30810839623344, -104.72135954999581`}, { 54.32285873273257, -92.5147572032185}, {55., -80.00000000000001}, { 55, -70}, {55, -60}, {55, -50}, {55, -40}, {55, -30}, {55, -20}, { 55, -10}, {55, 0}, {55, 10}, {55, 20}, {55, 30}, {55, 40}, {55, 50}, {55, 60}, {55, 70}, {55, 80}}, $CellContext`simulate = False, $CellContext`showP = True, $CellContext`x = 65, $CellContext`y = 170}; Typeset`initDone$$ = True), SynchronousInitialization->True, UnsavedVariables:>{Typeset`initDone$$}, UntrackedVariables:>{Typeset`size$$}], "Manipulate", Deployed->True, StripOnInput->False], Manipulate`InterpretManipulate[1]]], "Output", CellChangeTimes->{ 3.528237130043*^9, 3.5282372219639997`*^9, 3.528237271483*^9, 3.528237636448*^9, 3.528237903824*^9, 3.5282380323780003`*^9, 3.528238108296*^9, 3.528238230309*^9, 3.528238274477*^9, {3.52823836446*^9, 3.528238375183*^9}, {3.528238411467*^9, 3.528238440413*^9}, 3.528238534792*^9, 3.528238704994*^9, 3.528238835631*^9, { 3.528238969255*^9, 3.5282389763269997`*^9}, {3.528239023007*^9, 3.528239048013*^9}, 3.52823911231*^9, 3.528239164543*^9, 3.528239194606*^9, {3.528239252075*^9, 3.5282392831809998`*^9}, { 3.52823940687*^9, 3.5282394189639997`*^9}, 3.5282395864*^9, 3.528239637748*^9, 3.5282398137720003`*^9, 3.52823986467*^9, 3.528240161766*^9, 3.528240213925*^9, 3.5284486648356237`*^9, 3.528451285681624*^9, 3.528451340623624*^9, 3.528451928412624*^9, { 3.528452718234624*^9, 3.528452746119624*^9}, 3.528452821109624*^9, 3.528453833145624*^9, {3.528453886720624*^9, 3.528453925425624*^9}, 3.528454426112624*^9, 3.528454597471624*^9, {3.528454628234624*^9, 3.528454664013624*^9}, 3.528454751777624*^9, 3.528454821432624*^9, 3.528455024858624*^9, 3.528455190521624*^9, 3.528455363307624*^9, 3.528455394454624*^9, 3.528455450896624*^9, 3.528455534824624*^9, 3.528455596344624*^9, 3.528455737280624*^9, 3.528455909505624*^9, 3.528455954291624*^9, 3.5284561853276243`*^9, 3.528456460600624*^9, 3.5284566215326242`*^9, 3.528456681038624*^9, 3.528456941921624*^9, 3.5284571509526243`*^9, 3.528457196869624*^9, 3.528457908682624*^9, { 3.528457986996624*^9, 3.528458031336624*^9}, {3.528458144972624*^9, 3.528458171398624*^9}, 3.528458203102624*^9, 3.5284583021776237`*^9, 3.528458359680624*^9, 3.528458440541624*^9, 3.528459737398624*^9, 3.528459834345624*^9, {3.528459951866624*^9, 3.528459968656624*^9}, 3.528460277455624*^9, 3.528460322049624*^9, 3.5284603855186243`*^9, 3.528460544688624*^9, 3.528460741331624*^9, 3.5284638890020237`*^9, 3.528463972228024*^9, {3.5284640580748243`*^9, 3.528464071662424*^9}, 3.528464180800024*^9, 3.528464424394024*^9, 3.5284644945628242`*^9, { 3.5284646596888237`*^9, 3.528464675070424*^9}, 3.528464713040824*^9, { 3.528464818247224*^9, 3.528464831413624*^9}, 3.5284648909276237`*^9, 3.5284973446066*^9, 3.5284973818536*^9, {3.5284974169716*^9, 3.5284974349086*^9}, 3.5284974870056*^9, {3.528499409283*^9, 3.528499430642*^9}, 3.528499460928*^9, {3.5284994910439997`*^9, 3.528499510391*^9}, 3.528499586072*^9, {3.5284996165769997`*^9, 3.528499679847*^9}, 3.528499716182*^9, {3.5284997491619997`*^9, 3.528499811507*^9}, {3.52849984158*^9, 3.528499859718*^9}, 3.528499955578*^9, 3.528500029308*^9, 3.528500063957*^9, {3.52850012999*^9, 3.528500141784*^9}, 3.528500189244*^9, 3.528500452186*^9, 3.5285007897390003`*^9, 3.528500846258*^9, 3.548195236378377*^9, 3.5481954510191536`*^9, 3.548195629467867*^9, 3.548195670215139*^9, { 3.5481957246904345`*^9, 3.5481957484804764`*^9}, 3.548195837775033*^9, 3.548195998689316*^9, 3.5481960538042126`*^9, 3.5481964325104775`*^9, { 3.548196499933796*^9, 3.5481965262978425`*^9}, 3.548196682610117*^9, 3.5481967240593896`*^9, 3.5481969237553406`*^9, 3.548197233727885*^9, 3.548197287079979*^9, 3.5481973281392508`*^9, 3.548197519567187*^9, 3.548197567350071*^9, 3.5481976353661904`*^9, 3.5481976780166655`*^9, 3.548197790040462*^9, 3.548198452355225*^9, 3.548198522680149*^9, 3.552049048701871*^9}] }, Open ]] }, Open ]] }, WindowSize->{1264, 862}, WindowMargins->{{0, Automatic}, {Automatic, 0}}, ShowSelection->True, FrontEndVersion->"8.0 for Microsoft Windows (32-bit) (October 6, 2011)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[1257, 32, 793, 18, 75, "Title"], Cell[CellGroupData[{ Cell[2075, 54, 41280, 1021, 19, "Input", CellOpen->False], Cell[43358, 1077, 19912, 394, 580, "Output"] }, Open ]] }, Open ]] } ] *) (* End of internal cache information *) (* NotebookSignature Cx0QvpXUKESBQDwkPQWvUQkg *)