Skip to content

Commit

Permalink
add primitiveNeighborlist option
Browse files Browse the repository at this point in the history
  • Loading branch information
qzhu2017 committed Jul 8, 2023
1 parent 171d35a commit eeacab9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pyxtal_ff/descriptors/SO3.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import division
import numpy as np
from ase.neighborlist import NeighborList
from ase.neighborlist import NeighborList, NewPrimitiveNeighborList
from optparse import OptionParser
from scipy.special import sph_harm, spherical_in
from ase import Atoms
Expand All @@ -18,9 +18,10 @@ class SO3:
alpha: float, gaussian width parameter
derivative: bool, whether to calculate the gradient of not
weight_on: bool, if True, the neighbors with different type will be counted as negative
primitive: bool, use the asePrimitiveNeighborList
'''

def __init__(self, nmax=3, lmax=3, rcut=3.5, alpha=2.0, derivative=True, stress=False, cutoff_function='cosine', weight_on=False):
def __init__(self, nmax=3, lmax=3, rcut=3.5, alpha=2.0, derivative=True, stress=False, cutoff_function='cosine', weight_on=False, primitive=False):
# populate attributes
self.nmax = nmax
self.lmax = lmax
Expand All @@ -31,6 +32,7 @@ def __init__(self, nmax=3, lmax=3, rcut=3.5, alpha=2.0, derivative=True, stress=
self._type = "SO3"
self.cutoff_function = cutoff_function
self.weight_on = weight_on
self.PrimitiveNeighborList = primitive
return

def __str__(self):
Expand Down Expand Up @@ -322,7 +324,10 @@ def build_neighbor_list(self, atom_ids=None):
atom_ids = range(len(atoms))

cutoffs = [self.rcut/2]*len(atoms)
nl = NeighborList(cutoffs, self_interaction=False, bothways=True, skin=0.0)
if self.PrimitiveNeighborList:
nl = NewPrimitiveNeighborList(cutoffs, self_interaction=False, bothways=True, skin=0.0)
else:
nl = NeighborList(cutoffs, self_interaction=False, bothways=True, skin=0.0)
nl.update(atoms)

center_atoms = []
Expand Down

0 comments on commit eeacab9

Please sign in to comment.