def get_potential_energy(in_file='input.traj'): """ Performs a ASE get_potential_energy() call with the ase-espresso calculator with the keywords defined inside the atoms object information. This can be a singlepoint calculation or a full relaxation depending on the keywords. """ # Read the input file from the current directory atoms = read(in_file) # Planewave basis set requires periodic boundary conditions atoms.set_pbc([1, 1, 1]) # Assign kpoints to be split across nodes if get_nnodes() > 1: if not sum(atoms.info['kpts']) == 1: atoms.info['parflags'] = '-npool {}'.format(get_nnodes()) # Setting up the calculator calc = espresso(**atoms.info) atoms.set_calculator(calc) # Perform the calculation and write trajectory from log. atoms.get_potential_energy() images = log_to_atoms(out_file='output.traj') # Save the calculator to the local disk for later use. try: calc.save_flev_output() except(RuntimeError): calc.save_output() return atoms_to_encode(images)
def __init__(self, ncalc = 1, outdirprefix = 'out', mtxt = 'multilog.txt', **kwargs ): """ In addition to the parameters of a standard espresso calculator, the number ncalc (default 1) of espresso calculators to be spawned should be specified. outdirprefix (default 'out') and mtxt (default 'multilog.txt') are optional. """ #stop old espresso calculators while len(espressos)>0: espressos.pop().stop() arg = kwargs.copy() arg['single_calculator'] = False arg['numcalcs'] = ncalc self.ncalc = ncalc self.outdirprefix = outdirprefix self.mtxt = mtxt self.done = [False]*self.ncalc self.calculators = [] for i in range(ncalc): arg['outdir'] = outdirprefix+'_%04d' % i arg['procrange'] = i esp = espresso(**arg) self.calculators.append(esp) espressos.append(esp)
def run(self): configuration = fileToJson('config.json') container = {} designDocumentName = configuration['designDocumentName'] subscriberPort = configuration['subscriberPort'] publisherPort = configuration['publisherPort'] couchbaseUrl = configuration['couchbaseUrl'] samplesViewName = configuration['samplesViewName'] metricsViewName = configuration['metricsViewName'] myScheduler = scheduler(60) #The scheduler checks every minute for a possible model update databaseConfiguration = couchbaseConfiguration(designDocumentName, couchbaseUrl) container['repository'] = lambda: repository(couchbaseUrl, designDocumentName, "") container['samplesRepository'] = lambda: repository(couchbaseUrl, designDocumentName, samplesViewName) container['metricsRepository'] = lambda: repository(couchbaseUrl, designDocumentName, metricsViewName) container['csvRepository'] = lambda: csvRepository(configuration['csvFileLocation']) container['subscriber'] = lambda: zmqProxy(str(subscriberPort), container['repository'](), container['scheduler'](), lambda x: container['modelUpdateTask']().createModelIfOld(x)) container['nupic'] = lambda: nupicProxy(container['repository']()) container['nupicConfiguration'] = lambda: nupicConfiguration(configuration['swarmConfiguration'], container['repository'](), configuration['csvFileLocation']) container['modelCreationTask'] = lambda: modelCreationTask(container['nupicConfiguration'] (), container['samplesRepository'](), container['metricsRepository'](), container['csvRepository'](), container['nupic']()) container['modelUpdateTask'] = lambda: modelUpdateTask(container['nupicConfiguration'](), container['modelCreationTask'](), configuration['swarmIntervalInHours']) container['espresso'] = lambda: espresso(publisherPort, subscriberPort) container['scheduler'] = lambda: myScheduler databaseConfiguration.createMapView(configuration['samplesViewName'], configuration['samplesMapFunction'], None) databaseConfiguration.createMapView(configuration['metricsViewName'], configuration['metricsMapFunction'], None) serviceLocator.setServiceLocator(container)
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 else: self.arg['startingpot'] = 'file' self.esp = espresso(**self.arg) self.esp.set_atoms(atoms) self.esp.load_chg(self.equilibriumdensity) self.esp.get_potential_energy(atoms) self.esp.stop() self.ready = True
def get_relaxed_calculation(in_file='output.traj'): """ Attach a stored calculator in the current directory to the provided atoms object. Then return the atoms object with the calculator attached. """ # Read the last geometry from the input file atoms = read(in_file) # Reinitialize the calculator from calc.tgz and attach it. calc = espresso(**atoms.info) calc.load_flev_output() atoms.set_calculator(calc) return atoms
def string2expr(string): """Compute minimal two-level sum-of-products form. Parameters ---------- string : string A string of zeros and ones representing a truthtable. Returns ------- expr : list Minimal two-level SOP form. Examples -------- A truthtable: |---+---+---+-----| | A | B | C | out | |---+---+---+-----| | 0 | 0 | 0 | 1 | | 0 | 0 | 1 | 0 | | 0 | 1 | 0 | 1 | | 0 | 1 | 1 | 1 | | 1 | 0 | 0 | 0 | | 1 | 0 | 1 | 1 | | 1 | 1 | 0 | 0 | | 1 | 1 | 1 | - | |---+---+---+-----| string = '1011010-' """ ninput = int(log(len(string), 2)) cover = [] for i in range(len(string)): row = bin(i).replace('0b', '') row = '0' * (ninput - len(row)) + row tmp = [int(k) + 1 for k in row] value = int(string[i]) if string[i] == '0' or string[i] == '1' else 2 cover.append((tuple(tmp), (value,))) cover = set(cover) result = list(espresso(ninput, 1, cover)) result = [i[0] for i in result] result = [''.join(['X' if i == 3 else str(i-1) for i in j]) for j in result] return result
def calc_energy(lat): global iter_num iter_num += 1 atoms = Atoms(name, scaled_positions=[(0, 0, 0), (0.5, 0.5, 0), (0.5, 0, 0.5), (0, 0.5, 0.5)], cell=[lat[0], lat[0], lat[1]], pbc=True) atoms.set_pbc((1, 1, 1)) calc = espresso(pw=pw, dw=dw, xc=xc, kpts=kpts, nbands=-20, sigma=0.1, spinpol=False, mode='scf', convergence={ 'energy': 1e-6 * 13.6, 'mixing': 0.1, 'nmix': 10, 'mix': 4, 'maxsteps': 500, 'diag': 'david' }, psppath='/home/users/vossj/suncat/psp/gbrv1.5pbe', output={ 'avoidio': True, 'removewf': True, 'wf_collect': False }, outdir='calcdir-' + str(iter_num)) atoms.set_calculator(calc) energy = atoms.get_potential_energy() print '%18f %23f %18f' % (lat[0], lat[1], energy) return energy
def qeCalc(self, xc, spinpol, restart): from espresso import espresso pspDict = { 'sherlock': { 'gbrv15pbe': '/home/vossj/suncat/psp/gbrv1.5pbe' }, 'suncat': { 'gbrv15pbe': '/nfs/slac/g/suncatfs/sw/external/esp-psp/gbrv1.5pbe' } } cluster = getCluster() psppath = pspDict[cluster][self.psp] return espresso( pw=self.pw, dw=self.pw * self.dwratio(), xc=xc, kpts=self.kpt(), spinpol=spinpol, convergence={ 'energy': self.econv(), 'mixing': self.mixing(), 'nmix': self.nmix(), 'maxsteps': self.maxstep(), 'diag': 'david' }, nbands=self.nbands(), sigma=self.sigma(), dipole={'status': True if self.kind() == 'surface' else False}, outdir='calcdir' # output directory , startingwfc='file' if restart else 'atomic+random', psppath=psppath, output={'removesave': True})
def vccalc(self): from espresso import espresso return espresso(pw=self.pw(), dw=self.pw() * self.dwrat(), xc=self.xc(), kpts=self.kpt(), nbands=self.nbands(), dipole={'status': self.dipole()}, sigma=self.sigma(), mode='vc-relax', cell_dynamics='bfgs', opt_algorithm='bfgs', cell_factor=2., spinpol=self.spinpol(), outdir='calcdir', output={'removesave': True}, psppath=self.psppath(), convergence={ 'energy': self.econv(), 'mixing': self.mixing(), 'nmix': self.nmix(), 'maxsteps': self.maxstep(), 'diag': 'david' })
def evaluate(args): x = str(args['xc'][0]) be = bool(str(args['beefensemble'][0])) pe = bool(str(args['printensemble'][0])) kpoints = tuple(float(args['kpts'][0][0]), float(args['kpts'][0][1]), float(args['kpts'][0][2])) p = float(args['pw'][0]) d = float(args['dw'][0]) sp = bool(args['spinpol'][0]) pflags = str(args['parflags'][0]) odir = str(args['outdir'][0]) print(x, be, pe, kpoints, p, d, sp, pflags, odir) calcargs = dict( xc=x, beefensemble=be, printensemble=pe, kpts=kpoints, #only need 1 kpt in z-direction pw=p, dw=d, spinpol=sp, parflags=pflags, outdir=odir) calc = espresso(**calcargs) atoms = io.read( 'Pt_111.json') #Read in the structure built by the other script atoms.set_calculator(calc) energy = atoms.get_potential_energy( ) #this is the potential energy of the electrons as computed by DFT. It will be closely related to the enthalpy. f = open('converged.log', 'w') f.write(str(energy)) f.close() return energy
def get_energy(x): global iteration iteration +=1 atoms = make_cluster(element1,element2,x) calc = espresso(pw=500, dw=5000, xc='BEEF-vdW', kpts='gamma', nbands=-20, sigma=0.1, convergence = {'energy':0.0005, 'mixing':0.1, 'nmix':10, 'maxsteps':500, 'diag':'david', }, outdir='calcdir_'+str(iteration), ) atoms.set_calculator(calc) energy = atoms.get_potential_energy() print('%20.8f%20.8f' % (x,energy)) f = open('out%04i.energy' % iteration, 'w') f.write(repr(x) + ' ' + str(energy)) f.close() # cleanup calc.stop() del calc os.system('rm -r calcdir_'+str(iteration)) return energy
'maxsteps': 1000, 'diag': 'cg' } Pt_slab = surface(Pt, (1, 1, 1), 2) Pt_slab.center(vacuum=10, axis=2) CO_molecule = molecule('CO') CO_molecule.center(10) add_adsorbate(Pt_slab, CO_molecule, h, position=(2.5, 2.5)) constraint = FixAtoms( mask=[True, True, True, True, False, False, False, False]) Pt_slab.set_constraint(constraint) Pt_slab.calc = espresso(pw=current_pw, dw=current_pw * 10, kpts=(current_k, current_k, 1), xc='PBE', outdir='test_output', convergence=conv_dict) dyn = QuasiNewton(Pt_slab, trajectory='Pt+CO.traj') dyn.run(fmax=0.05) combined_energy = Pt_slab.get_potential_energy() print(combined_energy) f = open("Comb_" + str(current_pw) + "_" + str(current_k) + ".txt", "w") f.write(str(combined_energy) + '\n') f.close()
name = 'N2' # load N2 molecule and add 20.0 AA vacuum atoms = molecule('N2') atoms.center(10.0) calc = espresso( pw=500, # plane-wave cutoff dw=5000, # density cutoff xc='BEEF-vdW', # exchange-correlation functional kpts='gamma', # k-point sampling nbands=-10, # 10 extra bands besides the bands needed to hold # the valence electrons sigma=0.1, psppath='/home/vossj/suncat/psp/gbrv1.5pbe', # pseudopotential convergence={ 'energy': 1e-5, 'mixing': 0.1, 'nmix': 10, 'mix': 4, 'maxsteps': 500, 'diag': 'david' }, # convergence parameters beefensemble=True, printensemble=True, outdir='calcdir') # output directory for Quantum Espresso files atoms.set_calculator(calc) vibrateatoms = [atom.index for atom in atoms] dyn = QuasiNewton(atoms, logfile=name + '.log', trajectory=name + '.traj')
calc = espresso( pw=pw, dw=dw, xc=xc, kpts=kpts, spinpol=True, nbands=-30, occupations='smearing', #'smeraing', 'fixed', 'tetrahedra' smearing='fd', #Fermi-Dirac sigma=0.1, calcstress=True, mode='relax', nosym=True, beefensemble=True, convergence={ 'energy': 1e-6 * 13.6, 'mixing': 0.1, 'nmix': 10, 'mix': 4, 'maxsteps': 500, 'diag': 'david' }, psppath='/home/users/vossj/suncat/psp/gbrv1.5pbe', output={ 'avoidio': False, 'removewf': True, 'wf_collect': False }, outdir='calcdir', dipole={'status': True})
if metal2: atoms = bulk(metal, crystal, a=a, cubic=True) atoms.set_chemical_symbols(metal + '3' + metal2) else: atoms = bulk(metal, crystal, a) calc = espresso( pw=500, #plane-wave cutoff dw=5000, #density cutoff xc='BEEF-vdW', #exchange-correlation functional kpts=(k, k, k), #sampling grid of the Brillouin zone #(is internally folded back to the #irreducible Brillouin zone) nbands=-10, #10 extra bands besides the bands needed to hold #the valence electrons sigma=0.1, psppath='/home/vossj/suncat/psp/gbrv1.5pbe', #pseudopotential path convergence={ 'energy': 1e-5, 'mixing': 0.1, 'nmix': 10, 'mix': 4, 'maxsteps': 500, 'diag': 'david' }, #convergence parameters outdir='calcdir') atoms.set_pbc([1, 1, 1]) #periodic boundary conditions in all directions atoms.set_calculator(calc) #connect espresso to Pt structure energy = atoms.get_potential_energy() #this triggers a DFT calculation energies.append(energy)
for k in kpts: if metal2: atoms = bulk(metal, crystal, a=a, cubic=True) atoms.set_chemical_symbols(metal+'3'+metal2) else: atoms = bulk(metal, crystal, a) calc = espresso(pw=500, #plane-wave cutoff dw=5000, #density cutoff xc='BEEF-vdW', #exchange-correlation functional kpts=(k,k,k), #sampling grid of the Brillouin zone #(is internally folded back to the #irreducible Brillouin zone) nbands=-10, #10 extra bands besides the bands needed to hold #the valence electrons sigma=0.1, psppath='/home/vossj/suncat/psp/gbrv1.5pbe', #pseudopotential path convergence= {'energy':1e-5, 'mixing':0.1, 'nmix':10, 'mix':4, 'maxsteps':500, 'diag':'david' }, #convergence parameters outdir='calcdir') atoms.set_pbc([1,1,1]) #periodic boundary conditions in all directions atoms.set_calculator(calc) #connect espresso to Pt structure energy = atoms.get_potential_energy() #this triggers a DFT calculation energies.append(energy)
atoms = io.read('relaxed.traj') atoms.set_pbc((True, True, True)) kpts = (4, 4, 1) # make sure these settings are consistent with what you have been using! calc = espresso( pw=500, dw=5000, kpts=kpts, nbands=-20, sigma=0.1, xc='BEEF-vdW', psppath='/home/vossj/suncat/psp/gbrv1.5pbe', outdir='pdos', convergence={ 'mixing': 0.1, 'maxsteps': 200 }, output={ 'avoidio': True, 'removewf': True, 'wf_collect': False }, ) atoms.set_calculator(calc) energy = atoms.get_potential_energy() print 'energy:', energy dos = calc.calc_pdos(nscf=True, kpts=kpts, tetrahedra=False, sigma=0.2)
# set up espresso calculator with 20 extra bands # and 4x4x1 k-point sampling (for continuous surfaces) # use 'gamma' for clusters! calc = espresso( pw=500, #plane-wave cutoff dw=5000, #density cutoff xc='BEEF-vdW', #exchange-correlation functional kpts=(4, 4, 1), #k-point sampling FOR SURFACES # kpts=(1,1,1), #k-point sampling FOR CLUSTERS nbands=-20, #20 extra bands besides the bands needed to hold #the valence electrons sigma=0.1, psppath='/home/vossj/suncat/psp/gbrv1.5pbe', #pseudopotential path convergence={ 'energy': 1e-5, #convergence parameters 'mixing': 0.1, 'nmix': 10, 'mix': 4, 'maxsteps': 500, 'diag': 'david' }, dipole={'status': True}, #dipole correction to account for periodicity in z beefensemble=True, printensemble=True, outdir='calcdir') #output directory for Quantum Espresso files # attach the espresso calculator to the surface atoms.set_calculator(calc)
atoms.set_constraint(fixatoms) # set up espresso calculator with 20 extra bands # and 4x4x1 k-point sampling (for continuous surfaces) # use 'gamma' for clusters! calc = espresso(pw=500, #plane-wave cutoff dw=5000, #density cutoff xc='BEEF-vdW', #exchange-correlation functional kpts=(4,4,1), #k-point sampling FOR SURFACES # kpts=(1,1,1), #k-point sampling FOR CLUSTERS nbands=-20, #20 extra bands besides the bands needed to hold #the valence electrons sigma=0.1, psppath='/home/vossj/suncat/psp/gbrv1.5pbe', #pseudopotential path convergence= {'energy':1e-5, #convergence parameters 'mixing':0.1, 'nmix':10, 'mix':4, 'maxsteps':500, 'diag':'david' }, dipole={'status':True}, #dipole correction to account for periodicity in z beefensemble = True, printensemble =True, outdir='calcdir') #output directory for Quantum Espresso files # attach the espresso calculator to the surface atoms.set_calculator(calc) # optimize the structure until the maximum force is # at most 0.05 eV/AA
from ase.io import read from espresso import espresso from ase.optimize import QuasiNewton name = 'pt' slab_ads = read(name + '.traj') slab_ads.calc = espresso( pw=400, dw=4500, kpts=(6, 6, 1), xc='PBE', outdir='E_slab_ads', #espresso outdirectory saved #here convergence={ 'energy': 1e-6, 'mixing': 0.05, 'mixing_mode': 'local-TF', 'maxsteps': 1000, 'diag': 'cg' }) relax_slab_ads = QuasiNewton(slab_ads, logfile=(name + '_opt.log'), trajectory=(name + '_opt.traj'), restart=(name + '_opt.pckl')) #ase output relax_slab_ads.run(fmax=0.05) E_slab_ads = slab_ads.get_potential_energy() print(E_slab_ads)
import copy from ase.io import read, write import shutil xc = 'BEEF' # Setup ASE calculator (e.g. QE). calc = espresso(mode='scf', outdir='ekspressen', pw=500., dw=5000., xc=xc, kpts=(4, 4, 1), nbands=-20, occupations='smearing', sigma=0.1, smearing='gaussian', parflags='-npool 2', convergence={ 'energy': 1e-5, 'mixing': 0.25, 'maxsteps': 300 }, dipole={'status': True}, spinpol=False) # Optimize the initial and final states using a minimizer (MLMin, BFGS, FIRE ...) # Optimize the initial state using MLMin: slab = read('./structures/initial.traj') slab.set_calculator(copy.deepcopy(calc)) qn = MLMin(slab, trajectory='initial.traj')
# Find the distance between the two atoms to fix a = Atoms() a.append(atoms[atom1]) a.append(atoms[atom2]) d = a.get_distance(0, 1) # calculator setup, using the same settings as before calc = espresso( pw=500, dw=5000, kpts=kpts, # (4,4,1) FOR SURFACES and 'gamma' FOR CLUSTERS nbands=-10, xc='BEEF-vdW', psppath='/home/vossj/suncat/psp/gbrv1.5pbe', convergence={ 'energy': 1e-5, 'mixing': 0.1, 'nmix': 10, 'maxsteps': 500, 'diag': 'david' }, beefensemble=True, spinpol=False, outdir='calcdir', ) # attach the calculator atoms.set_calculator(calc) # Print the results to a file called "PES.dat" # this will write out the total energy at each fixed bond length f = open('PES.dat', 'w')
atoms.set_initial_magnetic_moments(magmoms) ################################### #Create Calculator ################################### calc = espresso(pw = pw_cutoff, dw = dw_cutoff, xc = xc, kpts = kpt, nbands = nbands, sigma = sigma, mode = 'vc-relax', cell_dynamics = 'bfgs', opt_algorithm = 'bfgs', cell_factor = 5., spinpol = spinpol, outdir=calcdir, output= {'avoidio':False, 'removewf':True, 'wf_collect':False}, convergence={'mixing': 0.1, 'maxsteps': 500, 'energy':5e-4, 'diag':'david', 'mixing_mode':'plain'} ) atoms.set_calculator(calc) energy = atoms.get_potential_energy() #trigger espresso to be launched print 'Optimized unit cell:' print calc.get_final_structure().cell
# Find the distance between the two atoms to fix a = Atoms() a.append(atoms[atom1]) a.append(atoms[atom2]) d = a.get_distance(0,1) # calculator setup, using the same settings as before calc = espresso(pw = 500, dw = 5000, kpts = kpts, # (4,4,1) FOR SURFACES and 'gamma' FOR CLUSTERS nbands = -10, xc = 'BEEF-vdW', psppath='/home/vossj/suncat/psp/gbrv1.5pbe', convergence = {'energy':1e-5, 'mixing':0.1, 'nmix':10, 'maxsteps':500, 'diag':'david' }, beefensemble=True, spinpol = False, outdir = 'calcdir', ) # attach the calculator atoms.set_calculator(calc) # Print the results to a file called "PES.dat" # this will write out the total energy at each fixed bond length f = open('PES.dat', 'w') print >> f,'newlength energy'
# File Management ################################### path = os.getcwd() + '/' files = [f for f in listdir(path) if isfile(join(path, f))] files.sort() for f in files: if f[-5:] == '.traj': traj = f atoms = io.read(traj) calc = espresso(pw=pw_cutoff, dw=dw_cutoff, xc=xc, kpts=kpt, nbands=nbands, sigma=sigma, spinpol=spinpol, dipole=dipole, convergence=convergence, outdir=calcdir, output=output, parflags=parflags) atoms.set_calculator(calc) energy = atoms.get_potential_energy() with open('energy.txt', 'w') as f: f.write(str(atoms.get_potential_energy()))
from ase import * from ase import io from ase.cluster.icosahedron import Icosahedron from ase.optimize import * from espresso import espresso # read in the cluster name = 'PtCu13' atoms = io.read('cluster.traj') #espresso calculator setup calc = espresso(pw=500, #plane-wave cutoff dw=5000, #density cutoff xc='BEEF-vdW', #exchange-correlation functional kpts='gamma', #k-point sampling. 'gamma' for (1,1,1) nbands=-10, #10 extra bands besides the bands needed to hold #the valence electrons sigma=0.1, psppath='/home/vossj/suncat/psp/gbrv1.5pbe', #pseudopotential path convergence= {'energy':1e-5, 'mixing':0.1, 'nmix':10, 'mix':4, 'maxsteps':500, 'diag':'david' }, #convergence parameters outdir='calcdir') #output directory for Quantum Espresso files atoms.set_calculator(calc) #connect espresso to cluster qn = QuasiNewton(atoms, trajectory=name+'.traj', logfile=name+'.log') #relax atoms qn.run(fmax=0.05) #until max force<=0.05 eV/AA
# # pseudopotentials=pseudopotentials, # ) calc = espresso( pw=300, dw=3000, xc='PBE', kpts=[1, 1, 1], sigma=0.1, smearing='mv', spinpol=False, convergence={ 'energy': 0.0001, 'mixing': 0.1, 'nmix': 10, 'maxsteps': 300, 'diag': 'david', }, output={ 'avoidio': True, 'removewf': True, 'wf_collect': False, 'removesave': True, }, outdir='calcdir', ) atoms.set_calculator(calc) # __|
from ase.data.molecules import molecule from espresso import espresso from ase.optimize import QuasiNewton from ase.vibrations import Vibrations from ase.thermochemistry import IdealGasThermo from ase.all import view, read, write atoms = molecule('N2') # molecular atoms.center(vacuum=10.0) atoms.set_cell([[10, 0, 0], [0, 10.1, 0], [0, 0, 10.2]]) calc = espresso(pw=500., dw=5000., nbands=-10, kpts=(1, 1, 1), xc='BEEF', outdir='calcdir', psppath="/scratch/users/colinfd/psp/gbrv", sigma=10e-4) atoms.set_calculator(calc) dyn = QuasiNewton(atoms, logfile='out.log', trajectory='out.traj') dyn.run(fmax=0.01) electronicenergy = atoms.get_potential_energy() vib = Vibrations(atoms) # run vibrations on all atoms vib.run() vib_energies = vib.get_energies() thermo = IdealGasThermo(
from scipy.optimize import * from espresso import espresso import os from ase.lattice import bulk iter = 0 atoms_list = [] calc = espresso(pw=800, dw=8000, kpts=kpts, nbands=-20, xc='BEEF', convergence={ 'energy': 1e-5, 'mixing': 0.1, 'maxsteps': 200, 'diag': 'david' }, dipole={'status': False}, spinpol=False, outdir='outdir', output={'removesave': True}) def get_energy(x): "Function to create an atoms object with lattice parameters specified by x and obtain its energy using calc." global iter iter += 1 a = x[0] atoms = bulk(symbols[0], crystalstructure='fcc', a=x)
from ase.data.molecules import molecule from espresso import espresso from ase.optimize import QuasiNewton from ase.vibrations import Vibrations from ase.thermochemistry import IdealGasThermo from ase.all import view, read, write atoms = molecule("NH3") # molecular atoms.center(vacuum=10.0) atoms.set_cell([[10, 0, 0], [0, 10.1, 0], [0, 0, 10.2]]) calc = espresso( pw=500.0, dw=5000.0, nbands=-10, kpts=(1, 1, 1), xc="BEEF", outdir="outdir", psppath="/scratch/users/colinfd/psp/gbrv", sigma=10e-4, ) atoms.set_calculator(calc) dyn = QuasiNewton(atoms, logfile="out.log", trajectory="out.traj") dyn.run(fmax=0.01) electronicenergy = atoms.get_potential_energy() vib = Vibrations(atoms) # run vibrations on all atoms vib.run() vib_energies = vib.get_energies()
from ase import io from espresso import espresso atoms = io.read('relaxed.traj') atoms.set_pbc((True,True,True)) kpts = (4,4,1) # make sure these settings are consistent with what you have been using! calc=espresso(pw=500, dw=5000, kpts=kpts, nbands=-20, sigma=0.1, xc='BEEF-vdW', psppath='/home/vossj/suncat/psp/gbrv1.5pbe', outdir='pdos', convergence = {'mixing':0.1,'maxsteps':200}, output = {'avoidio':True,'removewf':True,'wf_collect':False}, ) atoms.set_calculator(calc) energy = atoms.get_potential_energy() print 'energy:',energy dos = calc.calc_pdos(nscf=True, kpts=kpts, tetrahedra=False, sigma=0.2) #save dos and pdos into pickle file f = open('out_dos.pickle', 'w')
print('Espresso Version' + esp.__version__) # Tell it where the files are, we are expecting at least one FeedLog and one Metadata file dataFolder = '/Users/xusy/Data/Espresso/Schlichting R58E02/MS48/' # dataFolder = '/Users/xusy/Library/Mobile Documents/com~apple~CloudDocs/EspressoManu/Data and Python Notebooks Organized by Figure/Figure 4 Trh R50H05/validFeeds/R50CsCh/' # dataFolder = '/Users/xusy/Library/Mobile Documents/com~apple~CloudDocs/EspressoManu/Data and Python Notebooks Organized by Figure/Figure 4 Trh R50H05/validFeeds/TrhCsCh/' # feedDataFolder = dataFolder + 'Feeds' feedDataFolder = dataFolder # Make a folder for the pictures you are about to dump, if, after checking, there is no existing "images" folder imagepath=dataFolder+'/' 'images/' mainDataPathList=os.listdir(dataFolder) if [s for s in mainDataPathList if 'images' in s]==[]: os.mkdir(imagepath) allFeedData = esp.espresso(feedDataFolder, expt_duration_minutes=1400) CPalette = createEspressoPalette(allFeedData) #%% dataFolder = '/Users/xusy/Library/Mobile Documents/com~apple~CloudDocs/EspressoManu/Data and Python Notebooks Organized by Figure/Figure 4 Trh R50H05/validFeeds/TrhCsCh/' allSpeedData = EspressoLocomotion.EspressoLocomotion(dataFolder, 0, 120) #%% allSpeedData.plotBoundedSpeedLines(colorBy = 'Temperature', col = 'Status', rp = '600s') #%% # resultsDf = TrhCsCh.metaDataDf
from ase.data.molecules import molecule from espresso import espresso from ase.optimize import QuasiNewton from ase.vibrations import Vibrations from ase.thermochemistry import IdealGasThermo from ase.all import view,read,write atoms = molecule('H2') # molecular atoms.center(vacuum = 10.0) atoms.set_cell([[10,0,0],[0,10.1,0],[0,0,10.2]]) calc = espresso(pw = 500., dw = 5000., nbands = -10, kpts=(1, 1, 1), xc = 'BEEF', outdir='outdir', psppath = "/scratch/users/colinfd/psp/gbrv", sigma = 10e-4) atoms.set_calculator(calc) dyn = QuasiNewton(atoms,logfile='out.log',trajectory='out.traj') dyn.run(fmax=0.01) electronicenergy = atoms.get_potential_energy() vib = Vibrations(atoms) # run vibrations on all atoms vib.run() vib_energies = vib.get_energies() thermo = IdealGasThermo(vib_energies=vib_energies,
calc = espresso( pw=500, #plane-wave cutoff dw=5000, #density cutoff xc='PBE', #exchange-correlation functional kpts=(5, 5, 1), #k-point sampling; nbands=-20, #20 extra bands besides the bands needed to hold sigma=0.1, #mode = 'vc-relax', #cell_dynamics = 'bfgs', #opt_algorithm = 'bfgs', #fmax = 0.05, nosym=True, convergence={ 'energy': 1e-5, 'mixing': 0.1, 'nmix': 10, 'mix': 4, 'maxsteps': 500, 'diag': 'david' }, #convergence parameters dipole={'status': True}, #dipole correction to account for periodicity in z output={ 'avoidio': False, 'removewf': True, 'wf_collect': False }, spinpol=False, parflags='-npool 2', outdir='calcdir') #output directory for Quantum Espresso files
atoms = bulk(metal, crystal, a=a * i, cubic=True) atoms.set_chemical_symbols(metal + '2' + metal2 + '2') else: atoms = bulk(metal, crystal, a * i, cubic=True) atoms.set_pbc((1, 1, 1)) calc = espresso(pw=pw, dw=dw, xc=xc, kpts=kpts, nbands=-20, sigma=0.1, mode='scf', convergence={ 'energy': 1e-6, 'mixing': 0.1, 'nmix': 10, 'mix': 4, 'maxsteps': 500, 'diag': 'david' }, psppath='/home/vossj/suncat/psp/gbrv1.5pbe', output={ 'avoidio': True, 'removewf': True, 'wf_collect': False }, outdir='calcdir') atoms.set_calculator(calc) volumes.append(atoms.get_volume()) energy = atoms.get_potential_energy() energies.append(energy)
(kpts[0], kpts[1], kpts[2], run)) atoms.rattle(stdev=0.05) for atom in atoms: atom.magmom = 0 calc = espresso(pw=pw, dw=dw, kpts=kpts, xc=xc, psppath=psppath, outdir='outdir', spinpol=False, convergence={ 'energy': 1e-5, 'mixing': 0.1, 'nmix': 10, 'mixing_mode': 'local-TF', 'maxsteps': 200, 'diag': 'david' }, output={'removesave': True}, dipole=dipole) atoms.set_calculator(calc) calc.atoms2species() calc.nbands = int(-1 * calc.get_nvalence()[0].sum() / 5.) #40% extra bands qn = QuasiNewton(atoms, logfile='qn.log', force_consistent=False)
kpts = 'gamma' else: print "Wrong number of metal atoms! Check your input trajectory!" exit() params = {'pw':500, 'dw':5000, 'kpts':kpts, 'nbands':-20, 'xc':'BEEF-vdW', 'psppath':'/home/vossj/suncat/psp/gbrv1.5pbe', 'convergence':{'energy':1e-5, 'mixing':0.1, 'nmix':10, 'maxsteps':500, 'diag':'david'}, 'spinpol':False} calc = espresso(outdir = 'calcdir', **params) # regular espresso calculator calcvib = vibespresso(outdirprefix = 'vibdir', **params) # special calculator for the vibration calculations atoms.set_calculator(calc) # attach calculator to the atoms energy = atoms.get_potential_energy() # caclulate the energy, to be used to determine G # vibrate N and H atoms vibrateatoms = [atom.index for atom in atoms if atom.symbol in ['H','N']] # calculate the vibrational modes for all N and H atoms atoms.set_calculator(calcvib) # attach vibrations calculator to the atoms # Calculate vibrations vib = Vibrations(atoms,indices=vibrateatoms,delta=0.03) # define a vibration calculation vib.run() # run the vibration calculation vib.summary(method='standard') # summarize the calculated results
#Main Script ################################################################################### atoms = io.read('init.traj') ################################### #Create Calculator ################################### calc = espresso(pw=pw_cutoff, dw=pw_cutoff * 10, xc=xc, kpts=kpt, nbands=nbands, sigma=sigma, mode='vc-relax', cell_dynamics='bfgs', opt_algorithm='bfgs', cell_factor=5., spinpol=spinpol, outdir=calcdir, output=output, psppath='/nfs/slac/g/suncatfs/sw/external/esp-psp/gbrv1.5pbe', convergence=convergence) atoms.set_calculator(calc) energy = atoms.get_potential_energy() #trigger espresso to be launched io.write('intermediate.traj', calc.get_final_structure()) atoms = io.read('intermediate.traj') atoms.set_calculator(calc) energy = atoms.get_potential_energy() #trigger espresso to be launched
'mixing': 0.1, 'maxsteps': 500, 'nmix': 10, 'energy': 5e-4, 'diag': 'david' } ################################### ################################### calc = espresso( pw=pw_cutoff, dw=dw_cutoff, beefensemble=True, # important! kpts=kpts, nbands=nbands, xc=xc, convergence=convergence, dipole=dipole, spinpol=spinpol, outdir=outdir, output=output, # mode = 'scf', ) #!/usr/bin/env python ################################################################################ # Class definitions. Preferred to import to improve reproducability. # ################################################################################ class Calculation:
calc= espresso( output = { 'avoidio': True, 'removesave': True, 'removewf': True, 'wf_collect': False, }, kpts = (6,6,6), parflags = None, xc = 'BEEF-vdW', nbands = -50, convergence = { 'nmix': 20, 'diag': 'david', 'energy': 2e-06, 'mixing_mode': 'local-TF', 'maxsteps': 500, 'mixing': 0.2 }, dw = 6000.0, outdir = 'calcdir', pw = 600, #noncollinear = False, dipole = { 'status': False }, beefensemble = True, printensemble = True, sigma = 0.005, spinpol = True )
def make_board(text, rules): print('Making board for:', text) print('') info = {} # Convert to Morse mark/space sequence. text = text.upper() info['text'] = text try: seqs = sequence.text_to_bit_sequence(text, rules['type']) except: logging.error('Error generating bit sequence', exc_info=sys.exc_info()) return print('Bit sequence:') info['sequence'] = [] for seq in seqs: s = sequence.to_string(seq) print(' ', s) info['sequence'].append(s) nseqs = len(seqs) print('') # Padding: either a fixed padding or to next power of two. length = len(seqs[0]) if length > 256: print('Sequence too long: maximum length is 256') sys.exit(1) length = util.next_power_of_two(length) npadding = length - len(seqs[0]) print('Length:', len(seqs[0]), '->', length) for i in range(npadding): for j in range(nseqs): seqs[j].append(sequence.SPACE) print('Padded bit sequence:') info['padded_sequence'] = [] for seq in seqs: s = sequence.to_string(seq) print(' ', s) info['padded_sequence'].append(s) print('') # Convert to Espresso format. try: esp = espresso.espresso(seqs) except: logging.error('Error running Espresso', exc_info=sys.exc_info()) return p = placement.place(esp, rules) print(p) c, a = placement.assign(p['gates'], info) print('') netlist.skidl_build(nseqs, length, c, a, rules) skidl.ERC() skidl.generate_netlist() bom.make_bom() return info
atoms.set_pbc((1, 1, 1)) calc = espresso( pw=pw, dw=dw, xc=xc, kpts=kpts, nbands=-20, sigma=0.1, calcstress=True, spinpol=False, convergence={ 'energy': 1e-5, #convergence parameters 'mixing': 0.1, 'nmix': 10, 'mix': 4, 'maxsteps': 500, 'diag': 'david' }, psppath='/home/users/vossj/suncat/psp/gbrv1.5pbe', outdir='cell_relax', mode='vc-relax', cell_factor=2, cell_dynamics='bfgs', opt_algorithm='bfgs', output={ 'avoidio': True, 'removewf': True, 'wf_collect': False }) atoms.set_calculator(calc)
"beefensemble": true, "printensemble": true, "convergence": { "energy": 1e-06, "mixing": 0.2, "maxsteps": 1000, "diag": "david" }, "startingwfc": "atomic", "dipole": { "status": false }, "outdir": "esp.log" } atoms = molecule() parameters['pw'] = {pw} parameters['kpts'] = ({kpts}, {kpts}, 1) atoms = read('structure.traj') calc = espresso(**parameters) atoms.set_calculator(calc) relax = BFGSLineSearch(atoms) relax.run(fmax=0.05) eng = atoms.get_potential_energy() with open('energy.txt', 'w') as f: f.write(str(eng))