def __init__(self, *args, **kwargs): kwargs['Hamiltonian_SCC'] = 'Yes' # SCC = self-consistency charges kwargs['Hamiltonian_ShellResolvedSCC'] = 'No' # Use l-dependent Hubbard values ? kwargs['Hamiltonian_OrbitalResolvedSCC'] = 'No' kwargs['Hamiltonian_SCCTolerance'] = '1e-5' # SCC convergence criterion kwargs['Hamiltonian_MaxSCCIterations'] = 250 kwargs['maximum_angular_momenta'] = {'Xx': MAM1, 'Yy': MAM2} kwargs['Hamiltonian_Charge'] = '0.000000' kwargs['Hamiltonian_ReadInitialCharges'] = 'No' # DFTB-equivalent of restarting from saved electron density kwargs['Hamiltonian_Filling'] = 'Fermi {' kwargs['Hamiltonian_Filling_empty'] = 'Temperature [Kelvin] = 300' kwargs['Hamiltonian_PolynomialRepulsive'] = 'SetForAll {Yes}' # Use polynomial or spline repulsive ? kwargs['Hamiltonian_Eigensolver'] = 'RelativelyRobust {}' DftbPlusCalculator.__init__(self, *args, **kwargs)
def singlepoint(t): ''' This function will be used in the iter007 step, which restarts from the runXXX/godb.db databases from the iter006 step. Since the repulsive interactions have been reparametrized in between, the structures in the database need to be re-evaluated. ''' calc = DftbPlusCalculator(t, kpts=(1, 1, 1), use_spline=True, maximum_angular_momenta={'Si': 1}) t.set_calculator(calc) E = t.get_potential_energy() F = t.get_forces() S = None finalize(t, energy=E, forces=F, stress=S) return t
def singlepoint(t, kptdensity=3.5): if get_raw_score(t) < -1e5: return t try: calc = DftbPlusCalculator(t, kpts=kptdensity, use_spline=True, maximum_angular_momenta={'Pd': 2, 'H': 0, 'O': 1}) t.set_calculator(calc) E = t.get_potential_energy() F = t.get_forces() S = t.get_stress() finalize(t, energy=E, forces=F, stress=S) penalize(t) except (IOError, TypeError, RuntimeError, UnboundLocalError) as err: print(err) print('Warning: problems with singlepoint recalculation') finalize(t, energy=1e9, forces=None, stress=None) return t
def relax_one(t): ''' This method defines how to locally minimize a given atoms object 't'. ''' # The provided structure will often contain atoms separated # by relatively short distances. Pushing these atoms a bit # apart using a soft potential will reduce the number of # subsequent ionic steps and will help avoid DFTB convergence # problems. pos = t.get_positions() numbers = list(set(t.get_atomic_numbers())) blmin = closest_distances_generator(numbers, 0.5) t = push_apart(t, blmin, variable_cell=False) print('Starting relaxation', flush=True) clock = time() t.wrap() # Define the DFTB+ calculator: calc = DftbPlusCalculator(t, kpts=(1, 1, 1), use_spline=True, maximum_angular_momenta={'Si': 1}) # Start the actual relaxation using the # tango.relax_utils.relax_precon method. # This wraps around the preconditioned # optimizers in ASE and also takes care of # setting the raw score etc.: try: t = relax_precon(t, calc, fmax=1e-2, variable_cell=False, logfile=None, trajfile=None) except IOError: # the DFTB+ ASE calculator throws an IOError # in case it couldn't find the 'results.tag' # output file, which may sporadically happen # due to SCC converge issues when e.g. a Si7 # cluster is breaking into fragments. We simply # handle this by aborting the relaxation and # assigning a very high energy to the structure: finalize(t, energy=1e9, forces=None, stress=None) print('Relaxing took %.3f seconds.' % (time() - clock), flush=True) return t
def relax_one(t, kptdensity=3.5): cellbounds = CellBounds( bounds={ 'phi': [0.1 * 180., 0.9 * 180.], 'chi': [0.1 * 180., 0.9 * 180.], 'psi': [0.1 * 180., 0.9 * 180.], 'a': [1.5, 20], 'b': [1.5, 20], 'c': [1.5, 20] }) if not cellbounds.is_within_bounds(t.get_cell()): print('Candidate outside cellbounds -- skipping') finalize(t, energy=1e9, forces=None, stress=None) return t pos = t.get_positions() numbers = list(set(t.get_atomic_numbers())) blmin = closest_distances_generator(numbers, 0.5) t = push_apart(t, blmin, variable_cell=True) print('Starting relaxation', flush=True) clock = time() t.wrap() calc = DftbPlusCalculator(t, kpts=0.66 * kptdensity, use_spline=True, read_chg=True, maximum_angular_momenta={'C': 1}) try: t = relax_precon(t, calc, fmax=2e-1, smax=1e-2, variable_cell=True, optimizer='LBFGS', a_min=1e-4, cellbounds=cellbounds, logfile='opt_first.log', trajfile='opt_first.traj') except (IOError, TypeError, RuntimeError, UnboundLocalError) as err: # SCC or geometry optimization convergence problem print(err) del t.constraints t.wrap() calc = DftbPlusCalculator(t, kpts=kptdensity, use_spline=True, read_chg=True, maximum_angular_momenta={'C': 1}) try: t = relax_precon(t, calc, fmax=1e-1, smax=5e-3, variable_cell=True, optimizer='LBFGS', a_min=1e-4, cellbounds=cellbounds, logfile='opt.log', trajfile='opt.traj') except (IOError, TypeError, RuntimeError, UnboundLocalError) as err: # SCC or geometry optimization convergence problem print(err) try: t = read('opt.traj@-1') energy = t.get_potential_energy() forces = t.get_forces() stress = t.get_stress() except (FileNotFoundError, UnknownFileTypeError) as err: print(err) energy, forces, stress = (1e9, None, None) finalize(t, energy=energy, forces=forces, stress=stress) print('Relaxing took %.3f seconds.' % (time() - clock), flush=True) os.system('mv opt_first.traj prev_first.traj') os.system('mv opt_first.log prev_first.log') os.system('mv opt.log prev.log') os.system('mv opt.traj prev.traj') penalize(t) return t
def relax_one(t, kptdensity=3.5): cellbounds = CellBounds(bounds={'phi': [0.1 * 180., 0.9 * 180.], 'chi': [0.1 * 180., 0.9 * 180.], 'psi': [0.1 * 180., 0.9 * 180.], 'a': [1.5, 20], 'b': [1.5, 20], 'c':[1.5, 20]}) if not cellbounds.is_within_bounds(t.get_cell()): print('Candidate outside cellbounds -- skipping') finalize(t, energy=1e9, forces=None, stress=None) return t tags = t.get_tags() pos = t.get_positions() pairs = [] for tag in list(set(tags)): indices = list(np.where(tags == tag)[0]) if len(indices) == 2: pairs.append(indices) c = FixBondLengths(pairs) t.set_constraint(c) blmin = {(1, 1): 1.8, (1, 8): 0.9, (1, 46): 1.8, (8, 8): 2.0, (8, 46): 1.5, (46, 46): 1.5} t = push_apart(t, blmin, variable_cell=True) del t.constraints oh_bondlength = 0.97907 for (o_atom, h_atom) in pairs: vec = t.get_distance(o_atom, h_atom, mic=True, vector=True) pos[h_atom] = pos[o_atom] + vec * oh_bondlength / np.linalg.norm(vec) t.set_positions(pos) print('Starting relaxation', flush=True) clock = time() t.wrap() calc = DftbPlusCalculator(t, kpts=0.66*kptdensity, use_spline=True, read_chg=True, maximum_angular_momenta={'Pd': 2, 'H': 0, 'O': 1}) try: t = relax_precon(t, calc, fmax=2e-1, smax=1e-2, variable_cell=True, optimizer='LBFGS', a_min=1e-4, cellbounds=cellbounds, fix_bond_lengths_pairs=pairs, logfile='opt_first.log', trajfile='opt_first.traj') except (IOError, TypeError, RuntimeError, UnboundLocalError) as err: # SCC or geometry optimization convergence problem print(err) if isinstance(t, Filter): t = t.atoms del t.constraints t.wrap() calc = DftbPlusCalculator(t, kpts=kptdensity, use_spline=True, read_chg=True, maximum_angular_momenta={'Pd': 2, 'H': 0, 'O': 1}) try: t = relax_precon(t, calc, fmax=1e-1, smax=5e-3, variable_cell=True, optimizer='LBFGS', a_min=1e-4, cellbounds=cellbounds, fix_bond_lengths_pairs=pairs, logfile='opt.log', trajfile='opt.traj') except (IOError, TypeError, RuntimeError, UnboundLocalError) as err: # SCC or geometry optimization convergence problem print(err) try: t = read('opt.traj@-1') energy = t.get_potential_energy() forces = t.get_forces() stress = t.get_stress() except (FileNotFoundError, UnknownFileTypeError) as err: print(err) energy, forces, stress = (1e9, None, None) if isinstance(t, Filter): t = t.atoms finalize(t, energy=energy, forces=forces, stress=stress) print('Relaxing took %.3f seconds.' % (time() - clock), flush=True) os.system('mv opt_first.traj prev_first.traj') os.system('mv opt_first.log prev_first.log') os.system('mv opt.log prev.log') os.system('mv opt.traj prev.traj') penalize(t) return t
def __init__(self, *args, **kwargs): kwargs['Hamiltonian_SCC'] = 'No' kwargs['Hamiltonian_ShellResolvedSCC'] = 'No' kwargs['Hamiltonian_OrbitalResolvedSCC'] = 'No' kwargs['maximum_angular_momenta'] = {'Si': 1} DftbPlusCalculator.__init__(self, *args, **kwargs)