(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 10.2' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 158, 7] NotebookDataLength[ 15969, 365] NotebookOptionsPosition[ 15435, 342] NotebookOutlinePosition[ 15811, 358] CellTagsIndexPosition[ 15768, 355] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["Simple model for vapor deposition", "Title", CellChangeTimes->{{3.662998863033058*^9, 3.6629988755411224`*^9}}], Cell["\<\ Vito R. Vanin, Instituto de F\[IAcute]sica, Universidade de S\[ATilde]o Paulo \ - 14/03/2016\ \>", "Text", CellChangeTimes->{{3.6629988836818542`*^9, 3.6629989126562777`*^9}, { 3.6664366000105996`*^9, 3.6664366034320354`*^9}, {3.666955453670004*^9, 3.666955454433032*^9}}], Cell["\<\ Simulation of the model described in section 1.2, as pictured in figure 1.2: \ an atom sticks to any slot with equal probability. You can change the number of slots and the number of atoms that stick to the \ backing.\ \>", "Text", CellChangeTimes->{{3.6629989233674192`*^9, 3.6629989616516*^9}, { 3.6629996844178424`*^9, 3.6629997707305794`*^9}, {3.6654736026681213`*^9, 3.6654736494411793`*^9}, {3.6664365618496885`*^9, 3.6664365911916914`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"randomDeposition", "[", RowBox[{"numberOfAtoms_", ",", "numberOfSlots_", ",", "sortAgain_"}], "]"}], ":=", "\[IndentingNewLine]", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "occupation", ",", "graphics", ",", "atoms", ",", "backingPosition", ",", "filament", ",", "backing", ",", "source", ",", "cloud"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"backingPosition", "=", "28"}], ";", "\[IndentingNewLine]", RowBox[{"filament", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"Line", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"2", RowBox[{"(", RowBox[{"i", "-", "1"}], ")"}]}], ",", RowBox[{"Mod", "[", RowBox[{ RowBox[{"i", "-", "1"}], ",", "2"}], "]"}]}], " ", "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"2", "i"}], ",", RowBox[{"Mod", "[", RowBox[{"i", ",", "2"}], "]"}]}], "}"}]}], "}"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "numberOfSlots"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"backing", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"Disk", "[", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"2", "i"}], "-", "1"}], ",", "backingPosition"}], "}"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "numberOfSlots"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"source", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"Disk", "[", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"2", "i"}], "-", "1"}], ",", "3"}], "}"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "numberOfSlots"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"graphics", "=", RowBox[{"{", RowBox[{"Graphics", "[", RowBox[{"{", RowBox[{ "Black", ",", "filament", ",", "backing", ",", "Blue", ",", "source"}], "}"}], "]"}], "}"}]}], ";", "\[IndentingNewLine]", RowBox[{"atoms", "=", RowBox[{"{", RowBox[{"Disk", "[", RowBox[{"{", RowBox[{"1", ",", "backingPosition"}], "}"}], "]"}], "}"}]}], ";", "\[IndentingNewLine]", RowBox[{"occupation", "=", RowBox[{"ConstantArray", "[", RowBox[{"0", ",", "numberOfSlots"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Do", "[", RowBox[{ RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "index", "}"}], ",", RowBox[{ RowBox[{"index", "=", RowBox[{"RandomInteger", "[", RowBox[{"{", RowBox[{"1", ",", "numberOfSlots"}], "}"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"AppendTo", "[", RowBox[{"atoms", ",", RowBox[{"Disk", "[", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"2", "index"}], "-", "1"}], ",", RowBox[{"backingPosition", "-", RowBox[{"2", RowBox[{"(", " ", RowBox[{"++", RowBox[{"occupation", "[", RowBox[{"[", "index", "]"}], "]"}]}], ")"}]}]}]}], "}"}], "]"}]}], " ", "]"}], ";", "\[IndentingNewLine]", RowBox[{"cloud", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"Disk", "[", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"2", RowBox[{"RandomInteger", "[", RowBox[{"{", RowBox[{"1", ",", "numberOfSlots"}], "}"}], "]"}]}], "-", "1"}], ",", RowBox[{"RandomInteger", "[", RowBox[{"{", RowBox[{"6", ",", RowBox[{"backingPosition", "-", "2"}]}], "}"}], "]"}]}], "}"}], "]"}], ",", RowBox[{"{", "3", "}"}]}], "]"}]}], ";", " ", "\[IndentingNewLine]", RowBox[{"AppendTo", "[", RowBox[{"graphics", ",", RowBox[{"Graphics", "[", RowBox[{"{", RowBox[{ "Blue", ",", "atoms", ",", "cloud", ",", "source", ",", "Red", ",", RowBox[{"{", RowBox[{"Thick", ",", "filament"}], "}"}], ",", "Black", ",", "backing"}], "}"}], "]"}]}], " ", "]"}]}]}], " ", "]"}], ",", RowBox[{"{", "numberOfAtoms", " ", "}"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"AppendTo", "[", RowBox[{"graphics", ",", RowBox[{"Graphics", "[", RowBox[{"{", RowBox[{ "Blue", ",", "atoms", ",", "source", ",", "Black", ",", "filament", ",", "backing"}], "}"}], "]"}]}], " ", "]"}]}]}], " ", "\[IndentingNewLine]", "]"}]}]], "Input", CellChangeTimes->{{3.663511804660277*^9, 3.663511890575205*^9}, { 3.6635119329319053`*^9, 3.663512264388276*^9}, {3.6635124883664904`*^9, 3.663512516845157*^9}, {3.663512908817884*^9, 3.663512968234865*^9}, { 3.6635130098861732`*^9, 3.6635130140160646`*^9}, {3.6635130888309655`*^9, 3.663513089530398*^9}, {3.6635132051710176`*^9, 3.6635132140046062`*^9}, 3.663533589958585*^9, 3.663534089017527*^9, {3.6635343727415867`*^9, 3.6635343973123655`*^9}, {3.6635346159160028`*^9, 3.663534628672527*^9}, { 3.663619806325791*^9, 3.6636198409384136`*^9}, {3.663619932744353*^9, 3.663619936102023*^9}, {3.663619983609769*^9, 3.6636199955680904`*^9}, { 3.663620135633524*^9, 3.6636201729405212`*^9}, 3.6636203809649363`*^9, { 3.663620454115625*^9, 3.6636204545849996`*^9}, {3.663620486056515*^9, 3.6636204910590506`*^9}, {3.663620613216401*^9, 3.663620615436758*^9}, { 3.66362111316115*^9, 3.663621152537837*^9}, {3.6636212681626415`*^9, 3.663621314079515*^9}, {3.665345690552675*^9, 3.6653457087859025`*^9}, { 3.665345788246419*^9, 3.665345798702104*^9}, {3.6653458534056664`*^9, 3.6653458558856945`*^9}, {3.665345940927821*^9, 3.66534606995487*^9}, { 3.6653461677126703`*^9, 3.6653462866694584`*^9}, {3.665346333527311*^9, 3.665346350123124*^9}, {3.6653463893166227`*^9, 3.6653464193802023`*^9}, { 3.6653464669557314`*^9, 3.665346485371702*^9}, {3.665346591960011*^9, 3.665346648604642*^9}, {3.6653466835654526`*^9, 3.66534681632119*^9}, { 3.6653468663593626`*^9, 3.6653469828090487`*^9}, {3.665347013530648*^9, 3.665347014184351*^9}, {3.6653470483090577`*^9, 3.6653470791491213`*^9}, { 3.6653471228919964`*^9, 3.665347165327141*^9}, {3.6653472080744905`*^9, 3.6653472083218946`*^9}, {3.6653472456608686`*^9, 3.665347305900185*^9}, { 3.6653473549953566`*^9, 3.6653473636015296`*^9}, {3.665347429396418*^9, 3.6653474972608166`*^9}, {3.66534755851673*^9, 3.66534758920807*^9}, 3.6653478619404864`*^9, {3.665347980139166*^9, 3.6653480254655037`*^9}, { 3.6653488824613934`*^9, 3.665348892382992*^9}, {3.665349103465032*^9, 3.665349106270002*^9}, {3.6653491439545794`*^9, 3.665349169249432*^9}, { 3.665349381605921*^9, 3.665349406886191*^9}, 3.665349474193062*^9, { 3.6653495186997995`*^9, 3.6653495249252353`*^9}, {3.6653495659815083`*^9, 3.6653495872686577`*^9}, {3.6653496630126514`*^9, 3.665349684230172*^9}, { 3.665349729438831*^9, 3.6653497304242115`*^9}, {3.6653497634044495`*^9, 3.6653497636741037`*^9}, {3.665349797992099*^9, 3.6653498469669323`*^9}, 3.665349877310058*^9, {3.6653499590739784`*^9, 3.6653499595433383`*^9}, 3.6653864536585617`*^9, {3.6654731739156036`*^9, 3.6654731742841654`*^9}, { 3.66547330960297*^9, 3.6654733349930873`*^9}, {3.665473470331233*^9, 3.6654734713340063`*^9}, {3.666116201982028*^9, 3.666116208431012*^9}, { 3.66611625499833*^9, 3.666116343134243*^9}, {3.6661164273061485`*^9, 3.6661164277373915`*^9}, {3.666116469089556*^9, 3.6661164843133764`*^9}, { 3.6661166983504815`*^9, 3.6661167773092675`*^9}, {3.6661170402381773`*^9, 3.6661170406068926`*^9}, {3.666117139083453*^9, 3.66611714140551*^9}, { 3.666436027665261*^9, 3.666436042100885*^9}, {3.666436072197837*^9, 3.666436127677781*^9}, {3.6664361649118958`*^9, 3.666436172313786*^9}, { 3.666436205271964*^9, 3.6664362663807325`*^9}, {3.666436366773028*^9, 3.666436441190591*^9}, {3.666436474641635*^9, 3.6664364751265526`*^9}, { 3.6664365096002254`*^9, 3.66643651821942*^9}, {3.666436716711268*^9, 3.6664367340908585`*^9}, {3.6669553650144076`*^9, 3.666955368863793*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Manipulate", "[", " ", RowBox[{ RowBox[{"r", ";", RowBox[{"ListAnimate", "[", RowBox[{ RowBox[{"randomDeposition", "[", RowBox[{"numberOfAtoms", ",", "numberOfSlots", ",", "sortAgain"}], "]"}], ",", RowBox[{"AnimationRunning", "\[Rule]", "False"}], " ", ",", RowBox[{"AnimationRepetitions", "\[Rule]", "1"}]}], "]"}]}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"numberOfAtoms", ",", "28"}], "}"}], ",", "1", ",", "60", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"numberOfSlots", ",", "15"}], "}"}], ",", "6", ",", "20", ",", "1"}], "}"}], ",", "Delimiter", ",", RowBox[{"Row", "[", RowBox[{"{", RowBox[{"Button", "[", RowBox[{"\"\\"", ",", RowBox[{"{", RowBox[{"r", "=", RowBox[{"RandomReal", "[", "]"}]}], "}"}], ",", RowBox[{"Appearance", "\[Rule]", "\"\\""}], ",", RowBox[{"ImageSize", "\[Rule]", RowBox[{"{", RowBox[{"250", ",", "28"}], "}"}]}]}], "]"}], "}"}], "]"}], ",", RowBox[{"ControlPlacement", "\[Rule]", "Bottom"}]}], "]"}]], "Input", CellChangeTimes->{{3.663534659731124*^9, 3.6635347348371363`*^9}, { 3.663534773848199*^9, 3.6635347787521963`*^9}, {3.663535111573491*^9, 3.6635351119730673`*^9}, {3.6635351501115065`*^9, 3.6635351586334934`*^9}, 3.663619210206543*^9, {3.6636192841928177`*^9, 3.663619298727461*^9}, { 3.665386354771177*^9, 3.6653863894543467`*^9}, {3.6661165853484445`*^9, 3.6661166062170763`*^9}, {3.666116653687729*^9, 3.6661166553185787`*^9}, { 3.666116783114648*^9, 3.6661168379598107`*^9}, {3.66611693059737*^9, 3.6661169493273993`*^9}, {3.666117173201067*^9, 3.6661171981234303`*^9}, { 3.6661174728255863`*^9, 3.6661175367979803`*^9}, {3.6661175695451508`*^9, 3.666117703113015*^9}, {3.666117736801379*^9, 3.6661177449714556`*^9}, { 3.666436269550933*^9, 3.666436291051628*^9}, {3.670621240477212*^9, 3.670621250621981*^9}, {3.670621353951486*^9, 3.6706213578198576`*^9}}], Cell[BoxData[ TagBox[ StyleBox[ DynamicModuleBox[{$CellContext`numberOfAtoms$$ = 12, $CellContext`numberOfSlots$$ = 20, Typeset`show$$ = True, Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = "\"untitled\"", Typeset`specs$$ = {{{ Hold[$CellContext`numberOfAtoms$$], 28}, 1, 60, 1}, {{ Hold[$CellContext`numberOfSlots$$], 15}, 6, 20, 1}, { Hold[ Row[{ Button[ "Sort again", {$CellContext`r = RandomReal[]}, Appearance -> "Palette", ImageSize -> {250, 28}]}]], Manipulate`Dump`ThisIsNotAControl}}, Typeset`size$$ = { 531., {217., 226.}}, Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ = True, $CellContext`numberOfAtoms$5888$$ = 0, $CellContext`numberOfSlots$5889$$ = 0}, DynamicBox[Manipulate`ManipulateBoxes[ 1, StandardForm, "Variables" :> {$CellContext`numberOfAtoms$$ = 28, $CellContext`numberOfSlots$$ = 15}, "ControllerVariables" :> { Hold[$CellContext`numberOfAtoms$$, $CellContext`numberOfAtoms$5888$$, 0], Hold[$CellContext`numberOfSlots$$, $CellContext`numberOfSlots$5889$$, 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" :> ($CellContext`r; ListAnimate[ $CellContext`randomDeposition[$CellContext`numberOfAtoms$$, \ $CellContext`numberOfSlots$$, $CellContext`sortAgain], AnimationRunning -> False, AnimationRepetitions -> 1]), "Specifications" :> {{{$CellContext`numberOfAtoms$$, 28}, 1, 60, 1}, {{$CellContext`numberOfSlots$$, 15}, 6, 20, 1}, Delimiter, Row[{ Button[ "Sort again", {$CellContext`r = RandomReal[]}, Appearance -> "Palette", ImageSize -> {250, 28}]}]}, "Options" :> {ControlPlacement -> Bottom}, "DefaultOptions" :> {}], ImageSizeCache->{594., {321., 330.}}, SingleEvaluation->True], Deinitialization:>None, DynamicModuleValues:>{}, SynchronousInitialization->True, UndoTrackedVariables:>{Typeset`show$$, Typeset`bookmarkMode$$}, UnsavedVariables:>{Typeset`initDone$$}, UntrackedVariables:>{Typeset`size$$}], "Manipulate", Deployed->True, StripOnInput->False], Manipulate`InterpretManipulate[1]]], "Output", CellChangeTimes->{ 3.6661175388155575`*^9, {3.666117577590582*^9, 3.6661176673293734`*^9}, 3.666117706846857*^9, 3.666117746441207*^9, 3.666435922565488*^9, 3.6664363173829045`*^9, {3.666436413800867*^9, 3.666436443645157*^9}, 3.666436478429224*^9, 3.6664365217360277`*^9, 3.666436629353999*^9, 3.6664367413928194`*^9, 3.6669553796380806`*^9, 3.6706210937214212`*^9, 3.670621264743061*^9, 3.6706213671846*^9}] }, Open ]] }, Open ]] }, WindowSize->{1350, 889}, WindowMargins->{{-8, Automatic}, {Automatic, 0}}, Magnification:>1.3 Inherited, FrontEndVersion->"10.4 for Microsoft Windows (64-bit) (February 25, 2016)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[580, 22, 118, 1, 117, "Title"], Cell[701, 25, 288, 6, 39, "Text"], Cell[992, 33, 463, 8, 64, "Text"], Cell[1458, 43, 8813, 187, 390, "Input"], Cell[CellGroupData[{ Cell[10296, 234, 2123, 44, 140, "Input"], Cell[12422, 280, 2985, 58, 705, "Output"] }, Open ]] }, Open ]] } ] *)