sisl.shape.shape module

Implementation of different shapes

This module implements a generic shape which may be sub-classed for other more distinct shapes such as, Spheres, Boxes, Polygons etc.

class sisl.shape.shape.Shape(center)[source]

Bases: object

Baseclass for shapes.

This class should always be sub-classed.

There are a few routines that are always necessary to implement in a inherited class: - center

return the geometric center of the shape
  • volume return the volume of the shape.
  • displacement return a vector that is the largest displacement vector such that a grid of the Shape will fully contian all space
  • within Enables to check if coordinates, or other things are contained in this shape
  • iwithin Returns only the indices of elements that are within
  • enlarge Creates a new shape with a only the indices of elements that are within

A Shape allows interaction with outside elements to check if geometric points are within the shapes. For instance to assert that a given point x, y, z is within a sphere of radius r with center cx, cy, cz on may do:

>>> xyz = [...]
>>> shape = Sphere(r, [cx, cy, cz])
>>> if shape.within(xyz):
>>>    # do something

This makes it very efficient to enable arbitrary shapes to be passed and used as determinations of regions of space.

Attributes

center Return the geometric center of the shape
displacement Return a displacement vector for full containment
volume

Methods

__call__(*args, **kwargs) Re-initialize the Shape
enlarge(length) Return a new Shape with an increased size length
iwithin(other) Returns indices of the elements of other that are within the shape
within(other) Returns True if other is fully within self

Initialize the Shape with a center

Attributes

center Return the geometric center of the shape
displacement Return a displacement vector for full containment
volume

Methods

__call__(*args, **kwargs) Re-initialize the Shape
enlarge(length) Return a new Shape with an increased size length
iwithin(other) Returns indices of the elements of other that are within the shape
within(other) Returns True if other is fully within self
center

Return the geometric center of the shape

displacement

Return a displacement vector for full containment

enlarge(length)[source]

Return a new Shape with an increased size length

iwithin(other)[source]

Returns indices of the elements of other that are within the shape

volume
within(other)[source]

Returns True if other is fully within self