Skip to content

Commit

Permalink
Merge pull request #433 from isaacsas/doc_tweaks
Browse files Browse the repository at this point in the history
update docs for Catalyst 14 and new saveat behavior
  • Loading branch information
isaacsas authored Aug 5, 2024
2 parents 2bedae4 + 423133b commit afae6f6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 23 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ The documentation includes
- [the JumpProcesses.jl API documentation](https://docs.sciml.ai/JumpProcesses/stable/api/).

## Contributions welcomed!
Contact us in sciml-bridged on Slack to discuss where to get started, the [`Help wanted`](https://github.com/SciML/JumpProcesses.jl/issues/431) issue, or just open a PR to address an open issue or add new functionality. Contributions, no matter how small, are always welcome and appreciated,

Contact us in sciml-bridged on Slack to discuss where to get started, the [`Help wanted`](https://github.com/SciML/JumpProcesses.jl/issues/431) issue, or just open a PR to address an open issue or add new functionality. Contributions, no matter how small, are always welcome and appreciated,
including documentation editing/writing. See also the [contribution section](#contributing-and-getting-help).

## Installation
Expand Down
6 changes: 2 additions & 4 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ DensityInterface = "b429d917-457f-4dbc-8f4c-0cc954292b1d"
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
GR_jll = "d2c73de3-f751-5644-a686-071e5b155ba9"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
JumpProcesses = "ccbc3e58-028d-4f4c-8cd5-9ae44345cda5"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Expand All @@ -14,16 +13,15 @@ StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
StochasticDiffEq = "789caeaf-c7a9-5a7d-9973-96adeb23e2a0"

[compat]
Catalyst = "13.0"
Catalyst = "14.0"
DensityInterface = "0.4"
DifferentialEquations = "7.11"
Distributions = "0.25"
Documenter = "1.1"
GR_jll = "0.72"
Graphs = "1.9"
JumpProcesses = "9.8"
OrdinaryDiffEq = "6.59"
Plots = "1.39"
PointProcesses = "0.4, 0.5"
PointProcesses = "0.5"
StableRNGs = "1.0"
StochasticDiffEq = "6.63"
6 changes: 2 additions & 4 deletions docs/src/assets/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ DensityInterface = "b429d917-457f-4dbc-8f4c-0cc954292b1d"
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
GR_jll = "d2c73de3-f751-5644-a686-071e5b155ba9"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
JumpProcesses = "ccbc3e58-028d-4f4c-8cd5-9ae44345cda5"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Expand All @@ -14,16 +13,15 @@ StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
StochasticDiffEq = "789caeaf-c7a9-5a7d-9973-96adeb23e2a0"

[compat]
Catalyst = "13.0"
Catalyst = "14.0"
DensityInterface = "0.4"
DifferentialEquations = "7.11"
Distributions = "0.25"
Documenter = "1.1"
GR_jll = "0.72"
Graphs = "1.9"
JumpProcesses = "9.8"
OrdinaryDiffEq = "6.59"
Plots = "1.39"
PointProcesses = "0.4"
PointProcesses = "0.5"
StableRNGs = "1.0"
StochasticDiffEq = "6.63"
36 changes: 22 additions & 14 deletions docs/src/tutorials/discrete_stochastic_example.md
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ many cases when using jump problems, you may wish to decrease the saving
pressure given by large numbers of jumps. To do this, you set the
`save_positions` keyword argument to `JumpProblem`. Just like for other
[callbacks](https://docs.sciml.ai/DiffEqDocs/stable/features/callback_functions/),
this is a tuple `(bool1, bool2)` which sets whether to save `u` before or
this is a tuple `(bool1, bool2)` which sets whether to save `u` before and/or
after a jump. If we do not want to save at every jump, we would thus pass:

```@example tut2
Expand All @@ -669,23 +669,31 @@ spaced grid:

```@example tut2
sol = solve(jump_prob, SSAStepper(); saveat = 10.0)
plot(sol, label = ["S(t)" "I(t)" "R(t)"], marker = :o)
```

Notice that our plot is now defined at precisely the specified time points, and
for time values in between those points piecewise-linear interpolation is used
in graphing the solution. Note, however, that evaluation of the solution object
still treats the solution as piecewise constant, and so `sol` should not be
explicitly evaluated at any times besides the times at which it was saved, i.e.
notice that `sol(15.0)` does not interpolate the solution vectors at times `10`
and `20` below, but is instead the same as the solution at time `10`:

# we plot each solution component separately since
# the graph should no longer be a step function
plot(sol.t, sol[1, :]; marker = :o, label = "S(t)", xlabel = "t")
plot!(sol.t, sol[2, :]; marker = :x, label = "I(t)", xlabel = "t")
plot!(sol.t, sol[3, :]; marker = :d, label = "R(t)", xlabel = "t")
```@example tut2
sol(10.0), sol(15.0), sol(20.0)
```

Notice that our plot (and solutions) are now defined at precisely the specified
time points. *It is important to note that interpolation of the solution object
will no longer be exact for a pure jump process, as the solution values at jump
times have not been stored. i.e for `t` a time we did not save at `sol(t)` will
no longer give the exact value of the solution at `t`.*
*It is important to keep in mind that neither plotting or evaluation of the
solution object will be exact for a pure jump process when using `saveat` except
for the times given via `saveat`. This is because the solution values at jump
times have not been stored. i.e for `t` a time for which we did not save the
state, `sol(t)` will no longer give the exact value of the solution at `t`.*

In summary, the jump callback will save the state variable `u` before and
after the jump whenever `save_positions = (true, true)`. All other saving
behavior is delegated to the integrator and controlled via keyword arguments to `solve` such as `saveat`.
In summary, the jump callback will save the state variable `u` before and after
the jump whenever `save_positions = (true, true)`. All other saving behavior is
delegated to the integrator and controlled via keyword arguments to `solve` such
as `saveat`.

## Defining the Jumps Directly: Mixing `ConstantRateJump`/`VariableRateJump` and `MassActionJump`

Expand Down

0 comments on commit afae6f6

Please sign in to comment.