Working with Values of Potentials¶
Visualization of Potentials¶
- sumpy.visualization.make_field_plotter_from_bbox(bbox, h, extend_factor=0)[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.
Differentiation of Potentials¶
- sumpy.point_calculus.NodesKind
alias of
Literal[‘chebyshev’, ‘equispaced’, ‘legendre’]
- class sumpy.point_calculus.NodesKind¶
- class sumpy.point_calculus.CalculusPatch(center: ndarray[floating], 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¶
- points¶
shape:
(dim, npoints_total)
- diff(axis: int, f_values: ndarray[inexact], nderivs: int = 1) ndarray[inexact] | Literal[0][source]¶
Return the derivative along axis of f_values.
- Parameters:
f_values – an array of shape
(npoints_total,)- Returns:
an array of shape
(npoints_total,)
- laplace(f_values: ndarray[inexact])[source]¶
Return the Laplacian of f_values.
- Parameters:
f_values – an array of shape
(npoints_total,)- Returns:
an array of shape
(npoints_total,)
- div(arg: ObjectArray1D[ndarray[inexact]]) ndarray[inexact] | int[source]¶
- Parameters:
arg – an object array containing
numpy.ndarrays with shape(npoints_total,).
- curl(arg: ObjectArray1D[ndarray[inexact]]) ObjectArray1D[ndarray[inexact]][source]¶
Take the curl of the vector quantity arg.
- Parameters:
arg – an object array of shape
(3,)containingnumpy.ndarrays with shape(npoints_total,).
- eval_at_center(f_values)[source]¶
Interpolate f_values to the center point.
- Parameters:
f_values – an array of shape
(npoints_total,)- Returns:
a scalar.
- x¶
- y¶
- z¶
- sumpy.point_calculus.frequency_domain_maxwell(cpatch: CalculusPatch, e: ObjectArray1D[ndarray[complexfloating]], h: ObjectArray1D[ndarray[complexfloating]], k: complex)[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(cl_context: pyopencl.Context, 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__(cl_context: pyopencl.Context, 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(targets: ndarray) 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]
These functions manipulate these potentials:
- sumpy.toys.multipole_expand(psource: PotentialSource, center: ndarray, order: int | None = None, rscale: float = 1, **expn_kwargs) MultipoleExpansion[source]¶
- sumpy.toys.local_expand(psource: PotentialSource, center: ndarray, order: int | None = None, rscale: int | float | complex | number = 1, **expn_kwargs) LocalExpansion[source]¶
- sumpy.toys.logplot(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(psource: PotentialSource, radius: float, center: ndarray | None = None, npoints: int = 100, debug: bool = False) number[source]¶
These functions help with plotting:
- 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
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.
- 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.
- 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.
- 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.