Skip to contents

The jump-growth equation

As was observed in (Datta, Delius, and Law 2010), the variability in prey size leads to a diffusion term in the PDE for the abundance density \(N(w,t)\). This term is neglected in mizer but will become important when matching mizer abundances to observed abundances, because it will account for fish that are larger than average. The PDE including the diffusion term is \[ \frac{\partial N}{\partial t} = \frac12 \frac{\partial^2}{\partial w^2}(d N) - \frac{\partial}{\partial w}(g N)-\mu N \tag{1}\] where \(g\) is the growth rate, \(\mu\) is the death rate and \(d\) is a new diffusion rate.

The diffusion rate has an expression that is similar to that of the growth rate. Recall that the growth rate is given by \[ \begin{split} g(w)=&(1-f(w))\,\gamma(w)\int N_c(w_p)\phi(w/w_p)\alpha\,(1-\psi(w)) w_p\,dw_p\\ &- K(w)(1-\psi(w)), \end{split} \tag{2}\] where \(N_c(w)\) is the abundance density of prey, \(\phi(w/w_p)\) is the predation kernel, \(\gamma(w)\) is the search volume, \(f(w)\) is the feeding level, \(K(w)\) is the metabolic respiration rate, \(\alpha\) is the conversion efficiency and \(\psi(w)\) is the proportion of available energy that is invested into reproduction. Because the metabolic respiration loss is subtracted from the available energy before that is split into growth and reproduction, only a proportion \(1-\psi\) of the metabolic rate is subtracted from the growth rate.

The factor \(\alpha (1- \psi(w))w_p\) in the integral in Eq. 2 is the increase in somatic weight of the predator resulting from the ingestion of the prey of weight \(w_p\). In the expression for the diffusion rate \(d(w)\) this factor is squared: \[ d(w) = (1-f(w))\,\gamma(w) \int N_c(w_p)\phi(w/w_p)(\alpha\,(1-\psi(w)) w_p)^2\,dw_p. \tag{3}\] The loss due to metabolic respiration affects the growth rate but not the diffusion rate. In the derivation of the PDE Eq. 1 in (Datta, Delius, and Law 2010) the metabolic respiration was not discussed but its contribution to only the first-order derivative term can be found in (Capitan and Delius 2010).

The increase \(\alpha (1- \psi(w))w_p\) in predator mass is typically only a small proportion of the predator mass because the preferred prey are typically much smaller than the predator and also \(\alpha\) and \(1-\psi(w)\) are both smaller than \(1\). Because this factor is squared in the expression for \(d(w)\) it might be expected that the term in the PDE involving \(d(w)\) can be safely neglected. However it is worth testing this intuition. We will do this now by first determining the diffusion rate in a model with allometric growth and death rates. We will then use that to determine its effect on the slope of the juvenile spectrum. Finally we will look at the numerical solution for the steady state.

Example calculation of diffusion rate

Let us assume that the prey abundance is given by a power law: \(N_c(w)=N_0w^{-\lambda}\) and that the predation kernel is \[ \phi(w/w_p) = \exp\left(-\frac{\log(w/w_p/\beta)^2}{2\sigma^2}\right). \tag{4}\]

For juveniles \(\psi(w)=0\) and hence the integral in the expression Eq. 2 for the growth rate becomes \[ \begin{split} I_g&:=\int N_c(w_p)\phi(w/w_p)\alpha\,(1-\psi(w)) w_p\,dw_p\\ &=\alpha\int w_p^{1-\lambda}\exp\left(-\frac{\log(w/w_p/\beta)^2}{2\sigma^2}\right)dw_p. \end{split} \tag{5}\] This integral can be evaluated most easily by changing integration variable to \(x=\log(w_p/w_0)\)for an arbitrary reference weight \(w_0\) and then recognising the resulting integral \[ I_g=\alpha\, w_0^{2-\lambda}\int e^{(2-\lambda)x}\exp\left(-\frac{(x-\log(w/w_0)+\log(\beta))^2}{2\sigma^2}\right)dx \tag{6}\] as a Gaussian integral. Using the general result that \[ \int e^{ax}\exp\left(-\frac{(x-\mu)^2}{2\sigma^2}\right)dx = \sqrt{\frac{2\pi}{\sigma^2}}\exp\left(a\mu+\frac{a^2\sigma^2}{2}\right) \tag{7}\] with \(a = 2-\lambda\) and \(\mu = \log(w/w_0)-\log(\beta)\) we find that \[ \begin{split} I_g&= \alpha\, w_0^{2-\lambda}\sqrt{\frac{2\pi}{\sigma^2}}\exp\left((2-\lambda)(\log(w/w_0)-\log(\beta))+\frac{(2-\lambda)^2\sigma^2}{2}\right)\\ &=\alpha w^{2-\lambda}\sqrt{\frac{2\pi}{\sigma^2}}\beta^{\lambda - 2}\exp\left(\frac{(2-\lambda)^2\sigma^2}{2}\right) \end{split} \tag{8}\]

Assuming further a constant feeding level \(f(w)=f\), an allometric metabolic loss rate \(K(w) = k_s w^n\) and an allometric search volume \(\gamma(w)=\gamma w^q\) with an exponent of \(q = n - 2 + \lambda\) we obtain \[ g(w) = \left((1-f)\gamma \alpha \sqrt{\frac{2\pi}{\sigma^2}}\beta^{\lambda - 2}\exp\left(\frac{(2-\lambda)^2\sigma^2}{2}\right)-k_s\right) w^n. \tag{9}\] If we assume further that the metabolic loss is a fraction \(f_c/f\) of the incoming energy (we refer to \(f_c\) as the critical feeding level) then this simplifies to \[ g(w) =\left( \left(1-\frac{f_c}{f}\right)(1-f)\gamma \alpha \sqrt{\frac{2\pi}{\sigma^2}}\beta^{\lambda - 2}\exp\left(\frac{(2-\lambda)^2\sigma^2}{2}\right)\right) w^n. \tag{10}\]

We can evaluate the diffusion rate \(d(w)\) in the same manner. The extra factor of \(w_p\) changes \(a\) from \(2-\lambda\) to \(3-\lambda\) and we obtain \[ d(w) = \left((1-f(w))\gamma \alpha^2 \sqrt{\frac{2\pi}{\sigma^2}}\beta^{\lambda - 3}\exp\left(\frac{(3-\lambda)^2\sigma^2}{2}\right)\right) w^{n+1}. \tag{11}\] Comparing this to the expression Eq. 10 for \(g(w)\) we find that \[ d(w) = g(w)w\frac{1}{1-f_c/f}\frac{\alpha}{\beta}\exp\left(\frac{(2\lambda - 3)\sigma^2}{2}\right). \tag{12}\]

To get a feel for the typical magnitude of the factor let’s consider concrete values \[ (1-f_c/f)=0.6, \qquad\alpha = 0.8, \qquad\beta = 100, \qquad\sigma = 2, \qquad\lambda = 2. \tag{13}\]

Then \[ d(w) \approx 0.15 g(w)w. \tag{14}\]

However we see that the value of \(d(w)\) is strongly influenced by the width of the feeding kernel. If we choose \(\sigma = 1\) then \(d(w)\approx 0.03 g(w)w\). This decrease in the diffusion rate with decreasing \(\sigma\) may explains the result from (Datta, Delius, Law, and Plank 2010) that the stability of the system decreases with decreasing \(\sigma\).

Effect on juvenile slope

In this section we will calculate the effect of the diffusion on the slope of the juvenile spectrum in the steady state. You can skip this section if you are not interested in the details of the calculation. The outcome is that the change in the juvenile slope is small. However, the change in the size spectrum of the adults is much larger, as we will see in Section 5.

Without diffusion we find the juvenile spectrum by solving the steady-state equation \[ \frac{\partial}{\partial w}(g(w) N(w)) =-\mu(w) N(w). \tag{15}\]

This has the solution \[ N(w) = \frac{g(w_0)}{g(w)}N(w_0)\exp\left(-\int_{w_0}^w\frac{\mu(w')}{g(w')}dw'\right). \tag{16}\]

With allometric growth and death rates \(g(w)=g_0w^n\) and \(\mu(w)=\mu_0w^{n-1}\) this gives \[ N(w)=\left(\frac{w}{w_0}\right)^{-n} N(w_0)\exp\left(-\frac{\mu_0}{g_0}\int_{w_0}^w\frac{1}{w'}dw'\right)=N(w_0)\left(\frac{w}{w_0}\right)^{-\mu_0/g_0-n}. \tag{17}\]

Thus the juvenile steady state abundance density is given by a power law with exponent \(-\mu_0/g_0-n\).

In the presence of diffusion the steady state equation becomes the second-order ODE \[ \frac12 \frac{\partial^2}{\partial w^2}(d N) - \frac{\partial}{\partial w}(g N)-\mu N=0. \tag{18}\]

We have seen in the previous section that with \(g(w)=g_0w^n\) the diffusion rate is also a power law with one extra factor of \(w\): \(d(w)=d_0w^{n+1}\). This makes the equation Eq. 18 scale invariant and hence we again expect the solution to be a power law, So we make the Ansatz \(N(w)=N(w_0)(w/w_0)^a\) with the exponent \(a\) to be determined. Substituting this Ansatz into Eq. 18 gives \[ \frac12 d_0N_0(n+1+a)(n+a)w^{n+a-1} -g_0N_0(n+a)w^{n+a-1}-\mu_0 N_0w^{n-1+a} = 0 \tag{19}\] which requires that \[ \frac12 d_0 (n+a)^2+\left(\frac12 d_0 -g_0\right)(n+a)-\mu_0=0. \tag{20}\] This is a quadratic equation for \(n+a\): \[ \frac12 d_0 (n+a)^2+\left(\frac12 d_0 -g_0\right)(n+a)-\mu_0=0. \tag{21}\] This has two solutions \[ (n+a_\pm) = \frac1{d_0}\left(g_0-d_0/2\pm\sqrt{(g_0-d_0/2)^2+2d_0\mu_0}\right) \tag{22}\] where \(a_+\) is the solution with the + sign and \(a_-\) is the solution with the - sign.

We are only interested in the solution that goes to \(a=-\mu_0/g_0-n\) when \(d_0\to 0\). This means we are interested in the solution with the - sign. To check that indeed the solution \(a_{-}\) satisfies \(\lim_{a_-\to 0}= -\mu_0/g_0-n\) it is helpful to expand the square root term around \(d_0=0\): \[ \sqrt{(g_0-d_0/2)^2+2d_0\mu_0}=g_0+\frac{-g_0+2\mu_0}{2g_0}d_0+\frac{g_0^2-(-g_0+2\mu_0)^2}{8g_0^3}d_0^2+\dots \tag{23}\] So we find \[ \begin{split} a &= -n+\frac1{d_0}\left(g_0-d_0/2-\sqrt{(g_0-d_0/2)^2+2d_0\mu_0}\right)\\ &\approx -n-\frac{\mu_0}{g_0} - \frac18\left(1-\left(-1+2\frac{\mu_0}{g_0}\right)^2\right) d_0+\dots\\ &=-n-\frac{\mu_0}{g_0} +\frac12\left(\frac{\mu_0}{g_0}\left(1-\frac{\mu_0}{g_0}\right)\right)\frac{d_0}{g_0}+\dots \end{split} \tag{24}\]

We see that when \(\mu_0=g_0\) then the first correction term to the juvenile slope vanishes. The largest increase in slope (i.e., the least negative slope) is achieved when \(\mu_0/g_0=1/2\). In that case the slope without diffusion is \(-1.25\) (assuming \(n=0.75\)). The correction term then is \(d_0/(8g_0)\). We had already seen in the previous section that \(d_0/g_0\) is typically very small, so the change in slope is also very small.

Using the example value of \(d_0/g_0\approx0.15\) and \(n=0.75\) we get a slope correction of approximately \(0.018\) from \(-1.25\) to \(-1.232\).

Using the value \(d_0/g_0\approx0.03\) we get a smaller slope correction of approximately \(0.004\) from \(-1.25\) to \(-1.246\).

When \(\mu_0/g_0>1\) then the diffusion correction is negative, i.e., the juvenile slope becomes more negative due to diffusion, meaning fewer large fish.

Transforming to logarithmic weight

Mizer works with logarithmically-spaced weight bins. That is good, but it makes it complicated to work out numerical schemes for solving the equations. It is much easier to work with equally-spaced bins. The obvious solution is to view the logarithm of the weight as the independent variable instead of the weight. So we will work with \[ x = \log(w/w_0) \tag{25}\] where \(w_0\) is an arbitrary reference weight. That transforms the logarithmically-spaced bins in \(w\) to equally-spaced bins in \(x\).

params <- celtic_params
w <- w(params)
x <- log(w / w[1])
h <- x[2] - x[1]

We should then also work with the abundance density as a function of \(x\). Let’s denote it by \(n(x)\). It is related to the abundance density \(N(w)\) by \[ n(x)dx = N(w)dw \tag{26}\] where \(dx = dw/w\) is the differential in \(x\). Because \(dx = dw / w\) this means \(N(w)=n(x)/w\).

By the chain rule we have \[ \frac{\partial}{\partial w} = \frac{\partial x}{\partial w}\frac{\partial}{\partial x} = \frac{1}{w}\frac{\partial}{\partial x} \tag{27}\]

We can now transform the PDE Eq. 1 for \(N(w,t)\) into a PDE for \(n(x,t)\): \[ \frac{\partial n}{\partial t} = \frac12 \frac{\partial}{\partial x}\left(\frac{1}{w}\frac{\partial}{\partial x}\frac{d n}{w}\right) - \frac{\partial}{\partial x}\left(\frac{g n}{w}\right)-\mu n-w e \tag{28}\] We rewrite this using that \[ \frac{1}{w}\frac{\partial}{\partial x}\frac{d n}{w} = \frac{\partial}{\partial x}\frac{d n}{w^2}+\frac{d n}{w^2} \tag{29}\] Introducing the rescaled growth and diffusion rates \[ \tilde{g} = \frac{g}{w}-\frac12\frac{d}{w^2},~~~~\tilde{d}=\frac{d}{w^2} \tag{30}\] simplifies the PDE Eq. 28 to \[ \frac{\partial n}{\partial t} = \frac12 \frac{\partial^2}{\partial x^2}(\tilde{d}n) - \frac{\partial}{\partial x}\left(\tilde{g}n\right)-\mu n-w e. \tag{31}\] Note that while the diffusion rate was just rescaled by the factor of \(1/w^2\) that should be expected from the transformation from \(d^2/dw^2\) to \(d^2/dx^2\), the growth rate also received an additional contribution from the diffusion.

To get to a more common form of the advection-reaction-diffusion equation we rewrite the diffusion term: \[ \frac12 \frac{\partial^2}{\partial x^2}(\tilde{d}n) = \frac12 \frac{\partial}{\partial x}\left(\tilde{d}\frac{\partial n}{\partial x}\right) + \frac12 \frac{\partial}{\partial x}\left(\left(\frac{\partial}{\partial x}\tilde{d}\right)n\right) \tag{32}\] The second term can be combined with the growth term if we introduce \[ \hat{g}=\tilde{g}-\frac12 \frac{\partial}{\partial x}\tilde{d}. \tag{33}\] This gives us the PDE \[ \frac{\partial n}{\partial t} = \frac12 \frac{\partial}{\partial x}\left(\tilde{d}\frac{\partial n}{\partial x}\right) - \frac{\partial}{\partial x}\left(\hat{g}n\right)-\mu n-w e. \tag{34}\] where \(\hat{g}\) is the rescaled growth rate that includes the effect of diffusion.

Numerical scheme for steady-state ODE

We need to solve the steady-state ODE \[ \frac12 \frac{\partial}{\partial x}\left(\tilde{d}\frac{\partial n}{\partial x}\right) - \frac{\partial}{\partial x}\left(\hat{g}n\right)-\mu n=w e. \tag{35}\] To achieve stability even where the diffusion is small compared to the advection, we should use an upwind difference scheme to solve the steady-state equation.

Upwind scheme

For the growth term we use an upwind difference scheme, with the direction of upwind depending on the sign of \(\hat{g}\):

  • If \(\hat{g}_i \geq 0\), we use \[ \left(\hat{g}n\right)'(x_i) \approx \frac{\hat{g}_{i}n_{i}-\hat{g}_{i-1}n_{i-1}}{h}. \tag{36}\]
  • If \(\hat{g}_i < 0\), we use \[ \left(\hat{g}n\right)'(x_i) \approx \frac{\hat{g}_{i+1}n_{i+1}-\hat{g}_{i}n_{i}}{h}. \tag{37}\]

A concise way to write this is \[ \left(\hat{g}n\right)'(x_i) \approx \frac{|\hat{g}_i|n_i- \hat{g}^+_{i-1}n_{i-1} -\hat{g}^-_{i+1}n_{i+1}}{h} \tag{38}\] where \[ \hat{g}^\pm = |\hat{g}|\pm \hat{g} \tag{39}\] are either positive or zero, depending on the sign of \(\hat{g}\).

The diffusion term in Eq. 35 can be treated with a second-order scheme. \[ \frac12 \frac{\partial}{\partial x}\left(\tilde{d}\frac{\partial n}{\partial x}\right) \approx \frac1{2h}\left(\tilde{d}_{i+1/2}\frac{n_{i+1}-n_i}{h}-\tilde{d}_{i-1/2}\frac{n_i-n_{i-1}}{h}\right), \tag{40}\] where \(\tilde{d}_{i+1/2}\) and \(\tilde{d}_{i-1/2}\) are approximating the values of the diffusion rate at the midpoints between the grid points. For simplicity we use \[ \tilde{d}_{i+1/2} = \frac{\tilde{d}_i + \tilde{d}_{i+1}}{2} \tag{41}\] but this can be replaced by a more sophisticated scheme if desired.

After multiplying by \(h^2\) this gives us the linear system \[ \begin{split} \frac{1}{2}&\left(\tilde{d}_{i+1/2}(n_{i+1}-n_i)-\tilde{d}_{i-1/2}(n_i-n_{i-1})\right)\\& - h\left(|\hat{g}_i|n_i-\hat{g}^+_{i-1}n_{i-1}-\hat{g}^-_{i+1}n_{i+1}\right) - h^2 \mu_i n_i = h^2 w_i e_i. \end{split} \tag{42}\] Collecting terms gives us \[ L_in_{i-1} +D_in_{i} + U_in_{i+1} = h^2 w_i e_i \tag{43}\] for \(i=1,\dots N\), with \[ \begin{split} D_i=&-\left(\frac{\tilde{d}_{i+1/2}+\tilde{d}_{i-1/2}}{2}+h|\hat{g}_i|+h^2\mu_i\right),\\ L_i&=\frac{\tilde{d}_{i-1/2}}{2}+h\hat{g}^+_{i-1},\\ U_i&=\frac{\tilde{d}_{i+1/2}}{2}+h\hat{g}^-_{i+1}. \end{split} \tag{44}\] The boundary conditions are that \(n_0 = n_0\) at the left boundary and \(n_{N+1} = 0\) at the right boundary. We can write the equations for the intermediate points in matrix form by brining the boundary terms to the right-hand side: \[ \begin{pmatrix} D_1 & U_1 & 0 & \cdots & 0\\ L_2 & D_2 & U_2 & \cdots & 0\\ \vdots & \ddots & \ddots & \ddots & \vdots\\ 0 & \cdots & L_{N-1} & D_{N-1} & U_{N-1}\\ 0 & \cdots & 0 & L_N & D_N \end{pmatrix} \begin{pmatrix} n_1\\ n_2\\ \vdots\\ n_{N-1}\\ n_N \end{pmatrix} = \begin{pmatrix} h^2w_1e_1-n_0 L_1\\ h^2w_2e_2\\ \vdots\\ h^2w_{N-1}e_{N-1}\\ h^2w_Ne_N \end{pmatrix} \tag{45}\]

This is implemented in the function steady_diffusion(). The linear system is solved using the double-sweep method implemented in solve_double_sweep(). The double-sweep method is a very efficient algorithm for solving tridiagonal linear systems like the one we have here. It is described in more detail in the next section.

Double-sweep method

Here we derive the double-sweep method (Thomas’ algorithm) for solving a tridiagonal linear system. The system is given by \[ A x = b \tag{46}\] where \(A\) is a tridiagonal matrix with lower diagonal \(L\), main diagonal \(D\), and upper diagonal \(U\), so in components the system takes the form \[ L_ix_{i-1} +D_ix_{i} + U_ix_{i+1} - b_i = 0 \tag{47}\] for \(i=1,\dots,N\) with the understanding that \(L_1 = U_N = 0\) so that only the interior points \(i=1,\dots,N\) are solved for. The boundary conditions should be encoded in the choice of \(b_1\) and \(b_N\).

The Thomas algorithm proceeds by making the Ansatz \[ x_{i-1}=\alpha_ix_i+\beta_i, \tag{48}\] where \(\alpha_i\) and \(\beta_i\) are to be determined. Substituting Eq. 48 this into Eq. 43 gives \[ U_ix_{i+1}+(\alpha_iL_i+D_i)x_i+\beta_iL_i - b_i = 0. \tag{49}\] Similarly using \(x_{i}=\alpha_{i+1}x_{i+1}+\beta_{i+1}\) in Eq. 49 gives \[ \left[U_i + (\alpha_iL_i+D_i)\alpha_{i+1}\right]x_{i+1}+\left[(\alpha_iL_i+D_i)\beta_{i+1}+\beta_iL_i-b_i\right]=0. \tag{50}\] We can satisfy this by making the expressions in the square brackets vanish, which gives us \[ \alpha_{i+1}=-\frac{U_i}{\alpha_iL_i+D_i},\qquad \beta_{i+1}=-\frac{\beta_iL_i-b_i}{\alpha_iL_i+D_i}. \tag{51}\] Looking at the case \(i=1\) where by definition we have \(L_1=0\), we see that \(\alpha_2=-U_1/D_1\) and \(\beta_2=b_1/D_1\). We can now use Eq. 51 to determine all the \(\alpha\)’s and \(\beta\)’s.

If we consider Eq. 49 for \(i=N\) and use \(U_N=0\), we find that \[ (\alpha_NL_N+D_N)x_N+\beta_NL_N - b_N = 0, \] from which we get \[ x_N = \frac{b_N - \beta_N L_N}{\alpha_N L_N + D_N}. \] We can now use the \(\alpha\)’s and \(\beta\)’s to calculate \(x_{N-1}\), \(x_{N-2}\), …, \(x_1\) in a back substitution step.

This is implemented in the function solve_double_sweep().

Stability

The double-sweep method is known to be stable if \(U_i,L_i>0\), \(D_i<0\) and \(U_i+L_i\leq -D_i\). Now we automatically have \(L_i>0, U_i>0\) and \(D_i<0\). The condition \(U_i+L_i\leq -D_i\) is satisfied if \[ \frac{\tilde{d}_{i+1/2}+\tilde{d}_{i-1/2}}{2}+h\left(\hat{g}^+_{i+1}+\hat{g}^-_{i-1}\right)\leq \frac{\tilde{d}_{i+1/2}+\tilde{d}_{i-1/2}}{2}+h|\hat{g}_i|+h^2\mu_i, \] which simplifies to \(0\leq \mu_i\), which is always satisfied.

Without diffusion

When the diffusion rate is zero, then \(\hat{g}=\tilde{g}\) and the double-sweep method reduces to the method we are currently using. In that case, using that then \(\tilde{g}_i >0\), we have \[ U_i=0,\qquad L_i=h\tilde{g}_{i-1}, \qquad D_i=-h\,\tilde{g}_i-h^2\mu_i \] and thus \[ \alpha_{i+1} = -\frac{U_i}{D_i} = 0, \qquad \beta_{i+1} = -\frac{\beta_i L_i}{D_i} = \beta_i\frac{\tilde{g}_{i-1}}{\tilde{g}_i+h\mu_i}. \] This gives \[ n_i=\beta_{i+1}=\beta_i\frac{\tilde{g}_{i-1}}{\tilde{g}_i+h\mu_i} =n_{i-1}\frac{\tilde{g}_{i-1}}{\tilde{g}_i+h\mu_i}. \] For the number density as a function of \(w\) this gives \[ \begin{split} N_i=\frac{n_i}{w_i} &= \frac{n_{i-1}}{w_{i}}\frac{\tilde{g}_{i-1}}{\tilde{g}_i+h\mu_i} =\frac{n_{i-1}}{w_{i}}\frac{g_{i-1}/w_{i-1}}{g_i/w_i+h\mu_i} =\frac{n_{i-1}}{w_{i-1}}\frac{g_{i-1}}{g_i+hw_i\mu_i }\\ &=N_{i-1}\frac{g_{i-1}}{g_i+\Delta w_i\mu_i}+O(h^2) \end{split} \] where we used that \[ \Delta w_i=w_{i+1}-w_i = w_i\left(\exp(h)-1\right)= hw_i+O(h^2). \]

This is the same as the scheme we are currently using for calculating the steady state.

Example of steady state solution

We now demonstrate the use of the upwind finite-difference scheme by calculating and plotting a steady state solution for a realistic species (Herring) from the North Sea model.

params <- validParams(celtic_params)
species <- "Herring"
w <- params@w

# Without diffusion
params_no_diffusion <- params
ps_no_diffusion <- mizer::steadySingleSpecies(params_no_diffusion, species)
n_steady_no_diffusion <- ps_no_diffusion@initial_n[species, ]

# Set nonzero diffusion rate
species_params(params)$d_over_g <- 0.15

# Set diffusion from d_over_g
# d(w) = d_over_g * g(w) * w
for (s in species_params(params)$species) {
    d_over_g <- species_params(params)[s, "d_over_g"]
    w <- params@w
    growth <- getEGrowth(params)[s, ]
    n <- params@species_params[s, "n"]
    g_0 <- growth[1] / w[1]^n
    d_0 <- d_over_g * g_0
    ext_diffusion(params)[s, ] <- d_0 * w^(n + 1)
}

# Solve for steady state using the upwind scheme
ps <- mizer::steadySingleSpecies(params, species)
n_steady <- ps@initial_n[species, ]

# Plot the resulting abundance density versus size
plot(w, n_steady, log = "xy", type = "l", lwd = 2,
     xlab = "Weight (g)", ylab = "Abundance density",
     main = paste("Steady state solution for", species))
#> Warning in xy.coords(x, y, xlabel, ylabel, log): 51 y values <= 0 omitted from
#> logarithmic plot
lines(w, n_steady_no_diffusion, col = "red", lwd = 2, lty = 2)

p0 <- params
p0@initial_n[species, ] <- n_steady_no_diffusion
y0 <- plotYieldVsSize(p0, species = species, x_var = "Length",
                      return_data = TRUE)[[1]] |>
    dplyr::filter(Type == "Model catch")
y0$Type <- "No diffusion"

p <- params
p@initial_n[species, ] <- n_steady
y <- plotYieldVsSize(p, species = species, x_var = "Length",
                     return_data = TRUE)[[1]] |>
    dplyr::filter(Type == "Model catch")
y$Type <- "With diffusion"
y <- rbind(y0, y)

ggplot(y, aes(x = l, y = `Catch density`, colour = Type)) +
    geom_line()

Time-dependent PDE solution with upwind finite-difference method

We now solve the time-dependent PDE \[ \frac{\partial n}{\partial t} = \frac12 \frac{\partial^2}{\partial x^2}(\tilde{d}n) - \frac{\partial}{\partial x}(\hat{g}n)-\mu n \] using the same upwind finite-difference method as for the steady-state ODE, but now with time-stepping. We use an implicit Euler method for time integration, which is unconditionally stable for this kind of equation. At each time step, we solve a tridiagonal linear system using the double-sweep (Thomas) algorithm.

Capitan, Jose A, and Gustav W. Delius. 2010. ‘Scale-Invariant Model of Marine Population Dynamics’. Physical Review E 81 (6): 061901. https://doi.org/10.1103/PhysRevE.81.061901.
Datta, Samik, Gustav W. Delius, and Richard Law. 2010. ‘A Jump-Growth Model for Predator-Prey Dynamics: Derivation and Application to Marine Ecosystems’. Bulletin of Mathematical Biology 72 (6): 1361–82. https://doi.org/10.1007/s11538-009-9496-5.
Datta, Samik, Gustav W. Delius, Richard Law, and Michael J. Plank. 2010. ‘A Stability Analysis of the Power-Law Steady State of Marine Size Spectra’. Journal of Mathematical Biology 63 (December): 779–99. https://doi.org/10.1007/s00285-010-0387-z.