This is a toolbox to apply the adaptive finite volume method solving Fokker-Planck equations in economic applications

$\frac{dg}{dt} = -\sum_{i=1}^d \frac{d}{dx_i}(s_i(x)\cdot g(x)) + \sum_{i=1}^d \nu_i \frac{d^2g(x)}{dx_i^2}$

For an introduction to the finite-volume method, one can read any reference, but one can read [Ahn, 2019] written with the computation of the distribution for the heterogeneous agent models in mind. However, working through the Tutorials should be sufficient for most applications.

• Conservation of mass (of discretized equations)

• Positivity of the distribution function

• Local interaction of parameters (compared to global approximations such as Chebyshev polynomials)

• More interpretable results from geometric nature of parameters
• Adjusting approximation domain in a natural manner
• Since parameters are local/interpretable in nature, a natural candidate for the function approximation under perturbation methods.

• Grid points increase exponentially

• Keeping the structure of completely unstructured grid is costly.

Ultimately, the result of the cost-benefit analysis for a particular problem is hard to estimate without testing. The codes/toolbox should shorten the testing time for the finite-volume method for Fokker-Planck equations.

## General Workflow¶

• Initialize Grid

grid = afv_grid(n_dim);

• Split the grid for the first time:

grid.split_init(1, x_cuts);

• Collect Edges:

grid.extract_edges();

• Set drifts and variances:

grid.drift = stuff;
grid.diffusion = stuff;

• Compute the Transition Matrix:

A_FP = grid.compute_transition_matrix_modified();
A_FP_boundary = grid.compute_transition_matrix_boundary(ind, dir, flow,  is_left_edge);
A_FP = A_FP + A_FP_boundary;

• Further refine grids:

grid.split(indices);