Skip to content

Commit 0d13a40

Browse files
committed
update more docs with internal references
1 parent aa9735c commit 0d13a40

File tree

8 files changed

+46
-42
lines changed

8 files changed

+46
-42
lines changed

docs/src/introduction_to_catalyst/catalyst_for_new_julia_users.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Catalyst models are created through the `@reaction_network` *macro*. For more in
7777

7878
The `@reaction_network` command is followed by the `begin` keyword, which is followed by one line for each *reaction* of the model. Each reaction consists of a *reaction rate*, followed by the reaction itself. The reaction contains a set of *substrates* and a set of *products* (what is consumed and produced by the reaction, respectively). These are separated by a `-->` arrow. Finally, the model ends with the `end` keyword.
7979

80-
Here, we create a simple *birth-death* model, where a single species ($X$) is created at rate $b$, and degraded at rate $d$. The model is stored in the variable `rn`.
80+
Here, we create a simple [*birth-death* model](@ref basic_CRN_library_bd), where a single species ($X$) is created at rate $b$, and degraded at rate $d$. The model is stored in the variable `rn`.
8181
```@example ex2
8282
rn = @reaction_network begin
8383
b, 0 --> X
@@ -136,7 +136,7 @@ Pkg.add("JumpProcesses")
136136
using JumpProcesses
137137
```
138138

139-
This time, we will declare a so-called [SIR model for an infectious disease](https://en.wikipedia.org/wiki/Compartmental_models_in_epidemiology#The_SIR_model). Note that even if this model does not describe a set of chemical reactions, it can be modelled using the same framework. The model consists of 3 species:
139+
This time, we will declare a so-called [SIR model for an infectious disease](@ref basic_CRN_library_sir). Note that even if this model does not describe a set of chemical reactions, it can be modelled using the same framework. The model consists of 3 species:
140140
* $S$, the amount of *susceptible* individuals.
141141
* $I$, the amount of *infected* individuals.
142142
* $R$, the amount of *recovered* (or *removed*) individuals.

docs/src/model_creation/chemistry_related_functionality.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# [Chemistry-related functionality](@id chemistry_functionality)
22

3-
While Catalyst has primarily been designed around the modelling of biological systems, reaction network models are also common across chemistry. This section describes two types of functionality, that while of general interest, should be especially useful in the modelling of chemical systems.
3+
While Catalyst has primarily been designed around the modelling of biological systems, reaction network models are also common in chemistry. This section describes two types of functionality, that while of general interest, should be especially useful in the modelling of chemical systems.
44
- The `@compound` option, which enables the user to designate that a specific species is composed of certain subspecies.
55
- The `balance_reaction` function, which enables the user to balance a reaction so the same number of components occur on both sides.
66

7+
78
## Modelling with compound species
89

910
### Creating compound species programmatically
@@ -17,7 +18,7 @@ Next, we create the `CO2` compound species:
1718
```@example chem1
1819
@compound CO2 ~ C + 2O
1920
```
20-
Here, the compound is the first argument to the macro, followed by its component (with the left-hand and right-hand sides separated by a `~` sign). While non-compound species (such as `C` and `O`) have their independent variable (in this case `t`) designated, independent variables are generally not designated for compounds (these are instead directly inferred from their components). Components with non-unit stoichiometries have this value written before the component (generally, the rules for designating the components of a compound are identical to those of designating the substrates or products of a reaction). The created compound, `CO2`, is also a species, and can be used wherever e.g. `C` can be used:
21+
Here, the compound is the first argument to the macro, followed by its component (with the left-hand and right-hand sides separated by a `~` sign). While non-compound species (such as `C` and `O`) have their independent variable (in this case `t`) designated, independent variables are generally not designated for compounds (these are instead directly inferred from their components). Components with non-unitary stoichiometries have this value written before the component (generally, the rules for designating the components of a compound are identical to those of designating the substrates or products of a reaction). The created compound, `CO2`, is also a species, and can be used wherever e.g. `C` can be used:
2122
```@example chem1
2223
isspecies(CO2)
2324
```
@@ -32,7 +33,7 @@ Alternatively, we can retrieve the components and their stoichiometric coefficie
3233
```@example chem1
3334
component_coefficients(CO2)
3435
```
35-
Finally, it is possible to check whether a species is a compound or not using the `iscompound` function:
36+
Finally, it is possible to check whether a species is a compound using the `iscompound` function:
3637
```@example chem1
3738
iscompound(CO2)
3839
```
@@ -68,7 +69,7 @@ end
6869
```
6970
When creating compound species using the DSL, it is important to note that *every component must be known to the system as a species, either by being declared using the `@species` or `@compound` options, or by appearing in a reaction*. E.g. the following is not valid
7071
```julia
71-
rn = @reaction_network begin``
72+
rn = @reaction_network begin
7273
@compounds begin
7374
C2O ~ C + 2O
7475
H2O ~ 2H + O
@@ -77,7 +78,7 @@ rn = @reaction_network begin``
7778
(k1,k2), H2O+ CO2 <--> H2CO3
7879
end
7980
```
80-
as the components `C`, `H`, and `O` are not declared as a species anywhere. Please also note that only `@compounds` can be used as an option in the DSL, not `@compound`.
81+
as the components `C`, `H`, and `O` are not declared as species anywhere. Please also note that only `@compounds` can be used as an option in the DSL, not `@compound`.
8182

8283
### Designating metadata and default values for compounds
8384
Just like for normal species, it is possible to designate metadata and default values for compounds. Metadata is provided after the compound name, but separated from it by a `,`:
@@ -92,10 +93,10 @@ If both default values and meta data are provided, the metadata is provided afte
9293
```@example chem1
9394
@compound (CO2 = 2.0, [unit="mol"]) ~ C + 2O
9495
```
95-
In all of these cases, the side to the left of the `~` must be enclosed within `()`.
96+
In all of these cases, the left-hand side must be enclosed within `()`.
9697

9798
### Compounds with multiple independent variables
98-
While we generally do not need to specify independent variables for compound, if the components (together) have more than one independent variable, this have to be done:
99+
While we generally do not need to specify independent variables for compound, if the components (together) have more than one independent variable, this *must be done*:
99100
```@example chem1
100101
t = default_t()
101102
@variables s
@@ -113,7 +114,7 @@ Here, the reaction rate (`k`) is not involved in the reaction balancing. We use
113114
```@example chem1
114115
balance_reaction(rx)
115116
```
116-
which correctly finds the (rather trivial) solution `C + 2O --> CO2`. Here we note that `balance_reaction` actually returns a vector. The reason is that the reaction balancing problem may have several solutions. Typically, there is only a single solution (in which case this is the vector's only element). No, or an infinite number of, solutions is also possible depending on the given reaction.
117+
which correctly finds the (rather trivial) solution `C + 2O --> CO2`. Here we note that `balance_reaction` actually returns a vector. The reason is that, in some cases, the reaction balancing problem does not have a single obvious solution. Typically, a single solution is the obvious candidate (in which case this is the vector's only element). However, when this is not the case, the vector instead contain several reactions (from which a balanced reaction cab be generated).
117118

118119
Let us consider a more elaborate example, the reaction between ammonia (NH₃) and oxygen (O₂) to form nitrogen monoxide (NO) and water (H₂O). Let us first create the components and the unbalanced reaction:
119120
```@example chem2

docs/src/model_creation/dsl_advanced.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ using Catalyst
99
```
1010

1111
## [Explicit specification of network species and parameters](@id dsl_advanced_options_declaring_species_and_parameters)
12-
[Previously](@ref ref), we mentioned that the DSL automatically determines which symbols correspond to species and which to parameters. This is done by designating everything that appears as either a substrate or a product as a species, and all remaining quantities as parameters (i.e. those only appearing within rates or [stoichiometric constants](@ref ref)). Sometimes, one might want to manually override this default behaviour for a given symbol. I.e. consider the following model, where the conversion of a protein `P` from its inactive form (`Pᵢ`) to its active form (`Pₐ`) is catalysed by an enzyme (`E`). Using the most natural description:
12+
Previously, we mentioned that the DSL automatically determines which symbols correspond to species and which to parameters. This is done by designating everything that appears as either a substrate or a product as a species, and all remaining quantities as parameters (i.e. those only appearing within rates or [stoichiometric constants](@ref dsl_description_stoichiometries_parameters)). Sometimes, one might want to manually override this default behaviour for a given symbol. I.e. consider the following model, where the conversion of a protein `P` from its inactive form (`Pᵢ`) to its active form (`Pₐ`) is catalysed by an enzyme (`E`). Using the most natural description:
1313
```@example dsl_advanced_explicit_definitions
1414
catalysis_sys = @reaction_network begin
1515
k*E, Pᵢ --> Pₐ
@@ -74,7 +74,7 @@ end
7474
parameters(dimerisation)
7575
```
7676
!!! danger
77-
Generally, Catalyst and the SciML ecosystem *do not* guarantee that parameter and species order are preserved throughout various operations on a model. Writing programs that depend on these orders is *strongly discouraged*. There are, however, some legacy packages which still depend on order (one example is provided [here](@ref ref)). In these situations, this might be useful. However, in these cases, it is recommended that the user is extra wary, and also checks the order manually.
77+
Generally, Catalyst and the SciML ecosystem *do not* guarantee that parameter and species order are preserved throughout various operations on a model. Writing programs that depend on these orders is *strongly discouraged*. There are, however, some legacy packages which still depend on order (one example can be found [here](@ref optimization_parameter_fitting_basics)). In these situations, this might be useful. However, in these cases, it is recommended that the user is extra wary, and also checks the order manually.
7878

7979
!!! note
8080
The syntax of the `@species` and `@parameters` options is identical to that used by the `@species` and `@parameters` macros [used in programmatic modelling in Catalyst](@ref programmatic_CRN_construction) (for e.g. designating metadata or initial conditions). Hence, if one has learnt how to specify species/parameters using either approach, that knowledge can be transferred to the other one.
@@ -125,7 +125,7 @@ rn = @reaction_network begin
125125
end
126126
127127
tspan = (0.0, 10.0)
128-
p = [:p => 1.0, :D => 0.2]
128+
p = [:p => 1.0, :d => 0.2]
129129
oprob = ODEProblem(rn, u0, tspan, p)
130130
sol = solve(oprob)
131131
plot(sol)
@@ -171,18 +171,18 @@ two_state_system = @reaction_network begin
171171
(ka,kD), Xi <--> Xa
172172
end
173173
```
174-
A metadata can be given to only a subset of a system's species/parameters, and a quantity can be given several metadata entries. To give several metadata, separate each by a `,`. Here we only provide a description for `kA`, for which we also provide a [bounds metadata](@ref https://docs.sciml.ai/ModelingToolkit/dev/basics/Variable_metadata/#Bounds),
174+
A metadata can be given to only a subset of a system's species/parameters, and a quantity can be given several metadata entries. To give several metadata, separate each by a `,`. Here we only provide a description for `kA`, for which we also provide a [`bounds` metadata](@ref https://docs.sciml.ai/ModelingToolkit/dev/basics/Variable_metadata/#Bounds),
175175
```@example dsl_advanced_metadata
176176
two_state_system = @reaction_network begin
177-
@parameters kA [description="X's activation rate", bound=(0.01,10.0)]
177+
@parameters kA [description="X's activation rate", bounds=(0.01,10.0)]
178178
(ka,kD), Xi <--> Xa
179179
end
180180
```
181181

182182
It is possible to add both default values and metadata to a parameter/species. In this case, first provide the default value, and next the metadata. I.e. to in the above example set $kA$'s default value to $1.0$ we use
183183
```@example dsl_advanced_metadata
184184
two_state_system = @reaction_network begin
185-
@parameters kA=1.0 [description="X's activation rate", bound=(0.01,10.0)]
185+
@parameters kA=1.0 [description="X's activation rate", bounds=(0.01,10.0)]
186186
(ka,kD), Xi <--> Xa
187187
end
188188
```
@@ -191,10 +191,10 @@ When designating metadata for species/parameters in `begin ... end` blocks the s
191191
```@example dsl_advanced_metadata
192192
two_state_system = @reaction_network begin
193193
@parameters begin
194-
kA, [description="X's activation rate", bound=(0.01,10.0)]
195-
kD = 1.0, [description="X's deactivation rate"]
194+
kA, [description="X's activation rate", bounds=(0.01,10.0)]
195+
kD = 1.0, [description="X's deactivation rate"]
196196
end
197-
(ka,kD), Xi <--> Xa
197+
(kA,kD), Xi <--> Xa
198198
end
199199
```
200200

@@ -229,7 +229,7 @@ end
229229
A common use-case for constant species is when modelling systems where some species are present in such surplus that their amounts the reactions' effect on it is negligible. A system which is commonly modelled this way is the [Brusselator](https://en.wikipedia.org/wiki/Brusselator).
230230

231231
### [Designating parameter types](@id dsl_advanced_options_parameter_types)
232-
Sometimes it is desired to designate that a parameter should have a specific [type](@ref ref). When supplying this parameter's value to e.g. an `ODEProblem`, that parameter will then be restricted to that specific type. Designating a type is done by appending the parameter with `::` followed by its type. E.g. in the following example we specify that the parameter `n` (the number of `X` molecules in the `Xn` polymer) must be an integer (`Int64`)
232+
Sometimes it is desired to designate that a parameter should have a specific [type](https://docs.julialang.org/en/v1/manual/types/). When supplying this parameter's value to e.g. an `ODEProblem`, that parameter will then be restricted to that specific type. Designating a type is done by appending the parameter with `::` followed by its type. E.g. in the following example we specify that the parameter `n` (the number of `X` molecules in the `Xn` polymer) must be an integer (`Int64`)
233233
```@example dsl_advanced_parameter_types
234234
using Catalyst # hide
235235
polymerisation_network = @reaction_network begin
@@ -238,7 +238,7 @@ polymerisation_network = @reaction_network begin
238238
end
239239
nothing # hide
240240
```
241-
Generally, when simulating models with mixed parameter types, it is recommended to [declare parameter values as tuples, rather than vectors](@ref ref), e.g.:
241+
Generally, when simulating models with mixed parameter types, it is recommended to [declare parameter values as tuples, rather than vectors](@ref simulation_intro_ODEs_input_forms), e.g.:
242242
```@example dsl_advanced_parameter_types
243243
ps = (:kB => 0.2, :kD => 1.0, :n => 2)
244244
nothing # hide
@@ -254,7 +254,7 @@ nothing # hide
254254
```
255255

256256
### [Vector-valued species or parameters](@id dsl_advanced_options_vector_variables)
257-
Sometimes, one wishes to declare a large number of similar parameters or species. This can be done by *creating them as vectors*. E.g. below we create a [two-state system](@ref ref). However, instead of declaring `X1` and `X2` (and `k1` and `k2`) as separate entities, we declare them as vectors:
257+
Sometimes, one wishes to declare a large number of similar parameters or species. This can be done by *creating them as vectors*. E.g. below we create a [two-state system](@ref basic_CRN_library_two_states). However, instead of declaring `X1` and `X2` (and `k1` and `k2`) as separate entities, we declare them as vectors:
258258
```@example dsl_advanced_vector_variables
259259
using Catalyst # hide
260260
two_state_model = @reaction_network begin
@@ -316,7 +316,7 @@ end
316316
rn1 == rn2
317317
```
318318

319-
Setting model names is primarily useful for [hierarchical modelling](@ref ref), where network names are appended to the display names of subnetworks' species and parameters.
319+
Setting model names is primarily useful for [hierarchical modelling](@ref compositional_modeling), where network names are appended to the display names of subnetworks' species and parameters.
320320

321321
## [Creating observables](@id dsl_advanced_options_observables)
322322
Sometimes one might want to use observable variables. These are variables with values that can be computed directly from a system's state (rather than having their values implicitly given by reactions or equations). Observables can be designated using the `@observables` option. Here, the `@observables` option is followed by a `begin ... end` block with one line for each observable. Each line first gives the observable, followed by a `~` (*not* a `=`!), followed by an expression describing how to compute it.
@@ -350,11 +350,11 @@ sol[:Xtot]
350350
to get a vector with `Xtot`'s value throughout the simulation. We can also use
351351
```@example dsl_advanced_observables
352352
using Plots
353-
plot(sol; idxs = [:Xtot, :Ytot])
353+
plot(sol; idxs = :Xtot)
354354
```
355355
to plot the observables (rather than the species).
356356

357-
Observables can be defined using complicated expressions containing species, parameters, and [variables](@ref ref) (but not other observables). In the following example (which uses a [parametric stoichiometry](@ref ref)) `X` polymerises to form a complex `Xn` containing `n` copies of `X`. Here, we create an observable describing the total number of `X` molecules in the system:
357+
Observables can be defined using complicated expressions containing species, parameters, and [variables](@ref ref) (but not other observables). In the following example (which uses a [parametric stoichiometry](@ref dsl_description_stoichiometries_parameters)) `X` polymerises to form a complex `Xn` containing `n` copies of `X`. Here, we create an observable describing the total number of `X` molecules in the system:
358358
```@example dsl_advanced_observables
359359
rn = @reaction_network begin
360360
@observables Xtot ~ X + n*Xn
@@ -378,7 +378,7 @@ Observables are by default considered [variables](@ref ref) (not species). To de
378378
```@example dsl_advanced_observables
379379
rn = @reaction_network begin
380380
@species Xtot(t)
381-
@observables Xtot ~ X + n*XnXY
381+
@observables Xtot ~ X + n*Xn
382382
(kB,kD), n*X <--> Xn
383383
end
384384
nothing # hide

0 commit comments

Comments
 (0)