Skip to content

Commit 55a9fa3

Browse files
committed
update
1 parent 8f29ced commit 55a9fa3

File tree

4 files changed

+7
-15
lines changed

4 files changed

+7
-15
lines changed

docs/src/catalyst_functionality/chemistry_related_functionality.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ While Catalyst has primarily been designed around the modelling of biological sy
77
## Modelling with compound species
88

99
#### Creating compound species programmatically
10-
We will first show how to create compound species through [programmatic construction](@ref programmatic_CRN_construction), and then demonstrate using the DSL. To create a compound species, use the `@compound` macro, first designating the compound, followed by its components (and stoichiometries). In this example, we will create a CO₂ compound species, consisting of one C species and two O species. First, we create species corresponding to the components:
10+
We will first show how to create compound species through [programmatic construction](@ref programmatic_CRN_construction), and then demonstrate using the DSL. To create a compound species, use the `@compound` macro, first designating the compound, followed by its components (and stoichiometries). In this example, we will create a CO₂ molecule, consisting of one C atom and two O atoms. First, we create species corresponding to the components:
1111
```@example chem1
1212
@variables t
1313
@species C(t) O(t)
1414
```
15-
Next, we create the `CO2` compound:
15+
Next, we create the `CO2` compound species:
1616
```@example chem1
1717
@compound CO2(t) = C + 2O
1818
```
@@ -76,10 +76,10 @@ rn = @reaction_network begin
7676
(k1,k2), H2O+ CO2 <--> H2CO3
7777
end
7878
```
79-
as the components `C`, `H`, and `O` are not explicitly declared as a species anywhere. Please also note that only `@compounds` can be used as an option in the DSL, not `@compound`.
79+
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`.
8080

8181
## Balancing chemical reactions
82-
One use of defining a species as a compound is that they can be used to balance reactions to that the number of compounds are the same on both sides. Catalyst provides the `balance_reaction` function, which takes a reaction, and returns a balanced version. E.g. let us consider a reaction when carbon dioxide is formed from carbon and oxide `C + O --> CO2`. Here, `balance_reaction` enables us to find coefficients creating a balanced reaction (in this case, where the number of carbon and oxygen atoms are the same on both sides). To demonstrate, we first created the unbalanced reactions:
82+
One use of defining a species as a compound is that they can be used to balance reactions to that the number of components are the same on both sides. Catalyst provides the `balance_reaction` function, which takes a reaction, and returns a balanced version. E.g. let us consider a reaction when carbon dioxide is formed from carbon and oxide `C + O --> CO2`. Here, `balance_reaction` enables us to find coefficients creating a balanced reaction (in this case, where the number of carbon and oxygen atoms are the same on both sides). To demonstrate, we first created the unbalanced reactions:
8383
```@example chem1
8484
rx = @reaction k, C + O --> $CO2
8585
```

src/chemistry_functionality.jl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,6 @@ function make_compound(expr)
5555
components_designation_expr = Expr(:escape, :($species_name = ModelingToolkit.setmetadata($species_name, Catalyst.CompoundComponents, $components))) # E.g. `CO2 = ModelingToolkit.setmetadata(CO2, Catalyst.CompoundSpecies, [C, O])`
5656
coefficients_designation_expr = Expr(:escape, :($species_name = ModelingToolkit.setmetadata($species_name, Catalyst.CompoundCoefficients, $coefficients))) # E.g. `CO2 = ModelingToolkit.setmetadata(CO2, Catalyst.CompoundSpecies, [1, 2])`
5757

58-
println(
59-
return quote
60-
$species_declaration_expr
61-
$compound_designation_expr
62-
$components_designation_expr
63-
$coefficients_designation_expr
64-
end)
65-
6658
# Returns the rephrased expression.
6759
return quote
6860
$species_declaration_expr

src/reaction_network.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,11 +468,11 @@ end
468468

469469
# When compound species are declared using the "@compound begin ... end" option, get a list of the compound species, and also the expression that crates them.
470470
function read_compound_options(opts)
471-
# If the compound option is used retrive a list of compound species, and the option that creeates them
471+
# If the compound option is used retrive a list of compound species (need to be added to teh reaction system's species), and the option that creates them (used to declare them as compounds at the end).
472472
if haskey(opts, :compounds)
473473
compound_expr = opts[:compounds]
474474
compound_species = [arg.args[1].args[1] for arg in compound_expr.args[3].args] # Loops through where in the "@compound begin ... end" the compound species names are.
475-
else
475+
else # If option is not used, return empty vectors and expressions.
476476
compound_expr = :()
477477
compound_species = Union{Symbol, Expr}[]
478478
end

test/miscellaneous_tests/compound_macro.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ let
106106
@compound H2_1(t) = 2*H
107107
@compound H2_2(t) = alpha*H
108108
@compound H2_3(t) = 2*h
109-
@compound H2_4(t) = alpha*2H
109+
@compound H2_4(t) = alpha*H
110110

111111
@test iscompound(H2_1)
112112
@test iscompound(H2_2)

0 commit comments

Comments
 (0)