(* 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[ 1886854, 33147] NotebookOptionsPosition[ 1884046, 33052] NotebookOutlinePosition[ 1884666, 33075] CellTagsIndexPosition[ 1884623, 33072] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell[TextData[{ "Checking the Beer Paper with ", StyleBox["Mathematica", FontSlant->"Italic"], ": Question 5 " }], "Section", CellChangeTimes->{{3.722123784112422*^9, 3.7221237885584297`*^9}}, TextAlignment->Center], Cell["\<\ Michael A. Karls Department of Mathematical Sciences Ball State University Muncie, IN 47306 USA\ \>", "Text", CellChangeTimes->{{3.733432323713651*^9, 3.733432325561757*^9}, { 3.7335227002827053`*^9, 3.7335227016697054`*^9}}, TextAlignment->Center], Cell[CellGroupData[{ Cell["\<\ Run this command once per experiment to clear out model solution variables \ stored in memory.\ \>", "Subsubsection", CellChangeTimes->{{3.397869975*^9, 3.397870026796875*^9}}], Cell[BoxData[ RowBox[{"Clear", "[", RowBox[{"solution", ",", "bubbledata"}], "]"}]], "Input", CellChangeTimes->{{3.397869402390625*^9, 3.39786944175*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Enter parameters in model.", "Subsubsection", CellChangeTimes->{{3.397869490234375*^9, 3.397869492328125*^9}, { 3.3978696215*^9, 3.39786964003125*^9}, 3.39786995503125*^9}], Cell[BoxData[{ RowBox[{ RowBox[{ SubscriptBox["\[Rho]", "beer"], "=", RowBox[{"1.010", "*", SuperscriptBox["10", "3"]}]}], ";"}], "\n", RowBox[{ RowBox[{"g", "=", "9.807"}], ";"}], "\n", RowBox[{ RowBox[{"R", "=", "8.3145"}], ";"}], "\n", RowBox[{ RowBox[{"P", "=", RowBox[{"1.013", "*", SuperscriptBox["10", "5"]}]}], ";"}], "\n", RowBox[{ RowBox[{ SubscriptBox["m", "CO2"], "=", RowBox[{"4.401", "*", SuperscriptBox["10", RowBox[{"-", "2"}]]}]}], ";"}], "\n", RowBox[{ RowBox[{"\[Eta]", "=", RowBox[{"1.3", "*", SuperscriptBox["10", RowBox[{"-", "3"}]]}]}], ";"}], "\n", RowBox[{ RowBox[{"T", "=", "281"}], ";"}], "\n", RowBox[{ RowBox[{"k", "=", RowBox[{"7.5", "*", SuperscriptBox["10", RowBox[{"-", "3"}]]}]}], ";"}]}], "Input", CellChangeTimes->{{3.397869347015625*^9, 3.397869435953125*^9}, { 3.397869565734375*^9, 3.39786956690625*^9}, {3.397869600328125*^9, 3.39786960171875*^9}, {3.3978696843125*^9, 3.397869701078125*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["\<\ Solve the system of ordinary differential equations (ODE) with initial data \ numerically.\ \>", "Subsubsection", CellChangeTimes->{{3.397869707359375*^9, 3.39786972415625*^9}, { 3.3978698616875*^9, 3.397869892234375*^9}, {3.397869926109375*^9, 3.39786993003125*^9}}], Cell[BoxData[ RowBox[{"Clear", "[", RowBox[{"k", ",", "d"}], "]"}]], "Input", CellChangeTimes->{{3.718802329288537*^9, 3.71880233192492*^9}, { 3.719493548891511*^9, 3.719493549375112*^9}}], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"solution", "[", RowBox[{"k_", ",", "d_"}], "]"}], ":=", " ", RowBox[{"NDSolve", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{ RowBox[{"n", "'"}], "[", "t", "]"}], "\[Equal]", RowBox[{"4", "*", "\[Pi]", "*", "k", "*", SuperscriptBox[ RowBox[{"(", FractionBox[ RowBox[{"3", "*", RowBox[{"n", "[", "t", "]"}], "*", "R", "*", "T"}], RowBox[{"4", "*", "\[Pi]", "*", RowBox[{"(", RowBox[{"P", "-", RowBox[{"g", "*", SubscriptBox["\[Rho]", "beer"], "*", RowBox[{"x", "[", "t", "]"}]}]}], ")"}]}]], ")"}], RowBox[{"2", "/", "3"}]]}]}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"x", "'"}], "[", "t", "]"}], "\[Equal]", RowBox[{"y", "[", "t", "]"}]}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"y", "'"}], "[", "t", "]"}], "\[Equal]", RowBox[{ RowBox[{"g", "*", RowBox[{"(", RowBox[{ FractionBox[ RowBox[{ SubscriptBox["\[Rho]", "beer"], "*", "R", "*", "T"}], RowBox[{ SubscriptBox["m", "CO2"], "*", RowBox[{"(", RowBox[{"P", "-", RowBox[{"g", "*", SubscriptBox["\[Rho]", "beer"], "*", RowBox[{"x", "[", "t", "]"}]}]}], ")"}]}]], "-", "1"}], ")"}]}], "-", RowBox[{ RowBox[{"(", FractionBox[ RowBox[{"d", "*", RowBox[{"y", "[", "t", "]"}]}], RowBox[{ SubscriptBox["m", "CO2"], "*", RowBox[{"n", "[", "t", "]"}]}]], ")"}], "*", SuperscriptBox[ RowBox[{"(", FractionBox[ RowBox[{"3", "*", RowBox[{"n", "[", "t", "]"}], "*", "R", "*", "T"}], RowBox[{"4", "*", "\[Pi]", "*", RowBox[{"(", RowBox[{"P", "-", RowBox[{"g", "*", SubscriptBox["\[Rho]", "beer"], "*", RowBox[{"x", "[", "t", "]"}]}]}], ")"}]}]], ")"}], RowBox[{"2", "/", "3"}]]}]}]}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"x", "[", "0", "]"}], "\[Equal]", RowBox[{"-", "0.156"}]}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"y", "[", "0", "]"}], "\[Equal]", "0"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"n", "[", "0", "]"}], "\[Equal]", RowBox[{"9", "*", SuperscriptBox["10", RowBox[{"-", "10"}]]}]}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"x", ",", "y", ",", "n"}], "}"}], ",", RowBox[{"{", RowBox[{"t", ",", "5"}], "}"}]}], "]"}]}], ";"}]], "Input", CellChangeTimes->{{3.397870276359375*^9, 3.397870324421875*^9}, { 3.397893982765625*^9, 3.397894001953125*^9}, {3.7188023174950123`*^9, 3.7188023437496443`*^9}, {3.7193406133382883`*^9, 3.7193406141650934`*^9}, { 3.7193406587813797`*^9, 3.7193406589685807`*^9}, {3.719493543930702*^9, 3.7194935531815186`*^9}, {3.719493776935113*^9, 3.719493777434314*^9}, { 3.719495325175417*^9, 3.719495325721418*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"solution", "[", RowBox[{ RowBox[{"2", "*", SuperscriptBox["10", RowBox[{"-", "3"}]]}], ",", "260"}], "]"}]], "Input", CellChangeTimes->{{3.7194935575963264`*^9, 3.719493564007938*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{"{", RowBox[{ RowBox[{"x", "\[Rule]", TagBox[ RowBox[{"InterpolatingFunction", "[", RowBox[{ RowBox[{"{", RowBox[{"{", RowBox[{"0.`", ",", "5.`"}], "}"}], "}"}], ",", "\<\"<>\"\>"}], "]"}], False, Editable->False]}], ",", RowBox[{"y", "\[Rule]", TagBox[ RowBox[{"InterpolatingFunction", "[", RowBox[{ RowBox[{"{", RowBox[{"{", RowBox[{"0.`", ",", "5.`"}], "}"}], "}"}], ",", "\<\"<>\"\>"}], "]"}], False, Editable->False]}], ",", RowBox[{"n", "\[Rule]", TagBox[ RowBox[{"InterpolatingFunction", "[", RowBox[{ RowBox[{"{", RowBox[{"{", RowBox[{"0.`", ",", "5.`"}], "}"}], "}"}], ",", "\<\"<>\"\>"}], "]"}], False, Editable->False]}]}], "}"}], "}"}]], "Output", CellChangeTimes->{ 3.7192753148192863`*^9, 3.719303220866249*^9, 3.7193405173820734`*^9, 3.7193406183927207`*^9, 3.719340664163414*^9, 3.719408765733291*^9, 3.7194936063630123`*^9, 3.719493786279529*^9, 3.7194952428662667`*^9, 3.719495342382247*^9, 3.7195238925520287`*^9, 3.719539574813141*^9, 3.7220789147931805`*^9, 3.7221238875094037`*^9, 3.7221578003153687`*^9, 3.723739554304037*^9, 3.7334323395445566`*^9, 3.73343269504289*^9, { 3.7335227165567055`*^9, 3.733522729668705*^9}}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"solution", "[", RowBox[{ RowBox[{"2", "*", SuperscriptBox["10", RowBox[{"-", "3"}]]}], ",", "260"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]], "Input", CellChangeTimes->{{3.7188024116650085`*^9, 3.718802436094452*^9}, { 3.7194935692807474`*^9, 3.7194935882981806`*^9}, 3.719493641059473*^9, { 3.719493801086955*^9, 3.7194938041913605`*^9}, {3.719495352210264*^9, 3.7194953531930656`*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"x", "\[Rule]", TagBox[ RowBox[{"InterpolatingFunction", "[", RowBox[{ RowBox[{"{", RowBox[{"{", RowBox[{"0.`", ",", "5.`"}], "}"}], "}"}], ",", "\<\"<>\"\>"}], "]"}], False, Editable->False]}], ",", RowBox[{"y", "\[Rule]", TagBox[ RowBox[{"InterpolatingFunction", "[", RowBox[{ RowBox[{"{", RowBox[{"{", RowBox[{"0.`", ",", "5.`"}], "}"}], "}"}], ",", "\<\"<>\"\>"}], "]"}], False, Editable->False]}], ",", RowBox[{"n", "\[Rule]", TagBox[ RowBox[{"InterpolatingFunction", "[", RowBox[{ RowBox[{"{", RowBox[{"{", RowBox[{"0.`", ",", "5.`"}], "}"}], "}"}], ",", "\<\"<>\"\>"}], "]"}], False, Editable->False]}]}], "}"}]], "Output", CellChangeTimes->{ 3.7188041877530327`*^9, 3.7192753015134244`*^9, 3.7193032208974485`*^9, 3.719340517413274*^9, 3.719340618423921*^9, 3.7193406641946144`*^9, 3.719408765764488*^9, 3.7194936431996775`*^9, 3.7194938057045636`*^9, 3.7194952428818665`*^9, {3.719495347873457*^9, 3.719495353785867*^9}, 3.7195238926143765`*^9, 3.71953957484434*^9, 3.7220789148243833`*^9, 3.7221238875406036`*^9, 3.7221578003309684`*^9, 3.7237395543352365`*^9, 3.7334323395675583`*^9, 3.7334326950658913`*^9, {3.733522716586705*^9, 3.7335227297007055`*^9}}] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["\<\ Use the solution to the system of ODE to find bubble radius at each time \ increment and display bubble data in a table.\ \>", "Subsubsection", CellChangeTimes->{{3.397869734453125*^9, 3.39786979928125*^9}, { 3.397869837109375*^9, 3.397869838890625*^9}, {3.397869897515625*^9, 3.397869930984375*^9}}], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"r", "[", "t_", "]"}], ":=", SuperscriptBox[ RowBox[{"(", FractionBox[ RowBox[{"3", "*", RowBox[{"n", "[", "t", "]"}], "*", "R", "*", "T"}], RowBox[{"4", "*", "\[Pi]", "*", RowBox[{"(", RowBox[{"P", "-", RowBox[{"g", "*", SubscriptBox["\[Rho]", "beer"], "*", RowBox[{"x", "[", "t", "]"}]}]}], ")"}]}]], ")"}], RowBox[{"1", "/", "3"}]]}], ";"}]], "Input", CellChangeTimes->{ 3.397869833109375*^9, {3.39789393446875*^9, 3.397893955734375*^9}, { 3.7188024034252615`*^9, 3.7188024085918283`*^9}, {3.7188024747572002`*^9, 3.7188024755684004`*^9}, {3.7188026014568005`*^9, 3.7188026426282005`*^9}, {3.7188027160508003`*^9, 3.7188027424334*^9}, { 3.718802900586051*^9, 3.7188029032537193`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"bubbledata", "[", RowBox[{"k_", ",", "d_"}], "]"}], ":=", RowBox[{"Table", "[", RowBox[{ RowBox[{"Evaluate", "[", RowBox[{ RowBox[{"{", RowBox[{"t", ",", RowBox[{"100", "*", RowBox[{"x", "[", "t", "]"}]}], ",", RowBox[{ RowBox[{"r", "[", "t", "]"}], "/", RowBox[{"r", "[", "0", "]"}]}]}], "}"}], "/.", RowBox[{ RowBox[{"solution", "[", RowBox[{"k", ",", "d"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], "]"}], ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", "3.78", ",", "0.54"}], "}"}]}], "]"}]}], ";"}]], "Input", CellChangeTimes->{{3.7188031529571238`*^9, 3.7188031891987343`*^9}, { 3.7192760564582157`*^9, 3.719276106752616*^9}, {3.7194936667245183`*^9, 3.719493679753542*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"bubbledata", "[", RowBox[{ RowBox[{"2", "*", SuperscriptBox["10", RowBox[{"-", "3"}]]}], ",", "260"}], "]"}]], "Input", CellChangeTimes->{{3.718802963508465*^9, 3.718802971823478*^9}, { 3.719493685915552*^9, 3.71949369586837*^9}, {3.7194938148617797`*^9, 3.719493818153385*^9}, {3.719495362740283*^9, 3.719495363754285*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0.`", ",", RowBox[{"-", "15.6`"}], ",", "1.`"}], "}"}], ",", RowBox[{"{", RowBox[{"0.54`", ",", RowBox[{"-", "14.035121301446605`"}], ",", "1.145296584124993`"}], "}"}], ",", RowBox[{"{", RowBox[{"1.08`", ",", RowBox[{"-", "12.25797282009732`"}], ",", "1.2909810777786437`"}], "}"}], ",", RowBox[{"{", RowBox[{"1.62`", ",", RowBox[{"-", "10.267942674249127`"}], ",", "1.4371233567959951`"}], "}"}], ",", RowBox[{"{", RowBox[{"2.16`", ",", RowBox[{"-", "8.064347484376237`"}], ",", "1.5837475618952477`"}], "}"}], ",", RowBox[{"{", RowBox[{"2.7`", ",", RowBox[{"-", "5.646422098244895`"}], ",", "1.7309253346276006`"}], "}"}], ",", RowBox[{"{", RowBox[{"3.24`", ",", RowBox[{"-", "3.0133268895501963`"}], ",", "1.8787030871891592`"}], "}"}], ",", RowBox[{"{", RowBox[{"3.7800000000000002`", ",", RowBox[{"-", "0.1641374559879906`"}], ",", "2.027139175936447`"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{ 3.7192760373482156`*^9, 3.7192761098570156`*^9, 3.7193032210534477`*^9, 3.719340517491274*^9, 3.719340618517522*^9, 3.719340664303815*^9, 3.719408765795685*^9, 3.7194936968979716`*^9, 3.7194938191205873`*^9, 3.719495242928667*^9, 3.719495364456286*^9, 3.7195238926767244`*^9, 3.719539574875539*^9, 3.7220789148399844`*^9, 3.722123887556204*^9, 3.7221578003621683`*^9, 3.723739554366437*^9, 3.7334323395965595`*^9, 3.733432695099893*^9, {3.7335227166227055`*^9, 3.733522729762705*^9}}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"TableForm", "[", RowBox[{ RowBox[{"bubbledata", "[", RowBox[{ RowBox[{"2", "*", SuperscriptBox["10", RowBox[{"-", "3"}]]}], ",", "260"}], "]"}], ",", RowBox[{"TableHeadings", "\[Rule]", RowBox[{"{", RowBox[{"None", ",", RowBox[{"{", RowBox[{ "\"\