def atomizationEnergyH2O(dbname, xc): database = db.connect(dbname) system = database.get_atoms( selection=20) # Use atom with reference 20 as structure calc = gp.GPAW(xc=xc) system.set_calculator(calc) eH2O = system.get_potential_energy() calc = gp.GPAW(xc=xc, hund=True) Hsyst = Atoms("H", positions=[[3.5, 3.5 + 0.001, 3.5 + 0.0002]]) Hsyst.set_cell([7, 7, 7]) Hsyst.center() Hsyst.set_calculator(calc) eH = Hsyst.get_potential_energy() Osyst = Atoms("O", positions=[[3.5, 3.5 + 0.001, 3.5 + 0.0002]]) Osyst.set_cell([7, 7, 7]) Osyst.center() Osyst.set_calculator(calc) eO = Osyst.get_potential_energy() print("Hydrogen energy: %.2E" % (eH)) print("Oxygen energy: %.2E" % (eO)) print("Atomization energy: %.2E" % (eH2O - 2 * eH - eO))
def main(argv): atoms = bulk("Al") atoms = atoms * (4, 4, 4) mode = "fd" e_cut = 500 if (mode == "fd"): h = 0.2 calc = gp.GPAW(mode="fd", h=h, xc="PBE", kpts=(6, 6, 6), nbands=-10) else: calc = gp.GPAW(mode=gp.PW(e_cut), xc="PBE", kpts=(6, 6, 6), nbands=-10) atoms.set_calculator(calc) energy = atoms.get_potential_energy() print("Energy: %.2E" % (energy))
def main(argv): fname = argv[0] if (int(argv[1]) == 1): variable_cell = True else: variable_cell = False atoms = read(fname) #atoms = bulk("Al") calc = gp.GPAW(mode=gp.PW(500), kpts=(12, 12, 12), xc="PBE", nbands=-20) atoms.set_calculator(calc) prc = Exp(mu=1.0, mu_c=1.0) outfname = fname.split("/")[-1] outfname = outfname.split(".")[0] logfile = outfname + ".log" traj_file = outfname + ".traj" relaxer = PreconLBFGS(atoms, logfile=logfile, precon=prc, use_armijo=True, variable_cell=variable_cell) trajObj = Trajectory(traj_file, 'w', atoms) relaxer.attach(trajObj) if (variable_cell): relaxer.run(fmax=0.025, smax=0.003) else: relaxer.run(fmax=0.025) outfname = fname.split("/")[-1] outfname = outfname.split(".")[0] outfname += "_relaxed.xyz" print("Energy: {}".format(atoms.get_potential_energy())) write(outfname, atoms)
def main(): atoms = bulk("Al", cubic=True) atoms = atoms * (3, 3, 3) for i in range(int(len(atoms) / 5)): atoms[i].symbol = "Mg" atoms.rattle(stdev=0.005) calc = gp.GPAW(mode=gp.PW(500), xc="PBE", kpts=(4, 4, 4), nbands="120%") atoms.set_calculator(calc) logfile = "relax250.log" traj = "relax250.traj" trajObj = Trajectory(traj, 'w', atoms) precon = Exp(mu=1) relaxer = PreconLBFGS(atoms, logfile=logfile, use_armijo=True, precon=precon, memory=50) #relaxer = PreconFIRE( atoms, logfile=logfile, use_armijo=True, precon=precon ) relaxer.attach(trajObj) try: relaxer.run(fmax=0.05) except Exception as exc: print(exc)
def relax(runID): db = connect(db_name) atoms = db.get_atoms(id=runID) con = sq.connect(db_name) cur = con.cursor() cur.execute("SELECT value FROM text_key_values WHERE id=? AND key='name'", (runID, )) name = cur.fetchone()[0] con.close() calc = gp.GPAW(mode=gp.PW(600), xc="PBE", kpts=(4, 4, 4), nbands="120%", symmetry="off") atoms.set_calculator(calc) precon = Exp(mu=1.0, mu_c=1.0) save_to_db = SaveToDB(db_name, runID, name) logfile = "logfile%d.log" % (runID) traj = "trajectory%d.traj" % (runID) uf = UnitCellFilter(atoms, hydrostatic_strain=True) relaxer = PreconLBFGS(uf, logfile=logfile, use_armijo=True, precon=precon) relaxer.attach(save_to_db, interval=1, atoms=atoms) trajObj = Trajectory(traj, "w", atoms) relaxer.attach(trajObj) relaxer.run(fmax=0.05, smax=0.003)
def main(argv): n_mg = int(argv[0]) atoms = bulk("Al") atoms = atoms * (4, 4, 4) for i in range(n_mg): atoms[i].symbol = "Mg" atoms.rattle(stdev=0.005) calc = gp.GPAW(mode=gp.PW(500), xc="PBE", kpts=(4, 4, 4), nbands="120%") atoms.set_calculator(calc) logfile = "preconTest%d.log" % (n_mg) traj = "preconTest%d.traj" % (n_mg) trajObj = Trajectory(traj, 'w', atoms) precon = Exp(mu=1) relaxer = PreconLBFGS(atoms, logfile=logfile, use_armijo=True, precon=precon) relaxer.attach(trajObj) try: relaxer.run(fmax=0.05) except: pass print("Mu: %.2E" % (relaxer.precon.mu))
def _wan(gpts=(8, 8, 8), atoms=None, calc=None, nwannier=2, fixedstates=None, initialwannier='bloch', kpts=(1, 1, 1), file=None, rng=rng, full_calc=False, std_calc=True): if std_calc and calc is None and atoms is None: calc = std_calculator else: if calc is None: gpaw = pytest.importorskip('gpaw') calc = gpaw.GPAW(gpts=gpts, nbands=nwannier, kpts=kpts, symmetry='off', txt=None) if atoms is None and not full_calc: pbc = (np.array(kpts) > 1).any() atoms = molecule('H2', pbc=pbc) atoms.center(vacuum=3.) if not full_calc: atoms.calc = calc atoms.get_potential_energy() return Wannier(nwannier=nwannier, fixedstates=fixedstates, calc=calc, initialwannier=initialwannier, file=None, rng=rng)
def main(): database = "aluminum.db" # Parse parameters from the database con = sqdb.connect(database) cur = con.cursor() cur.execute( "SELECT VIEW,CUTOFF,KPTS,LATTICEPARAM,_rowid_,STRUCTURE FROM PARAMS WHERE STATUS=?", ("RUN", )) jobs = cur.fetchall() con.close() print(jobs) for job in jobs: stamp = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S") structure = job[5] a = job[3] show = job[0] b = a / 2.0 if (structure == "FCC"): bulk = Atoms("Al", cell=[[0, b, b], [b, 0, b], [b, b, 0]], pbc=True) elif (structure == "BCC"): bulk = Atoms("Al", cell=[[b, b, b], [b, b, -b], [b, -b, b]], pbc=True) else: print("Unknown lattice type") continue if (show == 1): view(bulk) calcfile = "data/alum" + structure + stamp + ".txt" cutoff = job[1] k = job[2] calc = gp.GPAW(mode=gp.PW(cutoff), kpts=(k, k, k), txt=calcfile, xc="LDA") bulk.set_calculator(calc) energy = bulk.get_potential_energy() gpwfile = "data/alum" + structure + stamp + ".gpw" calc.write(gpwfile) # Update the database aseDB = db.connect(database) lastID = aseDB.write(bulk) con = sqdb.connect(database) cur = con.cursor() row = int(job[4]) cur.execute( "UPDATE PARAMS SET GPWFILE=?,TXTFILE=?,STATUS=?,ID=? WHERE _rowid_=?", (gpwfile, calcfile, "FINISHED", lastID, row)) con.commit() con.close()
def main(runID): db = connect(db_name) calc = gp.GPAW(mode=gp.PW(500), xc="PBE", kpts=(8, 8, 8), nbands=-50) atoms = db.get_atoms(id=runID) atoms.set_calculator(calc) energy = atoms.get_potential_energy() del db[runID] db.write(atoms)
def relax(fname): atoms = read(fname) calc = gp.GPAW(mode=gp.PW(600),kpts=(4,4,4),xc="PBE") atoms.set_calculator(calc) uf = UnitCellFilter(atoms,hydrostatic_strain=True) relaxer = PreconLBFGS( uf, logfile="logfile.log" ) relaxer.run( fmax=0.025,smax=0.003 ) write( fname, atoms )
def run_dft(): kpt = 16 atoms = bulk("Al",crystalstructure="fcc",a=4.05) calc = gp.GPAW( mode=gp.PW(600), xc="PBE", kpts=(kpt,kpt,kpt), nbands=-50 ) atoms.set_calculator( calc ) relaxer = BFGS( UnitCellFilter(atoms) ) relaxer.run( fmax=0.025 ) energy = atoms.get_potential_energy() print (energy)
def main(): atoms = build.bulk("Al") atoms = atoms * (8, 4, 4) nMg = int(0.2 * len(atoms)) for i in range(nMg): atoms[i].symbol = "Mg" calc = gp.GPAW(mode=gp.PW(400), xc="PBE", nbands=-10, kpts=(4, 4, 4)) atoms.set_calculator(calc) energy = atoms.get_potential_energy() / len(atoms)
def test_get_centers(factory): # Rough test on the position of the Wannier functions' centers gpaw = pytest.importorskip('gpaw') calc = gpaw.GPAW(gpts=(32, 32, 32), nbands=4, txt=None) atoms = molecule('H2', calculator=calc) atoms.center(vacuum=3.) atoms.get_potential_energy() wanf = Wannier(nwannier=2, calc=calc, initialwannier='bloch') centers = wanf.get_centers() com = atoms.get_center_of_mass() assert np.abs(centers - [com, com]).max() < 1e-4
def originalCalculation(): atoms = bulk("Al", cubic=True) calc = gp.GPAW(mode=gp.PW(350), nbands=-50, xc="PBE", kpts={"density": 1.37, "even": True}) atoms.set_calculator(calc) energy = atoms.get_potential_energy() calc.write( "al.gpw", mode="all" ) n = calc.get_all_electron_density(gridrefinement=4) np.save("density_al.npy", n) view(atoms, viewer="avogadro", data=n) ase.io.write("al_density.cube", atoms, data=n)
def run(h, symb): atoms = bulk("Al") atoms[0].symbol = symb kpts = {"density": 5.4, "even": True} calc = gp.GPAW(h=h, kpts=kpts, nbands=-100) atoms.set_calculator(calc) atoms.get_potential_energy() db = connect(DB_NAME) db.write(atoms, grid_spacing=h)
def main( argv ): atoms = bulk("Al") kpt = int(argv[0]) n_atoms = int(argv[1]) h = float(argv[2]) atoms = atoms*(n_atoms,n_atoms,n_atoms) mode = "fd" calc = gp.GPAW(mode="fd", h=h, xc="PBE", kpts=(kpt,kpt,kpt), nbands="120%" ) atoms.set_calculator( calc ) energy = atoms.get_potential_energy() print ("Energy: %.2E"%(energy))
def originalCalculation(): d = 1.1 a = 5.0 c = a / 2.0 atoms = ase.Atoms("CO", positions=([c - d / 2.0, c, c], [c + d / 2.0, c, c]), cell=(a, a, a)) calc = gp.GPAW(nbands=5, h=0.2, txt=None) atoms.set_calculator(calc) energy = atoms.get_potential_energy() calc.write("CO.gpw", mode="all")
def main(runID): db = ase.db.connect(db_name()) atoms = db.get_atoms(id=runID) row = db.get(id=runID) n_kpt = row.n_kpt cutoff = row.cutoff calc = gp.GPAW(mode=gp.PW(cutoff), xc="PBE", kpts=(n_kpt, n_kpt, n_kpt), nbands="120%") atoms.set_calculator(calc) energy = atoms.get_potential_energy() db.update(runID, trial_energy=energy)
def main(): a = 4.05 atoms = alfact.Al7068(symbol=("Al", "Zn", "Mg", "Cu"), latticeconstant=a, pbc=True) #write( "al7068.pov", atoms, rotation="-10z,-70x" ) atoms.set_cell([6 * a, 6 * a, 6 * a]) atoms.center() k = 4 #calc = gp.GPAW( xc="PBE", mode=gp.PW(300), kpts=(k,k,k) ) calc = gp.GPAW(xc="PBE", h=0.2) atoms.set_calculator(calc) energy = atoms.get_potential_energy() print("Energy: %.2E eV/atom" % (energy))
def _std_calculator_gpwfile(tmp_path_factory, factories): factories.require('gpaw') import gpaw atoms = molecule('H2', pbc=True) atoms.center(vacuum=3.) gpw_path = tmp_path_factory.mktemp('sub') / 'dumpfile.gpw' calc = gpaw.GPAW(gpts=(8, 8, 8), nbands=4, kpts=(2, 2, 2), symmetry='off', txt=None) atoms.calc = calc atoms.get_potential_energy() calc.write(gpw_path, mode='all') return gpw_path
def test_get_pdos(wan): nwannier = 4 gpaw = pytest.importorskip('gpaw') calc = gpaw.GPAW(gpts=(16, 16, 16), nbands=nwannier, txt=None) atoms = molecule('H2') atoms.center(vacuum=3.) atoms.calc = calc atoms.get_potential_energy() wanf = wan(atoms=atoms, calc=calc, nwannier=nwannier, initialwannier='bloch') eig_n = calc.get_eigenvalues() for i in range(nwannier): pdos_n = wanf.get_pdos(w=i, energies=eig_n, width=0.001) assert pdos_n[i] != pytest.approx(0)
def optimizeH2O(dbname): database = db.connect(dbname) sqdb = sq.connect(dbname) cur = sqdb.cursor() cur.execute( "SELECT _rowid_,CellSize,XC,JobType,AtomID FROM InputParams WHERE STATUS=?", ("RUN", )) jobs = cur.fetchall() sqdb.close() for job in jobs: jobtype = job[3] atomID = int(job[4]) if (atomID >= 0): print("Using Atoms object with ID %d" % (atomID)) system = database.get_atoms(selection=atomID) else: system = Atoms(["H", "H", "O"], positions=[[3.0, 3.8, 2.4], [3, 2.23, 2.4], [3, 3, 3]]) size = job[1] system.set_cell([size, size, size]) system.center() xc = job[2] calc = gp.GPAW(xc=xc) system.set_calculator(calc) if (jobtype == "Optimize"): opt = QuasiNewton(system, trajectory="H2O.gpw.traj") opt.run(fmax=0.05) elif (jobtype == "GS"): e1 = system.get_potential_energy() lastID = database.write(system) row = int(job[0]) # Update ID print("Updating entry in database") sqdb = sq.connect(dbname) cur = sqdb.cursor() cur.execute("UPDATE InputParams SET ID=?, STATUS=? WHERE _rowid_=?", (lastID, "FINISHED", row)) sqdb.commit() sqdb.close() print("Database updated")
def main(runID): db = connect(db_name) atoms = db.get_atoms(id=runID) N = 14 calc = gp.GPAW(mode=gp.PW(500), xc="PBE", kpts=(N, N, N), nbands=-50, symmetry={'do_not_symmetrize_the_density': True}) atoms.set_calculator(calc) precon = Exp(mu=1.0, mu_c=1.0) uf = UnitCellFilter(atoms, hydrostatic_strain=True) logfile = "al3mg2{}.log".format(runID) relaxer = PreconLBFGS(uf, logfile=logfile, use_armijo=True, precon=precon) relaxer.run(fmax=0.025, smax=0.003) energy = atoms.get_potential_energy() del db[db.get(id=runID)] db.write(atoms)
def compute_bulk(fname): atoms = read(fname) calc = gp.GPAW(mode=gp.PW(600),kpts=(4,4,4),xc="PBE") energies = [] base_fname = fname.split(".")[0] lat_params = np.loadtxt( base_fname+"_latparam.csv", delimiter="," ) V0 = atoms.get_volume() a0 = (V0)**(1.0/3.0) for a in lat_params: sim_atoms = atoms.copy() cell = sim_atoms.get_cell() cell *= (a/a0) sim_atoms.set_cell(cell,scale_atoms=True) sim_atoms.set_calculator(calc) energy = sim_atoms.get_potential_energy() energies.append(energy/len(sim_atoms)) out = np.vstack((lat_params,energies)).T np.savetxt( base_fname+"_bulk.csv",out,delimiter=",",header="Lattice parameter,energy per atom")
def main(argv): n_mg = int(argv[0]) atoms = bulk("Al") atoms = atoms * (4, 4, 4) for i in range(n_mg): atoms[i].symbol = "Mg" atoms.rattle(stdev=0.005) calc = gp.GPAW(mode=gp.PW(500), xc="PBE", kpts=(4, 4, 4), nbands="120%") atoms.set_calculator(calc) logfile = "bfgsTest%d.log" % (n_mg) traj = "bfgsTest%d.traj" % (n_mg) trajObj = Trajectory(traj, 'w', atoms) relaxer = BFGS(atoms, logfile=logfile) relaxer.attach(trajObj) try: relaxer.run(fmax=0.05) except: pass
def main(): unitcellSize = 10.0 # Size of unit cell in Angstrohm center = unitcellSize/2.0 # Create Hydrogen atom located at the center of the unitcell atom = ase.Atoms( "H", positions=[(center,center,center)], magmoms=[0], cell=(center,center+0.001, center+0.002)) # Initialize the GPAW calculator calc = gp.GPAW( mode=gp.PW(), xc="PBE", hund=True, eigensolver="rmm-diis", occupations=gp.FermiDirac(0.0, fixmagmom=True), txt="hydrogen.out") atom.set_calculator( calc ) print ("Solving single atom...") e1 = atom.get_potential_energy() calc.write("H.gpw") # Simulate hydrogen molecule d = 0.74 # Bond length molecule = ase.Atoms( "H2", positions=([center-d/2.0,center,center],[center+d/2.0,center,center]), cell=(center,center,center)) calc.set(txt="H.out") calc.set(hund=False) molecule.set_calculator( calc ) print ("Solving hydrogen molecule...") e2 = molecule.get_potential_energy() # Test if it recalculates everytime for i in range(10): e2 = molecule.get_potential_energy() print (e2) calc.write("H2.gpw") print ( "Hydrogen atom energy: %.2f eV"%(e1) ) print ( "Hydrogen molecule energy: %.2f eV"%(e2) ) print ( "Atomization energy: %.2f eV"%(2*e1-e2) )
import gpaw as gp from ase.build import bulk from ase.visualize import view from ase.optimize.precon import PreconLBFGS from ase.io import write from ase.calculators.emt import EMT atoms = bulk("Mg", crystalstructure="fcc", a=4.1) atoms = atoms * (2, 2, 2) si_indx = [1, 2, 4, 7] for indx in si_indx: atoms[indx].symbol = "Si" calc = gp.GPAW(mode=gp.PW(600), xc="PBE", kpts=(2, 2, 2), nbands=-100) atoms.set_calculator(calc) opt = PreconLBFGS(atoms, variable_cell=True) opt.run(fmax=0.025, smax=0.003) write("data/relaxed_mgsi.xyz", atoms)
def std_calculator(_std_calculator_gpwfile): import gpaw return gpaw.GPAW(_std_calculator_gpwfile, txt=None)
def main(argv): uid = int(argv[0]) attempt_restart = 1 kpts_density = 1.37 lattice_param = 4.05 relax_atoms = 0 final_structure = 0 optimizer = "lbfgs" init_from_traj = 0 for arg in argv: if arg.find("--restart=") != -1: attempt_restart = int(arg.split("--restart")[1]) elif "--kpt=" in arg: kpts_density = float(arg.split("--kpt=")[1]) elif "--a=" in arg: lattice_param = float(arg.split("--a=")[1]) elif "--relax=" in arg: relax_atoms = int(arg.split("--relax=")[1]) elif "--final=" in arg: final_structure = int(arg.split("--final=")[1]) elif "--opt=" in arg: optimizer = arg.split("--opt=")[1] elif "--traj=" in arg: init_from_traj = int(arg.split("--traj=")[1]) db = connect(db_name) atoms = db.get(id=uid).toatoms() atoms = delete_vacancies(atoms) name = db.get(id=uid).name kpt = {"density": kpts_density, "even": True} # calc = gp.GPAW(h=0.32, kpts=kpt, xc="PBE", nbands="120%") calc = gp.GPAW(mode=gp.PW(600), kpts=kpt, xc="PBE", nbands="120%") atoms.set_calculator(calc) restart_file = db.get(id=uid).get("restart_file", "") if relax_atoms == 0 and final_structure == 0: atoms.get_potential_energy() # Store the energy of the atoms object with the correct name # and lattice parameter db.write(atoms, name=name, lattice_param=lattice_param, run_type="lattice_param_estimation") elif relax_atoms == 1: if os.path.exists(restart_file) and attempt_restart == 1: atoms, calc = gp.restart(restart_file) elif init_from_traj: trajfile = "trajectory{}.traj".format(name) traj = Trajectory(trajfile, 'r') atoms = traj[-1] atoms.set_calculator(calc) else: db.update(uid, restart_file=SaveRestartFiles.restart_name(name)) restart_saver = SaveRestartFiles(calc, name) trajObj = Trajectory("trajectory{}.traj".format(name), 'a', atoms) ucf = UnitCellFilter(atoms, hydrostatic_strain=True) logfile = "log_{}.txt".format(name) if optimizer == "cg": relaxer = SciPyFminCG(ucf, logfile=logfile) elif optimizer == "fire": relaxer = PreconFIRE(ucf, logfile=logfile) else: relaxer = PreconLBFGS(ucf, logfile=logfile) relaxer.attach(trajObj) relaxer.attach(restart_saver, interval=1) relaxer.run(fmax=0.025) db.write(atoms, name=name, lattice_param=lattice_param, run_type="geometry_opt", restart_file=SaveRestartFiles.restart_name(name)) elif final_structure: atoms.get_potential_energy() uid = db.write(atoms, name=name, struct_type="final", kpts_density=kpts_density) init_id = db.get(name=name, struct_type='initial').id db.update(init_id, final_struct_id=uid, converged=1)
def main(argv): relax_mode = "both" # both, cell, positions system = "AlMg" runID = int(argv[0]) nkpt = int(argv[1]) single_point = False if (len(argv) >= 3): single_point = (int(argv[2]) == 1) print("Running job: %d" % (runID)) db_paths = [ "/home/ntnu/davidkl/GPAWTutorial/CE/almg_fcc_vac.db", "almg_fcc_vac.db", "/home/davidkl/GPAWTutorial/CE/almg_fcc_vac.db" ] for path in db_paths: if (os.path.isfile(path)): db_name = path break #db_name = "almgsi_test_db.db" db = ase.db.connect(db_name) name = db.get(id=runID).key_value_pairs["name"] new_run = not db.get(id=runID).key_value_pairs["started"] # Update the databse db.update(runID, started=True, converged=False) db.update(runID, nkpt=nkpt) atoms = db.get_atoms(id=runID) atoms = delete_vacancies(atoms) if (len(atoms) == 1): nbands = -10 else: nbands = "120%" kpts = (nkpt, nkpt, nkpt) try: restart_name = SaveRestartFiles.restart_name(name) atoms, calc = gp.restart(restart_name) except: calc = gp.GPAW(mode=gp.PW(500), xc="PBE", kpts=kpts, nbands=nbands) atoms.set_calculator(calc) if (single_point): calc = gp.GPAW(mode=gp.PW(500), xc="PBE", kpts=kpts, nbands=nbands) atoms.set_calculator(calc) logfile = "almg_fcc_vac{}.log".format(name) traj = "almg_bcc{}.traj".format(name) db.update(runID, trajfile=traj) trajObj = Trajectory(traj, 'w', atoms) #storeBest = SaveToDB(db_name,runID,name,mode=relax_mode) save_calc = SaveRestartFiles(calc, name) update_db_info = UpdateDBInfo(db_name, runID, atoms) volume = atoms.get_volume() try: precon = Exp(mu=1.0, mu_c=1.0) fmax = 0.025 smax = 0.003 if (relax_mode == "both"): relaxer = PreconLBFGS(atoms, logfile=logfile, use_armijo=True, variable_cell=True) elif (relax_mode == "positions"): #relaxer = SciPyFminCG( atoms, logfile=logfile ) relaxer = BFGS(atoms, logfile=logfile) elif (relax_mode == "cell"): str_f = StrainFilter(atoms, mask=[1, 1, 1, 0, 0, 0]) relaxer = BFGS(str_f, logfile=logfile) fmax = smax * volume relaxer.attach(trajObj) #relaxer.attach( storeBest, interval=1, atoms=atoms ) relaxer.attach(save_calc, interval=1) relaxer.attach(update_db_info, interval=1) if (not single_point): if (relax_mode == "both"): relaxer.run(fmax=fmax, smax=smax) else: relaxer.run(fmax=fmax) energy = atoms.get_potential_energy() orig_atoms = db.get_atoms(runID) single_p_calc = SinglePointCalculator(orig_atoms, energy=energy) orig_atoms.set_calculator(single_p_calc) kvp = db.get(name=name).key_value_pairs del db[runID] newID = db.write(orig_atoms, key_value_pairs=kvp) if (relax_mode == "positions"): db.update(newID, converged_force=True) elif (relax_mode == "cell"): db.update(newID, converged_stress=True) else: db.update(newID, converged_stress=True, converged_force=True) db.update(newID, single_point=single_point) db.update(newID, restart_file=SaveRestartFiles.restart_name(name)) row = db.get(id=newID) conv_force = row.get("converged_force", default=0) conv_stress = row.get("converged_stress", default=0) if ((conv_force == 1) and (conv_stress == 1) and (nkpt == 4)): db.update(newID, converged=True) except Exception as exc: print(exc)