pde_rk package

Module contents

pde_rk.pde_rk(dxdt: callable, X0: list, Tmax: float, deltat: float, t_eval: ndarray, killfunc: Optional[callable] = None, stabilitycheck: bool = False, maxstep: Optional[float] = None, rk: bool = True) Tuple[list, float, list, ndarray]

Function for solving system of PDEs using adaptive Runge-Kutta method Adapted from Hubatsch et al., 2019 (see https://github.com/lhcgeneva/PARmodelling)

Parameters
  • dxdt – a function that takes list of 1D arrays (one for each species) corresponding to concentrations over space, and returns a list of gradient arrays

  • X0 – a list specifying the initial state of the system. Will be used as the input to dxdt on the first time step

  • Tmax – timepoint at which to terminate simulation

  • deltat – initial timestep (this will be adapted throughout the simulation)

  • t_eval – a list of timepoints for which to save the state of the system

  • killfunc – an optional kill function that takes the same input as dxdt. Integration will terminate when this function returns True

  • stabilitycheck – if True, integration will terminate when the system stabilises (changes by less that 1% per 60 time units). Default is False

  • maxstep – maximum time step to tolerate

  • rk – if True, the function will use an adaptive Runge-Kutta method. If False, the function will use a basic Euler method with a constant time step

Returns
  • soln – final solution

  • time – final time. Will be close to Tmax but not exact due to finite and adaptable time step

  • solns – solutions at times specified by t_eval

  • times – times corresponding to saved states in solns. Will be close to times specified in t_eval but not exact due to finite and adaptable time step