SciML / Catalyst.jl

Chemical reaction network and systems biology interface for scientific machine learning (SciML). High performance, GPU-parallelized, and O(1) solvers in open source software.
https://docs.sciml.ai/Catalyst/stable/
Other
437 stars 71 forks source link

Add solubility limit for species #910

Open TorkelE opened 1 month ago

TorkelE commented 1 month ago

So, a thing that you have in chemistry is that you have a solution, within which your species are. However, there is a limit to how much of each species the liquid can solve, and the amount of a species above this limit seprates (i.e. might become solid form at the bottom of the liquid's container). However, if the species amount go down, this can again become soluble.

Practically, there are two values for a species:

Modelling this is something which would be useful fo chemists, and if we can support this, Catalyst would become a lot more attractive for chemists. Implementing the solubility limit for a species is easy, we would just make it a metadata:

rn = @reaction_network begin
    @parameters Xmax
    @species X(t) [solutbilitylimit = Xmax]
    (p,d), 0 <--> X
end

Practically, the most direct way to implement it would then be to, throughout the ODEs (or similar terms) replace all occurrences of X with min(X, getsolutbilitylimit(X)). There are of additional considerations though (i.e. does this make the ODE functions non-smooth in certain points, and is this bad for performance). Another question is if we can implement this by introducing equations.

We will have to discuss the best way to do this, but it would definitely be a feature we should add at some point.

(I only really know the terminology in Swedish for this kinds of thing, so the technical language is a bit crude)

isaacsas commented 1 month ago

Can you add some literature references showing the equations one wants to solve for some simple examples?

TorkelE commented 1 month ago

It came up when I discussed with my collaborator. I am not sure if there are any standardise approaches for this (will ask around) or just a frequent phenomena that people have to deal with (or don't deal with)