# ValueError: One or more NEB images share the same calculator. DFTB calculator

Hi, I am trying to do parallel NEB calculation with DFTB calculator. The following python file works without errors when the EMT calculator is used instead of DFTB. However, when DFTB is used the following error is shown: ValueError: One or more NEB images share the same calculator. Each image must have its own calculator. You may wish to use the ase.neb.SingleCalculatorNEB class instead, although using separate calculators is recommended.

neb.py file:

from ase.io import read
from ase.constraints import FixAtoms
from ase.calculators.emt import EMT
from ase.calculators.dftb import Dftb
from ase.neb import NEB
from ase.optimize import BFGS
from ase.parallel import world

#constraint = FixAtoms(mask=[i > 15 for i in range(0,66)])

images = [initial]
j = world.rank * 3 // world.size  # my image number
for i in range(3):
image = initial.copy()
if i == j:
#image.calc = EMT()    <--- the error is not reported when EMT is used here
image.calc=Dftb(label='h2o',
atoms=images[i], kpts=(1,4,1),
Hamiltonian_SCC='yes',
Hamiltonian_SCCTolerance=1E-7,
Hamiltonian_MaxSCCIterations=300,
Hamiltonian_ForceEvaluation="'dynamics'",
Hamiltonian_Filling = 'Fermi {Temperature [Kelvin] = 100.0}',
Hamiltonian_MaxAngularMomentum_='',
Hamiltonian_MaxAngularMomentum_C='"p"',
Hamiltonian_MaxAngularMomentum_O='"p"',
Driver_='',
)
print(image)
#image.set_constraint(constraint)
images.append(image)
images.append(final)

neb = NEB(images, parallel=True)
neb.interpolate()
qn = BFGS(neb, trajectory='neb.traj')
qn.run(fmax=0.05)

I run the calculation with mpirun -n 3 gpaw python neb.py

How to fix the code to resolve the error?

I got similar error when using vasp calculator. I fixed it by attaching new calculator in each images. Hopes it is useful for you. Here is my code:

from ase.calculators.vasp import Vasp
from ase.neb import NEB
from ase.io import read
from ase.optimize import BFGS
# Load initial and final structures
atoms = Vasp(restart=True, directory='nh3-initial').get_atoms()
atoms2 = Vasp(restart=True, directory='nh3-final').get_atoms()

# Create 5 images including endpoints
images = [atoms]   # initial state
images += [atoms.copy() for i in range(3)]
images += [atoms2]  # final state

# Set up NEB interpolation
neb = NEB(images)
neb.interpolate()

# Set up VASP calculator for NEB calculation
calc = Vasp(directory='molecules/nh3-neb',
xc='PBE',
ibrion=1, encut=350,
nsw=90,
spring=-5.0)

for image in images[1:4]:
image.calc =  Vasp(
xc='PBE',
ibrion=1, encut=350,
nsw=90,
spring=-5.0)
# Run the NEB optimization
qn = BFGS(neb, trajectory='neb.traj', restart='neb.pckl')

qn.run(fmax=0.05)

Hi! Have you managed to run more than image at the same time?