{'fraction_non_alphanumeric': 0.03496303557570559, 'fraction_numerical': 0.012498468324960177, 'mean_word_length': 4.704566635601118, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
WannSymm: A symmetry analysis code for Wannier orbitals

We derived explicit expressions of symmetry operators on Wannier basis, and implemented these operators in WannSymm software. Based on this implementation, WannSymm can i) symmetrize the real-space Hamiltonian output from Wannier90 code, ii) generate symmetry operators of the little group at a specific k-point, and iii) perform symmetry analysis for Wannier band structure. In general, symmetrized Hamiltonians yield improved results compared with the original ones when they are employed for nodal structure searching, surface Green's function calculations, and other model calculations.


Introduction
Symmetry serves as one of the most fundamental concept and properties in the modern physics. In the condensed matter physics, in particular, the Landau's symmetry breaking theory [1,2] for phase transition is widely applied in the second order phase transitions such as superconductivity phase transitions and magnetic phase transitions, where the symmetry-based order parameter signals the phase transition. In the solid state theory, the irreducible representations of a space group can be used in labelling the electronic energy bands in a crystalline solid [3], which becomes particularly important in the modern band topology theory. The discovery of topological insulators [4,5,6], quantum anomalous Hall insulators [7], as well as topological Weyl and Dirac semimetals brings intensive study on the topological properties of materials [8], where the band symmetry is crucial to the determination of band topologies. Such topology-symmetry correspondence became evident in the more recently discovered symmetry based indicator theory that can be used to distinguish topological non-trivial phases from trivial ones [9,10,11,12]. This is particularly useful for superconductors, because one may apply the symmetry-indicator theory and predict topological superconductor candidates using normal state Hamiltonian combined with its superconducting pairing symmetry, if weak-coupling condition is met [12]. Furthermore, for most ab initio codes, symmetry is used to improve calculation accuracy, as well as to reduce the calculation burden.
Many state-of-art first-principles calculation codes utilizes plane-wave or augmented plane-wave basis, which are more expensive than localized basis. Therefore in many cases, a real-space Hamiltonian is obtained via Wannier projection (e.g., Wannier90 code [13]) after the ground state is converged, and the post-process calculations employs this real-space Wannier Hamiltonian to speed up the calculations. However, due to numerical errors introduced in the projection procedure, the crystal symmetries may be violated in the derived real-space Hamiltonian. These numerical errors may lead to incorrect results. Therefore, it is important to restore correct symmetries in the derived real-space Hamiltonian. At present, there are several codes performing similar tasks. For example, the wannhr symm code in the WannierTools package [14] performs symmetrization of Hamiltonian without magnetic orders; the symmetry-adapted Wannier function method [15] does wannierization with symmetry constraint for spinless Hamiltonians.
In this article, we introduce the WannSymm code which can be applied to non-magnetic (NM), ferromagnetic (FM) or anti-ferromagnetic (AFM) crystals. It can symmetrize the real-space Wannier Hamiltonian, perform symmetry analysis and obtain the eigenvalues and characters of relevant symmetries at a given k point. It implements parallel algorithm for symmetrizing the real-space Hamiltonian. The method does not depend on the radial part of Wannier orbitals, and thus it can be applied to any tight-binding like Hamiltonian defined on a local basis-set with atomic-like angular dependence. Using WannSymm, we have already performed symmetry analysis for the unconventional superconductor K 2 Cr 3 As 3 [16], calculated the simple Z 2 index for topological material W 2 As 3 [17], the mirror eigenvalues for nodal ring semimetal InTaSe 2 [18] and correctly identify the nodal structures and topological invariants for the Kondo nodal-line semimetal Ce 3 Pd 3 Bi 4 [19].

Crystal symmetry operations
The WannSymm code employs spglib [20] to determine the relevant symmetry operations for a specific system. The spglib obtains the symmetry operations from the input of crystal structures. However, these symmetry operations are purely spatial and do not involve time-reversal operation, forming a group denoted as G S . For the systems without long-range magnetic order, the full symmetry of the Hamiltonian is then G H = G T = G S ⊕ T G S , where T is the time-reversal symmetry. For the systems with long-range magnetic order [either ferromagnetic (FM) or antiferromagnetic (AFM)], the rotation operations are required to act on both spatial space and spin space when spin-orbit coupling (SOC) is considered. Therefore, the full symmetry of the Hamiltonian G H is a subgroup of G T . Noticing that the operations in G H should leave the magnetic moment unchanged as well, we determine the elements of G H by taking every R ∈ G T and operating it on the magnetic sublattice. If the sublattice after the operation R remains equivalent to the original one, R belongs to G H . In WannSymm, the magnetic sublattice is represented by a set of magnetic moment vectors at the atomic positions τ .

Atomic-like Wannier basis and Real-space Hamiltonian
In practice, Wannier orbitals are usually obtained by projecting Blöch waves to atomic orbital-like initial guess |g . It is our experience that the angular dependence of |g is more important than its radial function in order to obtain an accurate Wannier fitting in most cases. In addition, we shall see that the WannSymm code relies on the angular dependence of the Wannier basis to perform the symmetrization procedure. Therefore, we shall assume that the Wannier basis are cubic-harmonic atomic-orbital like, i.e. |w iR = |Rτ nlmσ where i denotes the ith orbital, R is Bravais lattice vector, τ is the atomic position of the i-th orbital in the unit cell, and n, l and σ are its primary, orbital and spin quantum numbers, respectively. m is the index of the cubic harmonic. The corresponding real-space Hamiltonian can be written as Following the definition of Fourier transformation, we have the basis of corresponding reciprocal-space and Hamiltonian in this basis We use the same convention as employed in Wannier90 [13] code. If the tight-binding convention instead of Wannier convention is employed, an additional e ik·τ i or e ik·(τ j −τ i ) factor may appear in the basis or Hamiltonian transformation, respectively.

Symmetry operator
The matrix representation of symmetry operators are derived in the Hilbert space formed by the atomic-like Wannier basis |Rτ nlmσ . The rotation op-eratorD(R) corresponding to a proper rotation R iŝ wheren is the normalized rotation axis, φ is the rotated angle, andL is the angular momentum operator. For spherical harmonics, it is straightforward to obtain the matrix form ofL, hence the rotation matrix D l in spherical harmonics. Therefore we employ the transformation U from cubic harmonics to spherical harmonics, defined by where |Y (l, m) and |lm ′ denote the spherical harmonics and cubic harmonics, respectively. The indices of lattice, position, primary quantum number and spin are omitted in the expression. The rotation matrix in cubic harmonics D l is then given by D l = U l D l U −1 l . We denote the rotation matrix of a specific rotation R and angular quantum number l as D l (R), and the spinor part as D s (R). Therefore, is the new atomic position after rotation.
In addition, the spatial inversion operator simply introduces a factor of (−1) l for the orbital part. For the time-reversal operation T = U · K, since the cubic harmonics are real functions, it has trivial effect on the orbital part during the symmetrization. Therefore, we only need to take care of the spinor part using −iσ y K with K being the complex conjugation. With these definitions, the matrix representation of all symmetry operations can be fully constructed.

Real space
We then elaborate a little bit further of the symmetry operator for the real-space Hamiltonian, which is useful during the symmetrization process.
According to above derivation, a symmetry operation S acting on the Wannier basis in general can be written as: . Therefore, the real-space symmetry operation matrices are very sparse.
Since the HamiltonianĤ transforms asŜĤŜ † and the elements of realspace Hamiltonian are H R ij = 0τ i n i l i m i σ i |H|Rτ j n j l j m j σ j , the rotated Hamiltonian is then In general, a symmetry operation S maps an atom i at τ i to its symmetrically equivalent site with an optional lattice translation R S i , which depends only on the symmetry operation S and the site coordinate τ i . With this in mind, we have Using the above result, we are able to calculate the real-space Hamiltonian after symmetry operation S. This procedure is employed in the Hamiltonian symmetrization process, which involves: being all the integer tanslations. This is because all the integer translational symmetries are automatically preserved in the Wannier representation.

Reciprocal space
According to Eq. 1, the rotation of reciprocal Wannier orbitals are In addition, S k can be used to perform symmetry analysis of a Blöch state. In order to do that, we first identify the little group G k H of Hamiltonian H k at a specific point k. The eigenstates of H k therefore can block-diagonalize S k , with the trace of each block being the characters of different symmetry representations. Thus the irreducible representation of each Blöch state can be determined using a character table.

Details of the code 2.4.1. Data Structure
In the WannSymm code, each symmetry operation is represented by two flags of spatial inversion and time-reversal in addition to a proper rotation and the associated translation.
In order to implement the above algorithm, the real-space Hamiltonian H R ij = w i0 |H|w jR are divided into blocks such that the bra/ket states in each block have the same τ , n, and l. In other words, the Hilbert space is divided into subspaces formed by atomic orbitals with the same primary and orbital quantum numbers on each atom. A mapping between subspace orbital indices to global orbital indices is maintained by the WannSymm code to facilitate the calculation.
For the reciprocal space calculations, since the S k has a definite dimension the same as the H k , we can construct S k using Eq. 3 with the assist of the subspace-global mapping.
The structure of the program is illustrated in Fig. 1.

Installation and Typical Input/Output File
The WannSymm code depends on spglib to analyze the symmetry of crystal. In addition, it also requires a working implementation of LAPACK/BLAS library. Makefile compiling system is used. In order to compile the WannSymm code, the users need to change the make.sys file in the top folder, and provide paths of spglib and LAPACK/BLAS library.
The WannSymm code can also utilize message passing interface (MPI) to speed up the calculations. Currently, MPI parallelization is implemented over the number of symmetry operations.
The compiled code can be executed with mpirun -np $Num of process wannsymm.x $InputFile where $InputFile is the name of the master input file. If it is not provided, a default master input file wannsymm.in must be provided. A typical master input file looks like: # template input file of wannsymm.x # anything following '#', '!' or '//' in a line will be regard as comments The master input file must contain DFTcode tag, SeedName tag, Spinors tag, projections block and crystal structure information. Most of these tags are self-explanatory, and we shall not restate their meanings here. The DFTcode tag is related to the type of the real-space Hamiltonian from Wannier90 code. It can be either "VASP" for Vienna Abinitio Simulation Package (VASP) [21,22] users or "QE" for Quantum ESPRESSO [23] users. For the Wien2K [24] users, the type of the real-space Hamiltonian can be specified as the VASP-type. The projections block follows the Wan-nier90 convention, and the crystal structure information can be provided either in the POSCAR-format file specified in the Use POSCAR tag or in the Structure in Format of POSCAR tag. In addition, a real-space Hamiltonian following the Wannier90 convention should be provided in seedname hr.dat file as well.
The execution generates several output files. The most important output file is seedname symmed hr.dat, which contains the symmetrized Hamiltonian. In addition, an output file symmetries.dat contains all the symmetries found by spglib. The output file wannsymm.out contains additional important details of the calculation. Finally, one can track the progress of the calculations by monitoring the .progress-of-threadXX files:

tail -f .progress-of-thread1
After the symmetrized Hamiltonian is generated, the symmetry of Blöch states can be analyzed by setting additional two tags in the master input file: Restart tag tells the code to enter analysis mode and skip the symmetrization procedure, whereas Kpt tag specifies the K-point (in unit of reciprocal lattices) to be analyzed. Once the calculation is done, the code generates an additional output files bnd sym characters. It reads:  The first line is the K-point calculated, followed by the little group information (all the symmetry operations of the little group). After that, the characters of each state are listed, which can be used with a character table to figure out the irreducible representation of the state.

Examples and verification
To verify the validity of our algorithm and code, we share here several examples in which our code is applied to symmetrize the Wannier Hamiltonian. These examples consists of four different materials, including paramagnet K 2 Cr 3 As 3 , anti-ferromagnet MnF 2 , ferromagnet CrO 2 and topological nodal-line semimetal Ce 3 Pd 3 Bi 4 [19].
The real-space Hamiltonian employed in these examples are generated by the VASP, QE or Wien2K and their corresponding interface codes. In all these calculations, unless otherwise specified, the spin-orbit coupling (SOC) effect is considered as a second variation to the full Hamiltonian. All the initial guess of Wannier orbitals are atomic-like. During the Wannierization, we completely turn off the minimization of Wannier spreading, because the minimization procedure has no symmetry constraint, and may severely alter the symmetry (or the angular dependence of the orbitals). This procedure is conceptually the same as the maximally projected Wannier function proposed by Anisimov et al. [25].
3.1. Paramagnet K 2 Cr 3 As 3 K 2 Cr 3 As 3 received much attention and intensive study in recent years, due to its possible unconventional superconductivity and nontrivial topological property [16,26,27]. Experimentally and theoretically, it was proposed to be paramagnetic at normal ground state. Structurally, it has quasi-onedimensional structure with the space group P6m2 (No. 187), which contains 12 symmetry operations.
The Wannier Hamiltonian is generated using 96 states containing Cr-3d and As-4p orbitals in the presence of SOC. Due to the crystal symmetry, there are 12 symmetrically equivalent k-paths for band structure. Using the real-space Wannier Hamiltonian, we calculate the band structure of all the equivalent k-paths and illustrate them in a single plot [ Fig. 3 (a)]. In the ideal case, the band structures from these equivalent high symmetry k-paths should be exactly the same. However, the Wannierization procedure has no symmetry constraint and the numerical errors are therefore inevitable. The inset of Fig. 3 (a) shows a zoomed-in part of band structure along K-Γ, illustrating the poor symmetry of the Hamiltonian without symmetrization. The energy differences are the order of ∼ 3×10 −4 eV, which is already larger than commonly employed symmetry criterion for double precision calculations (in most cases no larger than 10 −6 eV). With the symmetrized real-space Hamiltonian, we also calculated band structures along all 12 equivalent k-paths, which is illustrated in Fig. 3 (b). Overall, the band structure generated using the symmetrized Hamiltonian resembles the one from original Hamiltonian, and the DFT band structure as well. In addition, the violated symmetry during the wannierization is restored by the symmetrization code, as shown in the inset of Fig. 3 (b). Numerically, the energy differences between the 12 equivalent k-paths reach the order of 10 −14 eV, which is close to the limit of double precision float.
Using our code, we have also calculated the symmetry characters for the 10 states near the Fermi level (from -0.07 eV to 0.10 eV) at Γ point. With the character table given in Ref. [3], we have also determined the irreducible representation for these states. The results are (1-2) Γ 9 ; (3-4) Γ 8 ; (5-6) Γ 7 ; (7-8) Γ 9 and (9-10) Γ 8 , the numbers inside the brakets are band indices labeled in the order of increasing band energies, and the two indices within the same brakets are degenerate states. These results are the same as those calculated by Quantum ESPRESSO [23]. The eigenvalues of symmetry operators (i.e. the parity at the time-reversal invariant momenta, the mirror eigenvalue and the eigenvalue for rotation symmetry) as reported in our previous studies [16,17,18] can also be obtained with this code.
We want to take a minor detour and discuss about the differences between our method and the symmetry adapted Wannier function method [15]. Unlike our method, the symmetry adapted Wannier function method employs the symmetry constraint during the wannierization and minimization procedures. Conceptually, it may be more appealing than postprocess procedures like our method. In practice, however, for some complex systems, the Blöch state may involve too many higher order angular momentum contributions, and the symmetry adapted Wannier function may fail to capture the low-energy excitation. Such an example is illustrated in Fig.2 (c-d), where we compare the interpolated band structures obtained from symmetryadapted Wannier functions, symmetrized real-space Hamiltonian and DFT band structures in the absence of SOC. The real-space Wannier Hamiltonian for both cases are obtained using 48 atomic-like orbitals including Cr-3d and As-4p in non-SOC case. We employ the Wannierization procedure with the same outer energy window and without minimization of Wannier spreading. The symmetrized real-space Hamiltonian using WannSymm correctly reproduces the low-energy excitations as well as the band symmetry at the Γ point around the Fermi level, in contrast to the symmetry adapted Wannier function method.

Anti-ferromagnet MnF 2 and Ferromagnet CrO 2
MnF 2 is a typical anti-ferromagnetic (AFM) material [29]. Its space group is P 4 2 /mnm (No. 136), which contains 16 symmetry operations. We show the crystal structure as well as the magnetic pattern in Fig. 4 (a-b). The original real-space Wannier Hamiltonian H in MnF 2 is constructed using 48 Wannier states, including the Mn-4s, Mn-3d and F-2p atomic orbitals.
In the presence of SOC, we show in Fig. 5 (a) the original DFT band structure as well as the band structure reconstructed using H nomag MnF 2 , which is derived by symmetrizing H in MnF 2 without considering the long-range AFM order. With H in MnF 2 , we can calculate the Zeeman splittings for F-2p and the exchange splittings for Mn-d. And the Zeeman splittings for F-2p x(y) and F-2p z are 0.024 and 0.160 eV, respectively. The former two are equivalent because the magnetic moment is assumed to be parallel to c. And the exchange splittings for Mn-d z 2 , Mn-d x 2 −y 2 , Mn-d zx(y) , Mn-d xy are 4.401, 4.486, 4.397 and 4.392 eV, respectively. Again, d zx and d zy are equivalent due to crystal symmetry. The ligand states between [-8, -3] eV are mostly contributed by F-2p orbitals, where only small Zeeman splitting (which is only 3% as large as the exchange splitting for Mn-d) is present, and are therefore less affected by the ignorance of magnetic order. The Mn-3d states between [-2, 4] eV, however, are apparently inconsistent with the original DFT band structure as the exchange-splitting is (incorrectly) suppressed to 0 eV from ∼ 4.39 eV if the global time-reversal symmetry is also considered during the symmetrization process. We then derive the correct magnetic group using the procedure described above, the resulting magnetic group contains 16 symmetry operations, including 1 four-fold rotation symmetry, 4 two-fold rotation symmetry and an inversion symmetry. Using the correct magnetic group, we symmetrize H in MnF 2 to obtain the real-space Hamiltonian H mag MnF 2 . Fig. 5 (b) shows the comparison between the original DFT band structure and the band structure reconstructed using H mag MnF 2 . The good comparison manifests the validity of our method.
We illustrate the ferromagnetic (FM) case using CrO 2 . CrO 2 is a typical FM material [30], it shares the same space group P 4 2 /mnm (No. 136) with MnF 2 and the crystal structure is illustrated in Fig. 4 (b). For simplicity, we constrain the magnetic moment along z-direction in the presence of SOC. Please be advised that the moment direction also affects the determination of magnetic group. In this case, we obtain the original Wannier real-space Hamiltonian (H in CrO 2 ) using 44 states including Cr-3d and O-2p orbitals. Similar to the MnF 2 case, we also compare the original DFT band structure and band structure reconstructed with symmetrized Hamiltonian with/without considering magnetic order (Fig. 6). In Fig. 6(a), the symmetrization was done without considering FM order, and thus the large exchange splitting (∼ 2 eV for Cr-d) is missing. In contrast, the exchange-splitting is preserved, and the correct band structure is reproduced in Fig. 6(b) once the FM order is taken into consideration.
The real-space Wannier Hamiltonian (H in Ce343 ) is obtained using 108 states including Pd-4d and Bi-3p orbitals. We then employ the WannierTools code [14] to find the nodal structures between the band 4 and band 5 (band indices follow the Supplemental Material of [19]). The resulting nodal lines and nodal points are shown in Fig. 7 (b). Since the symmetry of H in Ce343 is poor, it is almost impossible to correctly identify the nodal structures. However, after the symmetrization procedure, the result improves drastically. The resulting nodal structure using the symmetrized real-space Hamiltonian (H sym Ce343 ) is shown in Fig. 7 (c), illustrating the correct nodal rings around the Fermi level. Such a significant change brought by the symmetrization procedure suggests that the topological properties are sensitive to the Hamiltonian symmetry, and thus a Hamiltonian with correct symmetry is crucial to the topological classification.

Conclusion
WannSymm is a user friendly, fast, MPI-parallelized open source C-based code for symmetry analysis based on real-space Hamiltonian constructed us- ing atomic-like orbitals. We implement not only for the nonmagnetic cases, but also for the magnetic cases without and with SOC. We demonstrate the validity of our method by using typical materials, e.g. K 2 Cr 3 As 3 , MnF 2 , CrO 2 , and Ce 3 Pd 3 Bi 4 . After symmetrization, the crystal symmetries ruined during the Wannierise procedure are restored, and thus the improved numerical results can be obtained. Eigenvalues and characters of an arbitrary symmetry operator (symmorphic or nonsymmorphic) can also be obtained using this code. Since our code directly handles real-space Hamiltonian output from Wannier90 code, it can easily be used in combination with any code that has an interface to Wannier90, including VASP, Quantum ESPRESSO and Wien2K. We emphasize here that our current method can be applied to linear combinations of atomic orbitals (e.g., sp 2 -like, sp 3 -like orbitals, etc) with small modifications, but cannot be applied to general Wannier orbitals with arbitrary angular dependence (e.g. summation of Blöch waves). Finally, the method does not depend on the details of Wannier orbital generation except for atomic-like orbital assumption, and therefore can be applied to any real-space Hamiltonian as long as it is defined on a basis set which has atomic-like angular dependence.