def test_si_scf_cg(): si = bulk('Si', 'fcc', 10.2 * Bohr) kpts = np.asarray([[0.1250000, 0.1250000, 0.1250000, 1.00], [0.1250000, 0.1250000, 0.3750000, 3.00], [0.1250000, 0.1250000, 0.6250000, 3.00], [0.1250000, 0.1250000, 0.8750000, 3.00], [0.1250000, 0.3750000, 0.3750000, 3.00], [0.1250000, 0.3750000, 0.6250000, 6.00], [0.1250000, 0.3750000, 0.8750000, 6.00], [0.1250000, 0.6250000, 0.6250000, 3.00], [0.3750000, 0.3750000, 0.3750000, 1.00], [0.3750000, 0.3750000, 0.6250000, 3.00]]) calc = Espresso(pw=18.0 * Rydberg, calculation='scf', kpts=kpts, tprnfor=True, tstress=True, occupations='smearing', smearing='marzari-vanderbilt', degauss=0.05, convergence={'energy': 1e-6, 'mixing': 0.7, 'maxsteps': 100, 'diag': 'cg'}, outdir='si_scf') si.set_calculator(calc) calc.calculate(si) assert np.allclose(si.get_potential_energy(), -152.90087195020132)
def getCalculator(self): """Mangle the supplied settings and return an Abinit ASE Calculator object. The pseudopotential path is semi-hardcoded. Because crap. """ ecut = self.settings["settings"]["cutoff_pw"] xc = self.settings["settings"]["xc"] sigma = self.settings["settings"]["sigma"] smearing = str(self.settings["settings"]["smearing"]) kpts = list(self.settings["kpoints"]) pseudopotential = self.settings["pseudopotential"] from espresso import Espresso calc = Espresso( mode="scf", pw=ecut, # density cutoff automatically 4*ecut ? kpts=kpts, xc=xc, outdir='./', smearing=smearing, sigma=sigma, psppath=pseudopotential, output={ 'removewf': True, 'removesave': True }, parflags='-npool 4', ) return calc
def test_relax_co_ase_bfgs(tmpdir): tmpdir.chdir() co = Atoms('CO', [[2.256 * Bohr, 0.0, 0.0], [0.0, 0.0, 0.0]]) co.set_cell(np.ones(3) * 12.0 * Bohr) calc = Espresso(pw=24.0 * Rydberg, dw=144.0 * Rydberg, kpts='gamma', xc='PBE', calculation='scf', ion_dynamics=None, spinpol=False, outdir='qe_ase_bfgs') co.set_calculator(calc) minimizer = BFGS(co, logfile='minimizer.log', trajectory='relaxed.traj') minimizer.run(fmax=0.01) print('ase(scf) bfgs:') print('energy: ', co.get_potential_energy()) print('positions: ', co.positions) print('forces: ', co.get_forces())
def runcalc(self, atoms): if not self.ready: self.arg['outdir'] = self.outdirprefix + '_%04d' % self.counter self.counter += 1 if self.firststep: self.esp = Espresso(**self.arg) self.esp.set_atoms(atoms) self.esp.get_potential_energy(atoms) self.esp.save_chg(self.equilibriumdensity) self.firststep = False self.esp.close() else: self.arg['startingpot'] = 'file' self.esp = Espresso(**self.arg) self.esp.set_atoms(atoms) self.esp.initialize(atoms) self.esp.load_chg(self.equilibriumdensity) self.esp.get_potential_energy(atoms) self.esp.close() self.ready = True
def class_instance(): temp_service_config_path = os.path.join("/tmp", SERVICE_CONFIG_NAME) try: # Placing the service_manifest.yml in the tmp directory shutil.copyfile(SERVICE_CONFIG_PATH, temp_service_config_path) from espresso import Espresso yield Espresso() finally: # Delete the service_manifest.yml os.remove(temp_service_config_path)
def test_relax_co_qe_bfgs(): co = Atoms('CO', [[2.256 * Bohr, 0.0, 0.0], [0.0, 0.0, 0.0]]) co.set_cell(np.ones(3) * 12.0 * Bohr) calc = Espresso(pw=24.0 * Rydberg, dw=144.0 * Rydberg, kpts='gamma', xc='PBE', calculation='relax', ion_dynamics='bfgs', spinpol=False, outdir='qe_bfgs') co.set_calculator(calc) calc.calculate(co) print('qe bfgs:') print('energy: ', co.get_potential_energy()) print('positions: ', co.positions) print('forces: ', co.get_forces())
def test_starbuzz_coffee(self): beverage_1 = Espresso() self.simulate(beverage_1) beverage_2 = DarkRoast() beverage_2 = Mocha(beverage_2) beverage_2 = Mocha(beverage_2) beverage_2 = Whip(beverage_2) self.simulate(beverage_2) beverage_3 = HouseBlend() beverage_3 = Soy(beverage_3) beverage_3 = Mocha(beverage_3) beverage_3 = Whip(beverage_3) self.simulate(beverage_3)
def test_co_espresso_vibrations(tmpdir): tmpdir.chdir() co = Atoms('CO', positions=[[1.19382389081, 0.0, 0.0], [0.0, 0.0, 0.0]]) co.set_cell(np.ones(3) * 12.0 * Bohr) calc = Espresso(pw=34.0 * Rydberg, dw=144.0 * Rydberg, kpts='gamma', xc='PBE', calculation='scf', ion_dynamics='None', spinpol=False, outdir='vibs') co.set_calculator(calc) # calculate the vibrations vib = Vibrations(co, indices=range(len(co)), delta=0.01, nfree=2) vib.run() assert np.allclose(vib.get_energies(), REF_ENE)
calc = Espresso( pw=500, # IMP | (ev) nbands=-50, # ######################################################################### # kpts=3 * (1, ), kpts=(6, 6, 6), kptshift=(0, 0, 0), calculation='relax', ion_dynamics='bfgs', fmax=0.05, xc='PBE', # IMP # ######################################################################### outdir="calcdir", U_projection_type='atomic', site=site_config, tot_magnetization=-1, occupations='smearing', dipole={'status': False}, field={'status': False}, output={ 'disk_io': 'default', 'avoidio': True, 'removewf': True, 'removesave': True, 'wf_collect': False, }, convergence={ 'energy': 1e-4, 'mixing': 0.1, 'maxsteps': 300, 'diag': 'david', }, smearing='fd', sigma=0.1, # ######################################################################### # parflags=pflags, alwayscreatenewarrayforforces=True, verbose='low', )
def test_al_scf_david(): al = bulk('Al', 'fcc', 7.5 * Bohr) kpts = np.asarray([[0.0625000, 0.0625000, 0.0625000, 1.00], [0.0625000, 0.0625000, 0.1875000, 3.00], [0.0625000, 0.0625000, 0.3125000, 3.00], [0.0625000, 0.0625000, 0.4375000, 3.00], [0.0625000, 0.0625000, 0.5625000, 3.00], [0.0625000, 0.0625000, 0.6875000, 3.00], [0.0625000, 0.0625000, 0.8125000, 3.00], [0.0625000, 0.0625000, 0.9375000, 3.00], [0.0625000, 0.1875000, 0.1875000, 3.00], [0.0625000, 0.1875000, 0.3125000, 6.00], [0.0625000, 0.1875000, 0.4375000, 6.00], [0.0625000, 0.1875000, 0.5625000, 6.00], [0.0625000, 0.1875000, 0.6875000, 6.00], [0.0625000, 0.1875000, 0.8125000, 6.00], [0.0625000, 0.1875000, 0.9375000, 6.00], [0.0625000, 0.3125000, 0.3125000, 3.00], [0.0625000, 0.3125000, 0.4375000, 6.00], [0.0625000, 0.3125000, 0.5625000, 6.00], [0.0625000, 0.3125000, 0.6875000, 6.00], [0.0625000, 0.3125000, 0.8125000, 6.00], [0.0625000, 0.3125000, 0.9375000, 6.00], [0.0625000, 0.4375000, 0.4375000, 3.00], [0.0625000, 0.4375000, 0.5625000, 6.00], [0.0625000, 0.4375000, 0.6875000, 6.00], [0.0625000, 0.4375000, 0.8125000, 6.00], [0.0625000, 0.4375000, 0.9375000, 6.00], [0.0625000, 0.5625000, 0.5625000, 3.00], [0.0625000, 0.5625000, 0.6875000, 6.00], [0.0625000, 0.5625000, 0.8125000, 6.00], [0.0625000, 0.6875000, 0.6875000, 3.00], [0.0625000, 0.6875000, 0.8125000, 6.00], [0.0625000, 0.8125000, 0.8125000, 3.00], [0.1875000, 0.1875000, 0.1875000, 1.00], [0.1875000, 0.1875000, 0.3125000, 3.00], [0.1875000, 0.1875000, 0.4375000, 3.00], [0.1875000, 0.1875000, 0.5625000, 3.00], [0.1875000, 0.1875000, 0.6875000, 3.00], [0.1875000, 0.1875000, 0.8125000, 3.00], [0.1875000, 0.3125000, 0.3125000, 3.00], [0.1875000, 0.3125000, 0.4375000, 6.00], [0.1875000, 0.3125000, 0.5625000, 6.00], [0.1875000, 0.3125000, 0.6875000, 6.00], [0.1875000, 0.3125000, 0.8125000, 6.00], [0.1875000, 0.4375000, 0.4375000, 3.00], [0.1875000, 0.4375000, 0.5625000, 6.00], [0.1875000, 0.4375000, 0.6875000, 6.00], [0.1875000, 0.4375000, 0.8125000, 6.00], [0.1875000, 0.5625000, 0.5625000, 3.00], [0.1875000, 0.5625000, 0.6875000, 6.00], [0.1875000, 0.6875000, 0.6875000, 3.00], [0.3125000, 0.3125000, 0.3125000, 1.00], [0.3125000, 0.3125000, 0.4375000, 3.00], [0.3125000, 0.3125000, 0.5625000, 3.00], [0.3125000, 0.3125000, 0.6875000, 3.00], [0.3125000, 0.4375000, 0.4375000, 3.00], [0.3125000, 0.4375000, 0.5625000, 6.00], [0.3125000, 0.4375000, 0.6875000, 6.00], [0.3125000, 0.5625000, 0.5625000, 3.00], [0.4375000, 0.4375000, 0.4375000, 1.00], [0.4375000, 0.4375000, 0.5625000, 3.00]]) calc = Espresso(pw=15.0 * Rydberg, calculation='scf', kpts=kpts, tprnfor=True, tstress=True, occupations='smearing', smearing='marzari-vanderbilt', degauss=0.05, outdir='al_scf') al.set_calculator(calc) calc.calculate(al) assert np.allclose(al.get_potential_energy(), -74.44991079398747) assert np.allclose(al.get_forces(), np.zeros(3)) assert np.allclose(al.get_stress(), np.array([-0.02784864, -0.02784864, -0.02784864, -0.0, -0.0, -0.0]))
def main(): beverage = Espresso() print(beverage.get_description(), '$', beverage.cost()) beverage = HouseBlend() print(beverage.get_description(), '$', beverage.cost()) beverage = Mocha(beverage) print(beverage.get_description(), '$', beverage.cost()) beverage = Whip(beverage) print(beverage.get_description(), '$', beverage.cost())
calc = Espresso( # atoms=None, pw=350.0, dw=None, fw=None, nbands=-10, # ######################################################################### kpts=3 * (1, ), kptshift=(0, 0, 0), fft_grid=None, calculation='relax', ion_dynamics='bfgs', nstep=None, constr_tol=None, fmax=0.05, cell_dynamics=None, press=None, dpress=None, cell_factor=None, cell_dofree=None, dontcalcforces=False, nosym=False, noinv=False, nosym_evc=False, no_t_rev=False, xc='PBE', beefensemble=False, printensemble=False, psppath=None, spinpol=False, noncollinear=False, spinorbit=False, # ######################################################################### outdir="calcdir", txt=None, calcstress=False, smearing='fd', sigma=0.1, fix_magmom=False, isolated=None, U=None, J=None, U_alpha=None, U_projection_type='atomic', nqx1=None, nqx2=None, nqx3=None, exx_fraction=None, screening_parameter=None, exxdiv_treatment=None, ecutvcut=None, tot_charge=None, charge=None, tot_magnetization=-1, occupations='smearing', dipole={'status': False}, field={'status': False}, output={ # Default # 'disk_io': 'default', # 'avoidio': False, # 'removewf': True, # 'removesave': False, # 'wf_collect': False, 'disk_io': 'default', 'avoidio': True, 'removewf': True, 'removesave': True, 'wf_collect': False, }, convergence={ # Default # 'energy': 1e-6, # 'mixing': 0.7, # 'maxsteps': 100, # 'diag': 'david', 'energy': 1e-3, 'mixing': 0.1, 'maxsteps': 300, 'diag': 'david', }, startingpot=None, startingwfc=None, ion_positions=None, # ######################################################################### # parflags=None, # parflags=pflags, alwayscreatenewarrayforforces=True, verbose='low', # automatically generated list of parameters # some coincide with ase-style names iprint=None, tstress=None, tprnfor=None, dt=None, lkpoint_dir=None, max_seconds=None, etot_conv_thr=None, forc_conv_thr=None, tefield=None, dipfield=None, lelfield=None, nberrycyc=None, lorbm=None, lberry=None, gdir=None, nppstr=None, nbnd=None, ecutwfc=None, ecutrho=None, ecutfock=None, force_symmorphic=None, use_all_frac=None, one_atom_occupations=None, starting_spin_angle=None, degauss=None, nspin=None, ecfixed=None, qcutz=None, q2sigma=None, x_gamma_extrapolation=None, lda_plus_u=None, lda_plus_u_kind=None, edir=None, emaxpos=None, eopreg=None, eamp=None, clambda=None, report=None, lspinorb=None, esm_w=None, esm_efield=None, esm_nfit=None, london=None, london_s6=None, london_rcut=None, xdm=None, xdm_a1=None, xdm_a2=None, electron_maxstep=None, scf_must_converge=None, conv_thr=None, adaptive_thr=None, conv_thr_init=None, conv_thr_multi=None, mixing_beta=None, mixing_ndim=None, mixing_fixed_ns=None, ortho_para=None, diago_thr_init=None, diago_cg_maxiter=None, diago_david_ndim=None, diago_full_acc=None, efield=None, tqr=None, remove_rigid_rot=None, tempw=None, tolp=None, delta_t=None, nraise=None, refold_pos=None, upscale=None, bfgs_ndim=None, trust_radius_max=None, trust_radius_min=None, trust_radius_ini=None, w_1=None, w_2=None, wmass=None, press_conv_thr=None, # site=None, site=site_config, )
def test_Espresso(self): espresso = Espresso() self.simulate(espresso)