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

Allow calculation of isolated atom #426

Closed
wants to merge 3 commits into from

Conversation

tjgiese
Copy link

@tjgiese tjgiese commented May 2, 2024

Description

  1. plot_dimers.py: The --n-samples was not being respected when calculating the linear spacing. Furthermore, if the model contained a single atom type, then matplotlib returns a scalar axes variable rather than a list.
  2. _atomwise.py: Prevent assert failure when the system consists of a single atom
  3. _grad_output.py: If a system consists of a single atom, then pytorch will complain that there are no gradients to calculate. The proposed "fix" is to check if all of the configurations consist of 1 atom; if so, then don't call autograd - instead return zeros.

Motivation and Context

Previous version of nequip could not calculate the energy of an isolate atom. One often wants to create loss functions that fit relative energies (not just total energies). If an isolated atom cannot be calculated, then it prevents supermolecular calculation of molecule-atomic ion interactions, for example. A discussion of this issue, and the calculation of well-separated dimers, can be found on the allegro github project: mir-group/allegro#82

How Has This Been Tested?

I followed the nequip/allegro tutorial to generate si-deployed.pth. I then created a python script that reads the model file and an ase xyz file. The model is used to calculate the energy and forces. The energy of a well-separated dimer is verified to be twice the energy of the monomer.

Test environment

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds or improves functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation improvement (updates to user guides, docstrings, or developer docs)

Checklist:

  • My code follows the code style of this project and has been formatted using black.
  • All new and existing tests passed, including on GPU (if relevant).
  • I have added tests that cover my changes (if relevant).
  • The option documentation (docs/options) has been updated with new or changed options.
  • I have updated CHANGELOG.md.
  • I have updated the documentation (if relevant).

@tjgiese tjgiese marked this pull request as ready for review May 3, 2024 13:11
@tjgiese tjgiese changed the title Draft: allow calculation of isolated atom Allow calculation of isolated atom May 3, 2024
@tjgiese tjgiese closed this May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant