# SIR Model - Finding Relationship between Contact Rate and Peak Infection Rate

## Summary

In this set of exercises, a script is developed that solves the coupled system of ordinary differential equations making up an SIR model of virus spread. The peak value computed for the infected population is found and the process repeats over several values of contact rate. This simple model gives students an example of using a ODE solver, spline interpolation, and function optimization all together to get a useful result.

## Learning Goals

The basic concepts of solution of ODEs, optimization and interpolation are used extensively in engineering and this exercise should serve to review those topics. MATLAB is used throughout - this is a LiveScript-based set of exercises. The interesting part is seeing how the different numerical tools (MATLAB tools) are used together to get a result of interest that is simple to understand. It is not set up for an presentation, but it could be reworked slightly to accommodate that.

## Context for Use

The exercise assumes a moderate degree of familiarity with MATLAB. The interesting part is how it couples together the use of subfunctions, ODE45, fminbnd, spline and various plotting routines, all in one problem. As a homework assignment, I think it would take a few hours to go through the first time. I have included solutions. Everything is in LiveScript.

## Description and Teaching Materials

The assignment is self contained. The equations for the SIR model were captured from Wikipedia but are common knowledge. MATLAB is required as is access to the functions fminbnd, spline, ppval, and ode45,
Step 0 - Introduction - SIR model problem (MATLAB Live Script 35kB Aug13 20)
Step 1 - finding a minimum (warm up problem) (MATLAB Live Script 45kB Aug13 20)
Step 2 - finding a maximum (MATLAB Live Script 45kB Aug13 20)

Step 3 - Interpolating data with a spline (MATLAB Live Script 44kB Aug13 20)

Step 4 - Finding max of interpolated function (MATLAB Live Script 44kB Aug13 20)

step5_solving_system_ODEs.mlx (MATLAB Live Script 36kB Aug13 20)

step6_finding_max_of_solution_to_ODE.mlx (MATLAB Live Script 48kB Aug13 20)

step7_SIR_model.mlx (MATLAB Live Script 58kB Aug13 20)

step8_bring_it_all_together.mlx (MATLAB Live Script 84kB Sep8 20)

step9_parametric_study.mlx (MATLAB Live Script 334kB Aug13 20)

step10_final_result.mlx (MATLAB Live Script 39kB Aug13 20)

## Teaching Notes and Tips

The solution is included at the end of every step. Teachers may wish to provide the students the problems without the solutions.

## Assessment

This activity was used in a junior-level MATLAB class for mechanical engineering students soon after we all went remote at the outbreak of COVID-19. It was classified as a "Practice what you have learned" problem - intended to exercise tools they had already used but likely had not used together.

## References and Resources

No external resources are necessary.