Additional Python components

BaseOptimizer

BaseOptimizer serves as base for all optimizers.

class icet.fitting.base_optimizer.BaseOptimizer(fit_data, fit_method, standardize=True, seed=42)

BaseOptimizer class.

Serves as base class for all Optimizers solving Ax = y.

Parameters:
  • fit_data (tuple of NumPy (N, M) array and NumPy (N) array) – the first element of the tuple represents the fit matrix A whereas the second element represents the vector of target values y; here N (=rows of A, elements of y) equals the number of target values and M (=columns of A) equals the number of parameters
  • fit_method (string) – method to be used for training; possible choice are “least-squares”, “lasso”, “elasticnet”, “bayesian-ridge”, “ardr”
  • standardize (bool) – whether or not to standardize the fit matrix before fitting
  • seed (int) – seed for pseudo random number generator
compute_rmse(A, y)

Compute the root mean square error using the A, y, and the vector of fitted parameters x corresponding to ||Ax-y||_2.

Parameters:
  • A (NumPy (N, M) array) – fit matrix where N (=rows of A, elements of y) equals the number of target values and M (=columns of A) equals the number of parameters (=elements of x)
  • y (NumPy (N) array) – vector of target values
Returns:

root mean squared error

Return type:

float

fit_method

string – fit method.

get_contributions(A)

Compute the average contribution to the predicted values from each element of the parameter vector.

Parameters:A (NumPy (N, M) array) – fit matrix where N (=rows of A, elements of y) equals the number of target values and M (=columns of A) equals the number of parameters
Returns:average contribution for each row of A from each parameter
Return type:NumPy (N, M) array
number_of_nonzero_parameters

int – number of non-zero parameters

number_of_parameters

int – number of parameters (=columns in A matrix).

number_of_target_values

int – number of target values (=rows in A matrix).

parameters

NumPy array – copy of parameter vector.

predict(A)

Predict data given an input matrix A, i.e., Ax, where x is the vector of the fitted parameters.

Parameters:A (NumPy (N, M) array or NumPy (M, )) – fit matrix where N (=rows of A, elements of y) equals the number of target values and M (=columns of A) equals the number of parameters
Returns:vector of predicted values
Return type:NumPy (N) array, or float if single row is inputed
seed

int – seed used to initialize pseudo random number generator.

standardize

bool – whether or not to standardize the fit matrix before fitting.

summary

dict – Comprehensive information about the optimizer.

Geometry

icet.tools.geometry.add_vacuum_in_non_pbc(atoms)

Adds vacuum in non-periodic directions.

Parameters:atoms (Atoms) – input atomic structur
Returns:input atomic structure with vacuum in non-pbc directions
Return type:atoms
icet.tools.geometry.ase_atoms_to_spglib_cell(atoms)

Returns a tuple of three components: cell metric, atomic positions, and atomic species of the input ASE Atoms object.

Return type:Tuple[ndarray, ndarray, ndarray]
icet.tools.geometry.find_lattice_site_by_position(atoms, position, tol=0.0001)

Tries to construct a lattice site equivalent from position in reference to the atoms object.

atoms
input atomic structure
position
presumed cartesian coordinates of a lattice site
Return type:LatticeSite
icet.tools.geometry.find_permutation(target, permutated)

Returns the permutation vector that takes permutated to target.

Parameters:
  • target (Sequence[~T]) – a container that supports indexing and its elements contain objects with __eq__ method
  • permutated (Sequence[~T]) – a container that supports indexing and its elements contain objects with __eq__ method
Return type:

List[int]

icet.tools.geometry.fractional_to_cartesian(atoms, frac_positions)

Turns fractional positions into cartesian positions.

Parameters:
  • atoms (Atoms) – input atomic structure
  • frac_positions (List[List[float]]) – fractional positions
Return type:

List[List[float]]

icet.tools.geometry.get_fractional_positions_from_ase_neighbor_list(atoms, neighbor_list)

Returns the fractional positions of the lattice sites in atomic structure from a neighbor list.

Parameters:
  • atoms (Atoms) – input atomic structure
  • neighbor_list (NeighborList) – list of neighbors of the input structure
Return type:

List[List[float]]

icet.tools.geometry.get_fractional_positions_from_neighbor_list(structure, neighbor_list)

Returns the fractional positions of the lattice sites in structure from a neighbor list.

Parameters:
  • atoms – input atomic structure
  • neighbor_list (NeighborList) – list of lattice neighbors of the input structure
Return type:

List[List[float]]

icet.tools.geometry.get_permutation(container, permutation)

Returns the permuted version of container.

Return type:Sequence[~T]
icet.tools.geometry.get_position_from_lattice_site(atoms, lattice_site)

Gets the corresponding position from the lattice site.

Parameters:
  • atoms (Atoms) – input atomic structure
  • lattice_site (LatticeSite) – specific lattice site of the input structure
icet.tools.geometry.get_primitive_structure(atoms, no_idealize=True)

Determines primitive structure using spglib.

Parameters:
  • atoms (Atoms) – input atomic structure
  • no_idealize (bool) – If True, disable to idealize length and angles
Returns:

primitive structure

Return type:

atoms_prim

icet.tools.geometry.get_scaled_positions(positions, cell, wrap=True, pbc=[True, True, True])

Returns the positions in reduced (or scaled) coordinates.

Parameters:
  • positions (ndarray) – atomic positions in cartesian coordinates
  • cell (ndarray) – cell metric
  • wrap (bool) – if True, positions outside the unit cell will be wrapped into the cell in the directions with periodic boundary conditions such that the scaled coordinates are between zero and one.
  • pbc (List[bool]) – periodic boundary conditions flags
Return type:

ndarray

LocalOrbitListGenerator

class icet.core.local_orbit_list_generator.LocalOrbitListGenerator
clear()
generate_full_orbit_list()
generate_local_orbit_list()
get_prim_to_supercell_map()
get_unique_offsets_count()
get_unique_primcell_offsets()

ManyBodyNeighborList

class icet.core.many_body_neighbor_list.ManyBodyNeighborList
build()
calculate_intersection()

NeighborList

icet.core.neighbor_list.get_neighbor_lists(atoms, cutoffs=None)

Returns list of icet neighbor lists from a configuration and cutoffs.

Parameters:
  • atoms (ASE Atoms object / icet Structure object (bi-optional)) – atomic configuration
  • cutoffs – positive floats indicating the cutoffs for the various clusters
Returns:

Return type:

list of NeighborList objects

Orbit

class icet.core.orbit.Orbit
add_equivalent_sites()
allowed_permutations

Get the list of equivalent permutations for this orbit.

If this orbit is a triplet and the permutation [0,2,1] exists this means that The lattice sites [s1, s2, s3] are equivalent to [s1, s3, s2] This will have the effect that for a ternary CE the cluster functions (0,1,0) will not be considered since it is equivalent to (0,0,1).

equivalent_sites

List of equivalent Lattice Sites

get_all_possible_mc_vector_permutations()

Similar to get all permutations but needs to be filtered through the number of allowed elements.

Parameters:
  • allowed_components (list of int) – The allowed components for the lattice sites, allowed_components[i] correspond to the lattice site self.representative_sites[i].
  • all_mc_vectors (returns) –
get_allowed_sites_permutations()
get_equivalent_sites()
get_equivalent_sites_permutations()
get_mc_vectors()

Return the mc vectors for this orbit given the allowed components. The mc vectors are returned as a list of tuples

Parameters:allowed_components (list of int) – The allowed components for the lattice sites, allowed_components[i] correspond to the number of allowed compoments at lattice site orbit.representative_sites[i].
get_representative_cluster()

The representative cluster represents the geometrical version of what this orbit is.

get_representative_sites()
get_sites_with_permutation()

Return the permuted to representative sites of equivalent_sites[index].

order

Returns the order of the orbit. The order is the same as the number of bodies in the representative cluster or the number of lattice sites per element in equivalent_sites.

permutations_to_representative

list of permutations; permutations_to_representative[i] takes self.equivalent_sites[i] to the same order as self.representative_sites.

This can be used if you for example want to count elements and are interested in difference between ABB, BAB, BBA and so on. If you count the lattice sites that are permuted according to these permutations then you will get the correct counts.

permuted_sites

Get the equivalent sites but permuted to representative site.

radius

Returns the radius of the representative cluster.

representative_cluster

The representative cluster represents the geometrical version of what this orbit is.

representative_sites

The representative sites is a list of lattice sites that are uniquely picked out for this orbit which can be used to represent and distinguish between orbits.

sort()

Sort the equivalent sites list.

OrbitList

class icet.core.orbit_list.OrbitList(atoms, cutoffs)

The orbit list object has an internal list of orbits.

An orbit has a list of equivalent sites with the restriction that at least one site is in the cell of the primitive structure.

Parameters:
  • atoms (ASE Atoms object) – This atoms object will be used to construct a primitive structure on which all the lattice sites in the orbits are based on.
  • cutoffs (list of float) – cutoffs[i] is the cutoff for orbits with order i+2.
add_orbit()

Add an Orbit object to the OrbitList

clear()

Clears the OrbitList

find_orbit()

Return the index of the orbit with the given representative cluster

get_number_of_NClusters()

Returns the number of orbits in the OrbitList

get_orbit()

Returns a copy of the orbit at the position i in the OrbitList

get_orbit_list()

Returns a list of Orbit objects from OrbitList

get_primitive_structure()

Returns the primitive atomic structure used to construct the OrbitList instance

get_supercell_orbit_list(atoms)

Returns an orbit list for a supercell structure.

Parameters:atoms (Atoms) – supercell atomic structure
Returns:
Return type:An OrbitList object
is_row_taken()

Some random description

orbits

Internal list of orbits

permutation_matrix

Returns icet PermutationMatrix object.

primitive_structure

Returns the primitive structure to which the lattice sites in the orbits are referenced to.

print()
remove_inactive_orbits(allowed_species)

Removes orbits with inactive sites

Parameters:allowed_species (List[int]) – the number of allowed species on each site in the primitive structure
sort()

Sort the orbits by orbit comparison

PermutationMap

icet.core.permutation_matrix.permutation_matrix_from_atoms(atoms, cutoff, find_prim=True)

Set up a list of permutation maps from an atoms object.

Parameters:
  • atoms (ASE Atoms object) – input structure
  • cutoff (float) – cutoff radius
  • find_primitive (boolean) – if True the symmetries of the primitive structure will be employed
Returns:

the tuple comprises the permutation matrix, the primitive structure, and the neighbor list

Return type:

matrix, icet Structure object, NeighborList object

Structure