pencil.math.poisson_solver
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
|
poisson_vector_cartesian(bx, by, bz, x, y, z, hx, hy, hz, niter=1000) |
|
poisson_scalar_cylindrical(bc, r, theta, z, h, niter=200) |
|
poisson_vector_cylindrical(br, btheta, bz, r, theta, z, hr, htheta, hz, niter=1000) |
|
poisson_vector_spherical(br, btheta, bphi, r, theta, phi, hr, htheta, hphi, niter=200) |
Module Contents
- pencil.math.poisson_solver.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.
- bx, by, bzndarray of shape [nz, ny, nx]
Boundary conditions on exterior points for each component. Keep the inner points 0.
- x, y, zndarrays of shape [nx], [ny] and [nz]
Coordinate arrays to calculate grid spacing.
- hx, hy, hzndarray of shape [nz, ny, nx]
Representing the components of the known function h.
- niterint
Number of iterations.
ndarray with the shape [3, nz, ny, nx], representing solution to the Poisson equation.
- pencil.math.poisson_solver.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.
- Parameters:
bc (ndarray of shape [nz, ny, nx]) – Boundary conditions on exterior points. Keep the inner points 0.
r (ndarrays of shape [nx], [ny] and [nz]) – Coordinate arrays to calculate grid spacing.
theta (ndarrays of shape [nx], [ny] and [nz]) – Coordinate arrays to calculate grid spacing.
z (ndarrays of shape [nx], [ny] and [nz]) – Coordinate arrays to calculate grid spacing.
h (ndarray of shape [nz, ny, nx]) – Representing the known function h.
niter (int) – Number of iterations.
- Return type:
ndarray with the shape [nz, ny, nx], representing solution to the Poisson equation.
- pencil.math.poisson_solver.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.
- br, btheta, bzndarray of shape [nz, ny, nx]
Boundary conditions on exterior points for each component. Keep the inner points 0.
- r, theta, zndarrays of shape [nx], [ny] and [nz]
Coordinate arrays to calculate grid spacing.
- hr, htheta, hzndarray of shape [nz, ny, nx]
Representing the components of the known function h.
- niterint
Number of iterations.
ndarray with the shape [3, nz, ny, nx], representing solution to the Poisson equation.
- pencil.math.poisson_solver.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.
- br, btheta, bphindarray of shape [nz, ny, nx]
Boundary conditions on exterior points for each component. Keep the inner points 0.
- r, theta, phindarrays 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, hphindarray of shape [nz, ny, nx]
Representing the components of the known function h.
- niterint
Number of iterations.
ndarray with the shape [3, nz, ny, nx], representing solution to the Poisson equation.