程序代写代做代考 cache x86 (* Content-type: application/vnd.wolfram.mathematica *)
(* Content-type: application/vnd.wolfram.mathematica *)
(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)
(* CreatedBy=’Mathematica 12.0′ *)
(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[ 158, 7]
NotebookDataLength[ 12203, 297]
NotebookOptionsPosition[ 11058, 270]
NotebookOutlinePosition[ 11398, 285]
CellTagsIndexPosition[ 11355, 282]
WindowFrame->Normal*)
(* Beginning of Notebook Content *)
Notebook[{
Cell[CellGroupData[{
Cell[“Lab Week 7”, “Title”,
CellChangeTimes->{{3.822706098827648*^9, 3.822706106430932*^9}, {
3.8239468886690893`*^9,
3.8239468929886217`*^9}},ExpressionUUID->”ca359983-38f4-4f7a-a685-
99c62a097f1e”],
Cell[TextData[StyleBox[“Homework 6”, “Subtitle”]], “Text”,
CellChangeTimes->{{3.822706112205819*^9, 3.822706119791602*^9}, {
3.823946894896603*^9,
3.823946895320945*^9}},ExpressionUUID->”03ac98e9-e199-4728-86d8-
cd8df5a8f94c”],
Cell[CellGroupData[{
Cell[“Problem 1”, “Section”,
CellChangeTimes->{{3.822706126159574*^9,
3.82270612883962*^9}},ExpressionUUID->”bf54f8f1-71f9-44e7-a0bd-
b4a3bf37f7f8″],
Cell[TextData[StyleBox[“a) Simulate the diffusion of N particles in 2
dimensions with periodic boundary conditions. Visualize the system
trajectory by using animate and creating a histogram for the x-direction.
Devise a method for determining when the system is a equilibrium. How does
noise relate to the diffusion constant? Additionally, leave a comment for
all functions below.”, “Subsection”]], “Text”,
CellChangeTimes->{{3.822706134633354*^9, 3.822706154581642*^9},
3.822739059837325*^9, {3.823816938416851*^9, 3.823816971327691*^9}, {
3.8239469840784807`*^9, 3.823947126784843*^9}, {3.823947186869759*^9,
3.82394720170963*^9}, {3.823947463182878*^9,
3.823947496590643*^9}},ExpressionUUID->”2658a4a2-7330-48b1-846e-
9f4cae75174a”],
Cell[BoxData[“”], “Input”,
CellChangeTimes->{{3.8239470130143547`*^9,
3.823947016525483*^9}},ExpressionUUID->”65a76d71-c53e-4565-9a8a-
0a1f74339d7e”],
Cell[BoxData[{
RowBox[{
RowBox[{
RowBox[{“initialAgents”, “[“, “n_”, “]”}], “:=”,
RowBox[{“RandomReal”, “[“,
RowBox[{
RowBox[{“NormalDistribution”, “[“,
RowBox[{“0”, “,”, “0.05”}], “]”}], “,”,
RowBox[{“{“,
RowBox[{“n”, “,”, “2”}], “}”}]}], “]”}]}], “;”}], “
”,
RowBox[{
RowBox[{
RowBox[{“visualize”, “[“, “agents_”, “]”}], “:=”, “
”,
RowBox[{“Graphics”, “[“,
RowBox[{
RowBox[{“{“,
RowBox[{
RowBox[{“AbsolutePointSize”, “[“, “10”, “]”}], “,”,
RowBox[{“Hue”, “[“,
RowBox[{“0.67”, “,”, “0.6”, “,”, “0.6”}], “]”}], “,”,
RowBox[{“Point”, “[“, “agents”, “]”}]}], “}”}], “,”, “
”,
RowBox[{“ImageSize”, “->”,
RowBox[{“{“,
RowBox[{“400”, “,”, “400”}], “}”}]}], “,”, “
”,
RowBox[{“AspectRatio”, “->”, “Automatic”}], “,”, “
”,
RowBox[{“Frame”, “->”, “True”}], “,”, “
”,
RowBox[{“FrameTicks”, “->”, “False”}], “,”, “
”,
RowBox[{“Axes”, “->”, “False”}], “,”, “
”,
RowBox[{“PlotRange”, “->”,
RowBox[{“{“,
RowBox[{
RowBox[{“{“,
RowBox[{
RowBox[{“-“, “1”}], “,”, “1”}], “}”}], “,”,
RowBox[{“{“,
RowBox[{
RowBox[{“-“, “1”}], “,”, “1”}], “}”}]}], “}”}]}]}], “
”, “]”}]}],
“;”}], “
”,
RowBox[{
RowBox[{
RowBox[{
RowBox[{“updateAgents”, “[“,
RowBox[{“agents_”, “,”, “noise_”}], “]”}], “:=”,
RowBox[{“Module”, “[“,
RowBox[{
RowBox[{“{“, “i”, “}”}], “,”,
RowBox[{“If”, “[“,
RowBox[{
RowBox[{“noise”, “>”, “0.”}], “,”,
RowBox[{“Table”, “[“,
RowBox[{
RowBox[{“Clip”, “[“,
RowBox[{
RowBox[{
RowBox[{“agents”, “[“,
RowBox[{“[“, “i”, “]”}], “]”}], “+”,
RowBox[{“RandomReal”, “[“,
RowBox[{
RowBox[{“NormalDistribution”, “[“,
RowBox[{“0”, “,”, “noise”}], “]”}], “,”, “2”}], “]”}]}], “,”,
RowBox[{“{“,
RowBox[{
RowBox[{“-“, “1”}], “,”, “1”}], “}”}]}], “]”}], “,”,
RowBox[{“{“,
RowBox[{“i”, “,”,
RowBox[{“Length”, “[“, “agents”, “]”}]}], “}”}]}], “]”}], “,”,
“
”, “agents”}], “]”}]}], “
”, “]”}]}], “;”}],
“[IndentingNewLine]”,
RowBox[{“(*”, ” “, “Parameters”, ” “, “*)”}]}], “[IndentingNewLine]”,
RowBox[{
RowBox[{“numSteps”, ” “, “=”, ” “, “100000”}],
“;”}], “[IndentingNewLine]”,
RowBox[{
RowBox[{“numParticles”, ” “, “=”, ” “, “100”}],
“;”}], “[IndentingNewLine]”,
RowBox[{
RowBox[{“DD”, ” “, “=”, ” “, “0.01”}], “;”}], “[IndentingNewLine]”,
RowBox[{
RowBox[{“myAgents”, ” “, “=”, ” “,
RowBox[{“ConstantArray”, “[“,
RowBox[{“0”, “,”, “numSteps”}], “]”}]}], “;”}], “[IndentingNewLine]”,
RowBox[{
RowBox[{
RowBox[{
RowBox[{“myAgents”, “[“,
RowBox[{“[“, “0”, “]”}], “]”}], ” “, “=”, ” “,
RowBox[{“initialAgents”, “[“, “numParticles”, “]”}]}], “;”}],
“[IndentingNewLine]”}], “[IndentingNewLine]”,
RowBox[{“For”, “[“,
RowBox[{
RowBox[{“t”, “=”, “1”}], “,”, ” “,
RowBox[{“t”, “<", "numSteps"}], ",", " ",
RowBox[{"t", "++"}], ",", "[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{"myAgents", "[",
RowBox[{"[", "t", "]"}], "]"}], " ", "=", " ",
RowBox[{"updateAgents", "[",
RowBox[{
RowBox[{"myAgents", "[",
RowBox[{"[",
RowBox[{"t", " ", "-", " ", "1"}], "]"}], "]"}], ",", " ", "DD"}],
"]"}]}], ";"}]}], "[IndentingNewLine]", "]"}]}], "Input",
CellChangeTimes->{{3.823823258491226*^9, 3.82382325961141*^9}, {
3.823824810418147*^9, 3.823824813084709*^9}, {3.823824891505232*^9,
3.823824896078597*^9}, {3.823824933035413*^9, 3.823825146527771*^9}, {
3.823825345497595*^9, 3.823825376084662*^9}, {3.8238254432157917`*^9,
3.823825578056011*^9}, {3.8238256864752197`*^9, 3.823825692067996*^9}, {
3.823825731222021*^9, 3.823825773769854*^9}, {3.823825807284655*^9,
3.823825812085175*^9}, {3.82382588875665*^9, 3.823825927925229*^9}, {
3.823825998878051*^9, 3.823826030543096*^9}, {3.823826131734275*^9,
3.8238262049439917`*^9}, {3.823826296059133*^9, 3.82382639391203*^9},
3.823826457550797*^9, {3.8238265690225143`*^9, 3.823826570540267*^9}, {
3.823826615185136*^9, 3.823826662134515*^9}, {3.8238266982578573`*^9,
3.8238267103313503`*^9}, {3.8238267405434017`*^9, 3.82382678099257*^9}, {
3.823826883068468*^9, 3.82382690898139*^9}, 3.82382697148944*^9,
3.823946924201337*^9},ExpressionUUID->”d484a686-8c35-4e5e-a0f2-
e9b793740d4f”],
Cell[CellGroupData[{
Cell[BoxData[
RowBox[{
RowBox[{“Animate”, “[“,
RowBox[{
RowBox[{“visualize”, “[“,
RowBox[{“myAgents”, “[“,
RowBox[{“[“, “t”, “]”}], “]”}], “]”}], “,”,
RowBox[{“{“,
RowBox[{“t”, “,”, “0”, “,”, “numSteps”, “,”, “1”}], “}”}]}], “]”}],
“
”}]], “Input”,
CellChangeTimes->{{3.823823258491226*^9, 3.82382325961141*^9}, {
3.823824810418147*^9, 3.823824813084709*^9}, {3.823824891505232*^9,
3.823824896078597*^9}, {3.823824933035413*^9, 3.823825146527771*^9}, {
3.823825345497595*^9, 3.823825376084662*^9}, {3.8238254432157917`*^9,
3.823825578056011*^9}, {3.8238256864752197`*^9, 3.823825692067996*^9}, {
3.823825731222021*^9, 3.823825773769854*^9}, {3.823825807284655*^9,
3.823825812085175*^9}, {3.82382588875665*^9, 3.823825927925229*^9}, {
3.823825998878051*^9, 3.823826030543096*^9}, {3.823826131734275*^9,
3.8238262049439917`*^9}, {3.823826296059133*^9, 3.82382639391203*^9},
3.823826457550797*^9, {3.8238265690225143`*^9, 3.823826570540267*^9}, {
3.823826615185136*^9, 3.823826662134515*^9}, {3.8238266982578573`*^9,
3.8238267103313503`*^9}, {3.8238267405434017`*^9, 3.82382678099257*^9}, {
3.823826883068468*^9, 3.823826963312007*^9}},
CellLabel->
“In[278]:=”,ExpressionUUID->”365c9f3c-567c-4aa2-ae6a-5e5cf90e89f5″],
Cell[BoxData[
TagBox[
StyleBox[
DynamicModuleBox[{$CellContext`t$$ = 6518, Typeset`show$$ = True,
Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = “Menu”,
Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ =
“”untitled””, Typeset`specs$$ = {{
Hold[$CellContext`t$$], 0, 10000, 1}}, Typeset`size$$ = {
400., {198., 202.}}, Typeset`update$$ = 0, Typeset`initDone$$,
Typeset`skipInitDone$$ = True, $CellContext`t$286822$$ = 0},
DynamicBox[Manipulate`ManipulateBoxes[
1, StandardForm, “Variables” :> {$CellContext`t$$ = 0},
“ControllerVariables” :> {
Hold[$CellContext`t$$, $CellContext`t$286822$$, 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`visualize[
Part[$CellContext`myAgents, $CellContext`t$$]],
“Specifications” :> {{$CellContext`t$$, 0, 10000, 1,
AppearanceElements -> {
“ProgressSlider”, “PlayPauseButton”, “FasterSlowerButtons”,
“DirectionButton”}}},
“Options” :> {
ControlType -> Animator, AppearanceElements -> None, DefaultBaseStyle ->
“Animate”, DefaultLabelStyle -> “AnimateLabel”, SynchronousUpdating ->
True, ShrinkingDelay -> 10.}, “DefaultOptions” :> {}],
ImageSizeCache->{445., {234., 240.}},
SingleEvaluation->True],
Deinitialization:>None,
DynamicModuleValues:>{},
SynchronousInitialization->True,
UndoTrackedVariables:>{Typeset`show$$, Typeset`bookmarkMode$$},
UnsavedVariables:>{Typeset`initDone$$},
UntrackedVariables:>{Typeset`size$$}], “Animate”,
Deployed->True,
StripOnInput->False],
Manipulate`InterpretManipulate[1]]], “Output”,
CellChangeTimes->{
3.8238232644423656`*^9, 3.823825583834017*^9, 3.823825694399633*^9,
3.823825739909689*^9, 3.823825813177113*^9, 3.8238258926754627`*^9,
3.8238259289291983`*^9, {3.823826000590176*^9, 3.823826030988311*^9},
3.823826174682054*^9, 3.823826206480578*^9, {3.823826296706038*^9,
3.823826329451919*^9}, 3.823826362016163*^9, 3.823826400390871*^9,
3.8238264594132547`*^9, {3.823826638686146*^9, 3.823826675319862*^9},
3.823826711989064*^9, {3.823826747403532*^9, 3.823826788328635*^9}, {
3.823826893714567*^9, 3.823826930380022*^9}, 3.823826964320922*^9},
CellLabel->
“Out[278]=”,ExpressionUUID->”571ad12f-6717-42b5-9202-65351da1b312″]
}, Open ]],
Cell[“<
b) Compare the results above to the analytical solution for the 1-D
diffusion of particles starting from a single point.
>“, “Subsection”,
CellChangeTimes->{{3.8239471483045387`*^9, 3.8239471782208357`*^9}, {
3.8239472120658627`*^9,
3.823947240159985*^9}},ExpressionUUID->”3b9a6bba-c4ac-4090-991b-
d14b4826f635″]
}, Open ]]
}, Open ]]
},
WindowSize->{960, 1035},
WindowMargins->{{Automatic, -1758}, {Automatic, 2}},
FrontEndVersion->”12.0 for Mac OS X x86 (64-bit) (April 8, 2019)”,
StyleDefinitions->”Default.nb”
]
(* End of Notebook Content *)
(* Internal cache information *)
(*CellTagsOutline
CellTagsIndex->{}
*)
(*CellTagsIndex
CellTagsIndex->{}
*)
(*NotebookFileOutline
Notebook[{
Cell[CellGroupData[{
Cell[580, 22, 206, 4, 98, “Title”,ExpressionUUID->”ca359983-38f4-4f7a-a685-99c62a097f1e”],
Cell[789, 28, 233, 4, 46, “Text”,ExpressionUUID->”03ac98e9-e199-4728-86d8-cd8df5a8f94c”],
Cell[CellGroupData[{
Cell[1047, 36, 153, 3, 67, “Section”,ExpressionUUID->”bf54f8f1-71f9-44e7-a0bd-b4a3bf37f7f8″],
Cell[1203, 41, 766, 11, 128, “Text”,ExpressionUUID->”2658a4a2-7330-48b1-846e-9f4cae75174a”],
Cell[1972, 54, 154, 3, 30, “Input”,ExpressionUUID->”65a76d71-c53e-4565-9a8a-0a1f74339d7e”],
Cell[2129, 59, 4632, 118, 535, “Input”,ExpressionUUID->”d484a686-8c35-4e5e-a0f2-e9b793740d4f”],
Cell[CellGroupData[{
Cell[6786, 181, 1298, 24, 52, “Input”,ExpressionUUID->”365c9f3c-567c-4aa2-ae6a-5e5cf90e89f5″],
Cell[8087, 207, 2592, 49, 493, “Output”,ExpressionUUID->”571ad12f-6717-42b5-9202-65351da1b312″]
}, Open ]],
Cell[10694, 259, 336, 7, 81, “Subsection”,ExpressionUUID->”3b9a6bba-c4ac-4090-991b-d14b4826f635″]
}, Open ]]
}, Open ]]
}
]
*)