[Scilab-users] Covid19 model
Claus Futtrup
cfuttrup at gmail.com
Thu Apr 30 16:40:23 CEST 2020
Hi Scilabers
On 17. April I sent an email, but I think it wasn't released to the
mailing list, I only find it online here:
http://mailinglists.scilab.org/Scilab-users-Covid19-model-td4040626.html
Here's the email again (without attachment, see above link if you'd like
to view the attachment)
A friend (Lars Risbo) published some MATLAB code in LinkedIn for
simulating the infection with a company lockdown after some time. I
figured I'd try to convert it to Scilab.
The code usesODE45and I'm not sure that I understand how to convert this
MATLAB code to Scilab. I hope you can explain what I need to do to make
the code work. Some of the original MATLAB code is found in the comments.
// covid19risbo.sce//// SEIRsim1//
Susceptible-Exposed-Infectious-Recovered (SEIR)functiondydt=odefun(t,
y)ift<daysR=R0;elseR=0.6;// Change reproductive rate after
lockdownendA=[00-delta*R*y(1)/Npop000;...0-gamdelta*R*y(1)/Npop000;...0gam-delta000;...00delta*(1-Fhosp)000;...00delta*Fhosp0-1/Thosp0;...00delta*R*y(1)/Npop000];dydt=A*y;endBegin=datenum(2020,02,20,0,0,0);//
begin dateDlock=datenum(2020,03,12,0,0,0);// date of
lockdowndays=Dlock-Begin;R0=2.6;// inital R valuegam=1/3;// gamma, the
inverse of average latent timedelta=1/5;// inv time constant which
infectious people either recover or enter hospitalFhosp=0.16;// fraction
of recovering people going to hospitalThosp=14;// average time of
hospitalisationNpop=6e6;// total initial population of
sensitivey0=[Npop;50;50;0;0;0];// [S E I R Hosp ] intial
cond.t1=0:60;y1=ode(y0,0,60,odefun);// [t1,y1] = ode45(@odefun,[0
60],y0); // run 1st
scernarioidx=[3:6];scf();a=gca();plot(Begin+t1,y1(:,idx),'-');//
semilogy(Begin+t1,y1(:,idx),'-','LineWidth',3)a.log_flags="nln";xlabel('Date')ylabel('Number
of cases')xgrid();// ax=gca;// ax.YLim=[10
max(max(y2(:,idx)))];xtitle({'Danish Corona lock down on 20.03.12, vs 14
days later','R goes from 2.6 to 0.6 at
lockdown'});legend('Infected','Recovered','Hospitalised','Total Cases');
P.S. Attached a simple graph of what the output should look like (file
covid19risbo.jpg < 50 kb), at least partially - because I deleted an
alternative case with a later lockdown date = dashed lines.
Best regards,
Claus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20200430/79132534/attachment.htm>
More information about the users
mailing list