in

A density functional theory for ecology across scales

Modular components of the DFTe energy functional

The central ingredient of DFTe is an energy functional E, assembled according to Eq. (1). The methodology of DFTe can be understood by inspecting the dispersal and environmental energies in Eqs. (2) and (3) without interactions. In our first case study, illustrated in Fig. 2 and Supplementary Fig. 2, we demonstrate that equation (3), in conjunction with Eq. (2), can realistically describe the influence of the environment on species’ distributions. Mechanisms that alter the trade-off between dispersal and environment can be introduced as part of Eint. For instance, back reactions on the environment could be modelled with a bifunctional Ebr[Venv, n] that yields the equilibrated modified environment ({V}_{s}^{{{{{{{{rm{env}}}}}}}}}+delta {E}_{{{{{{{{rm{br}}}}}}}}}[{{{{{{{{bf{V}}}}}}}}}^{{{{{{{{rm{env}}}}}}}}},{{{{{{{bf{n}}}}}}}}]/delta {n}_{s}({{{{{{{bf{r}}}}}}}})), cf. Eq. (5).

In the following we make explicit the interaction and resource energies that enter Eq. (1) and are used in our case studies of Figs. 2–7. We let Eint[n] include all possible bipartite interactions

$${E}_{gamma }[{{{{{{{bf{n}}}}}}}}]=mathop{sum }limits_{{s,{s}^{{prime} }!=!1}atop {{s}^{{prime} }ne s}}^{S}{int}_{A}({{{{{{{rm{d}}}}}}}}{{{{{{{bf{r}}}}}}}})({{{{{{{rm{d}}}}}}}}{{{{{{{{bf{r}}}}}}}}}^{{prime} }){n}_{s}{({{{{{{{bf{r}}}}}}}})}^{{alpha }_{s}},{gamma }_{s{s}^{{prime} }}({{{{{{{bf{r}}}}}}}},, {{{{{{{{bf{r}}}}}}}}}^{{prime} }){n}_{{s}^{{prime} }}{({{{{{{{{bf{r}}}}}}}}}^{{prime} })}^{{beta }_{{s}^{{prime} }}},$$

(6)

which include amensalism, commensalism, mutualism, and so forth. Here, ({alpha }_{s},, {beta }_{{s}^{{prime} }}ge 0), and the interaction kernels ({gamma }_{s{s}^{{prime} }}) are assembled from fitness proxies of species s and ({s}^{{prime} }) (Supplementary Table 1). Higher-order interactions can be introduced, for example, through (i) terms like ({n}_{s},{gamma }_{s{s}^{{prime} }},{n}_{{s}^{{prime} }},{gamma }_{{s}^{{prime} }{s}^{{primeprime} }}^{{prime} },{n}_{{s}^{{primeprime} }}) that build on pairwise interactions or (ii) genuinely multipartite expressions like ({gamma }_{s{s}^{{prime} }{s}^{{primeprime} }}{n}_{s},,{n}_{{s}^{{prime} }},{n}_{{s}^{{primeprime} }}). Multi-partite interactions based on bipartite interactions do not seem to be an uncommon scenario48. However, there may be systems where nonzero coefficients ({gamma }_{s{s}^{{prime} }{s}^{{primeprime} }}) couple all species. This poses a challenge for mechanistic theories in general. Then, ‘simpler subsystems’ that have to be included in the DFTe workflow of Fig. 1a can only refer to situations where other energy components are absent, such as resource terms or complex environments. For example, the coefficients ({gamma }_{s{s}^{{prime} }{s}^{{primeprime} }}) could be extracted in an experiment with a controlled simple environment and then used to model the interacting species in a real-world setting. For (({alpha }_{s},, {beta }_{{s}^{{prime} }})=(1,1)) we identify the contact interaction in physics as ({gamma }_{s{s}^{{prime} }}propto delta ({{{{{{{bf{r}}}}}}}}-{{{{{{{{bf{r}}}}}}}}}^{{prime} })) with the two-dimensional delta function δ( ), while the Coulomb interaction amounts to setting ({gamma }_{s{s}^{{prime} }}propto 1/|{{{{{{{bf{r}}}}}}}}-{{{{{{{{bf{r}}}}}}}}}^{{prime} }|). The mechanistic effect of these interaction kernels on the density distributions is the same in ecology as it is in physics—a mathematical insight that inspired us to build ecological analogues to the phenomenology of quantum gases, which feature functionals of the kind in Eq. (6). Note that we do not introduce any quantum effects into ecology despite the fact that the mathematical structure of DFTe is borrowed in part from quantum physics. While the contact interaction is a suitable candidate for plants and especially microbes52, we expect long-range interactions (for example, repulsion of Coulomb type) to be more appropriate for species with long-range sensors, such as eyes. Both types of interactions feature in describing the ecosystems addressed in this work.

In a natural setting the equilibrium abundances are ultimately constrained by the accessible resources. It is within these limits of resource availability that environment as well as intra- and inter-specific interactions can shape the density distributions. An energy term for penalising over- and underconsumption of resources is thus of central importance. Each species consumes resources from some of the K provided resources, indexed by k. A subset of species consumes the locally available resource density ρk(r) according to the resource requirements νks, which represent the absolute amount of resource k consumed by one individual (or aggregated constituent) of species s. The simple quadratic functional

$${E}_{{{{{{{{rm{Res}}}}}}}}}[{{{{{{{bf{n}}}}}}}}]={int}_{A}({{{{{{{rm{d}}}}}}}}{{{{{{{bf{r}}}}}}}})mathop{sum }limits_{k=1}^{K}{{{{{{{{mathcal{L}}}}}}}}}_{k}left({{{{{{{bf{n}}}}}}}},, {rho }_{k}right)equiv zeta {int}_{A}({{{{{{{rm{d}}}}}}}}{{{{{{{bf{r}}}}}}}})mathop{sum }limits_{k=1}^{K}{w}_{k}({{{{{{{bf{r}}}}}}}}){left[mathop{sum }limits_{s=1}^{S}{nu }_{ks}{n}_{s}({{{{{{{bf{r}}}}}}}})-{rho }_{k}({{{{{{{bf{r}}}}}}}})right]}^{2}$$

(7)

proves appropriate. Here, νksns is the portion of resource density ρk that is consumed by species s. That is, νks > 0 indicates that s requires resource k. If Eq. (7) is the total energy functional, then a single-species system with a single resource equilibrates with density n1(r) = ρ1(r)/ν11 at every position r, and additional DFTe energy components would modify this equilibrium. Predator–prey relationships are introduced by making species k a resource ({rho }_{k}=left]{n}_{k}right[), where (left]nright[) declares n a constant w.r.t. the functional differentiation of E, that is, the predator tends to align with the prey, not the prey with the predator. In view of the energy minimisation, the quadratic term in Eq. (7) entails that regions of low resource density ρk are less important than regions of high ρk. The different resources k have the same ability to limit the abundances, such that the limiting resource k = l at r has to come with the largest of weights wl(r), irrespective of the absolute amounts of resources at r. For example, the weights wk have to ensure that an essential but scarce mineral has (a priori) the same ability to limit the abundances as a resource like water, which might be abundant in absolute terms. To that end, we specify the weights

$${w}_{k}({{{{{{{bf{r}}}}}}}})=frac{1}{{bar{rho }}_{k}^{2}}mathop{sum}limits_{s}eta ({nu }_{ks})exp left[sigma left(frac{{lambda }_{ks}}{{lambda }_{ls}}-1right)right],$$

(8)

which are inspired by the smooth minimum function, where σ < 0, λks(r) = ρk(r)/νks, and the carrying capacity of the limiting resource is ({lambda }_{ls}=mathop{min }limits_{k},{lambda }_{ks}). The step function η( ) in Eq. (8) ensures that only resources k that are actually consumed by species s contribute to wk. We rescale wk using the average ({bar{rho }}_{k}=frac{1}{A}{int}_{A}({{{{{{{rm{d}}}}}}}}{{{{{{{bf{r}}}}}}}}),{rho }_{k}({{{{{{{bf{r}}}}}}}})), which puts all resources on equal footing in their ability to limit abundances and renders ({E}_{{{{{{{{rm{Res}}}}}}}}}) invariant under change of resource units. The ratio of carrying capacities in Eq. (8) implements the relative importance of all resources at r, with resources k ≠ l suppressed exponentially according to their deviation from their ability to limit the abundances. For example, with σ = − 4 and λks = 2λls, resource k ≠ l is largely irrelevant for species s as it weighs in at less than 2% compared to the limiting resource l. There can be multiple limiting resources for a species s, most conceivably, multiple resources that vanish locally. In the limit of vanishing resource density (ρl,  λls → 0), the exponential in Eq. (8) reduces to the Kronecker-delta δkl, thereby rendering all resources with λks > λls irrelevant at r. Using ({E}_{{{{{{{{rm{Res}}}}}}}}}), we show that an analytically solvable minimal example of two amensalistically interacting species already exhibits a plethora of resource-dependent equilibrium states (see Supplementary Notes and Supplementary Fig. 1).

We specify the DFTe energy functional in Eq. (1) by summing Eqs. (2), (3), (6), and (7) and by (optionally) constraining the abundances to N via Lagrange multipliers μ:

$$E[{{{{{{{bf{n}}}}}}}},, {{{{{{{boldsymbol{mu }}}}}}}}]({{{{{{{bf{N}}}}}}}}) equiv E[{{{{{{{bf{n}}}}}}}}]+{E}_{{{{{{{{boldsymbol{mu }}}}}}}}}[{{{{{{{bf{n}}}}}}}}]({{{{{{{bf{N}}}}}}}}) equiv {E}_{{{{{{{{rm{dis}}}}}}}}}[{{{{{{{bf{n}}}}}}}}]+{E}_{{{{{{{{rm{env}}}}}}}}}[{{{{{{{bf{n}}}}}}}}]+{E}_{gamma }[{{{{{{{bf{n}}}}}}}}]+{E}_{{{{{{{{rm{Res}}}}}}}}}[{{{{{{{bf{n}}}}}}}}]+mathop{sum }limits_{s=1}^{S}{mu }_{s}left({N}_{s}-{int}_{A}({{{{{{{rm{d}}}}}}}}{{{{{{{bf{r}}}}}}}}),{n}_{s}right).$$

(9)

Uniform situations are characterised by spatially constant ingredients ns = Ns/A, ρk = Rk/A, coefficients τs, etc. for the DFTe energy, such that Eq. (9) reduces to a function E(N) with building blocks

$${E}_{{{{{{{{rm{dis}}}}}}}}}longrightarrow frac{1}{2,A}mathop{sum }limits_{s=1}^{S}{tau }_{s},{N}_{s}^{2},$$

(10)

$${E}_{{{{{{{{rm{env}}}}}}}}}longrightarrow mathop{sum }limits_{s=1}^{S}{V}_{s}^{{{{{{{{rm{env}}}}}}}}},{N}_{s},$$

(11)

$${E}_{gamma }longrightarrow mathop{sum }limits_{{s,{s}^{{prime} }!=!1}atop {{s}^{{prime} }ne s}}^{S}frac{{N}_{s}^{{alpha }_{s}},{gamma }_{s{s}^{{prime} }},{N}_{{s}^{{prime} }}^{{beta }_{{s}^{{prime} }}}}{{A}^{{alpha }_{s}+{beta }_{{s}^{{prime} }}-1}},$$

(12)

$${E}_{{{{{{{{rm{Res}}}}}}}}}longrightarrow Amathop{sum }limits_{k=1}^{K}{{{{{{{{mathcal{L}}}}}}}}}_{k}left({{{{{{{bf{N}}}}}}}}/A,, {R}_{k}/Aright).$$

(13)

Ecosystem equilibria from the DFTe energy functional

The general form of Eq. (9) gives rise to two types of minimisers (viz., equilibria): First, we term

$${{{{{{{mathcal{H}}}}}}}}({{{{{{{bf{N}}}}}}}})equiv E[tilde{{{{{{{{bf{n}}}}}}}}}]equiv mathop{min }limits_{{{{{{{{bf{n}}}}}}}}}left{E[{{{{{{{bf{n}}}}}}}}],left|,{int}_{A}({{{{{{{rm{d}}}}}}}}{{{{{{{bf{r}}}}}}}}),{{{{{{{bf{n}}}}}}}}({{{{{{{bf{r}}}}}}}})={{{{{{{bf{N}}}}}}}},{{{{{{{rm{(fixed)}}}}}}}}right.right}$$

(14)

the ‘DFTe hypersurface’, with (tilde{{{{{{{{bf{n}}}}}}}}}) the energy-minimising spatial density profiles for given (fixed) N. Second, the ecosystem equilibrium is attained at the equilibrium abundances (hat{{{{{{{{bf{N}}}}}}}}}={int}_{A}({{{{{{{rm{d}}}}}}}}{{{{{{{bf{r}}}}}}}}),hat{{{{{{{{bf{n}}}}}}}}}({{{{{{{bf{r}}}}}}}})), which yield the global energy minimum

$${{{{{{{mathcal{H}}}}}}}}(hat{{{{{{{{bf{N}}}}}}}}})=mathop{min }limits_{{{{{{{{bf{N}}}}}}}}},{{{{{{{mathcal{H}}}}}}}}({{{{{{{bf{N}}}}}}}}),$$

(15)

where the minimisation samples all admissible abundances, that is, ({{{{{{{bf{N}}}}}}}}in {left({{mathbb{R}}}_{0}^{+}right)}^{times S}) if no further constraints are imposed.

The direct minimisation of E[n] is most practical for uniform systems, which only require us to minimise E(N) over an S-dimensional space of abundances. For the general nonuniform case, we adopt a two-step strategy that reflects Eqs. (14) and (15). First, we obtain the equilibrated density distributions on ({{{{{{{mathcal{H}}}}}}}}) for fixed N from the computational DPFT framework26,27,28,29,30,31. Second, a conjugate gradient descent searches ({{{{{{{mathcal{H}}}}}}}}({{{{{{{bf{N}}}}}}}})) for the global minimiser (hat{{{{{{{{bf{N}}}}}}}}}). Technically, we perform the computationally more efficient descent in μ-space. Local minima are frequently encountered, and we identify the best candidate for the global minimum from many individual runs that are initialised with random μ. Note that system realisations with energies close to the global minimum, especially local minima, are likely observable in reality, assuming that the system can equilibrate at all. There is always an equilibrium if the energy functional is bounded from below, together with the fact that the support (abundances/densities) of the energy functional is finite in any practical application. If some DFTe energy components are chosen (too) negative, the system can be unstable, in which case the energy functional has no minimum and is inappropriate for modelling the equilibrium in question. This means that another energy functional has to be considered, or, in the worst case, that DFTe is incapable of simulating this system. We also caution that no numerical optimisation algorithms for non-convex black-box functions can guarantee to find the global minimum, not even approximately. Without analytically available characteristics of the global minimum, all one may hope for are candidates of the minimiser, and those may not even be local minima—there is no way to be certain that an optimum proposed by a numerical optimisation algorithm is stable.

Density-potential functional theory (DPFT) in Thomas–Fermi (TF) approximation

Defining

$${V}_{s}({{{{{{{bf{r}}}}}}}})={mu }_{s}-frac{delta {E}_{{{{{{{{rm{dis}}}}}}}}}[{{{{{{{bf{n}}}}}}}}]}{delta {n}_{s}({{{{{{{bf{r}}}}}}}})}$$

(16)

for all s, we obtain the reversible Legendre transform

$${E}_{{{{{{{{rm{dis}}}}}}}}}^{{{{{{{{rm{L}}}}}}}}}[{{{{{{{bf{V}}}}}}}}-{{{{{{{boldsymbol{mu }}}}}}}}]={E}_{{{{{{{{rm{dis}}}}}}}}}[{{{{{{{bf{n}}}}}}}}]+mathop{sum }limits_{s=1}^{S}{int}_{A}({{{{{{{rm{d}}}}}}}}{{{{{{{bf{r}}}}}}}}),({V}_{s}-{mu }_{s}),{n}_{s}$$

(17)

of the dispersal energy and thereby supplement the total energy with the additional variables V:

$$E[{{{{{{{bf{V}}}}}}}},, {{{{{{{bf{n}}}}}}}},, {{{{{{{boldsymbol{mu }}}}}}}}]({{{{{{{bf{N}}}}}}}})={E}_{{{{{{{{rm{dis}}}}}}}}}^{{{{{{{{rm{L}}}}}}}}}[{{{{{{{bf{V}}}}}}}}-{{{{{{{boldsymbol{mu }}}}}}}}]-{int}_{A}({{{{{{{rm{d}}}}}}}}{{{{{{{bf{r}}}}}}}}),{{{{{{{bf{n}}}}}}}}cdot ({{{{{{{bf{V}}}}}}}}-{{{{{{{{bf{V}}}}}}}}}^{{{{{{{{rm{env}}}}}}}}})+{E}_{{{{{{{{rm{int}}}}}}}}}[{{{{{{{bf{n}}}}}}}}]+{{{{{{{boldsymbol{mu }}}}}}}}cdot {{{{{{{bf{N}}}}}}}}.$$

(18)

This density-potential functional is equivalent to (but more flexible than) the density-only functional E[n,  μ](N). The minimisers of E[n] are thus among the stationary points of Eq. (18) and are obtained by solving

$${n}_{s}[{V}_{s}-{mu }_{s}]({{{{{{{bf{r}}}}}}}})=frac{delta {E}_{{{{{{{{rm{dis}}}}}}}}}^{{{{{{{{rm{L}}}}}}}}}[{V}_{s}-{mu }_{s}]}{delta {V}_{s}({{{{{{{bf{r}}}}}}}})}$$

(19)

and

$${V}_{s}[{{{{{{{bf{n}}}}}}}}]({{{{{{{bf{r}}}}}}}})={V}_{s}^{{{{{{{{rm{env}}}}}}}}}({{{{{{{bf{r}}}}}}}})+frac{delta {E}_{{{{{{{{rm{int}}}}}}}}}[{{{{{{{bf{n}}}}}}}}]}{delta {n}_{s}({{{{{{{bf{r}}}}}}}})}$$

(20)

self-consistently for all ns while enforcing ∫A(dr) ns(r) = Ns. Specifically, starting from V(0) = Venv, such that ({n}_{s}^{(0)}={n}_{s}[{V}_{s}^{(0)}-{mu }_{s}^{(0)}]), we iterate

$${n}_{s}^{(i)}mathop{longrightarrow }limits^{{{{{{{{rm{equation}}}}}}}},(20)}{V}_{s}^{(i+1)}={V}_{s}[{{{{{{{{bf{n}}}}}}}}}^{(i)}]mathop{longrightarrow }limits^{{{{{{{{rm{equation}}}}}}}},(19)}{n}_{s}^{(i+1)}=(1-{theta }_{s}),{n}_{s}^{(i)}+{theta }_{s},{n}_{s}left[{V}_{s}^{(i+1)}-{mu }_{s}^{(i+1)}right]$$

(21)

until all ns are converged sufficiently. This self-consistent loop establishes a trade-off between dispersal energy and effective environment V by forcing an initial out-of-equilibrium density distribution to equilibrate at fixed N. We adjust ({mu }_{s}^{(i)}) in each iteration i such that ({n}_{s}^{(i)}) integrates to Ns. Small enough density admixtures, with 0 < θs < 1, are required for convergence. Each point of ({{{{{{{mathcal{H}}}}}}}}({{{{{{{bf{N}}}}}}}})) in Eq. (14) represents the thus-equilibrated system for given N. The dispersal energy Edis[ns] in Eq. (2), where an increase of the dispersal pressure constants τs tends to dilute ns (see also Supplementary Fig. 2), is only one component of the total energy and has to be balanced against, for example, the environmental energy. This trade-off produces the aggregation of, for example the fruit flies in Fig. 2 and the grasses in Fig. 4. In the latter case the confining role is played by the interaction potential, not the environmental potential, which are combined anyway through Eq. (5). If Edis with positive τs were the only energy component in an unconstraining, i.e., flat and infinite environment, then (mathop{min }limits_{{n}_{s}},{E}_{{{{{{{{rm{dis}}}}}}}}}[{n}_{s}]=0) for a density that is maximally dispersed/diluted with ns (r) → 0 everywhere.

Assuming a given interaction energy, we require an explicit expression for the right-hand side of Eq. (19) to realise the self-consistent loop of Eq. (21). For two-dimensional fermion gases in TF approximation28, we have

$${E}_{{{{{{{{rm{dis}}}}}}}}}^{{{{{{{{rm{L}}}}}}}}}[{{{{{{{bf{V}}}}}}}}-{{{{{{{boldsymbol{mu }}}}}}}}]=-frac{1}{2}mathop{sum }limits_{s=1}^{S}int({{{{{{{rm{d}}}}}}}}{{{{{{{bf{r}}}}}}}}),frac{1}{{tau }_{s}}{[{mu }_{s}-{V}_{s}]}_{+}^{2},$$

(22)

which delivers (i) the density in Eq. (4) to be used for the right-hand side of Eq. (19) and (ii) Eq. (2) via Eq. (17) upon inverting the functional relationship n[V] of Eq. (4). For stabilising the numerics if necessary or if, for example, unambiguous derivatives of the density are sought, we replace Eq. (4) by its smooth version

$${n}_{s}[{V}_{s}-{mu }_{s}]({{{{{{{bf{r}}}}}}}},, T)=frac{1}{{tau }_{s}}{left[{mu }_{s}-{V}_{s}right]}_{T},$$

(23)

where ({[x]}_{T}=T,log left[1+exp left(x/Tright)right]) is a smooth version of [x]+. If τs = 0, we can add a dispersal energy with positive τs to E in order to execute the self-consistent loop with Eqs. (4) or (23), and compensate by subtracting the same dispersal energy from the interaction energy, which enters Eq. (20). The notation ns[Vs − μs](r) declares that ns is a functional (function of functions) of Vs − μs, and that ns is also a function of r. In the specific case of Eq. (4), the functional dependence of ns reduces to a trivial dependence on Vs − μs, which renders ns dependent on r alone—a consequence of Eq. (22) as the source of Eq. (4). Alternatives to Eq. (22) with nonlocal integrands will make ns a nontrivial functional of Vs − μs, for example, ({n}_{s}[{V}_{s}-{mu }_{s}]({{{{{{{bf{r}}}}}}}})=frac{1}{{tau }_{s}}int({{{{{{{rm{d}}}}}}}}{{{{{{{{bf{r}}}}}}}}}^{{prime} })frac{{[{mu }_{s}-{V}_{s}({{{{{{{{bf{r}}}}}}}}}^{{prime} })]}_{+}}{|{{{{{{{bf{r}}}}}}}}-{{{{{{{{bf{r}}}}}}}}}^{{prime} }|}), which reduces to Eq. (4) if (1/|{{{{{{{bf{r}}}}}}}}-{{{{{{{{bf{r}}}}}}}}}^{{prime} }|) is replaced by (delta ({{{{{{{bf{r}}}}}}}}-{{{{{{{{bf{r}}}}}}}}}^{{prime} })).

Explicit parameterisations of the DFTe energy functional

We model ecological phenomena with the help of the potentials introduced in Eqs. (5) and (20) as a consequence of the energy functional. They are mathematical constructs that can be measured and validated only through a mathematical relation with observable quantities like densities and abundances. At best, we can claim that these mathematical constructs describe our observations appropriately. The situation is no different in physics, see Supplementary Notes. We also note that all DFTe parameters of the specific data-driven models pertinent to Figs. 2–5 and 7 are either fit parameters or are inferred from the data.

Parameterisations for the fruit flies in heated chambers

In view of Eq. (4), an educated guess informed by the measured reference density ({n}_{{{{{{{{rm{ref}}}}}}}}}^{{{{{{{{rm{1Dc}}}}}}}}}) (see Supplementary Fig. 2) is a quadratic environment induced by the heat source at x0. We also include a repulsive long-range interaction, since (i) the data in Fig. 2g of ref. 25 suggests that the interaction is quadratic in the density and (ii) fruit flies have to sense their peers remotely, for example, in defending territory53. This leaves us with two parameters, ε and γ, for fitting the minimising density of

$$E[n,, mu ](N), =frac{1}{2}{int}_{A}({{{{{{{rm{d}}}}}}}}{{{{{{{bf{r}}}}}}}}),n{({{{{{{{bf{r}}}}}}}})}^{2}+varepsilon {int}_{A}({{{{{{{rm{d}}}}}}}}{{{{{{{bf{r}}}}}}}}){(x+{x}_{0})}^{2},n({{{{{{{bf{r}}}}}}}})+gamma {int}_{A}({{{{{{{rm{d}}}}}}}}{{{{{{{bf{r}}}}}}}})({{{{{{{rm{d}}}}}}}}{{{{{{{{bf{r}}}}}}}}}^{{prime} })frac{n({{{{{{{bf{r}}}}}}}})n({{{{{{{{bf{r}}}}}}}}}^{{prime} })}{|{{{{{{{bf{r}}}}}}}}-{{{{{{{{bf{r}}}}}}}}}^{{prime} }|} ,,+mu left(N-{int}_{A}({{{{{{{rm{d}}}}}}}}{{{{{{{bf{r}}}}}}}}),n({{{{{{{bf{r}}}}}}}})right)$$

(24)

to ({n}_{{{{{{{{rm{ref}}}}}}}}}^{{{{{{{{rm{1Dc}}}}}}}}}). In the Supplementary Notes we offer a more detailed account of the reasoning behind Eq. (24). In ref. 25 the interaction parameters from the quasi-one-dimensional (1D) chamber are combined with the environmental information from a low-density experiment (three flies) in a ‘staircase chamber’ to predict a high-density distribution of 220 flies (labelled ‘DFFT’ in Fig. 2b). This is a reasonable procedure, since the low-density three-flies experiment represents a situation with very small total repulsion and is therefore well suited for extracting the environmental influence on the density distribution. We thus follow the same strategy. Keeping γ = 9 cm from the density fit to the quasi-1D chamber setup, we get ε = 14.5 cm−2 for three flies in the staircase chamber and use both parameters for predicting the density distribution of 220 flies (labelled ‘DFTe’ in Fig. 2b). Since γ is (i) one of the system’s characteristic length scales, (ii) an estimator of the spatial reach of the long-range interaction, and (iii) close to the system size, we deem the fruit flies setup a small-scale system—in contrast to the large-scale contact-interacting systems of Figs. 4 and 6.

Parameterisations for the resource competition among four algae

We face a uniform environment with S species and two resources. An amensalistic interaction is an appropriate candidate for putting a subset of species at a disadvantage relative to their heterospecifics (see Supplementary Table 1). We rule out parasitism, understood in the sense of an asymmetric interaction, for which the DFTe equilibria do not produce the correct survivors in all reference resource cases ({{{{{{{{mathcal{R}}}}}}}}}_{1-7}) (see Supplementary Table 2). In contrast to the fruit-flies study above, the abundances are not fixed but are rather to be determined as minimisers of the N-dependent energy function (E({{{{{{{bf{N}}}}}}}})={E}_{{{{{{{{rm{Res}}}}}}}}}({{{{{{{bf{N}}}}}}}})+{E}_{gamma }({{{{{{{bf{N}}}}}}}})), assembled from Eqs. (10)–(13). The spatially uniform interaction kernel

$${gamma }_{s{s}^{{prime} }}=gamma left{{left[{left(frac{{f}_{s}}{{f}_{{s}^{{prime} }}}right)}^{kappa }-1right]}_{+}+{left[{left(frac{{g}_{s}}{{g}_{{s}^{{prime} }}}right)}^{1/kappa }-1right]}_{+}right}$$

(25)

for Eγ(N), see Eq. (12), is assembled from the fitness proxies

$${f}_{s}=mathop{sum }limits_{k=1}^{2}frac{{w}_{k}}{{R}_{sk}^{*}}$$

(26)

and

$${g}_{s}=mathop{sum }limits_{k=1}^{2}frac{{w}_{k}}{{nu }_{ks}},$$

(27)

which we assume to influence the species’ ability to consume the provided resources in the presence of heterospecifics. In the Supplementary Notes we provide a complementary step-by-step account of the intuition that leads us to Eqs. (25)–(28). The s-specific traits ({R}_{sk}^{*}) (the densities of resource k, below which species s cannot survive in monoculture) and νks (see Eq. (7)) follow from monoculture experiments (see Supplementary Notes and Table 1 of ref. 1). The exponent κ in Eq. (25) introduces a hierarchy between the fitness proxies of Eqs. (26) and (27) and serves as a second parameter to be used in the fitting of our reference data, which are all 42 ‘reference’ abundances ({{{{{{{{bf{N}}}}}}}}}_{{{{{{{{mathcal{R}}}}}}}}}) of two-species R*-equilibria that follow from ({{{{{{{{mathcal{R}}}}}}}}}_{1-7}). The parameter γ enables the trade-off between competition and resource energy. In the spirit of R*-theory, we choose σ → −  in Eq. (8), such that only the limiting resource for each species enters the weights wk for ({E}_{{{{{{{{rm{Res}}}}}}}}}). Finally, the minimisers of

$$E({{{{{{{bf{N}}}}}}}})=mathop{sum }limits_{k=1}^{2}{w}_{k}{left[mathop{sum }limits_{s=1}^{S}{nu }_{ks}{N}_{s}-{rho }_{k}right]}^{2}+mathop{sum }limits_{{s,{s}^{{prime} }!=!1}atop {{s}^{{prime} }ne s}}^{S}{gamma }_{s{s}^{{prime} }},{N}_{{s}^{{prime} }}$$

(28)

yield the best fit to ({{{{{{{{bf{N}}}}}}}}}_{{{{{{{{mathcal{R}}}}}}}}}) for γ = 8 × 10−8 and κ = 8, used for modelling the three- and four-species communities in Fig. 3.

It would be surprising if Eq. (25) were the only possible choice for the interaction kernel, and it is quite likely that many different energy functionals that encode different mechanisms and input parameters are equally suited for reproducing the data targeted in this example. Only future DFTe studies that take into account additional data can reduce the space of possible functionals. Taking the cue from physics, we may hope that a universal functional will prevail and thereby provide deeper insights into the fundamental mechanisms and relations underlying ecological systems in general and microbial communities in particular.

Parameterisations for the competition between three grasses in salinity gradients

The slim characterisation of the experimental setting reported in Ref. 34 (see Supplementary Notes) contrasts with the number of parameters of the DFTe functional E[n,  μ](N) in Eq. (9), for which all components require input—except the environmental potential energies, which are constant in this uniform situation and therefore irrelevant. In order to proceed, we assume the following: (i) Coexistence of the three competing grasses in mixture suggests that three different resources are exclusively limiting each species; (ii) all species exhibit equal dispersal τ as well as interaction strength γ factored into ({gamma }_{s{s}^{{prime} }}=gamma ,{[{f}_{s}/{f}_{{s}^{{prime} }}-1]}_{+}) (mixture- and monoculture abundances are not proportional, implying some kind of salinity-dependent competition); (iii) asymmetric interactions, since amensalism and repulsion yield distributions inconsistent with field data, see Supplementary Notes and Supplementary Fig. 5; (iv) as suggested in Ref. 34, we fix the salinity-dependent fitness proxies fs as the fraction of above-ground biomass of s in mixture. This reflects increasing salt tolerance in the order Poa < Hord < Pucc. We then fit the nine parameters (τ, σ, νks, γ) of

$$E({{{{{{{bf{N}}}}}}}})=frac{tau }{2}mathop{sum }limits_{s=1}^{3}{N}_{s}^{2}+mathop{sum }limits_{k=1}^{3}{w}_{k}{left[mathop{sum }limits_{s=1}^{3}{nu }_{ks}{N}_{s}-{R}_{k}right]}^{2}+mathop{sum }limits_{{s,{s}^{{prime} }!=!1}atop {{s}^{{prime} }ne s}}^{S}{N}_{s},{gamma }_{s{s}^{{prime} }},{N}_{{s}^{{prime} }}^{2}$$

(29)

to the abundances for the mixture in uniform salinity (see Supplementary Figs. 5 and 6), such that the nonuniform version of Eq. (29) allows us to predict the density distributions in Fig. 4 implied by heterogeneous resource distributions (see Supplementary Notes).

Parameterisations for the dynamics of microbial predation

P. aurelia (P) feeds on Cerophyl (c) and serves as the single resource for the predator D. nasutum (D). From the general DFTe energy we thus select the two quadratic resource energies and a parasitic interaction with fit parameter γ, akin to an asymmetric repulsive contact interaction that favours D. For this spatially uniform microbial system in suspension, E[n] reduces to the function

$$E({N}_{{{{{{{{rm{P}}}}}}}}},, {N}_{{{{{{{{rm{D}}}}}}}}})equiv {{{{{{{mathcal{H}}}}}}}}({{{{{{{bf{N}}}}}}}})=frac{A}{{rho }_{c}^{2}}{left({nu }_{cP}frac{{N}_{{{{{{{{rm{P}}}}}}}}}}{A}-{rho }_{c}right)}^{2}+frac{{A}^{3}}{{N}_{{{{{{{{rm{P}}}}}}}}}^{2}}{left({nu }_{PD}frac{{N}_{{{{{{{{rm{D}}}}}}}}}}{A}-frac{{N}_{{{{{{{{rm{P}}}}}}}}}}{A}right)}^{2}+frac{gamma }{{A}^{2}},{N}_{{{{{{{{rm{D}}}}}}}}},{N}_{{{{{{{{rm{P}}}}}}}}}^{2}.$$

(30)

We fit its minimiser (hat{{{{{{{{bf{N}}}}}}}}}) (red cross in Fig. 5) to the average abundances (cyan cross in Fig. 5) for the last cycle of the most stable time series (Fig. 14c in ref. 36); see also Supplementary Notes, Supplementary Fig. 9, and Supplementary Table 3. These average abundances anchor our comparison between the experimental data and the DFTe trajectory ({{{{{{{mathcal{H}}}}}}}}(hat{{{{{{{{bf{N}}}}}}}}})+Delta E), with a suitably chosen ‘excitation’ energy ΔE. As expected, amensalistic interactions are not supported by the data and are therefore ruled out, see Supplementary Fig. 8 and Supplementary Fig. 10. By comparing, for example, the energies in Eqs. (29) and (30) for the grasses and the microbial predator–prey system, respectively, we see that DFTe is capable of determining what (very) different systems share—in this case the parasitic interaction, but not the dispersal pressure.

Parameterisations for the complex large-scale synthetic community

The community encompasses heterogeneous environments, competition over resources, all bipartite interactions of Supplementary Table 1, and predator–prey relations. From Eq. (9), we assemble the according DFTe energy functional

$$E[{{{{{{{bf{n}}}}}}}},, {{{{{{{boldsymbol{mu }}}}}}}}]({{{{{{{bf{N}}}}}}}})= {int}_{A}({{{{{{{rm{d}}}}}}}}{{{{{{{bf{r}}}}}}}})mathop{sum }limits_{s=1}^{S=7}left(frac{{tau }_{s}}{2}{n}_{s}^{2}+{V}_{s}^{{{{{{{{rm{env}}}}}}}}},{n}_{s}+mathop{sum}limits_{({alpha }_{s},{beta }_{{s}^{{prime} }})}mathop{sum }limits_{{s,{s}^{{prime} }!=!1}atop {{s}^{{prime} }ne s}}^{S=7}{n}_{s}^{{alpha }_{s}},{gamma }_{s{s}^{{prime} }}^{({alpha }_{s},{beta }_{{s}^{{prime} }})},{n}_{{s}^{{prime} }}^{{beta }_{{s}^{{prime} }}}right) +mathop{sum }limits_{s=1}^{S=7}{mu }_{s}left({N}_{s}-{int}_{A}({{{{{{{rm{d}}}}}}}}{{{{{{{bf{r}}}}}}}}),{n}_{s}right)+{int}_{A}({{{{{{{rm{d}}}}}}}}{{{{{{{bf{r}}}}}}}})mathop{sum }limits_{k=1}^{K=6} Bigg(frac{1}{{bar{rho }}_{k}^{2}}mathop{sum }limits_{s=1}^{S=7}eta left({nu }_{ks}right),exp left[sigma left(frac{{lambda }_{ks}}{{lambda }_{ls}}-1right)right]Bigg){left(mathop{sum }limits_{{s}^{{prime} }=1}^{S=7}{nu }_{k{s}^{{prime} }}{n}_{{s}^{{prime} }}-{rho }_{k}right)}^{2}.$$

(31)

The species differ in their dispersal strengths τs, habitat preferences ({V}_{s}^{{{{{{{{rm{env}}}}}}}}}), the types (({alpha }_{s},, {beta }_{{s}^{{prime} }})) of heterospecific interactions, modulated by interaction strengths ({gamma }_{s{s}^{{prime} }}^{({alpha }_{s},{beta }_{{s}^{{prime} }})}), as well as the types and amounts of required resources, see Supplementary Table 4. The synthetic environments and non-prey resource distributions are depicted in Supplementary Fig. 11. The density ns of each species may, independently from the other densities ({n}_{{s}^{{prime} }ne s}), refer to individuals per area, frequency, biomass density, fractional land cover, or any other expedient metric—units and absolute scales are absorbed in the parameters ({tau }_{s},{V}_{s}^{{{{{{{{rm{env}}}}}}}}}), and so forth. By deploying only contact-type interactions (see Supplementary Table 4), we implicitly state that members of any species are not directly influenced by conspecifics or heterospecifics beyond their local pixel of our coarse-grained area A. For example, if the Cat habitat area is ~50 km2, then A exceeds ~50,000 km2 (see Supplementary Notes). This large-scale system contrasts with the fruit flies experiment in Fig. 2, where the long-range repulsive interaction between individuals turns out to couple all individuals explicitly across the entire area. Note that contact-type interactions on large spatial scales do not imply that the system is weakly interacting: Both the synthetic food web here and the fruit flies experiment are strongly interacting since the interaction energies comprise a substantial part of the total energy for both systems. Using the so specified energy functional along with the density expression of Eq. (4), we simulate 33 × 33 = 1089 parcels in the focal area A = 1. We obtain the equilibrium density profiles from a conjugate gradient descent towards the global energy minimum of Eq. (31) in the up to seven-dimensional space of abundances N. In view of the stark disparity between species distributions (i) in isolation and (ii) under the influence of interactions, see Supplementary Fig. 14, we build intuition on the entire community by modelling subsystems with fewer species (Supplementary Figs. 12 and 13).

We illustrate the connections between DFTe inputs and outputs by explaining the small decrease of the Pig abundance upon Cat extermination (Fig. 6b): We observed that the Pig is the limiting resource for the Cat only in regions of very low Pig density (see Supplementary Fig. 13), such that changes in the Pig distribution are not primarily connected to the removal of the Cat. Second, the heavily predated Deer as well as the mutualistically connected Tree generally benefit from the absence of the Cat. As a result, the Grass and, consequently, the Snail come under pressure, which helps the Fungus, whose mutualistic connection to the Tree closes the positive feedback loop between Deer, Tree, and Fungus. The increased Fungus density then attracts the Pig, except in two small enclaves (indicated with arrows in Fig. 6b), where the processes just described are reversed, such that the Pig is mainly redistributed globally. Of course, this narrative conveys only the broad strokes of the quantitative simulation and plays out under the constraints imposed by environments and resources, but it conveys the quantitative knowledge about the community functioning obtained from the DFTe simulation.

Parameterisations for the twenty tree species in a tropical forest

Since we lack additional ecological information beyond densities and soil composition for constraining the full DFTe energy functional, we chose the same energy functional as in Eq. (31), though with (i) S = 20 species, which constitute more than 50% of the total basal area of the 328 censused species, (ii) all K = 11 measured resources, and (iii) the ansatz ({V}_{s}^{{{{{{{{rm{env}}}}}}}}}={epsilon }_{s}^{{{{{{{{rm{alt}}}}}}}}},{V}^{{{{{{{{rm{alt}}}}}}}}}+{epsilon }_{s}^{{{{{{{{rm{pH}}}}}}}}},{V}^{{{{{{{{rm{pH}}}}}}}}}). Accordingly, there are 17 DFTe fit parameters per species—the two parameters ({epsilon }_{s}^{{{{{{{{rm{alt}}}}}}}}}) and ({epsilon }_{s}^{{{{{{{{rm{pH}}}}}}}}}) that encode the response to altitude and pH-level, eleven resource requirements νks for k = 1, …, 11, dispersal pressure τs, and three fitness proxies ({f}_{s}^{({{{{{{{rm{a/c}}}}}}}})},, {f}_{s}^{({{{{{{{rm{r/m}}}}}}}})}), and ({f}_{s}^{({{{{{{{rm{asym}}}}}}}})}) that encode all the bipartite interactions of Supplementary Table 1 through the kernels ({gamma }_{s{s}^{{prime} }}^{{{{{{{{rm{(i)}}}}}}}}}={f}_{s}^{{{{{{{{rm{(i)}}}}}}}}}-{f}_{{s}^{{prime} }}^{{{{{{{{rm{(i)}}}}}}}}}) for ({s}^{{prime} }, > ,s). We also leave σ for the resource weights as a free parameter. All these 341 (281) DFTe parameters of the energy functional with (without) bipartite interactions are unknown and have to be extracted from fitting E to the reference densities nref. This presents a high-dimensional constrained problem of maximising the least-squares overlap ξ between the densities (tilde{{{{{{{{bf{n}}}}}}}}}left({tilde{{{{{{{{bf{n}}}}}}}}}}^{{}_{0}}right)) and nref, which we solve by using stochastic evolutionary algorithms that are efficient in escaping local optima, see Supplementary Notes.

Reporting summary

Further information on research design is available in the Nature Portfolio Reporting Summary linked to this article.


Source: Ecology - nature.com

Two wild carnivores selectively forage for prey but not amino acids

Development of an array of molecular tools for the identification of khapra beetle (Trogoderma granarium), a destructive beetle of stored food products