pde_opt.numerics.utils.testing

This module contains helper functions for testing the PDEs.

Functions

check_convergence(numeric, symbolic, ...)

Test convergence of a numeric equation against a symbolic equation.

l2_rel_err(numeric, symbolic)

L2 relative error between numeric and symbolic

plot_convergence(dx, err[, orders, anchor])

Log–log plot of error vs dx with dotted reference slopes.

pde_opt.numerics.utils.testing.l2_rel_err(numeric, symbolic)[source]

L2 relative error between numeric and symbolic

pde_opt.numerics.utils.testing.check_convergence(numeric: Type[BaseEquation], symbolic: Type[BaseSymbolicEquation], numeric_args, symbolic_args, Ns, L)[source]

Test convergence of a numeric equation against a symbolic equation.

Parameters:
  • numeric – Numeric equation class

  • symbolic – Symbolic equation class

  • numeric_args – Arguments for the numeric equation

  • symbolic_args – Arguments for the symbolic equation

  • Ns – List of grid sizes to test

  • L – Length of the domain

Returns:

List of grid sizes and errors

pde_opt.numerics.utils.testing.plot_convergence(dx, err, orders=(0.5, 1.0, 1.5, 2.0), anchor='min')[source]

Log–log plot of error vs dx with dotted reference slopes.

anchor: ‘min’ -> anchor reference lines at smallest dx point,

‘max’ -> anchor at largest dx point.