[PYTHON] Implement the mathematical model "SIR model" of infectious diseases in OpenModelica (see the effect of the vaccine)

Add vaccine effects to the basic SIR model

A model created by adding the vaccine effect to the model created in the previous article, "Implementing a mathematical model" SIR model "of infectious diseases with Open Modelica" Let's create.

Prerequisites for this vaccine model --Has the effect of safely transferring "S: infectious person" to "R: immunized recoverer" ――A person who has acquired immunity once does not lose immunity --The effect of the vaccine shall be determined by the product of "the effectiveness of the vaccine itself (the rate at which the vaccine can shift from S to R)" and "the rate of vaccination (the rate of vaccination in the total)". --It is assumed that vaccination has been completed by the time the infection begins.

As parameters, "vaccine_effect = effectiveness of the vaccine itself (ratio that can shift from S to R)" and "vaccine_rate = vaccination rate (ratio of vaccinations received)" can be set.

parameter Real vaccine_effect = 1.0 "Effect of Vaccine";
parameter Real vaccine_rate = 0.7 "Vaccination rate";

The equation part is as follows It's as simple as changing S to R at a constant rate in front of the SIR model and not affecting I. If the antibody is lost over time or if the vaccine is given while the infection is occurring, this model cannot handle it, but it is just a matter of seeing the effect of vaccination.

equation
  Vy = vaccine_effect * vaccine_rate;
  Sy = Si - Si * Vy;
  Iy = Ii;
  Ry = Ri + Si * Vy;

The whole vaccine code looks like this.

class cl_Vaccine
  extends Modelica.Blocks.Icons.Block;
  parameter Real vaccine_effect = 1.0 "Effect of Vaccine";
  parameter Real vaccine_rate = 0.7 "Vaccination rate";
  Modelica.Blocks.Interfaces.RealInput Si "Connector of initial S(Susceptible)" annotation(
      Placement(visible = true, transformation(origin = {-100, 60}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-120, 60}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealInput Ii "Connector of initial I (Infectious)" annotation(
      Placement(visible = true, transformation(origin = {-100, 0}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-120, 0}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealInput Ri "Connector of initial R (Removed)" annotation(
      Placement(visible = true, transformation(origin = {-100, -62}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-120, -62}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealOutput Sy "Output connector of S(Susceptible)" annotation(
      Placement(visible = true, transformation(origin = {100, 60}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, 62}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealOutput Iy "Output connector of I (Infectious)" annotation(
      Placement(visible = true, transformation(origin = {100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealOutput Ry "Output connector of R (Removed)" annotation(
      Placement(visible = true, transformation(origin = {100, -60}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, -60}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealOutput Vy "Output connector of Vaccination rate" annotation(
      Placement(visible = true, transformation(origin = {0, -100}, extent = {{-10, -10}, {10, 10}}, rotation = -90), iconTransformation(origin = {0, -110}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
  equation
    Vy = vaccine_effect * vaccine_rate;
    Sy = Si - Si * Vy;
    Iy = Ii;
    Ry = Ri + Si * Vy;
  annotation(
      Icon(graphics = {Text(origin = {-22, 24}, extent = {{-52, 32}, {94, -72}}, textString = "Vac")}, coordinateSystem(initialScale = 0.1)));
end cl_Vaccine;

Simulation results with vaccination

Cl_vaccine is put in front of the basic SIR model, the vaccination rate is set to 50%, and the vaccine itself is set so that the vaccinated person can be changed to 100% antibody carrier. This is equivalent to setting the initial values of S, I, and R of the basic model to (499.5, 1, 499.5). 10_SIR_vaccine_model.png

According to the simulation results, the maximum number of infected people can be reduced to about 1/20 with an inoculation rate of 50%. At the 70% vaccination rate, it was even lower by nearly an order of magnitude. 11_SIR_vaccine_graph.png

Summary

By modeling with OpenModelica, I think it was easy to simulate a simple infectious disease model by adding elements little by little. The idea presented here is very divisive, so if you have any major problems, I would appreciate it if you could give me some advice.

Recommended Posts

Implement the mathematical model "SIR model" of infectious diseases in OpenModelica (see the effect of the vaccine)
Implement the mathematical model "SIR model" of infectious diseases with OpenModelica
Implement the mathematical model "SIR model" of infectious diseases in OpenModelica (reflecting mortality rate and reinfection rate)
Implement the mathematical model "SIR model" of infectious diseases with OpenModelica (example of repeating regulation and deregulation)
Introduction of mathematical prediction model for infectious diseases (SIR model)
Mathematical prediction model for infectious diseases (SIR model): Case study (1)
Mathematical model of infectious disease epidemics
Implement part of the process in C ++
Sum of variables in a mathematical model
[SIR model analysis] Peak out of infection numbers in Japan and around the world ♬
Solving mathematical models of infectious disease epidemics in Python
Specify the lighting Model of SCN Material in Pythonista
Count the number of parameters in the deep learning model
Implement the solution of Riccati algebraic equations in Python
[SIR model analysis] Peak out of infection numbers in Japan and around the world ♬ Part 2