stochrare.fokkerplanck¶
Numerical solvers for the Fokker-Planck equations¶
This module contains numerical solvers for the Fokker-Planck equations associated to diffusion processes.
For now, it only contains a basic finite difference solver for the 1D case.
-
class
stochrare.fokkerplanck.
FokkerPlanck1D
(drift, diffusion)¶ Bases:
object
Solver for the 1D Fokker-Planck equation.
\(\partial_t P(x,t) = - \partial_x a(x,t)P(x,t) + D \partial^2_{xx} P(x,t)\)
Parameters: - drift (function with two variables) – The drift coefficient \(a(x, t)\).
- diffusion (float) – The constant diffusion coefficient \(D\).
Notes
This is just the legacy code which was migrated from the
stochrare.dynamics.DiffusionProcess1D
class. It should be rewritten with a better structure. In particular, it only works with a constant diffusion for now.-
classmethod
gaussian1d
(mean, std, X)¶ Return a 1D Gaussian pdf.
Parameters: - mean (float) –
- std (float) –
- X (ndarray) – The sample points.
Returns: pdf – The Gaussian pdf at the sample points.
Return type: ndarray
-
fpintegrate
(t0, T, **kwargs)¶ Numerical integration of the associated Fokker-Planck equation, or its adjoint.
Parameters: - t0 (float) – Initial time.
- T (float) – Integration time.
Keyword Arguments: - bounds (float 2-tuple) – Domain where we should solve the equation (default (-10.0,10.0))
- npts (ints) – Number of discretization points in the domain (i.e. spatial resolution). Default: 100.
- dt (float) – Timestep (default choice suitable for the heat equation with forward scheme)
- bc (stochrare.edpy.BoundaryCondition object or tuple) – Boundary conditions (either a BoundaryCondition object or a tuple sent to _fpbc)
- method (str) – Numerical scheme: explicit (‘euler’, default), implicit, or crank-nicolson
- adjoint (bool) – Integrate the adjoint FP rather than the forward FP (default False).
- P0 (str) – Initial condition: ‘gauss’ (default), ‘dirac’ or ‘uniform’.
Returns: t, X, P – Final time, sample points and solution of the Fokker-Planck equation at the sample points.
Return type: float, ndarray, ndarray
-
fpintegrate_generator
(*args, **kwargs)¶ Numerical integration of the associated Fokker-Planck equation, generator version.
Parameters: *args (variable length argument list) – Times at which to yield the pdf. Yields: t, X, P (float, ndarray, ndarray) – Time, sample points and solution of the Fokker-Planck equation at the sample points.
Classes
FokkerPlanck1D (drift, diffusion) |
Solver for the 1D Fokker-Planck equation. |