Skip to content

Commit

Permalink
Merge e082f6c into 1f8b6b0
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacsas committed Sep 16, 2021
2 parents 1f8b6b0 + e082f6c commit 0a794bb
Show file tree
Hide file tree
Showing 15 changed files with 386 additions and 226 deletions.
17 changes: 14 additions & 3 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,22 @@
## Catalyst unreleased (master branch)
- **BREAKING:** added a dependency on Nemo.jl for integer matrix linear algebra methods.
- Added `incidencematgraph`, `linkageclasses`, `deficiency`, `subnetworks`, `linkagedeficiency`, `isreversible` and `isweaklyreversible` API functions.
- Added the ability to compose `ReactionSystem`s via subsystems, and include
either `ODESystem`s or `NonlinearSystem`s as subsystems. Note, if using
subsystems it is not currently possible to convert to a `JumpSystem`. It is
also not possible to include either `SDESystem`s or `JumpSystems` as
subsystems.
- Depreciated `merge`, use `ModelingToolkit.extend` instead.
- Depreciated `params` and `numparams` (use `ModelingToolkit.parameters` to get
all parameters of a system and all subsystems, or use `reactionparams` to get
all parameters of a system and all `ReactionSystem` subsystems. The latter
correspond to those parameters used within `Reaction`s.)

## Catalyst 9.0
*1.* **BREAKING:** `netstoichmat`, `prodstoichmat` and `substoichmat` are now transposed to be
number of species by number of reactions. This is more consistent with the chemical
reaction network literature for stoichiometry matrices.
*1.* **BREAKING:** `netstoichmat`, `prodstoichmat` and `substoichmat` are now
transposed to be number of species by number of reactions. This is more
consistent with the chemical reaction network literature for stoichiometry
matrices.

*2.* `reactioncomplexmap` added to provide a mapping from reaction complexes to
reactions they participate in.
Expand Down
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ julia = "1.5"
[extras]
Graphviz_jll = "3c863552-8265-54e4-a6dc-903eb78fde85"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
Expand All @@ -48,4 +49,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[targets]
test = ["Graphviz_jll", "LinearAlgebra", "OrdinaryDiffEq", "Random", "SafeTestsets", "StableRNGs", "Statistics", "SteadyStateDiffEq", "StochasticDiffEq", "Test", "Unitful"]
test = ["Graphviz_jll", "LinearAlgebra", "NonlinearSolve", "OrdinaryDiffEq", "Random", "SafeTestsets", "StableRNGs", "Statistics", "SteadyStateDiffEq", "StochasticDiffEq", "Test", "Unitful"]
29 changes: 17 additions & 12 deletions docs/src/api/catalyst_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,25 @@ ReactionSystem
```@docs
species
speciesmap
params
ModelingToolkit.parameters
reactionparams
paramsmap
reactions
numspecies
numparams
numreactions
numreactionparams
```

## ModelingToolkit-Inherited Accessor Functions
- `ModelingToolkit.get_eqs(sys)`: The reactions of the system (ignores subsystems).
- `ModelingToolkit.equations(sys)`: Collects all reactions and equations from
the system and all subsystems.
- `ModelingToolkit.get_states(sys)`: The set of chemical species in the system (ignores subsystems).
- `ModelingToolkit.states(sys)`: Collects all species and states from the system and all subsystems.
- `ModelingToolkit.get_ps(sys)`: The parameters of the system (ignores subsystems).
- `ModelingToolkit.parameters(sys)`: Collects all parameters from the system and all subsystems.
- `ModelingToolkit.get_iv(sys)`: The independent variable of the system, usually time.

## Basic Reaction Properties
```@docs
ismassaction
Expand All @@ -98,21 +109,14 @@ netstoichmat
reactionrates
```

## Composition and Accessor Functions for [`ReactionSystem`](@ref)s
- `ModelingToolkit.get_eqs(sys)` or `equations(sys)`: The reactions that define the system.
- `ModelingToolkit.get_states(sys)` or `states(sys)`: The set of chemical species in the system.
- `ModelingToolkit.get_ps(sys)` or `parameters(sys)`: The parameters of the system.
- `ModelingToolkit.get_iv(sys)`: The independent variable of the reaction
system, usually time.

## Functions to Extend a Network
```@docs
@add_reactions
addspecies!
addparam!
addreaction!
merge!(network1::ReactionSystem, network2::ReactionSystem)
merge(network1::ReactionSystem, network2::ReactionSystem)
ModelingToolkit.extend
ModelingToolkit.compose
```

## Network Analysis and Representations
Expand All @@ -136,8 +140,9 @@ isweaklyreversible

## Network Comparison
```@docs
==(rn1::ReactionSystem, rn2::ReactionSystem)
==(rn1::Reaction, rn2::Reaction)
isequal_without_names
==(rn1::ReactionSystem, rn2::ReactionSystem)
```

## Network Visualization
Expand Down
2 changes: 1 addition & 1 deletion docs/src/tutorials/advanced_examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ tspan = (0.,4.)
u0 = [5.]
osys = convert(ODESystem, rs)
u0map = map((x,y) -> Pair(x,y), species(rs), u0)
pmap = map((x,y) -> Pair(x,y), params(rs), p)
pmap = map((x,y) -> Pair(x,y), parameters(rs), p)
oprob = ODEProblem(osys, u0map, tspan, pmap)
sol = solve(oprob, Tsit5())
```
Expand Down
2 changes: 1 addition & 1 deletion docs/src/tutorials/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ called `rn`). The generated `ReactionSystem` can be converted to a differential
equation model via
```julia
osys = convert(ODESystem, rn)
oprob = ODEProblem(osys, Pair.(species(rn),u0), tspan, Pair.(params(rn),p))
oprob = ODEProblem(osys, Pair.(species(rn),u0), tspan, Pair.(parameters(rn),p))
```
or more directly via
```julia
Expand Down
5 changes: 3 additions & 2 deletions docs/src/tutorials/generated_systems.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ API method listed first:

* [`species(rn)`](@ref) and `states(rn)` is a vector of all the chemical
species within the system, each represented as a `ModelingToolkit.Term`.
* [`params(rn)`](@ref) and `parameters(rn)` is a vector of all the parameters
* [`parameters(rn)`](@ref) is a vector of all the parameters
within the system, each represented as a `ModelingToolkit.Sym`.
* [`reactions(rn)`](@ref) and `equations(rn)` is a vector of all the
`Reaction`s within the system.
Expand Down Expand Up @@ -37,4 +37,5 @@ Empty `ReactionSystem`s can be generated via [`make_empty_network`](@ref) or
[`@reaction_network`](@ref) with no arguments (giving one argument to the latter
will specify a system name). `ReactionSystem`s can be programmatically extended
using [`addspecies!`](@ref), [`addparam!`](@ref), [`addreaction!`](@ref),
[`@add_reactions`](@ref), or composed using `merge` and `merge!`.
[`@add_reactions`](@ref), or composed using [`ModelingToolkit.extend`](@ref) and
`ModelingToolkit.compose`](@ref).
2 changes: 1 addition & 1 deletion docs/src/tutorials/models.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ sol = solve(prob, Tsit5())
```
Here, the order of unknowns in `u0` and `p` matches the order that species and
parameters first appear within the DSL. They can also be determined by examining
the ordering within the [`species(rn)`](@ref) and [`params(rn)`](@ref) vectors,
the ordering within the [`species(rn)`](@ref) and [`parameters(rn)`](@ref) vectors,
or accessed more explicitly through the [`speciesmap(rn)`](@ref) and
[`paramsmap(rn)`](@ref) dictionaries, which map the ModelingToolkit `Term`s
and/or `Sym`s corresponding to each species or parameter to their integer id.
Expand Down
4 changes: 2 additions & 2 deletions docs/src/tutorials/using_catalyst.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ species(repressilator)
P₃(t)
```
```julia
params(repressilator)
parameters(repressilator)
```
```julia
7-element Array{Sym{ModelingToolkit.Parameter{Real}},1}:
Expand Down Expand Up @@ -198,7 +198,7 @@ instead pass `odesys` directly, provided we construct mappings from each species
to their initial value, and each parameter to their value like:
```julia
u₀map = Pair.(species(repressilator), u₀)
pmap = Pair.(params(repressilator), p)
pmap = Pair.(parameters(repressilator), p)
oprob2 = ODEProblem(osys, u₀map, tspan, pmap)
```
`oprob` and `oprob2` are functionally equivalent, each representing the same
Expand Down
16 changes: 10 additions & 6 deletions src/Catalyst.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,31 @@ $(DocStringExtensions.README)
module Catalyst

using DocStringExtensions
using SparseArrays, DiffEqBase, Reexport, ModelingToolkit, DiffEqJump
using SparseArrays, DiffEqBase, Reexport, DiffEqJump
using Latexify, Requires

# ModelingToolkit imports and convenience functions we use
using ModelingToolkit;
using Symbolics
using ModelingToolkit: Symbolic, value, istree, get_states, get_ps, get_iv, get_systems,
get_eqs, get_defaults, toparam
get_eqs, get_defaults, toparam, get_defaults, get_observed
import ModelingToolkit: get_variables, namespace_expr, namespace_equation, get_variables!,
modified_states!, validate
modified_states!, validate, namespace_variables, namespace_parameters

# internal but needed ModelingToolkit functions
import ModelingToolkit: check_variables, check_parameters, _iszero, _merge, check_units, get_unit

const DEFAULT_IV = (@parameters t)[1]
@reexport using ModelingToolkit

import Base: (==), merge!, merge, hash, size, getindex, setindex, isless, Sort.defalg, length, show
import Base: (==), hash, size, getindex, setindex, isless, Sort.defalg, length, show
import MacroTools, LightGraphs
const LG = LightGraphs
import Nemo: FlintZZ, matrix, nullspace, rank

# convenience shorthands for packages
const MT = ModelingToolkit
const LG = LightGraphs

# as used in Catlab
const USE_GV_JLL = Ref(false)
function __init__()
Expand Down Expand Up @@ -54,7 +58,7 @@ include("registered_functions.jl")

# functions to query network properties
include("networkapi.jl")
export species, params, reactions, speciesmap, paramsmap, numspecies, numreactions, numparams
export species, reactionparams, reactions, speciesmap, paramsmap, numspecies, numreactions, numparams
export make_empty_network, addspecies!, addparam!, addreaction!
export dependants, dependents, substoichmat, prodstoichmat, netstoichmat
export conservationlaws, conservedquantities
Expand Down
Loading

0 comments on commit 0a794bb

Please sign in to comment.