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

Energy jump when bond_graph_len becomes zero #79

Closed
2 of 4 tasks
PROA200 opened this issue Oct 5, 2023 · 4 comments
Closed
2 of 4 tasks

Energy jump when bond_graph_len becomes zero #79

PROA200 opened this issue Oct 5, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@PROA200
Copy link

PROA200 commented Oct 5, 2023

Version

0.2.1

Which OS(es) are you using?

  • MacOS
  • Windows
  • Linux

What happened?

When I compute the energy for a series of strained structures using CHGNet, I get a jump in the energy (and stress) when no edges remain in the bond graph (i.e., every pair of atoms is 3.0 A apart). This occurs silently, and I'm expecting the energy/stress to be smooth when the edges are broken. Am I missing something, or is there something wrong here?

Code snippet

import numpy as np
from pymatgen.core import Structure
from chgnet.model import CHGNet
import matplotlib.pyplot as plt

model = CHGNet.load()

distances = []
energies = []

struct = Structure(
    lattice=[
        [3.54216907, 0, 2.04507188],
        [1.18072406, 3.33958984, 2.04507188],
        [0, 0, 4.09014583],
    ],
    species=["Ag", "Br"],
    coords=[[0.0, 0.0, 0.0], [0.5, 0.5, 0.5]],
)

for strain in np.linspace(0, 0.1, 20):
    struct_copy = struct.copy()
    struct_copy.apply_strain(strain)
    distances.append(struct_copy.distance_matrix[0][1])
    energies.append(model.predict_structure(struct_copy)["e"])

plt.plot(distances, energies, "o-")
plt.gca().set(xlabel="Distance (Å)", ylabel="Energy (eV)")
plt.show()

gh-79

Log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@PROA200 PROA200 added the bug Something isn't working label Oct 5, 2023
@bowen-bd
Copy link
Collaborator

bowen-bd commented Oct 6, 2023

Hi,

Thanks a lot for reporting this issue, this is indeed a bug that leads to the concerning energy discontinuity in AgBr.

The energy jump becomes a serious issue in the AgBr structure because there exist a enormous sudden increase in the number of BondGraph edges at the discontinuity.
image

And we checked this issue is especially serious in AgBr composition, if we modify the composition the energy discontinuity is much smaller:
image

We will fix this bug and retrain the model, this will be released in the next release

@janosh
Copy link
Collaborator

janosh commented Oct 12, 2023

Closed by 1a558ea.

@janosh janosh closed this as completed Oct 12, 2023
@bowen-bd
Copy link
Collaborator

bowen-bd commented Oct 12, 2023

Additional notes for users concerned about this issue:

The discontinuity in the potential energy surface will only appear when a structure with a zero bond graph—meaning there are no paired atoms within 3 Å—transforms into a state with a non-zero bond graph (at least one pair of atoms within 3 Å).

This is particularly the case when applying strain to an AgBr structure. In general, especially during molecular dynamics simulations, it is highly unlikely to encounter structures with zero pairs within 3 Å. Therefore, even CHGNet versions <= 0.2.1 should work without issues for most use cases.

@bowen-bd
Copy link
Collaborator

bowen-bd commented Oct 23, 2023

This issue is now fully resolved: v0.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants