Grid¶
-
class
sisl.Grid(shape, bc=None, sc=None, dtype=None, geom=None)[source]¶ Object to retain grid information
This grid object handles cell vectors and divisions of said grid.
A grid can be periodic and non-periodic.
Attributes
DIRICHLETNEUMANNPERIODICcellReturns the inherent SuperCellobjectscelldcellReturns the delta-cell dtypeReturns the data-type of the grid dvolVolume of the grids voxel elements isc_offReturns the inherent SuperCellobjectsisc_offn_sReturns the inherent SuperCellobjectsn_snscReturns the inherent SuperCellobjectsnscrcellReturns the inherent SuperCellobjectsrcellsc_offReturns the inherent SuperCellobjectssc_offshapeReturns the shape of the grid sizeReturns size of the grid volReturns the inherent SuperCellobjectsvolMethods
__init__(shape[, bc, sc, dtype, geom])Initialize a Gridobject.add_vacuum(vacuum, axis)Add vacuum along the axis lattice vector append(other, axis)Appends other Gridto this grid along axisaverage(axis)Returns the average grid along direction axis copy()Returns a copy of the object. cross_section(idx, axis)Takes a cross-section of the grid along axis axis index(coord[, axis])Returns the index along axis axis where coord exists interp(shape[, method])Returns an interpolated version of the grid is_orthogonal()Return true if all cell vectors are linearly independent mean(axis)Returns the average grid along direction axis read(sile, *args, **kwargs)Reads grid from the Sileusing read_gridremove(idx, axis)Removes certain indices from a specified axis. remove_part(idx, axis, above)Removes parts of the grid via above/below designations. sc_index(*args, **kwargs)Call local SuperCellobjectsc_indexfunctionset_bc([boundary, a, b, c])Set the boundary conditions on the grid set_boundary([boundary, a, b, c])Set the boundary conditions on the grid set_boundary_condition([boundary, a, b, c])Set the boundary conditions on the grid set_geom(geom)Sets the Geometryfor the grid.set_geometry(geom)Sets the Geometryfor the grid.set_grid(shape[, dtype])Create the internal grid of certain size. set_nsc(*args, **kwargs)Set the number of super-cells in the SuperCellobjectset_sc(sc)Overwrites the local supercell set_supercell(sc)Overwrites the local supercell sub(idx, axis)Retains certain indices from a specified axis. sub_part(idx, axis, above)Retains parts of the grid via above/below designations. sum(axis)Returns the grid summed along axis axis. swapaxes(a, b)Returns Grid with swapped axis write(sile, *args, **kwargs)Writes grid to the Sileusing write_grid-
DIRICHLET= 3¶
-
NEUMANN= 2¶
-
PERIODIC= 1¶
-
add_vacuum(vacuum, axis)¶ Add vacuum along the axis lattice vector
Parameters: vacuum : float
amount of vacuum added, in Ang
axis : int
the lattice vector to add vacuum along
-
cross_section(idx, axis)[source]¶ Takes a cross-section of the grid along axis axis
Remark: This API entry might change to handle arbitrary cuts via rotation of the axis
-
dcell¶ Returns the delta-cell
-
dtype¶ Returns the data-type of the grid
-
dvol¶ Volume of the grids voxel elements
-
index(coord, axis=None)[source]¶ Returns the index along axis axis where coord exists
Parameters: coord : array_like or float
the coordinate of the axis
axis : int
the axis direction of the index
-
interp(shape, method='linear', **kwargs)[source]¶ Returns an interpolated version of the grid
Parameters: shape : int, array_like
the new shape of the grid
method : str
the method used to perform the interpolation, see
scipy.interpolate.interpnfor further details.**kwargs :
optional arguments passed to the interpolation algorithm The interpolation routine is
scipy.interpolate.interpn
-
is_orthogonal()¶ Return true if all cell vectors are linearly independent
-
mean(axis)¶ Returns the average grid along direction axis
-
static
read(sile, *args, **kwargs)[source]¶ Reads grid from the
Sileusing read_gridParameters: sile : Sile, str
a
Sileobject which will be used to read the grid if it is a string it will create a new sile usingget_sile.* : args passed directly to
read_grid(,**)
-
remove(idx, axis)[source]¶ Removes certain indices from a specified axis.
Works exactly opposite to
sub.Parameters: idx : array_like
the indices of the grid axis axis to be removed
axis : int
the axis segment from which we remove all indices idx
-
remove_part(idx, axis, above)[source]¶ Removes parts of the grid via above/below designations.
Works exactly opposite to
sub_partParameters: idx : array_like
the indices of the grid axis axis to be removed for
above=Truegrid[:idx,...] forabove=Falsegrid[idx:,...]axis : int
the axis segment from which we retain the indices idx
above: bool
- if
Truewill retain the grid: grid[:idx,...]- else it will retain the grid:
grid[idx:,...]
- if
-
set_bc(boundary=None, a=None, b=None, c=None)[source]¶ Set the boundary conditions on the grid
Parameters: boundary: (3, ) or int, optional
boundary condition for all boundaries (or the same for all)
a: int, optional
boundary condition for the first unit-cell vector direction
b: int, optional
boundary condition for the second unit-cell vector direction
c: int, optional
boundary condition for the third unit-cell vector direction
-
set_boundary(boundary=None, a=None, b=None, c=None)¶ Set the boundary conditions on the grid
Parameters: boundary: (3, ) or int, optional
boundary condition for all boundaries (or the same for all)
a: int, optional
boundary condition for the first unit-cell vector direction
b: int, optional
boundary condition for the second unit-cell vector direction
c: int, optional
boundary condition for the third unit-cell vector direction
-
set_boundary_condition(boundary=None, a=None, b=None, c=None)¶ Set the boundary conditions on the grid
Parameters: boundary: (3, ) or int, optional
boundary condition for all boundaries (or the same for all)
a: int, optional
boundary condition for the first unit-cell vector direction
b: int, optional
boundary condition for the second unit-cell vector direction
c: int, optional
boundary condition for the third unit-cell vector direction
-
set_geom(geom)¶ Sets the
Geometryfor the grid.Setting the
Geometryfor the grid is a possibility to attach atoms to the grid.It is not a necessary entity.
-
set_geometry(geom)[source]¶ Sets the
Geometryfor the grid.Setting the
Geometryfor the grid is a possibility to attach atoms to the grid.It is not a necessary entity.
-
set_nsc(*args, **kwargs)¶ Set the number of super-cells in the
SuperCellobjectSee
set_nscfor allowed parameters.See also
SuperCell.set_nsc- the underlying called method
-
set_sc(sc)¶ Overwrites the local supercell
-
set_supercell(sc)¶ Overwrites the local supercell
-
shape¶ Returns the shape of the grid
-
size¶ Returns size of the grid
-
sub(idx, axis)[source]¶ Retains certain indices from a specified axis.
Works exactly opposite to
remove.Parameters: idx : array_like
the indices of the grid axis axis to be retained
axis : int
the axis segment from which we retain the indices idx
-
sub_part(idx, axis, above)[source]¶ Retains parts of the grid via above/below designations.
Works exactly opposite to
remove_partParameters: idx : array_like
the indices of the grid axis axis to be retained for
above=Truegrid[idx:,...] forabove=Falsegrid[:idx,...]axis : int
the axis segment from which we retain the indices idx
above: bool
- if
Truewill retain the grid: grid[idx:,...]- else it will retain the grid:
grid[:idx,...]
- if
-