Exemple #1
0
 def calculate_isolate_molecular_levels(self, tp):
     atoms = self.isolate_atoms
     atoms.pbc = True
     p = tp.gpw_kwargs.copy()
     p['nbands'] = None
     if 'mixer' in p:
         if not tp.spinpol:
             p['mixer'] = Mixer(0.1, 5, weight=100.0)
         else:
             p['mixer'] = MixerDif(0.1, 5, weight=100.0)
     p['poissonsolver'] = PoissonSolver(nn=2)
     if type(p['basis']) is dict and len(p['basis']) == len(tp.atoms):
         p['basis'] = 'dzp'
         raise Warning('the dict basis is not surpported in isolate atoms')
     if 'txt' in p and p['txt'] != '-':
         p['txt'] = 'isolate_' + p['txt']
     atoms.set_calculator(GPAW(**p))
     atoms.get_potential_energy()
     setups = atoms.calc.wfs.setups
     self.project_basis_in_molecule = get_atom_indices(
         self.project_atoms_in_molecule, setups)
     kpt = atoms.calc.wfs.kpt_u[0]
     s_mm = atoms.calc.wfs.S_qMM[0]
     c_nm = eig_states_norm(kpt.C_nM, s_mm)
     self.isolate_eigen_values = kpt.eps_n
     self.isolate_eigen_vectors = c_nm
     self.isolate_s_mm = s_mm
Exemple #2
0
 def calculate_isolate_molecular_levels(self, tp):
     atoms = self.isolate_atoms
     atoms.pbc = True
     p = tp.gpw_kwargs.copy()
     p['nbands'] = None
     if 'mixer' in p:
         if not tp.spinpol:
             p['mixer'] = Mixer(0.1, 5, weight=100.0)
         else:
             p['mixer'] = MixerDif(0.1, 5, weight=100.0)
     p['poissonsolver'] = PoissonSolver(nn=2)
     if type(p['basis']) is dict and len(p['basis']) == len(tp.atoms):
         p['basis'] = 'dzp'
         raise Warning('the dict basis is not surpported in isolate atoms')
     if 'txt' in p and p['txt'] != '-':
         p['txt'] = 'isolate_' + p['txt']
     atoms.set_calculator(GPAW(**p))
     atoms.get_potential_energy()
     setups = atoms.calc.wfs.setups
     self.project_basis_in_molecule = get_atom_indices(
                                   self.project_atoms_in_molecule, setups)         
     kpt = atoms.calc.wfs.kpt_u[0]
     s_mm = atoms.calc.wfs.S_qMM[0]
     c_nm = eig_states_norm(kpt.C_nM, s_mm)
     self.isolate_eigen_values = kpt.eps_n
     self.isolate_eigen_vectors = c_nm
     self.isolate_s_mm = s_mm
Exemple #3
0
    def lead_scattering_states(self, tp, energy, l, s, q):
        #Calculating the scattering states in electrodes
        #l ---- index of electrode
        #s ---- index of spin
        #q ---- index of local k point

        #if it is multi-terminal system, should add a part that can rotate
        # the lead hamiltonian
        MaxLambda = 1e2
        MinErr = 1e-8
        energy += tp.bias[l]
        hes00 = tp.lead_hsd[l].H[s][q].recover() - \
                                    tp.lead_hsd[l].S[q].recover() * energy
        hes01 = tp.lead_couple_hsd[l].H[s][q].recover() - \
                             tp.lead_couple_hsd[l].S[q].recover() * energy
        nb = hes00.shape[-1]
        dtype = hes00.dtype
        A = np.zeros([2 * nb, 2 * nb], dtype)
        B = np.zeros([2 * nb, 2 * nb], dtype)

        A[:nb, nb:2 * nb] = np.eye(nb)
        A[nb:2 * nb, :nb] = hes01.T.conj()
        A[nb:2 * nb, nb:2 * nb] = hes00

        B[:nb, :nb] = np.eye(nb)
        B[nb:2 * nb, nb:2 * nb] = -hes01

        from scipy.linalg import eig
        D, V = eig(A, B)
        index = np.argsort(abs(D))
        D = D[index]
        V = V[:, index]

        #delete NaN
        index = find(np.abs(D) >= 0)
        D = D[index]
        V = V[:, index]

        #delete some unreasonable solutions
        index = find(abs(D) > MaxLambda)
        cutlen = len(D) - index[0]
        index = np.arange(cutlen, len(D) - cutlen)
        D = D[index]
        V = V[:, index]

        k = np.log(D) * (-1.j) / 2 / np.pi
        Vk = V[:nb]

        #sort scattering states
        proindex = find(abs(k.imag) < MinErr)

        if len(proindex) > 0:
            k_sort = np.sort(k[proindex].real)
            index = np.argsort(k[proindex].real)
            k[proindex] = k[proindex[index]].real
            Vk[:, proindex] = Vk[:, proindex[index]]

            #normalization the scattering states
            j = proindex[0]
            while j <= proindex[-1]:
                same_k_index = find(abs((k - k[j]).real) < MinErr)
                sk = self.lead_k_matrix(tp, l, s, q, k[j])
                Vk[:, same_k_index] = eig_states_norm(Vk[:, same_k_index], sk)
                j += len(same_k_index)
        return np.array(k[proindex]), np.array(Vk[:, proindex])
Exemple #4
0
 def lead_scattering_states(self, tp, energy, l, s, q):
     #Calculating the scattering states in electrodes
     #l ---- index of electrode
     #s ---- index of spin
     #q ---- index of local k point
     
     #if it is multi-terminal system, should add a part that can rotate
     # the lead hamiltonian
     MaxLambda = 1e2
     MinErr = 1e-8
     energy += tp.bias[l]
     hes00 = tp.lead_hsd[l].H[s][q].recover() - \
                                 tp.lead_hsd[l].S[q].recover() * energy
     hes01 = tp.lead_couple_hsd[l].H[s][q].recover() - \
                          tp.lead_couple_hsd[l].S[q].recover() * energy
     nb = hes00.shape[-1]
     dtype = hes00.dtype
     A = np.zeros([2*nb, 2*nb], dtype)
     B = np.zeros([2*nb, 2*nb], dtype)
         
     A[:nb, nb:2*nb] = np.eye(nb)
     A[nb:2*nb, :nb] = hes01.T.conj()
     A[nb:2*nb, nb:2*nb] = hes00
         
     B[:nb, :nb] = np.eye(nb)
     B[nb:2*nb, nb:2*nb] = -hes01
         
     from scipy.linalg import eig
     D, V = eig(A, B)
     index = np.argsort(abs(D))
     D = D[index]
     V = V[:, index]
     
     #delete NaN
     index = find(np.abs(D) >= 0)
     D = D[index]
     V = V[:, index]
     
     #delete some unreasonable solutions
     index = find(abs(D) > MaxLambda)
     cutlen = len(D) - index[0]
     index = np.arange(cutlen, len(D) - cutlen)
     D = D[index]
     V = V[:, index]
         
     k = np.log(D) * (-1.j) / 2 / np.pi
     Vk = V[:nb]
         
     #sort scattering states 
     proindex = find(abs(k.imag) < MinErr)
         
     if len(proindex) > 0:
         k_sort = np.sort(k[proindex].real)
         index = np.argsort(k[proindex].real)
         k[proindex] = k[proindex[index]].real
         Vk[:, proindex] = Vk[:, proindex[index]]
             
         #normalization the scattering states
         j = proindex[0]
         while j <= proindex[-1]:
             same_k_index = find(abs((k - k[j]).real) < MinErr)
             sk = self.lead_k_matrix(tp, l, s, q, k[j])
             Vk[:, same_k_index] = eig_states_norm(Vk[:, same_k_index],
                                                                      sk)
             j += len(same_k_index)
     return np.array(k[proindex]), np.array(Vk[:, proindex])