Skip to content

Commit 18fcbf1

Browse files
committed
prepare formatting round
1 parent b235784 commit 18fcbf1

File tree

6 files changed

+152
-186
lines changed

6 files changed

+152
-186
lines changed

docs/src/api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ of all options currently available.
100100
- [`continuous_events`](@ref constraint_equations_events): Allows the creation of continuous events.
101101
- [`discrete_events`](@ref constraint_equations_events): Allows the creation of discrete events.
102102
- [`combinatoric_ratelaws`](@ref faq_combinatoric_ratelaws): Takes a single option (`true` or `false`), which sets whether to use combinatorial rate laws.
103+
- [`require_declaration`](@ref dsl_advanced_options_require_dec): Turns off all inference of parameters, species, variables, the default differential, and observables (requiring these to be explicitly declared using e.g. `@species`).
103104

104105
## [ModelingToolkit and Catalyst accessor functions](@id api_accessor_functions)
105106
A [`ReactionSystem`](@ref) is an instance of a

docs/src/model_creation/dsl_advanced.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ ModelingToolkit.getdescription(two_state_system.kA)
204204
```
205205

206206
### [Designating constant-valued/fixed species parameters](@id dsl_advanced_options_constant_species)
207-
208207
Catalyst enables the designation of parameters as `constantspecies`. These parameters can be used as species in reactions, however, their values are not changed by the reaction and remain constant throughout the simulation (unless changed by e.g. the [occurrence of an event](@ref constraint_equations_events). Practically, this is done by setting the parameter's `isconstantspecies` metadata to `true`. Here, we create a simple reaction where the species `X` is converted to `Xᴾ` at rate `k`. By designating `X` as a constant species parameter, we ensure that its quantity is unchanged by the occurrence of the reaction.
209208
```@example dsl_advanced_constant_species
210209
using Catalyst # hide
@@ -501,6 +500,34 @@ Catalyst.getdescription(rx)
501500

502501
A list of all available reaction metadata can be found [in the api](@ref api_rx_metadata).
503502

503+
## [Declaring individual reaction using the `@reaction` macro](@id dsl_advanced_options_reaction_macro)
504+
Catalyst exports a macro `@reaction` which can be used to generate a singular [`Reaction`](@ref) object of the same type which is stored within the [`ReactionSystem`](@ref) structure (which in turn can be generated by `@reaction_network `). In the following example, we create a simple [SIR model](@ref basic_CRN_library_sir). Next, we instead create its individual reaction components using the `@reaction` macro. Finally, we confirm that these are identical to those stored in the initial model (using the [`reactions`](@ref) function).
505+
```@example dsl_advanced_reaction_macro
506+
using Catalyst # hide
507+
sir_model = @reaction_network begin
508+
α, S + I --> 2I
509+
β, I --> R
510+
end
511+
infection_rx = @reaction α, S + I --> 2I
512+
recovery_rx = @reaction β, I --> R
513+
issetequal(reactions(sir_model), [infection_rx, recovery_rx])
514+
```
515+
516+
Here, the `@reaction` macro is followed by a single line consisting of three parts:
517+
- A rate (at which the reaction occurs).
518+
- Any number of substrates (which are consumed by the reaction).
519+
- Any number of products (which are produced by the reaction).
520+
The rules of writing and interpreting this line are [identical to those for `@reaction_network`](@ref dsl_description_reactions) (however, bi-directional reactions are not permitted).
521+
522+
Generally, the `@reaction` macro provides a more concise notation to the [`Reaction`](@ref) constructor. One of its primary uses is for [creating models programmatically](@ref programmatic_CRN_construction). When doing so, it can often be useful to use [*interpolation*](@ref dsl_advanced_options_symbolics_and_DSL_interpolation) of symbolic variables declared previously:
523+
```@example dsl_advanced_reaction_macro
524+
t = default_t()
525+
@parameters k b
526+
@species A(t)
527+
ex = k*A^2 + t
528+
rx = @reaction b*$ex*$A, $A --> C
529+
```
530+
504531
## [Working with symbolic variables and the DSL](@id dsl_advanced_options_symbolics_and_DSL)
505532
We have previously described how Catalyst represents its models symbolically (enabling e.g. symbolic differentiation of expressions stored in models). While Catalyst utilises this for many internal operation, these symbolic representations can also be accessed and harnessed by the user. Primarily, doing so is much easier during programmatic (as opposed to DSL-based) modelling. Indeed, the section on [programmatic modelling](@ref programmatic_CRN_construction) goes into more details about symbolic representation in models, and how these can be used. It is, however, also ways to utilise these methods during DSL-based modelling. Below we briefly describe two methods for doing so.
506533

src/Catalyst.jl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,6 @@ const CONSERVED_CONSTANT_SYMBOL = :Γ
7272
const forbidden_symbols_skip = Set([:ℯ, :pi, , :t, :∅])
7373
const forbidden_symbols_error = union(Set([:im, :nothing, CONSERVED_CONSTANT_SYMBOL]),
7474
forbidden_symbols_skip)
75-
const forbidden_variables_error = let
76-
fvars = copy(forbidden_symbols_error)
77-
delete!(fvars, :t)
78-
fvars
79-
end
8075

8176
### Package Main ###
8277

0 commit comments

Comments
 (0)