From 5bb467b1eefae8de52b2e74213ea7bd6734d8093 Mon Sep 17 00:00:00 2001 From: Orestis Malaspinas <orestis.malaspinas@hesge.ch> Date: Sun, 22 Mar 2020 22:46:47 +0100 Subject: [PATCH] added tp edo in md --- Makefile | 4 ++++ covid/python/covid.py | 30 +++++++++++++++++------------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 907a770..b5d4f18 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,10 @@ deploy: all make -C tpIntegrales cp tpIntegrales/*.pdf mti/tpIntegrales/ cp tpIntegrales/tp_integrales_conv.html mti/tpIntegrales/index.html + mkdir -p mti/tpEdo + make -C tpEdo + cp tpEdo/*.pdf mti/tpEdo/ + cp tpEdo/tpEquadiffs.html mti/tpEdo/index.html clean: rm -rf *.html *.pdf diff --git a/covid/python/covid.py b/covid/python/covid.py index a65c786..07754a5 100644 --- a/covid/python/covid.py +++ b/covid/python/covid.py @@ -2,7 +2,7 @@ import numpy as np import matplotlib.pyplot as plt swiss = np.array([2.100350058, 3.150525088, 4.900816803, 6.534422404, 10.501750292, 13.302217036, 24.970828471, 31.271878646, 39.323220537, 43.640606768, 57.292882147, 76.079346558, 100.116686114, 131.271878646, 158.576429405, 256.709451575, 256.709451575, 268.378063011, 309.218203034, 353.325554259, 453.675612602]) -swiss = np.array([18, 27, 42, 56, 90, 114, 214, 268, 337, 374, 491, 652, 858, 1125, 1359, 2200, 2200, 2300, 2650, 3028, 3888]) +swiss = np.array([18, 27, 42, 56, 90, 114, 214, 268, 337, 374, 491, 652, 858, 1125, 1359, 2200, 2200, 2300, 2650, 3028, 3888]) / 0.02 days = np.array(range(1,len(swiss)+1)) @@ -27,18 +27,21 @@ def timestep(S0, I0, R0, dt, beta, lamb, N): S0 = 8000000 I0 = swiss[0] R0 = 0 -max_t = 50*days[len(swiss)-1] -n_steps = 10000 +max_t = 3*days[len(swiss)-1] +n_steps = 100000 dt = max_t / n_steps N = compute_n(S0, I0, R0) lamb = 1.0 / 14.0 -beta_1 = 0.34 -beta_2 = beta_1 / 100 +beta_1 = 0.35 +beta_2 = beta_1 / 10 beta = beta_1 +R0 = beta / lamb +print(R0) + s_list = [S0] r_list = [R0] i_list = [I0] @@ -49,20 +52,21 @@ for i in range(0, n_steps): i_list.append(I1) r_list.append(R1) t_list.append(t_list[i]+dt) - if (t_list[i+1] >= 27 and t_list[i+1] <= 127) : - beta = beta_2 - else: - beta = beta_1 + # if (R1 >= 0.9 * N): + # print(t_list[i]+dt) + # break + # if (t_list[i+1] < 27) : + # beta = beta_1 + # elif (I1 > 0.01*N) : + # beta = beta_2 # else: - # beta = 1 + # beta = beta_1 s = np.array(s_list) r = np.array(r_list) ii = np.array(i_list) t = np.array(t_list) - -print(t) - +s plt.semilogy(t, s, 'b') plt.semilogy(t, r, 'r') plt.semilogy(t, ii, 'k') -- GitLab