@@ -46,9 +46,18 @@ function chemical_arrows(rn::ModelingToolkit.ReactionSystem;
46
46
47
47
mathjax && (str *= " \\ require{mhchem}\n " )
48
48
49
+ println (kwargs)
49
50
50
51
backwards_reaction = false
51
52
rxs = ModelingToolkit. equations (rn)
53
+ @variables t
54
+
55
+ # this should replace A(t) with A in equations however, currently substituter rewrites
56
+ # things like x/y as inv(y)*x^1 which looks worse... for now we leave a stub that can
57
+ # be updated when substitution preserves expressions better.
58
+ # subber = ModelingToolkit.substituter([s(t) => s() for s in states(rn)])
59
+ subber = x -> x
60
+
52
61
for (i, r) in enumerate (rxs)
53
62
if backwards_reaction
54
63
backwards_reaction = false
@@ -57,7 +66,7 @@ function chemical_arrows(rn::ModelingToolkit.ReactionSystem;
57
66
str *= " \\ ce{ "
58
67
59
68
# ## Expand functions to maths expressions
60
- rate = r. rate isa Operation ? Expr (r. rate) : r. rate
69
+ rate = r. rate isa Operation ? Expr (subber ( r. rate) ) : r. rate
61
70
expand && (rate = recursive_clean! (rate))
62
71
expand && (rate = recursive_clean! (rate))
63
72
@@ -72,7 +81,7 @@ function chemical_arrows(rn::ModelingToolkit.ReactionSystem;
72
81
poststr = mathjax ? " ]" : " \$ ]"
73
82
if i + 1 <= length (rxs) && issetequal (r. products,rxs[i+ 1 ]. substrates) && issetequal (r. substrates,rxs[i+ 1 ]. products)
74
83
# ## Bi-directional arrows
75
- rate_backwards = Expr (rxs[i+ 1 ]. rate)
84
+ rate_backwards = rxs[i + 1 ] . rate isa Operation ? Expr (subber ( rxs[i+ 1 ]. rate)) : rxs[i + 1 ] . rate
76
85
expand && (rate_backwards = recursive_clean! (rate_backwards))
77
86
expand && (rate_backwards = recursive_clean! (rate_backwards))
78
87
str *= " &<=>"
0 commit comments