8.4 Oscillating 1D Systems: A Second Order ODE
239
Fig. 8.17 The effect of a vaccination campaign
else:
return 0
In the code for updating the arrays S and V, we then get a term p(t[n])*S[n].
Alternatively, we can instead let p(t) be an array filled with correct values prior
to the simulation. Then we need to allocate an array p of length N_t+1 and find the
indices corresponding to the time period between 6 and 15 days. These indices are
found from the time point divided by Δ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]. The file SIRV2.py contains a program based on filling an array p.
The effect of a vaccination campaign is illustrated in Fig. 8.17. All the data are
as in Fig. 8.15, except that p is ten times stronger for a period of 10 days and p = 0
elsewhere.
8.4 Oscillating 1D Systems: A Second Order ODE
Numerous engineering constructions and devices contain materials that act like
springs. Such springs give rise to oscillations, and controlling oscillations is a key
engineering task. We shall now learn to simulate oscillating systems.
As always, we start with the simplest meaningful mathematical model, which for
oscillations is a second-order differential equation:
u
(t) + ω
2 u(t) = 0,
(8.40)
239
Fig. 8.17 The effect of a vaccination campaign
else:
return 0
In the code for updating the arrays S and V, we then get a term p(t[n])*S[n].
Alternatively, we can instead let p(t) be an array filled with correct values prior
to the simulation. Then we need to allocate an array p of length N_t+1 and find the
indices corresponding to the time period between 6 and 15 days. These indices are
found from the time point divided by Δ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]. The file SIRV2.py contains a program based on filling an array p.
The effect of a vaccination campaign is illustrated in Fig. 8.17. All the data are
as in Fig. 8.15, except that p is ten times stronger for a period of 10 days and p = 0
elsewhere.
8.4 Oscillating 1D Systems: A Second Order ODE
Numerous engineering constructions and devices contain materials that act like
springs. Such springs give rise to oscillations, and controlling oscillations is a key
engineering task. We shall now learn to simulate oscillating systems.
As always, we start with the simplest meaningful mathematical model, which for
oscillations is a second-order differential equation:
u
(t) + ω
2 u(t) = 0,
(8.40)
