# Differentiation and Evaluation¶

## 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.

class sumpy.visualization.FieldPlotter(center, extent=1, npoints=1000)[source]
set_matplotlib_limits()[source]
show_scalar_in_matplotlib(fld, max_val=None, func_name='imshow', **kwargs)[source]
show_scalar_in_mayavi(fld, max_val=None, **kwargs)[source]
write_vtk_file(file_name, data, real_only=False)[source]

## Differentiation of Potentials¶

class sumpy.point_calculus.CalculusPatch(center, h=0.1, order=4, nodes='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.

weights()[source]

” :returns: a vector of high-order quadrature weights on the points

basis()[source]

” :returns: a list containing functions that realize

a high-order interpolation basis on the points.

diff(axis, f_values, nderivs=1)[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,)

dx(f_values)[source]
dy(f_values)[source]
dy(f_values)[source]
laplace(f_values)[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)[source]
Parameters

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

curl(arg)[source]

Take the curl of the vector quantity arg.

Parameters

arg – an object array of shape (3,) containing numpy.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
norm(arg, p)[source]
plot_nodes()[source]
plot(f)[source]
sumpy.point_calculus.frequency_domain_maxwell(cpatch, e, h, k)[source]

## Support for Numerical Experiments with Expansions¶

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

class sumpy.toys.ToyContext(cl_context, kernel, mpole_expn_class=None, local_expn_class=None, expansion_factory=None, extra_source_kwargs=None, extra_kernel_kwargs=None)[source]

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

__init__(cl_context, kernel, mpole_expn_class=None, local_expn_class=None, expansion_factory=None, extra_source_kwargs=None, extra_kernel_kwargs=None)[source]

Initialize self. See help(type(self)) for accurate signature.

class sumpy.toys.PotentialSource(toy_ctx)[source]

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

eval(targets)[source]

Supports (lazy) arithmetic:

__neg__()[source]
__add__(other)[source]
__radd__(other)
__sub__(other)[source]
__rsub__(other)[source]
__mul__(other)[source]
__rmul__(other)
class sumpy.toys.ConstantPotential(toy_ctx, value)[source]
__init__(toy_ctx, value)[source]

Initialize self. See help(type(self)) for accurate signature.

class sumpy.toys.PointSources(toy_ctx, points, weights, center=None)[source]
points

[ndim, npoints]

__init__(toy_ctx, points, weights, center=None)[source]

Initialize self. See help(type(self)) for accurate signature.

These functions manipulate these potentials:

sumpy.toys.multipole_expand(psource, center, order=None, rscale=1, **expn_kwargs)[source]
sumpy.toys.local_expand(psource, center, order=None, rscale=1, **expn_kwargs)[source]
sumpy.toys.logplot(fp, psource, **kwargs)[source]
sumpy.toys.combine_inner_outer(psource_inner, psource_outer, radius, center=None)[source]
sumpy.toys.combine_halfspace(psource_pos, psource_neg, axis, center=None)[source]
sumpy.toys.combine_halfspace_and_outer(psource_pos, psource_neg, psource_outer, axis, radius=None, center=None)[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={}, **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, center, radius)[source]
__init__(toy_ctx, center, radius)[source]

Initialize self. See help(type(self)) for accurate signature.

class sumpy.toys.HalfspaceOnePotential(toy_ctx, center, axis, side=1)[source]
__init__(toy_ctx, center, axis, side=1)[source]

Initialize self. See help(type(self)) for accurate signature.

class sumpy.toys.ExpansionPotentialSource(toy_ctx, center, rscale, order, coeffs, derived_from, radius=None, expn_style=None, text_kwargs=None)[source]
radius

Not used mathematically. Just for visualization, purely advisory.

text_kwargs

Passed to :method: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, coeffs, derived_from, radius=None, expn_style=None, text_kwargs=None)[source]
class sumpy.toys.LocalExpansion(toy_ctx, center, rscale, order, coeffs, derived_from, radius=None, expn_style=None, text_kwargs=None)[source]
class sumpy.toys.Sum(psources)[source]
class sumpy.toys.Product(psources)[source]
class sumpy.toys.SchematicVisitor(default_expn_style='circle')[source]