def get_h_and_s(calc, spin=0, kpt=0): calc.atoms.set_calculator(calc) if calc.wfs.S_qMM is None: calc.wfs.set_positions(calc.spos_ac) tkpts_kc, tweights_k, H_skMM, S_kMM = get_lead_lcao_hamiltonian( calc, direction='x') fermi = calc.get_fermi_level() s = S_kMM[kpt] h = H_skMM[spin, kpt] - fermi * s remove_pbc(calc.atoms, h, s, d=0) return h, s
def get_hs(natoms, nkpts): calc = GPAW(h=0.25, mode='lcao', basis='sz', width=0.2, kpts=nkpts, mixer=Mixer(0.1, 5, weight=80.0), usesymm=False) atoms = Atoms('Na', pbc=True, cell=(L, L, L)).repeat(natoms) atoms.set_calculator(calc) atoms.get_potential_energy() fermi = calc.get_fermi_level() ibz, w, h, s = get_lead_lcao_hamiltonian(calc, direction=direction) h = h[0] - fermi * s for h1, s1 in zip(h, s): remove_pbc(atoms, h1, s1, d=dir) return ibz, w, h, s
def get_h_and_s(calc, kpt=0): calc.atoms.set_calculator(calc) if calc.wfs.S_qMM is None: calc.wfs.set_positions(calc.spos_ac) h = calc.wfs.eigensolver.calculate_hamiltonian_matrix( hamiltonian=calc.hamiltonian, wfs=calc.wfs, kpt=calc.wfs.kpt_u[kpt]) s = calc.wfs.S_qMM[kpt] tri2full(h) tri2full(s) h *= Hartree h -= calc.get_fermi_level() * s remove_pbc(atoms=calc.atoms, h=h, s=s) return h, s
def get_h_and_s(calc, direction='x'): ''' The function below performs 1. tri2full 2. *= Hartree ''' h_skmm, s_kmm = get_lcao_hamiltonian(calc) ''' The code below performs 1. remove_pbc 2. align_fermi ''' d = 'xyz'.index(direction) nspins, nkpts = h_skmm.shape[:2] for s in range(nspins): for k in range(nkpts): if s == 0: remove_pbc(atoms, h_skmm[s, k], s_kmm[k], d) else: remove_pbc(atoms, h_skmm[s, k], None, d) h_skmm[s, k] -= s_kmm[k] * calc.occupations.get_fermi_level() return h_skmm, s_kmm
txt='pt_h2_lcao_scat.txt', mixer=Mixer(0.1, 5, weight=100.0), symmetry={ 'point_group': False, 'time_reversal': False }) atoms.set_calculator(calc) atoms.get_potential_energy() # Converge everything! Ef = atoms.calc.get_fermi_level() H_skMM, S_kMM = get_lcao_hamiltonian(calc) # Only use first kpt, spin, as there are no more H, S = H_skMM[0, 0], S_kMM[0] H -= Ef * S remove_pbc(atoms, H, S, 0) # Dump the Hamiltonian and Scattering matrix to a pickle file pickle.dump((H, S), open('scat_hs.pickle', 'wb'), 2) ######################## # Left principal layer # ######################## # Use four Pt atoms in the lead, so only take those from before atoms = atoms[:4].copy() atoms.set_cell([4 * a, L, L]) # Attach a GPAW calculator calc = GPAW( h=0.3,
occupations=FermiDirac(width=0.1), kpts=(1, 1, 1), mode='lcao', txt='pt_h2_lcao_scat.txt', mixer=Mixer(0.1, 5, weight=100.0), symmetry={'point_group': False, 'time_reversal': False}) atoms.set_calculator(calc) atoms.get_potential_energy() # Converge everything! Ef = atoms.calc.get_fermi_level() H_skMM, S_kMM = get_lcao_hamiltonian(calc) # Only use first kpt, spin, as there are no more H, S = H_skMM[0, 0], S_kMM[0] H -= Ef * S remove_pbc(atoms, H, S, 0) # Dump the Hamiltonian and Scattering matrix to a pickle file pickle.dump((H, S), open('scat_hs.pickle', 'wb'), 2) ######################## # Left principal layer # ######################## # Use four Pt atoms in the lead, so only take those from before atoms = atoms[:4].copy() atoms.set_cell([4 * a, L, L]) # Attach a GPAW calculator calc = GPAW(h=0.3, xc='PBE',