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

fix new distance calculation for Dirichlet boundary conditions #16

Merged
merged 2 commits into from
Jan 20, 2022

Conversation

jrdegreeff
Copy link
Member

These changes to the sign of the distance have uncovered a bug in the SNAP code that assumed the old sign (hence the tests not passing). I have verified that doing yi - xi is incorrect for the LJ implementation (particles are attracted to each other way too much and accelerations blow up). I don't know anything about the SNAP code, so I don't want to go poking around changing signs, but I'd suggest that we fix that issue and get the tests passing again in a second commit before merging this PR.

@dallasfoster
Copy link
Collaborator

These changes to the sign of the distance have uncovered a bug in the SNAP code that assumed the old sign (hence the tests not passing). I have verified that doing yi - xi is incorrect for the LJ implementation (particles are attracted to each other way too much and accelerations blow up). I don't know anything about the SNAP code, so I don't want to go poking around changing signs, but I'd suggest that we fix that issue and get the tests passing again in a second commit before merging this PR.

In general the force between atom_i and atom_j is calculated using r_{ij}, that is the vectors with tail at atom_i and head at atom_j. In reference to the code, that means we need to return yi - xi since (essentially) yi = atom_j and xi = atom_i. The reason that the SNAP tests fail is because I am verifying them against LAMMPS results, which calculates r_{ij} as atom_j - atom_i. NBodySimulator uses r_{ij} = atom_i - atom_j.

@jrdegreeff
Copy link
Member Author

These changes to the sign of the distance have uncovered a bug in the SNAP code that assumed the old sign (hence the tests not passing). I have verified that doing yi - xi is incorrect for the LJ implementation (particles are attracted to each other way too much and accelerations blow up). I don't know anything about the SNAP code, so I don't want to go poking around changing signs, but I'd suggest that we fix that issue and get the tests passing again in a second commit before merging this PR.

In general the force between atom_i and atom_j is calculated using r_{ij}, that is the vectors with tail at atom_i and head at atom_j. In reference to the code, that means we need to return yi - xi since (essentially) yi = atom_j and xi = atom_i. The reason that the SNAP tests fail is because I am verifying them against LAMMPS results, which calculates r_{ij} as atom_j - atom_i. NBodySimulator uses r_{ij} = atom_i - atom_j.

The displacement vectors are all internal to InteratomicPotentials, so what NBodySimulator does should be irrelevant. Basically one way or another, the sign of the displacement needs to be consistent with the sign convention used in the force calculation. The forces are the only thing that are eventually passed to NBS via Atomistic. We can certainly stick with the convention that is accordance with LAMMPS, but I think this is indicative of a bug somewhere else in the force calculations.

@jrdegreeff jrdegreeff merged commit 1c182aa into main Jan 20, 2022
@jrdegreeff jrdegreeff deleted the dist-fix branch January 20, 2022 18:54
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.

2 participants