Web-Books
in the Austria-Forum
Austria-Forum
Web-Books
Informatik
Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python
Page - 120 -
  • User
  • Version
    • full version
    • text only version
  • Language
    • Deutsch - German
    • English

Page - 120 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Image of the Page - 120 -

Image of the Page - 120 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Text of the Page - 120 -

120 4 SolvingOrdinaryDifferentialEquations Modeling the loss of immunity is very similar tomodeling recovery from the disease: the amount of people losing immunity is proportional to the amount of recovered patients and the length of the time interval t. We can thereforewrite the loss in theR category as tR in time t, where 1 is the typical time it takes to lose immunity. The loss inR.t/ is a gain inS.t/. The “budgets” for the categories thereforebecome SnC1 DSn ˇ tSnInC tRn; (4.30) InC1 DInCˇ tSnIn tIn; (4.31) RnC1 DRnC tIn tRn: (4.32) Dividingby t and letting t !0gives thedifferential equationsystem S0 D ˇSI C R; (4.33) I 0 DˇSI I; (4.34) R0 D I R: (4.35) Thissystemcanbesolvedbythesamemethodsaswedemonstratedfor theoriginal SIRmodel.Onlyonemodification in theprogramisnecessary: addingnu*R[n] to theS[n+1]updateandsubtracting the samequantity in theR[n+1]update: for n in range(N_t): S[n+1] = S[n] - dt*beta*S[n]*I[n] + dt*nu*R[n] I[n+1] = I[n] + dt*beta*S[n]*I[n] - dt*gamma*I[n] R[n+1] = R[n] + dt*gamma*I[n] - dt*nu*R[n] Themodifiedcode is found in thefileSIR2.py. Setting 1 to 50 days, reducingˇ by a factor of 4 compared to the previous example (ˇD 0:00033), andsimulating for300daysgivesanoscillatorybehavior in the categories, as depicted inFig. 4.11. It is easy now toplay aroundand study how the parameters affect the spreading of the disease. For example,making the disease slightlymore effective (increaseˇ to 0.00043) and increasing the average time to lossof immunity to90days lead tootheroscillations, seeFig. 4.12. 4.2.8 IncorporatingVaccination Wecanextend themodel to also includevaccination. To this end, it canbeuseful to track thosewhoarevaccinatedand thosewhoarenot. So,we introducea fourth category, V, for thosewho have taken a successful vaccination. Furthermore, we assume that in a time interval t, a fractionp t of the S category is subject to a successful vaccination. Thismeans that in the time t,p tS people leave from theSto theVcategory. Since thevaccinatedonescannotget thedisease, there isno impacton the IorRcategories.Wecanvisualize thecategories, and themovement between them,as
back to the  book Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python"
Programming for Computations – Python A Gentle Introduction to Numerical Simulations with Python
Title
Programming for Computations – Python
Subtitle
A Gentle Introduction to Numerical Simulations with Python
Authors
Svein Linge
Hans Petter Langtangen
Publisher
Springer Open
Date
2016
Language
English
License
CC BY-NC 4.0
ISBN
978-3-319-32428-9
Size
17.8 x 25.4 cm
Pages
248
Keywords
Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
Category
Informatik
Web-Books
Library
Privacy
Imprint
Austria-Forum
Austria-Forum
Web-Books
Programming for Computations – Python