Is it not possible to optimize periodic structures in ASE using DFTB+ calculator?

Hi all,

I am trying to use DFTB+ for some calculations on a periodic structure and I am not able to make the DFTB+ calc realize that the structure is periodic. The periodicity is set in ASE correctly, and is not a problem if I use the ASE optimizers for my relaxation, but when I try to use the DFTB+ optimizers then the periodicity is not detected. but I think it gets lost in translation when it gets passed to the calculator.

I believe the issue lies in the fact that the Geometry block is automatically generated by ASE and cannot be modified manually in the script, so I am unable to include the flags LatticeVectors and Periodicity. Is this true? Should I do it in a different way?

In general, I am trying to make this work because I eventualliy want to do some MDs using DFTB+ and keeping a part of my system at constant potential, built-in through AtomSitePotential. So I would also appreciate any advice regarding how to make that end goal work :slight_smile:

Thanks in advance for your help.

This works for me:

from ase.build import bulk
from ase.calculators.dftb import Dftb
from ase.io import read, write

atoms = bulk('Si', cubic=False)
write('initial.gen', atoms)
calc = Dftb(
    label='si',
    kpts=(4, 4, 4),
    # Driver_='ConjugateGradient',
    # Driver_MaxForceComponent=1e-4,
    # Driver_MaxSteps=1000,
    Driver_='GeometryOptimisation',
    Driver_Optimiser_ = 'LBFGS',
    Driver_Optimiser_Memory = 20,
    Driver_LatticeOpt = 'Yes',
    Hamiltonian_='xTB',
    Hamiltonian_Method='GFN2-xTB',
)

atoms.calc = calc
calc.calculate(atoms)

final = read('geo_end.gen')
# Note that the .xyz output from DFTB+ lacks lattice vectors, but .gen includes them
write('final.xyz', final)

The ASE calculator uses the .gen structure format of DFTB+, which does include lattice vectors, to write the structure. So there is no need for them to appear explicitly in the main input file.