/py_poisson_solver

Solve Poisson's equation in unbounded and periodic domains

Primary LanguageGnuplot

pyPoissonSolver

https://travis-ci.com/tp5uiuc/py_poisson_solver.svg?token=ZZkcxuTHm9peGgncAAKa&branch=master https://codecov.io/gh/tp5uiuc/py_poisson_solver/branch/master/graph/badge.svg?token=82EEIXLOQC https://coveralls.io/repos/github/tp5uiuc/py_poisson_solver/badge.svg?t=h3yU6Y https://img.shields.io/badge/license-Unlicense-blue.svg

This is a small library for solving the poisson equation ∇^2 φ = -f on unit unbounded and periodic domains.

Installing prerequisites

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.

Usage

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 of unbounded or periodic
  • y_boundary_condition is one of unbounded or periodic
  • order_of_accuracy is one of 0, 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)

Convergence plots

  • For unbounded simulations :

docs/convergence_unbounded.jpg

  • For mixed unbounded-periodic simulations:

docs/convergence_mixed.jpg

  • For pure periodic simulations:

docs/convergence_periodic.jpg