(*********************************************************************** Mathematica-Compatible Notebook This notebook can be used on any computer system with Mathematica 3.0, MathReader 3.0, or any compatible application. The data for the notebook starts with the line of stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. ***********************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 6656, 186]*) (*NotebookOutlinePosition[ 7550, 217]*) (* CellTagsIndexPosition[ 7506, 213]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell[TextData["The S-I-R model, part 6a"], "Title", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "The infection spreads from a point source in a two-dimensional space and the \ susceptible level drops from a high value to a low."], "Subtitle", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "The number of susceptibles (at a given time and place) is \"sus\", and the \ number of infected is \"inf\". The domain is the rectangle 0 <= x <= XM, 0 \ <= y <= YM and the time interval is 0 <= t <= TM. This sets the boundaries \ of the domain. However, because we want to look at partial derivatives of \ sus and inf along the boundary, we extend the domain by allowing x = -1, x = \ XM+1 and likewise for y. (Write XM as a multiple of 6 so that it will divide \ evenly by both 2 and 3.)"], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[BoxData[ \(XM = 4\ *6; YM = XM; TM = 150; SUS1 = 100; SUS2 = 10; INF = 5; \n \(BET = .01; dt = .5; ALF = BET - 4\ GAM; GAM = .002; B = 1\/14; \)\)], "Input", AspectRatioFixed->True], Cell[TextData[ "First clear the definition of sus, inf, and rec so that any changes we make \ in the parameters will be perceived in the following definitions."], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[BoxData[ \(Clear[sus]; Clear[inf]\)], "Input", AspectRatioFixed->True], Cell[TextData[ "Boundary condition: Make the derivative in the x-direction equal to zero \ along the two sides of the rectangle parallel to the y-axis. (By the \ microscope equation, the differences z[t, 1, y] - z[t, -1, y] and z[t, XM+1, \ y] - z[t, XM-1, y]are therefore zero. This allows us to define z[t, -1, y] \ and z[t, XM+1, y] in terms of known values of z. Note therefore that these \ terms must be on the left-hand sides of the equations; the expression z[t, 1, \ y] = z[t, -1, y] would _not_ define z[t, -1, y]!)"], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[BoxData[ \(Do[sus[t, \(-1\), y] = sus[t, 1, y]; sus[t, XM + 1, y] = sus[t, XM - 1, y]; inf[t, \(-1\), y] = inf[t, 1, y]; inf[t, XM + 1, y] = inf[t, XM - 1, y], {t, 0, TM}, {y, 0, YM}]\)], "Input", AspectRatioFixed->True], Cell[TextData[ "Boundary condition: Make the derivative in the y-direction equal to zero \ along the two sides of the rectangle parallel to the x-axis. "], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[BoxData[ \(Do[sus[t, x, \(-1\)] = sus[t, x, 1]; sus[t, x, YM + 1] = sus[t, x, YM - 1]; inf[t, x, \(-1\)] = inf[t, x, 1]; inf[t, x, YM + 1] = inf[t, x, YM - 1], {t, 0, TM}, {x, 0, XM}]\)], "Input", AspectRatioFixed->True], Cell[TextData[ "Initial condition: Set two susceptible levels (above and below the normal \ threshhold) across the rectangle and introduce infected at a single point in \ the rectangle."], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[BoxData[{ \(\(Do[sus[0, x, y] = SUS1; inf[0, x, y] = 0, {x, \(-1\), XM + 1}, {y, \(-1\), YM + 1}]; \)\), \(\(Do[ sus[0, x, y] = SUS2, {x, \(2\ XM\)\/3, XM + 1}, {y, \(-1\), YM + 1}]; \)\), \(\(inf[0, XM\/3, YM\/2] = INF; \)\)}], "Input", AspectRatioFixed->True], Cell[TextData[ "Iteration: Compute the next z-value using the discrete versions of the \ PDEs."], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[BoxData[ \(Do[sus[t, x, y] = N[sus[t - 1, x, y] - dt\ sus[t - 1, x, y]\ \((ALF\ inf[t - 1, x, y] + GAM\ \(( inf[t - 1, x + 1, y] + inf[t - 1, x - 1, y] + inf[t - 1, x, y + 1] + inf[t - 1, x, y - 1])\))\)]; inf[t, x, y] = N[\((1 - B\ dt)\)\ inf[t - 1, x, y] + dt\ sus[t - 1, x, y]\ \((ALF\ inf[t - 1, x, y] + GAM\ \(( inf[t - 1, x + 1, y] + inf[t - 1, x - 1, y] + inf[t - 1, x, y + 1] + inf[t - 1, x, y - 1])\))\)], { t, 1, TM}, {x, 0, XM}, {y, 0, YM}]\)], "Input", AspectRatioFixed->True], Cell["\<\ The next two create animations that show the infection propagates \ more slowly in the region that has a low number of susceptibles.\ \>", "Text",\ Evaluatable->False, AspectRatioFixed->True], Cell[BoxData[ \(\(Table[ ListPlot3D[Table[inf[k, x, y], {x, 0, XM}, {y, 0, YM}], ViewPoint \[Rule] {4, 3, 2}, PlotRange \[Rule] {0, SUS1}, BoxRatios \[Rule] {1, 1, .6}, PlotLabel \[Rule] k], {k, 0, TM}]; \)\)], "Input", AspectRatioFixed->True], Cell[BoxData[ \(\(Table[ ListPlot3D[Table[sus[k, x, y], {x, 0, XM}, {y, 0, YM}], ViewPoint \[Rule] {4, 3, 2}, PlotRange \[Rule] {0, SUS1}, BoxRatios \[Rule] {1, 1, .6}, PlotLabel \[Rule] k], {k, 0, TM}]; \)\)], "Input", AspectRatioFixed->True] }, Open ]] }, FrontEndVersion->"X 3.0", ScreenRectangle->{{0, 1280}, {0, 1024}}, WindowToolbars->{}, CellGrouping->Automatic, WindowSize->{520, 869}, WindowMargins->{{Automatic, 49}, {22, Automatic}}, PrivateNotebookOptions->{"ColorPalette"->{RGBColor, 128}}, ShowCellLabel->True, ShowCellTags->False, RenderingOptions->{"ObjectDithering"->True, "RasterDithering"->False}, CharacterEncoding->"XAutomaticEncoding" ] (*********************************************************************** Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. ***********************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[1731, 51, 99, 2, 107, "Title"], Cell[1833, 55, 209, 4, 141, "Subtitle"], Cell[2045, 61, 568, 9, 122, "Text"], Cell[2616, 72, 199, 4, 62, "Input"], Cell[2818, 78, 218, 4, 50, "Text"], Cell[3039, 84, 81, 2, 27, "Input"], Cell[3123, 88, 586, 9, 122, "Text"], Cell[3712, 99, 255, 6, 59, "Input"], Cell[3970, 107, 212, 4, 50, "Text"], Cell[4185, 113, 255, 6, 59, "Input"], Cell[4443, 121, 244, 5, 50, "Text"], Cell[4690, 128, 300, 7, 113, "Input"], Cell[4993, 137, 153, 4, 32, "Text"], Cell[5149, 143, 720, 16, 171, "Input"], Cell[5872, 161, 206, 6, 50, "Text"], Cell[6081, 169, 278, 6, 75, "Input"], Cell[6362, 177, 278, 6, 75, "Input"] }, Open ]] } ] *) (*********************************************************************** End of Mathematica Notebook file. ***********************************************************************)