#!/usr/bin/env python

from ase.neb import NEB
from ase import io
import os
from xtb.ase.calculator import XTB

calc = XTB(method='GFN0-xTB',max_iterations=100)
initial = io.read('POSCAR_start')
initial.calc = calc
final = io.read('POSCAR_end_sorted')
final.calc = calc
images = [initial]
for i in range(5):
    images.append(initial.copy())
    images[-1].calc = calc
images.append(final)
neb = NEB(images)
neb.interpolate('idpp',mic=True)
dir_names = ['0'+str(i) for i in range(7)]
for i, image in zip(dir_names,neb.images):
	if not os.path.isdir(i):
		os.mkdir(i)
	io.write(i+'/POSCAR',image)
