Devices & Geometry
The classes defined in superscreen.device
, superscreen.geometry
,
and superscreen.parameter
are used to set up the inputs to a
SuperScreen
simulation, namely:
The geometry and penetration depth of all superconducting films
The spatial distribution of the applied magnetic field
Devices
Device
- class superscreen.Device(name, *, layers, films, holes=None, terminals=None, abstract_regions=None, length_units='um', solve_dtype='float32')[source]
An object representing a device composed of one or more layers of thin film superconductor.
- Parameters:
name (
str
) – Name of the device.layers (
Union
[Sequence
[Layer
],Dict
[str
,Layer
]]) –Layers
making up the device.films (
Union
[Sequence
[Polygon
],Dict
[str
,Polygon
]]) –Polygons
representing regions of superconductor.holes (
Union
[Sequence
[Polygon
],Dict
[str
,Polygon
],None
]) –Holes
representing holes in superconducting films.terminals (
Optional
[Dict
[str
,List
[Polygon
]]]) – A dict of{film_name: terminals}
representing transport terminals in the device.abstract_regions (
Union
[Sequence
[Polygon
],Dict
[str
,Polygon
],None
]) –Polygons
representing abstract regions in a device.length_units (
str
) – Distance units for the coordinate system.solve_dtype (
Union
[str
,dtype
]) – The float data type to use when solving the device.
- property poly_points: ndarray
Shape (n, 2) array of (x, y) coordinates of all Polygons in the Device.
- polygons_by_layer(polygon_type=None)[source]
Returns a dict of
{layer_name: list of polygons in layer}
.
- scale(xfact=1, yfact=1, origin=(0, 0))[source]
Returns a new device with polygons scaled horizontally and/or vertically.
Negative
xfact
(yfact
) can be used to reflect the device horizontally (vertically) about theorigin
.
- rotate(degrees, origin=(0, 0))[source]
Returns a new device with polygons rotated a given amount counterclockwise about specified origin.
- mirror_layers(about_z=0.0)[source]
Returns a new device with its layers mirrored about the plane
z = about_z
.- Parameters:
about_z (
float
) – The z-position of the plane (parallel to the x-y plane) about which to mirror the layers.- Return type:
- Returns:
The mirrored
superscreen.Device
.
- translate(dx=0, dy=0, dz=0, inplace=False)[source]
Translates the device polygons, layers, and meshes in space by a given amount.
- Parameters:
dx (
float
) – Distance by which to translate along the x-axis.dy (
float
) – Distance by which to translate along the y-axis.dz (
float
) – Distance by which to translate layers along the z-axis.inplace (
bool
) – If True, modifies the device (self
) in-place and returns None, otherwise, creates a new device, translates it, and returns it.
- Return type:
- Returns:
The translated device.
- translation(dx, dy, dz=0)[source]
A context manager that temporarily translates a device in-place, then returns it to its original position.
- make_mesh(buffer_factor=0.05, buffer=None, join_style='round', min_points=None, max_edge_length=None, preserve_boundary=False, smooth=0, **meshpy_kwargs)[source]
Generates the triangular mesh for each film and stores them in the
self.meshes
dictionary.The arguments
buffer_factor
,buffer
,min_points
,max_edge_length
, andsmooth
can be specified either as a single value for all films or as a dict of{film_name: argument_value}
.- Parameters:
buffer_factor (
Union
[float
,Dict
[str
,float
],None
]) – Buffer for the film bounding box(es), in units of the maximum film dimension. This argument is ignored ifbuffer
is not None.buffer (
Union
[float
,Dict
[str
,float
],None
]) – Buffer for the film bounding box(es), inlength_units
.join_style (
str
) – The join style for the buffered region (seesuperscreen.Polygon.buffer()
).min_points (
Union
[int
,Dict
[str
,int
],None
]) – Minimum number of vertices in the mesh. If None, then the number of vertices will be determined by meshpy_kwargs and the number of vertices in the underlying polygons.max_edge_length (
Union
[float
,Dict
[str
,float
],None
]) – The maximum distance between vertices in the resulting mesh.preserve_boundary (
bool
) – Do not add any mesh sites to the boundary.smooth (
Union
[int
,Dict
[str
,int
]]) – Number of Laplacian smoothing iterations to perform.**meshpy_kwargs – Passed to meshpy.triangle.build().
- Return type:
- mesh_stats(precision=3)[source]
When called with in Jupyter notebook, displays a table of information about the mesh.
- mutual_inductance_matrix(hole_polygon_mapping=None, units='pH', all_iterations=False, **solve_kwargs)[source]
Calculates the mutual inductance matrix \(\mathbf{M}\) for the Device.
\(\mathbf{M}\) is defined such that element \(M_{ij}\) is the mutual inductance \(\Phi^f_{S_i} / I_j\) between hole \(j\) and polygon \(S_{i}\), which encloses hole \(i\). \(\Phi^f_{S_i}\) is the fluxoid for polygon \(S_i\) and \(I_j\) is the current circulating around hole \(j\).
- Parameters:
hole_polygon_mapping (
Optional
[Dict
[str
,ndarray
]]) – A dict of{hole_name: polygon_coordinates}
specifying a mapping between holes in the device and polygons enclosing those holes, for which the fluxoid will be calculated. The length of this dict,n_holes
, will determine the dimension of the square mutual inductance matrix \(M\).units (
str
) – The units in which to report the mutual inductance.all_iterations (
bool
) – Whether to return mutual inductance matrices for alliterations + 1
solutions, or just the final solution.solve_kwargs – Keyword arguments passed to
superscreen.solve.solve()
, e.g.iterations
.
- Return type:
- Returns:
If all_iterations is False, returns a shape
(n_holes, n_holes)
mutual inductance matrix from the final iteration. Otherwise, returns a list of mutual inductance matrices, each with shape(n_holes, n_holes)
. The length of the list is1
if the device has a single layer, oriterations + 1
if the device has multiple layers.
- plot_polygons(ax=None, subplots=False, legend=False, figsize=None, **kwargs)[source]
Plot all of the Device’s polygons.
- Parameters:
ax (
Optional
[Axes
]) – matplotlib axis on which to plot. If None, a new figure is created.subplots (
bool
) – If True, plots each film on a different subplot.legend (
bool
) – Whether to add a legend.figsize (
Optional
[Tuple
[float
,float
]]) – matplotlib figsize, only used if ax is None.kwargs – Passed to
ax.plot()
for the polygon boundaries.
- Return type:
- Returns:
Matplotlib Figure and Axes
- plot_mesh(ax=None, subplots=False, figsize=None, show_sites=False, show_edges=True, site_color=None, edge_color=None, linewidth=0.75, linestyle='-', marker='.')[source]
Plot all of the Device’s meshes.
- Parameters:
ax (
Optional
[Axes
]) – matplotlib axis on which to plot. If None, a new figure is created.subplots (
bool
) – If True, plots each film on a different subplot.figsize (
Optional
[Tuple
[float
,float
]]) – matplotlib figsize, only used if ax is None.show_sites (
bool
) – Whether to show the mesh sites.show_edges (
bool
) – Whether to show the mesh edges.site_color (
Union
[str
,Sequence
[float
],None
]) – The color for the sites.edge_color (
Union
[str
,Sequence
[float
],None
]) – The color for the edges.linewidth (
float
) – The line width for all edges.linestyle (
str
) – The line style for all edges.marker (
str
) – The marker to use for the mesh sites.
- Return type:
- Returns:
Matplotlib Figure and Axes
- patches()[source]
Returns a dict of
{layer_name: {film_name: PathPatch}}
for visualizing the device. `
- draw(ax=None, subplots=False, max_cols=3, legend=False, figsize=None, alpha=0.5, exclude=None, layer_order='increasing')[source]
Draws all polygons in the device as matplotlib patches.
- Parameters:
ax (
Optional
[Axes
]) – matplotlib axis on which to plot. If None, a new figure is created.subplots (
bool
) – If True, plots each layer on a different subplot.max_cols (
int
) – The maximum number of columns to create ifsubplots
is True.legend (
bool
) – Whether to add a legend.figsize (
Optional
[Tuple
[float
,float
]]) – matplotlib figsize, only used if ax is None.alpha (
float
) – The alpha (opacity) value for the patches (0 <= alpha <= 1).exclude (
Union
[str
,List
[str
],None
]) – A polygon name or list of polygon names to exclude from the figure.layer_order (
str
) – If"increasing"
("decreasing"
) draw polygons in increasing (decreasing) order by layer heightlayer.z0
.
- Return type:
- Returns:
Matplotlib Figre and Axes.
Layer
- class superscreen.Layer(name, Lambda=None, london_lambda=None, thickness=None, z0=0)[source]
A single layer of a superconducting device.
You can provide either an effective penetration depth
Lambda
, or both a London penetration depth (lambda_london
) and a layerthickness
.Lambda
andlondon_lambda
can either be real numers or instances ofsuperscreen.Parameter
which compute the penetration depth as a function of position.- Parameters:
name (
str
) – Name of the layer.Lambda (
Union
[float
,Parameter
,None
]) – The effective magnetic penetration depth of the superconducting film(s) in the layer.thickness (
Optional
[float
]) – Thickness of the superconducting film(s) located in the layer.london_lambda (
Union
[float
,Parameter
,None
]) – London penetration depth of the superconducting film(s) located in the layer.z0 (
float
) – Vertical location of the layer.
Polygon
- class superscreen.Polygon(name=None, *, layer=None, points)[source]
A simply-connected polygon located in a Layer.
- Parameters:
layer (
Optional
[str
]) – Name of the layer in which the polygon is located.points (
Union
[Polygon
,ndarray
,LineString
,LinearRing
,Polygon
]) – The polygon vertices. This can be a shape(n, 2)
array of x, y coordinates or a shapelyLineString
,LinearRing
, orsuperscreen.Polygon
.
- property is_valid: bool
True if the
superscreen.Polygon
has aname
andlayer
its geometry is valid.
- property extents: Tuple[float, float]
Returns the total x, y extent of the polygon, (Delta_x, Delta_y).
- property polygon: Polygon
A shapely
superscreen.Polygon
representing thesuperscreen.Polygon
- set_name(name)[source]
Sets the Polygon’s name and returns
self
.- Parameters:
name (
Optional
[str
]) – The new name for thesuperscreen.Polygon
- Return type:
- Returns:
self
- set_layer(layer)[source]
Sets the Polygon’s layer and returns
self
.- Parameters:
layer (
Optional
[str
]) – The new layer for thesuperscreen.Polygon
- Return type:
- Returns:
self
- contains_points(points, index=False, radius=0)[source]
Determines whether
points
lie within the polygon.- Parameters:
points (
ndarray
) – Shape(n, 2)
array of x, y coordinates.index (
bool
) – If True, then return the indices of the points inpoints
that lie within the polygon. Otherwise, returns a shape(n, )
boolean array.radius (
float
) – An additional margin onself.path
. Seematplotlib.path.Path.contains_points()
.
- Return type:
- Returns:
If index is True, returns the indices of the points in
points
that lie within the polygon. Otherwise, returns a shape(n, )
boolean array indicating whether each point lies within the polygon.
- on_boundary(points, radius=0.001, index=False)[source]
Determines whether
points
lie within a given radius of the Polygon boundary.- Parameters:
- Returns:
If index is True, returns the indices of the points in
points
that lie within the polygon. Otherwise, returns a shape(n, )
boolean array indicating whether each point lies within the polygon.
- make_mesh(min_points=None, max_edge_length=None, convex_hull=False, smooth=0, build_operators=False, **meshpy_kwargs)[source]
Creates a
Mesh
for the polygon.- Parameters:
min_points (
Optional
[int
]) – Minimum number of vertices in the mesh. If None, then the number of vertices will be determined by meshpy_kwargs and the number of vertices in the underlying polygons.max_edge_length (
Optional
[float
]) – The maximum distance between vertices in the resulting mesh.convex_hull (
bool
) – If True, then the entire convex hull of the polygon (minus holes) will be meshed. Otherwise, only the polygon interior is meshed.smooth (
int
) – Number of Laplacian smoothing steps to perform.build_operators (
bool
) – Whether to build thesuperscreen.device.MeshOperators
for the mesh.**meshpy_kwargs – Passed to meshpy.triangle.build().
- Return type:
- rotate(degrees, origin=(0.0, 0.0), inplace=False)[source]
Rotates the polygon counterclockwise by a given angle.
- Parameters:
degrees (
float
) – The amount by which to rotate the polygon.origin (
Union
[str
,Tuple
[float
,float
]]) – (x, y) coorindates about which to rotate, or the strings “center” (for the bounding box center) or “centroid” (for the polygon center of mass).inplace (
bool
) – If True, modify the polygon in place. Otherwise, return a modified copy.
- Return type:
- Returns:
The rotated polygon.
- scale(xfact=1.0, yfact=1.0, origin=(0, 0), inplace=False)[source]
Scales the polygon horizontally by
xfact
and vertically byyfact
.Negative
xfact
(yfact
) can be used to reflect the polygon horizontally (vertically) about theorigin
.- Parameters:
xfact (
float
) – Distance by which to translate along the x-axis.yfact (
float
) – Distance by which to translate along the y-axis.origin (
Union
[str
,Tuple
[float
,float
]]) – (x, y) coorindates for the scaling origin, or the strings “center” (for the bounding box center) or “centroid” (for the polygon center of mass).inplace (
bool
) – If True, modify the polygon in place. Otherwise, return a modified copy.
- Return type:
- Returns:
The scaled polygon.
- union(*others, name=None)[source]
Returns the union of the polygon and zero or more other polygons.
- Parameters:
others (
Union
[Polygon
,ndarray
,LineString
,LinearRing
,Polygon
]) – One or more objects with which to join the polygon.name (
Optional
[str
]) – A name for the resulting joinedsuperscreen.Polygon
(defaults toself.name
.)
- Return type:
- Returns:
A new
Polygon
instance representing the union ofself
andothers
.
- intersection(*others, name=None)[source]
Returns the intersection of the polygon and zero or more other polygons.
- Parameters:
others (
Union
[Polygon
,ndarray
,LineString
,LinearRing
,Polygon
]) – One or more objects with which to join the polygon.name (
Optional
[str
]) – A name for the resulting joinedsuperscreen.Polygon
(defaults toself.name
.)
- Return type:
- Returns:
A new
Polygon
instance representing the intersection ofself
andothers
.
- difference(*others, symmetric=False, name=None)[source]
Returns the difference of the polygon and zero more other polygons.
- Parameters:
others (
Union
[Polygon
,ndarray
,LineString
,LinearRing
,Polygon
]) – One or more objects with which to join the polygon.symmetric (
bool
) – Whether to join via a symmetric difference operation (aka XOR). See the shapely documentation.name (
Optional
[str
]) – A name for the resulting joinedsuperscreen.Polygon
(defaults toself.name
.)
- Return type:
- Returns:
A new
Polygon
instance representing the difference ofself
andothers
.
- buffer(distance, join_style='mitre', mitre_limit=5.0, single_sided=True, as_polygon=True)[source]
Returns polygon points or a new
superscreen.Polygon
object with vertices offset fromself.points
by a givendistance
. Ifdistance > 0
this “inflates” the polygon, and ifdistance < 0
this shrinks the polygon.- Parameters:
distance (
float
) – The amount by which to inflate or deflate the polygon.join_style (
Union
[str
,int
]) – One of “round” (1), “mitre” (2), or “bevel” (3). See the shapely documentation.mitre_limit (
float
) – See the shapely documentation.single_sided (
bool
) – See the shapely documentation.as_polygon (
bool
) – If True, returns a newsuperscreen.Polygon
instance, otherwise returns a shape(n, 2)
array of polygon vertices.
- Return type:
- Returns:
A new
superscreen.Polygon
or an array of vertices offset bydistance
.
- resample(num_points=None, degree=1, smooth=0)[source]
Resample vertices so that they are approximately uniformly distributed along the polygon boundary.
- Parameters:
num_points (
Optional
[int
]) – Number of points to interpolate to. Ifnum_points
is None, the polygon is resampled tolen(self.points)
points. Ifnum_points
is not None and has a boolean value of False, then an unaltered copy of the polygon is returned.degree (
int
) – The degree of the spline with which to iterpolate. Defaults to 1 (linear spline).smooth (
float
) – Smoothing condition.
- Return type:
- classmethod from_union(items, *, name=None, layer=None)[source]
Creates a new
Polygon
from the union of a sequence of polygons.
- classmethod from_intersection(items, *, name=None, layer=None)[source]
Creates a new
Polygon
from the intersection of a sequence of polygons.
- classmethod from_difference(items, *, name=None, layer=None, symmetric=False)[source]
Creates a new
Polygon
from the difference of a sequence of polygons.- Parameters:
items (
Iterable
[Union
[Polygon
,ndarray
,LineString
,LinearRing
,Polygon
]]) – A sequence of polygon-like objects to join.layer (
Optional
[str
]) – Name of the layer in which the polygon is located.symmetric (
bool
) – If True, creates a newPolygon
from the “symmetric difference” (aka XOR) of the inputs.
- Return type:
- Returns:
A new
Polygon
.
Meshing
- class superscreen.Mesh(sites, elements, boundary_indices, vertex_areas, triangle_areas, edge_mesh, build_operators=True)[source]
A triangular mesh of a simply- or multiply-connected polygon.
Tip
Use
Mesh.from_triangulation()
to create a new mesh from a triangulation.- Parameters:
sites (
Sequence
[Tuple
[float
,float
]]) – The (x, y) coordinates of the mesh vertices.elements (
Sequence
[Tuple
[int
,int
,int
]]) – A list of triplets that correspond to the indices of he vertices that form a triangle. [[0, 1, 2], [0, 1, 3]] corresponds to a triangle connecting vertices 0, 1, and 2 and another triangle connecting vertices 0, 1, and 3.boundary_indices (
Sequence
[int
]) – Indices corresponding to the boundary.vertex_areas (
Sequence
[float
]) – The areas corresponding to the sites or vertices.triangle_areas (
Sequence
[float
]) – The areas of the triangular mesh elements.edge_mesh (
EdgeMesh
) – The edge mesh.build_operators (
bool
) – Whether to build thesuperscreen.device.MeshOperators
for the mesh.
- property triangulation: Triangulation
Matplotlib triangulation of the mesh.
- static from_triangulation(sites, elements, build_operators=True)[source]
Create a triangular mesh from the coordinates of the triangle vertices and a list of indices corresponding to the vertices that connect to triangles.
- Parameters:
sites (
Sequence
[Tuple
[float
,float
]]) – The (x, y) coordinates of the mesh sites.elements (
Sequence
[Tuple
[int
,int
,int
]]) – A list of triplets that correspond to the indices of the vertices that form a triangle. E.g. [[0, 1, 2], [0, 1, 3]] corresponds to a triangle connecting vertices 0, 1, and 2 and another triangle connecting vertices 0, 1, and 3.build_operators (
bool
) – Whether to build thesuperscreen.device.MeshOperators
for the mesh.
- Return type:
- Returns:
A new
tdgl.finite_volume.Mesh
instance
- smooth(iterations, build_operators=True)[source]
Perform Laplacian smoothing of the mesh, i.e., moving each interior vertex to the arithmetic average of its neighboring points.
- Parameters:
iterations (
int
) – The number of smoothing iterations to perform.build_operators (
bool
) – Whether to build thesuperscreen.device.MeshOperators
for the mesh.
- Return type:
- Returns:
A new Mesh with relaxed vertex positions.
- plot(ax=None, show_sites=False, show_edges=True, site_color=None, edge_color='k', linewidth=0.75, linestyle='-', marker='.')[source]
Plot the mesh.
- Parameters:
ax (
Optional
[Axes
]) – Aplt.Axes
instance on which to plot the mesh.show_sites (
bool
) – Whether to show the mesh sites.show_edges (
bool
) – Whether to show the mesh edges.site_color (
Union
[str
,Sequence
[float
],None
]) – The color for the sites.edge_color (
Union
[str
,Sequence
[float
],None
]) – The color for the edges.linewidth (
float
) – The line width for all edges.linestyle (
str
) – The line style for all edges.marker (
str
) – The marker to use for the mesh sites.
- Return type:
- Returns:
The resulting
plt.Axes
- to_hdf5(h5group, compress=True)[source]
Save the mesh to a
h5py.Group
.- Parameters:
h5group (
Group
) – Theh5py.Group
into which to store the mesh.compress (
bool
) – IfTrue
, store only the sites and elements.
- Return type:
- static from_hdf5(h5group)[source]
Load a mesh from an HDF5 file.
- Parameters:
h5group (
Group
) – The HDF5 group to load the mesh from.- Return type:
- Returns:
The loaded mesh.
- static is_restorable(h5group)[source]
Returns
True
if theh5py.Group
contains all of the data necessary to create aMesh
without re-computing any values.- Parameters:
h5group (
Group
) – Theh5py.Group
to check.- Return type:
- Returns:
Whether the mesh can be restored from the given group.
- class superscreen.device.EdgeMesh(centers, edges, boundary_edge_indices, directions, edge_lengths)[source]
A mesh composed of the edges in a triangular mesh.
Tip
Use
EdgeMesh.from_mesh()
to create from an existing mesh.- Parameters:
- class superscreen.device.MeshOperators(*, weights, Q, gradient_x, gradient_y, laplacian)[source]
A container for the finite element operators for a
superscreen.Mesh
.- Parameters:
- static from_mesh(mesh)[source]
Construct a
superscreen.device.MeshOperators
instance from asuperscreen.Mesh
.- Parameters:
mesh (
Mesh
) – Thesuperscreen.Mesh
- Return type:
- Returns:
A new
superscreen.device.MeshOperators
instance
- static C_vector(points)[source]
Computes the edge vector, C:
\[\begin{split}C_i &= \frac{1}{4\pi}\sum_{p,q=\pm1}\sqrt{(\Delta x - px_i)^{-2} + (\Delta y - qy_i)^{-2}}\\ \Delta x &= \frac{1}{2}(\mathrm{max}(x) - \mathrm{min}(x))\\ \Delta y &= \frac{1}{2}(\mathrm{max}(y) - \mathrm{min}(y))\end{split}\]See Eq. 12 in [Brandt-PRB-2005], Eq. 16 in [Kirtley-RSI-2016], and Eq. 15 in [Kirtley-SST-2016].
- static Q_matrix(points, weights)[source]
Computes the kernel matrix, Q:
\[Q_{ij} = (\delta_{ij}-1)q_{ij} + \delta_{ij}\frac{1}{w_{ij}}\left(C_i + \sum_{l\neq i}q_{il}w_{il}\right)\]See Eq. 10 in [Brandt-PRB-2005], Eq. 11 in [Kirtley-RSI-2016], and Eq. 11 in [Kirtley-SST-2016].
- superscreen.device.generate_mesh(poly_coords, hole_coords=None, min_points=None, max_edge_length=None, convex_hull=False, boundary=None, preserve_boundary=False, min_angle=32.5, **kwargs)[source]
Generates a Delaunay mesh for a given set of polygon vertex coordinates.
Additional keyword arguments are passed to
triangle.build()
.- Parameters:
poly_coords (
ndarray
) – Shape(n, 2)
array of polygon(x, y)
coordinates.hole_coords (
Optional
[List
[ndarray
]]) – A list of arrays of hole boundary coordinates.min_points (
Optional
[int
]) – The minimimum number of vertices in the resulting mesh.max_edge_length (
Optional
[float
]) – The maximum distance between interior vertices in the resulting mesh.convex_hull (
bool
) – If True, then the entire convex hull of the polygon (minus holes) will be meshed. Otherwise, only the polygon interior is meshed.boundary (
Optional
[ndarray
]) – Shape(m, 2)
(wherem <= n
) array of(x, y)
coordinates for points on the boundary of the polygon.preserve_boundary (
bool
) – Do not add any mesh sites to the boundary.min_angle (
float
) – The minimum angle in the mesh’s triangles. Setting a larger value will make the triangles closer to equilateral, but the mesh generation may fail if the value is too large.
- Return type:
- Returns:
Mesh vertex coordinates and triangle indices.
Parameters
Parameter
- class superscreen.Parameter(func, **kwargs)[source]
A callable object that computes a scalar or vector quantity as a function of position coordinates x, y (and optionally z).
Addition, subtraction, multiplication, and division between multiple Parameters and/or real numbers (ints and floats) is supported. The result of any of these operations is a
CompositeParameter
object.- Parameters:
func (
Callable
) – A callable/function that actually calculates the parameter’s value. The function must take x, y (and optionally z) as the first and only positional arguments, and all other arguments must be keyword arguments. Therefore func should have a signature likefunc(x, y, z, a=1, b=2, c=True)
,func(x, y, *, a, b, c)
,func(x, y, z, *, a, b, c)
, orfunc(x, y, z, *, a, b=None, c=3)
.kwargs – Keyword arguments for func.
CompositeParameter
- class superscreen.parameter.CompositeParameter(left, right, op)[source]
Bases:
Parameter
A callable object that behaves like a
superscreen.Parameter
(i.e. it computes a scalar or vector quantity as a function of position coordinates x, y, z). Asuperscreen.parameter.CompositeParameter
object is created as a result of mathematical operations betweenParameters
,CompositeParameters
, and/or real numbers.Addition, subtraction, multiplication, division, and exponentiation between
Parameters
,CompositeParameters
and real numbers (ints and floats) are supported. The result of any of these operations is a newsuperscreen.parameter.CompositeParameter
object.- Parameters:
left (
Union
[int
,float
,Parameter
,CompositeParameter
]) – The object on the left-hand side of the operator.right (
Union
[int
,float
,Parameter
,CompositeParameter
]) – The object on the right-hand side of the operator.op (
Union
[Callable
,str
]) – The operator acting on left and right (or its string representation).
Constant
Geometry
- superscreen.geometry.rotate(coords, angle_degrees)[source]
Rotates an array of (x, y) coordinates counterclockwise by the specified angle.
- superscreen.geometry.translate(coords, dx, dy)[source]
Translates the given (x, y) coordinates in the palne by
(dx, dy)
.
- superscreen.geometry.ellipse(a, b, points=100, center=(0, 0), angle=0)[source]
Returns the coordinates for an ellipse with major axis a and semimajor axis b, rotated by the specified angle about (0, 0), then translated to the specified center.
- Parameters:
a (
float
) – Major axis lengthb (
float
) – Semi-major axis lengthpoints (
int
) – Number of points in the circlecenter (
Tuple
[float
,float
]) – Coordinates of the center of the circleangle (
float
) – Angle (in degrees) by which to rotate counterclockwise about (0, 0) before translating to the specified center.
- Returns:
A shape
(points, 2)
array of (x, y) coordinates
- superscreen.geometry.circle(radius, points=100, center=(0, 0))[source]
Returns the coordinates for a circle with a given radius, centered at the specified center.
- superscreen.geometry.box(width, height=None, points=101, center=(0, 0), angle=0)[source]
Returns the coordinates for a rectangle with a given width and height, centered at the specified center.
- Parameters:
width (
float
) – Width of the rectangle (in the x direction).height (
Optional
[float
]) – Height of the rectangle (in the y direction). If None is given, then height is set to width and the function returns a square.points (
int
) – The target number of points making up the box. The actual number of points may be slightly different than this value.center (
Tuple
[float
,float
]) – Coordinates of the center of the rectangle.angle (
float
) – Angle (in degrees) by which to rotate counterclockwise about (0, 0) after translating to the specified center.
- Return type:
- Returns:
A shape
(m, 2)
or array of (x, y) coordinates.