Skip to content

Commit

Permalink
Fix missing 1/N in epid.mo
Browse files Browse the repository at this point in the history
  • Loading branch information
SG-phimeca committed Nov 8, 2024
1 parent 6716944 commit 22f3ae5
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 29 deletions.
4 changes: 2 additions & 2 deletions doc/application/plot_metamodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
# simulate the FMU.
# The simulation inputs and outputs will be used to train the metamodel.

inputLaw = ot.Uniform(0.001, 0.01)
inputLaw = ot.Uniform(1.5, 2.5)
inputSample = inputLaw.getSample(30)
outputFMUSample = function(inputSample)

Expand Down Expand Up @@ -205,7 +205,7 @@ def globalMetamodel(sample):
ot.Show(graph)

# %%
# As the epidemiological model considers a population size of 700, the residual
# As the epidemiological model considers a population size of 763, the residual
# mean error on the field is acceptable.

# %%
Expand Down
8 changes: 4 additions & 4 deletions doc/example/dynamic/plot_dyn_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# Define the time grid for the FMU's output. The last value of the time grid,
# here 10., will define the FMU stop time for simulation.

mesh = ot.RegularGrid(0.0, 0.1, 100)
mesh = ot.RegularGrid(0.0, 0.1, 2000)
meshSample = mesh.getVertices()
print(meshSample)

Expand All @@ -47,7 +47,7 @@
inputs_fmu=["infection_rate"],
outputs_fmu=["infected"],
start_time=0.0,
final_time=10.0,
final_time=200.0,
)
print(type(function))

Expand All @@ -61,7 +61,7 @@
# Simulate the function on an input :py:class:`openturns.Point` yields an output
# :py:class:`openturns.Sample`, corresponding to the output evolution over time:

inputPoint = ot.Point([0.007])
inputPoint = ot.Point([2.0])
outputSample = function(inputPoint)

plt.xlabel("FMU simulation time (s)")
Expand All @@ -73,7 +73,7 @@
# Simulate the function on a input :py:class:`openturns.Sample` yields a set of
# fields called :py:class:`openturns.ProcessSample`:

inputSample = ot.Sample([[0.007], [0.005], [0.003]])
inputSample = ot.Sample([[2.0], [2.25], [2.5]])
outputProcessSample = function(inputSample)
print(outputProcessSample)

Expand Down
6 changes: 3 additions & 3 deletions doc/example/dynamic/plot_dyn_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
temporary_file = "initialization.mos"
with open(temporary_file, "w") as f:
f.write("total_pop = 500;\n")
f.write("healing_rate = 0.02;\n")
f.write("healing_rate = 0.5;\n")

# %%
# If no initial value is provided for an input / parameter, it is set to its
Expand Down Expand Up @@ -79,8 +79,8 @@
# function input variable ``infection_rate`` to propagate its uncertainty
# through the model:

lawInfected = ot.Normal(0.01, 0.003)
inputSample = lawInfected.getSample(10)
law_infection_rate = ot.Normal(2.0, 0.25)
inputSample = law_infection_rate.getSample(10)
outputProcessSample = function(inputSample)

# %%
Expand Down
26 changes: 14 additions & 12 deletions doc/fmus/epid.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ time writes:
.. math::
\begin{aligned}
\frac{\partial S}{\partial t}(t) &= - \beta S(t) I(t) \\
\frac{\partial I}{\partial t}(t) &= \beta S(t) I(t) - \gamma I(t) \\
\frac{\partial S}{\partial t}(t) &= - \frac{\beta}{N} S(t) I(t) \\
\frac{\partial I}{\partial t}(t) &= \frac{\beta}{N} S(t) I(t) - \gamma I(t) \\
\frac{\partial R}{\partial t}(t) &= \gamma I(t)
\end{aligned}
Expand All @@ -36,25 +36,27 @@ This model is implemented in Modelica language. The default simulation time is 5
model epid
parameter Real total_pop = 700;
parameter Real total_pop = 763;
parameter Real infection_rate = 2.0;
parameter Real healing_rate = 0.5;
Real infected;
Real susceptible;
Real removed;
parameter Real infection_rate = 0.007;
parameter Real healing_rate = 0.02;
initial equation
infected = 1;
removed = 0;
total_pop = infected + susceptible + removed;
equation
der(susceptible) = - infection_rate*infected*susceptible;
der(infected) = infection_rate*infected*susceptible - healing_rate*infected;
der(removed) = healing_rate*infected;
der(susceptible) = - infection_rate * infected * susceptible / total_pop;
der(infected) = infection_rate * infected * susceptible / total_pop -
healing_rate * infected;
der(removed) = healing_rate * infected;
annotation(
experiment(StartTime = 0, StopTime = 50, Tolerance = 1e-6, Interval = 0.1));
experiment(StartTime = 0.0, StopTime = 200.0, Tolerance = 1e-6, Interval = 0.1));
end epid;
We focus on the effect of the ``infection_rate`` and ``healing_rate`` on the evolution of the ``infected`` category.
Expand Down
16 changes: 8 additions & 8 deletions otfmi/example/file/epid.mo
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
model epid

parameter Real total_pop = 700;
parameter Real total_pop = 763;
parameter Real infection_rate = 2.0;
parameter Real healing_rate = 0.5;

Real infected;
Real susceptible;
Real removed;

parameter Real infection_rate = 0.007;
parameter Real healing_rate = 0.02;

initial equation
infected = 1;
removed = 0;
total_pop = infected + susceptible + removed;

equation
der(susceptible) = - infection_rate*infected*susceptible;
der(infected) = infection_rate*infected*susceptible - healing_rate*infected;
der(removed) = healing_rate*infected;
der(susceptible) = - infection_rate * infected * susceptible / total_pop;
der(infected) = infection_rate * infected * susceptible / total_pop -
healing_rate * infected;
der(removed) = healing_rate * infected;

annotation(
experiment(StartTime = 0, StopTime = 50, Tolerance = 1e-6, Interval = 0.1));
experiment(StartTime = 0.0, StopTime = 200.0, Tolerance = 1e-6, Interval = 0.1));
end epid;

0 comments on commit 22f3ae5

Please sign in to comment.