1 Introduction

The cytoplasm of a cell does not behave like an ideal solution [1], since, in many cases, interactions among the solutes cannot be neglected. Indeed, in the cytoplasm there is a plethora of interactions among proteins, other macromolecules, and ions. Some of the most common interactions that are relevant in the cellular cytoplasm are steric and crowding effects [2, 3], as well as electrostatic interactions [4, 5]. Arguably, the most striking phenomenon caused by these interactions is the emergence of phase-separated condensates, also known as membraneless organelles in the cell-biology literature, which are now widely studied [6,7,8]. The composition of these membraneless organelles is different from the one of the cytoplasm, because they are typically enriched in a specific type of molecules while they exclude others [9]. Moreover, it has been hypothesised that such organelles spatially control biochemical reactions, by modulating their rates and specificity within the condensate [10,11,12,13].

Given their important role in the internal spatial organisation of cells, the regulation of phase-separation phenomena is crucial for many cellular functions. One of the ways in which cells can dynamically control the onset, composition and function of membraneless organelles is through chemical reactions, notably post-translational modifications like phosphorylation [14, 15] or methylation [16]. However, the rates of these chemical reactions are also affected by the fact that the solution is non-ideal, i.e., by the interactions between solutes, requiring a paradigm beyond that of ideal chemical reactions networks (CRNs). Moreover, in this type of system, diffusion plays a crucial role (since it organises the molecules in areas of high and low concentration), suggesting that an effort should be made to understand these non-ideal reaction-diffusion systems from the theoretical standpoint.

Most of these theoretical efforts [17,18,19,20] have been based on effective reaction-diffusion models that can describe patterning and non-equilibrium phenomena in a simple way, but lack thermodynamic consistency. More precisely, in these approaches the reaction dynamics is modelled with mass-action kinetics (MAK), which implicitly assumes that the solution is ideal (while the interaction-influenced diffusion that drives phase-separation is not), which leads to the aforementioned lack of consistency. Early progress in reconciling the spatial patterns predicted by these models with a thermodynamically consistent description was limited to a linear-stability analysis of binary systems [21]. More recently, some works aimed at establishing a deterministic theory for non-ideal CRNs [22], the relation between phase coexistence and chemical kinetics [23], and exploring minimal examples for pattern formation with non-ideal CRNs [24,25,26]. Nevertheless, the link between non-equilibrium CRNs and phase separation has not yet been elucidated in full generality.

Here, we aim at building a thermodynamically consistent framework for interacting reaction-diffusion systems which may exhibit phase-separation at steady state. Therefore, in this framework, in the same way diffusion is governed by a free energy (that takes into account the interactions), the dynamics of the chemical reactions must also reflect this free-energetic dependency. Here, previous efforts are complemented by analysing the behaviour of non-ideal CRNs in the stochastic limit, in an effort to build a more complete theory. This explicit description of non-ideality in the CRN allows us to naturally adapt and generalise the results from the well-established theory of ideal CRNs. We do so by first constructing a framework such that, in the absence of explicit non-equilibrium driving, the system relaxes to thermodynamical equilibrium. Unlike much of the previous literature, which deals with particular reaction motifs (with a few exceptions, e.g. Ref. [27]), we focused on a broad class of networks, named complex-balanced networks, for which the steady-state creation and annihilation rate of each chemical complex are equal. For this type of non-dilute CRNs, we derive the steady-state probability distributions and Lyapunov functionals, which allows us to obtain the steady-state concentration profiles.

The paper is organised as follows: The first half of the paper consists of a review of the theory of CRNs and its connection to thermodynamical quantities. In Sect. 2 we describe the dynamics of spatially homogeneous CRNs in the stochastic and deterministic limit, introduce the concept of complex balance, and recall the main features of MAK. In Sect. 3, we impose thermodynamical constraints on the reaction rates for CRNs at equilibrium, by consistently relating these rates to the free energy, and discuss how they can be modified in non-equilibrium settings.

Sections 4 and  5 contain the main novel results of the paper. In Sect. 4 we generalise to non-ideal CRNs the known result for the steady-state distribution of complex-balanced networks. Building on this result, in Sect. 5 we propose a candidate Lyapunov function of complex-balanced systems. In the same Section, we generalise the previous Lyapunov function to systems with spatial inhomogeneities, and derive the resulting phase diagram for a non-equilibrium, complex-balanced, chemically reactive mixture.

Finally, in Sect. 6 we discuss the interpretations and implications of our results.

2 Chemical-Reaction Networks

A chemical-reaction network (CRN) is composed of N chemical species and M reaction pathways; which we assume reversible, for a better alignment with thermodynamic principles. A reaction within the CRN, denoted by the label \(\rho \), is specified as follows:

$$\begin{aligned} \sum _a r^{\rho }_a X_a \leftrightharpoons \sum _a s^{\rho }_a X_a, \end{aligned}$$
(1)

where \(X_a\), \(a=1, \cdots , N\) is one the N species in the network. In the rest of this paper, the indexes a and b will be used for chemical species only.

The matrices \(r^{\rho }_a\) and \(s^{\rho }_a\) denote the number of particles of each species participating in the forward and backward reaction, respectively, i.e., \(r^{\rho }_a\) specifies the number of reactants of type a in the forward reaction \(\rho \), and \(s^{\rho }_a\), that of the products of type a in the backward reaction. Note that, given that the reactions are taken to be reversible, the distinction between reactants and products is arbitrary.

The amount of particles of species a created along the forward reaction is denoted by

$$\begin{aligned} v^\rho _a=s^{\rho }_a-r^{\rho }_a. \end{aligned}$$
(2)

We also introduce the vectors \(\varvec{v}^\rho = (v^\rho _1, \cdots , v^\rho _N) \), \(\varvec{r}^\rho =( r^\rho _1 \cdots r^\rho _N)\) and \(\varvec{s}^\rho =( s^\rho _1, \cdots , s^\rho _N)\). , and the matrices

$$\begin{aligned} \varvec{V} =\, \left( \begin{array}{c} \vdots \\ \varvec{v}^\rho \\ \vdots \end{array}\right) , \, \varvec{R} = \left( \begin{array}{c} \vdots \\ \varvec{r}^\rho \\ \vdots \end{array}\right) ,\, \varvec{S}= \, \left( \begin{array}{c} \vdots \\ \varvec{s}^\rho \\ \vdots \end{array}\right) . \end{aligned}$$
(3)

Finally, we define a complex \(\varvec{z}\) as the number and type of particles that participate in a chemical reaction as either reactants (\(\varvec{z}=\varvec{r}^\rho \)) or products (\(\varvec{z}=\varvec{s}^\rho \)). A single complex \(\varvec{z}\) may appear in more than one reaction within the network. In order to clarify the definitions above, we illustrate them for the following network.

2.1 Example

For the CRN

$$\begin{aligned} \textrm{A}+\textrm{B}&\leftrightharpoons \textrm{C}, \end{aligned}$$
(4)
$$\begin{aligned} \textrm{B}&\leftrightharpoons \textrm{D}, \end{aligned}$$
(5)

the vectors of reactants are

$$\begin{aligned} \varvec{r}^1= \begin{pmatrix} 1,&1,&0,&0 \end{pmatrix},\, \varvec{r}^2= \begin{pmatrix} 0,&1,&0,&0 \end{pmatrix},\, \end{aligned}$$
(6)

and the product vectors are

$$\begin{aligned} \varvec{s}^1= \begin{pmatrix} 0,&0,&1,&0 \end{pmatrix},\, \varvec{s}^2= \begin{pmatrix} 0,&0,&0,&1 \end{pmatrix}, \end{aligned}$$
(7)

where each of the entries in the vector correspond to different species and the reactions are labelled by the superindices. Finally, we have the vectors

$$\begin{aligned} \varvec{v}^1= \begin{pmatrix} -1,&-1,&1,&0 \end{pmatrix},\, \varvec{v}^2= \begin{pmatrix} 0,&-1,&0,&1 \end{pmatrix}, \end{aligned}$$
(8)

that specify the net amount of particles of each species created by each of the reactions occurring once in the forward direction.

Building on the definitions above, in what follows we introduce the stochastic and deterministic description of a CRN, the starting point of the rest of this work.

2.2 Stochastic Description

If the chemical species in the solution diffuse fast (with respect to the typical timescale of chemical reactions) and is stirred regularly, the system may be considered to be well mixed and it can be described in terms of a single homogeneous concentration of each of the species across space. Then, a state of the system—the number of particles of each type—is determined by the vector

$$\begin{aligned} \varvec{n}=( n_1, \cdots , n_N). \end{aligned}$$
(9)

Each state \(\varvec{n}\) of the system has a probability measure \(P(\varvec{n}, t)\) at any instant of time t. The dynamics for the probability of states of homogeneous CRNs is given by the Chemical Master Equation (CME), which reads [28]:

$$\begin{aligned} \frac{\partial P(\varvec{n}, t)}{\partial t}=&\sum _\rho f_{+\rho } (\varvec{n}-\varvec{v}^{\rho }) P(\varvec{n}-\varvec{v}^{\rho }) + \sum _\rho f_{-\rho } (\varvec{n}+\varvec{v}^{\rho }) P(\varvec{n}+\varvec{v}^{\rho })\nonumber \\&-\sum _\rho [f_{+\rho } (\varvec{n})+f_{-\rho } (\varvec{n}) ]P(\varvec{n}) , \end{aligned}$$
(10)

where the summations over \(\rho \) run over all reactions in the CRN, \(\varvec{v}\) is given by Eq. (2), and the rate of the transitions in the network is given by the propensity functions \(f_{\pm \rho }\), \(+\rho \) corresponding to the forward direction of the reaction and \(-\rho \) corresponding to the backward direction. Eq. (10) is different to other statements of the CME because we made explicit the fact that every reaction is reversible.

2.3 Deterministic Description

For large particle numbers, by averaging both sides of Eq. (10) and assuming vanishing correlations according to the mean-field picture—assumptions that are supposed to be accurate in the large-particle number limit—one can work out a set of equations for the concentrations \(c_a = n_a/V\) in the macroscopic limit, where both \(n_a\) and V are large. In this limit, the state of the system is specified by the concentrations \(c_1, \cdots , c_N\), and one obtains the following classical set of equations for the dynamics of the concentrations in a CRN [29]:

$$\begin{aligned} \frac{\partial c_a}{\partial t} = \sum _\rho v_a^\rho (J_{+\rho }-J_{-\rho }), \end{aligned}$$
(11)

where the currents J still need to be determined. While both the deterministic and stochastic descriptions refer to the same system, the former one is only accurate for large particle numbers, also known as the thermodynamic limit, where fluctuations are negligible.

2.4 Complex Balance

In a CRN, a complex is a set of chemical species and their respective particle numbers, which take part in a reaction, as either reactants or products. Its most general expression is the vector

$$\begin{aligned} \varvec{z}=(z_1, \cdots , z_a, \cdots ), \end{aligned}$$
(12)

where the index a runs over all chemical species and the integer \(z_a\) is the number of molecules of the species \(X_a\) in the complex \(\varvec{z}\). Any CRN can be represented as a graph whose nodes denote the complexes that take part in the reactions, where there is an edge between two complexes if and only if there is a reaction \(\varvec{z}^m \leftrightharpoons \varvec{z}^n\) in the CRN, and \(\varvec{z}^m\) and \(\varvec{z}^n\) are two different complexes—see for example Fig .

Fig. 1
figure 1

Graphical representation of a chemical-reaction network (CRN). The CRN has six complexes, where each is represented as a node in the graph: \(\textrm{A}\), \(\textrm{B}\), \(\mathrm C\), \(\textrm{A}+\textrm{D}\), \(\mathrm E\) and \(\textrm{B}+\textrm{D}\). The five reactions present in the CRN are numbered

In a deterministic CRN, whose kinetics are given by Eq. (11), the creation rate of the complex \(\varvec{z}\), \(J_{+\varvec{z}}\), is defined as

$$\begin{aligned} J_{+\varvec{z}}=\sum _{\rho \vert \varvec{s}^\rho =\varvec{z}} J_{+\rho } +\sum _{\rho \vert \varvec{r}^\rho =\varvec{z}} J_{-\rho } \end{aligned}$$
(13)

where both addends in Eq. (13) are source terms for the complex \(\varvec{z}\): The subscript \(\rho \vert \varvec{s}^\rho =\varvec{z}\) indicates that the sum is taken over the reactions \(\rho \) whose product complex equals the complex \(\varvec{z}\), and, similarly, \(\rho \vert \varvec{r}^\rho =\varvec{z}\) indicates that that the sum is taken over those reactions whose reactant complex equals \(\varvec{z}\). Proceeding along the same lines, we define the rate of annihilation of the complex \(\varvec{z}\) as

$$\begin{aligned} J_{-\varvec{z}}=\sum _{\rho \vert \varvec{s}^\rho =\varvec{z}} J_{-\rho } +\sum _{\rho \vert \varvec{r}^\rho =\varvec{z}} J_{+\rho }. \end{aligned}$$
(14)

A deterministic network is said to have a complex-balanced steady state if its steady state satisfies the condition that the creation rate and the annihilation rate of each complex are equal [30]:

$$\begin{aligned} J_{+\varvec{z}}=J_{-\varvec{z}} \quad \;\;\; \forall \, \varvec{z}. \end{aligned}$$
(15)

While there exist some topological conditions in the CRN which ensure that the steady state is complex balanced [31], not every CRN possesses a complex-balanced non-equilibrium steady-state. We refer the interested reader to Refs. [32,33,34] for more detailed discussions on the topological constraints that determine complex-balancing and its consequences for MAK networks.

In general, a complex-balanced steady state is one of many steady states which a CRN may have. We can order these types of steady states in terms of their generality as follows:

Fig. 2
figure 2

Graphical depiction of the different types of steady states, taking the network of Fig. 1 as example. A) Detailed-balanced steady state. Here, the backward and forward rates of each reaction are equal. B) Complex-balanced steady state. There exist non-vanishing net currents (red arrows) but the steady state still satisfies the complex-balanced requirement, Eq. (15). It only allows for cycles at steady state that can be visualised from the network in terms of complexes (red cycle). C) General steady state. There exist non-vanishing net currents (red arrows) and the complex-balanced requirement does not hold

Equilibrium steady state. The most restrictive condition that we can impose to a steady state is detailed balance:

$$\begin{aligned} J_{+\rho }=J_{-\rho } \quad \;\;\; \forall \, \rho . \end{aligned}$$
(16)

Equation (16) corresponds to a system at thermodynamic equilibrium, and implies that the rate of the forward reaction equals the rate of the backward reaction for every reaction \(\rho \) in the CRN (example depicted in Fig.  A).

Complex-balanced steady state. More general than detailed-balanced steady states are complex-balanced steady states, which satisfy

$$\begin{aligned} \sum _{\rho \vert \varvec{s}^\rho =\varvec{z}} J_{+\rho } +\sum _{\rho \vert \varvec{r}^\rho =\varvec{z}} J_{-\rho }=\sum _{\rho \vert \varvec{s}^\rho =\varvec{z}} J_{-\rho } +\sum _{\rho \vert \varvec{r}^\rho =\varvec{z}} J_{+\rho } \quad \;\;\; \forall \, \varvec{z}. \end{aligned}$$
(17)

Equation (17) implies that the creation and the annihilation rate of each complex \(\varvec{z}\) are equal. In the example of Fig. 1, the only way to have a complex-balanced steady state which is not at equilibrium (i.e. is not entirely detailed-balanced) is by taking the net rate \(J_{+\rho }-J_{-\rho }\) in reaction 1 equal to the net rate of those of reactions 2 and 3, and thus reactions 4 and 5 must be detailed balanced (since the system has to be at steady state). This steady state is depicted in Fig. 2 B.

General steady state. The most general class of steady states is defined by the vanishing time derivatives of the dynamical equation (11). By splitting the contributions of each complex \(\varvec{z}\), this condition can be rewritten as

$$\begin{aligned}&\sum _m z_a^m \Bigg (\sum _{\rho \vert \varvec{s}^\rho =\varvec{z}_m} J_{+\rho } +\sum _{\rho \vert \varvec{r}^\rho =\varvec{z}_m} J_{-\rho }\Bigg ) =\sum _m z_a^m \Bigg (\sum _{\rho \vert \varvec{r}^\rho =\varvec{z}_m} J_{+\rho } +\sum _{\rho \vert \varvec{s}^\rho =\varvec{z}_m} J_{-\rho }\Bigg ) \;\;\;\;\forall \, a , \end{aligned}$$
(18)

where m is an index that labels each of the complexes in the network and the integer \(z_a^m\) represents its components. As a result, there are no constraints between the net rates of each reaction other than those imposed by the stationarity condition of Eq. (11). In the example of Fig. 1, this implies that, at steady state, there can be current cycles where, for example, species \(\textrm{A}\) is created by reaction 1, but annihilated by reaction 4 through the complex \(\textrm{A}+\textrm{D}\), thus breaking complex balance (see Fig. 2 C).

From this hierarchical classification, it can be clearly seen that detailed balance, Eq. (16), implies complex balance, Eq. (17), which, in turn, implies the steady-state condition, Eq. (18). However, the converse is not true: A general steady state is not necessarily complex balanced, and a complex-balanced steady state is not necessarily detail balanced. Therefore, complex balance is less restrictive of a constraint than detailed balance, but it is more restrictive than a generic steady state.

2.5 Complex Balance in Networks with Mass-Action Kinetics

As a particular instance of special importance, in what follows we will discuss complex balance in ideal CRNs with MAK.

In short, MAK consists of the hypothesis that the rate of the chemical reaction is proportional to the product of the concentrations of the reactants: As a result, in the deterministic description, the MAK expressions for the currents read

$$\begin{aligned} J_{+\rho }=k_{+\rho } \prod _a c_a^{r_a^\rho }, \quad J_{-\rho }=k_{-\rho } \prod _a c_a^{s_a^\rho }, \end{aligned}$$
(19)

where \(k_{\pm \rho }\) are the rate constants. In what follows, we will denote by \(c^*_a\) the steady-state concentration of species a in the deterministic description. Then, for a deterministic system with MAK, the complex-balance condition is given by

$$\begin{aligned} \sum _{\rho \vert \varvec{s}^\rho =\varvec{z}}&k_{+\rho } \prod _a (c_a^*)^{r_a^\rho } +\sum _{\rho \vert \varvec{r}^\rho =\varvec{z}} k_{-\rho } \prod _a (c_a^*)^{s_a^\rho } \nonumber \\ =&\sum _{\rho \vert \varvec{s}^\rho =\varvec{z}} k_{-\rho } \prod _a (c_a^*)^{s_a^\rho } +\sum _{\rho \vert \varvec{r}^\rho =\varvec{z}} k_{+\rho } \prod _a (c_a^*)^{r_a^\rho } \quad \; \forall \, \varvec{z}. \end{aligned}$$
(20)

Conversely, in the stochastic description [with dynamics is given by Eq. (10)] the MAK expressions for \(f_{\pm \rho }\) become

$$\begin{aligned} f_{+\rho } (\varvec{n})=&k_{+\rho } \prod _a \frac{n_a!}{(n_a-r_a^{\rho })!}, \end{aligned}$$
(21)
$$\begin{aligned} f_{-\rho } (\varvec{n})=&k_{-\rho } \prod _a \frac{n_a!}{(n_a-s_a^{\rho })!}. \end{aligned}$$
(22)

Previous studies [33] have shown that the steady state of complex-balanced CRNs with MAK is known to have a product-form expression in terms of independent Poisson distributions, and it reads

$$\begin{aligned} \pi (\varvec{n})=\prod _{a=1}^M \frac{(c^{*}_a)^{n_a}}{n_a!}e^{-c^{*}_a}, \end{aligned}$$
(23)

linking the deterministic steady state (\(c_a^*\)) to the stochastic steady state \(\pi \). Furthermore, in Ref. [33] it is shown that, if the propensity functions take the more general form

$$\begin{aligned} f_{+\rho } (\varvec{n})=&k_{+\rho } \frac{\theta (\varvec{n}) }{\theta (\varvec{n}-\varvec{r}^\rho ) }, \end{aligned}$$
(24)
$$\begin{aligned} f_{-\rho } (\varvec{n})=&k_{-\rho } \frac{\theta (\varvec{n}) }{\theta (\varvec{n}-\varvec{s}^\rho ) }, \end{aligned}$$
(25)

then the steady-state distribution reads

$$\begin{aligned} \pi (\varvec{n})= \frac{M}{\theta (\varvec{n})}\prod _{a=1} (c^*_a)^{n_a}, \end{aligned}$$
(26)

where M is a normalisation constant and \(\theta \) a function which maps the vector of integer numbers \(\varvec{n}\) into a real-valued positive number.

In what follows, we will demonstrate that the result (23) can be generalised to the non-ideal case, i.e., to a class of propensity functions f which take into account the physical interactions between molecules.

3 Reaction Rates for Non-ideal Chemical-Reaction Networks

In the previous Section we introduced the general description of CRNs, both on a stochastic and deterministic level: in either cases, a choice for the propensity functions, or currents, must be made to set the network dynamics. For ideal solutions, the most common choice is MAK, as outlined above. However, in what follows we consider solutes which mutually interact and which are, therefore, not ideal, and specify the propensity functions.

3.1 Equilibrium Systems

Here, we consider CRNs at thermodynamic equilibrium, i.e., systems which are not subject to external, non-equilibrium driving. Given that the system is an equilibrium one, at steady state the principle of detailed balance must hold for every reaction \(\rho \): The probability flux across a reaction \(\rho \) in the forward direction must equal the one in the backward direction. In this Section, we will impose the detailed-balance condition on the propensity functions at thermal equilibrium and suggest a generalisation for systems out of equilibrium.

3.1.1 Stochastic Description

In the stochastic description, the detailed-balance condition at steady state reads

$$\begin{aligned} P^{\text {eq}}(\varvec{n})f_{+\rho }(\varvec{n})=f_{-\rho } (\varvec{n}+\varvec{v}^\rho ) P^{\text {eq}}(\varvec{n}+\varvec{v}^\rho ), \end{aligned}$$
(27)

where the equilibrium probability distribution \(P^{\text {eq}}(\varvec{n})\) for closed stochastic systems—total number of particles fixed—is given by the canonical Boltzmann distribution:

$$\begin{aligned} P^{\text {eq}}(\varvec{n})=\frac{1}{Z}e^{-\beta F(\varvec{n})}, \end{aligned}$$
(28)

with \(\beta = 1/(k_{\textrm{B}}T)\), \(k_{\textrm{B}}\) is the Boltzmann constant, T the temperature, \( F(\varvec{n})\) the Helmholtz free energy of the system in state \(\varvec{n}\), and Z a normalisation factor—the partition function in statistical physics. For systems that exchange mass with a single particle reservoir, the equilibrium distribution (28) is replaced by the distribution for the grand-canonical ensemble [35].

Combined with Eq. (28), the detailed-balance condition in Eq. (27) yields the following constraint for the propensity functions:

$$\begin{aligned} \frac{f_{+\rho }(\varvec{n})}{f_{-\rho } (\varvec{n}+\varvec{v}^\rho )} =&\frac{P^{\text {eq}}(\varvec{n}+\varvec{v}^\rho )}{ P^{\text {eq}}(\varvec{n})}\nonumber \\ =&e^{-\beta [ F(\varvec{n}+\varvec{v}^\rho )- F(\varvec{n})]}. \end{aligned}$$
(29)

Then, we choose the following functional form for the propensity functions:

$$\begin{aligned} f_{+\rho }(\varvec{n})=\,&k_\rho e^{\beta [ F(\varvec{n})-F(\varvec{n}-\varvec{r}^{\rho })]}, \end{aligned}$$
(30)
$$\begin{aligned} f_{-\rho } (\varvec{n})=\,&k_\rho e^{\beta [F(\varvec{n})-F(\varvec{n}-\varvec{s}^{\rho })]}, \end{aligned}$$
(31)

where \(k_\rho \) is the reaction constant, which needs to be equal in both the forward and the backward reaction for Eq. (29) to be satisfied. Given that the free energy F may, in general, depend on the inter-particle interactions—such as steric, electrostatic, or other interactions—Eq. (29) implies that the chemical-reaction rates may depend on these inter-particle interactions.

The choices (30) and (31) for the propensity functions are not unique, but it is particularly appealing because it reduces to MAK for ideal systems. In fact, consider an ideal lattice-model solution with \({\mathcal {N}}\) particles including both solvent and solute—see Appendix A for details. The free energy is

$$\begin{aligned} F_{\text {id}}=\sum _a n_a \mu _a^0 +\frac{1}{\beta }\Bigg [\sum _a \log (n_a !) - \log ({\mathcal {N}}!)\Bigg ], \end{aligned}$$
(32)

where \({\mathcal {N}}=\sum _a n_a\) (including solvent particles in the sum) and \(\mu _a^0\) is the standard-state chemical potential of species a (taken with respect a given reference state noted as ‘0’), which may depend on parameters like temperature or nature of the solvent and the solute a. Then, the rates take the following form:

$$\begin{aligned} f_{+\rho }(\varvec{n})=&k_\rho e^{\beta [ F(\varvec{n})-F(\varvec{n}-\varvec{r}^{\rho })]}\nonumber \\ =&k_\rho e^{\beta \sum _a r^{\rho }_a \mu _i^0} \frac{({\mathcal {N}}-\sum _a r_a^\rho )!}{{\mathcal {N}}!} \prod _a \frac{n_a!}{(n_a-r_a^{\rho })!}, \end{aligned}$$
(33)

where \(({\mathcal {N}}-\sum _a r_a^\rho )!/{\mathcal {N}}!\) can be approximated by \({\mathcal {N}}^{-\sum _a r_a^\rho }\). Setting

$$\begin{aligned} k_{+\rho }=k_\rho \frac{\exp (\beta \sum _a r^{\rho }_a \mu _a^0)}{{\mathcal {N}}^{\sum _a r_a^\rho }}, \end{aligned}$$
(34)

we obtain that \(f_{+\rho }\) coincides with the MAK propensity function (21), and similarly for \(f_{-\rho }\) and Eq. (22).

We conclude this Section with a remark on the reaction constant, \(k_\rho \): In Eqs. (30) and (31) we have assumed that \(k_\rho \) is a constant of the reaction, independent on the state \(\varvec{n}\) of the system. However, in general \(k_\rho \) may depend on \(\varvec{n}\), because the system itself is part of the environment where the chemical reactions take place. These effects can be disregarded for most cases in ideal solutions (since they are usually dilute), but they may not be negligible in non-ideal systems. For instance, in the case of phase separation, the multiple phases of the system may constitute very different environments for the chemical reactions, accelerating them or slowing them down.

Independently of whether \(k_\rho \) in Eqs. (30) and (31) depends on the system state or not, detailed balance, Eq. (29), must still hold. This means that the forward reaction constant for a state \(\varvec{n}\) must be equal to the backward reaction constant for a state \(\varvec{n}+\varvec{v}^\rho \). One way to ensure this equality while keeping the state-dependency of the reaction constants, is to make \(k_\rho \) a function of the state \(\varvec{n}\) deprived of the reactant complex, i.e., \(\varvec{n}-\varvec{r}^\rho \), for the forward case, and of \(\varvec{n}+\varvec{v}^\rho -\varvec{s}^\rho \) for the backward one:

$$\begin{aligned} f_{+\rho }(\varvec{n})=&k_\rho (\varvec{n}-\varvec{r}^\rho ) e^{\beta [ F(\varvec{n})-F(\varvec{n}-\varvec{r}^{\rho })]}, \end{aligned}$$
(35)
$$\begin{aligned} f_{-\rho } (\varvec{n}+\varvec{v}^\rho )=&k_\rho (\varvec{n}+\varvec{v}^\rho -\varvec{s}^\rho ) e^{\beta [F(\varvec{n}+\varvec{v}^\rho )-F(\varvec{n}+\varvec{v}^\rho -\varvec{s}^{\rho })]}, \end{aligned}$$
(36)

where Eqs. (35) and (36) satisfy Eq. (29) because

$$\begin{aligned} \varvec{n}-\varvec{r}^\rho =\varvec{n}+\varvec{v}^\rho -\varvec{s}^\rho , \end{aligned}$$
(37)

see Eq. (2).

The dependency above of \(k_\rho \) on the system state can be pictured as follows. In analogy with the classical transition-state theory, we can think of the microscopic mechanism of a reaction as a random walk in a free-energy landscape [36, 37], see Fig. . Then, the value of the rate constant \(k_\rho \) depends on the height of the free-energy barrier \(\Delta F\) of the reaction. The stable local minima in the reaction landscape have reaction free energies \(F^0_\textrm{I}, F^0_\textrm{II}\), which are defined as the free energy of the system once the entropic term \(\sum _a \log (n_a)!\), has been removed [37]. Thus, \(F^0_\textrm{I}\) and \(F^0_\textrm{II}\) need not be equal since they include a contribution due to the interactions of reactants and products with its environment, i.e., the phase they are in. Hence, \(F^0_\textrm{I}\) and \(F^0_\textrm{II}\) are determined by F but the barrier height \(\Delta F\) is not. The dependency of the height of the barrier—and thus of \(k_\rho \)—on the system state is precisely the one discussed in Eqs. (35) and (36), and it may strongly affect the CRN dynamics. In summary, we are connecting the chemical reaction rates to the free energy of the system F, but also to \(\Delta F\) which sets the value of the reaction constants \(k_\rho \).

Fig. 3
figure 3

Free-energy landscape for a chemical reaction. The horizontal dimension is the reaction coordinate and the vertical one specifies the height of the reaction free energy \(F^0\)—the free energy F with the entropic term \(\sum _a\log n_a!\) removed [37]. The quantities \(F^0(\varvec{n})\) and \(F^0(\varvec{n}+\varvec{v}_\rho )\) denote the reaction free energy of the system before and after the reaction, subscripts \(\mathrm I\) and \(\mathrm II\) specify the system phase, and \(\Delta F\) the height of the free-energy barrier. For each phase, there are two minima in the free-energy landscape, corresponding to whether the reaction has occurred or not, see the left- and right-hand minimum, respectively. In this example, \(\Delta F\) depends on the phase the reaction takes place in, and, thus, the reaction constant \(k_\rho \) would also depend on the environment in which the reaction occurs

3.1.2 Deterministic Description

When the particle numbers \(\varvec{n}\) are large compared to the number of reactants and products, \(\varvec{r}\) and \(\varvec{s}\), respectively, the free-energy differences which appear in the rates (30) and (31) can be rewritten as

$$\begin{aligned} F(\varvec{n})-F(\varvec{n}-\varvec{r}^\rho ) \approx&F(\varvec{n})-\Bigg [F(\varvec{n}) - \sum _a \frac{\partial F}{\partial n_a} r^\rho _a\Bigg ]\nonumber \\ =&\sum _a r_a^\rho \mu _a, \end{aligned}$$
(38)

where in the first line we expanded F to first order in \(\varvec{r}\), in the second line we used the definition of the chemical potential of species a:

$$\begin{aligned} \mu _a=&\frac{\partial F}{\partial n_a} \nonumber \\ =&\frac{\partial \mathfrak {f}}{\partial c_a}, \end{aligned}$$
(39)

and \(\mathfrak {f}(\varvec{c})\) is the free energy per unit volume in the deterministic notation. The second line in Eq. (38) is only an approximation, however, in the large particle number or deterministic limit, the error due to retaining only the first term in the Taylor expansion becomes vanishing. In this limit, Eq. (38) matches the affinity of the reaction, which is the driving force of the chemical reaction, according to irreversible thermodynamics [37], see Appendix B for details.

Therefore, the currents in a deterministic, non-ideal CRN can be written as

$$\begin{aligned} J_{+\rho }=&k_\rho e^{\beta \sum _a r_a^\rho \mu _a},\nonumber \\ J_{-\rho } =&k_\rho e^{\beta \sum _a s_a^\rho \mu _a}, \end{aligned}$$
(40)

which is an expression conceptually similar to that given by other approaches to construct thermodynamically consistent dynamics for deterministic CRNs [22, 24]. Once again, the currents (40) match their ideal MAK counterpart (19) if the chemical potentials used in the rates are those of an ideal solution, i.e., \(\mu _a=1/ \beta \log c_a+\mu _a^0\). Here and in the rest of the text, dimensional arguments of the logarithms remain due to the fact that we are absorbing the effect of the total concentration in \(\mu ^0\), i.e., the original chemical potential was \(\mu _a=1/ \beta \log (c_a/c_{\text {tot}})+\mu _a^0\), where \(c_{\text {tot}}=\sum _a c_a\) (the sum includes the solvent), but since variations in \(c_{\text {tot}}\) can be neglected \(-\log (c_{\text {tot}})\) is just a constant and is absorbed into \(\mu ^0_a\) (and, thus, into \(k_{\rho }\)).

As in the previous section, if we assume the rate constant is state-dependent then the currents are given by

$$\begin{aligned} J_{+\rho }(\varvec{c})&={\tilde{k}}_\rho g_\rho (\varvec{c}) e^{\beta \sum _a r^\rho _a \mu _a}, \nonumber \\ J_{-\rho }(\varvec{c})&={\tilde{k}}_\rho g_\rho (\varvec{c}) e^{\beta \sum _a s^\rho _a \mu _a}, \end{aligned}$$
(41)

where \({\tilde{k}}_\rho \) is still a constant and any dependency of the rate constant on the state is given by the function \(g_\rho (\varvec{c})\).

3.2 Non-equilibrium Systems

So far we considered the propensity functions of equilibrium CRNs. Given the large number of physically interesting systems which are out of equilibrium, such as living beings, in what follows we will generalise the analysis of Sect. 3.1 to a specific type of non-equilibrium systems: those in which the work is done by the chemostats they are connected to.

Let us assume that \(N'\) out of the N species in the system are connected to multiple particle reservoirs—chemostats: In the stochastic and deterministic description, each chemostat keeps constant the chemical potential of the species to which it is connected. Then, in general, the system will not relax to equilibrium, because of the work done on it by the chemostats. In the stochastic and deterministic description, the dimensions of the space of states or concentrations, respectively, is reduced to \(N-N'\le N\), since the chemostatted species are no longer dynamical variables.

3.2.1 Stochastic Description

We assume that connecting the system to several chemostats does not alter any of the mechanisms of the chemical reactions, since it only tunes the concentration of the species to which they are connected, in order to match a given value of chemical potential. Then, reactions that involve both chemostatted and non-chemostatted species are driven in one direction by the work done by the chemostats inserting and removing particles from the system (in order to keep their chemical potentials constant). Given that the mechanism of reaction remains the same, in line with the previous section the rates of these driven chemical transitions are taken to be [22, 23, 25, 26]

$$\begin{aligned} f_{+\rho }(\varvec{n})=\,&k_\rho e^{\beta [ F(\varvec{n})-F(\varvec{n}-\varvec{r}^{\rho })+\sum _b r^\rho _b \mu _b]}, \end{aligned}$$
(42)
$$\begin{aligned} f_{-\rho } (\varvec{n})=\,&k_\rho e^{\beta [F(\varvec{n})-F(\varvec{n}-\varvec{s}^{\rho })+\sum _b s^\rho _b \mu _b]}, \end{aligned}$$
(43)

where now F is the free energy of the \(N-N'\) non-chemostatted species, \(\varvec{n}\) contains the particle numbers of the non-chemostatted species only, and the summation over b runs over the chemostatted species. For the sake of clarity, in what follows we will reserve the index b for the chemostatted species, and the index a for the non-chemostatted ones.

The rationale behind these relations is that the chemical reaction is still driven by free energy differences except that now the the free energy differences due to the consumption of chemostatted species is just given by the chemical potential of the chemostats \(\mu _b\). The terms \(\sum _b r^\rho _b \mu _b\) and \(\sum _b s^\rho _b \mu _b\) in the exponential represents the chemical work done by the chemostats (with chemical potentials fixed at \( \mu _b \)) when a reaction \(\rho \) occurs, which pushes the system out of equilibrium. The effect of the non-chemostatted species is still given by the free energy differences \(F(\varvec{n})-F(\varvec{n}-\varvec{r}^{\rho })\) and \(F(\varvec{n})-F(\varvec{n}-\varvec{s}^{\rho })\).

This implicitly assumes that the chemostatted species are abundant (so that the chemical potential does not fluctuate) and that they are ideal (negligible interactions with the non-chemostatted species). If the chemostatted species were not ideal, then the concentration of species might dynamically vary to match the chemostatted chemical potential as the particle numbers in the system change. Here, we only consider the simpler case of ideal chemostatted species and refer the interested reader to Ref. [22], where the case of non-ideal chemostatted species was analysed.

As in Sect. 3.1 [see Eqs. (35) and (36)], the rate constants in Eqs. (42) and (43) may be generalised in such a way that \(k_\rho \) depends on the system state:

$$\begin{aligned} f_{+\rho }(\varvec{n})&={\tilde{k}}_\rho g_\rho (\varvec{n}-\varvec{r}^\rho ) e^{\beta [ F(\varvec{n})-F(\varvec{n}-\varvec{r}^{\rho })+\sum _b r^\rho _b \mu _b]}, \nonumber \\ f_{-\rho } (\varvec{n}+\varvec{v}^\rho )&={\tilde{k}}_\rho g_\rho (\varvec{n}+\varvec{v}^\rho -\varvec{s}^{\rho }) e^{\beta [F(\varvec{n}+\varvec{v}^\rho )-F(\varvec{n}+\varvec{v}^\rho -\varvec{s}^{\rho })+\sum _b s^\rho _b \mu _b]}, \end{aligned}$$
(44)

where \({\tilde{k}}_\rho \) is independent of \(\varvec{n}\). Propensity functions of this form have been suggested before in other contexts, such as in the modelling of molecular motors [38].

3.2.2 Deterministic Description

Proceeding along the lines of Sect. 3.1.2, in the deterministic limit the above propensity functions result in the currents

$$\begin{aligned} J_{+\rho }(\varvec{c})&={\tilde{k}}_\rho g_\rho (\varvec{c}) e^{\beta ( \sum _a r^\rho _a \mu _a+\sum _b r^\rho _b \mu _b)}, \nonumber \\ J_{-\rho }(\varvec{c})&={\tilde{k}}_\rho g_\rho (\varvec{c}) e^{\beta ( \sum _a s^\rho _a \mu _a+\sum _b s^\rho _b \mu _b)}. \end{aligned}$$
(45)

4 Steady-State Distribution for Complex-Balanced, Non-ideal CRNs

In what follows, we will prove one of the central results of this work, i.e., that the complex-balance condition allows us to generalise to non-ideal CRNs the result (23) [33] for the steady-state distribution of the network, which is generally unique (for details see Refs. [39, 40]).

Namely, we claim that CRNs for which the complex-balance condition (15) holds, the steady state of the stochastic dynamics (10) with propensity functions (44) reads

$$\begin{aligned} \pi _\textrm{neq} (\varvec{n})=\frac{e^{-\beta [F(\varvec{n})+\sum _a {\tilde{\mu }}_a n_a]}}{Z}, \end{aligned}$$
(46)

where the parameters \(\tilde{\mu }_a\) depend on the chemostats to which the system is connected and on the reaction constants of the network, but not on F. These parameters can be obtained from the CRN in the ideal and deterministic limit, thus significantly simplifying the task of obtaining analytically the steady-state of the system. Note that we reserve \(\mu _b\) for the chemical potentials of the chemostats while \(\tilde{\mu }_a\) is a parameter that describes how the particle numbers at steady state of the non-chemostatted species depend on the non-equilibrium driving of the system. An additional necessary condition to prove this result is that the function \(g_\rho \) must be the same for all reactions, i.e., \(g_\rho =g\); the relaxation of this hypothesis will be discussed in Sect. 6.

The proof follows closely that of Anderson, Craciun and Kurtz [33], and here we only present its main steps—see Appendix C for a full proof. We will substitute the steady-state (46) into the dynamical equations, look for solutions where the probability flux across complexes vanishes, and obtain the complex-balance condition for a network with MAK, Eq. (20). We can thus conclue that, if the network modelled deterministically with MAK is complex-balanced at steady state, i.e. Eq. (20) is satisfied, then Eq. (46) is the steady-state probability distribution of its stochastic non-ideal counterpart. Furthermore, the parameters \(\tilde{\mu }_a\) in Eq. (46) can be obtained by solving Eq. (20).

By inserting the ansatz (46) in Eq. (10) with propensity functions of the form (44) and \(g_\rho =g\) for all reactions, at steady state we obtain

$$\begin{aligned}&\sum _\rho {\tilde{k}}_\rho \Big \{ g(\varvec{n}-\varvec{s}^\rho ) e^{\beta [ F(\varvec{n}) -F(\varvec{n}-\varvec{s}^\rho )+\sum _a v_a^\rho \tilde{\mu }_a +\sum _b r^\rho _b \mu _b ] } \nonumber \\&\quad + g(\varvec{n}-\varvec{r}^\rho ) e^{\beta [ F(\varvec{n}) -F(\varvec{n}-\varvec{r}^\rho ) -\sum _a v_a^\rho \tilde{\mu }_a +\sum _b s^\rho _b \mu _b] } \Big \}\nonumber \\&\quad = \sum _\rho {\tilde{k}}_\rho \Big \{ g(\varvec{n}-\varvec{r}^\rho ) e^{\beta [ F(\varvec{n}) -F(\varvec{n}-\varvec{r}^\rho ) +\sum _b r^\rho _b \mu _b] } \nonumber \\&\quad + g(\varvec{n}-\varvec{s}^\rho ) e^{\beta [ F(\varvec{n}) -F(\varvec{n}-\varvec{s}^\rho )+\sum _b s^\rho _b \mu _b] } \Big \}. \end{aligned}$$
(47)

The previous equation is satisfied if, for each complex \(\varvec{z}\), we have

$$\begin{aligned}&\sum _{\rho \vert \varvec{s}^\rho =\varvec{z} } {\tilde{k}}_\rho g(\varvec{n}-\varvec{s}^\rho ) e^{\beta [ F(\varvec{n}) -F(\varvec{n}-\varvec{s}^\rho ) +\sum _a v_a^\rho \tilde{\mu }_a +\sum _b r^\rho _b \mu _b] } \nonumber \\&\quad +\sum _{\rho \vert \varvec{r}^\rho =\varvec{z} } {\tilde{k}}_\rho g(\varvec{n}-\varvec{r}^\rho ) e^{\beta [ F(\varvec{n}) -F(\varvec{n}-\varvec{r}^\rho ) -\sum _a v_a^\rho \tilde{\mu }_a +\sum _b s^\rho _b \mu _b] } \nonumber \\&\quad =\sum _{\rho \vert \varvec{r}^\rho =\varvec{z} } {\tilde{k}}_\rho g(\varvec{n}-\varvec{r}^\rho ) e^{\beta [ F(\varvec{n}) -F(\varvec{n}-\varvec{r}^\rho )+\sum _b r^\rho _b \mu _b] } \nonumber \\&\quad +\sum _{\rho \vert \varvec{s}^\rho =\varvec{z} } {\tilde{k}}_\rho g(\varvec{n}-\varvec{s}^\rho ) e^{\beta [ F(\varvec{n}) -F(\varvec{n}-\varvec{s}^\rho )+\sum _b s^\rho _b \mu _b] }. \end{aligned}$$
(48)

Given that in the previous equation the complex \(\varvec{z}\) is fixed, it can be simplified and yields

$$\begin{aligned}&\sum _{\rho \vert \varvec{s}^\rho =\varvec{z}} {\tilde{k}}_\rho e^{\beta [ \sum _a (z_a-r_a^\rho ) \tilde{\mu }_a +\sum _b r^\rho _b \mu _b]} + \sum _{\rho \vert \varvec{r}^\rho =\varvec{z}} {\tilde{k}}_\rho e^{\beta [-\sum _a (s_a^\rho -z_a) \tilde{\mu }_a +\sum _b s^\rho _b \mu _b] } \nonumber \\&\quad =\sum _{\rho \vert \varvec{r}^\rho =\varvec{z} } {\tilde{k}}_\rho e^{\beta \sum _b r^\rho _b \mu _b} +\sum _{\rho \vert \varvec{s}^\rho =\varvec{z} } {\tilde{k}}_\rho e^{\beta \sum _b s^\rho _b \mu _b }. \end{aligned}$$
(49)

Setting

$$\begin{aligned} c_a^*&=\exp [-\beta ( \tilde{\mu }_a+\mu _a^0)], \end{aligned}$$
(50)
$$\begin{aligned} k_{+\rho }&={\tilde{k}}_{\rho }\exp \Bigg [\beta \Bigg (\sum _a r_a^\rho \mu _a^0+\sum _b r_b^\rho \mu _b\Bigg )\Bigg ] , \end{aligned}$$
(51)
$$\begin{aligned} k_{-\rho }&={\tilde{k}}_{\rho }\exp \Bigg [\beta \Bigg (\sum _a s_a^\rho \mu _a^0+\sum _b s_b^\rho \mu _b\Bigg )\Bigg ] , \end{aligned}$$
(52)

Eq. (49) can be shown to be equivalent to the complex-balance condition for deterministic CRNs with MAK, Eq. (20), with rate constants given by Eqs. (51) and (52). These rate constants include the contribution of the standard-state chemical potentials \(\mu _a^0\) and the chemostats, as is usually the case in MAK [41] (although, without loss of generality, for the purposes of this result, all \(\mu ^0_a\) can taken to be 0). Hence, a CRN for which the deterministic steady-state is complex balanced allows for a steady state of the form (46) for its stochastic and non-ideal version. Solving Eq. (20) for the steady-state concentrations with MAK and rate constants (51) and (52) yields \(c_a^*\) and, thus, the parameters \(\tilde{\mu }_a\) [via Eq. (50)] which appear in the steady-state distribution (46). The exponential relationship between the concentrations \(c_a^*\) and \(\tilde{\mu }_a\) reflects the logarithmic contribution of concentrations in the ideal chemical potential of solutes: \(\mu _a=\mu _a^0+1/\beta \log c_a\).

Equation (46) shows that the steady-state distribution of a non-ideal complex-balanced CRN has the form of an effective Boltzmann distribution, with the standard-state chemical potentials \(\mu _a^0\) shifted by \(\tilde{\mu }_a\) (typically \(\mu _a^0\) would be included within F). From the physical standpoint, it is interesting to note that in Eq. (46) the free-energetic contribution F and the non-equilibrium term \(\sum _a \tilde{\mu }_a n_a\) factor out.

This result is similar to Theorem 6.6 of Ref. [33]—here Eq. (26)— but we have generalised it slightly to include rates of the form (44), which includes the function g that could be of interest in phase-separated systems as it modulates the rates depending on the environment. Moreover, our approach relates both the rates (44) and the steady-state distribution (46) to thermodynamic quantities, like free energies and chemical potentials.

In what follows, we will illustrate the result (46) with a minimal working example of a complex-balanced CRN, and compare its predictions with numerical simulations.

4.1 Example

Let us consider the following CRN—see Fig.  for a graphical representation:

$$\begin{aligned} {\textrm{A}}+\textrm{D} \leftrightharpoons&\,{\textrm{B}}, \nonumber \\ {\textrm{B}} \leftrightharpoons&\, \textrm{C},\nonumber \\ \textrm{C} \leftrightharpoons&\, {\textrm{A}}+\textrm{D}, \end{aligned}$$
(53)

with a free energy taken from a regular-solution theory (where each particle, including the solvent, occupies a finite volume and thus total volume is linked to the total number of particles), see Appendix A for details.

For the sake of simplicity, we assume that the solvent particle number, \(n_\text {sol}\), is conserved, and allow the total volume to vary:

$$\begin{aligned} N=N_\textrm{ABC}+n_\textrm{D} +n_\text {sol}, \end{aligned}$$
(54)

where the total number of particles of species \(\textrm{A}\), \(\textrm{B}\) and \(\mathrm C\),

$$\begin{aligned} N_\textrm{ABC} =n_{\textrm{A}}+n_{\textrm{B}}+n_\textrm{C}, \end{aligned}$$
(55)

is kept constant in the CRN defined in (53).

Fig. 4
figure 4

Graphical representation of the illustrative CRNs of Sects. 4.1 (left) and 5.1.1 (right)

Since the CRN (53) is complex balanced (which can be checked a posteriori), its steady state in the stochastic description and with propensity functions (44) can be obtained from its deterministic dynamical equations (11). To achieve this, we write the stoichiometry matrices

$$\begin{aligned} \varvec{R}= \begin{pmatrix} 1 &{} 0 &{} 0 &{} 1 \\ 0 &{} 1 &{} 0 &{} 0 \\ 0 &{} 0 &{} 1 &{} 0 \end{pmatrix},\, \varvec{S}= \begin{pmatrix} 0 &{} 1 &{} 0 &{} 0 \\ 0 &{} 0 &{} 1 &{} 0 \\ 1 &{} 0 &{} 0 &{} 1 \end{pmatrix} , \end{aligned}$$
(56)

which, together with the reaction constants given by Eqs. (51) and (52) and the free energy (32), completely define an ideal CRN. For simplicity, we assume that the standard-state chemical potentials \(\mu ^0\) take the value 0 and that \({\tilde{k}}_\rho =1\) for every reaction \(\rho \). Finally, as an example, we take the non-equilibrium contribution of the chemostats to be present only in the reaction C\(\leftrightharpoons \)A+D, with \(\sum _b r_b \mu _b=0\) and \(\sum _b s_b \mu _b=\log (5/2) \beta ^{-1}\). These considerations, together with MAK [Eq. (19)] and the dynamics (11), yield the following set of deterministic and ideal equations for the CRN:

$$\begin{aligned} \frac{d n_{\textrm{A}}}{dt}&=n_{\textrm{B}}+\frac{5}{2}\, n_\textrm{C}-2 \, n_{\textrm{A}} n_\textrm{D} \nonumber \\ \frac{d n_{\textrm{B}}}{dt}&=n_\textrm{C}+ n_{\textrm{A}} n_\textrm{D} -2 \, n_{\textrm{B}}\nonumber \\ \frac{d n_\textrm{C}}{dt}&=n_{\textrm{B}}+ n_{\textrm{A}} n_\textrm{D} -\frac{7}{2} \, n_\textrm{C} . \end{aligned}$$
(57)

Note that in the system derived from the matrices (56) \(\text {d}_t n_{\textrm{A}}=\text {d}_t n_\textrm{D}\). For the sake of concreteness, we take as initial conditions

$$\begin{aligned} N_\textrm{ABC}=40 \end{aligned}$$
(58)

and

$$\begin{aligned} n_{\textrm{A}}-n_\textrm{D}=5, \end{aligned}$$
(59)

the solution of the above system at steady state is \(n^*_{\textrm{A}}\simeq 8.1\), \(n^*_{\textrm{B}} \simeq 19.1\), \(n^*_\textrm{C} \simeq 12.7\) and \(n^*_\textrm{D}\simeq 3.1\). It can be checked that this steady-state solution satisfies the complex-balance requirement for MAK, Eq. (20). According to Eq. (50), we have the following identity: \(n^*_a=e^{-\beta \tilde{\mu }_a}\), which enables us to obtain the values of \({\tilde{\mu }}_a\) and the steady-state probability (46).

Note that there are two conservation laws, Eqs. (58) and (59), and four chemical species: hence, \(\pi _\textrm{neq} (\varvec{n})\) is a distribution with only two independent variables.

In order to evaluate Eq. (46) explicitly, let us assume that the system has the following regular-solution free energy

$$\begin{aligned} F(\varvec{n})= \frac{1}{\beta } \log \left( \frac{n_{\textrm{A}}!\, n_{\textrm{B}}!\, n_\textrm{C}!\, n_\textrm{D}!\, n_\textrm{sol}!}{N!}\right) + (n_{\textrm{A}}\mu ^0_{\textrm{A}}+n_\textrm{C}\mu ^0_\textrm{C}+n_\textrm{D}\mu ^0_\textrm{D})+\chi \frac{n_{\textrm{A}} n_\textrm{C}}{N}, \end{aligned}$$
(60)

where the first addend is an entropic term, the second corresponds to the internal energies of the chemical species taken with respect to that of species \(\textrm{B}\), and the third to an interaction between species \(\textrm{A}\) and \(\mathrm C\).

Setting \(\chi =10\) and \(\mu ^0_{\textrm{A}}=\mu ^0_\textrm{C}=\mu ^0_\textrm{D}=\log 2\), we obtain the bimodal steady-state probability depicted in Fig. , which closely matches the one obtained from a simulation of the same CRN using the Gillespie algorithm [42]. Simulations were started in parallel from random Poissonian initial conditions satisfying the constraints above, and the samples were obtained after the simulation relaxed to steady state. Note that, in order to arrive to the set of Eqs. (57), we assumed all \(\mu ^0_a=0\), while in the free energy we are giving them a different value. It would have been equivalent to insert these values of \(\mu ^0_a\) into the system (57) and omit them in the free energy (60).

Fig. 5
figure 5

Examples of marginal probabilities (A) and conditional probabilities (B) of the CRN discussed in Sect. 4.1. Blue triangles are the probabilities obtained from the Gillespie simulation, and the red lines theoretical predictions from our analytical result (46)

5 Lyapunov Function for Complex-Balanced Steady States

A Lyapunov function is a function that is minimised by the dynamics of the system and takes the value 0 at steady state. Under fairly general conditions, the logarithm of the steady-state probability distribution in the stochastic CRN is a Lyapunov function of the deterministic one [43, 44].

While the exact form of the Lyapunov function has been obtained for ideal and complex-balanced CRNs [30, 45], here we demonstrate that for non-ideal, complex-balanced CRNs the following function decreases with the dynamics

$$\begin{aligned} {\mathcal {L}}(\varvec{c})&=-\lim _{V\rightarrow \infty } \frac{1}{V} \log [\pi _\textrm{neq}(\varvec{n})]\nonumber \\ \quad&=\beta \left[ \mathfrak {f}(\varvec{c})+\sum _a \tilde{\mu }_a c_a\right] +\frac{\log Z}{V}, \end{aligned}$$
(61)

where the factor 1/V has been inserted to maintain the magnitude intensive while \(V\rightarrow \infty \). Our approach generalises the results of Anderson and Nguyen [46] for product-form stationary states of CRNs. We will call the function (61) a Lyapunov function: This is a slight abuse of terminology, because we will only prove that \({\mathcal {L}} \) decreases with the dynamics, not that its value is zero at steady state.

The function \({\mathcal {L}}\) equals zero only if

$$\begin{aligned} \frac{\log Z}{V}= -\beta \left[ \mathfrak {f}(\varvec{c}^*)+\sum _a \tilde{\mu }_a c_a^*\right] , \end{aligned}$$
(62)

where the asterisk denotes values at steady state. Given that Z is a normalisation factor for the stochastic complex-balanced CRN at steady state, see Eq. (46), it reads

$$\begin{aligned} Z=\sum _{\varvec{n}} e^{-\beta [F(\varvec{n})+\sum _a \tilde{\mu }_a n_a]}, \end{aligned}$$
(63)

which, for a deterministic CRN involving a large number of particles, can be evaluated using the saddle-point approximation, where the sum is evaluated at the minimum value of the argument of the exponential. If the deterministic system is monostable, then the argument of the exponential has a single local minimum. Therefore, for monostable CRNs, this approximation will yield the correct value and the Lyapunov function Eq. (61) will take the value 0 at steady state. However, care must be taken when handling multistable CRNs in this way, which is why, in order to avoid this complexities, we will not prove that Eq. (61) takes the value 0 at steady state in general. Nevertheless, the fact that this function decreases with the dynamics is sufficient for our purposes.

In what follows we sketch the proof that, for complex-balanced non-ideal CRNs, the Lyapunov function (61) is a decreasing function of time—for a full step-by-step proof, see Appendix D.

Given that the normalisation factor Z does not depend on time but only on the non-equilibrium steady state, the time derivative of \({\mathcal {L}}\) is

$$\begin{aligned}&\frac{d {\mathcal {L}}}{dt} =\sum _{k} \frac{\partial {\mathcal {L}}}{\partial c_{k}} \frac{\partial c_{k}}{\partial t} \nonumber \\&\quad =\beta \sum _{k} (\mu _{k}+\tilde{\mu }_{k}) \left\{ \sum _\rho v_{k}^\rho k_\rho g(\varvec{c}) \left[ e^{\beta ( \sum _a r_a^\rho \mu _a+ \sum _b r_b^\rho \mu _b)} -e^{\beta (\sum _a s_a^\rho \mu _a+\sum _b s_b^\rho \mu _b)}\right] \right\} , \end{aligned}$$
(64)

where in the second line we used Eqs. (11) and (45), together with the assumption \(g_\rho =g\). After adding and subtracting terms of the form \(\sum _a r_a^\rho \tilde{\mu }_a\) in the exponentials (of the form \(\sum _a s_a^\rho \tilde{\mu }_a\) for the second exponential), we repeatedly apply the inequality \(e^x(y-x)\le e^y-e^x\) to the sums of chemical potentials, and obtain

$$\begin{aligned} \frac{d {\mathcal {L}}}{dt} \le&\sum _\rho k_\rho g(\varvec{c}) e^{\beta (\sum _b r_b^\rho \mu _b- \sum _a r_a^\rho \tilde{\mu }_a)} \left[ e^{ \beta \sum _a (\mu _a+\tilde{\mu }_a)s_a^\rho }- e^{\beta \sum _a r_a^\rho (\mu _a+\tilde{\mu }_a)}\right] \nonumber \\&+\sum _\rho k_\rho g(\varvec{c}) e^{\beta (\sum _b s_b^\rho \mu _b- \sum _a s_a^\rho \tilde{\mu }_a) } \left[ e^{\beta \sum _a(\mu _a+\tilde{\mu }_a)r_a^\rho }- e^{\beta \sum _a s_a^\rho (\mu _a+\tilde{\mu }_a)}\right] . \end{aligned}$$
(65)

The expression in the right-hand side (RHS) above can be split in terms of the different complexes in the system:

$$\begin{aligned}&\frac{d {\mathcal {L}}}{dt} \le \sum _{\varvec{z} } g(\varvec{c}) \Bigg \lbrace \sum _{\rho \vert \varvec{s}^\rho =\varvec{z}} k_\rho e^{\beta [\sum _b r_b^\rho \mu _b-\sum _a r_a^\rho \tilde{\mu }_a+ \sum _a (\mu _a+\tilde{\mu }_a)s_a^\rho ]} \nonumber \\&\quad -\sum _{\rho \vert \varvec{r}^\rho =\varvec{z}} k_\rho e^{\beta [\sum _b r_b^\rho \mu _b-\sum _a r_a^\rho \tilde{\mu }_a+ \sum _a r_a^\rho (\mu _a+\tilde{\mu }_a)]} \nonumber \\&\quad +\sum _{\rho \vert \varvec{r}^\rho =\varvec{z}} k_\rho e^{\beta [\sum _b s_b^\rho \mu _b-\sum _a s_a^\rho \tilde{\mu }_a + \sum _a(\mu _a+\tilde{\mu }_a)r_a^\rho ]}\nonumber \\&\quad - \sum _{\rho \vert \varvec{s}^\rho =\varvec{z}} k_\rho e^{\beta [\sum _b s_b^\rho \mu _b- \sum _a s_a^\rho \tilde{\mu }_a+ \sum _a s_a^\rho (\mu _a+\tilde{\mu }_a)]}\Bigg \rbrace . \end{aligned}$$
(66)

For a complex-balanced system, it can be shown that the expression in curly brackets in Eq. (66) vanishes for each complex \(\varvec{z}\) independently, as a consequence of the complex-balance condition for MAK systems, Eq. (20). Then

$$\begin{aligned} \frac{d {\mathcal {L}}}{dt} \le 0, \end{aligned}$$
(67)

and \({\mathcal {L}}\) decreases, or remains unchanged, along a trajectory.

We conclude that, unlike in classical equilibrium systems, here it is not the F that is minimised by the dynamics, but a free energy (61) where the standard chemical potentials \(\mu _a^0\) are shifted by \(\tilde{\mu }_a\). This shift, which is entirely due to the non-equilibrium contribution of the chemostats, enables the system to present non-vanishing chemical-reaction net flows between species at steady-state, which, in the following, we will call chemical currents.

5.1 Spatially Heterogeneous Systems

In order to describe phase-separating systems, in what follows we will incorporate in our framework spatial inhomogeneities. In the deterministic description, concentrations are now a function of space, \(c_a(\varvec{x})\) within a volume \(\Omega \), and the free energy is a functional of these concentrations, \(F[\varvec{c}]\).

The time derivative of the concentrations is given by the following reaction-diffusion (RD) equation

$$\begin{aligned} \frac{\partial c_a(\varvec{x})}{\partial t}=-\varvec{\nabla } \cdot \varvec{J}_a+ \sum _\rho v_a^\rho [J_{+\rho }(\varvec{x})-J_{-\rho }(\varvec{x})], \end{aligned}$$
(68)

where the time dependence of c is omitted, the first term in the RHS of the equation represents diffusion, and the second one the chemical reactions. As in the linear irreversible thermodynamics framework [47], the driving force of the diffusion current \( \varvec{J}_a\) is the gradient of chemical potentials, \(\varvec{\nabla } \mu _a\): the diffusive currents then read

$$\begin{aligned} \varvec{J}_a=-\sum _k {\mathcal {M}}_{ak} \varvec{\nabla } \mu _k, \end{aligned}$$
(69)

where \( {\mathcal {M}}_{ak}\) is the mobility matrix. We assume no-flux boundary conditions

$$\begin{aligned} \varvec{J}_a\vert _{\varvec{x} \in \partial \Omega }=0 \end{aligned}$$
(70)

for the non-chemostatted species, where \(\partial \Omega \) denotes the boundaries of the volume \(\Omega \).

We now consider a generalisation of the Lyapunov function (61) to inhomogeneous systems. In the following, we will show that the dynamics (68) for complex-balanced networks minimise the Lyapunov functional

$$\begin{aligned} L = \beta \int _{\Omega } \textrm{d} \varvec{x} {\mathcal {L}}(\varvec{c}({\textbf{x}})) = \beta F[{\textbf{c}}]+ \beta \int _{\Omega } \textrm{d} \varvec{x} \sum _a \tilde{\mu }_a c_a({\textbf{x}}) \end{aligned}$$
(71)

where \(F[{\textbf{c}}]\) is the free energy of the system, which depends on the concentration profile through

$$\begin{aligned} F[\varvec{c}] = \int _{\Omega } \textrm{d} \varvec{x} \, \mathfrak {f}(\varvec{c}). \end{aligned}$$
(72)

The time derivative of the Lyapunov functional (71) yields

$$\begin{aligned}&\frac{d L}{dt} =\int _\Omega \frac{\partial {\mathcal {L}}}{\partial t}\textrm{d} \varvec{x} \nonumber \\&\quad =\sum _a \int _\Omega \textrm{d} \varvec{x} \, \frac{\partial {\mathcal {L}}}{\partial c_a({\varvec{x}})} \frac{\partial c_a({\varvec{x}})}{\partial t} \nonumber \\&\quad =\sum _a \int _\Omega \textrm{d} \varvec{x} \, \beta [\mu _a(\varvec{x}) + \tilde{\mu }_a] \left[ {\varvec{\nabla }} \cdot \varvec{J}_a + \sum _\rho v_a^\rho (J_{+\rho }-J_{-\rho })\right] , \end{aligned}$$
(73)

where \(\mu _a(\varvec{x})=\delta F[\varvec{c}(\varvec{x})]/\delta c_a(\varvec{x})\) is the local chemical potential.

By applying the results of Sect. 5, Eq. (67), at every spatial point \(\varvec{x}\), we obtain that the second term in the square brackets of the RHS of Eq. (73) is negative or zero. Therefore, to prove that \(dL/dt \le 0 \) it is sufficient to show that the first term in the square brackets of the RHS is also negative or zero. In this regard, we note that

$$\begin{aligned}&\sum _a \int _\Omega \textrm{d} \varvec{x} \, [\mu _a (\varvec{x}) + \tilde{\mu }_a] {\varvec{\nabla }} \cdot \varvec{J}_a \nonumber \\&= \sum _a \int _\Omega \textrm{d} \varvec{x} \lbrace {\varvec{\nabla }} \cdot [(\mu _a (\varvec{x} ) + \tilde{\mu }_a) \varvec{J}_a ] -[{\varvec{\nabla }} (\mu _a (\varvec{x}) + \tilde{\mu }_a)] \cdot \varvec{J}_a \rbrace . \end{aligned}$$
(74)

The first term in the RHS of the last equality vanishes due to the divergence theorem and Neumann boundary conditions (70). By observing that \(\tilde{\mu }\) does not depend on space, the addend containing \(\tilde{\mu }\) in the second term vanishes (\(\nabla \tilde{\mu }_a=0\)). Finally, if the Onsager reciprocal relations for the mobility matrix \( {\mathcal {M}}_{ak}\) hold [48], then the addend containing \(\mu _a({\varvec{x}})\) in the second term is necessarily positive, because it represents the entropy production of a diffusion process [37, 47]. The Onsager reciprocity relations ensure that a system relaxes to equilibrium in the absence of external work. Thus, the condition that the Onsager relations hold is not a limitation of the result but a consequence of thermodynamical consistency.

Combining the results above, we obtain that

$$\begin{aligned} \frac{dL}{dt} \le 0. \end{aligned}$$
(75)

It follows that, for a non-ideal, complex-balanced system, L decreases, which we can now use to obtain useful information about the steady state, along the lines of the free energy minimisation for systems at thermodynamic equilibrium.

Therefore, for a complex-balanced system, we can minimise L (subject to constraints in particle numbers) in order to obtain the concentration profile at steady state. This minimisation results in constraints for the steady-state profile of the form

$$\begin{aligned} \frac{\delta L}{\delta c_a({\textbf{x}})}= \beta (\mu _a ({\textbf{x}})+\tilde{\mu }_a) -\lambda =0, \end{aligned}$$
(76)

where \(\lambda \) is a Lagrange multiplier that enforces the particle-conservation constraint—for further details see Sect. 5.2. Equation (76) implies that in a complex-balaced solution at steady state there cannot be any diffusive currents, since the chemical potential is constant throughout space and the force driving diffusion currents is \(\nabla \mu _a({\varvec{x}})\). Nevertheless, chemical currents can exist at steady state, as noted in the previous section, and the concentration profile may not be homogeneous. This is a major consequence of the present work and it stems directly from the form of the chemical reaction rates and the fact that the network is complex-balanced.

5.1.1 Example

Let us consider the following CRN (see Fig. 4 for a graphical representation):

$$\begin{aligned} {\textrm{A}} \leftrightharpoons {\textrm{B}}\, \nonumber \\ {\textrm{B}} \leftrightharpoons \textrm{C}, \nonumber \\ \textrm{C} \leftrightharpoons {\textrm{A}}, \end{aligned}$$
(77)

with a free energy taken from a regular solution theory, as before. We will first assume that the system is homogeneous and later we will analyse the full reaction-diffusion system.

For simplicity, we assume that the system is driven out of equilibrium solely by imposing a non-equilibrium chemical potential difference in the transition from \(\mathrm C \leftrightharpoons \textrm{A}\), with \(\sum _b s_b \mu _b=-\Delta \beta ^{-1}\) and \(\sum _b r_b \mu _b=0\).

We take all the reaction constants k equal to each other, and note that the network is necessarily complex-balanced, as all chemical reactions are unimolecular (in unimolecular networks each of the species is a complex, hence the steady-state condition is equivalent to the complex-balance condition, if \(g_\rho =g\) for every reaction \(\rho \)).

Proceeding along the lines of Sect. 4.1, in the stochastic description the steady-state of the CRN (77) with propensity functions (44) can be obtained from the following ideal and deterministic rate equations:

$$\begin{aligned} \frac{d n_{\textrm{A}}}{dt}&=n_{\textrm{B}}+e^{-\Delta }n_\textrm{C}-2 n_{\textrm{A}} \\ \frac{d n_{\textrm{B}}}{dt}&=n_\textrm{C}+ n_{\textrm{A}} -2n_{\textrm{B}}\\ \frac{d n_\textrm{C}}{dt}&=n_{\textrm{B}}+ n_{\textrm{A}} -(1+e^{-\Delta })n_\textrm{C} . \end{aligned}$$

The solution of the above system at steady-state is

$$\begin{aligned} n_{\textrm{A}}&=\frac{2 n_\textrm{C}}{3} \left( \frac{1}{2}+e^{-\Delta }\right) , \\ n_{\textrm{B}}&=n_\textrm{C} \left[ \left( \frac{1}{2}+e^{-\Delta }\right) \frac{1}{3}+\frac{1}{2}\right] . \end{aligned}$$

We obtain the values of \(\tilde{\mu }_a\) by identifying \(n_a\) with \(e^{-\beta \tilde{\mu }_a}\) [as in Eq. (50)]. Noting that we can express such potentials with respect to that of species \(\mathrm C\), we obtain the Lyapunov function of the system

$$\begin{aligned} {\mathcal {L}}(\varvec{c})=\beta \mathfrak {f}(\varvec{c})-c_{\textrm{A}} \log \frac{1+2 e^{-\Delta }}{3}-c_{\textrm{B}} \log \left( \frac{1}{2} + \frac{\frac{1}{2}+e^{-\Delta }}{3}\right) -\frac{\log Z}{V}, \end{aligned}$$
(78)

where a detailed expression of the normalisation constant Z is not essential here, because Z is constant along the dynamics, and it does not alter the location of the minima of \({\mathcal {L}}\) in the space of concentrations \(\varvec{c}\).

Unlike above, we will now describe the amount of species with reference to the fraction of volume they occupy at each point of space \(\phi ({\textbf{x}})\). Then,

$$\begin{aligned} \sum _a \phi _a({\textbf{x}}) +\phi _\text {solv} ({\textbf{x}})=1, \end{aligned}$$
(79)

where \(\phi _\text {solv} ({\textbf{x}})\) is the volume fraction of the solvent and the sum runs over solutes only. Equation (79) states that the solution is incompressible and, thus, \(\phi _\text {solv} ({\textbf{x}})=1-\sum _a \phi _a({\textbf{x}}).\) The reason for using volume fractions instead of concentrations is threefold: It is the convention normally used in phase separation studies and regular solution models, it enforces incompressibility (which is the case in most liquids) and is dimensionless. For simplicity we will assume that the molecular volumes of every species is the same, so that \(\phi _a({\textbf{x}})\) is proportional to \(c_a({\textbf{x}})\).

Hence, the following regular solution free-energy density can describe spatial inhomogeneities in an incompressible solution:

$$\begin{aligned} \beta \mathfrak {f}({\varvec{c}})=&\sum _a \phi _a \log \phi _a+ \Bigg (1-\sum _a \phi _a \Bigg )\log \Bigg (1- \sum _a \phi _a \Bigg )\nonumber \\&+ \chi _\textrm{AA} \phi _{\textrm{A}}^2+\chi _\textrm{AB} \phi _{\textrm{A}} \phi _{\textrm{B}}+\sum _{a,k}\kappa _{ak}(\varvec{\nabla } \phi _a) \cdot \varvec{\nabla } \phi _{k}, \end{aligned}$$
(80)

where the first two terms in the RHS are entropic terms and the following two represent the interactions between the solutes. The last addend represents the free-energetic cost of spatial inhomogeneities in the concentration profiles, and is known as Cahn-Hilliard term [49].

Assuming the system is one-dimensional, the resulting Lyapunov functional for the RD system is

$$\begin{aligned} L = \beta \int \textrm{d} x \Bigg [ \mathfrak {f}(\varvec{\phi })+ \sum _a \tilde{\mu }_a \phi _a(x) \Bigg ], \end{aligned}$$
(81)

where \(\tilde{\mu }_a\) are the ones obtained for the homogeneous system and do not depend on the coordinate x.

We set \(\chi _\textrm{AA}=-2\), \(\chi _\textrm{AB}=-7\), \(\Delta =-2\), \(\kappa _\textrm{AA}=\kappa _\textrm{BB}=5\), \(\kappa _\textrm{AB}=1\) and any other Cahn-Hilliard coefficient equal to 0. With this parameter set, the reaction-diffusion system exhibits phase separation at steady state (see Fig. ). By entering this free energy in the RD equations (68) and assuming no state dependency of the reaction constants \(k_\rho \), we obtain a set of equations which describes the dynamics of the system. Figure 6 shows that the Lyapunov functional (81) is minimised by the dynamics, and that the non-equilibrium steady state is characterised by phase coexistence.

Finally, in Fig 6 C, the net reaction flux \(J_{+\rho }-J_{-\rho }\) at steady state as a function of the spatial coordinate is depicted. This net reaction flux is constant in space and, given the topology of the CRN (77), is equal for all reactions \( \rho \). The fact that the net reaction flux is independent of the spatial coordinate despite the varying concentrations (see Fig. 6 B) is a result of chemical reaction fluxes being driven by the chemical potential, which, as argued above, is constant—see Eq. (76). Note that this is also a consequence of having dropped the dependency of the reaction constants on the environment via a function \(g(\varvec{c})\). If all reaction constants were subject to this modulation (which has to be the same for every reaction for our results to hold), then the reaction rates at steady state could be space-dependent but the chemical potential would still be constant.

Fig. 6
figure 6

Numerical results for the CRN (77) obtained by perturbing a homogeneous solution and integrating forward in time the reaction-diffusion equations (68) until a steady state is reached. The system is considered one-dimensional, and its normalised spatial coordinate x lies between zero and one. A) Evolution of the Lyapunov functional as a function of time in logarithmic scale. Here, the Lyapunov functional does not include the constant term \(\log Z\) in Eq. (61). B) Steady-state profile of the system, displaying phase coexistence. The volume fractions \(\phi \) of species \(\textrm{A}\), \(\textrm{B}\) and \(\mathrm C\) are plotted as functions of x. C) Net reaction flux \(J_{+\rho }-J_{-\rho }\) (black line, arbitrary units) at steady state, as a function of x

5.2 Phase Diagram of a Chemically Reactive Mixture

Since the Lyapunov functional for complex-balanced systems discussed in Sect. 5.1 is minimised by the dynamics, it carries plenty of information on the steady state.

Along the lines of phase separation for equilibrium systems, the steady state can be obtained by minimising \(L[\varvec{c}]\) with respect to \(\varvec{c}\), subject to certain constraints, e.g., particle conservation. The concentration profiles which realise the absolute minimum of \(L[\varvec{c}]\) may be either spatially uniform, or depend on space, according to the system parameters. On a qualitative level, the phenomenology of a complex-balanced system does not change much with respect to that of a non-ideal solution at equilibrium, but the non-equilibrium terms may alter the phase diagram, thus tweaking the onset of phase separation.

To illustrate this point, in this Section we consider a non-ideal solution with the CRN (77) in the deterministic description, and obtain its phase diagram. Therefore, we minimise the Lyapunov functional (81) of Sect. 5.1.1, with the particle-conservation constraint

$$\begin{aligned} \phi _N=\frac{1}{\vert \Omega \vert }\int _\Omega \textrm{d} \varvec{x}[\phi _{\textrm{A}}(\varvec{x})+\phi _{\textrm{B}}(\varvec{x})+\phi _\textrm{C}(\varvec{x})], \end{aligned}$$
(82)

where \(\phi _a(\varvec{x})\) is the volume fraction of species a, and the constant \(\phi _N\) fixes the total volume fraction of the solutes. Then, the function that needs to be minimised is the Lagrangian

$$\begin{aligned} \Lambda = \int _\Omega \textrm{d} \varvec{x} \, {\mathcal {L}}(\varvec{\phi }) - \lambda \left\{ \vert \Omega \vert \, \phi _N - \int _\Omega \textrm{d} \varvec{x}\,[\phi _{\textrm{A}}(\varvec{x})+\phi _{\textrm{B}}(\varvec{x})+\phi _\textrm{C}(\varvec{x})]\right\} , \end{aligned}$$
(83)

where \(\lambda \) is the Lagrange multiplier associated with the conservation of solutes, and \(\vert \Omega \vert \) the volume of \(\Omega \).

For the sake of simplicity, we take the typical lengthscale of \(\Omega \) to be large with respect to inter-species interfaces: as a result, the volume fractions \(\varvec{\phi }(\varvec{x})\) can be approximated by piecewise constant functions. If the system phase separates, we assume that only two homogeneous, distinct phases, which we denote by ‘1’ and ‘2’, will appear. Within this assumption, the Lagrangian (83) reads

$$\begin{aligned} \Lambda =\vert \Omega ^1\vert {\mathcal {L}}(\varvec{\phi }^1)+\vert \Omega _2\vert {\mathcal {L}}(\varvec{\phi }^2)- \lambda [\vert \Omega \vert \phi _N -\vert \Omega ^1\vert (\phi ^1_{\textrm{A}}+\phi ^1_{\textrm{B}}+\phi ^1_\textrm{C})-\vert \Omega _2\vert (\phi ^2_{\textrm{A}}+\phi ^2_{\textrm{B}}+\phi ^2_\textrm{C})], \end{aligned}$$
(84)

where \(\Omega _1\) and \(\Omega _2\) stand for the volumes phases 1 and 2, respectively, with \(\vert \Omega _1\vert +\vert \Omega _2\vert = \vert \Omega \vert \), and we consider the following free-energy density

$$\begin{aligned} \beta \mathfrak {f}(\varvec{\phi })=\sum _a \phi _a \log \phi _a + \Bigg (1-\sum _a \phi _a \Bigg ) \log \Bigg (1-\sum _a \phi _a \Bigg )- \chi \phi _{\textrm{A}}^2, \end{aligned}$$
(85)

where all species except A are considered non-interacting and A interacts with itself (\(\chi >0\) implies an effective attraction between A particles).

Fig. 7
figure 7

Top: Steady-state concentration profiles of the example discussed in Sect. 5.2, obtained by numerical integration of the RD equations [Eq. (68)]. The concentrations of each species are plotted as functions of the one-dimensional space coordinate x, from \(x=0\) to \(x=1\). Each panel has a number (roman numerals) associated and corresponds to a different parameter configuration, which is specified by the exact position of the roman numerals in the phase diagram below. The leftmost and rightmost panel correspond to a spatially uniform steady state, while in the two middle panels phase separation occurs. Bottom: Phase diagrams as functions of the total solute fraction \(\phi _N\) and interaction parameter \(\chi \) (A) or non-equilibrium driving \(\Delta \) (B), obtained by minimising the Lagrangian \(\Lambda \), see Appendix E. The numerical minimisation requires higher precision as the parameters near criticality, which is why the density of data around the critical point decreases. The color code represents the amount of A particles along the phase-coexistence lines. While in the top panels the width of the inter-phase interface is finite to ease numerical integration, in the lower panels such width has been assumed to vanish

The minimisation of \(\Lambda \) yields the phase diagram in Fig. , see Appendix E for details. Phase separation occurs in regions II and III of the phase diagram, as shown in the concentration profiles displayed in the insets.

From the form of the free energy (85), we can see that is the species \(\textrm{A}\) that drives phase separation, since for \(\chi >0\) the free energy will favour segregating A from the rest of the solution. Thus, whether the steady-state displays one phase or a coexistence of phases also depends on the value of the non-equilibrium chemical potential difference \(\Delta \), which can alter the concentration of A at steady state and, hence, modulate phase separation, as can be seen in Fig 7 B.

6 Discussion

In this work, we have shown that for a chemically reactive non-ideal solution we can obtain results for complex-balanced networks analogous to those for ideal solutions, provided that the system is modelled in a thermodynamically consistent way. This implies that the rates of the chemical reactions incorporate the interactions between the species in the system and, therefore, mass-action kinetics (MAK) no longer holds. By generalising MAK to a non-ideal solution, we obtained the steady-state probability distribution for a stochastic complex-balanced CRN and the Lyapunov function of its deterministic counterpart. Furthermore, after including diffusion in the description of the system we were also able to find a Lyapunov functional for the reaction-diffusion system, functional that determines the phase diagram of the system when minimised.

Our results are of particular importance for non-equilibrium phase-separating systems. By combining previous results from the mathematical theory of CRNs [33, 46] and concepts of non-equilibrium thermodynamics [37, 48], we found that the resulting complex-balanced RD system cannot sustain diffusion currents at steady state, see Eq. (76). Since, in many cases, diffusion currents are required for pattern formation in reaction-diffusion systems, breaking complex balance is a necessary condition to obtain such patterned steady states, at least when interactions are modelled in a thermodynamically consistent way unlike, e.g., those in Refs. [19, 20]. In this regard, complex balance can be broken in two ways: First, by choosing a suitable network topology that allows for a steady state which is not complex-balanced, as in Ref. [21]. Second, in a system where different phases coexist, by allowing the reaction rates to depend differently on local environment: For example, in Ref. [25] a patterned steady-state is produced by allowing one (and only one) of the reaction constants to depend on the concentration of an enzyme which localises in one of the phases. Mathematically, this violates one of the necessary conditions for our results to hold, namely \(g_\rho =g\) (see Sect. 4), thus allowing for more general steady states.

In biological cells, phase separation has been hypothesised to perform many functions, such as, accelerating biochemical reactions within the condensate irrespective of the rate of the reaction in the dilute phase [50, 51]. The present work implies that, in order to control chemical reactions in each of the phases independently (at steady state) breaking complex balance is necessary, by virtue of Eq. (76). Indeed, in a complex-balanced system, the chemical potential of every species is constant throughout space. Then, given that the force driving the chemical reactions are the chemical potentials, the reaction rates in both phases are related, making it impossible to regulate the rates of chemical reactions in each phase in a fully independent way, and suggesting that breaking complex balance in one of the two ways outlined above is crucial for such control.

Clearly, the largest limitation of our study is the fact that we are restricted to complex-balanced networks, which, as shown above, constrains its phenomenology. However, these networks still have a broad applicability and interest in cell biology, examples of which are the E. coli chemotaxis system [52], kinetic proofreading [53, 54] or histone post-translational modifications [55] (the latter being particularly interesting since the model includes chemical reaction rates that are not MAK, which makes our theory particularly relevant to this case).

Overall, complex balance is known to be a key feature of CRNs which determines not only their behavior [32, 33] but also their thermodynamic properties [34]. In this analysis, we further stress the connection between the characteristics of the reaction network and the thermodynamically consistent structure of the physical system, in an effort to generalise results from ideal CRNs, and explore non-equilibrium dynamics of complex-balanced networks. However, little is known about non-complex balanced systems and, given our results, further research regarding the behaviour of this type of networks out of thermodynamic equilibrium would be of the utmost importance, both from the physical [56] and biological [51] point of view.