sisl.grid module¶
Define a grid
This grid is the basis of different used models.
-
class
sisl.grid.
Grid
(shape=None, bc=None, sc=None, dtype=None, geom=None)[source]¶ Bases:
sisl.supercell.SuperCellChild
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
cell
Returns the inherent SuperCell
objectscell
dcell
Returns the delta-cell dtype
Returns the data-type of the grid dvol
Returns the delta-volume n_s
Returns the inherent SuperCell
objectsn_s
nsc
Returns the inherent SuperCell
objectsnsc
rcell
Returns the inherent SuperCell
objectsrcell
sc_off
Returns the inherent SuperCell
objectssc_off
shape
Returns the shape of the grid size
Returns size of the grid vol
Returns the inherent SuperCell
objectsvol
Methods
ArgumentParser
([parser])Create and return a group of argument parsers which manipulates it self Grid
.append
(other, axis)Appends other Grid
to 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
wherecoord
existsinterp
(shape, *args, **kwargs)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 Sile
usingread_grid
remove
(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 SuperCell
objectsc_index
functionset_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 Geometry
for the grid.set_grid
(shape[, dtype])Create the internal grid of certain size. set_nsc
(nsc)Set the number of super-cells in the SuperCell
objectset_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)Writes grid to the Sile
usingwrite_grid
Initialize a
Grid
object.Initialize a
Grid
object.Parameters: shape :
list of ints
the size of each grid dimension
bc :
int
the boundary condition (
Grid.Periodic/Grid.Neumann/Grid.Dirichlet
)sc :
SuperCell/list
the associated supercell (
Attributes
cell
Returns the inherent SuperCell
objectscell
dcell
Returns the delta-cell dtype
Returns the data-type of the grid dvol
Returns the delta-volume n_s
Returns the inherent SuperCell
objectsn_s
nsc
Returns the inherent SuperCell
objectsnsc
rcell
Returns the inherent SuperCell
objectsrcell
sc_off
Returns the inherent SuperCell
objectssc_off
shape
Returns the shape of the grid size
Returns size of the grid vol
Returns the inherent SuperCell
objectsvol
Methods
ArgumentParser
([parser])Create and return a group of argument parsers which manipulates it self Grid
.append
(other, axis)Appends other Grid
to 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
wherecoord
existsinterp
(shape, *args, **kwargs)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 Sile
usingread_grid
remove
(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 SuperCell
objectsc_index
functionset_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 Geometry
for the grid.set_grid
(shape[, dtype])Create the internal grid of certain size. set_nsc
(nsc)Set the number of super-cells in the SuperCell
objectset_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)Writes grid to the Sile
usingwrite_grid
-
ArgumentParser
(parser=None, *args, **kwargs)[source]¶ Create and return a group of argument parsers which manipulates it self
Grid
.Parameters: parser: ArgumentParser, None
in case the arguments should be added to a specific parser. It defaults to create a new.
limit_arguments: bool, True
If
False
additional options will be created which are similar to other options. For instance--repeat-x
which is equivalent to--repeat x
.short: bool, False
Create short options for a selected range of options
positional_out: bool, False
If
True
, adds a positional argument which acts as –out. This may be handy if only the geometry is in the argument list.
-
Dirichlet
= 3¶
-
Neumann
= 2¶
-
Periodic
= 1¶
-
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
¶ Returns the delta-volume
-
index
(coord, axis=None)[source]¶ Returns the index along axis
axis
wherecoord
existsParameters: coord : array_like / float
the coordinate of the axis
axis : int
the axis direction of the index
-
interp
(shape, *args, **kwargs)[source]¶ Returns an interpolated version of the grid
Parameters: shape : int, array_like
the new shape of the grid
*args, **kwargs :
optional arguments passed to the interpolation algorithm The interpolation routine is
scipy.interpolate.interpn
-
mean
(axis)¶ Returns the average grid along direction
axis
-
static
read
(sile, *args, **kwargs)[source]¶ Reads grid from the
Sile
usingread_grid
Parameters: sile : Sile, str
* : 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 removedaxis : 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_part
Parameters: idx : array_like
the indices of the grid axis
axis
to be removed forabove=True
grid[:idx,...] forabove=False
grid[idx:,...]axis : int
the axis segment from which we retain the indices
idx
above: bool
- if
True
will 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 boundary: [3], integer, optional
boundary condition for all boundaries (or the same for all)- a: integer, optional
- boundary condition for the first unit-cell vector direction
- b: integer, optional
- boundary condition for the second unit-cell vector direction
- c: integer, 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 boundary: [3], integer, optional
boundary condition for all boundaries (or the same for all)- a: integer, optional
- boundary condition for the first unit-cell vector direction
- b: integer, optional
- boundary condition for the second unit-cell vector direction
- c: integer, 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 boundary: [3], integer, optional
boundary condition for all boundaries (or the same for all)- a: integer, optional
- boundary condition for the first unit-cell vector direction
- b: integer, optional
- boundary condition for the second unit-cell vector direction
- c: integer, optional
- boundary condition for the third unit-cell vector direction
-
set_geom
(geom)[source]¶ Sets the
Geometry
for the grid.Setting the
Geometry
for the grid is a possibility to attach atoms to the grid.It is not a necessary entity.
-
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 retainedaxis : 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_part
Parameters: idx : array_like
the indices of the grid axis
axis
to be retained forabove=True
grid[idx:,...] forabove=False
grid[:idx,...]axis : int
the axis segment from which we retain the indices
idx
above: bool
- if
True
will retain the grid: grid[idx:,...]
- else it will retain the grid:
grid[:idx,...]
- if
-
swapaxes
(a, b)[source]¶ Returns Grid with swapped axis
If
swapaxes(0,1)
it returns the 0 in the 1 values.
-
write
(sile)[source]¶ Writes grid to the
Sile
usingwrite_grid
Parameters: sile : Sile, str
-
-
sisl.grid.
sgrid
(grid=None, argv=None, ret_grid=False)[source]¶ Main script for sgrid script.
This routine may be called with
argv
and/or aSile
which is the grid at hand.Parameters: this may either be the grid, as-is, or a
Sile
which contains the grid.argv :
list of str
the arguments passed to sgeom
ret_grid :
bool
(False
)whether the function should return the grid