Web-Books
im Austria-Forum
Austria-Forum
Web-Books
Informatik
Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python
Seite - 123 -
  • Benutzer
  • Version
    • Vollversion
    • Textversion
  • Sprache
    • Deutsch
    • English - Englisch

Seite - 123 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Bild der Seite - 123 -

Bild der Seite - 123 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Text der Seite - 123 -

4.2 SpreadingofDiseases 123 4.2.9 DiscontinuousCoefficients:AVaccinationCampaign Whataboutmodelingavaccinationcampaign? Imagine that sixdaysafter theout- breakof thedisease, the localhealthstation launchesavaccinationcampaign.They reach out tomany people, say 10 times as efficiently as in the previous (constant vaccination)case. If thecampaign lasts for10dayswecanwrite p.t/D ( 0:005; 6 24 t 15 24; 0; otherwise Note thatwemustmultiply the t value by24 because t ismeasured in hours, not days. In thedifferential equationsystem,pS.t/mustbe replacedbyp.t/S.t/, and in this case we get a differential equation systemwith a term that is discontinu- ous. This is usually quite a challenge inmathematics, but as long aswe solve the equationsnumerically inaprogram,adiscontinuouscoefficient is easy to treat. There are twoways to implement the discontinuous coefficientp.t/: through a functionand throughanarray. Thefunctionapproach isperhaps theeasiest: def p(t): return 0.005 if (6*24 <= t <= 15*24) else 0 In thecode forupdating thearraysSandVweget a termp(t[n])*S[n]. Wecanalso letp.t/beanarrayfilledwithcorrectvaluesprior to thesimulation. Thenwe need to allocate an array p of length N_t+1 and find the indices corre- sponding to the timeperiodbetween6and15days. These indices are found from the timepointdividedby t. That is, p = zeros(N_t+1) start_index = 6*24/dt stop_index = 15*24/dt p[start_index:stop_index] = 0.005 The p.t/S.t/ term in the updating formulas for S and V simply becomes p[n]*S[n]. ThefileSIRV2.pycontainsaprogrambasedonfillinganarrayp. The effect of a vaccinationcampaign is illustrated inFig. 4.14. All thedata are as inFig.4.13 (left), except thatp is ten times stronger for aperiodof10daysand pD0elsewhere.
zurück zum  Buch Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python"
Programming for Computations – Python A Gentle Introduction to Numerical Simulations with Python
Titel
Programming for Computations – Python
Untertitel
A Gentle Introduction to Numerical Simulations with Python
Autoren
Svein Linge
Hans Petter Langtangen
Verlag
Springer Open
Datum
2016
Sprache
englisch
Lizenz
CC BY-NC 4.0
ISBN
978-3-319-32428-9
Abmessungen
17.8 x 25.4 cm
Seiten
248
Schlagwörter
Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
Kategorie
Informatik
Web-Books
Bibliothek
Datenschutz
Impressum
Austria-Forum
Austria-Forum
Web-Books
Programming for Computations – Python