Hello Everyone,
I was hoping for some guidance on how to incorporate constraints for pH equilibriums constants into a disinfection model I am building in Julia.
A simplified version of the reaction network is here:
using OrdinaryDiffEq
using Catalyst
using DifferentialEquations
using Plots
using Latexify
disinfectionmodel = @reaction_network begin
k1, HOCl + NH3 --> NH2Cl
k2, NH2Cl --> HOCl + NH3
k3, HOCl + NH2Cl --> NHCl2
k4, NHCl2 --> HOCl + NH2Cl
k5, HOCl + H + Br --> BrCl
(kf, kf/10^-14), H + OH ↔ H2O
(kf, kf/10^-9.25), NH3 + H ↔ NH4
(kf, kf/10^-7.53), OCl + H ↔ HOCl
end
What I am having trouble with now is the constraints associated with the pH dependent equilibrium relationships of weak acids and of pH itself. The full reaction system includes multiple reactions in which H or OH are the products or the reactant. I have done a bit of sleuthing and found this resource on the Catalyst:
https://github.com/SciML/Catalyst.jl/issues/137
However, when I tried to utilize the @add_constraints macro mentioned in the link above as shown below, I receive the following an error documented below:
@add_constraints disinfectionmodel begin
log10(H) + log10(OH) = -14
log10((NH3)*(H)/(NH4)) = -9.25
log10((OCl)*(H)/(HOCl)) = - 7.53
end
LoadError: UndefVarError: @add_constraints not defined
in expression starting at In[4]:1
I looked through the Catalyst resource material and was unsuccessful in finding anything that would guide me further but will acknowledge that I am still a bit of a novice when it comes to Julia and programming in general along with interpreting source material. Being able to add these constraints prior to utilizing the differential equation solver will be really helpful!
Thank you for any help anyone can provide!