pencil.math.poisson_solver ========================== .. py:module:: pencil.math.poisson_solver .. autoapi-nested-parse:: This code contains various functions to solve the vector form of the Poisson equation in various coordinate systems (Cartesian, cylindrical and spherical) using finite differences. Functions --------- .. autoapisummary:: pencil.math.poisson_solver.poisson_vector_cartesian pencil.math.poisson_solver.poisson_scalar_cylindrical pencil.math.poisson_solver.poisson_vector_cylindrical pencil.math.poisson_solver.poisson_vector_spherical Module Contents --------------- .. py:function:: poisson_vector_cartesian(bx, by, bz, x, y, z, hx, hy, hz, niter=1000) poisson_vector_cartesian(bx, by, bz, x, y, z, hx, hy, hz, niter=1000) Solve the vector form of the Poisson equation in 3D Cartesian coordinates, $ abla^2 u = h$, using finite differences. Parameters ---------- bx, by, bz : ndarray of shape [nz, ny, nx] Boundary conditions on exterior points for each component. Keep the inner points 0. x, y, z : ndarrays of shape [nx], [ny] and [nz] Coordinate arrays to calculate grid spacing. hx, hy, hz : ndarray of shape [nz, ny, nx] Representing the components of the known function h. niter : int Number of iterations. Returns ---------- ndarray with the shape [3, nz, ny, nx], representing solution to the Poisson equation. .. py:function:: poisson_scalar_cylindrical(bc, r, theta, z, h, niter=200) poisson_scalar_cylindrical(bc, r, theta, z, h, niter=200) Solve the scalar form of the Poisson equation in cylindical coordinates using finite differences. :param bc: Boundary conditions on exterior points. Keep the inner points 0. :type bc: ndarray of shape [nz, ny, nx] :param r: Coordinate arrays to calculate grid spacing. :type r: ndarrays of shape [nx], [ny] and [nz] :param theta: Coordinate arrays to calculate grid spacing. :type theta: ndarrays of shape [nx], [ny] and [nz] :param z: Coordinate arrays to calculate grid spacing. :type z: ndarrays of shape [nx], [ny] and [nz] :param h: Representing the known function h. :type h: ndarray of shape [nz, ny, nx] :param niter: Number of iterations. :type niter: int :rtype: ndarray with the shape [nz, ny, nx], representing solution to the Poisson equation. .. py:function:: poisson_vector_cylindrical(br, btheta, bz, r, theta, z, hr, htheta, hz, niter=1000) poisson_vector_cylindrical(br, btheta, bz, r, theta, z, hr, htheta, hz, niter=1000) Solve the vector form of the Poisson equation, $ abla^2 u = h$, in cylindrical coordinates using finite diffferences. Parameters: ---------- br, btheta, bz : ndarray of shape [nz, ny, nx] Boundary conditions on exterior points for each component. Keep the inner points 0. r, theta, z : ndarrays of shape [nx], [ny] and [nz] Coordinate arrays to calculate grid spacing. hr, htheta, hz : ndarray of shape [nz, ny, nx] Representing the components of the known function h. niter : int Number of iterations. Returns ---------- ndarray with the shape [3, nz, ny, nx], representing solution to the Poisson equation. .. py:function:: poisson_vector_spherical(br, btheta, bphi, r, theta, phi, hr, htheta, hphi, niter=200) poisson_vector_spherical(br, btheta, bphi, r, theta, phi, hr, htheta, hphi, niter=200) Solve the vector form of the Poisson equation, $ abla^2 u = h$, in spherical coordinates using finite differences. Parameters: ---------- br, btheta, bphi : ndarray of shape [nz, ny, nx] Boundary conditions on exterior points for each component. Keep the inner points 0. r, theta, phi : ndarrays of shape [nx], [ny] and [nz] Coordinate arrays, where the convention is taken that theta ranges from 0 to pi, phi ranges from 0 to 2pi. Note that singularities arise in the equation when theta = 0. This may produce unintended results. hr, htheta, hphi : ndarray of shape [nz, ny, nx] Representing the components of the known function h. niter : int Number of iterations. Returns ---------- ndarray with the shape [3, nz, ny, nx], representing solution to the Poisson equation.