+[docs]
+classLattice(object):""" A lattice object. Essentially a matrix with conversion matrices. In general, it is assumed that length units are in Angstroms and angles are in
@@ -144,7 +149,9 @@
+[docs]
+ defget_points_in_sphere(self,frac_points,center,r,zip_results=True):""" Find all points within a sphere from the point taking into account periodic boundary conditions. This includes sites in other periodic
@@ -282,7 +295,9 @@
See the License for the specific language governing permissions andlimitations under the License."""
+
fromaseimportAtomsimportase.geometryimportnumpyasnpimportdscribe.utils.geometry
-
+[docs]
+classSystem(Atoms):"""Represents atomic systems that are used internally by the package. Inherits from the ase.Atoms class, but adds the possibility to cache various time-consuming quantities that can be shared when creating multiple
@@ -155,7 +160,9 @@
+[docs]
+ defget_cell_inverse(self):"""Get the matrix inverse of the lattice matrix."""ifself._cell_inverseisNone:self._cell_inverse=np.linalg.inv(self.get_cell())returnself._cell_inverse
+[docs]
+ defto_scaled(self,positions,wrap=False):"""Used to transform a set of positions to the basis defined by the cell of this system.
@@ -205,7 +218,10 @@
+[docs]
+ defto_cartesian(self,scaled_positions,wrap=False):"""Used to transform a set of relative positions to the cartesian basis defined by the cell of this system.
@@ -227,7 +243,10 @@
+[docs]
+ defget_displacement_tensor(self):"""A matrix where the entry A[i, j, :] is the vector self.cartesian_pos[j] - self.cartesian_pos[i].
@@ -261,7 +280,10 @@
+[docs]
+ defget_distance_matrix_within_radius(self,radius,pos=None,output_type="coo_matrix"):"""Calculates a sparse distance matrix by only considering distances
@@ -303,7 +328,10 @@
+
def_reset_structure(self):"""Resets the common structural information that is cached by this object. The caching is done in order to share common structural
@@ -351,6 +392,7 @@
See the License for the specific language governing permissions andlimitations under the License."""
-importsysimportnumpyasnp
-importsparseassp
-fromscipy.sparseimportcoo_matrixfromaseimportAtomsfromdscribe.descriptors.descriptorlocalimportDescriptorLocalfromdscribe.extimportACSFWrapper
-importdscribe.utils.geometry
-
+[docs]
+classACSF(DescriptorLocal):"""Implementation of Atom-Centered Symmetry Functions. Notice that the species of the central atom is not encoded in the output,
@@ -122,7 +122,9 @@
+[docs]
+ defcreate(self,system,centers=None,n_jobs=1,only_physical_cores=False,verbose=False):"""Return the ACSF output for the given systems and given centers.
@@ -256,7 +262,10 @@
+[docs]
+ defcreate_single(self,system,centers=None):"""Creates the descriptor for the given system. Args:
@@ -270,116 +279,53 @@
Source code for dscribe.descriptors.acsf
first dimension is given by the number of centers and the second dimension is determined by the get_number_of_features()-function. """
- # Check if there are types that have not been declared
- self.check_atomic_numbers(system.get_atomic_numbers())
+ # Validate and normalize system
+ positions=self.validate_positions(system.get_positions())
+ atomic_numbers=self.validate_atomic_numbers(system.get_atomic_numbers())
+ pbc=self.validate_pbc(system.get_pbc())
+ cell=self.validate_cell(system.get_cell(),pbc)# Create C-compatible list of atomic indices for which the ACSF is# calculated
- calculate_all=FalseifcentersisNone:
- calculate_all=True
- indices=np.arange(len(system))
- else:
- indices=centers
-
- # 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.
- ifcalculate_allandnotself.periodic:
- n_atoms=len(system)
- all_pos=system.get_positions()
- dmat=dscribe.utils.geometry.get_adjacency_matrix(
- self.r_cut,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.
- ifself.periodic:
- system=dscribe.utils.geometry.get_extended_system(
- system,self.r_cut,return_cell_indices=False
- )
-
- # 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]
- dmat_primary=dscribe.utils.geometry.get_adjacency_matrix(
- self.r_cut,central_pos,all_pos
- )
-
- # Create symmetric full matrix
- col=dmat_primary.col
- row=[
- indices[x]forxindmat_primary.row
- ]# Fix row numbering to refer to original system
- data=dmat_primary.data
- dmat=coo_matrix((data,(row,col)),shape=(n_atoms,n_atoms))
- dmat_lil=dmat.tolil()
- dmat_lil[col,row]=dmat_lil[row,col]
-
- # If G4 terms are requested, calculate also secondary neighbour distances
- iflen(self.g4_params)!=0:
- neighbour_indices=np.unique(col)
- neigh_pos=all_pos[neighbour_indices]
- dmat_secondary=dscribe.utils.geometry.get_adjacency_matrix(
- self.r_cut,neigh_pos,neigh_pos
- )
- col=[
- neighbour_indices[x]forxindmat_secondary.col
- ]# Fix col numbering to refer to original system
- row=[
- neighbour_indices[x]forxindmat_secondary.row
- ]# Fix row numbering to refer to original system
- dmat_lil[row,col]=np.array(dmat_secondary.data)
-
- 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
+ centers=np.arange(len(system))# Calculate ACSF with C++
- output=np.array(
- self.acsf_wrapper.create(
- system.get_positions(),
- system.get_atomic_numbers(),
- dmat_dense,
- neighbours,
- indices,
- ),
- dtype=np.float64,
+ out=self.init_descriptor_array(len(centers))
+ self.acsf_wrapper.create(
+ out,
+ positions,
+ atomic_numbers,
+ cell,
+ pbc,
+ centers,)
- returnoutput
+[docs]
+ defget_number_of_features(self):"""Used to inquire the final number of features that this descriptor will have. Returns: int: Number of features for this descriptor. """
- wrapper=self.acsf_wrapper
- descsize=(1+wrapper.n_g2+wrapper.n_g3)*wrapper.n_types
- descsize+=(wrapper.n_g4+wrapper.n_g5)*wrapper.n_type_pairs
+ returnself.acsf_wrapper.get_number_of_features()
+[docs]
+ defvalidate_derivatives_method(self,method,attach):ifnotattach:raiseValueError("ACSF derivatives can only be calculated with attach=True.")returnsuper().validate_derivatives_method(method,attach)
+[docs]
+ defvalidate_g2_params(self,value):"""Used to check the validity of given G2 parameters. Args:
@@ -442,14 +391,20 @@
Source code for dscribe.descriptors.acsf
ifnp.any(value[:,0]<=0)isTrue:raiseValueError("G2 eta parameters should be positive numbers.")
- self.acsf_wrapper.set_g2_params(value.tolist())
+ returnvalue.tolist()
+[docs]
+ defvalidate_g3_params(self,value):"""Used to check the validity of given G3 parameters and to initialize the C-memory layout for them.
@@ -465,14 +420,26 @@
Source code for dscribe.descriptors.acsf
ifvalue.ndim!=1:raiseValueError("g3_params should be a vector.")
- self.acsf_wrapper.g3_params=value.tolist()
+ returnvalue.tolist()
+
@property
- defg4_params(self):
- returnself.acsf_wrapper.g4_params
+ defg3_params(self):
+ returnself.acsf_wrapper.g3_params
- @g4_params.setter
- defg4_params(self,value):
+ @g3_params.setter
+ defg3_params(self,value):
+"""Used to check the validity of given G3 parameters and to
+ initialize the C-memory layout for them.
+
+ Args:
+ value(array): List of G3 parameters.
+ """
+ self.acsf_wrapper.g3_params=self.validate_g3_params(value)
+
+
+[docs]
+ defvalidate_g4_params(self,value):"""Used to check the validity of given G4 parameters and to initialize the C-memory layout for them.
@@ -498,14 +465,20 @@
Source code for dscribe.descriptors.acsf
ifnp.any(value[:,2]<=0)isTrue:raiseValueError("3-body G4 eta parameters should be positive numbers.")
- self.acsf_wrapper.g4_params=value.tolist()
+ returnvalue.tolist()
+[docs]
+ defvalidate_g5_params(self,value):"""Used to check the validity of given G5 parameters and to initialize the C-memory layout for them.
@@ -531,7 +504,17 @@
Source code for dscribe.descriptors.acsf
ifnp.any(value[:,2]<=0)isTrue:raiseValueError("3-body G5 eta parameters should be positive numbers.")
- self.acsf_wrapper.g5_params=value.tolist()
See the License for the specific language governing permissions and
limitations under the License."""
-importnumpyasnp
+importnumpyasnpfromaseimportAtomsimportase.geometry.cell
-importsparse
-
fromdscribe.descriptors.descriptormatriximportDescriptorMatrix
-fromdscribe.utils.dimensionalityimportis1d
-
importdscribe.ext
-
+[docs]
+ defcreate(self,system,n_jobs=1,only_physical_cores=False,verbose=False):"""Return the Coulomb matrix for the given systems. Args:
@@ -204,7 +209,10 @@
See the License for the specific language governing permissions and
limitations under the License."""
+
fromabcimportABC,abstractmethodimportnumpyasnpimportsparseassp
+importase.geometry.cell
+
fromdscribe.utils.speciesimportget_atomic_numbersimportjoblibfromjoblibimportParallel,delayed
-
+[docs]
+ @abstractmethoddefget_number_of_features(self):"""Used to inquire the final number of features that this descriptor will have.
@@ -154,7 +166,10 @@
+[docs]
+ defvalidate_derivatives_method(self,method):"""Used to validate and determine the final method for calculating the derivatives. """
@@ -167,6 +182,7 @@
+[docs]
+ defvalidate_species(self,value):
+"""Used to validate the species information.
+
+ Args:
+ species(iterable): Chemical species either as a list of atomic
+ numbers or list of chemical symbols.
+
+ Returns:
+ List of atomic numbers.
+ """
+ returnget_atomic_numbers(value)
+
+
+
+[docs]
+ defvalidate_atomic_numbers(self,atomic_numbers):"""Used to check that the given atomic numbers have been defined for this descriptor.
@@ -226,9 +259,65 @@
Source code for dscribe.descriptors.descriptor
raise ValueError("The following atomic numbers are not defined ""for this descriptor: {}".format(zs.difference(self._atomic_number_set))
- )
+ )
+ returnatomic_numbers
+
+
+
+[docs]
+ defvalidate_positions(self,positions):
+"""Used to check that the cartesian positions are valid.
-
[docs]defformat_array(self,input):
+ Args:
+ positions(np.ndarray): Positions to check .
+
+ Raises:
+ ValueError: If the atomic numbers in the given system are not
+ included in the species given to this descriptor.
+ """
+ # Check that the system does not have elements that are not in the list
+ # of atomic numbers
+ ifnp.isnan(positions.any()):
+ raiseValueError(
+ "The given system has a NaN value in the atomic positions."
+ )
+ returnpositions
+
+
+
+[docs]
+ defvalidate_pbc(self,pbc):
+"""Used to check that the given pbc cell is valid and return a
+ normalized value.
+
+ Args:
+ pbc(np.ndarray): Cell periodicity as three booleans.
+ """
+ returnnp.asarray(pbc,dtype=bool)
+
+
+
+[docs]
+ defvalidate_cell(self,cell,pbc):
+"""Used to check that the given unit cell is valid.
+
+ Args:
+ cell(np.ndarray): 3x3 unit cell.
+ pbc(np.ndarray): Cell periodicity as three booleans.
+
+ Raises:
+ ValueError: If the given cell is invalid.
+ """
+ ifself.periodicandany(pbc)andcell.volume==0:
+ raiseValueError(
+ "Cannot compute periodic descriptor on a zero-volume cell."
+ )
+ returnase.geometry.cell.complete_cell(cell)
+
+
+
+[docs]
+ defformat_array(self,input):"""Used to format a float64 numpy array in the final format that will be returned to the user. """
@@ -239,7 +328,10 @@
+
def_get_indices(self,n_atoms,include,exclude):"""Given the number of atoms and which indices to include or exclude, returns a list of final indices that will be used. If not includes or
@@ -445,7 +538,9 @@
Source code for dscribe.descriptors.descriptorglobal
See the License for the specific language governing permissions and
limitations under the License."""
+
importnumpyasnpimportsparseasspfromaseimportAtoms
@@ -102,10 +105,14 @@
Source code for dscribe.descriptors.descriptorglobal
Source code for dscribe.descriptors.descriptorlocal
See the License for the specific language governing permissions and
limitations under the License."""
+
importnumpyasnp
-importsparseasspfromaseimportAtomsfromdscribe.descriptors.descriptorimportDescriptorfromdscribe.utils.dimensionalityimportis1d
-
+[docs]
+classDescriptorLocal(Descriptor):"""An abstract base class for all local descriptors."""def__init__(self,periodic,sparse,dtype="float64",average="off"):super().__init__(periodic=periodic,sparse=sparse,dtype=dtype)self.average=average
-
+[docs]
+ defvalidate_derivatives_method(self,method,attach):"""Used to validate and determine the final method for calculating the derivatives. """
@@ -122,7 +128,10 @@
Source code for dscribe.descriptors.descriptorlocal
+[docs]
+ definit_descriptor_array(self,n_centers):"""Return a zero-initialized numpy array for the descriptor."""n_features=self.get_number_of_features()ifself.average!="off":
@@ -319,7 +331,10 @@
Source code for dscribe.descriptors.descriptorlocal
c =np.zeros((n_centers,n_features),dtype=np.float64)returnc
+[docs]
+ definit_derivatives_array(self,n_centers,n_indices):"""Return a zero-initialized numpy array for the derivatives."""n_features=self.get_number_of_features()ifself.average!="off":
@@ -327,7 +342,10 @@
Source code for dscribe.descriptors.descriptorlocal
Source code for dscribe.descriptors.descriptormatrix
See the License for the specific language governing permissions and
limitations under the License."""
+
importnumpyasnpfromnumpy.randomimportRandomState
@@ -105,7 +108,9 @@
Source code for dscribe.descriptors.descriptormatrix
from dscribe.descriptors.descriptorglobalimportDescriptorGlobal
-
Source code for dscribe.descriptors.descriptormatrix
Returns:
ndarray: The zero padded matrix either as a 1D array. """
+ # Validate positions
+ self.validate_positions(system.get_positions())
+
# Remove the old norm vector for the new systemself._norm_vector=None
@@ -214,7 +227,10 @@
Source code for dscribe.descriptors.descriptormatrix
+[docs]
+ defget_eigenspectrum(self,matrix):"""Calculates the eigenvalues of the matrix and returns a list of them sorted by their descending absolute value.
@@ -257,7 +276,10 @@
Source code for dscribe.descriptors.descriptormatrix
+[docs]
+ defsort_randomly(self,matrix,sigma):""" Given a coulomb matrix, it adds random noise to the sorting defined by sigma. For sorting, L2-norm is used.
@@ -310,6 +338,7 @@
Source code for dscribe.descriptors.descriptormatrix
return matrix
+
def_get_norm_vector(self,matrix):""" Takes a coulomb matrix as input. Returns L2 norm of each row / column in a 1D-array.
@@ -324,7 +353,9 @@
Source code for dscribe.descriptors.descriptormatrix
+[docs]
+ defunflatten(self,features,n_systems=None):""" Can be used to "unflatten" a matrix descriptor back into a 2D array. Useful for testing and visualization purposes.
@@ -363,7 +394,9 @@
Source code for dscribe.descriptors.descriptormatrix
+[docs]
+ defget_matrix(self,system):""" The total energy matrix. Each matrix element (i, j) corresponds to the total interaction energy in a system with atoms i and j.
@@ -332,6 +345,7 @@
Source code for dscribe.descriptors.ewaldsummatrix
return total
+
def_calc_zero(self):"""Calculates the constant part of the Ewald sum matrix.
@@ -472,6 +486,7 @@
Source code for dscribe.descriptors.ewaldsummatrix
+[docs]
+ defcreate(self,system,centers=None,n_jobs=1,only_physical_cores=False,verbose=False):"""Return the LMBTR output for the given systems and given centers.
@@ -453,7 +463,10 @@
centers, for k terms, as an array. These are ordered as given in centers. """
- # Check that the system does not have elements that are not in the list
- # of atomic numbers
- atomic_number_set=set(system.get_atomic_numbers())
- self.check_atomic_numbers(atomic_number_set)
+ # Validate and normalize system
+ self.validate_positions(system.get_positions())
+ atomic_numbers=self.validate_atomic_numbers(system.get_atomic_numbers())
+ pbc=self.validate_pbc(system.get_pbc())
+ self.validate_cell(system.get_cell(),pbc)self._interaction_limit=len(system)system_positions=system.get_positions()
- system_atomic_numbers=system.get_atomic_numbers()# Ensure that the atomic number 0 is not present in the system
- if0inatomic_number_set:
+ if0inset(atomic_numbers):raiseValueError("Please do not use the atomic number 0 in local MBTR as it ""is reserved to mark the atoms use as analysis centers."
@@ -521,7 +534,7 @@
+[docs]
+ defget_location(self,species):"""Can be used to query the location of a species combination in the the flattened output.
@@ -946,7 +965,7 @@
Source code for dscribe.descriptors.lmbtr
numbers.append(specie)# Check that species exists and that X is included
- self.check_atomic_numbers(numbers)
+ self.validate_atomic_numbers(numbers)if0notinnumbers:raiseValueError("The central species X (atomic number 0) has to be one of the elements."
@@ -989,7 +1008,9 @@
See the License for the specific language governing permissions andlimitations under the License."""
+
importsysimportmathimportnumpyasnp
@@ -115,7 +118,9 @@
+[docs]
+defcheck_weighting(k:int,weighting:dict,periodic:bool):"""Used to ensure that the given weighting settings are valid. Args:
@@ -206,7 +217,10 @@
Source code for dscribe.descriptors.mbtr
raiseValueError("Periodic systems need to have a weighting function.")
+[docs]
+classMBTR(DescriptorGlobal):"""Implementation of the Many-body tensor representation. You can use this descriptor for finite and periodic systems. When dealing
@@ -216,7 +230,9 @@
+[docs]
+ defcreate(self,system,n_jobs=1,only_physical_cores=False,verbose=False):"""Return MBTR output for the given systems. Args:
@@ -471,7 +490,10 @@
+[docs]
+ defcreate_single(self,system):"""Return the many-body tensor representation for the given system. Args:
@@ -485,9 +507,11 @@
Source code for dscribe.descriptors.mbtr
self.system=systemself._interaction_limit=len(system)
- # Check that the system does not have elements that are not in the list
- # of atomic numbers
- self.check_atomic_numbers(system.get_atomic_numbers())
+ # Validate and normalize system
+ self.validate_positions(system.get_positions())
+ self.validate_atomic_numbers(system.get_atomic_numbers())
+ pbc=self.validate_pbc(system.get_pbc())
+ self.validate_cell(system.get_cell(),pbc)mbtr,_=getattr(self,f"_get_k{self.k}")(system,True,False)
@@ -500,7 +524,10 @@
+[docs]
+ defget_location(self,species):"""Can be used to query the location of a species combination in the the output.
@@ -556,7 +586,7 @@
Source code for dscribe.descriptors.mbtr
numbers.append(specie)# Check that species exists
- self.check_atomic_numbers(numbers)
+ self.validate_atomic_numbers(numbers)# Change into internal indexingnumbers=[self.atomic_number_to_index[x]forxinnumbers]
@@ -603,6 +633,7 @@
Source code for dscribe.descriptors.mbtr
returnslice(start,end)
+
def_get_k1(self,system,return_descriptor,return_derivatives):"""Calculates the first order term and/or its derivatives with regard to atomic positions.
@@ -966,7 +997,9 @@
+[docs]
+ defvalidate_derivatives_method(self,method):"""Used to validate and determine the final method for calculating the derivatives. """
@@ -1006,14 +1039,17 @@
+[docs]
+ defderivatives_analytical(self,d,c,system,indices,return_descriptor):# Ensuring variables are re-initialized when a new system is introducedself.system=systemself._interaction_limit=len(system)# Check that the system does not have elements that are not in the list# of atomic numbers
- self.check_atomic_numbers(system.get_atomic_numbers())
+ self.validate_atomic_numbers(system.get_atomic_numbers())mbtr,mbtr_d=getattr(self,f"_get_k{self.k}")(system,return_descriptor,True)
@@ -1031,7 +1067,9 @@
See the License for the specific language governing permissions and
limitations under the License."""
+
importnumpyasnpfromaseimportAtoms
@@ -105,7 +108,9 @@
Source code for dscribe.descriptors.sinematrix
from dscribe.descriptors.descriptormatriximportDescriptorMatrix
-
+[docs]
+classSineMatrix(DescriptorMatrix):"""Calculates the zero padded Sine matrix for different systems. The Sine matrix is defined as:
@@ -129,7 +134,9 @@
+[docs]
+ defcreate(self,system,n_jobs=1,only_physical_cores=False,verbose=False):"""Return the Sine matrix for the given systems. Args:
@@ -179,7 +186,10 @@
+[docs]
+ defget_matrix(self,system):"""Creates the Sine matrix for the given system. Args:
@@ -196,7 +206,7 @@
Source code for dscribe.descriptors.sinematrix
B =system.get_cell()try:B_inv=system.get_cell_inverse()
- except:
+ exceptException:raiseValueError("The given system has a non-invertible cell matrix: {}.".format(B))
@@ -222,7 +232,9 @@
Source code for dscribe.descriptors.sinematrix
# Set diagonal
np.fill_diagonal(smat,0.5*q**2.4)
- returnsmat
See the License for the specific language governing permissions andlimitations under the License."""
+
fromwarningsimportwarnimportnumpyasnp
@@ -113,7 +116,9 @@
+[docs]
+classSOAP(DescriptorLocal):"""Class for generating a partial power spectrum from Smooth Overlap of Atomic Orbitals (SOAP). This implementation uses real (tesseral) spherical harmonics as the angular basis set and provides two orthonormalized
@@ -136,7 +141,9 @@
# Setup the involved chemical speciesself.species=species
-
# Test that general settings are validifsigma<=0:raiseValueError(
@@ -312,7 +318,6 @@
Source code for dscribe.descriptors.soap
"one of the following: {}".format(average,supported_average))
-
ifnot(weightingorr_cut):raiseValueError("Either weighting or r_cut need to be defined")ifweighting:
@@ -390,11 +395,11 @@
+[docs]
+ defprepare_centers(self,system,centers=None):"""Validates and prepares the centers for the C++ extension."""
- # Check that the system does not have elements that are not in the list
- # of atomic numbers
- self.check_atomic_numbers(system.get_atomic_numbers())# Check if periodic is validifself.periodic:
@@ -432,7 +437,10 @@
+[docs]
+ defget_cutoff_padding(self):"""The radial cutoff is extended by adding a padding that depends on the used used sigma value. The padding is chosen so that the gaussians decay to the specified threshold value at the cutoff distance.
@@ -441,6 +449,7 @@
+[docs]
+ defcreate(self,system,centers=None,n_jobs=1,only_physical_cores=False,verbose=False):"""Return the SOAP output for the given systems and given centers.
@@ -574,7 +591,10 @@
+[docs]
+ defcreate_single(self,system,centers=None):"""Return the SOAP output for the given system and given centers. Args:
@@ -591,11 +611,15 @@
Source code for dscribe.descriptors.soap
centers and the second dimension is determined by the get_number_of_features()-function. """
+ # Validate and normalize system
+ positions=self.validate_positions(system.get_positions())
+ atomic_numbers=self.validate_atomic_numbers(system.get_atomic_numbers())
+ pbc=self.validate_pbc(system.get_pbc())
+ cell=self.validate_cell(system.get_cell(),pbc)
+
cutoff_padding=self.get_cutoff_padding()centers,_=self.prepare_centers(system,centers)n_centers=centers.shape[0]
- pos=system.get_positions()
- Z=system.get_atomic_numbers()soap_mat=self.init_descriptor_array(n_centers)# Determine the function to call based on rbf
@@ -624,10 +648,10 @@
+[docs]
+ defvalidate_derivatives_method(self,method,attach):"""Used to validate and determine the final method for calculating the derivatives. """
@@ -715,7 +742,10 @@
+[docs]
+ defget_location(self,species):"""Can be used to query the location of a species combination in the the flattened output.
@@ -1095,7 +1132,10 @@
+[docs]
+classValleOganov(MBTR):"""Shortcut for implementing the fingerprint descriptor by Valle and Oganov for using MBTR. Automatically uses the right weighting and normalizes the output, and can only be used for periodic systems.
@@ -94,7 +98,9 @@
Source code for dscribe.descriptors.valleoganov
<
as the other parameters and general usage of the descriptor, see the MBTR class. """
-
See the License for the specific language governing permissions and
limitations under the License."""
+
importnumpyasnpfromdscribe.kernels.localsimilaritykernelimportLocalSimilarityKernel
-
+[docs]
+classAverageKernel(LocalSimilarityKernel):"""Used to compute a global similarity of structures based on the average similarity of local atomic environments in the structure. More precisely, returns the similarity kernel K as:
@@ -116,7 +121,9 @@
Source code for dscribe.kernels.localsimilaritykernel
See the License for the specific language governing permissions and
limitations under the License."""
+
fromabcimportABC,abstractmethodimportnumpyasnp
@@ -106,7 +109,9 @@
Source code for dscribe.kernels.localsimilaritykernel
from sklearn.metrics.pairwiseimportpairwise_kernels
-
+[docs]
+classLocalSimilarityKernel(ABC):"""An abstract base class for all kernels that use the similarity of local atomic environments to compute a global similarity measure. """
@@ -151,7 +156,9 @@
Source code for dscribe.kernels.localsimilaritykernel
+[docs]
+ defget_pairwise_matrix(self,X,Y=None):"""Calculates the pairwise similarity of atomic environments with scikit-learn, and the pairwise metric configured in the constructor.
@@ -265,7 +275,10 @@
Source code for dscribe.kernels.localsimilaritykernel
+[docs]
+ @abstractmethoddefget_global_similarity(self,localkernel):""" Computes the global similarity between two structures A and B.
@@ -275,7 +288,9 @@
Source code for dscribe.kernels.localsimilaritykernel
structures A and B, with N and M atoms respectively.
Returns: float: Global similarity between the structures A and B.
- """
See the License for the specific language governing permissions and
limitations under the License."""
+
importnumpyasnpfromdscribe.kernels.localsimilaritykernelimportLocalSimilarityKernel
-
+[docs]
+classREMatchKernel(LocalSimilarityKernel):"""Used to compute a global similarity of structures based on the regularized-entropy match (REMatch) kernel of local atomic environments in the structure. More precisely, returns the similarity kernel K as:
@@ -168,7 +173,9 @@
See the License for the specific language governing permissions andlimitations under the License."""
+
importnumpyasnpimportscipy.sparse
@@ -105,7 +108,9 @@
+[docs]
+defget_adjacency_matrix(radius,pos1,pos2=None,output_type="coo_matrix"):"""Calculates a sparse adjacency matrix by only considering distances within a certain cutoff. Uses a k-d tree to reach O(n log(N)) time complexity.
@@ -147,7 +152,10 @@
+[docs]
+defget_adjacency_list(adjacency_matrix):"""Used to transform an adjacency matrix into an adjacency list. The adjacency list provides much faster access to the neighbours of a node.
@@ -172,7 +180,10 @@
+[docs]
+defget_extended_system(system,radial_cutoff,centers=None,return_cell_indices=False):"""Used to create a periodically extended system. If centers are not specified, simply takes returns the original system multiplied by an integer amount of times in each direction to cover the radial cutoff. If
@@ -306,6 +317,7 @@
+[docs]
+defget_atomic_numbers(species):"""Given a list of chemical species either as a atomic numbers or chemical symbols, return the correponding list of ordered atomic numbers with duplicates removed.
@@ -161,6 +169,7 @@
See the License for the specific language governing permissions andlimitations under the License."""
+
fromaseimportAtomsfromdscribe.core.systemimportSystemimportnumpyasnp
-
If you encounter issues with the software please submit them directly as
GitHub issues. For general
discussion and possible improvements/additions use the GitHub discussion forum. This ensures that all
issues/discussion are publicly available and archived.
This project has received funding from the Jenny and Antti Wihuri Foundation
and the European Union’s Horizon 2020 research and innovation programme under
grant agreements number no. 676580 NOMAD and no. 686053 CRITCAT.