# Brusselator and Catalyst

**URL:** <https://discourse.julialang.org/t/brusselator-and-catalyst/54222>\
**Category:** Chemistry\
**Created:** [January 29, 2021, 8:02pm UTC](https://discourse.julialang.org/t/brusselator-and-catalyst/54222 "2021-01-29T20:02:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aquarelleX332](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aquarellex332/32/21048_2.png) [@aquarelleX332](https://discourse.julialang.org/u/aquarelleX332)\
**Post date:** [January 29, 2021, 8:02pm UTC](https://discourse.julialang.org/t/brusselator-and-catalyst/54222/1 "2021-01-29T20:02:22Z")

</div>

Good evening to all,

I recently solved the ODEs system for the brusselator:

```julia
A -> X (k1)
2X + Y -> 3X (k2)
B + X -> Y + D (k3)
X -> E (k4)

```

where A, B, etc are chemical species and k represents kinetics coefficients.  
Because I wanted to get the limit cycle ([Y] as a function of [X]), I chose:

```julia
k1 = k2 = k3 = k4 = 1
[X]0 = [Y]0 = 1
[A] = 1 and [B] = 3 

```

Here [] denotes the concentration in various species. The objective was to solve d[X]/dt and d[Y]/dt. It is not difficult to fix the value of [A] and [B] since there is a direct access for the ODEs to be modified:

```julia
d[X]/dt = [A] + [Y][X]^2 - [B][X] -[X]
d[Y]/dt = -Y][X]^2 + [B][X]

```

I then became interested in Catalyst (so I solved the thermal decomposition of ethane as well as a problem of 2 consecutive organic reactions).  
The next problem is to solve the brusselator with Catalyst. I defined:

```julia
brusselator = @reaction_network begin
    k1, A → X
    k2, 2X + Y → 3X
    k3, B + X → Y + D
    k4, X → E
end k1 k2 k3 k4

```

I disabled rescaling of reaction rates. The latexification shows that the ODEs so obtained are correct.  
There is no problem to write **p** and **tspan**.

However how to formulate **u0** since [A] and [B] are not initial concentrations? How to introduce “external” modifications to the ODEs system since this latter is no longer apparent?  
At first sight I thought that some kind of forcing could help me. However I don’t see how to proceed on the basis of examples given [here](https://catalyst.sciml.ai/dev/tutorials/advanced_examples/).

Could someone please guide me?  
Thank you in advance,  
Thierry

---

<div class="post-metadata">

**Author:** ![isaacsas](https://avatars.discourse-cdn.com/v4/letter/i/f6c823/32.png) [@isaacsas](https://discourse.julialang.org/u/isaacsas)\
**Post date:** [January 29, 2021, 11:45pm UTC](https://discourse.julialang.org/t/brusselator-and-catalyst/54222/2 "2021-01-29T23:45:45Z")

</div>

If `A` and `B` are constant, those reactions are really zero and first order respectively. So you can just move `A` and `B` into the rates like

```julia
brusselator = @reaction_network begin
    k1*A, 0 → X
    k2, 2X + Y → 3X
    k3*B, X → Y + D
    k4, X → E
end k1 k2 k3 k4 A B

```

Alternatively, you need to modify your reactions to ensure they don’t change `A` and `B`, then the ODEs for `A` and `B` will have zero derivatives so you can just set their values in the initial condition vector:

```julia
brusselator = @reaction_network begin
    k1, A → A + X
    k2, 2X + Y → 3X
    k3, B + X → B + Y + D
    k4, X → E
end k1 k2 k3 k4

```

edit: Notice, in the first example `A` and `B` are now parameters.

---

<div class="post-metadata">

**Author:** ![aquarelleX332](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aquarellex332/32/21048_2.png) [@aquarelleX332](https://discourse.julialang.org/u/aquarelleX332)\
**Post date:** [January 30, 2021, 5:30am UTC](https://discourse.julialang.org/t/brusselator-and-catalyst/54222/3 "2021-01-30T05:30:53Z")

</div>

Hello Sam,

Your solution:

```julia
brusselator = @reaction_network begin
    k1*A, 0 → X
    k2, 2X + Y → 3X
    k3*B, X → Y + D
    k4, X → E
end k1 k2 k3 k4 A B

```

with p = (1.0,1.0,1.0,1.0,1.0,3.0)  
u0 = [1.0,1.0,0.0,0.0]  
tspan=(.0,50.0)

perfectly works.  
Many thanks! 😉 👍  
[I’m sorry I didn’t think to rework the system of equations.]

![brusselator_1](https://global.discourse-cdn.com/julialang/original/3X/3/a/3a76a2d69447a7670a31045b73aed41aea6721ae.png) ![brusselator_2](https://global.discourse-cdn.com/julialang/original/3X/0/e/0eb085c197ec5053d4001ea2cd47766a939f1663.png)

---

<div class="post-metadata">

**Author:** ![isaacsas](https://avatars.discourse-cdn.com/v4/letter/i/f6c823/32.png) [@isaacsas](https://discourse.julialang.org/u/isaacsas)\
**Post date:** [January 30, 2021, 1:38pm UTC](https://discourse.julialang.org/t/brusselator-and-catalyst/54222/4 "2021-01-30T13:38:27Z")

</div>

Glad that helped!
