Skip to content

Commit 9b67a59

Browse files
authored
mention constant species
1 parent fe9c78f commit 9b67a59

File tree

1 file changed

+69
-1
lines changed

1 file changed

+69
-1
lines changed

docs/src/catalyst_functionality/dsl_description.md

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ where here `t` always denotes Catalyst's time variable. Please note that many
285285
user-defined functions can be called directly, but others will require
286286
registration with Symbolics.jl ([see the faq](@ref user_functions)).
287287

288-
## Explicit specification of network species and parameters
288+
## [Explicit specification of network species and parameters](@id dsl_description_explicit_species)
289289
Recall that the `@reaction_network` macro automatically designates symbols used
290290
in the macro as either parameters or species, with symbols that appear as a
291291
substrate or product being species, and all other symbols becoming parameters
@@ -412,6 +412,74 @@ sol = solve(oprob)
412412
plot(sol)
413413
```
414414

415+
## Constant/fixed species
416+
It is possible to fix the concentration of a species in a reaction. Without fixing
417+
a species, a reaction could look like
418+
```@example tut2
419+
rn = @reaction_network begin
420+
k, X + Y --> 0
421+
end
422+
```
423+
424+
```@example tut2
425+
ode_sys = convert(ODESystem, rn)
426+
```
427+
428+
```@example tut2
429+
equations(ode_sys)
430+
```
431+
432+
Fixing a species could either be achieved by modifying the reaction specification
433+
and specifying constant species explicitly as species as described
434+
[above](@ref dsl_description_explicit_species), i.e.,
435+
```@example tut2
436+
rn = @reaction_network begin
437+
@species X(t)
438+
k * X, Y --> 0
439+
end
440+
```
441+
442+
```@example tut2
443+
ode_sys = convert(ODESystem, rn)
444+
```
445+
446+
```@example tut2
447+
equations(ode_sys)
448+
```
449+
450+
The species can of course also just be used as parameter - using the same modification
451+
of the reaction, i.e.,
452+
```@example tut2
453+
rn = @reaction_network begin
454+
k * X, Y --> 0
455+
end
456+
```
457+
458+
```@example tut2
459+
ode_sys = convert(ODESystem, rn)
460+
```
461+
462+
```@example tut2
463+
equations(ode_sys)
464+
```
465+
466+
The same result can also be achieved by declaring a species as fixed/constant
467+
without having to change the reaction itself, i.e.,
468+
```@example tut2
469+
rn = @reaction_network begin
470+
@parameters X [isconstantspecies = true]
471+
k, X + Y --> 0
472+
end
473+
```
474+
475+
```@example tut2
476+
ode_sys = convert(ODESystem, rn)
477+
```
478+
479+
```@example tut2
480+
equations(ode_sys)
481+
```
482+
415483
## [Setting initial conditions that depend on parameters](@id dsl_description_parametric_initial_conditions)
416484
It is possible to set the initial condition of one (or several) species so that they depend on some system parameter. This is done in a similar way as default initial conditions, but giving the parameter instead of a value. When doing this, we also need to ensure that the initial condition parameter is a variable of the system:
417485
```@example tut2

0 commit comments

Comments
 (0)