Lb = float(elem_list[6]) print("lattice constant b = ", Lb) Lc = float(elem_list[7]) print("lattice constant c = ", Lc) Lalpha = float(elem_list[8]) print("alpha angle = ", Lalpha) # First perform a regular SCF run calc = GPAW( mode=PW(400), maxiter=1500, spinpol=True, kpts=kpts, xc=xc, txt='-', occupations=FermiDirac(0.02), mixer=Mixer(0.01, 11, 100.0), ) atoms = bulk(element, struct, a=La, b=Lb, c=Lc, alpha=Lalpha) # sc,fcc,bcc,tetragonal,bct,hcp,rhmbohedral,orthorhombic # mlc, diamond,zincblende,rocksalt,cesiumchloride, fluorite, wurtzite atoms.set_calculator(calc) atoms.get_potential_energy() # Get the valence band maximum efermi = calc.get_fermi_level() Nk = len(calc.get_ibz_k_points()) Ns = calc.get_number_of_spins() eigval = np.array([[calc.get_eigenvalues(kpt=k, spin=s) for k in range(Nk)] for s in range(Ns)])
a = 5.43095 b = a / 2 c = b / 2 d = b + c si_nonortho = Atoms( [Atom('Si', (0, 0, 0)), Atom('Si', (a / 4, a / 4, a / 4))], cell=[(a / 2, a / 2, 0), (a / 2, 0, a / 2), (0, a / 2, a / 2)], pbc=True) # calculation with full symmetry calc = GPAW(nbands=-10, h=0.25, kpts=(2, 2, 2), occupations=FermiDirac(width=0.05), setups={0: 'hch1s'}) si_nonortho.set_calculator(calc) e = si_nonortho.get_potential_energy() niter = calc.get_number_of_iterations() calc.write('si_nonortho_xas_sym.gpw') # calculation without any symmetry calc = GPAW(nbands=-10, h=0.25, kpts=(2, 2, 2), occupations=FermiDirac(width=0.05), setups={0: 'hch1s'}, symmetry='off')
e=e, linspacestr=linspacestr, kptdensity=kptdensity, width=width, relativistic=relativistic, constant_basis=constant_basis, x=x) if id is None: continue # perform EOS step atoms.set_cell(cell * x, scale_atoms=True) # set calculator atoms.calc = GPAW(txt=name + '_' + code + '_' + str(n) + '.txt', xc='PBE', kpts=kpts, occupations=FermiDirac(width), parallel={'band': 1}, maxiter=777, idiotproof=False) atoms.calc.set(**kwargs) # remaining calc keywords t = time.time() atoms.get_potential_energy() c.write(atoms, name=name, mode=mode, e=e, linspacestr=linspacestr, kptdensity=kptdensity, width=width, relativistic=relativistic, constant_basis=constant_basis,
from ase.lattice import bulk from gpaw import GPAW, FermiDirac from gpaw.mpi import serial_comm from gpaw.test import equal from gpaw.xc.rpa import RPACorrelation from gpaw.xc.fxc import FXCCorrelation a0 = 5.43 Ni = bulk('Ni', 'fcc') Ni.set_initial_magnetic_moments([0.7]) calc = GPAW(mode='pw', kpts=(3, 3, 3), occupations=FermiDirac(0.001), setups={'Ni': '10'}, communicator=serial_comm) Ni.set_calculator(calc) E = Ni.get_potential_energy() calc.diagonalize_full_hamiltonian(nbands=50) rpa = RPACorrelation(calc, nfrequencies=8, skip_gamma=True) E_rpa = rpa.calculate(ecut=[50]) fxc = FXCCorrelation(calc, nlambda=16, nfrequencies=8, skip_gamma=True) E_fxc = fxc.calculate(ecut=[50]) equal(E_rpa, -7.826, 0.01) equal(E_fxc, -7.826, 0.01)
# Ground state calculation a = 5.431 atoms = bulk('Si', 'diamond', a=a) calc = GPAW(mode='pw', kpts={ 'density': 5.0, 'gamma': True }, parallel={ 'band': 1, 'domain': 1 }, xc='LDA', occupations=FermiDirac(0.001)) # use small FD smearing atoms.set_calculator(calc) atoms.get_potential_energy() # get ground state density # Restart Calculation with fixed density and dense kpoint sampling calc.set( kpts={ 'density': 15.0, 'gamma': False }, # dense kpoint sampling fixdensity=True) atoms.get_potential_energy() calc.diagonalize_full_hamiltonian(nbands=70) # diagonalize Hamiltonian calc.write('si_large.gpw', 'all') # write wavefunctions
from math import log from ase import Atoms from ase.units import Bohr from gpaw import GPAW, FermiDirac from gpaw.test import equal a = 4.0 h = 0.2 hydrogen = Atoms('H', [(a / 2, a / 2, a / 2)], cell=(a, a, a)) hydrogen.calc = GPAW(h=h, nbands=1, convergence={'energy': 1e-7}) e1 = hydrogen.get_potential_energy() equal(e1, 0.526939, 0.001) dens = hydrogen.calc.density c = dens.gd.find_center(dens.nt_sG[0]) * Bohr equal(abs(c - a / 2).max(), 0, 1e-13) kT = 0.001 hydrogen.calc.set(occupations=FermiDirac(width=kT)) e2 = hydrogen.get_potential_energy() equal(e1, e2 + log(2) * kT, 3.0e-7)
sys.__stdout__.write(x) raise RuntimeError('not silent') out, err = sys.stdout, sys.stderr sys.stdout = sys.stderr = Out() try: from gpaw import GPAW, FermiDirac from ase import Atom, Atoms a = 5.0 h = 0.2 calc = GPAW(h=h, nbands=1, kpts=(1, 1, 1), occupations=FermiDirac(width=1e-9), xc='PBE', txt=None) hydrogen = Atoms([Atom('H', (a / 2, a / 2, a / 2), magmom=0)], cell=(a, a, a), calculator=calc) f = hydrogen.get_forces() except: sys.stdout = out sys.stderr = err raise sys.stdout = out sys.stderr = err
atoms.positions[5:7, 0] = [4 * a + c, 4 * a + c + b] atoms.positions[:, 1:] = L / 2. pl_atoms1 = range(4) # Atomic indices of the left principal layer pl_atoms2 = range(8, 12) # Atomic indices of the right principal layer pl_cell1 = (L, L, 4 * a) # Cell for the left principal layer pl_cell2 = pl_cell1 # Cell for the right principal layer atoms.rotate('x', 'z') # Attach a GPAW calculator atoms.set_calculator( Transport(h=0.3, xc='PBE', basis='szp(dzp)', occupations=FermiDirac(width=0.1), kpts=(1, 1, 1), mode='lcao', save_file=False, txt='pt_h2_transport.txt', mixer=Mixer(0.1, 5, weight=100.0), pl_atoms=[pl_atoms1, pl_atoms2], pl_cells=[pl_cell1, pl_cell2], pl_kpts=(1, 1, 13), mol_atoms=range(4, 8), lead_restart=False, scat_restart=False, edge_atoms=[[0, 3], [0, 11]], analysis_data_list=['tc'], data_file='Pt_H2_nsc.dat', non_sc=True))
from ase import Atoms from gpaw import GPAW, FermiDirac from ase.optimize import QuasiNewton d = 0.74 # bond length a = 10.0 c = a / 2 atoms = Atoms('H2', positions=([c - d / 2, c, c], [c + d / 2, c, c]), cell=(a, a, a)) calc = GPAW(xc="PBE", eigensolver="dav", occupations=FermiDirac(0.0, fixmagmom=True), txt="H2.out", verbose=1) atoms.set_calculator(calc) ene = atoms.get_potential_energy() d0 = atoms.get_distance(0, 1) print("Initial energy = %18.10f eV" % ene) print("d0 = %18.10f angstrom" % d0) calc.write("H2.gpw") relax = QuasiNewton(atoms, logfile="relax.qn.log") relax.run(fmax=0.05)
BH.set_pbc(False) cf = GPAW(nbands=3, h=.3, txt=txt) BH.set_calculator(cf) e1 = BH.get_potential_energy() niter1 = cf.get_number_of_iterations() cf.write(fname, 'all') else: cf = GPAW(fname, txt=txt) wf = testSTM(cf) # finite system with spin fname = 'BH-spin_Sz2_wfs.gpw' BH.set_initial_magnetic_moments([1, 1]) if not load: BH.set_pbc(False) cf = GPAW(occupations=FermiDirac(0.1, fixmagmom=True), nbands=5, h=0.3, txt=txt) BH.set_calculator(cf) e2 = BH.get_potential_energy() niter2 = cf.get_number_of_iterations() cf.write(fname, 'all') else: cf = GPAW(fname, txt=txt) testSTM(cf) # periodic system if not load: BH.set_pbc(True) cp = GPAW(spinpol=True,
from ase.build import bulk from gpaw import GPAW, PW, FermiDirac from ase.units import Bohr, Hartree # Hydrogen atom: atoms = bulk("Si", "diamond", a=10.2631*Bohr) atoms.write("TEMP_Si.xsf") # gpaw calculator: ecutwfc = 15.0*Hartree calc = GPAW( mode=PW(ecutwfc), setups="hgh", xc="LDA_X+LDA_C_VWN", eigensolver="dav", spinpol=False, occupations=FermiDirac(0), kpts={"size": (3, 3, 3)}, txt="-") atoms.set_calculator(calc) e1 = atoms.get_potential_energy() calc.write("TEMP_Si.gpw") print("===================================================") print("Total energy : %18.10f eV = %18.10f Hartree" % (e1,e1/Hartree)) print("===================================================")
kpts += kshift atoms = bulk('MgO', 'rocksalt', a=4.212) if mode == 'pw': calc = GPAW(mode=PW(800), basis='dzp', xc='PBE', maxiter=300, kpts=kpts, parallel={ 'band': 1, 'domain': 1 }, setups={'Mg': '2'}, occupations=FermiDirac(0.01)) atoms.set_calculator(calc) E1 = atoms.get_potential_energy() from gpaw.xc.hybridg import HybridXC exx = HybridXC('EXX', method='acdf') E_hf1 = E1 + calc.get_xc_difference(exx) else: calc = GPAW(h=0.12, basis='dzp', kpts=kpts, xc='PBE', setups={'Mg': '2'}, parallel={ 'domain': 1, 'band': 1
#Initialize new calculations bulk_mat = bulk('Fe', 'bcc', a) bulk_mat.set_initial_magnetic_moments([initial_magmom]) bulk_mat = bulk_mat * (atoms, atoms, atoms) if (str(sys.argv[8]) == 'True'): del bulk_mat[[atom.index for atom in bulk_mat if atom.index == 0]] calc = GPAW(mode=PW(e_cut), nbands=nbands, xc='PBE', spinpol=True, kpts=(k_pts, k_pts, k_pts), occupations=FermiDirac(smear), txt=system_name + '.out') bulk_mat.set_calculator(calc) #Save the initial state of the calculations #calc.write('Fe_relaxer_initial.gpw') save_atoms(bulk_mat, e_cut, nbands, k_pts, smear, a, initial_magmom, 1, str(sys.argv[6])) saver = Gpw_save(calc, system_name + '_relaxed.gpw') traj = Trajectory(system_name + '_relaxed.traj', 'w', bulk_mat) ucf = UnitCellFilter(bulk_mat) relaxer = BFGS(ucf, logfile=system_name + '.txt') relaxer.attach(traj) relaxer.attach(saver) relaxer.run(fmax=0.025)
from ase.units import Bohr from ase.structure import bulk from gpaw import GPAW, FermiDirac from gpaw.atom.basis import BasisMaker from gpaw.response.df import DF from gpaw.mpi import serial_comm, rank, size from gpaw.utilities import devnull if rank != 0: sys.stdout = devnull # GS Calculation One a = 6.75 * Bohr atoms = bulk('C', 'diamond', a=a) calc = GPAW(h=0.2, kpts=(4, 4, 4), occupations=FermiDirac(0.001)) atoms.set_calculator(calc) atoms.get_potential_energy() calc.write('C.gpw', 'all') # Macroscopic dielectric constant calculation q = np.array([0.0, 0.00001, 0.]) w = np.linspace(0, 24., 241) df = DF(calc='C.gpw', q=q, w=(0., ), eta=0.001, ecut=50, hilbert_trans=False,