Skip to contents

This function uses the implicit Euler method to solve a PDE of the form: $$\dot{n}(x,t) = (d(x) n'(x,t))'-(g(x)n(x,t))'-\mu(x)n(x,t)$$

Usage

solve_diffusion_pde(d, g, mu, n_init, h, dt, nsteps)

Arguments

d

A vector of diffusion rates.

g

A vector of advection rates.

mu

A vector of reaction rates.

n_init

Initial condition for the solution.

h

Spatial step size.

dt

Time step size.

nsteps

Number of time steps to compute.

Value

A matrix (time x size) with the solution of the PDE.