Wannierisation inside WannierBerri
Now WannierBerri can construct wannier functions on its own. Both disentanglement and localisation.
Wannierisation can be performed with both sitesym=True and frozen window (this feature is currently not available in Wannier90).
see examples in examples/wannierise+sitesym-Fe and examples/wannierise+sitesym-diamond
- wannierise.wannierise(froz_min=inf, froz_max=-inf, num_iter=1000, conv_tol=1e-09, num_iter_converge=3, mix_ratio_z=0.5, mix_ratio_u=1, print_progress_every=10, sitesym=False, localise=True, init='amn', num_wann=None, parallel=True, symmetrize_Z=True)
Performs disentanglement and maximal localization of the bands recorded in w90data. The disentanglement is done following the procedure described in Souza et al., PRB 2001. The localization is done following a simplified procedure, avoiding gradient descent of the spread functional.
At the end writes
w90data.chk.v_matrixand setsw90data.wannierised = True- Parameters:
w90data (
Wannier90data) – the datafroz_min (float) – lower bound of the frozen window
froz_max (float) – upper bound of the frozen window
num_iter (int) – maximal number of iterations.
conv_tol (float) – tolerance for convergence of the spread functional (in \(\mathring{\rm A}^{2}\))
num_iter_converge (int) – the convergence is achieved when the standard deviation of the spread functional over the num_iter_converge*print_progress_every iterations is less than conv_tol
mix_ratio_z (float) – 0 <= mix_ratio_z <=1 - mixing the Z matrix (disentanglement) from previous itertions. 1 for max speed, smaller values are more stable
mix_ratio_u (float) – 0 <= mix_ratio_u <=1 - mixing the U matrix (localization) from previous itertions. 1 for max speed, smaller values are more stable WARNING : u<1 at the moment may lead to non-convergence. It is recommended to use mix_ratio_u=1 for now.
print_progress_every – frequency to print the progress
sitesym (bool) – whether to use the site symmetry (Symmetry-adapted Wannier Functions). If True, the symmetrizer attribute should be present in the w90data (either from pw2wannier90 or generated by wabnnierberri see
SymmetrizerSAWF,from_irrep()andset_D_wann_from_projections()localise (bool) – whether to perform the localization. If False, only disentanglement and rotation to projections are performed
kwargs_sitesym (dict) – additional the keyword arguments to be passed to the constructor of the
Symmetrizerinit (str) – the initialization of the U matrix. “amn” for the current state, “random” for random initialization, “restart” for restarting from the previous state
num_wann (int) – the number of Wannier functions. Required for random initialization only without sitesymmetry
parallel (bool) – if True - tries to run in parallel using ray. ray should be initialized before calling this function. If it was not initialized, the function will run in serial mode
symmetrize_Z (bool) – whether to symmetrize the disentangled Z matrix. If False, the Z matrix is not symmetrized which may lead to inaccuracy and slower convergence, but may be a faster calculation. Use it on your own risk.
- Returns:
w90data.chk.v_matrix – the optimized U matrices
- Return type:
numpy.ndarray
Note
- Also sets the following attributes of chk:
- w90data.chk.v_matrixnumpy.ndarray
the optimized U matrices
- w90data.wannierisedbool
True
- w90data.chk.wannier_centers_cartnumpy.ndarray (nW,3)
the centers of the Wannier functions
- w90data.chk.wannier_spreadsnumpy.ndarray (nW)
the spreads of the Wannier functions
If the outer window is needed, use
select_bands()before calling this function.The function is not parallelized yet
Disentanglement and localization are done in the irreducible BZ (if sitesym=True) and then symmetrized to the full BZ
Disentanglement and localization are done together, in the same loop. Therefore only one parameter num_iter is used for both
Example
# This tutorial shows how to generate a DMN file inside Wanier Berri code (without pw2wannier90)
# and then use it to generate a Wannier90 output.
# It may be used with any DFT code that is supported by IrRep (QE, VASP, AINIT, ...)
# the .dmn and .amn files are NOT needed before the calculation, they is generated on the fly
from wannierberri.symmetry.projections import Projection, ProjectionsSet
from irrep.bandstructure import BandStructure
import wannierberri as wb
path_data = "../../tests/data/Fe-222-pw/"
w90data = wb.w90files.Wannier90data(seedname=path_data + "Fe", readfiles=["mmn", "eig", "win", ], read_npz=True)
bandstructure = BandStructure(code='espresso',
prefix=path_data + "/Fe",
Ecut=200,
normalize=True,
magmom=[[0, 0, 1.]],
include_TR=True,
)
spacegroup = bandstructure.spacegroup
spacegroup.show()
# exit()
# symmetrizer = wb.symmetry.sawf.SymmetrizerSAWF().from_npz(path_data + f"/Fe_TR={False}.sawf.npz")
symmetrizer = wb.symmetry.sawf.SymmetrizerSAWF().from_irrep(bandstructure)
projection_s = Projection(orbital='s', position_num=[0, 0, 0], spacegroup=spacegroup)
projection_p = Projection(orbital='p', position_num=[0, 0, 0], spacegroup=spacegroup)
projection_d = Projection(orbital='d', position_num=[0, 0, 0], spacegroup=spacegroup)
projection_sp3d2 = Projection(orbital='sp3d2', position_num=[0, 0, 0], spacegroup=spacegroup)
projection_t2g = Projection(orbital='t2g', position_num=[0, 0, 0], spacegroup=spacegroup)
# projections_set = ProjectionsSet(projections=[projection_s, projection_p, projection_d])
projections_set = ProjectionsSet(projections=[projection_sp3d2, projection_t2g])
symmetrizer.set_D_wann_from_projections(projections_set)
amn = wb.w90files.amn_from_bandstructure(bandstructure, projections=projections_set)
w90data.set_symmetrizer(symmetrizer)
w90data.set_file("amn", amn)
w90data.select_bands(win_min=-8, win_max=50)
w90data.wannierise(init="amn",
froz_min=-10,
froz_max=20,
print_progress_every=10,
num_iter=101,
conv_tol=1e-10,
mix_ratio_z=1.0,
sitesym=True,
parallel=False
)
system = wb.system.System_w90(w90data=w90data, berry=True)
# Now do whatever you want with the system, as if it was created with Wannier90