zwicker-group / py-pde

Python package for solving partial differential equations using finite differences.

Home Page:https://py-pde.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What is the easiest way of topping field values within the framework of the SIR example?

HannoSpreeuw opened this issue · comments

Looking at the SIR model example what would be the easiest way to limit the values of one of the fields?

By means of evolution_rate the three fields s, i and r evolve.
What if one of those three fields cannot exceed some value because of some constraint?

Say that i cannot exceed some value alpha. So if i became larger than alpha it would have to be set equal to alpha.

How would you implement that?

I guess one could use to_scalar for a ScalarField, like this:

j = i.to_scalar(lambda f: numpy.fmin(f,alpha))