0% found this document useful (0 votes)
51 views5 pages

Indian Institute of Technology Gandhinagar: PH 509: Computational Physics

The document describes modeling disease dynamics using the SIR model of epidemiology. It presents: 1) The SIR differential equations and shows two equations are sufficient by normalizing populations. 2) Numerical solutions using odeint and Runge-Kutta methods for S(t), I(t), R(t) with λ < μ and λ > μ. 3) A plot of asymptotic recovered population R(∞) versus infection rate λ/recovery rate μ, showing it levels off at higher λ/μ ratios.

Uploaded by

Jitendra Gurjar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views5 pages

Indian Institute of Technology Gandhinagar: PH 509: Computational Physics

The document describes modeling disease dynamics using the SIR model of epidemiology. It presents: 1) The SIR differential equations and shows two equations are sufficient by normalizing populations. 2) Numerical solutions using odeint and Runge-Kutta methods for S(t), I(t), R(t) with λ < μ and λ > μ. 3) A plot of asymptotic recovered population R(∞) versus infection rate λ/recovery rate μ, showing it levels off at higher λ/μ ratios.

Uploaded by

Jitendra Gurjar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Indian Institute of Technology Gandhinagar

PH 509: Computational Physics

Assignment - 3

Due date: 31st Aug

Name: Akash Arya,Uday sigh,Jitendra Gurjar Roll number: 16510006,16510092,16510034

1 Problem
DISEASE DYNAMICS(SIR Model)

A famous for disease model is the SIR model.Here population is divided into Susceptible,Infected
and Recovered(S,I,R) groups with total population S+I+R=N,constant.Infection spreads when
susceptible and infected are in contact,at a rate .Infected people recover at a rate .The equations
governing these are

dS
= S I
dt

dI
=SI I
dt

dS
=I
dt

(a) Show that only two equations (say S,I) are sufficient to describe the dyanamics,when normalized
S
by N.Write equations for s = N and i = NI ,what is r ?

(b)With initial conditions s(0)=0.99,i(0)=0.01,solve the system using RK4 and odeint for the fol-
lowing conditions (plot s(t),i(t),r(t) v/s t) (i) < say = 0.8, = 1.0 (ii) > say = 1.2, = 1.0


(c)Set = 1,vary = 0.1 10 in steps of o.1.Plot r() v/s

1.1 ODEint Method


1.2 Program
import s c i p y . i n t e g r a t e a s s p i
import numpy a s np
import p ylab a s p l

Lambda=1.2
mu=1.0
TS=1.0
ND=70.0
s 0 =0.99
i 0 =0.01
INPUT = ( s0 , i 0 , 0 . 0 )

def d i f f e q s ( INP , t ) :

1
The main s e t o f e q u a t i o n s
( dS dt , d I d t , dR dt)=np . z e r o s ( ( 3 ) )
V = INP
dS dt = Lambda V [ 0 ] V [ 1 ]
d I d t = Lambda V [ 0 ] V [ 1 ] mu V [ 1 ]
dR dt = muV [ 1 ]
return ( dS dt , d I d t , dR dt ) # For o d e i n t

t s t a r t = 0 . 0 ; t e n d = ND; t i n c = TS
t s t e p = np . a r a n g e ( t s t a r t , t e n d+t i n c , t i n c )
RES = s p i . o d e i n t ( d i f f e q s , INPUT, t s t e p )

print RES

p l . p l o t (RES [ : , 0 ] , -g , l a b e l=s(t) )
p l . p l o t (RES [ : , 2 ] , -k , l a b e l=r(t) )
p l . p l o t (RES [ : , 1 ] , -b , l a b e l=i(t) )
p l . l e g e n d ( l o c =0)
p l . t i t l e ( Disease Dynamics . py )
p l . x l a b e l ( Time )
p l . y l a b e l ( s(t),r(t) and i(t) )
p l . yli m ( [ 0 . 0 , 1 . 0 ] )
pl . grid ()
p l . show ( )

1.3 Results
for = 0.8, = 1.0

2
for = 1.2, = 1.0

2 Runge Kutta Method


2.1 Program
import s c i p y a s sp
import numpy a s np
import p ylab a s p l

Lambda=0.8
mu=1.0
s 0 =0.99
i 0 =0.01
r 0 =0.0
h =0.001
P= [ ]
Q= [ ]
R= [ ]
time=np . a r a n g e ( 0 , 1 0 0 , h )

def f 1 ( S , I , R, t ) :
return LambdaS I
def f 2 ( S , I , R, t ) :
return LambdaS Imu I
def f 3 ( S , I , R, t ) :
return mu I

f o r t in time :
k0=h f 1 ( t , s0 , i 0 , r 0 )
l 0=h f 2 ( t , s0 , i 0 , r 0 )
m0=h f 3 ( t , s0 , i 0 , r 0 )
k1=h f 1 ( ( t+h / 2 . 0 ) , ( s 0+k0 / 2 . 0 ) , ( i 0+l 0 / 2 . 0 ) , ( r 0+m0 / 2 . 0 ) )
l 1=h f 2 ( ( t+h / 2 . 0 ) , ( s 0+k0 / 2 . 0 ) , ( i 0+l 0 / 2 . 0 ) , ( r 0+m0 / 2 . 0 ) )
m1=h f 3 ( ( t+h / 2 . 0 ) , ( s 0+k0 / 2 . 0 ) , ( i 0+l 0 / 2 . 0 ) , ( r 0+m0 / 2 . 0 ) )
k2=h f 1 ( ( t+h / 2 . 0 ) , ( s 0+k1 / 2 . 0 ) , ( i 0+l 1 / 2 . 0 ) , ( r 0+m1 / 2 . 0 ) )
l 2=h f 2 ( ( t+h / 2 . 0 ) , ( s 0+k1 / 2 . 0 ) , ( i 0+l 1 / 2 . 0 ) , ( r 0+m1 / 2 . 0 ) )
m2=h f 3 ( ( t+h / 2 . 0 ) , ( s 0+k1 / 2 . 0 ) , ( i 0+l 1 / 2 . 0 ) , ( r 0+m1 / 2 . 0 ) )
k3=h f 1 ( ( t+h ) , ( s 0+k2 ) , ( i 0+l 2 ) , ( r 0+m2) )
l 3=h f 2 ( ( t+h ) , ( s 0+k2 ) , ( i 0+l 2 ) , ( r 0+m2) )
m3=h f 3 ( ( t+h ) , ( s 0+k2 ) , ( i 0+l 2 ) , ( r 0+m2) )
s 0=s 0 +(h / 6 . 0 ) ( k0 + ( 2 . 0 k1 ) + ( 2 . 0 k2 ) + k3 )

3
i 0=i 0 +(h / 6 . 0 ) ( l 0 + ( 2 . 0 l 1 ) + ( 2 . 0 l 2 ) + l 3 )
r 0=r 0 +(h / 6 . 0 ) ( m0 + ( 2 . 0 m1) + ( 2 . 0 m2) + m3)

P . append ( s 0 )
Q. append ( i 0 )
R. append ( r 0 )

pl . subplot (2 ,2 ,1)
p l . p l o t ( time , P , l a b e l=s0 )
pl . grid ()
pl . subplot (2 ,2 ,2)
p l . p l o t ( time , Q, l a b e l=i0 )
pl . grid ()
pl . subplot (2 ,2 ,3)
p l . p l o t ( time , R, l a b e l=r0 )
pl . grid ()
p l . show ( )

2.2 Results
for = 0.8, = 1.0

4
for = 1.2, = 1.0

(C) when we increases the value of time and we plot r with respect to different values of / this will
be constant at higher values.

You might also like