新冠肺炎 (Covid-19) 传播模拟(Matlab代码实现)

     目录

💥1 概述

📚2 运行结果

🎉3 参考文献

👨‍💻4 Matlab代码

💥1 概述

本次疫情传播呈现出典型的复杂网络特征,可以用复杂网络疾病传播模型进行有效分析。复杂网络经典的疾病传播模型包括SI模型、SIR模型、SIS模型、SEIR模型等。​

本文模拟人(点),考虑他们在空间(盒子)中移动。人们以随机的速度行走(v_x,v_y)。当这些人撞到盒子的墙壁时,他们会再次从盒子上反弹回来。在模拟开始时,只有少数人生病(用红色圆点表示)。一旦这些病人(红点)进入健康人(绿点)的附近,他们也会被感染(变成红色)。一段时间后,病人(红点)恢复(变成蓝色),不能再感染或被感染。

结果:

红感染绿健康蓝恢复

📚2 运行结果

主函数部分代码:

%% Student names
​
% Student: Sheik Farooq (419396) 
​
​
%% Command to clean the screen
clc;
clear;
close All;
​
%% Task 1
​
% Initialization
a = 0.01; % minimum x and y values
b = 1.99; % maximum x value (Actually 2, but better representation in graph, 1.99 was used)
c = 0.99; % maximum y value (Actually 1, but better representation in graph, 0.99 was used)
n = 100;  % number of individuals
dt = 0.001;
vel_min = -1;
vel_max = 1;
infected_initial = 10; % in percentage
​
n_infec = infected_initial*n/100;    % no. of infected people
n_hel = (100-infected_initial)*n/100;  % no. of healthy people
n_recov = n-n_infec-n_hel;           % no. of recovered people
​
Time = 0:dt:1;  % Time vector
​
% initial X and Y positions of the points
pos_x_infec = (b-a).*rand(n_infec,1) + a;  % Healthy
pos_x_infec = [pos_x_infec, dt*ones(size(pos_x_infec))];
pos_y_infec = (c-a).*rand(n_infec,1) + a;
​
pos_x_hel = (b-a).*rand(n_hel,1) + a;  % Infected
pos_y_hel = (c-a).*rand(n_hel,1) + a;
​
pos_x_rec = [];
pos_y_rec = [];
vel_x_rec = [];
vel_y_rec = [];
​
% initial point positions of healthy and infected points shown in graph
figure(1);
hold on;
plot(pos_x_hel,pos_y_hel, 'o','MarkerFaceColor', 'g','MarkerEdgeColor', 'g')
plot(pos_x_infec(:,1),pos_y_infec, 'o','MarkerFaceColor', 'r','MarkerEdgeColor', 'r')
​
% Velocities
vel_x_hel = (vel_max-vel_min).*rand(n_hel,1) + vel_min;  % Velocities of Healthy
vel_y_hel = (vel_max-vel_min).*rand(n_hel,1) + vel_min;
​
vel_x_infec = (vel_max-vel_min).*rand(n_infec,1) + vel_min;  % Velocities of infected
vel_y_infec = (vel_max-vel_min).*rand(n_infec,1) + vel_min;
​
​
v=VideoWriter('Pandamic_1.avi');    % saves dynamic graph as a video file
open(v);
​
​
for k=1:length(Time)   % Main "for" loop (1 loop (dt)== 0.001 sec 
  
    % new positions of the persons based on velocity and old position
    
    pos_x_new_hel = pos_x_hel + vel_x_hel.*dt;   % Healthy
    pos_y_new_hel = pos_y_hel + vel_y_hel.*dt;
    pos_x_hel = pos_x_new_hel;
    pos_y_hel = pos_y_new_hel;
    
    
    pos_x_new_infec = pos_x_infec(:,1) + vel_x_infec.*dt;   % Unhealthy
    pos_y_new_infec = pos_y_infec + vel_y_infec.*dt;
    pos_x_infec = [pos_x_new_infec pos_x_infec(:,2)+dt];
    pos_y_infec = pos_y_new_infec;
    
    pos_x_new_rec = pos_x_rec + vel_x_rec.*dt;   % Healthy
    pos_y_new_rec = pos_y_rec + vel_y_rec.*dt;
    pos_x_rec = pos_x_new_rec;
    pos_y_rec = pos_y_new_rec;
    
    % Recovery of the infected points
    
    for j=1:length(pos_x_infec(:,1))
        if pos_x_infec(j,2)>=0.35
            pos_x_rec = [pos_x_rec; pos_x_infec(j,1)];
            pos_y_rec = [pos_y_rec; pos_y_infec(j,1)];
            vel_x_rec = [vel_x_rec; vel_x_infec(j,1)];
            vel_y_rec = [vel_y_rec; vel_y_infec(j,1)];
            pos_x_infec(j,:) = [];
            % pos_x_infec(j,2) = [];
            pos_y_infec(j) = [];
            vel_x_infec(j) = [];
            vel_y_infec(j) = [];
            pos_x_infec = [pos_x_infec;[0,0]];
            pos_y_infec = [pos_y_infec;0];
            vel_x_infec = [vel_x_infec;0];
            vel_y_infec = [vel_y_infec;0];
            j=j-1;
        end
    end

🎉3 参考文献

[1]范如国,王奕博,罗明,张应青,朱超平.基于SEIR的新冠肺炎传播模型及拐点预测分析[J].电子科技大学学报,2020,49(03):369-374.

部分理论引用网络文献,若有侵权联系博主删除。

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

荔枝科研社

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值