def gen_test_data(datadir: str, params_fd: dict, supercell): from gpaw.elph.electronphonon import ElectronPhononCoupling params_gs = copy.deepcopy(params_fd) atoms = Cluster(ase.build.bulk('C')) calc_gs = GPAW(**params_gs) atoms.calc = calc_gs atoms.get_potential_energy() atoms.calc.write("gs.gpw", mode="all") # Make sure the real space grid matches the original. # (basically we multiply the number of grid points in each dimension by the supercell dimension) params_fd['gpts'] = calc_gs.wfs.gd.N_c * list(supercell) if 'h' in params_fd: del params_fd['h'] del calc_gs if world.rank == 0: os.makedirs(datadir, exist_ok=True) calc_fd = GPAW(**params_fd) elph = ElectronPhononCoupling(atoms, calc=calc_fd, supercell=supercell, calculate_forces=True, name=f'{datadir}/elph') elph.run() calc_fd.wfs.gd.comm.barrier() elph = ElectronPhononCoupling(atoms, calc=calc_fd, supercell=supercell) elph.set_lcao_calculator(calc_fd) elph.calculate_supercell_matrix(dump=1)
def read_viewmol(self, filename): f = open(filename) # read the definition first definition = False for line in f: w = line.split() if not definition: if w[0] == '$coord': definition = True self.scale = float(w[1]) loa = Cluster([]) else: if w[0] == '$grad': # definition ends here self.definition = loa break else: # we assume this is a coordinate entry coo = (float(w[0]), float(w[1]), float(w[2])) loa.append(Atom(w[3], coo)) # get the iterations cycle = False for line in f: w = line.split() if not cycle: # search for the cycle keyword if w[0] == 'cycle=': cycle = True n_coo = 0 n_F = 0 self.images.append(Cluster([])) else: if n_coo < len(self.definition): n_coo += 1 coo = (float(w[0]), float(w[1]), float(w[2])) self[-1].append(Atom(w[3], coo)) elif n_F < len(self.definition): F = (float(w[0]), float(w[1]), float(w[2])) self[-1][n_F].F = F n_F += 1 if n_F == len(self.definition): cycle = False
def read(self, filename='trajectory.vmol', position=0): """Read atom configurations of step position""" self.file = None f = open(filename) # find coordinates loa = Cluster([]) coords = False for l in f.readlines(): if coords: w = l.split() loa.append(Atom(w[3].replace("\n", ""), (float(w[0]), float(w[1]), float(w[2]))))
h = 0.3 vac = 3.0 u0 = 0.180 epsinf = 80. st = 18.4 * 1e-3 * Pascal * m T = 298.15 vdw_radii = vdw_radii.copy() vdw_radii[1] = 1.09 atomic_radii = lambda atoms: [vdw_radii[n] for n in atoms.numbers] convergence = { 'energy': 0.1 / 8., 'density': 10., 'eigenstates': 10., } atoms = Cluster(molecule('H2O')) atoms.minimal_box(vac, h) calc = SolvationGPAW( xc='LDA', h=h, convergence=convergence, cavity=EffectivePotentialCavity( effective_potential=Power12Potential(atomic_radii, u0), temperature=T, surface_calculator=GradientSurface() ), dielectric=LinearDielectric(epsinf=epsinf), interactions=[SurfaceInteraction(surface_tension=st)] ) atoms.calc = calc atoms.get_potential_energy() atoms.get_forces()
# Wigner-Seitz ---------------------------------------- if 1: ws = WignerSeitz(calc.density.finegd, mol, calc) vr = ws.get_effective_volume_ratios() parprint('Wigner-Seitz:', vr) if len(lastres): equal(vr, lastres.pop(0), 1.e-10) results.append(vr) return results mol = Cluster(molecule('H2O')) mol.minimal_box(2.5, h=h) # calculate if 1: parprint('### fresh:') calc = GPAW(nbands=6, h=h, txt=None) if 1: calc.calculate(mol) calc.write(gpwname) lastres = run() # load previous calculation if 1: parprint('### reloaded:') calc = GPAW(gpwname, txt=None)
def get_unrelaxed_structure(): atoms = Cluster(ase.build.mx2('MoS2')) atoms.center(vacuum=vacuum_sep, axis=2) return atoms
from ase.build import molecule from ase import optimize from ase.vibrations.infrared import InfraRed from gpaw.cluster import Cluster from gpaw import GPAW, FermiDirac h = 0.22 atoms = Cluster(molecule('H2')) atoms.minimal_box(3.5, h=h) # relax the molecule calc = GPAW(h=h, occupations=FermiDirac(width=0.1)) atoms.calc = calc dyn = optimize.FIRE(atoms) dyn.run(fmax=0.05) atoms.write('relaxed.traj') # finite displacement for vibrations ir = InfraRed(atoms) ir.run()
from ase import Atom from gpaw import GPAW from gpaw.cluster import Cluster from gpaw.test import equal fname='H2_PBE.gpw' fwfname='H2_wf_PBE.gpw' txt = None # write first if needed try: c = GPAW(fname, txt=txt) c = GPAW(fwfname, txt=txt) except: s = Cluster([Atom('H'), Atom('H', [0,0,1])]) s.minimal_box(3.) c = GPAW(xc='PBE', h=.3, convergence={'density':1e-3, 'eigenstates':1e-3}) c.calculate(s) c.write(fname) c.write(fwfname, 'all') # full information c = GPAW(fwfname, txt=txt) E_PBE = c.get_potential_energy() try: # number of iterations needed in restart niter_PBE = c.get_number_of_iterations() except: pass dE = c.get_xc_difference('TPSS') E_1 = E_PBE + dE print "E PBE, TPSS=", E_PBE, E_1
def main__raman_ch4(structure, supercell, log): import ase.build from gpaw.lrtddft.spectrum import polarizability from gpaw.cluster import Cluster from gpaw import GPAW, FermiDirac #============================================= # Settings # Input structure relax_grid_sep = 0.22 # GPAW finite grid size vacuum_sep = 3.5 pbc = False if structure == 'ch4': def get_unrelaxed_structure(): atoms = Cluster(ase.build.molecule('CH4')) atoms.minimal_box(vacuum_sep, h=relax_grid_sep) return atoms elif structure == 'mos2': def get_unrelaxed_structure(): atoms = Cluster(ase.build.mx2('MoS2')) atoms.center(vacuum=vacuum_sep, axis=2) return atoms # Calculator (general settings) make_calc = functools.partial(GPAW, occupations=FermiDirac(width=0.1), symmetry={'point_group': False}, txt=log, ) # Relaxation settings make_calc_relax = functools.partial(make_calc, h=relax_grid_sep, ) # Args for computations on displaced structures raman_grid_sep = 0.25 # In the example, they use a larger spacing here than during relaxation. # (TODO: but why? On CH4 I observe that this to leads to equilibrium forces of # 0.067 ev/A, which seems to compromise our "energy minimum" state...) num_converged_bands = 10 num_total_bands = 20 make_calc_raman = functools.partial(make_calc, h=raman_grid_sep, convergence={ 'eigenstates': 1.e-5, 'bands': num_converged_bands, }, eigensolver='cg', nbands=num_total_bands, ) supercell_matrix = [[supercell[0], 0, 0], [0, supercell[1], 0], [0, 0, supercell[2]]] displacement_distance = 1e-2 # ---------- # Excitation settings (for polarizability) ex_kw = {'restrict': {'jend':num_converged_bands-1}} omega = 5.0 # eV get_polarizability = functools.partial(polarizability, omega=omega, form='v', tensor=True) subtract_equilibrium_polarizability = False #============================================= # Process disp_filenames = { 'ex': {'eq': 'raman-eq.ex.gz', 'disp': 'raman-{:04}.ex.gz'}, 'force': {'eq': 'force-set-eq.npy', 'disp': 'force-set-{:04}.npy'}, } # Relax unrelaxed_atoms = get_unrelaxed_structure() unrelaxed_atoms.pbc = pbc unrelaxed_atoms.calc = make_calc_relax() relax_atoms(outpath='relaxed.vasp', atoms=unrelaxed_atoms) # Phonopy displacements phonon = get_minimum_displacements(cachepath='phonopy_disp.yaml', unitcell=phonopy.interface.calculator.read_crystal_structure('relaxed.vasp', interface_mode='vasp')[0], supercell_matrix=supercell_matrix, displacement_distance=displacement_distance, ) # Computing stuff at displacements eq_atoms = Cluster(phonopy_atoms_to_ase(phonon.supercell)) eq_atoms.pbc = pbc if raman_grid_sep != relax_grid_sep: eq_atoms.minimal_box(vacuum_sep, h=raman_grid_sep) eq_atoms.calc = make_calc_raman() force_sets = make_force_sets_and_excitations(cachepath='force-sets.npy', disp_filenames=disp_filenames, phonon=phonon, atoms=eq_atoms, ex_kw=ex_kw, ) phonon.set_forces(force_sets) # Applying symmetry cart_pol_derivs = expand_raman_by_symmetry(cachepath='raman-cart.npy', phonon=phonon, disp_filenames=disp_filenames, get_polarizability=get_polarizability, ex_kw=ex_kw, subtract_equilibrium_polarizability=subtract_equilibrium_polarizability, ) # Phonopy part 2 gamma_eigendata = get_eigensolutions_at_q(cachepath='eigensolutions-gamma.npz', phonon=phonon, q=[0, 0, 0], ) # Raman of modes get_mode_raman(outpath='mode-raman-gamma.npy', eigendata=gamma_eigendata, cart_pol_derivs=cart_pol_derivs, )
from gpaw import GPAW from gpaw.cluster import Cluster from gpaw.pes.state import BoundState, H1s from gpaw.pes.ds_beta import CrossSectionBeta xc = 'PBE' ngauss = 2 h = .3 box = 3. gpwname = 'H1s.gpw' if 1: c = GPAW(xc='PBE', nbands=-1, h=h) s = Cluster([Atom('H')]) s.minimal_box(box, h=h) c.calculate(s) c.write(gpwname, 'all') else: c = GPAW(gpwname) s = c.get_atoms() c.converge_wave_functions() cm = s.get_center_of_mass() Ekin = 1. ekin = Ekin / Ha for form, title in [('L', 'length form'), ('V', 'velocity form')]: parprint('--', title) ds = [] for analytic in [True, False]:
from gpaw import GPAW, setup_paths from gpaw.cluster import Cluster from gpaw.eigensolvers import RMMDIIS from gpaw.xc.hybrid import HybridXC from gpaw.occupations import FermiDirac from gpaw.test import equal, gen if setup_paths[0] != '.': setup_paths.insert(0, '.') for atom in ['Be']: gen(atom, xcname='PBE', scalarrel=True, exx=True, yukawa_gamma=0.83, gpernode=149) h = 0.35 be = Cluster(Atoms('Be', positions=[[0, 0, 0]])) be.minimal_box(3.0, h=h) c = {'energy': 0.05, 'eigenstates': 0.05, 'density': 0.05} IP = 8.79 xc = HybridXC('LCY-PBE', omega=0.83) fname = 'Be_rsf.gpw' calc = GPAW(txt='Be.txt', xc=xc, convergence=c, eigensolver=RMMDIIS(), h=h, occupations=FermiDirac(width=0.0), spinpol=False) be.set_calculator(calc) # energy = na2.get_potential_energy() # calc.set(xc=xc)
def do_elph_symmetry( data_subdir: str, params_fd: dict, supercell, all_displacements: tp.Iterable[AseDisplacement], symmetry_type: tp.Optional[str], ): atoms = Cluster(ase.build.bulk('C')) # a supercell exactly like ElectronPhononCoupling makes supercell_atoms = atoms * supercell quotient_perms = list( interop.ase_repeat_translational_symmetry_perms(len(atoms), supercell)) # Make sure the grid matches our calculations (we repeated the grid of the groundstate) params_fd = copy.deepcopy(params_fd) params_fd['gpts'] = GPAW('gs.gpw').wfs.gd.N_c * list(supercell) if 'h' in params_fd: del params_fd['h'] wfs_with_sym = get_wfs_with_sym(params_fd=params_fd, supercell_atoms=supercell_atoms, symmetry_type=symmetry_type) calc_fd = GPAW(**params_fd) # GPAW displaces the center cell for some reason instead of the first cell elph = ElectronPhononCoupling(atoms, calc=calc_fd, supercell=supercell, calculate_forces=True) displaced_cell_index = elph.offset del elph # just showing that we don't use these anymore del calc_fd get_displaced_index = lambda prim_atom: displaced_cell_index * len( atoms) + prim_atom all_displacements = list(all_displacements) disp_atoms = [get_displaced_index(disp.atom) for disp in all_displacements] disp_carts = [ disp.cart_displacement(DISPLACEMENT_DIST) for disp in all_displacements ] disp_values = [ read_elph_input(data_subdir, disp) for disp in all_displacements ] full_Vt = np.empty((len(supercell_atoms), 3) + disp_values[0][0].shape) full_dH = np.empty((len(supercell_atoms), 3), dtype=object) full_forces = np.empty((len(supercell_atoms), 3) + disp_values[0][2].shape) lattice = supercell_atoms.get_cell()[...] oper_cart_rots = interop.gpaw_op_scc_to_cart_rots( wfs_with_sym.kd.symmetry.op_scc, lattice) if world.rank == 0: full_values = symmetry.expand_derivs_by_symmetry( disp_atoms, # disp -> atom disp_carts, # disp -> 3-vec disp_values, # disp -> T (displaced value, optionally minus equilibrium value) elph_callbacks(wfs_with_sym, supercell), # how to work with T oper_cart_rots, # oper -> 3x3 oper_perms=wfs_with_sym.kd.symmetry.a_sa, # oper -> atom' -> atom quotient_perms=quotient_perms, ) for a in range(len(full_values)): for c in range(3): full_Vt[a][c] = full_values[a][c][0] full_dH[a][c] = full_values[a][c][1] full_forces[a][c] = full_values[a][c][2] else: # FIXME # the symmetry part is meant to be done in serial but we should return back to # our original parallel state after it... pass return full_Vt, full_dH, full_forces
import numpy as np import ase.io from ase.calculators.vdwcorrection import vdWTkatchenko09prl from ase.parallel import barrier from ase.build import molecule from gpaw import GPAW from gpaw.analyse.hirshfeld import HirshfeldPartitioning from gpaw.analyse.vdwradii import vdWradii from gpaw.cluster import Cluster from gpaw.test import equal h = 0.4 s = Cluster(molecule('LiH')) s.minimal_box(3., h=h) def print_charge_and_check(hp, q=0, label='unpolarized'): q_a = np.array(hp.get_charges()) print('Charges ({0})='.format(label), q_a, ', sum=', q_a.sum()) equal(q_a.sum(), q, 0.03) return q_a # spin unpolarized if 1: out_traj = 'LiH.traj' out_txt = 'LiH.txt'
"""Check TDDFT ionizations with Yukawa potential.""" from ase.structure import molecule from ase.units import Hartree from gpaw import GPAW from gpaw.mpi import world from gpaw.cluster import Cluster from gpaw.occupations import FermiDirac from gpaw.test import equal from gpaw.eigensolvers import RMMDIIS from gpaw.lrtddft import LrTDDFT h2o = Cluster(molecule('H2O')) h2o.set_initial_magnetic_moments([2, -1, -1]) h2o.minimal_box(3.0, h=0.3) h2o_plus = Cluster(molecule('H2O')) h2o_plus.set_initial_magnetic_moments([2, -0.5, -0.5]) h2o_plus.minimal_box(3.0, h=0.3) def get_paw(): """Return calculator object.""" c = {'energy': 0.001, 'eigenstates': 0.001, 'density': 0.001} return GPAW(convergence=c, eigensolver=RMMDIIS(), xc='LCY-PBE:omega=0.83:unocc=True', parallel={'domain': world.size}, h=0.3, occupations=FermiDirac(width=0.0, fixmagmom=True)) calc = get_paw()
"""Check for change in total energy and lowest eigenvalue regarding to box.""" from ase import Atoms from ase.parallel import parprint from gpaw import GPAW, PoissonSolver from gpaw.cluster import Cluster from gpaw.test import equal h = 0.2 s = Cluster(Atoms('He')) s.minimal_box(3, h=h) c = GPAW( charge=1, txt='He_plus.txt', poissonsolver=PoissonSolver(use_charge_center=True), convergence={ # run fast 'energy': 0.001, 'eigenstates': 1e-4, 'density': 1e-3 }) s.set_calculator(c) e_small = s.get_potential_energy() eps_small = c.get_eigenvalues()[0] cell = s.get_cell() cell[0] *= 2 s.set_cell(cell) e_big = s.get_potential_energy() eps_big = c.get_eigenvalues()[0] parprint('Energies and Eigenvalues:')
txt=fname + '.log', occupations=FermiDirac(0.0, fixmagmom=True), convergence={ 'energy': 0.005, 'bands': nbands, 'eigenstates': 1e-4, 'density': 1e-3 }) atoms.set_calculator(calc) try: atoms.get_potential_energy() except KohnShamConvergenceError: pass if calc.scf.converged: for calcp in calc_parms: calc.set(**calcp) try: calc.calculate(system_changes=[]) except KohnShamConvergenceError: break if calc.scf.converged: calc.write(fname + '.gpw', mode='all') loa = Cluster(molecule('NaCl')) loa.minimal_box(border=6.0, h=0.25, multiple=16) loa.center() loa.translate([0.001, 0.002, 0.003]) nbands = 25 calc_me(loa, nbands)
from ase import Atom from gpaw import GPAW from gpaw.cluster import Cluster from gpaw.analyse.eed import ExteriorElectronDensity fwfname = 'H2_kpt441_wf.gpw' txt = None #txt = '-' # write first if needed try: c = GPAW(fwfname, txt=txt) s = c.get_atoms() except: s = Cluster([Atom('H'), Atom('H', [0, 0, 1])], pbc=[1, 1, 0]) s.minimal_box(3.) c = GPAW(xc='PBE', h=.3, kpts=(4, 4, 1), convergence={ 'density': 1e-3, 'eigenstates': 1e-3 }) c.calculate(s) c.write(fwfname, 'all') eed = ExteriorElectronDensity(c.wfs.gd, s) eed.write_mies_weights(c.wfs)
"""Test Hirshfeld for spin/no spin consitency""" from ase import Atom from gpaw import GPAW from ase.parallel import parprint from gpaw.analyse.hirshfeld import HirshfeldPartitioning from gpaw import FermiDirac from gpaw.cluster import Cluster from gpaw.test import equal h = 0.25 box = 3 atoms = Cluster() atoms.append(Atom('H')) atoms.minimal_box(box) volumes = [] for spinpol in [False, True]: calc = GPAW(h=h, occupations=FermiDirac(0.1, fixmagmom=True), experimental={'niter_fixdensity': 2}, spinpol=spinpol) calc.calculate(atoms) volumes.append(HirshfeldPartitioning(calc).get_effective_volume_ratios()) parprint(volumes) equal(volumes[0][0], volumes[1][0], 4e-9)
import os import sys from ase import Atoms, Atom, QuasiNewton, PickleTrajectory from gpaw import * from gpaw.cluster import Cluster from gpaw.utilities.viewmol import ViewmolTrajectory, write_viewmol s = Cluster([Atom('H'), Atom('H', (0, 0, 3))]) s.minimal_box(2) c = GPAW(h=0.3, nbands=2) s.set_calculator(c) vfname = 'traj.vmol' pfname = 'traj.pickle' vmt = ViewmolTrajectory(s, vfname) traj = PickleTrajectory(pfname, 'w', s) #c.attach(vmt.add, 100000) #sys.exit() # Find the theoretical bond length: dyn = QuasiNewton(s) dyn.attach(traj.write) dyn.attach(vmt.add) dyn.run(fmax=0.05) traj = PickleTrajectory(pfname, 'r') vfname2 = 'pickle.vmol' write_viewmol(traj, vfname2)
SKIP_VAC_CALC = True h = 0.24 vac = 4.0 epsinf = 78.36 rho0 = 0.00078 / Bohr**3 beta = 1.3 st = 72. * 1e-3 * Pascal * m convergence = { 'energy': 0.05 / 8., 'density': 10., 'eigenstates': 10., } atoms = Cluster(Atoms('Cl')) atoms.minimal_box(vac, h) if not SKIP_VAC_CALC: atoms.calc = GPAW(xc='PBE', h=h, charge=-1, convergence=convergence) Evac = atoms.get_potential_energy() print(Evac) else: # h=0.24, vac=4.0, setups: 0.9.11271, convergence: only energy 0.05 / 8 Evac = -3.83245253419 atoms.calc = SolvationGPAW( xc='PBE', h=h, charge=-1, convergence=convergence,
from gpaw.cluster import Cluster from gpaw.analyse.hirshfeld import HirshfeldPartitioning from gpaw.analyse.vdwradii import vdWradii h = 0.25 box = 3.0 molecule = 'Adenine-thymine_complex_stack' Energy = { 'PBE': [], 'vdW-DF': [], 'TS09': []} for molecule in ['Adenine-thymine_complex_stack']: ss = Cluster(Atoms(data[molecule]['symbols'], data[molecule]['positions'])) # split the structures s1 = ss.find_connected(0) s2 = ss.find_connected(-1) assert len(ss) == len(s1) + len(s2) c = GPAW(xc='PBE', h=h, nbands=-6, occupations=FermiDirac(width=0.1), txt=None) cdf = GPAW(xc='vdW-DF', h=h, nbands=-6, occupations=FermiDirac(width=0.1), txt=None) for s in [s1, s2, ss]: s.set_calculator(c) s.minimal_box(box, h=h) Energy['PBE'].append(s.get_potential_energy())
import gpaw.mpi as mpi from gpaw import GPAW from gpaw.cluster import Cluster txt = '-' txt = '/dev/null' load = False # load = True R = 0.7 # approx. experimental bond length a = 4. c = 4. H2 = Cluster([Atom('H', (a / 2, a / 2, (c - R) / 2)), Atom('H', (a / 2, a / 2, (c + R) / 2))], cell=(a, a, c)) H2.rotate(57, [1, 1, 1]) fname = 'H2.gpw' if (not load) or (not os.path.exists(fname)): calc = GPAW(xc='PBE', nbands=2, spinpol=False, txt=txt) H2.set_calculator(calc) H2.get_potential_energy() if load: calc.write(fname, 'all') else: calc = GPAW(fname, txt=txt) calc.initialize_wave_functions() fname = 'aed.plt'
from __future__ import print_function from ase.build import molecule from ase.parallel import parprint from gpaw import GPAW from gpaw.cluster import Cluster from gpaw.occupations import FixedOccupations, ZeroKelvin from gpaw.test import equal h = 0.4 box = 2 nbands = 2 txt = '-' txt = None H2 = Cluster(molecule('H2')) H2.minimal_box(box, h) convergence = {'energy': 0.01, 'eigenstates': 1.e-3, 'density': 1.e-2} if 1: # test ZeroKelvin vs FixedOccupations c = GPAW(h=h, nbands=nbands, occupations=ZeroKelvin(True), convergence=convergence, txt=txt) H2.set_calculator(c) E_zk = H2.get_potential_energy() c = GPAW(h=h, nbands=nbands, occupations=FixedOccupations([[2, 0]]),
from __future__ import print_function from ase import Atom from ase.neb import SingleCalculatorNEB from ase.optimize import FIRE from gpaw import GPAW from gpaw.cluster import Cluster txt = None mol = Cluster( [Atom('H'), Atom('H', [1, 0, 0]), Atom('H', [.5, .5, .5])], cell=[2, 2, 2], pbc=True) def set_calculators(all=False): c = GPAW(h=.3, convergence={ 'eigenstates': 0.1, 'energy': 0.1, 'density': 0.01 }, txt=txt) # c = EMT() n = len(images) if not all: n -= 2 neb.set_calculators([c] * n)
def get_unrelaxed_structure(): atoms = Cluster(ase.build.molecule('CH4')) atoms.minimal_box(vacuum_sep, h=relax_grid_sep) return atoms
import os import sys from gpaw.test import equal from ase import Atom from gpaw import GPAW, MixerDif from gpaw.cluster import Cluster h = .25 q = 0 box = 3. spin = True # B should not have spin contamination s = Cluster([Atom('B')]) s.minimal_box(box, h=h) s.set_initial_magnetic_moments([-1]) c = GPAW( xc='LDA', nbands=-3, charge=q, spinpol=spin, h=h, convergence={ 'eigenstates': 1e-3, 'density': 1e-2, 'energy': 0.1 }, )
from ase.vibrations.resonant_raman import ResonantRaman from gpaw.cluster import Cluster from gpaw import GPAW, FermiDirac from gpaw.lrtddft import LrTDDFT h = 0.25 atoms = Cluster('relaxed.traj') atoms.minimal_box(3.5, h=h) # relax the molecule calc = GPAW(h=h, occupations=FermiDirac(width=0.1), eigensolver='cg', symmetry={'point_group': False}, nbands=10, convergence={ 'eigenstates': 1.e-5, 'bands': 4 }) atoms.calc = calc # use only the 4 converged states for linear response calculation rr = ResonantRaman(atoms, LrTDDFT, exkwargs={'jend': 3}) rr.run()
CO.translate(-CO.get_center_of_mass()) p = CO.positions.copy() for i in range(2): equal(p[i, 1], 0, 1e-10) equal(p[i, 2], 0, 1e-10) # rotate the nuclear axis to the direction (1,1,1) CO.rotate(p[1] - p[0], (1, 1, 1)) q = CO.positions.copy() for c in range(3): equal(q[0, c], p[0, 0] / sqrt(3), 1e-10) equal(q[1, c], p[1, 0] / sqrt(3), 1e-10) # minimal box b = 4.0 CO = Cluster([Atom('C', (1, 0, 0)), Atom('O', (1, 0, R))]) CO.minimal_box(b) cc = CO.get_cell() for c in range(3): width = 2 * b if c == 2: width += R equal(cc[c, c], width, 1e-10) # minimal box, ensure multiple of 4 h = .13 b = [2, 3, 4] CO.minimal_box(b, h=h) cc = CO.get_cell() for c in range(3): # print "cc[c,c], cc[c,c] / h % 4 =", cc[c, c], cc[c, c] / h % 4
from __future__ import print_function from ase import Atom from ase.units import Hartree from gpaw import GPAW, FermiDirac, Davidson, PoissonSolver from gpaw.cluster import Cluster from gpaw.test import equal h = .35 box = 3. energy_tolerance = 0.0004 s = Cluster([Atom('Zn')]) s.minimal_box(box, h=h) E = {} E_U = {} for spin in [0, 1]: c = GPAW(h=h, spinpol=spin, xc='oldLDA', mode='lcao', basis='sz(dzp)', poissonsolver=PoissonSolver(relax='GS', eps=1e-7), parallel=dict(kpt=1), charge=1, occupations=FermiDirac(width=0.1, fixmagmom=spin)) s.set_calculator(c) E[spin] = s.get_potential_energy() c.set(setups=':d,3.0,1') E_U[spin] = s.get_potential_energy()
from gpaw.test import equal, gen from gpaw.eigensolvers import RMMDIIS from gpaw.cluster import Cluster from gpaw.lrtddft import LrTDDFT h = 0.35 # Gridspacing e_singlet = 4.61 e_singlet_lr = 5.54 if setup_paths[0] != '.': setup_paths.insert(0, '.') gen('Mg', xcname='PBE', scalarrel=True, exx=True, yukawa_gamma=0.38) c = {'energy': 0.05, 'eigenstates': 3, 'density': 3} na2 = Cluster(Atoms('Mg', positions=[[0, 0, 0]])) na2.minimal_box(2.5, h=h) calc = GPAW(txt='mg_ivo.txt', xc='LCY-PBE:omega=0.38:excitation=singlet', eigensolver=RMMDIIS(), h=h, occupations=FermiDirac(width=0.0), spinpol=False, convergence=c) na2.set_calculator(calc) na2.get_potential_energy() (eps_homo, eps_lumo) = calc.get_homo_lumo() e_ex = eps_lumo - eps_homo equal(e_singlet, e_ex, 0.15) calc.write('mg.gpw') c2 = GPAW('mg.gpw')