Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent energy and force when atoms are near the periodic boundries #257

Open
zyt0y opened this issue Jun 12, 2020 · 13 comments
Open
Labels
bug Something isn't working method: xTB Related to the xTB Hamiltonian and its parametrisations

Comments

@zyt0y
Copy link

zyt0y commented Jun 12, 2020

Describe the bug
In principle, the total energy and force should have translational invariance under the periodic boundtry condition. When I translate a periodic system (water on graphene), the total energy and maximal atomic force are not always the same.

To Reproduce
Setup:
python: 3.6.3
ase: 3.17.0
xtb-python: 20.1
xtb: 6.3.0

The structure for water trimer on graphene is built first. Then I translate the system using a equally spaced distance.

for i in range(20):
    atoms.translate([0, -i*0.1, 0])

Energy and force are calculated using following command:

atoms.set_calculator(XTB(method="GFN0-xTB"))
#atoms.set_calculator(XTB(method="GFN1-xTB"))
atoms.get_forces()

Energy and maximal atomic force are plotted for structrues at different displacements and with different methods. Reference calculations are performed using DFTB+. The carbon atoms near the cell boundaries are plotted in blue colors for better visual comparisons.
pbc
Trajectory files in ASE format pbc.zip are also provided here.

Expected behaviour
GFN0-xTB and GFN1-xTB should havetranslational invariance under the periodic boundtry condition and show similar curve as periodic DFTB+.

Additional context
I am running xtb using xtb-python interface. The problem should lie on xtb part, I guess.

@zyt0y zyt0y added the unconfirmed This report has not yet been confirmed by the developers label Jun 12, 2020
@awvwgk
Copy link
Member

awvwgk commented Jun 12, 2020

Could be an issue with the Wigner–Seitz cell (WSC) used for the cyclic cluster model (CCM) which is generating the periodic boundary conditions for the Hamiltonian. The current WSC generator can miss certain crucial interacting pairs if they are not included in a 3×3×3 supercell, i.e. if they are just in the 2, 0, 0 cell.

First, we should check if using the full real-space cutoff rather than the CCM is showing the same behaviour.

@zyt0y
Copy link
Author

zyt0y commented Jun 17, 2020

get_realspace_cutoff is defined in https://github.com/grimme-lab/xtb/blob/master/src/pbc.f90#L31 . Should I look into all places where get_realspace_cutoff is called?

@awvwgk
Copy link
Member

awvwgk commented Jun 17, 2020

Sorry, I'm currently short of time and haven't investigated further yet. It would certainly help to nail down the energy expression that is not translational invariant. The Hamiltonian was a wild guess, after checking the GFN1-xTB Hamiltonian is done in real-space, while the GFN0-xTB Hamiltonian is done with the CCM, so this might not be the issue.

The get_realspace_cutoff should only have very limited use in the code, I moved most of the boundary condition handling to https://github.com/grimme-lab/xtb/blob/master/src/type/latticepoint.f90. Since you don't deform the cell, the lattice point generator should always generate the same amount of lattice points for all cases.

@zyt0y
Copy link
Author

zyt0y commented Jun 17, 2020

I will try to figure out how PBC is working in xtb and see if I can indenitify where the problem is.

@awvwgk awvwgk added bug Something isn't working help wanted Extra attention is needed and removed unconfirmed This report has not yet been confirmed by the developers labels Jun 19, 2020
@zulissi
Copy link

zulissi commented Sep 5, 2020

Hi - we've also been noticing inconsistencies with PBC for molecules on surfaces in GFN0. Any luck tracking down the issue @tangzeyuan ?

@zyt0y
Copy link
Author

zyt0y commented Sep 5, 2020

Hi - we've also been noticing inconsistencies with PBC for molecules on surfaces in GFN0. Any luck tracking down the issue @tangzeyuan ?

No clues yet.

@awvwgk
Copy link
Member

awvwgk commented Sep 5, 2020

I haven't had time to investigate yet, either. Maybe I can clear enough projects by the end of this month to find time to work on the PBC implementation again. But can't promise.

@manuelmelle
Copy link

Same problem found:

I am running some preliminary calculations on a layered system, CoPS3, and found also some strange behaviour with the FIRE optimization of the periodic system with GFN0.

Atoms near the PBC boundaries show larger displacements which also could indicate that the boundary atoms do not interact properly with their neighbours through the PBC.

In this context, I would like to know if **it is possible to run fixed PBC optimizations or to select which cell parameters are optimized.

ps: great method and software BTW!

@zulissi
Copy link

zulissi commented Oct 27, 2020

FWIW, I found that using XTB for single-points in ASE and doing the optimization there (controlling cell parameters and free atoms etc) worked better for me than the internal optimizers. It still had the issues with PBC effects though.

@manuelmelle
Copy link

Thanks for the advice, I´ll try ASE and try to have a look at the source if I have some time.

From what you say, there seems to be a clear problem with the forces as mentioned, that depends on the system.
I computed other systems without trouble, but the one I am trying now is really problematic.

@zulissi
Copy link

zulissi commented Jan 24, 2021

Inspired by the suggestion that it might be a dispersion problem from grimme-lab/xtb-python#34, I removed the dispersion calculation and recompiled and it appears to be consistent now (at least on the same test structures he posted there).

FWIW, it would also be nice to have a settings to turn off the dispersion. We're using this as a base calculator to fit to DFT data that doesn't have dispersion, so regardless of PBC issues it's helpful to have it off.

@awvwgk awvwgk removed the help wanted Extra attention is needed label Jan 24, 2021
@awvwgk
Copy link
Member

awvwgk commented Jan 24, 2021

Thanks for reminding me on this, we recently were able to track this issue down to the generation of the lattice points (many thanks to @Thomas3R for spotting this).

I'll work on a patch for the 6.4.0 release this week.

@awvwgk awvwgk self-assigned this Jan 24, 2021
@awvwgk awvwgk added this to the v6.4.0 milestone Jan 24, 2021
@awvwgk awvwgk modified the milestones: v6.4.0, v6.4.1 Feb 1, 2021
@awvwgk awvwgk removed this from the v6.4.1 milestone Jun 10, 2021
@awvwgk
Copy link
Member

awvwgk commented Jun 10, 2021

Sorry for not following up on this issue for some time. I decided for a change in strategy for the periodic boundary conditions in xtb, because trying to implement everything here from scratch turned out quite time consuming and error prone.

Instead, I'm now working on a unified library implementation, which will be available in dftb+, xtb, qcxms, ... as common backend for the xTB Hamiltonians. I think this is the better way to go instead of creating monolithic projects. The next step on the periodic boundary conditions is therefore on getting a full k-point periodic xTB Hamiltonian into the dftb+ project.

@awvwgk awvwgk added this to the v6.5.0 milestone Sep 13, 2021
@awvwgk awvwgk added the method: xTB Related to the xTB Hamiltonian and its parametrisations label Mar 18, 2022
@awvwgk awvwgk modified the milestones: v6.5.0, v6.6.0 Apr 13, 2022
@awvwgk awvwgk removed their assignment Oct 1, 2022
@MtoLStoN MtoLStoN removed this from the v6.7.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working method: xTB Related to the xTB Hamiltonian and its parametrisations
Projects
None yet
Development

No branches or pull requests

5 participants