This is a small library for solving the poisson equation ∇^2 φ = -f on unit unbounded and periodic domains.
To install prerequisites for running the script, do
pip install -r requirements.txt
This installs the numpy,scipy
and matplotlib
scientific stack on your
system.
To make the poisson solver, use
from poisson_solver import make_poisson_solver, PoissonOrder
solver = make_poisson_solver(
grid_size, # number of points preferably 2**n
dx, # grid spacing
x_boundary_condition="unbounded", # x direction boundary condition
y_boundary_condition="periodic", # y direction boundary condition
order_of_accuracy=PoissonOrder(4) # order of accuracy needed
)
where
x_boundary_condition
is one ofunbounded
orperiodic
y_boundary_condition
is one ofunbounded
orperiodic
order_of_accuracy
is one of0, 2, 4, 6, 8, 10
.0
does not mean zero-order accuracy, but represents the unregularized version and is always second order accurate.
order_of_accuracy
does not matter for purely periodic domains : the solver is
spectrally accurate in this case (accuracy till machine precision if function
can be properly resolved)
- For unbounded simulations :
- For mixed unbounded-periodic simulations:
- For pure periodic simulations: