{"id":5903,"date":"2020-03-18T12:51:56","date_gmt":"2020-03-18T17:51:56","guid":{"rendered":"https:\/\/blogs.mathworks.com\/cleve\/?p=5903"},"modified":"2020-03-19T13:41:10","modified_gmt":"2020-03-19T18:41:10","slug":"covid-19-simulator","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/cleve\/2020\/03\/18\/covid-19-simulator\/","title":{"rendered":"COVID-19 Simulator"},"content":{"rendered":"\r\n\r\n<div class=\"content\"><!--introduction--><!--\/introduction--><h3>Contents<\/h3><div><ul><li><a href=\"#5f61bc0d-5c32-4ca2-8c38-f3cdf55e6265\">Simulator<\/a><\/li><li><a href=\"#d2e52605-f9f2-47c6-8c0c-2527d3c6b5f1\">Animation<\/a><\/li><li><a href=\"#0a910465-9f08-4615-b8a2-5c5d7c70b6dd\">First frame<\/a><\/li><li><a href=\"#549980ff-ccce-4842-9c35-c399eb382796\">Final frame<\/a><\/li><li><a href=\"#1a366231-f6ad-43eb-ba27-8779df1bbb2f\">Full barrier<\/a><\/li><li><a href=\"#0b78d73e-a6bf-4564-bc43-7d5f255ba140\">No barrier<\/a><\/li><li><a href=\"#0957d2ca-f757-443e-b243-907cca25f655\">Larger population<\/a><\/li><li><a href=\"#5581e599-c0c4-46d6-a011-889d27709e3f\">Smaller population<\/a><\/li><li><a href=\"#b9cb9d29-b575-4271-9b55-822a960b2c07\">Software<\/a><\/li><\/ul><\/div><h4>Simulator<a name=\"5f61bc0d-5c32-4ca2-8c38-f3cdf55e6265\"><\/a><\/h4><pre class=\"codeinput\">   help <span class=\"string\">covid19<\/span>\r\n<\/pre><pre class=\"codeoutput\">  Epidemic simulation.\r\n  Inspired by Washington Post graphic by Harry Stevens, March 14, 2020.\r\n  https:\/\/www.washingtonpost.com\/graphics\/2020\/world\/corona-simulator\/?itid=sf_\r\n \r\n  These are the four types of individuals.\r\n \r\n  * Mobile.   Susceptible, on the move.\r\n              Blue (or green) circle, O.\r\n  * Static.   Susceptible, stay at home.\r\n              Smaller, darker blue circle, o.\r\n  * Infected. Infects other susceptible individuals within distance \"radius\".\r\n              Red-orange asterisk, *.\r\n  * Immune.   Was infected for \"duration\" steps.  No longer infectious.\r\n              Darker red x.\r\n \r\n  These are the seven controllable parameters, with their starting values.\r\n \r\n    n = 50;            population size\r\n    infected = .10;    initial infected fraction\r\n    static = .20;      static fraction\r\n    radius = .03;      infectious distance\r\n    duration = 200;    time of infection\r\n    speed = .03;       speed of propagation\r\n    barrier = .80;     barrier height\r\n \r\n  The epidemic starts in the upper right quadrant.\r\n  The epidemic ends when all infected individuals have become immune.\r\n\r\n    Folders named covid19\r\n\r\n       Desktop\\covid19\r\n\r\n<\/pre><h4>Animation<a name=\"d2e52605-f9f2-47c6-8c0c-2527d3c6b5f1\"><\/a><\/h4><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"http:\/\/blogs.mathworks.com\/cleve\/files\/covid19_gif.gif\" alt=\"\"> <\/p><h4>First frame<a name=\"0a910465-9f08-4615-b8a2-5c5d7c70b6dd\"><\/a><\/h4><p>The animation begins with 5 infections in the upper right quadrant.  There are 45 unaffected.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"http:\/\/blogs.mathworks.com\/cleve\/files\/covid19_start_1.png\" alt=\"\"> <\/p><h4>Final frame<a name=\"549980ff-ccce-4842-9c35-c399eb382796\"><\/a><\/h4><p>The animation ends when there is no more infection. Three individuals have never been infected.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"http:\/\/blogs.mathworks.com\/cleve\/files\/covid19_final_1.png\" alt=\"\"> <\/p><h4>Full barrier<a name=\"1a366231-f6ad-43eb-ba27-8779df1bbb2f\"><\/a><\/h4><p>Final frame with complete barrier.  Left half is not infected.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"http:\/\/blogs.mathworks.com\/cleve\/files\/covid19_final_2.png\" alt=\"\"> <\/p><h4>No barrier<a name=\"0b78d73e-a6bf-4564-bc43-7d5f255ba140\"><\/a><\/h4><p>One individual is never infected.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"http:\/\/blogs.mathworks.com\/cleve\/files\/covid19_final_3.png\" alt=\"\"> <\/p><h4>Larger population<a name=\"0957d2ca-f757-443e-b243-907cca25f655\"><\/a><\/h4><p>Everybody is eventually infected, and in fewer time steps.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"http:\/\/blogs.mathworks.com\/cleve\/files\/covid19_final_4.png\" alt=\"\"> <\/p><h4>Smaller population<a name=\"5581e599-c0c4-46d6-a011-889d27709e3f\"><\/a><\/h4><p>Less infection.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"http:\/\/blogs.mathworks.com\/cleve\/files\/covid19_final_5.png\" alt=\"\"> <\/p><h4>Software<a name=\"b9cb9d29-b575-4271-9b55-822a960b2c07\"><\/a><\/h4><p>The code is one of the experiments in version 5.0 of Cleve_Lab on the MATLAB Central File Exchange, <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/59085-cleve_lab\">available here<\/a>.<\/p><p>The code is on the File Exchange by itself, <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/74601-covid19-simulator\">available here<\/a>.<\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_dc1403f55f8a4363b201f27052883333() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='dc1403f55f8a4363b201f27052883333 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' dc1403f55f8a4363b201f27052883333';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        copyright = 'Copyright 2020 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add copyright line at the bottom if specified.\r\n        if (copyright.length > 0) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n\r\n        d.title = title + ' (MATLAB code)';\r\n        d.close();\r\n    }   \r\n     --> <\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_dc1403f55f8a4363b201f27052883333()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n      the MATLAB code <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2019b<br><\/p><\/div><!--\r\ndc1403f55f8a4363b201f27052883333 ##### SOURCE BEGIN #####\r\n%% COVID-19 Simulator\r\n\r\n%% Simulator\r\n\r\n   help covid19\r\n   \r\n%% Animation\r\n%\r\n% <<covid19_gif.gif>>\r\n\r\n%% First frame\r\n% The animation begins with 5 infections in the upper\r\n% right quadrant.  There are 45 unaffected.\r\n%\r\n% <<covid19_start_1.png>>\r\n\r\n%% Final frame\r\n% The animation ends when there is no more infection.\r\n% Three individuals have never been infected.\r\n%\r\n% <<covid19_final_1.png>>\r\n\r\n%% Full barrier\r\n% Final frame with complete barrier.  Left half is not infected.\r\n%\r\n% <<covid19_final_2.png>>\r\n  \r\n%% No barrier\r\n% One individual is never infected.\r\n%\r\n% <<covid19_final_3.png>>\r\n\r\n%% Larger population\r\n% Everybody is eventually infected, and in fewer time steps.\r\n%\r\n% <<covid19_final_4.png>>\r\n\r\n%% Smaller population\r\n% Less infection.\r\n%\r\n% <<covid19_final_5.png>>\r\n  \r\n%% Software\r\n% The code is one of the experiments in version 5.0 of Cleve_Lab on the \r\n% MATLAB Central File Exchange,\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/59085-cleve_lab\r\n% available here>.\r\n%\r\n% The code is on the File Exchange by itself,\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/74601-covid19-simulator\r\n% available here>.\r\n\r\n\r\n##### SOURCE END ##### dc1403f55f8a4363b201f27052883333\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/covid19_start_1.png\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div><p>\r\n\r\nContentsSimulatorAnimationFirst frameFinal frameFull barrierNo barrierLarger populationSmaller populationSoftwareSimulator   help covid19\r\n  Epidemic simulation.\r\n  Inspired by Washington Post... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/cleve\/2020\/03\/18\/covid-19-simulator\/\">read more >><\/a><\/p>","protected":false},"author":78,"featured_media":5923,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[34,4,39],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/5903"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/users\/78"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/comments?post=5903"}],"version-history":[{"count":7,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/5903\/revisions"}],"predecessor-version":[{"id":5933,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/5903\/revisions\/5933"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/media\/5923"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/media?parent=5903"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/categories?post=5903"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/tags?post=5903"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}