-
Notifications
You must be signed in to change notification settings - Fork 8
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
Virial and Lammps interface #9
Comments
Hi @Huni-ML , Regarding NPT / stress / virial support in Regarding your other questions, @anjohan ? |
Hi @Huni-ML , The Allegro model simply does not output stress, so this won't work. Alby is working on implementing it. Unlike NequIP, the Allegro model does not get a cell with respect to which it can take a derivative. For the time being, you can run NPT on a single GPU using The As for eng_vdwl = 0.0;
#pragma omp parallel for reduction(+:eng_vdwl)
for(int ii = 0; ii < ntotal; ii++){
int i = ilist[ii];
f[i][0] = forces[i][0];
f[i][1] = forces[i][1];
f[i][2] = forces[i][2];
if (eflag_atom && ii < inum) eatom[i] = atomic_energies[i][0];
if(ii < inum) eng_vdwl += atomic_energies[i][0];
}
} |
Thanks for your reply! I will use Z = torch.autograd.grad(
energy,
rij_vectors,
create_graph=self.training,
retain_graph=self.training,
)
result["stress_volume"] = torch.matmul(
Z[0].t(), rij_vectors
) # Only consider one graph here In my own package, it gives similar results with the cell-derivative strain. Seems to be suitable for Allegro. |
@Huni-ML to clarify, |
Thanks for the clarification and that's what I'm doing. Thank you for the reminder! I have used Best Regards! |
@Huni-ML We usually train on stress and find that it helps with getting the correct lattice parameter. You may, however, need to re-check the DFT convergence, as stress can be harder to converge than energy and forces. |
@anjohan I only collect calculations that reach DFT convergence so I think it works. Thanks! |
@Linux-cpp-lisp @anjohan Hi, I submit a pull request that could be used for Allegro virial parallelism calculation just then. It's so urgent for me so I try it myself. With the atom virial without usage of cell, it should be suitable for allegro. |
Hi @Huni-ML , Wow! 😆 Very nice! I was waiting for it to be a little further along before I sent the link here, but we very recently have (most) of a finished stress implementation on the Please feel free also to do your LAMMPS tests using our Do you have any thoughts on these two different approaches to computing the stress? Are they equivalent? Are there important advantages/disadvantages of one or the other? Thank you for your efforts to contribute back into our codebase! |
Hi @Linux-cpp-lisp ,
I'm not sure about the correctness of this approach though.
In a word, 'edge_vec' calculated in |
Hi @Linux-cpp-lisp |
Great @Huni-ML !! Just to fill in the gaps for myself in your derivation: in general, $$ If $$ due to Allegro's strict locality which implies that If $$ once again by strict locality of Allegro. So your derivation follows by:
isn't the minus sign wrong? And I'm assuming in this line only refers to Does this all seem correct to you? |
Hi @Linux-cpp-lisp , The minus sign below is carefully checked and should exists so now it should give the correct sign for Lammps. I will do some NPT simulations to ensure its corectness with some simple examples in the future.
I make a throughout analysis of this edge-vector-based atomic virial method in the new version of this preprint in reseach gate and you can check more details there in page 11. Best regards. |
Hi everyone, I'm recently looking for a way to implementing virials. Thanks for reading this comment! |
Can I just add lines below from pair_nequip to use virial for NPT simulations?
I use
+=
instead of=
to accumulate different blocks of virial for parallel computation.Or just use
if (vflag_fdotr) virial_fdotr_compute();
?Also, does it make sense to assign
eng_vdwl = 0.0;
? In general Lammps NN interface such as DeepMD and IAP,eng_vdwl += ...
is implemented. Same to the forcef
andeatom
.In my situation for phase transitions, NPT simulations are vital so a pair_allegro with reliable virial is demanding.
Thank you for the help in advance!
The text was updated successfully, but these errors were encountered: