Skip to content

Commit d6fe8bf

Browse files
committed
update
1 parent 0832fe0 commit d6fe8bf

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

docs/src/catalyst_functionality/chemistry_related_functionality.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ Finally, it is possible to check whether a species is a compound or not using th
3737
iscompound(CO2)
3838
```
3939

40+
!!! note
41+
Currently, compounds with components that depend on variables that are not `t` are not supported. E.g.
42+
```julia
43+
@variables x y
44+
@species O(x, y)
45+
@compound O2 ~ 2O
46+
```
47+
will currently throw an error.
48+
49+
4050
Compound components that are also compounds are allowed, e.g. we can create a carbonic acid compound (H₂CO₃) that consists of CO₂ and H₂O:
4151
```@example chem1
4252
@species H(t)

src/chemistry_functionality.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,14 @@ function make_compound(expr)
8282
components_designation_expr = Expr(:escape, :($species_name = ModelingToolkit.setmetadata($species_name, Catalyst.CompoundComponents, $components)))
8383
coefficients_designation_expr = Expr(:escape, :($species_name = ModelingToolkit.setmetadata($species_name, Catalyst.CompoundCoefficients, $coefficients)))
8484

85+
# Currently, non-t independent variables are not supported for compounds. If there are any like these, we throw an error:
86+
non_t_iv_error_check_expr = Expr(:escape, :(issetequal(unique(reduce(vcat, arguments.(ModelingToolkit.unwrap.($components)))), [t]) || error("Currently, compounds depending on components that are not \"t\" are not supported.")))
87+
88+
println(non_t_iv_error_check_expr)
89+
8590
# Returns the rephrased expression.
8691
return quote
92+
$non_t_iv_error_check_expr
8793
$species_declaration_expr
8894
$multiple_ivs_error_check_expr
8995
$iv_designation_expr

0 commit comments

Comments
 (0)