pencil.math.laplace_solver
This code contains various functions to solve the vector form of the Laplace equation in various coordinate systems (Cartesian, cylindrical and spherical) using finite differences. Additionally, one can find functions to solve the scalar Laplace equation in Cartesian, cylidrindical and spherical coordinate systems, since these are used (at least in the case of Cartesian and cylindrical) in the vector solvers.
Functions
|
laplace_scalar_cartesian(bc, dx, dy, dz, niter=100) |
|
laplace_vector_cartesian(bx, by, bz, dx, dy, dz, niter=1000) |
|
laplace_scalar_cylindrical(bc, r, theta, z, niter=1000) |
|
laplace_vector_cylindrical(br, btheta, bz, r, theta, z, niter=200) |
|
laplace_scalar_spherical(bc, r, theta, phi, niter=200) |
|
laplace_vector_spherical(br, btheta, bphi, r, theta, phi, niter=200) |
Module Contents
- pencil.math.laplace_solver.laplace_scalar_cartesian(bc, dx, dy, dz, niter=200)
laplace_scalar_cartesian(bc, dx, dy, dz, niter=100)
Solve the scalar Laplace equation in Cartesian coordinates in 3 dimensions using finite differences.
- Parameters:
bc (ndarray of shape [nz, ny, nx]) – Boundary conditions on exterior points. Keep the inner points 0.
- dx, dy, dzfloats
Grid spacing in eaach direction.
- niterint
Number of iterations.
- Return type:
ndarray with the same shape as bc, representing solution to the Laplace equation.
- pencil.math.laplace_solver.laplace_vector_cartesian(bx, by, bz, dx, dy, dz, niter=200)
laplace_vector_cartesian(bx, by, bz, dx, dy, dz, niter=1000)
Solve the vector Laplace equation in Cartesian coordinates in 3 dimensions using finite differences. This function simply applies the scalar function to the three components.
- Parameters:
bx (ndarrays of shape [nz, ny, nx]) – Boundary conditions on exterior points. Keep the inner points 0.
by (ndarrays of shape [nz, ny, nx]) – Boundary conditions on exterior points. Keep the inner points 0.
bz (ndarrays of shape [nz, ny, nx]) – Boundary conditions on exterior points. Keep the inner points 0.
- dx, dy, dzfloat
Grid spacing in eaach direction.
- niterint
Number of iterations.
- Return type:
ndarray with the shape [3, nz, ny, nx], representing solution to the Laplace equation.
- pencil.math.laplace_solver.laplace_scalar_cylindrical(bc, r, theta, z, niter=200)
laplace_scalar_cylindrical(bc, r, theta, z, niter=1000)
Solve the scalar Laplace equation in cylindical coordinates in 3 dimensions using finite differences.
- Parameters:
bc (ndarray of shape [nz, ny, nx]) – Boundary conditions on exterior points. Keep the inner points 0.
- r, theta, zndarrays of shape [nx], [ny] and [nz]
1D coordinate arrays of r, theta and z.
- niterint
Number of iterations.
- Return type:
ndarray with the same shape as bc, representing solution to the Laplace equation.
- pencil.math.laplace_solver.laplace_vector_cylindrical(br, btheta, bz, r, theta, z, niter=200)
laplace_vector_cylindrical(br, btheta, bz, r, theta, z, niter=200)
Solve the vector Laplace equation in cylindrical coordinates in 3 dimensions using finite differences.
- Parameters:
br (ndarrays of shape [nz, ny, nx]) – Boundary conditions on exterior points. Keep the inner points 0.
btheta (ndarrays of shape [nz, ny, nx]) – Boundary conditions on exterior points. Keep the inner points 0.
bz (ndarrays of shape [nz, ny, nx]) – Boundary conditions on exterior points. Keep the inner points 0.
- r, theta, zndarrays of shape [nx], [ny] and [nz]
1D coordinate arrays of r, theta and z.
- niterint
Number of iterations.
- Return type:
ndarray with the shape [3, nz, ny, nx], representing solution to the Laplace equation.
- pencil.math.laplace_solver.laplace_scalar_spherical(bc, r, theta, phi, niter=200)
laplace_scalar_spherical(bc, r, theta, phi, niter=200)
Solve the scalar Laplace equation in spherical coordinates in 3 dimensions using finite differences.
- Parameters:
bc (ndarray of shape [nz, ny, nx]) – Boundary conditions on exterior points. Keep the inner points 0.
- r, theta, phindarrays of shape [nx], [ny] and [nz]
1D coordinate arrays of r, theta and phi. The convention is taken that theta ranges from 0 to pi and phi ranges from 0 to 2pi. Note that singularities arise in the equation when theta = 0 and r = 0. This may produce unintended results.
- niterint
Number of iterations.
- Return type:
ndarray with the same shape as bc, representing solution to the Laplace equation.
- pencil.math.laplace_solver.laplace_vector_spherical(br, btheta, bphi, r, theta, phi, niter=200)
laplace_vector_spherical(br, btheta, bphi, r, theta, phi, niter=200)
Solve the scalar Laplace equation in spherical coordinates in 3 dimensions using finite differences.
- Parameters:
bc (ndarray of shape [nz, ny, nx]) – Boundary conditions on exterior points. Keep the inner points 0.
btheta (ndarray of shape [nz, ny, nx]) – Boundary conditions on exterior points. Keep the inner points 0.
bphi (ndarray of shape [nz, ny, nx]) – Boundary conditions on exterior points. Keep the inner points 0.
- r, theta, phindarrays of shape [nx], [ny] and [nz]
1D coordinate arrays of r, theta and phi. The convention is taken that theta ranges from 0 to pi and phi ranges from 0 to 2pi. Note that singularities arise in the equation when theta = 0 and r = 0. This may produce unintended results.
- niterint
Number of iterations.
- Return type:
ndarray with the shape [3, nz, ny, nx], representing solution to the Laplace equation.