Modify neighbor list to handle multiple cutoffs. #238
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When implement aimnet2, we found that we needed the neighbor list to have have 2 cutoffs, a short range one for the local interactions and a longer one used for the charge and dispersion.
As originally implemented, the neighbor list only supported a single cutoff. After some exploration, the output of the neighbor list is negligible in terms of memory footprint, which definitely simplifies the approach we can take (and just focus on efficiency).
The way I implemented this is that the neighbor list will take a dict of cutoff values; r_ij and d_ij are calculated as usual (from the pairlist that was enumerated already), and then we just loop over the cutoffs, calculating the appropriate masks. Since the memory footprint is so small, instead of returning a single instance of PairListOutput, I return a dict of these, where keys that match the input keys for the cutoff.
This should make it both flexible and still easily readable. The
BaseNetwork
constructor will populate this cutoff dict automatically from the following parameters, if defined (dispersion and coulomb are optional):maximum_interaction_radius
,maximum_dispersion_interaction_radius
,maximum_coulomb_interaction_radius
.We might want to rename
maximum_interaction_radius
tomaximum_local_interaction_radius
or something of that sort to make it more explicit.Within the Core of the NNP itself (specifically
_model_Specific_input_preparation
), we can access the pair list outputs for a specific input just by giving the parameter key, e.g., :This avoided having to create any new variables that may not be used by all naps and this will be much clearer than indexing into a list (which I initially did).
Questions
maximum_interaction_radius
tomaximum_local_interaction_radius
? We can do this in a non-breaking way in the pydantic model by making an alias between the two parameters (so we could use either parameter name in the input file; I just think local might be clearer internally).Status