Searching for suitable projections

Note: work on this functionality is in progress

class wannierberri.symmetry.projections_searcher.EBRsearcher(symmetrizer, froz_min=inf, froz_max=-inf, outer_min=-inf, outer_max=inf, degen_thresh=1e-08, trial_projections_set=[], debug=False)[source]

A class to search for EBRs that cover the frozen window, but fit into the outer window

Parameters:
  • symmetrizer (~wannierberri.symmetry.symmetrizer_sawf.SymmetrizerSAWF) – The file of symmetry properties (only the band part is used, the wann part may be anything or empty)

  • froz_min (float) – The minimum and maximum energy of the frozen window

  • froz_max (float) – The minimum and maximum energy of the frozen window

  • outer_min (float) – The minimum and maximum energy of the outer window

  • outer_max (float) – The minimum and maximum energy of the outer window

  • degen_thresh (float) – The threshold to consider bands as degenerate

  • trial_projections_set (ProjectionsSet) – The set of trial projections

  • debug (bool) – If True, print debug information

eig

The eigenvalues of the bands at irreducible k-points

Type:

np.ndarray(shape=(NKirr,NB), dtype=float)

nsym_little

The number of little group symmetries for each irreducible k-point

Type:

list of int (length=NKirr)

Notes

  • So far it does not work with time-reversal symmetry, and was not tested with spinor wavefuncitons. It is recommended to search for projections on a scalar calculation (no spin). The projections found this way are usually good for spinful calculations as well.

find_combinations(num_wann_min=0, num_wann_max=None, fixed=[])[source]

find all possible combinations of trial projections that cover all the irreps inside the frozen window and fit into the outer window

Parameters:
  • num_wann_min (int) – The minimum and maximum maximum number of wannier functions

  • num_wann_max (int) – The minimum and maximum maximum number of wannier functions

  • fixed (list of int) – The indices of the trial projections that are fixed and should be taken exactly once

Returns:

combinations – The K combinations of coefficients that denote multip[licity of each irrep

Return type:

np.ndarray(shape=(K,M), dtype=int)

Projections and Wyckoff positions

class wannierberri.symmetry.projections.Projection(position_sym=None, position_num=None, spacegroup=None, wyckoff_position=None, orbital='s', void=False, free_var_values=None, spinor=None, rotate_basis=False, zaxis=None, xaxis=None, do_not_split_projections=False)[source]

Bases: object

A class to store initial projections.

Parameters:
  • position_num (np.array(shape=(n,3,), dtype=float) or str) – The position of the projection if fractional coordinates.

  • position_str (str) – comma-separated positions with x,y,z being the free variables, e.g. “x,y,z”, “x,x-y,1/2”, etc.

  • orbital (str) – The orbital of the projection. e.g. “s”, “p”, “sp3 etc. or several separated by a semicolon (e.g. “s;p”)

  • spacegroup (irrep.spacegroup.SpaceGroup) – The spacegroup of the structure. All points equivalent to the given ones are also added (not needed if wyckoff_position is provided)

  • void (bool) – if true, create an empty object, to be filled later

  • wyckoff_position (WyckoffPosition or WyckoffPositionNumeric) – The wyckoff position of the projection. If provided, the position_num and position_str nd spacegroup are ignored

  • free_var_values (np.array(shape=(n,), dtype=float)) – The values of the free variables in the position_str

  • spinor (bool) – If True, the projection is a spinor (overrides the spacegroup.spinor)

  • rotate_basis (bool) – If True, the basis for the projection is rotated for each site according to the spacegroup (experimental) If False, the basis is the same for all sites (old behaviour)

  • zaxis (np.array(shape=(3,), dtype=float)) – The z-axis of the basis, if rotate_basis is True

  • xaxis (np.array(shape=(3,), dtype=float)) – The x-axis of the basis, if rotate_basis is True

Notes

  • if both xaxis and zaxis are provided, they should be orthogonal

  • if only one of xaxis and zaxis is provided, the other is calculated as the perpendicular vector, coplanar with the provided one and the default one

  • if neither xaxis nor zaxis are provided, the default basis is used

  • the yaxis is calculated as the cross product of zaxis and xaxis

  • the spinor basis is NOT rotated, i.e. all wannier functions are in the sigma-z basis

orbitals

The orbitals of the projection

Type:

list(str)

wyckoff_position

The wyckoff position of the projection

Type:

WyckoffPosition or WyckoffPositionNumeric

spinor

If True, the projection is a spinor

Type:

bool

basis_list

The basis for each site (row-vectors)

Type:

list(np.array(shape=(3,3), dtype=float))

positions

The positions of the projections

Type:

np.array(shape=(n,3), dtype=float)

num_wann_per_site

The number of Wannier functions per site

Type:

int

num_points

The number of points

Type:

int

num_wann

The total number of Wannier functions

Type:

int

orbitals_str

The orbitals of the projection as one string separated by semicolons ;

Type:

str

copy()[source]
get_positions_and_orbitals()[source]
Returns:

  • list(np.ndarray(shape=(3,), dtype=float)) – The positions of the projections

  • list(str) – The orbitals of the projections (each orbital , e.g. pz, sp3-2, dx2-y2, etc.)

property num_points
property num_wann
property num_wann_per_site

number of wannier functions per site (without spin)

property num_wann_per_site_spinor

number of wannier functions per site (with spin)

property orbitals_str
property positions
split()[source]

assuming that Projections may contain several orbitals, this function splits them into separate projections if there is only one - a list with one element is returned

property str_short
write_wannier90(mod1=False)[source]
class wannierberri.symmetry.projections.ProjectionsSet(projections=[])[source]

Bases: object

class to store the set of projections and corresponding windows

add(projection)[source]
as_numeric()[source]
clear_cached_properties(attributes=None)[source]

Clear the cached properties

Parameters:

attributes: list(str)

The list of attributes to clear. If None, all cached properties are cleared

copy()[source]
property free_var_values
get_combination(multiplicities, dcopy=True)[source]

get the combination of projections

Parameters:

multiplicities (np.ndarray(shape=(num_projections), dtype=int)) – The multiplicity of each projection

Returns:

The projections set with the given multiplicities

Return type:

ProjectionsSet

get_distances()[source]
get_min_distance()[source]
get_positions()[source]
get_positions_from_free_vars(free_vars)[source]
join_same_wyckoff(unmergable=[], use_unmergable_defaults=True)[source]

merge different projections on the same wyckoff positions

property map_free_vars

get the mapping from free variables to positions of the points

Returns:

  • np.ndarray(shape=(num_points, 3, num_free_vars_wyckoff), dtype=float) – The rotation matrices of the symmetry operations

  • np.ndarray(shape=(num_points, 3), dtype=float) – The translation vectors of the symmetry operations

maximize_distance(r0=1)[source]
property num_free_vars
property num_free_vars_wyckoff
property num_points
property num_proj
property num_wann
property num_wann_per_site_list

Returns:

np.array(int, shape=(num_points))

for each point - a value od how many wannier functioons there are on this point

property pos_end
property pos_start
set_spinor(spinor: bool)[source]
split_orbitals()[source]
stick_to_atoms(atoms=[])[source]

NOT SURE IF THIS IS NEEDED NEITHER IF IT WORKS PROPERLY

Reduces the number of free variables by sticking together the ones that correspond to the same wyckoff position but different projections

resets the free_vars and clears the cached properties and sets map_free_vars to the new map

Parameters:

atoms (np.ndarray(shape=(num_atoms,3), dtype=float)) – List of atomic positions

property vars_end
property vars_start
write_wannier90(mod1=False, beginend=True, numwann=True)[source]

return a string of wannier90 input file for projections

Parameters:

mod1 (bool) – If True, the positions are printed modulo 1

Returns:

The string for the wannier90 input file

Return type:

str

write_with_multiplicities(multiplicities=None, orbit=False)[source]

return a string describing which projections are taken and how many times(if not zero)

Parameters:
  • multiplicity (np.ndarray(shape=(num_projections), dtype=int)) – The multiplicity of each projection

  • orbit (bool) – If True, the orbit of the wyckoff position is also printed

class wannierberri.symmetry.projections.RepulsivePotential(rotation, translation, weights=None, same_site=None, r0=1, real_lattice=array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]]), max_G_r0=5)[source]

Bases: object

A class to store the repulsive potential between the projections

Parameters:
  • rotation (np.ndarray(shape=(num_points, 3, nfree_vars), dtype=float)) – The rotation matrices to get the symmetry operations

  • translation (np.ndarray(shape=(num_points, 3), dtype=float)) – The translation vectors of the symmetry operations

  • weights (np.ndarray(shape=(num_points, dtype=float)) – The weights of the symmetry operations

  • same_site (np.ndarray(shape=(num_points, num_points), dtype=bool))

potential_jax(free_vars)[source]
wannierberri.symmetry.projections.check_orbit(spacegroup, positions, tol=1e-05)[source]

check if the positions are in the same orbit of the spacegroup

Parameters:
  • spacegroup (irrep.spacegroup.SpaceGroup) – The spacegroup of the structure.

  • positions (np.ndarray(shape=(N,3), dtype=float)) – Points which are checked to transform into each other under the symmetry operations.

Returns:

True if the points are in the same orbit, False otherwise.

Return type:

bool

wannierberri.symmetry.projections.find_distance_periodic(positions, real_lattice, max_shift=2)[source]

find the distances between the pairs of atoms in a list of positions the distance to the closest image in the periodic lattice is returned

Parameters:
  • positions (np.ndarray( (num_atoms,3), dtype=float)) – The list of atomic positions in reduced coordinates.

  • real_lattice (np.ndarray((3,3), dtype=float)) – The lattice vectors.

Returns:

The distance between the pairs atoms.

Return type:

np.ndarray( (num_atoms,num_atoms), dtype=float)

wannierberri.symmetry.projections.get_orbit(spacegroup, p, tol=1e-05)[source]

Get the orbit of a point p under the symmetry operations of a structure.

Parameters:
  • spacegroup (irrep.spacegroup.SpaceGroup) – The spacegroup of the structure.

  • p (np.ndarray(shape=(3,), dtype=float)) – Point for which to calculate the orbit in the reduced coordinates.

Returns:

The orbit of v under the symmetry operations of the structure.

Return type:

UniqueListMod1 of np.ndarray(shape=(3,), dtype=float)

wannierberri.symmetry.projections.get_perpendicular_coplanar_vector(a, b)[source]

return a vector c perpendicular to a and coplanar with both a and b and such that (b.c)>0

Parameters:
  • a (np.ndarray(3,)) – The first vector

  • b (np.ndarray(3,)) – The second vector

Returns:

The perpendicular vector(normalized)

Return type:

np.ndarray(3,)

wannierberri.symmetry.projections.orbit_and_rottrans(spacegroup, p)[source]

Get the orbit of a point p under the symmetry operations of a structure. and the corresponding rotation matrices and translation vectors.

Parameters:
  • spacegroup (irrep.spacegroup.SpaceGroup) – The spacegroup object.

  • p (np.ndarray(shape=(3,), dtype=float)) – Point for which to calculate the orbit in the reduced coordinates.

Returns:

  • np.ndarray(shape=(N, 3) – The orbit of v under the symmetry operations of the structure.

  • np.ndarray(shape=(N, 3, 3) – The rotation matrices of the symmetry operations

  • np.ndarray(shape=(N, 3) – The translation vectors of the symmetry operations

wannierberri.symmetry.projections.read_xzaxis(xaxis, zaxis)[source]
class wannierberri.symmetry.wyckoff_position.WyckoffPosition(position_str, spacegroup, free_var_values=None)[source]

Bases: object

Wyckoff position defined by a sympy string

Parameters:
  • wyckoff_position_str (str) – The string defining the Wyckoff position. E.g. “x,y,z”, “x,y,x-y”, “1/2,1/2,z”

  • spacegroup (irrep.spacegroup.SpaceGroup) – The spacegroup which transforms the coordinates

string

The string defining the Wyckoff position.

Type:

str

sympy

The sympy expression defining the Wyckoff position.

Type:

sympy.Expr

as_numeric()[source]
contains_position(position)[source]
property free_var_values
property free_vars
property map_on_free_vars

Returns the matrices R and T, such that given a vector V = [x,y,..] of free variables the point Wyckoff position is given by R@V + T

Returns:

  • np.ndarray(shape=(3,self.num_free_vars), dtype=float) – The rotation matrix.

  • np.ndarray(shape=(3,), dtype=float) – The translation vector. (values when all free variables are 0)

property map_orbit_on_free_vars

Returns the matrices R and T, such that given a vector V = [x,y,..] of free variables all points of the Wyckoff position is given by R@V + T

Returns:

  • np.ndarray(shape=(self.num_points, 3,self.num_free_vars), dtype=float) – The rotation matrix.

  • np.ndarray(shape=(self.num_points, 3), dtype=float) – The translation vectors (values when all free variables are 0)

property num_free_vars
orbit_str()[source]
position_numeric(x=0.36787944117144233, y=0.3183098861837907, z=np.float64(0.7071067811865475))[source]
property positions
property rotations_cart
stick_to_atoms(atoms, atoms_filled)[source]

ccheck if any of the atoms belong to this wyckoff position and find free variables that correspond to this atom (modulo 1)

Parameters:
  • atoms (list of np.ndarray(shape=(3,num_atoms), dtype=float)) – List of atomic positions.

  • atoms_filled (list of bool) – List of flags for filled atoms. (The list is modified, the filled atoms are marked as True.)

Returns:

The free variables corresponding to the atom.

Return type:

np.ndarray(shape=(num_free_vars,), dtype=float)

vars_dict_to_array(d)[source]
xdef = 0.36787944117144233
ydef = 0.3183098861837907
zdef = np.float64(0.7071067811865475)
class wannierberri.symmetry.wyckoff_position.WyckoffPositionNumeric(positions, spacegroup)[source]

Bases: WyckoffPosition

as_numeric()[source]
property map_orbit_on_free_vars

Returns the matrices R and T, such that given a vector V = [x,y,..] of free variables all points of the Wyckoff position is given by R@V + T

Returns:

  • np.ndarray(shape=(self.num_points, 3,self.num_free_vars), dtype=float) – The rotation matrix.

  • np.ndarray(shape=(self.num_points, 3), dtype=float) – The translation vectors (values when all free variables are 0)

property num_free_vars
orbit_str()[source]
property positions
wannierberri.symmetry.wyckoff_position.find_solution_mod1(A, B, max_shift=2)[source]

Find a solution such that A@x = B mod 1

Parameters:
  • A (np.ndarray (n,m)) – The matrix of the system.

  • B (np.ndarray (n,)) – The right hand side.

  • max_shift (int) – The maximum shift.

Returns:

The shifts that are compatible with the system.

Return type:

list of np.ndarray

wannierberri.symmetry.wyckoff_position.get_orbit(spacegroup, p, tol=1e-05)[source]

Get the orbit of a point p under the symmetry operations of a structure.

Parameters:
  • spacegroup (irrep.spacegroup.SpaceGroup) – The spacegroup of the structure. If None, the orbit is just the point p.

  • p (np.ndarray(shape=(3,), dtype=float)) – Point for which to calculate the orbit in the reduced coordinates.

Returns:

The orbit of v under the symmetry operations of the structure.

Return type:

UniqueListMod1 of np.ndarray(shape=(3,), dtype=float)

wannierberri.symmetry.wyckoff_position.get_shifts(max_shift, ndim=3)[source]

return all possible shifts of a 3-component vector with integer components recursively by number of dimensions

Parameters:
  • max_shift (int) – The maximum absolute value of the shift.

  • ndim (int) – The number of dimensions.

Returns:

The shifts. n=(max_shift*2+1)**ndim sorted by the norm of the shift

Return type:

array_like(n, ndim)

wannierberri.symmetry.wyckoff_position.orbit_and_rottrans(spacegroup, p)[source]

Get the orbit of a point p under the symmetry operations of a structure. and the corresponding rotation matrices and translation vectors.

Parameters:
  • spacegroup (irrep.spacegroup.SpaceGroup) – The spacegroup object.

  • p (np.ndarray(shape=(3,), dtype=float)) – Point for which to calculate the orbit in the reduced coordinates.

Returns:

  • np.ndarray(shape=(N, 3) – The orbit of v under the symmetry operations of the structure.

  • np.ndarray(shape=(N, 3, 3) – The rotation matrices of the symmetry operations

  • np.ndarray(shape=(N, 3) – The translation vectors of the symmetry operations

wannierberri.symmetry.wyckoff_position.split_into_orbits(positions, spacegroup)[source]

Split a list of positions into orbits under the symmetry operations of a structure.

Parameters:
  • positions (list of np.ndarray(shape=(3,), dtype=float)) – The positions to split into orbits.

  • spacegroup (irrep.spacegroup.SpaceGroup) – The spacegroup of the structure.

Returns:

the indices of the positions in the input list that belong to the same orbit.

Return type:

list of list of int