示例#1
0
 def diag_kpts(self, kpts, vec=0, pmk=0, elec_field=0.):
     """
     kpts: the coordinates of kpoints
     vec: whether to calculate the eigen vectors
     pmk: whether to calculate PMK for effective band structure
     elec_field: the electric field perpendicular to graphane plane
     fname: the file saveing results
     """
     if pmk:
         from tBG.fortran.spec_func import get_pk
     val_out = []
     vec_out = []
     pmk_out = []
     i = 1
     if vec or pmk:
         vec_calc = 1
     else:
         vec_calc = 0
     for k in kpts:
         print('%s/%s k' % (i, len(kpts)))
         Hk = self.hamilt_cell_diff(k, elec_field)
         vals, vecs, info = zheev(Hk, vec_calc)
         if info:
             raise ValueError('zheev failed')
         if pmk:
             Pk = get_pk(k,
                         np.array(self.layer_nsites) / 2, [1, 1], 2, 2,
                         vecs, self.coords, self.species())
             pmk_out.append(Pk)
         val_out.append(vals)
         if vec:
             vec_out.append(vecs)
         i = i + 1
     return np.array(val_out), np.array(vec_out), np.array(pmk_out)
示例#2
0
def diag_hamiltonian(H):
    vals = []
    vecs = []
    for i in [0, 1]:
        val, vec, info = zheev(H[i], 1)
        if info:
            raise ValueError('lapack in scipy zheev failed!')
        vals.append(val)
        vecs.append(vec)
    return vals, vecs
示例#3
0
 def diag_Hamiltonian(self, fname='EIGEN', vec=True):
     """
     fname: the file saving the eigenvalues and eigenvectors
     vec: True or False, whether eigenvectors are calculated
     E: the electric field strength eV/Angstrom
     """
     if vec:
         vec_calc = 1
     else:
         vec_calc = 0
     H = self.get_Hamiltonian()
     vals, vecs, info = zheev(H, vec_calc)
     if info:
         raise ValueError('zheev failed')
     if vec:
         np.savez_compressed(fname, vals=vals, vecs=vecs)
     else:
         np.savez_compressed(fname, vals=vals)
示例#4
0
 def calculate_eigensystem_unfolded(self, only_eigenvals=False):
     q_point = self.q_point
     scell = self.supercell
     atoms = self.atoms
     cell = atoms.cell
     n_unit_cell = atoms.positions.shape[0]
     positions = atoms.positions
     fc_s = self.second.dynmat.numpy()
     fc_s = fc_s.reshape(
         (n_unit_cell, 3, scell[0], scell[1], scell[2], n_unit_cell, 3))
     sc_r_pos = self.second.supercell_positions
     sc_r_pos_norm = 1 / 2 * np.linalg.norm(sc_r_pos, axis=1)**2
     dyn_s = np.zeros((n_unit_cell, 3, n_unit_cell, 3), dtype=np.complex)
     tt = self.second.supercell_replicas
     for ind in range(tt.shape[0]):
         t = tt[ind]
         replica_position = np.tensordot(t, cell, (-1, 0))
         for iat in np.arange(n_unit_cell):
             for jat in np.arange(n_unit_cell):
                 distance = replica_position + (positions[iat, :] -
                                                positions[jat, :])
                 projection = (np.dot(sc_r_pos, distance) -
                               sc_r_pos_norm[:])
                 if ((projection <= 1e-6).all()):
                     neq = (np.abs(projection) <= 1e-6).sum()
                     weight = 1.0 / (neq)
                     qr = 2. * np.pi * np.dot(q_point[:], t[:])
                     for ipol in np.arange(3):
                         for jpol in np.arange(3):
                             dyn_s[iat, ipol, jat,
                                   jpol] += fc_s[jat, jpol, t[0], t[1],
                                                 t[2], iat, ipol] * np.exp(
                                                     -1j * qr) * weight
     dyn = dyn_s[...].reshape((n_unit_cell * 3, n_unit_cell * 3))
     omega2, eigenvect, info = zheev(dyn)
     frequency = np.sign(omega2) * np.sqrt(np.abs(omega2))
     frequency = frequency[:] / np.pi / 2
     if only_eigenvals:
         esystem = (frequency[:] * np.pi * 2)**2
     else:
         esystem = np.vstack(((frequency[:] * np.pi * 2)**2, eigenvect))
     return esystem
 def diag_kpts(self, kpts, vec=0):
     """
     kpts: the coordinates of kpoints
     vec: whether to calculate the eigen vectors
     fname: the file saveing results
     """
     val_out = []
     vec_out = []
     i = 1
     if vec:
         vec_calc = 1
     else:
         vec_calc = 0
     for k in kpts:
         print('%s/%s k' % (i, len(kpts)))
         Hk = self.get_Hamiltonian_at_k(k)
         vals, vecs, info = zheev(Hk, vec_calc)
         if info:
             raise ValueError('zheev failed')
         val_out.append(vals)
         if vec:
             vec_out.append(vecs)
         i = i + 1
     return np.array(val_out), np.array(vec_out)
示例#6
0
文件: hubbard.py 项目: ZhichangFu/tBG
def diag_hamiltonian(H_mat):
    vals, vecs, info = zheev(H_mat, 1)
    if info:
        raise ValueError('lapack in scipy zheev failed!')
    return vals, vecs