(* 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[ 11938, 356] NotebookOptionsPosition[ 10719, 311] NotebookOutlinePosition[ 11341, 334] CellTagsIndexPosition[ 11298, 331] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["Checking the Beer Paper with Mathematica ", "Section", TextAlignment->Center], Cell["\<\ Michael A. Karls Department of Mathematical Sciences Ball State University Muncie, IN 47306 USA\ \>", "Text", CellChangeTimes->{{3.7334321466835256`*^9, 3.7334322042768197`*^9}, { 3.733522084067066*^9, 3.733522087329392*^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"}], ";"}]}], "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}, { 3.7197112117857943`*^9, 3.7197112130493937`*^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[{ RowBox[{ RowBox[{"solution", "[", "k_", "]"}], ":=", " ", 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[{"4", "*", "\[Pi]", "*", "\[Eta]", "*", 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[{"1", "/", "3"}]]}]}]}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"x", "[", "0", "]"}], "\[Equal]", RowBox[{"-", "0.156"}]}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"y", "[", "0", "]"}], "\[Equal]", "0"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"n", "[", "0", "]"}], "\[Equal]", 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.7195278603245487`*^9, 3.7195278608705482`*^9}, {3.7195279371077485`*^9, 3.719527937263748*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["\<\ Use the solution to the system of ODE to find bubble position and 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}, {3.719711811356194*^9, 3.719711815505794*^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", "[", "k_", "]"}], ":=", RowBox[{"Table", "[", RowBox[{ RowBox[{"Evaluate", "[", RowBox[{ RowBox[{"{", RowBox[{"t", ",", RowBox[{"100", "*", RowBox[{"x", "[", "t", "]"}]}], ",", RowBox[{ RowBox[{"r", "[", "t", "]"}], "/", RowBox[{"r", "[", "0", "]"}]}]}], "}"}], "/.", RowBox[{ RowBox[{"solution", "[", "k", "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], "]"}], ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", "3.78", ",", "0.54"}], "}"}]}], "]"}]}], ";"}]], "Input", CellChangeTimes->{{3.7188031529571238`*^9, 3.7188031891987343`*^9}, { 3.7192760564582157`*^9, 3.719276106752616*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"TableForm", "[", RowBox[{ RowBox[{"bubbledata", "[", "0.0075", "]"}], ",", RowBox[{"TableHeadings", "\[Rule]", RowBox[{"{", RowBox[{"None", ",", RowBox[{"{", RowBox[{ "\"\