Geometry¶
-
class
sisl.Geometry(xyz, atom=None, sc=None)[source]¶ Holds atomic information, coordinates, species, lattice vectors
The
Geometryclass holds information regarding atomic coordinates, the atomic species, the corresponding lattice-vectors.It enables the interaction and conversion of atomic structures via simple routine methods.
All lengths are assumed to be in units of Angstrom, however, as long as units are kept same the exact units are irrespective.
>>> square = Geometry([[0.5, 0.5, 0.5]], Atom(1), ... sc=SuperCell([1, 1, 10], nsc=[3, 3, 1])) >>> print(square) Geometry{na: 1, no: 1, Atoms{species: 1, Atom{H, Z: 1, orbs: 1, mass(au): 1.00794, maxR: -1.00000}: 1, }, nsc: [3, 3, 1], maxR: -1.0 }
Parameters: xyz : array_like
atomic coordinates
xyz[i, :]is the atomic coordinate of the i’th atom.atom : array_like or Atoms
atomic species retrieved from the
PeriodicTablesc : SuperCell
the unit-cell describing the atoms in a periodic super-cell
Examples
An atomic lattice consisting of Hydrogen atoms. An atomic square lattice of Hydrogen atoms
>>> xyz = [[0, 0, 0], ... [1, 1, 1]] >>> sc = SuperCell([2,2,2]) >>> g = Geometry(xyz, Atom('H'), sc)
The following estimates the lattice vectors from the atomic coordinates, although possible, it is not recommended to be used.
>>> xyz = [[0, 0, 0], ... [1, 1, 1]] >>> g = Geometry(xyz, Atom('H'))
Attributes
naNumber of atoms in geometry atomAtoms for the geometry ( Atomsobject)maxR([all])Maximum orbital range of the atoms xyz (ndarray) atomic coordinates sc (SuperCell) the supercell describing the periodicity of the geometry no: int total number of orbitals in the geometry Attributes
atomAtoms for the geometry ( Atomsobject)atomsAtoms for the geometry ( Atomsobject)cellReturns the inherent SuperCellobjectscellfirstoThe first orbital on the corresponding atom fxyzReturns geometry coordinates in fractional coordinates isc_offReturns the inherent SuperCellobjectsisc_offlastoThe last orbital on the corresponding atom massReturns the mass of all atoms as an array n_sReturns the inherent SuperCellobjectsn_snaNumber of atoms in geometry na_sNumber of supercell atoms noNumber of orbitals no_sNumber of supercell orbitals nscReturns the inherent SuperCellobjectsnscorbitalsList of orbitals per atom rcellReturns the inherent SuperCellobjectsrcellsc_offReturns the inherent SuperCellobjectssc_offvolReturns the inherent SuperCellobjectsvolMethods
Rij(ia, ja)Vector between atom ia and ja, atoms can be in super-cell indices __init__(xyz[, atom, sc])a2isc(ia)Returns the super-cell index for a specific/list atom a2o(ia[, all])Returns an orbital index of the first orbital of said atom. a2sc(a)Returns the super-cell offset for a specific atom add(other)Adds atoms (as is) from the othergeometry.add_vacuum(vacuum, axis)Add vacuum along the axis lattice vector angle(atom[, dir, ref, rad])The angle between atom atomand the direction dir, with possibility of a reference coordinate refappend(other, axis)Appends structure along axis.asc2uc(atom[, uniq])Returns atom from super-cell indices to unit-cell indices, possibly removing dublicates attach(s_idx, other, o_idx[, dist, axis])Attaches another Geometryat the s_idx index with respect to o_idx using different methods.axyz([atom, isc])Return the atomic coordinates in the supercell of a given atom. bond_correct(ia, atom[, method])Corrects the bond between ia and the atom.center([atom, what])Returns the center of the geometry close(xyz_ia[, R, idx, idx_xyz, ret_xyz, ...])Indices of atoms in the entire supercell within a given radius from a given coordinate close_all(xyz_ia[, R, idx, idx_xyz, ...])Indices of atoms in the entire supercell within a given radius from a given coordinate close_sc(xyz_ia[, isc, R, idx, idx_xyz, ...])Indices of atoms in a given supercell within a given radius from a given coordinate copy()A copy of the object. cut(seps, axis[, seg, rtol, atol])Returns a subset of atoms from the geometry by cutting the geometry into sepsparts along the directionaxis.distance([atom, R, tol, method])Calculate the distances for all atoms in shells of radius tol within max_Requal(other[, R])Whether two geometries are the same (optional not check of the orbital radius) fromASE(aseg)Returns geometry from an ASE object. iR([na, iR, R])Return an integer number of maximum radii ( self.maxR()) which holds approximatelynaatomsinsert(atom, geom)Inserts other atoms right before index is_orthogonal()Return true if all cell vectors are linearly independent iter()An iterator over all atomic indices iter_block([iR, R, atom, method])Iterator for performance critical loops iter_block_rand([iR, R, atom])Perform the random block-iteration by randomly selecting the next center of block iter_block_shape([shape, iR, atom])Perform the grid block-iteration by looping a grid iter_orbitals([atom, local])Returns an iterator over all atoms and their associated orbitals iter_species([atom])Iterator over all atoms (or a subset) and species as a tuple in this geometry maxR([all])Maximum orbital range of the atoms mirror(plane[, atom])Mirrors the structure around the center of the atoms move(v[, atom, cell])Translates the geometry by vo2a(io[, uniq])Atomic index corresponding to the orbital indicies. o2isc(io)Returns the super-cell index for a specific orbital. o2sc(o)Returns the super-cell offset for a specific orbital. oRij(io, jo)Vector between orbital ioand jo, orbitals can be in super-cell indicesoptimize_nsc([axis, R])Optimize the number of supercell connections based on self.maxR()orij(io, jo)Distance between orbital ioand jo, orbitals can be in super-cell indicesosc2uc(orbs[, uniq])Returns orbitals from super-cell indices to unit-cell indices, possibly removing dublicates prepend(other, axis)Prepends structure along axis.read(sile, *args, **kwargs)Reads geometry from the Sileusing Sile.read_geometryreduce()Remove all atoms not currently used in the self.atomobjectremove(atom)Remove atoms from the geometry. reorder()Reorders atoms according to first occurence in the geometry repeat(reps, axis)Create a repeated geometry reverse([atom])Returns a reversed geometry rij(ia, ja)Distance between atom ia and ja, atoms can be in super-cell indices rotate(angle, v[, origo, atom, only, rad])Rotate geometry around vector and return a new geometry rotate_miller(m, v)Align Miller direction along vrotatea(angle[, origo, atom, only, rad])Rotate around first lattice vector rotateb(angle[, origo, atom, only, rad])Rotate around second lattice vector rotatec(angle[, origo, atom, only, rad])Rotate around third lattice vector sc2uc(atom[, uniq])Returns atom from super-cell indices to unit-cell indices, possibly removing dublicates sc_index(*args, **kwargs)Call local SuperCellobjectsc_indexfunctionscale(scale)Scale coordinates and unit-cell to get a new geometry with proper scaling 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 sparserij([dtype, na_iR, method])Return the sparse matrix with all distances in the matrix sub(atom[, cell])Create a new Geometrywith a subset of thisGeometryswap(a, b)Swap a set of atoms in the geometry and return a new one swapaxes(a, b[, swap])Swap the axis for the atomic coordinates and the cell vectors tile(reps, axis)Tile the geometry to create a bigger one toASE()Returns the geometry as an ASE Atomsobjecttranslate(v[, atom, cell])Translates the geometry by vwithin(shapes[, idx, idx_xyz, ret_xyz, ret_rij])Indices of atoms in the entire supercell within a given shape from a given coordinate within_sc(shapes[, isc, idx, idx_xyz, ...])Indices of atoms in a given supercell within a given shape from a given coordinate write(sile, *args, **kwargs)Writes geometry to the Sileusing sile.write_geometry-
Rij(ia, ja)[source]¶ Vector between atom ia and ja, atoms can be in super-cell indices
Returns the vector between two atoms:
\[R_{ij} = r_j - r_i\]Parameters: ia : int or array_like
atomic index of first atom
ja : int or array_like
atomic indices
-
a2isc(ia)[source]¶ Returns the super-cell index for a specific/list atom
Returns a vector of 3 numbers with integers.
-
a2o(ia, all=False)[source]¶ Returns an orbital index of the first orbital of said atom. This is particularly handy if you want to create TB models with more than one orbital per atom.
Note that this will preserve the super-cell offsets.
Parameters: ia : array_like
Atomic indices
all : bool, optional
False, return only the first orbital corresponding to the atom, True, returns list of the full atom
-
add(other)[source]¶ Adds atoms (as is) from the
othergeometry. This will not alter the cell vectors.Parameters: other : Geometry
Other geometry class which is added
-
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
-
angle(atom, dir=(1.0, 0, 0), ref=None, rad=False)[source]¶ The angle between atom
atomand the direction dir, with possibility of a reference coordinate refThe calculated angle can be written as this
\[\alpha = \arccos \frac{(\mathrm{atom} - \mathrm{ref})\cdot \mathrm{dir}} {|\mathrm{atom}-\mathrm{ref}||\mathrm{dir}|}\]and thus lies in the interval \([0 ; \pi]\) as one cannot distinguish orientation without additional vectors.
Parameters: atom : int or array_like
atomic index
dir : str, int or vector
the direction from which the angle is calculated from, default to
xref : int or coordinate, optional
the reference point from which the vectors are drawn, default to origo
rad : bool, optional
whether the returned value is in radians
-
append(other, axis)[source]¶ Appends structure along
axis. This will automatically add theself.cell[axis,:]to all atomic coordiates in theotherstructure before appending.The basic algorithm is this:
>>> oxa = other.xyz + self.cell[axis,:][None,:] >>> self.xyz = np.append(self.xyz,oxa) >>> self.cell[axis,:] += other.cell[axis,:]
NOTE: The cell appended is only in the axis that is appended, which means that the other cell directions need not conform.
Parameters: other : Geometry or SuperCell
Other geometry class which needs to be appended If a
SuperCellonly the super cell will be extendedaxis : int
Cell direction to which the
othergeometry should be appended.
-
asc2uc(atom, uniq=False)¶ Returns atom from super-cell indices to unit-cell indices, possibly removing dublicates
-
attach(s_idx, other, o_idx, dist='calc', axis=None)[source]¶ Attaches another
Geometryat the s_idx index with respect to o_idx using different methods.Parameters: dist :
array_like,float,str(‘calc’)the distance (in Ang) between the attached coordinates. If dist is arraylike it should be the vector between the atoms; if `dist is float the argument axis is required and the vector will be calculated along the corresponding latticevector; else if dist is str this will correspond to the method argument of the
Atom.radiusclass of the two atoms. Here axis is also required.axis :
intspecify the direction of the lattice vectors used. Not used if dist is an array-like argument.
-
axyz(atom=None, isc=None)[source]¶ Return the atomic coordinates in the supercell of a given atom.
The Geometry[...] slicing is calling this function with appropriate options.
Parameters: atom : int or array_like
atom(s) from which we should return the coordinates, the atomic indices may be in supercell format.
isc : array_like, optional
Returns the atomic coordinates shifted according to the integer parts of the cell. Defaults to the unit-cell
Examples
>>> geom = Geometry([[0, 0, 0], [0.5, 0, 0]], sc=1.) >>> print(geom.axyz(isc=[1,0,0])) [[ 1. 0. 0. ] [ 1.5 0. 0. ]]
>>> geom = Geometry([[0, 0, 0], [0.5, 0, 0]], sc=1.) >>> print(geom.axyz(0)) [ 0. 0. 0.]
-
bond_correct(ia, atom, method='calc')[source]¶ Corrects the bond between ia and the
atom.Corrects the bond-length between atom ia and
atomin such a way that the atomic radius is preserved. I.e. the sum of the bond-lengths minimizes the distance matrix.Only atom ia is moved.
Parameters: ia : int
The atom to be displaced according to the atomic radius
atom : array_like or int
The atom(s) from which the radius should be reduced.
method :
str,floatIf str will use that as lookup in
Atom.radius. Else it will be the new bond-length.
-
center(atom=None, what='xyz')[source]¶ Returns the center of the geometry
By specifying what one can control whether it should be:
xyz|position: Center of coordinates (default)mass: Center of masscell: Center of cell
Parameters: atom : array_like
list of atomic indices to find center of
what : {‘xyz’, ‘mass’, ‘cell’}
determine whether center should be of ‘cell’, mass-centered (‘mass’), or absolute center of the positions.
-
close(xyz_ia, R=None, idx=None, idx_xyz=None, ret_xyz=False, ret_rij=False)[source]¶ Indices of atoms in the entire supercell within a given radius from a given coordinate
This heavily relies on the
close_scmethod.Note that if a connection is made in a neighbouring super-cell then the atomic index is shifted by the super-cell index times number of atoms. This allows one to decipher super-cell atoms from unit-cell atoms.
Parameters: xyz_ia : coordinate/index
Either a point in space or an index of an atom. If an index is passed it is the equivalent of passing the atomic coordinate close_sc(self.xyz[xyz_ia,:]).
R : (None), float/tuple of float
The radii parameter to where the atomic connections are found. If
Ris an array it will return the indices: in the ranges:>>> ( x <= R[0] , R[0] < x <= R[1], R[1] < x <= R[2] )
If a single float it will return:
>>> x <= R
idx : array_like, optional
List of indices for atoms that are to be considered
idx_xyz : array_like, optional
The atomic coordinates of the equivalent
idxvariable (idxmust also be passed)ret_xyz : bool, optional
If true this method will return the coordinates for each of the couplings.
ret_rij : bool, optional
If true this method will return the distances from the
xyz_iafor each of the couplings.
-
close_all(xyz_ia, R=None, idx=None, idx_xyz=None, ret_xyz=False, ret_rij=False)¶ Indices of atoms in the entire supercell within a given radius from a given coordinate
This heavily relies on the
close_scmethod.Note that if a connection is made in a neighbouring super-cell then the atomic index is shifted by the super-cell index times number of atoms. This allows one to decipher super-cell atoms from unit-cell atoms.
Parameters: xyz_ia : coordinate/index
Either a point in space or an index of an atom. If an index is passed it is the equivalent of passing the atomic coordinate close_sc(self.xyz[xyz_ia,:]).
R : (None), float/tuple of float
The radii parameter to where the atomic connections are found. If
Ris an array it will return the indices: in the ranges:>>> ( x <= R[0] , R[0] < x <= R[1], R[1] < x <= R[2] )
If a single float it will return:
>>> x <= R
idx : array_like, optional
List of indices for atoms that are to be considered
idx_xyz : array_like, optional
The atomic coordinates of the equivalent
idxvariable (idxmust also be passed)ret_xyz : bool, optional
If true this method will return the coordinates for each of the couplings.
ret_rij : bool, optional
If true this method will return the distances from the
xyz_iafor each of the couplings.
-
close_sc(xyz_ia, isc=(0, 0, 0), R=None, idx=None, idx_xyz=None, ret_xyz=False, ret_rij=False)[source]¶ Indices of atoms in a given supercell within a given radius from a given coordinate
This returns a set of atomic indices which are within a sphere of radius R.
If R is a tuple/list/array it will return the indices: in the ranges:
>>> ( x <= R[0] , R[0] < x <= R[1], R[1] < x <= R[2] )
Parameters: xyz_ia : array_like of floats or int
Either a point in space or an index of an atom. If an index is passed it is the equivalent of passing the atomic coordinate
close_sc(self.xyz[xyz_ia,:]).isc : array_like, optional
The super-cell which the coordinates are checked in.
R : float or array_like, optional
The radii parameter to where the atomic connections are found. If R is an array it will return the indices: in the ranges
( x <= R[0] , R[0] < x <= R[1], R[1] < x <= R[2] ). If a single float it will returnx <= R.idx : array_like of int, optional
List of atoms that will be considered. This can be used to only take out a certain atoms.
idx_xyz : array_like of float, optional
The atomic coordinates of the equivalent idx variable (idx must also be passed)
ret_xyz : bool, optional
If True this method will return the coordinates for each of the couplings.
ret_rij : bool, optional
If True this method will return the distance for each of the couplings.
-
cut(seps, axis, seg=0, rtol=0.0001, atol=0.0001)[source]¶ Returns a subset of atoms from the geometry by cutting the geometry into
sepsparts along the directionaxis. It will then _only_ return the first cut.This will effectively change the unit-cell in the
axisas-well as removingself.na/sepsatoms. It requires thatself.na % seps == 0.REMARK: You need to ensure that all atoms within the first cut out region are within the primary unit-cell.
Doing
geom.cut(2, 1).tile(2, 1), could for symmetric setups, be equivalent to a no-op operation. AUserWarningwill be issued if this is not the case.Parameters: seps : int
number of times the structure will be cut.
axis : int
the axis that will be cut
seg : int, optional
returns the i’th segment of the cut structure Currently the atomic coordinates are not translated, this may change in the future.
rtol : (tolerance for checking tiling, see
numpy.allclose)atol : (tolerance for checking tiling, see
numpy.allclose)
-
distance(atom=None, R=None, tol=0.1, method='average')[source]¶ Calculate the distances for all atoms in shells of radius tol within
max_RParameters: atom : int or array_like, optional
only create list of distances from the given atoms, default to all atoms
R : float, optional
the maximum radius to consider, default to
self.maxR(). To retrieve all distances for atoms within the supercell structure you can passnumpy.inf.tol : float or array_like, optional
the tolerance for grouping a set of atoms. This parameter sets the shell radius for each shell. I.e. the returned distances between two shells will be maximally 2*tol, but only if atoms are within two consecutive lists. If this is a list, the shells will be of unequal size.
The first shell size will be tol * .5 or tol[0] * .5 if tol is a list.
method : {‘average’, ‘mode’, ‘<numpy.func>’, func}
How the distance in each shell is determined. A list of distances within each shell is gathered and the equivalent method will be used to extract a single quantity from the list of distances in the shell. If ‘mode’ is chosen it will use
scipy.stats.mode. If a string is given it will correspond togetattr(numpy, method), while any callable function may be passed. The passed function will only be passed a list of unsorted distances that needs to be processed.Returns: numpy.ndarray
an array of positive numbers yielding the distances from the atoms in reduced form
See also
sparserij- return a sparse matrix will all distances between atoms
Examples
>>> geom = Geometry([0]*3, Atom(1, R=1.), sc=SuperCell(1., nsc=[5, 5, 1])) >>> geom.distance() # use geom.maxR() array([ 1.]) >>> geom.distance(tol=[0.5, 0.4, 0.3, 0.2]) array([ 1.]) >>> geom.distance(R=2, tol=[0.5, 0.4, 0.3, 0.2]) array([ 1. , 1.41421356, 2. ]) >>> geom.distance(R=2, tol=[0.5, 0.7]) # the R = 1 and R = 2 ** .5 gets averaged array([ 1.20710678, 2. ])
-
equal(other, R=True)[source]¶ Whether two geometries are the same (optional not check of the orbital radius)
Parameters: other : Geometry
the other Geometry to check against
maxR : bool, optional
if True also check if the orbital radii are the same (see
Atom.equal)
-
firsto¶ The first orbital on the corresponding atom
-
classmethod
fromASE(aseg)[source]¶ Returns geometry from an ASE object.
Parameters: aseg : ASE
Atomsobject which contains the following routines:get_atomic_numbers,get_positions,get_cell. From those methods asislobject will be created.
-
fxyz¶ Returns geometry coordinates in fractional coordinates
-
iR(na=1000, iR=20, R=None)[source]¶ Return an integer number of maximum radii (
self.maxR()) which holds approximatelynaatomsParameters: na : int, optional
number of atoms within the radius
iR : int, optional
initial
iRvalue, which the sphere is estitametd fromR : float, optional
the value used for atomic range (defaults to
self.maxR())
-
insert(atom, geom)[source]¶ Inserts other atoms right before index
We insert the
geomGeometrybeforeatom. Note that this will not change the unit cell.Parameters: atom : int
the index at which atom the other geometry is inserted
geom : Geometry
the other geometry to be inserted
-
is_orthogonal()¶ Return true if all cell vectors are linearly independent
-
iter()[source]¶ An iterator over all atomic indices
This iterator is the same as:
>>> for ia in range(len(self)): ... <do something>
or equivalently
>>> for ia in self: ... <do something>
See also
iter_species- iterate across indices and atomic species
iter_orbitals- iterate across atomic indices and orbital indices
-
iter_block(iR=20, R=None, atom=None, method='rand')[source]¶ Iterator for performance critical loops
NOTE: This requires that R has been set correctly as the maximum interaction range.
I.e. the loop would look like this:
>>> for ias, idxs in self.iter_block(): ... for ia in ias: ... idx_a = self.close(ia, R = R, idx = idxs)
This iterator is intended for systems with more than 1000 atoms.
Remark that the iterator used is non-deterministic, i.e. any two iterators need not return the same atoms in any way.
Parameters: iR : int, optional
the number of R ranges taken into account when doing the iterator
R : float, optional
enables overwriting the local R quantity. Defaults to
self.maxR()atom : array_like, optional
enables only effectively looping a subset of the full geometry
method : {‘rand’, ‘sphere’, ‘cube’}
select the method by which the block iteration is performed. Possible values are:
rand: a spherical object is constructed with a random center according to the internal atoms sphere: a spherical equispaced shape is constructed and looped cube: a cube shape is constructed and looped
Returns: Two lists with
[0]being a list of atoms to be looped and[1]being the atoms thatneed searched.
-
iter_block_rand(iR=20, R=None, atom=None)[source]¶ Perform the random block-iteration by randomly selecting the next center of block
-
iter_block_shape(shape=None, iR=20, atom=None)[source]¶ Perform the grid block-iteration by looping a grid
-
iter_orbitals(atom=None, local=True)[source]¶ Returns an iterator over all atoms and their associated orbitals
>>> for ia, io in self.iter_orbitals():
with
iabeing the atomic index,iothe associated orbital index on atomia. Note thatiowill start from0.Parameters: atom : int or array_like, optional
only loop on the given atoms, default to all atoms
local : bool, optional
whether the orbital index is the global index, or the local index relative to the atom it resides on.
See also
iter- iterate over atomic indices
iter_species- iterate across indices and atomic species
-
iter_species(atom=None)[source]¶ Iterator over all atoms (or a subset) and species as a tuple in this geometry
>>> for ia, a, idx_specie in self.iter_species(): ... isinstance(ia, int) == True ... isinstance(a, Atom) == True ... isinstance(idx_specie, int) == True
with
iabeing the atomic index,atheAtomobject, idx_specie is the index of the specieParameters: atom : int or array_like, optional
only loop on the given atoms, default to all atoms
See also
iter- iterate over atomic indices
iter_orbitals- iterate across atomic indices and orbital indices
-
lasto¶ The last orbital on the corresponding atom
-
mass¶ Returns the mass of all atoms as an array
-
move(v, atom=None, cell=False)[source]¶ Translates the geometry by
vOne can translate a subset of the atoms by supplying
atom.Returns a copy of the structure translated by
v.Parameters: v : array_like
the vector to displace all atomic coordinates
atom : int or array_like, optional
only displace the given atomic indices, if not specified, all atoms will be displaced
cell : bool, optional
If True the supercell also gets enlarged by the vector
-
na¶ Number of atoms in geometry
-
na_s¶ Number of supercell atoms
-
no¶ Number of orbitals
-
no_s¶ Number of supercell orbitals
-
o2a(io, uniq=False)[source]¶ Atomic index corresponding to the orbital indicies.
This is a particurlaly slow algorithm due to for-loops.
Note that this will preserve the super-cell offsets.
Parameters: io: array_like
List of indices to return the atoms for
uniq : bool, optional
If True only return the unique atoms.
-
o2isc(io)[source]¶ Returns the super-cell index for a specific orbital.
Returns a vector of 3 numbers with integers.
-
oRij(io, jo)[source]¶ Vector between orbital
ioand jo, orbitals can be in super-cell indicesReturns the vector between two orbitals:
\[R_{ij} = r_j - r_i\]Parameters: io : int or array_like
orbital index of first orbital
jo : int or array_like
orbital indices
-
optimize_nsc(axis=None, R=None)[source]¶ Optimize the number of supercell connections based on
self.maxR()After this routine the number of supercells may not necessarily be the same.
This is an in-place operation.
Parameters: axis : int or array_like, optional
only optimize the specified axis (default to all)
R : float, optional
the maximum connection radius for each atom
-
orbitals¶ List of orbitals per atom
-
orij(io, jo)[source]¶ Distance between orbital
ioand jo, orbitals can be in super-cell indicesReturns the distance between two orbitals:
\[r_{ij} = |r_j - r_i|\]Parameters: io : int or array_like
orbital index of first orbital
jo : int or array_like
orbital indices
-
osc2uc(orbs, uniq=False)[source]¶ Returns orbitals from super-cell indices to unit-cell indices, possibly removing dublicates
-
prepend(other, axis)[source]¶ Prepends structure along
axis. This will automatically add theself.cell[axis,:]to all atomic coordiates in theotherstructure before prepending.The basic algorithm is this:
>>> oxa = other.xyz >>> self.xyz = np.append(oxa, self.xyz + other.cell[axis,:][None,:]) >>> self.cell[axis,:] += other.cell[axis,:]
NOTE: The cell prepended is only in the axis that is prependend, which means that the other cell directions need not conform.
Parameters: other : Geometry or SuperCell
Other geometry class which needs to be prepended If a
SuperCellonly the super cell will be extendedaxis : int
Cell direction to which the
othergeometry should be prepended
-
static
read(sile, *args, **kwargs)[source]¶ Reads geometry from the
Sileusing Sile.read_geometryParameters: sile :
Sile, stra
Sileobject which will be used to read the geometry if it is a string it will create a new sile usingget_sile.
-
reduce()[source]¶ Remove all atoms not currently used in the
self.atomobjectNotes
This is an in-place operation.
-
remove(atom)[source]¶ Remove atoms from the geometry.
Indices passed MUST be unique.
Negative indices are wrapped and thus works.
Parameters: atom : array_like
indices of all atoms to be removed.
See also
sub- the negative of this routine, i.e. retain a subset of atoms
-
reorder()[source]¶ Reorders atoms according to first occurence in the geometry
Notes
This is an in-place operation.
-
repeat(reps, axis)[source]¶ Create a repeated geometry
The atomic indices are NOT retained for the base structure.
The expansion of the atoms are basically performed using this algorithm:
>>> ja = 0 >>> for ia in range(self.na): ... for id,r in args: ... for i in range(r): ... ja = ia + cell[id,:] * i
This method allows to utilise Bloch’s theorem when creating Hamiltonian parameter sets for TBtrans.
For geometries with a single atom this routine returns the same as
tile.It is adviced to only use this for electrode Bloch’s theorem purposes as
tileis faster.Parameters: reps : int
number of repetitions
axis : int
direction of repetition, 0, 1, 2 according to the cell-direction
See also
tile- equivalent but different ordering of final structure
Examples
>>> geom = Geometry([[0, 0, 0], [0.5, 0, 0]], sc=1) >>> g = geom.repeat(2,axis=0) >>> print(g.xyz) [[ 0. 0. 0. ] [ 1. 0. 0. ] [ 0.5 0. 0. ] [ 1.5 0. 0. ]] >>> g = geom.repeat(2,0).repeat(2,1) >>> print(g.xyz) [[ 0. 0. 0. ] [ 0. 1. 0. ] [ 1. 0. 0. ] [ 1. 1. 0. ] [ 0.5 0. 0. ] [ 0.5 1. 0. ] [ 1.5 0. 0. ] [ 1.5 1. 0. ]]
-
reverse(atom=None)[source]¶ Returns a reversed geometry
Also enables reversing a subset of the atoms.
Parameters: atom : int or array_like, optional
only reverse the given atomic indices, if not specified, all atoms will be reversed
-
rij(ia, ja)[source]¶ Distance between atom ia and ja, atoms can be in super-cell indices
Returns the distance between two atoms:
\[r_{ij} = |r_j - r_i|\]Parameters: ia : int or array_like
atomic index of first atom
ja : int or array_like
atomic indices
-
rotate(angle, v, origo=None, atom=None, only='abc+xyz', rad=False)[source]¶ Rotate geometry around vector and return a new geometry
Per default will the entire geometry be rotated, such that everything is aligned as before rotation.
However, by supplying
only = 'abc|xyz'one can designate which part of the geometry that will be rotated.Parameters: angle : float
the angle in radians of which the geometry should be rotated
v : array_like
the normal vector to the rotated plane, i.e. v = [1,0,0] will rotate the
yzplaneorigo : int or array_like, optional
the origin of rotation. Anything but [0, 0, 0] is equivalent to a self.move(-origo).rotate(...).move(origo). If this is an int it corresponds to the atomic index.
atom : int or array_like, optional
only rotate the given atomic indices, if not specified, all atoms will be rotated.
only : {‘abc+xyz’, ‘xyz’, ‘abc’}
which coordinate subject should be rotated, if
abcis in this string the cell will be rotated ifxyzis in this string the coordinates will be rotatedrad : bool, optional
if
Truethe angle is provided in radians (rather than degrees)See also
Quaternion- class to rotate
rotatea- generic function for rotating around first lattice vector
rotateb- generic function for rotating around second lattice vector
rotatec- generic function for rotating around third lattice vector
-
rotate_miller(m, v)[source]¶ Align Miller direction along
vRotate geometry and cell such that the Miller direction points along the Cartesian vector
v.
-
rotatea(angle, origo=None, atom=None, only='abc+xyz', rad=False)[source]¶ Rotate around first lattice vector
-
rotateb(angle, origo=None, atom=None, only='abc+xyz', rad=False)[source]¶ Rotate around second lattice vector
-
rotatec(angle, origo=None, atom=None, only='abc+xyz', rad=False)[source]¶ Rotate around third lattice vector
-
sc2uc(atom, uniq=False)[source]¶ Returns atom from super-cell indices to unit-cell indices, possibly removing dublicates
-
scale(scale)[source]¶ Scale coordinates and unit-cell to get a new geometry with proper scaling
Parameters: scale : float
the scale factor for the new geometry (lattice vectors, coordinates and the atomic radii are scaled).
-
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
-
sparserij(dtype=<type 'numpy.float64'>, na_iR=1000, method='rand')[source]¶ Return the sparse matrix with all distances in the matrix
The sparse matrix will only be defined for the elements which have orbitals overlapping with other atoms.
Parameters: dtype : numpy.dtype, numpy.float64
the data-type of the sparse matrix
na_iR : int, 1000
number of atoms within the sphere for speeding up the
iter_blockloop.method : str, ‘rand’
see
iter_blockfor detailsReturns: SparseAtom
sparse matrix with all rij elements
See also
iter_block- the method for looping the atoms
distance- create a list of distances
-
sub(atom, cell=None)[source]¶ Create a new
Geometrywith a subset of thisGeometryIndices passed MUST be unique.
Negative indices are wrapped and thus works.
Parameters: atom : array_like
indices of all atoms to be removed.
cell : array_like or SuperCell, optional
the new associated cell of the geometry (defaults to the same cell)
See also
SuperCell.fit- update the supercell according to a reference supercell
remove- the negative of this routine, i.e. remove a subset of atoms
-
swap(a, b)[source]¶ Swap a set of atoms in the geometry and return a new one
This can be used to reorder elements of a geometry.
Parameters: a : array_like
the first list of atomic coordinates
b : array_like
the second list of atomic coordinates
-
swapaxes(a, b, swap='cell+xyz')[source]¶ Swap the axis for the atomic coordinates and the cell vectors
If
swapaxes(0,1)it returns the 0 and 1 values swapped in thecellvariable.Parameters: a : int
axes 1, swaps with
bb : int
axes 2, swaps with
aswap : {‘cell+xyz’, ‘cell’, ‘xyz’}
-
tile(reps, axis)[source]¶ Tile the geometry to create a bigger one
The atomic indices are retained for the base structure.
Parameters: reps : int
number of tiles (repetitions)
axis : int
direction of tiling, 0, 1, 2 according to the cell-direction
See also
repeat- equivalent but different ordering of final structure
Examples
>>> geom = Geometry([[0, 0, 0], [0.5, 0, 0]], sc=1.) >>> g = geom.tile(2,axis=0) >>> print(g.xyz) [[ 0. 0. 0. ] [ 0.5 0. 0. ] [ 1. 0. 0. ] [ 1.5 0. 0. ]] >>> g = geom.tile(2,0).tile(2,axis=1) >>> print(g.xyz) [[ 0. 0. 0. ] [ 0.5 0. 0. ] [ 1. 0. 0. ] [ 1.5 0. 0. ] [ 0. 1. 0. ] [ 0.5 1. 0. ] [ 1. 1. 0. ] [ 1.5 1. 0. ]]
-
translate(v, atom=None, cell=False)¶ Translates the geometry by
vOne can translate a subset of the atoms by supplying
atom.Returns a copy of the structure translated by
v.Parameters: v : array_like
the vector to displace all atomic coordinates
atom : int or array_like, optional
only displace the given atomic indices, if not specified, all atoms will be displaced
cell : bool, optional
If True the supercell also gets enlarged by the vector
-
within(shapes, idx=None, idx_xyz=None, ret_xyz=False, ret_rij=False)[source]¶ Indices of atoms in the entire supercell within a given shape from a given coordinate
This heavily relies on the
within_scmethod.Note that if a connection is made in a neighbouring super-cell then the atomic index is shifted by the super-cell index times number of atoms. This allows one to decipher super-cell atoms from unit-cell atoms.
Parameters: shapes : Shape, list of Shape
idx : array_like, optional
List of indices for atoms that are to be considered
idx_xyz : array_like, optional
The atomic coordinates of the equivalent
idxvariable (idxmust also be passed)ret_xyz : bool, optional
If true this method will return the coordinates for each of the couplings.
ret_rij : bool, optional
If true this method will return the distances from the
xyz_iafor each of the couplings.
-
within_sc(shapes, isc=None, idx=None, idx_xyz=None, ret_xyz=False, ret_rij=False)[source]¶ Indices of atoms in a given supercell within a given shape from a given coordinate
This returns a set of atomic indices which are within a sphere of radius
R.If R is a tuple/list/array it will return the indices: in the ranges:
>>> ( x <= R[0] , R[0] < x <= R[1], R[1] < x <= R[2] )
Parameters: shapes : Shape or list of Shape
A list of increasing shapes that define the extend of the geometric volume that is searched. It is vital that:
shapes[0] in shapes[1] in shapes[2] ...
isc : array_like, optional
The super-cell which the coordinates are checked in. Defaults to [0, 0, 0]
idx : array_like, optional
List of atoms that will be considered. This can be used to only take out a certain atoms.
idx_xyz : array_like, optional
The atomic coordinates of the equivalent
idxvariable (idxmust also be passed)ret_xyz : bool, optional
If True this method will return the coordinates for each of the couplings.
ret_rij : bool, optional
If True this method will return the distance for each of the couplings.
-
write(sile, *args, **kwargs)[source]¶ Writes geometry to the
Sileusing sile.write_geometryParameters: sile :
Sile,stra
Sileobject which will be used to write the geometry if it is a string it will create a new sile usingget_sile*args, **kwargs:
Any other args will be passed directly to the underlying routine
-