Working with Values of PotentialsΒΆ

Visualization of PotentialsΒΆ

sumpy.visualization.make_field_plotter_from_bbox(bbox: tuple[onp.Array1D[floating[Any]], onp.Array1D[floating[Any]]], h: float | Sequence[float], extend_factor: float = 0) FieldPlotter[source]ΒΆ
Parameters:
  • bbox – a tuple (low, high) of points represented as 1D numpy arrays indicating the low and high ends of the extent of a bounding box.

  • h – Either a number or a sequence of numbers indicating the desired (approximate) grid spacing in all or each of the dimensions. If a sequence, the length must match the number of dimensions.

  • extend_factor – A floating point number indicating by what percentage the plot area should be grown compared to bbox.

class sumpy.visualization.FieldPlotter(center: onp.ToArray1D[floating[Any]], extent: float | onp.Array1D[floating[Any]] = 1, npoints: int | tuple[int, ...] = 1000, points: onp.ArrayND[floating[Any]] | None = None)[source]ΒΆ
dimensions: intΒΆ
npoints: intΒΆ
points: onp.Array2D[floating[Any]]ΒΆ
set_matplotlib_limits() None[source]ΒΆ
show_scalar_in_matplotlib(fld: onp.ArrayND[Any], max_val: float | None = None, func_name: str = 'imshow', **kwargs: Any) Any[source]ΒΆ
show_scalar_in_mayavi(fld: onp.ArrayND[Any], max_val: float | None = None, **kwargs: Any) None[source]ΒΆ
write_vtk_file(file_name: str | pathlib.Path, data: Iterable[tuple[str, onp.ArrayND[Any]]], *, real_only: bool = False, overwrite: bool = False) None[source]ΒΆ

Differentiation of PotentialsΒΆ

sumpy.point_calculus.NodesKind

alias of Literal[β€˜chebyshev’, β€˜equispaced’, β€˜legendre’]

class sumpy.point_calculus.InexactTΒΆ

alias of TypeVar(β€˜InexactT’, bound=inexact[Any])

class sumpy.point_calculus.NodesKindΒΆ
class sumpy.point_calculus.CalculusPatch(center: ndarray[floating[Any]], h: float = 0.1, order: int = 4, nodes: NodesKind = 'chebyshev')[source]ΒΆ

Sets up a grid of points on which derivatives can be calculated. Useful to verify that an evaluated potential actually solves a PDE.

dim: intΒΆ
npoints: intΒΆ
points: ndarray[floating[Any]]ΒΆ

Shape: (dim, npoints).

center: ndarray[floating[Any]]ΒΆ
weights() ndarray[floating[Any]][source]ΒΆ
Returns:

a vector of high-order quadrature weights on the points

basis() Sequence[Callable[[ndarray[floating[Any]]], ndarray[floating[Any]]]][source]ΒΆ
Returns:

a list containing functions that realize a high-order interpolation basis on the points.

diff(axis: int, f_values: number[Any] | complex, nderivs: int = 1) Literal[0][source]ΒΆ
diff(axis: int, f_values: ndarray[InexactT], nderivs: int = 1) ndarray[InexactT]

Return the derivative along axis of f_values.

Parameters:

f_values – an array of shape (npoints,)

Returns:

an array of shape (npoints,)

dx(f_values: ndarray[InexactT]) ndarray[InexactT][source]ΒΆ
dy(f_values: ndarray[InexactT]) ndarray[InexactT][source]ΒΆ
dz(f_values: ndarray[InexactT]) ndarray[InexactT][source]ΒΆ
laplace(f_values: ndarray[InexactT]) ndarray[InexactT][source]ΒΆ

Return the Laplacian of f_values.

Parameters:

f_values – an array of shape (npoints,)

Returns:

an array of shape (npoints,) representing the application of the Laplacian to f_values.

div(arg: ObjectArray1D[ndarray[InexactT]]) ndarray[InexactT][source]ΒΆ
Parameters:

arg – an object array containing numpy.ndarrays with shape (npoints,).

curl(arg: ObjectArray1D[ndarray[InexactT]]) ObjectArray1D[ndarray[InexactT]][source]ΒΆ

Take the curl of the vector quantity arg.

Parameters:

arg – an object array of shape (3,) containing numpy.ndarrays with shape (npoints,).

eval_at_center(f_values: ndarray[InexactT]) InexactT[source]ΒΆ

Interpolate f_values to the center point.

Parameters:

f_values – an array of shape (npoints,)

Returns:

a scalar.

property x: ndarray[floating[Any]]ΒΆ
property y: ndarray[floating[Any]]ΒΆ
property z: ndarray[floating[Any]]ΒΆ
norm(arg: ObjectArray1D[ndarray[InexactT]] | ndarray[InexactT], p: float) floating[Any][source]ΒΆ
plot_nodes() None[source]ΒΆ
plot(f: ndarray[floating[Any]]) None[source]ΒΆ
sumpy.point_calculus.frequency_domain_maxwell(cpatch: CalculusPatch, e: ObjectArray1D[ndarray[complexfloating[Any]]], h: ObjectArray1D[ndarray[complexfloating[Any]]], k: complex) tuple[ObjectArray1D[ndarray[complexfloating[Any]]], ObjectArray1D[ndarray[complexfloating[Any]]], ndarray[complexfloating[Any]], ndarray[complexfloating[Any]]][source]ΒΆ

Support for Numerical Experiments with Expansions (β€œExpansion toys”)ΒΆ

This module provides a convenient interface for numerical experiments with local and multipole expansions.

class sumpy.toys.ToyContext(kernel: Kernel, mpole_expn_class: MultipoleExpansionFactory | None = None, local_expn_class: LocalExpansionFactory | None = None, expansion_factory: ExpansionFactoryBase | None = None, extra_source_kwargs: Mapping[str, object] | None = None, extra_kernel_kwargs: Mapping[str, object] | None = None, m2l_use_fft: bool | None = None)[source]ΒΆ

This class functions as a container for generated code and β€˜behind-the-scenes’ information.

__init__(kernel: Kernel, mpole_expn_class: MultipoleExpansionFactory | None = None, local_expn_class: LocalExpansionFactory | None = None, expansion_factory: ExpansionFactoryBase | None = None, extra_source_kwargs: Mapping[str, object] | None = None, extra_kernel_kwargs: Mapping[str, object] | None = None, m2l_use_fft: bool | None = None)[source]ΒΆ
class sumpy.toys.PotentialSource(toy_ctx: ToyContext)[source]ΒΆ

A base class for all classes representing potentials that can be evaluated anywhere in space.

eval(actx: ArrayContext, targets: np.ndarray) np.ndarray[source]ΒΆ
Parameters:

targets – An array of shape (dim, ntargets).

Returns:

an array of shape (ntargets,).

Supports (lazy) arithmetic:

__neg__() PotentialSource[source]ΒΆ
__add__(other: int | float | complex | number | PotentialSource) PotentialSource[source]ΒΆ
__radd__(other: int | float | complex | number | PotentialSource) PotentialSource[source]ΒΆ
__sub__(other: int | float | complex | number | PotentialSource) PotentialSource[source]ΒΆ
__rsub__(other: int | float | complex | number | PotentialSource) PotentialSource[source]ΒΆ
__mul__(other: int | float | complex | number | PotentialSource) PotentialSource[source]ΒΆ
__rmul__(other: int | float | complex | number | PotentialSource) PotentialSource[source]ΒΆ
class sumpy.toys.ConstantPotential(toy_ctx: ToyContext, value)[source]ΒΆ

Inherits from PotentialSource.

__init__(toy_ctx: ToyContext, value)[source]ΒΆ
class sumpy.toys.PointSources(toy_ctx: ToyContext, points: ndarray, weights: ndarray, center: ndarray | None = None)[source]ΒΆ

Inherits from PotentialSource.

pointsΒΆ

[ndim, npoints]

__init__(toy_ctx: ToyContext, points: ndarray, weights: ndarray, center: ndarray | None = None)[source]ΒΆ

These functions manipulate these potentials:

sumpy.toys.multipole_expand(actx: ArrayContext, psource: PotentialSource, center: np.ndarray, *, order: int | None = None, rscale: float = 1, **expn_kwargs: Any) MultipoleExpansion[source]ΒΆ
sumpy.toys.local_expand(actx: ArrayContext, psource: PotentialSource, center: np.ndarray, *, order: int | None = None, rscale: float = 1, **expn_kwargs: Any) LocalExpansion[source]ΒΆ
sumpy.toys.logplot(actx: ArrayContext, fp: FieldPlotter, psource: PotentialSource, **kwargs) None[source]ΒΆ
sumpy.toys.combine_inner_outer(psource_inner: PotentialSource, psource_outer: PotentialSource, radius: float | None, center: ndarray | None = None) PotentialSource[source]ΒΆ
sumpy.toys.combine_halfspace(psource_pos: PotentialSource, psource_neg: PotentialSource, axis: int, center: ndarray | None = None) PotentialSource[source]ΒΆ
sumpy.toys.combine_halfspace_and_outer(psource_pos: PotentialSource, psource_neg: PotentialSource, psource_outer: PotentialSource, axis: int, radius: float | None = None, center: ndarray | None = None) PotentialSource[source]ΒΆ
sumpy.toys.l_inf(actx: ArrayContext, psource: PotentialSource, radius: float, center: np.ndarray | None = None, npoints: int = 100, debug: bool = False) number[source]ΒΆ

These functions help with plotting:

sumpy.toys.draw_box(el, eh, **kwargs)[source]ΒΆ
sumpy.toys.draw_circle(center, radius, **kwargs)[source]ΒΆ
sumpy.toys.draw_annotation(to_pt, from_pt, label, arrowprops=None, **kwargs)[source]ΒΆ
Parameters:
  • to_pt – Head of arrow

  • from_pt – Tail of arrow

  • label – Annotation label

  • arrowprops – Passed to arrowprops

  • kwargs – Passed to annotate

sumpy.toys.draw_schematic(psource, **kwargs)[source]ΒΆ

These are created behind the scenes and are not typically directly instantiated by users:

class sumpy.toys.OneOnBallPotential(toy_ctx: ToyContext, center: ndarray, radius: float)[source]ΒΆ

A potential that is the characteristic function on a ball.

Inherits from PotentialSource.

__init__(toy_ctx: ToyContext, center: ndarray, radius: float) None[source]ΒΆ
class sumpy.toys.HalfspaceOnePotential(toy_ctx: ToyContext, center: ndarray, axis: int, side: int = 1)[source]ΒΆ

A potential that is the characteristic function of a halfspace.

__init__(toy_ctx: ToyContext, center: ndarray, axis: int, side: int = 1) None[source]ΒΆ
class sumpy.toys.ExpansionPotentialSource(toy_ctx, center, rscale, order: int, coeffs, derived_from, radius=None, expn_style=None, text_kwargs=None)[source]ΒΆ

Inherits from PotentialSource.

radiusΒΆ

Not used mathematically. Just for visualization, purely advisory.

text_kwargsΒΆ

Passed to matplotlib.pyplot.annotate(). Used for customizing the expansion label. Changing the label text is supported by passing the kwarg s. Just for visualization, purely advisory.

__init__(toy_ctx, center, rscale, order: int, coeffs, derived_from, radius=None, expn_style=None, text_kwargs=None)[source]ΒΆ
class sumpy.toys.MultipoleExpansion(toy_ctx, center, rscale, order: int, coeffs, derived_from, radius=None, expn_style=None, text_kwargs=None)[source]ΒΆ

Inherits from ExpansionPotentialSource.

class sumpy.toys.LocalExpansion(toy_ctx, center, rscale, order: int, coeffs, derived_from, radius=None, expn_style=None, text_kwargs=None)[source]ΒΆ

Inherits from ExpansionPotentialSource.

class sumpy.toys.PotentialExpressionNode(psources: Sequence[PotentialSource])[source]ΒΆ

Inherits from PotentialSource.

__init__(psources: Sequence[PotentialSource]) None[source]ΒΆ
class sumpy.toys.Sum(psources: Sequence[PotentialSource])[source]ΒΆ

Inherits from PotentialExpressionNode.

class sumpy.toys.Product(psources: Sequence[PotentialSource])[source]ΒΆ

Inherits from PotentialExpressionNode.

class sumpy.toys.SchematicVisitor(default_expn_style='circle')[source]ΒΆ