Skip to content
Snippets Groups Projects
Commit 62b4681a authored by B.Brodda's avatar B.Brodda
Browse files

update 2/11

parent 8b1ccc55
No related branches found
No related tags found
1 merge request!2update 2/11
......@@ -22,7 +22,7 @@ module CompartmentModels
gE::Float64 # rate of E to I compartment
gI::Float64 # rate of I to R compartment
contactFrequency::Float64
population::Float64 = 0 # total population, set automatically in solveSEIR from u0
#population::Float64 = 0 # total population, set automatically in solveSEIR from u0
end
# Inplace modification due to performance, see https://docs.sciml.ai/DiffEqDocs/stable/tutorials/faster_ode_example/
......@@ -32,11 +32,11 @@ module CompartmentModels
# I Infected
# R Recovered (or Dead)
# parameters are log parameters
function SEIR!(du, u, p::NamedTuple{(:beta,:gE,:gI,:contactFrequency,:population)}, t)
function SEIR!(du, u, p::NamedTuple{(:beta,:gE,:gI,:contactFrequency)}, t)
# dS/dt
du[1] = -u[1] * u[3] * exp(p.beta) * exp(p.contactFrequency) / p.population
du[1] = -u[1] * u[3] * exp(p.beta) * exp(p.contactFrequency) / sum(u)
# dE/dt
du[2] = u[1] * u[3] * exp(p.beta) * exp(p.contactFrequency) / p.population - u[2] * exp(p.gE)
du[2] = u[1] * u[3] * exp(p.beta) * exp(p.contactFrequency) / sum(u) - u[2] * exp(p.gE)
# dI/dt
du[3] = u[2] * exp(p.gE) - u[3] * exp(p.gI)
# dR/dt
......@@ -48,7 +48,7 @@ module CompartmentModels
# E Exposed
# I Infected
# R Recovered (or Dead)
function solveSEIR(u0, parameters::NamedTuple{(:beta,:gE,:gI,:contactFrequency,:population)}, tspan, start_date)
function solveSEIR(u0, parameters::NamedTuple{(:beta,:gE,:gI,:contactFrequency)}, tspan, start_date)
prob = ODEProblem(SEIR!, u0, tspan, parameters);
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment