I'm having an issue with the dftb calculator from ASE package. I'm proving the precission of two methods to optimize some COF structure by stretching the cell isotropically. So the firts function is
def isotropic_cell_relax_2D(atoms, calculator, fmax=0.01):
"""Relaxes the atoms object isotropically in 2D, meaning one scaling factor for cell vectors in x and y is optimized.
This also means that all angles stay constant.
Args:
atoms (_type_): _description_
calculator (_type_): _description_
convergence_criterion (float, optional): some sort of convergence criterion. Check what kind is best.
Returns:
_type_: _description_
"""
from ase.optimize import BFGS
from scipy.optimize import minimize
def energy(scale_factor1):
atoms1 = atoms.copy()
# Scale the cell size of the atom object
atoms1.set_cell(atoms1.get_cell() * scale_factor1, scale_atoms=True)
# Create an EMT calculator and attach it to the atom object
atoms1.calc = calculator
dyn = BFGS(atoms1)
dyn.run(fmax=fmax)
# Calculate the energy of the system
return atoms1.get_potential_energy()
#optimization of the scale factor
opt = minimize(energy, x0 = 1, method='BFGS', options={'gtol': 1e-5, 'disp': True} )
scale_factor = opt.x[0]
#copy of atom object
atoms2 = atoms.copy()
atoms2.calc = calculator #attach calculator to atoms
#make the stress/stretch using the scalar factor
atoms2.set_cell(atoms2.get_cell() * scale_factor, scale_atoms=True)
dyn = BFGS(atoms2)
dyn.run(fmax=fmax)
E = atoms2.get_potential_energy()
results = {'Energy': E}
return results, atoms2, scale_factor
there the calculator is attached as
calc2 = Dftb(**dftb_GeomOpt)
so using this dictionarie
dftb_GeomOpt = {'Driver_': 'GeometryOptimization',
'Driver_Optimizer': 'LBFGS {}',
'Driver_Convergence_': '',
'Driver_Convergence_GradElem': 1e-6,
'Driver_MaxSteps': 3000,
'Hamiltonian_MaxAngularMomentum_O': 'p',
'Hamiltonian_MaxAngularMomentum_B': 'p',
'Hamiltonian_MaxAngularMomentum_C': 'p',
'Hamiltonian_MaxAngularMomentum_N': 'p',
'Hamiltonian_MaxAngularMomentum_H': 's',
'kpts': [1,1,1]
}
I get the error calling that function CalculationFailed: Calculator "dftb" failed with command "/home/jupyter-cgallegos/miniconda3/envs/htc_cofs/bin/dftb+ > dftb.out" failed in /home/jupyter-cgallegos/HTC_COFs/htc_cofs/dummy_recipes with error code 1
Im trying to understand right now the outputs dftb.out and dftb_in.hsd. dftb.out:
and dftb_in.hsd: