message: Added check for doing certain optimizations based on what positions are requested and if the system is periodic.
diff: @@ -173,19 +173,32 @@ class ACSF(Descriptor):
  # Create C-compatible list of atomic indices for which the ACSF is
  # calculated
  + calculate_all = False
  if positions is None:
  + calculate_all = True
  indices = np.arange(len(system))
  else:
  indices = positions
  + # If periodicity is not requested, and the output is requested for all
  + # atoms, we skip all the intricate optimizations that will make things
  + # actually slower for this case.
  + if calculate_all and not self.periodic:
  + n_atoms = len(system)
  + all_pos = system.get_positions()
  + dmat = dscribe.utils.geometry.get_adjacency_matrix(self.rcut, all_pos, all_pos)
  + # Otherwise the amount of pairwise distances that are calculated is
  + # kept at minimum. Only distances for the given indices (and possibly
  + # the secondary neighbours if G4 is specified) are calculated.
  + else:
  # Create the extended system if periodicity is requested. For ACSF only
  # the distance from central atom needs to be considered in extending
  # the system.
  if self.periodic:
  system = dscribe.utils.geometry.get_extended_system(system, self.rcut, return_cell_indices=False)
  - # First calculate distances from specified centers to all other atoms.
  - # This is already enough for everything else except G4.
  + # First calculate distances from specified centers to all other
  + # atoms. This is already enough for everything else except G4.
  n_atoms = len(system)
  all_pos = system.get_positions()
  central_pos = all_pos[indices]
  @@ -208,8 +221,9 @@ class ACSF(Descriptor):
  row = [neighbour_indices[x] for x in dmat_secondary.row] # Fix row numbering to refer to original system
  dmat_lil[row, col] = np.array(dmat_secondary.data)
  - # Get adjancency list and full dense adjancency matrix
  dmat = dmat_lil.tocoo()
  +
  + # Get adjancency list and full dense adjancency matrix
  neighbours = dscribe.utils.geometry.get_adjacency_list(dmat)
  dmat_dense = np.full((n_atoms, n_atoms), sys.float_info.max) # The non-neighbor values are treated as "infinitely far".
  dmat_dense[dmat.col, dmat.row] = dmat.data
  