(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 6.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 57317, 1564] NotebookOptionsPosition[ 53379, 1441] NotebookOutlinePosition[ 53740, 1457] CellTagsIndexPosition[ 53697, 1454] WindowFrame->Normal ContainsDynamic->False*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["Thermal Equilibrium", "Title"], Cell["\<\ APAM 1601 Columbia University\ \>", "Subsubtitle"], Cell[CellGroupData[{ Cell["Introduction", "Section"], Cell["\<\ In this notebook, we introduce the notion of a \"thermal equilibrium\" and \ investigate simple properties like mean energy and average particle density \ using a biased random walk model. \ \>", "Text"], Cell[CellGroupData[{ Cell["A simple atmosphere", "Subsection"], Cell[TextData[{ "Our starting point is a model for an ideal atmosphere. The gas within the \ atmosphere is confined, at the top, by a downward pointing gravity and, at \ the bottom, by the surface of the planet. The gas will be characterized by a \ \"temperature\", and the temperature will bias how likely the particle will \ take a random step upward (or downward). If the motion of a gas particle \ causes an increase in the overall energy of the atmosphere, then this motion \ must be restricted by a \"transition probability\" containing the Boltzman \ factor,", StyleBox[" Exp[\[Dash]\[CapitalDelta]U/T]", FontWeight->"Bold"], ", where \[CapitalDelta]", StyleBox["U ", FontSlant->"Italic"], "is the change of energy of the atmosphere." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Monte Carlo Simulation (Metropolis, et al., 1953)", "Subsection"], Cell[TextData[{ "We will use the famous \"Metropolis\" algorithm (Metropolis, Rosenbluth, \ Rosenbluth, Teller, and Teller, \"Equation of State Calculations by Fast \ Computing Machines,\" ", StyleBox["J. Chem. Phys.", FontSlant->"Italic"], " ", StyleBox["21", FontWeight->"Bold"], " (1953) pp. 1087-1092) to simulate the thermal fluctuations of our model \ atmosphere. A Monte Carlo simulation uses a random number generator to \ simulate the random fluctuations which occur in a large collection of \ particles." }], "Text"], Cell["\<\ The \"Metropolis\" algorithm is one of the is one of the most important and \ widely-used numerical methods in the field of statistical physics.(The story \ goes that the authors searched in vain for another physicist named \ Metropolis,so that the paper could have the symmetrical author list \ Metropolis,Metropolis,Rosenbluth,Rosenbluth,Teller and Teller! Metropolis \ (1915-1999) was an early pioneer in Monte Carlo methods and group leader at \ Los Alamos.His name appears first on the paper (cited above),and as a result \ most people refer to this method as the \"Metropolis\" Monte Carlo \ method.However,Marshall Rosenbluth (1927-2003) actually invented the \ algorithm.Marshall is perhaps one of the greatest pioneers in plasma physics \ and fusion energy science,and most plasma physicists refer to this algorithm \ as the Rosenbluth-Teller-Metropolis method.)\ \>", "Text"], Cell[GraphicsData["PICT", "\<\ 0000000009@0IP0A0_l<0?on0000B00004P000000000U01V0000000N00402P00 0000U01V0380000009@0IP0OP0200800PP0003:X00000@000000000000000000 00400000000000000000040000000000000000000000@0000000U01V00030000 00X02P000000U01V0000OWAYIVH0000000000000001QL71/000000001000IP2D 04P000180000037L004:E4U6AR0XC5YG:@00000000000000000000000000000H ool0000OD=Z]jTDJUD^SDQ_DfTd>WD bAb^Fc>XDnVE:WEf_E6Sen`F:`DJOE>UcJcCfVDF]fng`<]G>jGB3`b6`V;a>:gf Fb^DX]>HnFb>IcK9c:Lc^PCfeDBOIZNIeVg2/eVdF6aEVK B]BJ_9B7BFCHK7IG3HFjUJ3@icLjJhKKHGBiG>3@J9AJnGjolWThCU3727_XC2Me FEbOEZC8b34CSKeN_ejG[mNcf3h]kfekjoCf>KdoWkk: ]:fYci_<[SoZnfcA@8PL5@FPb8>JiR>^e ZJ^m4l>Z4gBf[I13GZjnkn:nVK[Y/[jeVJ[knATY4N?`oCk?Docc]50KN@A6l2:= 1Ha;[9bm8J`T;@bSLYb[2d9`dSDZ@i5BU@nZbBYNkBJ<`b[^]jW/Tb?5dfalYbIY K5k`Z=7LkARo;mb17koCG8do;;=/f:<>M2SE@kPReA:9@/_l/DO:D/bY;C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YTPT_8PP::]I0TI;4m 596DXkA6JX>:DV0PT?Y40k72n 4Y0i8`nc6a6I2^5Y5756cFn`4G96cF]feh9:`/a^mHVXNAg1^[jKJoJR89HTg0?7b`;7a0::W7HUJZddBkU0:h<]`GNoi 2@jbhn8`H[8B5990G11110`m4^I2I0dj6[8lX?8?4hg32<34cG1[1D E694/LkY;6b4ejN>0P;C2Dg;;g06FK1A9Y1ZC7093Nl4]33jbF/La/=jIY1ZnBn^ 8i8_8]4k33:VX@Phm8_N9ljTV<:E78FJLY:blfcFi5f;<^@[;M 7e22L0/8LP;^:`jhi2e=:f^[;`HJJ4^DWY>R3D[hd>f>2T/M;35>>X>8hNo>]d9Q :18g690_0lBY6I:;6/4hcVVD5XbbR 470c0dD/o4D/Nm6F=2@@ee5C5V`/`ZhNke;G1]4E?5>B3VMQ;@8e097c=]BI?3A3 20XhLT2U51@Rc24h73PIXQV@g?BWY3a5i2 iEAhm6TTo1>05HhM3R1RmM3=?]?LSL/M=O9`j31`2eBNlg>A1@MQ=[81:h3Vo[DH VO@j2Taj;=7:4YCF@aAQD7D^35?:Gk9/h?CM>VGoE>:o@ZIGA@2E:P8hj0/LjC0] ?hngAeEe;o0_0c74J59X^Doi=Lh/:hnZB3CnbS2BFM=g2cGFne6_Eg;k2e6bg046@:;B gYF;3e1e3XXQDBfPkeA73]?Y9c3[5fS1DSCLOGEJ>33@cG7bmg?WD:2EDBVa;[FU 8dBQ8_718_4@0:o80002L@00[lP0009a001`2^07X01`01 00400`0300@0000=00`0401V06H0^P2j02P0A00F455eJF=[E6U]IJXPHFiT8640 02P0BP095eA9ATHP:4aJEbTPI6ESKfe`LVEcLfmb02P0D0007f5bIB1^IFETIF@P M6lPLfEU87AXJG"], "Picture", ImageSize->{102, 148}, ImageMargins->{{0, 0}, {0, 0}}, ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ ButtonBox["Marshall Rosenbluth", BaseStyle->"Hyperlink", ButtonData:>{ URL["http://www.aps.org/praw/nicholso/00winner.cfm"], None}], " (1927-2003)" }], "Text"], Cell[TextData[{ "For our atmosphere model, we wish to simulate the random thermal agitation \ of a large collection particles interacting only with gravity (and the \ surface of the Earth.) Basically, each particle makes random steps upward or \ downward. However, these probabilities will no longer be \"unbiased\" (", StyleBox["i.e.", FontSlant->"Italic"], " 50-50 up or down.) Instead, for each potential step, we check the energy \ change involved and reject those steps that are thermally unlikely. Our \ simulation will start at an initial state and continue through a series of \ time steps towards some sort of \"thermal equilibrium\" or a \"relaxed \ state\". \nHow is this done?" }], "Text"], Cell["\<\ We will follow a set of specific rules. Step 1) Initialize the positions of the particles in the atmosphere. Step 2) Select a random particle. Make a potential random step (up or down). Step 3) Calculate the energy change to the entire system if the particle \ makes the step. Step 4a) If the energy change is negative, accept the step. Step 4b) If the energy change is positive, pick a random number between 0 and \ 1. If the random number is less than Exp[ - (energy change)/kT], then accept \ the step. Step 4c) Otherwise, reject the step and leave the position unchanged. Step 5) Go to Step 2 and repeat (for a very long time....)\ \>", "Text"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["The Potential Energy of an \"Ideal\" Atmosphere", "Section"], Cell["\<\ What is the potential energy of our ideal atmosphere? For simplicity, we will \ neglect all interactions between particles. Essentially, the particles feel \ only a gravitational force, and their dynamics are independent of other \ particles.\ \>", "Text"], Cell[TextData[{ "The total potential energy for ", StyleBox["N", FontSlant->"Italic"], " particles will be\n\t", Cell[BoxData[ FormBox[ SubscriptBox["U", "tot"], TraditionalForm]]], " = ", Cell[BoxData[ FormBox[ RowBox[{ UnderoverscriptBox["\[Sum]", RowBox[{"i", "=", "1"}], "N"], RowBox[{"\[Phi]", "(", SubscriptBox["x", "i"], ")"}]}], TraditionalForm]]], "\nwhere \[Phi](", Cell[BoxData[ FormBox[ SubscriptBox["x", "i"], TraditionalForm]]], ") = ", StyleBox["m g ", FontSlant->"Italic"], Cell[BoxData[ FormBox[ SubscriptBox["x", "i"], TraditionalForm]]], ", is the gravitational potential. Particles are at high potential energy \ when they are high in the sky and lowering potential energy when they are \ close to the ground. (The ground will be at ", StyleBox["x", FontSlant->"Italic"], " = 0.) In order to simulate the ground, we'll take \[Phi] = ", Cell[BoxData[ FormBox[ SuperscriptBox["10", "5"], TraditionalForm]]], " (a huge number) whenever ", StyleBox["x", FontSlant->"Italic"], " < 0." }], "Text"], Cell[TextData[{ "Computation of the change in the atmosphere's energy if a particle takes a \ random step is easy to specify. The change in energy is \[CapitalDelta]", StyleBox["U", FontSlant->"Italic"], "= ", StyleBox["m g ", FontSlant->"Italic"], "\[CapitalDelta]", StyleBox["x.", FontSlant->"Italic"], " If \[CapitalDelta]", StyleBox["U", FontSlant->"Italic"], " > 0, the upward step is accepted if a random number between 0 and 1 is \ less than ", StyleBox["Exp[-\[CapitalDelta]U / T]", FontWeight->"Bold"], "." }], "Text"], Cell[TextData[{ "We characterize thermal equilibrium with a temperature. The energy (per \ degree of freedom, one in our case) of an average particle is ", Cell[BoxData[ FormBox[ RowBox[{ SubscriptBox["k", "B"], "T"}], TraditionalForm]]], ", where ", Cell[BoxData[ FormBox[ SubscriptBox["k", "B"], TraditionalForm]]], "= 1.3807 \[Cross] ", Cell[BoxData[ FormBox[ SuperscriptBox["10", RowBox[{"-", "23"}]], TraditionalForm]]], " J/K is Boltzman's constant.We will take ", Cell[BoxData[ FormBox[ SubscriptBox["k", "B"], TraditionalForm]]], "=1, so temperature is in energy units. With ", StyleBox["m g", FontSlant->"Italic"], "= 1, the potential energy at ", StyleBox["x", FontSlant->"Italic"], " = 1 is equal to a thermal energy at ", StyleBox["T", FontSlant->"Italic"], " = 1." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["A Gravitationally-Biased Random Walker", "Section"], Cell[TextData[{ "We now have everything needed to define a \"gravitationally-biased\" random \ walker used to simulate particle confinement within a collisionless \ atmosphere. For simplicity, we set ", StyleBox["m", FontSlant->"Italic"], " = g", StyleBox[" = ", FontSlant->"Italic"], "1." }], "Text"], Cell[BoxData[ RowBox[{ RowBox[{"s", "[", "]"}], ":=", RowBox[{"\[CapitalDelta]x", " ", RowBox[{"RandomReal", "[", RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", "1"}], "}"}], "]"}]}]}]], "Input", CellLabel->"In[1]:="], Cell[BoxData[ RowBox[{ RowBox[{"step", "[", "x_", "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"trialStep", ",", "\[CapitalDelta]U"}], "}"}], ",", RowBox[{ RowBox[{"trialStep", "=", RowBox[{"s", "[", "]"}]}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"x", "+", "trialStep"}], "<", "0"}], ",", RowBox[{ RowBox[{"reject", "+=", "1"}], ";", RowBox[{"Return", "[", "x", "]"}]}]}], "]"}], ";", RowBox[{"\[CapitalDelta]U", "=", "trialStep"}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{"\[CapitalDelta]U", "<", "0"}], ",", RowBox[{"x", "+", "trialStep"}], ",", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"RandomReal", "[", "]"}], "<", SuperscriptBox["\[ExponentialE]", RowBox[{"-", FractionBox["\[CapitalDelta]U", "T"]}]]}], ",", RowBox[{"x", "+", "trialStep"}], ",", RowBox[{ RowBox[{"reject", "+=", "1"}], ";", "x"}]}], "]"}]}], "]"}]}]}], "]"}]}]], "Input", CellLabel->"In[2]:="], Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{"T", " ", "=", " ", "0.1"}], ";"}], " "}], "\[IndentingNewLine]", RowBox[{ RowBox[{"\[CapitalDelta]x", " ", "=", " ", "0.1"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"reject", " ", "=", " ", "0"}], ";"}], "\[IndentingNewLine]", RowBox[{"NestList", "[", RowBox[{"step", ",", " ", "1.0", ",", " ", "10"}], "]"}]}], "Input", CellLabel->"In[3]:="], Cell[BoxData["reject"], "Input", CellLabel->"In[7]:="], Cell[BoxData[{ RowBox[{ RowBox[{"reject", " ", "=", " ", "0"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"w1", " ", "=", " ", RowBox[{"NestList", "[", RowBox[{"step", ",", "1.0", ",", "50000"}], "]"}]}], ";", RowBox[{"Print", "[", RowBox[{"\"\\"", ",", " ", RowBox[{ RowBox[{"reject", "/", "50000"}], " ", "100.0", " ", "PerCent"}]}], "]"}], ";"}], ")"}], " ", "//", " ", "Timing"}]}], "Input", CellLabel->"In[8]:="], Cell[TextData[{ "We generally want to have the reject rate be between 30 and 40%. As \ \[CapitalDelta]", StyleBox["x", FontSlant->"Italic"], " increases, then the rejection rate increases. To decrease the rejection \ rate, the value for \[CapitalDelta]", StyleBox["x", FontSlant->"Italic"], " must be decreased. \[CapitalDelta]", StyleBox["x", FontSlant->"Italic"], " can be larger for larger ", StyleBox["T", FontSlant->"Italic"], "." }], "Text"], Cell[BoxData[ RowBox[{"ListPlot", "[", RowBox[{ RowBox[{"w1", "\[LeftDoubleBracket]", RowBox[{"Range", "[", RowBox[{"1", ",", "50000", ",", "100"}], "]"}], "\[RightDoubleBracket]"}], ",", RowBox[{"AxesLabel", "\[Rule]", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\""}], "}"}]}]}], "]"}]], "Input", CellLabel->"In[10]:="], Cell[BoxData[ RowBox[{ RowBox[{"walkAtmosphere", "[", "n_", "]"}], " ", ":=", " ", RowBox[{"NestList", "[", RowBox[{"step", ",", " ", "1.0", ",", " ", "n"}], "]"}], " ", RowBox[{"(*", " ", StyleBox[ RowBox[{ RowBox[{"initial", " ", "height", " ", "is", " ", "x"}], " ", "=", " ", "1.0"}], FontColor->RGBColor[0, 1, 0]], " ", "*)"}]}]], "Input", CellLabel->"In[11]:="], Cell["\<\ (Exercise for thought: does the initial condition affect the final thermal \ equilibrium?)\ \>", "Text"], Cell[CellGroupData[{ Cell["One thousand walkers\[Ellipsis]", "Subsection"], Cell["We take 250,000 steps\[Ellipsis]", "Text"], Cell[BoxData[{ RowBox[{ RowBox[{"nWalkers", " ", "=", " ", "1000"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"reject", " ", "=", " ", "0"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"walkList", " ", "=", " ", RowBox[{"Table", "[", RowBox[{ RowBox[{"walkAtmosphere", "[", "250", "]"}], ",", RowBox[{"{", "nWalkers", "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Print", "[", RowBox[{"\"\\"", ",", " ", RowBox[{ RowBox[{"reject", "/", "250000"}], " ", "100.0", " ", "PerCent"}]}], "]"}], ";"}]}], "Input", CellLabel->"In[12]:="], Cell[BoxData[ RowBox[{"walkList", " ", "//", " ", "Dimensions", " ", RowBox[{"(*", " ", StyleBox[ RowBox[{"1000", " ", "walks", " ", "500", " ", "steps", " ", "long"}], FontColor->RGBColor[0, 1, 0]], " ", "*)"}]}]], "Input", CellLabel->"In[16]:="], Cell[BoxData[ RowBox[{"ListAnimate", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"ListPlot", "[", RowBox[{ RowBox[{"walkList", "\[LeftDoubleBracket]", RowBox[{"All", ",", "n"}], "\[RightDoubleBracket]"}], ",", " ", RowBox[{"PlotRange", " ", "\[Rule]", " ", RowBox[{"{", RowBox[{"0", ",", " ", "1.0"}], "}"}]}], ",", " ", RowBox[{"AxesLabel", " ", "\[Rule]", " ", RowBox[{"{", RowBox[{"\"\\"", ",", " ", RowBox[{"\"\\"", " ", "<>", " ", RowBox[{"ToString", "[", RowBox[{"n", "-", "1"}], "]"}]}]}], "}"}]}]}], "]"}], ",", " ", RowBox[{"{", RowBox[{"n", ",", " ", "1", ",", " ", "251", ",", " ", "10"}], "}"}]}], "]"}], "]"}]], "Input", CellChangeTimes->{{3.445885234894099*^9, 3.445885246822703*^9}, { 3.445885334340488*^9, 3.4458853409485283`*^9}}, CellLabel->"In[39]:="], Cell[CellGroupData[{ Cell["Statistical Analysis", "Subsubsection"], Cell[TextData[{ StyleBox["Mathematica", FontSlant->"Italic"], " has useful tools for statistical analysis in the \"Add-On\" packages." }], "Text"], Cell[BoxData[ RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"Needs", "[", "\"\\"", "]"}], ";", RowBox[{"Needs", "[", "\"\\"", "]"}], ";", RowBox[{"Needs", "[", "\"\\"", "]"}]}], ")"}], ";"}]], "Input", CellChangeTimes->{3.445885358881974*^9}, CellLabel->"In[40]:="] }, Closed]], Cell[CellGroupData[{ Cell["BinCounts", "Subsubsection"], Cell[BoxData[ RowBox[{"BinCounts", "[", RowBox[{ RowBox[{"walkList", "\[LeftDoubleBracket]", RowBox[{"All", ",", "1"}], "\[RightDoubleBracket]"}], ",", " ", RowBox[{"{", RowBox[{"0.0", ",", " ", "1.5", ",", "0.05"}], "}"}]}], "]"}]], "Input", CellLabel->"In[20]:="], Cell[BoxData[ RowBox[{"BinCounts", "[", RowBox[{ RowBox[{"walkList", "\[LeftDoubleBracket]", RowBox[{"All", ",", "100"}], "\[RightDoubleBracket]"}], ",", " ", RowBox[{"{", RowBox[{"0.0", ",", " ", "1.5", ",", "0.05"}], "}"}]}], "]"}]], "Input", CellLabel->"In[21]:="], Cell[BoxData[ RowBox[{ RowBox[{"grid", " ", "=", " ", RowBox[{"Table", "[", RowBox[{ RowBox[{"BinCounts", "[", RowBox[{ RowBox[{"walkList", "\[LeftDoubleBracket]", RowBox[{"All", ",", "n"}], "\[RightDoubleBracket]"}], ",", " ", RowBox[{"{", RowBox[{"0.0", ",", " ", "1.5", ",", "0.05"}], "}"}]}], "]"}], ",", " ", RowBox[{"{", RowBox[{"n", ",", " ", "1", ",", " ", "251"}], "}"}]}], "]"}]}], ";"}]], "Input", CellLabel->"In[22]:="], Cell[BoxData[ RowBox[{"ListDensityPlot", "[", RowBox[{"grid", ",", RowBox[{"Mesh", "\[Rule]", "False"}], ",", RowBox[{"ColorFunction", "\[Rule]", "Hue"}], ",", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{"1", ",", "100"}], "}"}]}], ",", RowBox[{"FrameLabel", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"\"\\"", "<>", RowBox[{"ToString", "[", "nWalkers", "]"}], "<>", "\"\< Walkers\>\""}], ",", "\"\\""}], "}"}]}]}], "]"}]], "Input", CellLabel->"In[23]:="], Cell[BoxData[{ RowBox[{ RowBox[{"p1", "=", RowBox[{"ListPlot", "[", RowBox[{ RowBox[{"grid", "\[LeftDoubleBracket]", RowBox[{"15", ",", "All"}], "\[RightDoubleBracket]"}], ",", RowBox[{"PlotRange", "\[Rule]", "All"}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"RGBColor", "[", RowBox[{"1", ",", "0", ",", "0"}], "]"}], ",", RowBox[{"PointSize", "[", "0.01`", "]"}]}], "}"}]}], ",", RowBox[{"DisplayFunction", "\[Rule]", "Identity"}]}], "]"}]}], ";"}], "\n", RowBox[{ RowBox[{"p2", "=", RowBox[{"ListPlot", "[", RowBox[{ RowBox[{"grid", "\[LeftDoubleBracket]", RowBox[{"200", ",", "All"}], "\[RightDoubleBracket]"}], ",", RowBox[{"PlotRange", "\[Rule]", "All"}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"RGBColor", "[", RowBox[{"0", ",", "0", ",", "1"}], "]"}], ",", RowBox[{"PointSize", "[", "0.01`", "]"}]}], "}"}]}], ",", RowBox[{"DisplayFunction", "\[Rule]", "Identity"}]}], "]"}]}], ";"}], "\n", RowBox[{"Show", "[", RowBox[{"p1", ",", "p2", ",", RowBox[{"DisplayFunction", "\[Rule]", "$DisplayFunction"}], ",", RowBox[{"AxesOrigin", "\[Rule]", RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}]}], ",", RowBox[{"AxesLabel", "\[Rule]", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\""}], "}"}]}]}], "]"}]}], "Input", CellLabel->"In[24]:="] }, Closed]], Cell[CellGroupData[{ Cell["Histogram", "Subsubsection"], Cell[BoxData[ RowBox[{"p3", "=", RowBox[{"Histogram", "[", RowBox[{ RowBox[{"walkList", "\[LeftDoubleBracket]", RowBox[{"All", ",", "100"}], "\[RightDoubleBracket]"}], ",", RowBox[{"HistogramRange", "\[Rule]", RowBox[{"{", RowBox[{"0", ",", "1.5`"}], "}"}]}], ",", RowBox[{"HistogramCategories", "\[Rule]", "45"}], ",", RowBox[{"PlotLabel", "\[Rule]", RowBox[{"\"\\"", "<>", RowBox[{"ToString", "[", "100", "]"}]}]}], ",", RowBox[{"AxesLabel", "\[Rule]", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\<\>\""}], "}"}]}]}], "]"}]}]], "Input", CellLabel->"In[27]:="], Cell[BoxData[ RowBox[{ RowBox[{"histograms", " ", "=", " ", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"p1", " ", "=", " ", RowBox[{"Histogram", "[", RowBox[{ RowBox[{"walkList", "\[LeftDoubleBracket]", RowBox[{"All", ",", "n"}], "\[RightDoubleBracket]"}], ",", " ", RowBox[{"HistogramRange", " ", "\[Rule]", " ", RowBox[{"{", RowBox[{"0", ",", " ", "1.5"}], "}"}]}], ",", RowBox[{"HistogramCategories", " ", "\[Rule]", " ", "45"}], ",", RowBox[{"PlotLabel", " ", "\[Rule]", " ", RowBox[{"\"\\"", " ", "<>", " ", RowBox[{"ToString", "[", "n", "]"}]}]}], ",", " ", RowBox[{"AxesLabel", " ", "\[Rule]", " ", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\<\>\""}], "}"}]}], ",", " ", RowBox[{"DisplayFunction", " ", "\[Rule]", " ", "Identity"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Show", "[", RowBox[{"p1", ",", " ", RowBox[{"PlotRange", " ", "\[Rule]", " ", RowBox[{"{", RowBox[{"All", ",", RowBox[{"{", RowBox[{"0", ",", " ", "150"}], "}"}]}], "}"}]}], ",", RowBox[{"AxesOrigin", " ", "\[Rule]", " ", RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}]}], ",", " ", RowBox[{ "DisplayFunction", " ", "\[Rule]", " ", "$DisplayFunction"}]}], "]"}]}], ",", " ", RowBox[{"{", RowBox[{"n", ",", " ", "1", ",", " ", "251", ",", " ", "10"}], "}"}]}], "]"}]}], ";"}]], "Input", CellLabel->"In[28]:="], Cell[BoxData[ RowBox[{"ListAnimate", "[", "histograms", "]"}]], "Input", CellChangeTimes->{{3.445885392348763*^9, 3.445885400035577*^9}}, CellLabel->"In[41]:="] }, Closed]], Cell[CellGroupData[{ Cell["Mean and Standard Deviation", "Subsubsection"], Cell[BoxData[{ RowBox[{ RowBox[{"avgX", "=", RowBox[{"Mean", "/@", RowBox[{"Transpose", "[", "walkList", "]"}]}]}], ";"}], "\n", RowBox[{"avgPlot1", "=", RowBox[{"ListPlot", "[", RowBox[{"avgX", ",", RowBox[{"AxesLabel", "\[Rule]", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\<\>\""}], "}"}]}]}], "]"}]}]}], "Input",\ CellLabel->"In[29]:="], Cell[BoxData[{ RowBox[{ RowBox[{"varX", "=", RowBox[{"Variance", "/@", RowBox[{"Transpose", "[", "walkList", "]"}]}]}], ";"}], "\n", RowBox[{"ListPlot", "[", RowBox[{"varX", ",", RowBox[{"AxesLabel", "\[Rule]", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\""}], "}"}]}]}], "]"}]}], "Input",\ CellLabel->"In[31]:="], Cell[BoxData[{ RowBox[{ RowBox[{"stdDevX", "=", RowBox[{"StandardDeviation", "/@", RowBox[{"Transpose", "[", "walkList", "]"}]}]}], ";"}], "\n", RowBox[{"ListPlot", "[", RowBox[{"stdDevX", ",", RowBox[{"AxesLabel", "\[Rule]", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\""}], "}"}]}]}], "]"}]}], "Input", CellLabel->"In[33]:="], Cell[TextData[{ "The standard deviation indicates the magnitude of the \"fluctuations\" in \ ", StyleBox["x.", FontSlant->"Italic"] }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Entropy", "Subsubsection"], Cell[TextData[{ "Entropy is a measure of the disorder of the distribution of random walkers. \ For particles with negligible kinetic energy, entropy is defined simply as ", StyleBox["S", FontSlant->"Italic"], "(", StyleBox["t", FontSlant->"Italic"], ") = \[Dash] ", Cell[BoxData[ FormBox[ RowBox[{"\[Integral]", RowBox[{ RowBox[{"P", "(", RowBox[{"x", ",", "t"}], ")"}], " ", RowBox[{"Log", "[", RowBox[{"P", "(", RowBox[{"x", ",", "t"}], ")"}], "]"}], RowBox[{"\[DifferentialD]", "x"}]}]}], TraditionalForm]]], ", where ", StyleBox["P", FontSlant->"Italic"], "(", StyleBox["x,t", FontSlant->"Italic"], ") is the probability of a walker being at cell ", StyleBox["x", FontSlant->"Italic"], " at time ", StyleBox["t", FontSlant->"Italic"], ". Initially, all of the walkers are located at ", StyleBox["x", FontSlant->"Italic"], " = 1 with probability of 100%, The entropy is zero. As the probability \ become more uniform in ", StyleBox["x", FontSlant->"Italic"], ", then the entropy will increase. As the particles accelerate to the \ ground, the entropy ", StyleBox["appears", FontSlant->"Italic"], " to increase and then", " decrease. In a ", StyleBox["non-equilibrium ", FontSlant->"Italic"], "transient state of our simulation, our definition is not very useful.", " Recall, our estimate of the probability within a gird-box is the ratio, ", StyleBox["P", FontSlant->"Italic"], "(", StyleBox["x", FontSlant->"Italic"], ",", StyleBox["t", FontSlant->"Italic"], ") \[TildeTilde] (# of walkers within grid box ", StyleBox["x", FontSlant->"Italic"], ")/(total number of walkers)." }], "Text"], Cell[BoxData[ RowBox[{"Dimensions", "[", "grid", "]"}]], "Input", CellLabel->"In[35]:="], Cell[BoxData[ RowBox[{ RowBox[{"entropyGrid", " ", "=", " ", RowBox[{"Table", "[", RowBox[{ RowBox[{"Plus", " ", "@@", " ", RowBox[{"(", RowBox[{ RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"#", " ", ">", " ", "1"}], ",", RowBox[{"-", RowBox[{"N", "[", RowBox[{ RowBox[{"(", RowBox[{"#", "/", "nWalkers"}], ")"}], " ", RowBox[{"Log", "[", RowBox[{"(", RowBox[{"#", "/", "nWalkers"}], ")"}], "]"}]}], "]"}]}], ",", "0"}], "]"}], "&"}], " ", "/@", " ", RowBox[{"grid", "\[LeftDoubleBracket]", RowBox[{"t", ",", "All"}], "\[RightDoubleBracket]"}]}], ")"}]}], ",", " ", RowBox[{"{", RowBox[{"t", ",", " ", "1", ",", " ", "250"}], "}"}]}], "]"}]}], ";"}]], "Input", CellLabel->"In[36]:="], Cell[BoxData[ RowBox[{"ListPlot", "[", RowBox[{"entropyGrid", ",", RowBox[{"AxesLabel", "\[Rule]", RowBox[{"{", RowBox[{"\"\\"", ",", RowBox[{"\"\\"", "<>", RowBox[{"ToString", "[", "nWalkers", "]"}], "<>", "\"\< Walkers\>\""}]}], "}"}]}], ",", RowBox[{"Joined", "\[Rule]", "True"}], ",", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{"0", ",", "4"}], "}"}]}]}], "]"}]], "Input", CellLabel->"In[37]:="] }, Closed]] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["Potential Energy", "Section"], Cell[TextData[{ "The average potential energy of the particles within our model atmosphere \ shows relaxation towards lower energy as thermal equilibrium is approached. \ For our simple model, \[LeftAngleBracket]", StyleBox["U", FontSlant->"Italic"], "\[RightAngleBracket] ", StyleBox["=", FontVariations->{"CompatibilityType"->0}], " ", Cell[BoxData[ FormBox[ RowBox[{ UnderoverscriptBox["\[Sum]", RowBox[{"i", "=", "1"}], "nWalkers"], RowBox[{"\[Phi]", "(", SubscriptBox["x", "i"], ")"}]}], TraditionalForm]]], " = ", StyleBox["m g ", FontSlant->"Italic"], "\[LeftAngleBracket]", StyleBox["x", FontSlant->"Italic"], "\[RightAngleBracket]." }], "Text"], Cell[BoxData[{ RowBox[{ RowBox[{"avgU", "=", "avgX"}], ";"}], "\n", RowBox[{"ListPlot", "[", RowBox[{"avgU", ",", RowBox[{"AxesLabel", "\[Rule]", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\""}], "}"}]}]}], "]"}]}], "Input", CellLabel->"In[42]:="], Cell["\<\ In thermal equilibrium, the average potential energy should equal the \ temperature\[Ellipsis]\ \>", "Text"], Cell[BoxData[ RowBox[{"equilU", " ", "=", " ", RowBox[{"Mean", "[", RowBox[{"avgX", "\[LeftDoubleBracket]", RowBox[{"Range", "[", RowBox[{"200", ",", "250"}], "]"}], "\[RightDoubleBracket]"}], "]"}]}]], "Input", CellLabel->"In[44]:="], Cell[TextData[{ "Using the Boltzman distribution for the probability function, the \ equilibrium value of ", StyleBox["x", FontSlant->"Italic"], " is proportional to ", Cell[BoxData[ FormBox[ RowBox[{"\[Integral]", RowBox[{"x", " ", RowBox[{"Exp", "[", RowBox[{ RowBox[{"-", RowBox[{"U", "(", "x", ")"}]}], "/", "T"}], "]"}], RowBox[{"\[DifferentialD]", "x"}]}]}], TraditionalForm]]], "." }], "Text"], Cell[BoxData[ RowBox[{ RowBox[{"Integrate", "[", RowBox[{ RowBox[{"x", " ", RowBox[{"Exp", "[", RowBox[{ RowBox[{"-", "x"}], "/", "T"}], "]"}]}], ",", " ", RowBox[{"{", RowBox[{"x", ",", " ", "0", ",", " ", "Infinity"}], "}"}]}], "]"}], "/", RowBox[{"Integrate", "[", RowBox[{ RowBox[{"Exp", "[", RowBox[{ RowBox[{"-", "x"}], "/", "T"}], "]"}], ",", " ", RowBox[{"{", RowBox[{"x", ",", " ", "0", ",", " ", "Infinity"}], "}"}]}], "]"}]}]], "Input", CellLabel->"In[45]:="], Cell[TextData[{ "The mean fluctuation in the potential energy in time is ", Cell[BoxData[ FormBox[ SqrtBox[ RowBox[{"\[LeftAngleBracket]", SuperscriptBox[ RowBox[{"(", RowBox[{ SubscriptBox["U", "n"], " ", "-", " ", SubscriptBox["U", "avg"]}], ")"}], "2"], "\[RightAngleBracket]"}]], TraditionalForm]]], ", or" }], "Text"], Cell[BoxData[ RowBox[{"avg\[Delta]U", " ", "=", " ", RowBox[{"Sqrt", "[", RowBox[{"Mean", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{ RowBox[{ "avgU", "\[LeftDoubleBracket]", "n", "\[RightDoubleBracket]"}], " ", "-", " ", "equilU"}], ")"}], "^", "2"}], ",", " ", RowBox[{"{", RowBox[{"n", ",", " ", "200", ",", " ", "250"}], "}"}]}], "]"}], "]"}], "]"}]}]], "Input", CellLabel->"In[46]:="], Cell[TextData[{ "And this gives a fluctuation about 1/40 the size of \[LeftAngleBracket]", StyleBox["U", FontSlant->"Italic"], "\[RightAngleBracket] (about \[PlusMinus] 2.5 %). " }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Convergence in Monte Carlo Calculations", "Section"], Cell[TextData[{ "Perhaps the more important of the practical questions concerning Monte \ Carlo calculations is one of convergence. How many particles are required to \ estimate accurate averages? The answer to this question can be found in what \ we already know about random walks. The mean square distance from the average \ increases linearly with the number of steps in a random process. If we are \ trying to estimate the ", StyleBox["true", FontSlant->"Italic"], " equilibrium potential energy (", Cell[BoxData[ FormBox[ SubscriptBox["U", "true"], TraditionalForm]]], ")", " of a system by averaging over ", StyleBox["N", FontSlant->"Italic"], " steps, then the calculated average would be \[LeftAngleBracket]", StyleBox["U", FontSlant->"Italic"], "\[RightAngleBracket] ~ ( ", StyleBox["N ", FontSlant->"Italic"], Cell[BoxData[ FormBox[ SubscriptBox["U", "true"], TraditionalForm]]], StyleBox[" + ", FontSlant->"Italic"], Cell[BoxData[ FormBox[ SqrtBox[ RowBox[{"N", " ", RowBox[{"\[LeftAngleBracket]", SuperscriptBox[ StyleBox[ RowBox[{"\[Delta]", StyleBox["U", FontSlant->"Italic"]}]], "2"], "\[RightAngleBracket]"}]}]], TraditionalForm]]], ")", " /", StyleBox["N.", FontSlant->"Italic"], " The term ", Cell[BoxData[ FormBox[ SqrtBox[ RowBox[{"N", " ", RowBox[{"\[LeftAngleBracket]", SuperscriptBox[ StyleBox[ RowBox[{"\[Delta]", StyleBox["U", FontSlant->"Italic"]}]], "2"], "\[RightAngleBracket]"}]}]], TraditionalForm]]], " ~ \[CapitalDelta]", StyleBox["U", FontSlant->"Italic"], " is the deviation of the potential energy due to random diffusion. The \ value of the average is \[LeftAngleBracket]", StyleBox["U", FontSlant->"Italic"], "\[RightAngleBracket] ~ ", Cell[BoxData[ FormBox[ SubscriptBox["U", "true"], TraditionalForm]]], StyleBox[" + ", FontSlant->"Italic"], Cell[BoxData[ FormBox[ SqrtBox[ RowBox[{ RowBox[{"\[LeftAngleBracket]", SuperscriptBox[ StyleBox[ RowBox[{"\[Delta]", StyleBox["U", FontSlant->"Italic"]}]], "2"], "\[RightAngleBracket]"}], "/", "N"}]], TraditionalForm]]], ". As ", StyleBox["N", FontSlant->"Italic"], " \[Rule] \[Infinity], the difference (", StyleBox["i.e.", FontSlant->"Italic"], " the error) between the Monte Carlo estimate of the error and the ", StyleBox["true", FontSlant->"Italic"], " equilibrium potential energy decreases as 1/", Cell[BoxData[ FormBox[ SqrtBox["N"], TraditionalForm]]], ". " }], "Text"], Cell["\<\ For our first calculation, we had 1000 walkers.If we had only 62 walkers (16 \ times fewer), the error in our estimate of \[LeftAngleBracket]U\ \[RightAngleBracket] will be four (4) times larger.\ \>", "Text"], Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{"T", " ", "=", " ", "0.1"}], ";"}], " "}], "\[IndentingNewLine]", RowBox[{ RowBox[{"\[CapitalDelta]x", " ", "=", " ", "0.1"}], ";"}]}], "Input", CellLabel->"In[47]:="], Cell[BoxData[{ RowBox[{ RowBox[{"nWalkers", " ", "=", " ", "62"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"reject", " ", "=", " ", "0"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"walkList", " ", "=", " ", RowBox[{"Table", "[", RowBox[{ RowBox[{"walkAtmosphere", "[", "250", "]"}], ",", RowBox[{"{", "nWalkers", "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Print", "[", RowBox[{"\"\\"", ",", " ", RowBox[{ RowBox[{"reject", "/", RowBox[{"(", RowBox[{"250", " ", "62"}], ")"}]}], " ", "100.0", " ", "PerCent"}]}], "]"}], ";"}]}], "Input", CellLabel->"In[49]:="], Cell[BoxData[{ RowBox[{ RowBox[{"avgX", "=", RowBox[{"Mean", "/@", RowBox[{"Transpose", "[", "walkList", "]"}]}]}], ";"}], "\n", RowBox[{"avgPlot2", "=", RowBox[{"ListPlot", "[", RowBox[{"avgX", ",", RowBox[{"AxesLabel", "\[Rule]", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\<\>\""}], "}"}]}], ",", RowBox[{"PlotRange", "\[Rule]", "All"}], ",", RowBox[{"AxesOrigin", "\[Rule]", RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}]}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", RowBox[{"RGBColor", "[", RowBox[{"1", ",", "0", ",", "0"}], "]"}], "}"}]}]}], "]"}]}]}], "Input",\ CellLabel->"In[53]:="], Cell[BoxData[ RowBox[{"equilU", " ", "=", " ", RowBox[{"Mean", "[", RowBox[{"avgX", "\[LeftDoubleBracket]", RowBox[{"Range", "[", RowBox[{"200", ",", "250"}], "]"}], "\[RightDoubleBracket]"}], "]"}]}]], "Input", CellLabel->"In[55]:="], Cell[BoxData[ RowBox[{ RowBox[{"avgU", " ", "=", " ", "avgX"}], ";"}]], "Input", CellLabel->"In[56]:="], Cell[BoxData[ RowBox[{"avg\[Delta]U", " ", "=", " ", RowBox[{"Sqrt", "[", RowBox[{"Mean", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{ RowBox[{ "avgU", "\[LeftDoubleBracket]", "n", "\[RightDoubleBracket]"}], " ", "-", " ", "equilU"}], ")"}], "^", "2"}], ",", " ", RowBox[{"{", RowBox[{"n", ",", " ", "200", ",", " ", "250"}], "}"}]}], "]"}], "]"}], "]"}]}]], "Input", CellLabel->"In[57]:="], Cell[TextData[{ "This uncertainty (\[PlusMinus] 8.3 %) is about 4 times larger than with \ 1000 ideal atmospheric particles, as expected. The reality of Monte Carlo \ calculations is the need for a", StyleBox[" large number of realizations", FontSlant->"Italic"], " with which to find averages!" }], "Text"], Cell[BoxData[ RowBox[{"Show", "[", RowBox[{"avgPlot1", ",", "avgPlot2", ",", RowBox[{"PlotLabel", "\[Rule]", "\"\<62 vs 1000 Walkers\>\""}]}], "]"}]], "Input", CellLabel->"In[58]:="] }, Closed]], Cell[CellGroupData[{ Cell["Summary", "Section"], Cell[TextData[{ "The Rosenbluth-Teller-Metropolis algorithm is a general prescription for \ finding properties of systems at thermal equilibrium. Particles, or \ components of the larger system, are allowed to make random (thermal motions) \ and these motions are tested using a Boltzman probability distribution \ function. If the motion causes the system energy to increase, then the motion \ is rejected if the change in energy is too large. In this way, the \ \"simulated\" random motions of the system eventually relax to a state of \ thermal equilibrium. The properties of the thermal equilibrium can be \ estimated by taking averages of the simulation. The accuracy of the averages \ (as compared to the \"true\" equilibrium properties) improves as 1/", Cell[BoxData[ FormBox[ SqrtBox["N"], TraditionalForm]]], "when the number of particles (and configuration steps) increase. " }], "Text"] }, Closed]] }, Open ]] }, WindowToolbars->{}, WindowSize->{746, 777}, WindowMargins->{{432, Automatic}, {Automatic, 23}}, FrontEndVersion->"6.0 for Mac OS X x86 (32-bit) (May 21, 2008)", StyleDefinitions->"TutorialBook.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[590, 23, 36, 0, 51, "Title"], Cell[629, 25, 60, 3, 41, "Subsubtitle"], Cell[CellGroupData[{ Cell[714, 32, 31, 0, 86, "Section"], Cell[748, 34, 214, 4, 41, "Text"], Cell[CellGroupData[{ Cell[987, 42, 41, 0, 34, "Subsection"], Cell[1031, 44, 762, 15, 114, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[1830, 64, 71, 0, 34, "Subsection"], Cell[1904, 66, 535, 13, 77, "Text"], Cell[2442, 81, 895, 13, 149, "Text"], Cell[3340, 96, 17978, 278, 156, "Picture"], Cell[21321, 376, 185, 6, 23, "Text"], Cell[21509, 384, 706, 12, 125, "Text"], Cell[22218, 398, 658, 12, 251, "Text"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[22925, 416, 66, 0, 54, "Section"], Cell[22994, 418, 266, 5, 41, "Text"], Cell[23263, 425, 1083, 39, 125, "Text"], Cell[24349, 466, 548, 19, 60, "Text"], Cell[24900, 487, 839, 30, 60, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[25776, 522, 57, 0, 54, "Section"], Cell[25836, 524, 310, 10, 41, "Text"], Cell[26149, 536, 245, 8, 24, "Input"], Cell[26397, 546, 1136, 33, 130, "Input"], Cell[27536, 581, 415, 11, 78, "Input"], Cell[27954, 594, 55, 1, 26, "Input"], Cell[28012, 597, 524, 14, 81, "Input"], Cell[28539, 613, 464, 16, 42, "Text"], Cell[29006, 631, 367, 10, 26, "Input"], Cell[29376, 643, 404, 11, 46, "Input"], Cell[29783, 656, 114, 3, 23, "Text"], Cell[CellGroupData[{ Cell[29922, 663, 53, 0, 34, "Subsection"], Cell[29978, 665, 48, 0, 24, "Text"], Cell[30029, 667, 636, 18, 79, "Input"], Cell[30668, 687, 264, 6, 26, "Input"], Cell[30935, 695, 920, 22, 80, "Input"], Cell[CellGroupData[{ Cell[31880, 721, 45, 0, 33, "Subsubsection"], Cell[31928, 723, 150, 4, 23, "Text"], Cell[32081, 729, 324, 9, 26, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[32442, 743, 34, 0, 33, "Subsubsection"], Cell[32479, 745, 287, 7, 26, "Input"], Cell[32769, 754, 289, 7, 26, "Input"], Cell[33061, 763, 511, 15, 44, "Input"], Cell[33575, 780, 558, 14, 79, "Input"], Cell[34136, 796, 1517, 41, 153, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[35690, 842, 34, 0, 33, "Subsubsection"], Cell[35727, 844, 652, 16, 63, "Input"], Cell[36382, 862, 1670, 40, 135, "Input"], Cell[38055, 904, 163, 3, 26, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[38255, 912, 52, 0, 33, "Subsubsection"], Cell[38310, 914, 383, 12, 45, "Input"], Cell[38696, 928, 356, 11, 45, "Input"], Cell[39055, 941, 375, 11, 45, "Input"], Cell[39433, 954, 147, 5, 23, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[39617, 964, 32, 0, 33, "Subsubsection"], Cell[39652, 966, 1703, 60, 138, "Text"], Cell[41358, 1028, 90, 2, 26, "Input"], Cell[41451, 1032, 927, 27, 97, "Input"], Cell[42381, 1061, 490, 13, 80, "Input"] }, Closed]] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[42932, 1081, 35, 0, 54, "Section"], Cell[42970, 1083, 698, 24, 47, "Text"], Cell[43671, 1109, 297, 9, 43, "Input"], Cell[43971, 1120, 118, 3, 24, "Text"], Cell[44092, 1125, 258, 7, 26, "Input"], Cell[44353, 1134, 452, 16, 47, "Text"], Cell[44808, 1152, 554, 19, 45, "Input"], Cell[45365, 1173, 375, 13, 35, "Text"], Cell[45743, 1188, 502, 15, 26, "Input"], Cell[46248, 1205, 195, 5, 24, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[46480, 1215, 58, 0, 54, "Section"], Cell[46541, 1217, 2625, 93, 180, "Text"], Cell[49169, 1312, 219, 4, 42, "Text"], Cell[49391, 1318, 219, 6, 42, "Input"], Cell[49613, 1326, 687, 20, 79, "Input"], Cell[50303, 1348, 689, 20, 80, "Input"], Cell[50995, 1370, 258, 7, 26, "Input"], Cell[51256, 1379, 107, 3, 24, "Input"], Cell[51366, 1384, 502, 15, 26, "Input"], Cell[51871, 1401, 312, 7, 42, "Text"], Cell[52186, 1410, 194, 5, 24, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[52417, 1420, 26, 0, 54, "Section"], Cell[52446, 1422, 905, 15, 135, "Text"] }, Closed]] }, Open ]] } ] *) (* End of internal cache information *)