npl.core package

Submodules

npl.core.adsorption module

class npl.core.adsorption.AdsorptionSiteList[source]

Bases: object

build_site_list(particle)[source]
construct(particle)[source]
get_number_of_adsorbates()[source]
get_occupation_status_by_indices(status)[source]
get_occupation_vector()[source]
get_site_atom_indices(index)[source]
get_site_size(index)[source]
get_total_number_of_sites()[source]
occupation_vector()[source]
random_occupation(number_of_adsorbates)[source]
swap_status(index_pairs)[source]
class npl.core.adsorption.FindAdsorptionSites[source]

Bases: object

Class that identify and place add atoms based on the Generalized coordination Numbers of the nanoparticles

find_atom_plane_vec(particle, atom_idx)[source]
find_direction_for_edges(particle, atom_idx, center_of_mass)[source]
find_plane_for_bridge_atoms(particle, indices)[source]
get_bridge_sites(particle)[source]
get_hollow_sites(particle)[source]
get_ontop_sites(particle)[source]
class npl.core.adsorption.PlaceAddAtoms(symbols)[source]

Bases: object

Class that plance add atoms on positions identified by FindAdsorptionSites

bind_particle(particle)[source]
get_bridge_sties(particle)[source]
get_hollow_sties(particle)[source]
get_ontop_sites(particle)[source]
get_total_adsorption_sites(particle)[source]
get_xyz_site_from_atom_indices(particle, site)[source]
place_add_atom(particle, adsorbates, sites)[source]

npl.core.atom_wrapper module

class npl.core.atom_wrapper.AtomWrapper[source]

Bases: object

Wrapper class around the ase Atoms object to extend it with some higher-level functionality.

This class extends an Atoms object with additional functions for ordering, stoichiometry handling and is split from BaseNanoparticle to keep the size of the modules as small as possible.

add_atoms(new_atoms)[source]
get_all_symbols()[source]

Return list of symbols which occur at least once in the particle.

get_ase_atoms(indices=None)[source]

Return atoms specified by the indices.

Parameters:

indices: list/array of int

get_atoms(indices)[source]
get_indices()[source]

Convenience function for range(n_atoms).

get_indices_by_symbol(symbol)[source]

Return atom indices of given symbol.

Parameters:

symbol : str

get_n_atoms()[source]

Return the number of atoms.

get_n_atoms_of_symbol(symbol)[source]
get_position(idx)[source]
get_positions(indices=None)[source]

Return the positions of the atoms.

If indices is not specified, all atoms will be returned.

Parameters:

indices : list/array of int

get_stoichiometry()[source]

Return the current composition as defaultdict.

For symbols that are not in the particle, the defaultdict will evaluate to 0.

get_symbol(atom_idx)[source]
get_symbols(indices=None)[source]
random_ordering(new_stoichiometry)[source]

Creates a random chemical ordering for the given stoichiometry

The new stoichiometry has to be given as dict of type str -> int that matches the symbol to the number of atoms.

Parameters:

new_stoichiometry: dict

remove_atoms(indices)[source]
swap_symbols(index_pairs)[source]
transform_atoms(atom_indices, new_symbols)[source]
translate_atoms_positions(position)[source]

npl.core.base_nanoparticle module

class npl.core.base_nanoparticle.BaseNanoparticle[source]

Bases: object

Represent a nanoparticle. a NeighborList object. Multiple energies, feature vectors, and local environments can be accessed by storing them with their respective key. BaseNanoparticle is a data holder class in the sense that all common calculations such as the calculation of feature vectors, atomic descriptors, or energies should This ensures that BaseNanoparticle remains as general as possible. For project-specific behavior, the Nanoparticle class, which inherits from BaseNanoparticle, should be used. Attributes:

atoms (AtomWrapper): An object that wraps atomic information. neighbor_list (NeighborList): An object that stores the neighbor list. adsorption_site_list (AdsorptionSiteList): An object that stores adsorption sites. energies (dict): A dictionary to store multiple energy values. local_environments (dict): A dictionary to store local environments. atom_features (dict): A dictionary to store atomic features. feature_vectors (dict): A dictionary to store feature vectors.

add_atoms(atoms, recompute_neighbor_list=True, crystal=False)[source]

Add atoms to the nanoparticle.

Neighbor list will be recomputed after the addition by default.

Parameters:

atoms: Atoms recompute_neighbor_list: bool

build_from_dictionary(particle_dict, geometrical_dict=None)[source]

Construct a nanoparticle based on a representation as dictionary.

Takes either one dictionary for the whole nanoparticle or two if one only specifies the geometry.

Parameter:

particle_dict: dict Dictionary containing all the necessary information to build a nanoparticle. See get_as_dictionary() for valid keys.

geometrical_dict: dict Dictionary containing positions and neighbor list. If particle_dict also contains geometrical information, geometrical_dict will still be used.

construct_adsorption_list()[source]
construct_neighbor_list(exclude_x=True, scale_factor=1.0)[source]

Construct neighbor list.

Vacancies denoted by symbol ‘X’ are excluded by the default.

get_adsorption_as_list()[source]
get_adsorption_list()[source]
get_all_symbols()[source]

Return list of symbols that occur at least once in the particle

get_as_dictionary(fields=None)[source]

Return the nanoparticle in the form of a JSON-compatible dictionary.

Parameters:

fields: list of str

Specifies which piece of information the user wants to save. Accepted values are: ‘energies’, ‘symbols’, ‘positions’, ‘atom_features’, ‘local_environments’, ‘neighbor_list’, ‘feature_vectors’.

get_ase_atoms(indices=None, exclude_x=True)[source]

Return an ase Atoms object representing the nanoparticle.

By default all atoms will be returned except vacancies.

Parameters:

indices: list/array of int Only the selected atoms will be returned. If None is given, all indices will be returned by default.

exclude_x: bool Exclude vacancies denoted by symbol ‘X’ from the atoms object. Necessary e.g. for energy calculations

get_atom_feature(feature_key, index)[source]

Retrieve a specific feature of an atom by its index.

Args:

feature_key (str): The key corresponding to the desired feature. index (int): The index of the atom for which the feature is to be retrieved.

Returns:

The value of the specified feature for the atom at the given index.

get_atom_features(feature_key)[source]

Retrieve or initialize the features of an atom based on the given feature key.

If the feature key does not exist in the atom_features dictionary, it initializes an empty dictionary for that feature key.

Args:

feature_key (str): The key representing the specific feature of the atom.

Returns:

dict: The dictionary containing the features associated with the given feature key.

get_atom_indices_from_coordination_number(coordination_numbers, symbol=None)[source]

Return atom indices of atoms with certain coordination numbers.

In addition, the search can be restricted to a spcific symbol.

Parameters:

coordination_numbers : list/array of int symbol : str

get_atoms(indices)[source]

Retrieve atoms based on the provided indices.

Parameters: indices (list or array-like): A list or array of indices specifying which atoms to retrieve.

Returns: list: A list of atoms corresponding to the specified indices.

get_atoms_in_the_surface_plane(atom_idx, edges_corner=False)[source]

Get the atoms in the surface plane of a nanoparticle.

Parameters:

atom_idxint

The index of the atom for which to find the surface plane atoms.

edges_cornerbool, optional

If True, include atoms at the edges and corners of the surface plane. Default is False.

Returns:

list

A list of atom indices that are in the surface plane.

get_coordination_atoms(atom_idx)[source]

Get the coordination atoms for a given atom index.

Parameters: atom_idx (int): The index of the atom for which to find the coordination atoms.

Returns: list: A list of coordination atoms for the specified atom index.

get_coordination_number(atom_idx)[source]

Get the coordination number for a given atom.

The coordination number is the number of nearest neighbors surrounding a specific atom in the nanoparticle.

Parameters: atom_idx (int): The index of the atom for which to get the coordination number.

Returns: int: The coordination number of the specified atom.

get_energy(energy_key)[source]
get_feature_vector(feature_key)[source]

Retrieve the feature vector associated with the given feature key.

Args:

feature_key (str): The key corresponding to the desired feature vector.

Returns:

numpy.ndarray: The feature vector associated with the provided feature key.

Raises:

KeyError: If the feature_key is not found in the feature_vectors dictionary.

get_generalized_coordination_number(indices)[source]

Calculate the generalized coordination number for the given indices.

Parameters: indices (list or array-like): The indices of the atoms for which the

generalized coordination number is to be calculated.

Returns: float: The generalized coordination number for the specified indices.

get_generalized_coordination_numbers(sites)[source]

Calculate the generalized coordination numbers for a list of sites.

This method iterates over a list of sites, calculates the generalized coordination number for each site using the get_generalized_coordination_number method, and groups the sites by their generalized coordination numbers in a dictionary.

Args:

sites (list): A list of sites for which to calculate the generalized coordination numbers.

Returns:
dict: A dictionary where the keys are generalized coordination numbers and the values

are lists of sites that have the corresponding generalized coordination number.

get_geometrical_data()[source]

Return the geometrical information of the nanoparticle as dictionary.

This function returns a dict containing positions and the neighbor list, but not the symbols. In that way, nanoparticles with different orderings can share the same geometry.

get_indices()[source]

Convenience function for range(n_atoms).

get_indices_by_symbol(symbol)[source]

Return indices of all atoms of the respective symbol.

Parameters:

symbol: str

get_indices_of_adsorbates()[source]

Retrieve the indices of adsorbates.

This method returns the indices of adsorption sites that are occupied by adsorbates.

Returns:

list: A list of indices where adsorbates are present.

get_local_environment(atom_idx)[source]

Retrieve the local environment of a specified atom.

Parameters: atom_idx (int): The index of the atom for which the local environment is to be retrieved.

Returns: object: The local environment corresponding to the specified atom index.

get_local_environments()[source]

Retrieve the local environments of the nanoparticle.

Returns:

list: A list containing the local environments.

get_n_atoms()[source]

Return the number of atoms.

get_n_atoms_of_symbol(symbol)[source]
get_n_bonds()[source]

Return the number of bonds, requires valid neighbor list.

get_neighbor_list()[source]

Retrieve the list of neighboring particles.

Returns:

list: A list containing the neighboring particles.

get_number_of_adsorbates()[source]

Get the number of adsorbates on the nanoparticle.

This method retrieves the number of adsorbates from the adsorption site list.

Returns:

int: The number of adsorbates.

get_occupation_status_by_indices(status)[source]

Retrieve the occupation status of adsorption sites by their indices.

Args:

status (list or array-like): A list or array of indices representing the adsorption sites.

Returns:

list: A list of occupation statuses corresponding to the provided indices.

get_occupation_vector()[source]

Retrieve the occupation vector from the adsorption site list.

Returns:

list: A list representing the occupation vector of the adsorption sites.

get_position(idx)[source]
get_site_atom_indices(index)[source]
get_stoichiometry()[source]
get_symbol(index)[source]

Return symbol of the given index.

get_symbols(indices=None)[source]

Return the elements in order of the passed indices.

By default symbols for all atoms are returned.

Parameters:

indices : list/array of int

get_total_number_of_sites()[source]
has_energy(energy_key)[source]
is_pure()[source]

Check if the nanoparticle is composed of a single element.

Returns:

bool: True if the nanoparticle is composed of a single element, False otherwise.

load_npl_format(filename, filename_geometry=None)[source]

Load a nanoparticle file in the NPL format.

Files are loaded using pickle.

Parameter:

filename: str Filename of the particle.

filename_geometry: str Filename of geometrical data.

random_occupation(number_of_adsorbates)[source]
random_ordering(stoichiometry)[source]

Create a random chemical ordering for the particle with the given stoichiometry.

Parameters:

stoichiometry: dict Dictionary containing key-value pairs of the form symbol - number of atoms. Fractions are also supported, but care for round-off errors.

Example:

random_ordering({‘Pt’ : 79}

random_ordering({‘Pt’ : 0.5, ‘Au’ : 0.5})

read(filename, construct_neighbor_list=True, energy_key=None, crystal_structure=False)[source]

Wrapper class around ase.io.read.

By default a neighbor list will be constructed. Energies that are present in the atoms object, e.g. from after a DFT calculation can be given an individual energy key.

Parameters:

filename: str construct_neighbor_list: bool energy_key : str

remove_atoms(atom_indices, recompute_neighbor_list=True)[source]

Remove atoms from the nanoparticle.

Neighbor list will be recomputed after the removal by default.

Parameters:

atom_indices: list/array of int Indices of the atoms to be removed.

recompute_neighbor_list: bool

save_npl_format(filename, fields, filename_geometry=None)[source]

Save the nanoparticle by first exporting it to a dictionary and then using pickle.

The nanoparticle can be stored into two separate files, one of which holds the geometry (i.e. positions and neighbor list, not the symbols!). This allows to reuse the same geometry for several particles with different ordering.

Parameters:

filename: str filename.

fields: list of str Specify the piece of information to save. See get_as_dictionary() for explanation.

filename_geometry: str Filename of file in which the geometrical information will be stored. This is independent of the fields variable.

set_atom_feature(feature_key, index, atom_feature)[source]

Sets the feature of a specific atom in the nanoparticle.

Parameters: feature_key (str): The key identifying the feature to be set. index (int): The index of the atom whose feature is to be set. atom_feature: The new feature value to be assigned to the atom.

Returns: None

set_atom_features(atom_features, feature_key)[source]

Sets the features of an atom in the nanoparticle.

Parameters: atom_features (dict): A dictionary containing the features of the atom. feature_key (str): The key under which the atom features will be stored in the atom_features dictionary.

Returns: None

set_energy(energy_key, energy)[source]
set_feature_vector(feature_key, feature_vector)[source]
set_local_environment(atom_idx, local_environment)[source]

Sets the local environment for a specified atom.

Parameters: atom_idx (int): The index of the atom for which the local environment is being set. local_environment (object): The local environment to be assigned to the atom.

set_local_environments(local_environments)[source]

Sets the local environments for the nanoparticle.

Parameters: local_environments (dict): A dictionary containing the local environments to be set.

swap_status(index_pairs)[source]

Swap the status of adsorption sites based on the provided index pairs.

Parameters: index_pairs (list of tuple): A list of tuples where each tuple contains two indices.

The status of the adsorption sites at these indices will be swapped.

swap_symbols(index_pairs)[source]

Swap the elements of the specified pairs.

Parameters:

index_pairs: list of tuple List that contains tuples which contain two indices, respectively, of atoms where the symbols will be exchanged.

transform_atoms(atom_indices, new_symbols)[source]

Change the symbol for the given atoms.

The first atom will be changed to the first new symbol, the second atom to the second new symbol etc.

Parameters:

atom_indices: list/array of int

new_symbols: list of str

translate_atoms_positions(position)[source]

Shifts the origin of the coordinates towards a given position.

Useful to center the origin on an atom, when the position passed are the coordinates of the atom.

Parameters:

position: array Array that contains x y z coordinates.

write(filename)[source]

Wrapper around the ase.io.write method.

NPL specific information will NOT be stored, including energies

Parameters:

filename: str

npl.core.database_class module

npl.core.nanoparticle module

class npl.core.nanoparticle.Nanoparticle[source]

Bases: BaseNanoparticle

adjust_stoichiometry(target_stoichiometry)[source]
truncated_octahedron(height, cutoff, stoichiometry, lattice_constant=3.9, alloy=False)[source]

npl.core.neighbor_list module

class npl.core.neighbor_list.NeighborList[source]

Bases: object

construct(atoms, scale_factor=1.0, npl=True, cutoffs=None)[source]
get_atom_indices_from_coordination_number(atoms, coordination_numbers, symbol=None)[source]

Return atom indices of atoms with certain coordination numbers.

In addition, the search can be restricted to a spcific symbol.

Parameters:

coordination_numbers : list/array of int symbol : str

get_atoms_in_the_surface_plane(atom_idx, edges_corner=False)[source]

Find atoms within the same surface, excluding bulk atoms, atom must be in a terrace position. To include edges and cornes edges_corners=True

get_coordination_atoms(atom_idx)[source]
get_coordination_number(atom_idx)[source]
get_generalized_coordination_number(indices)[source]
get_max_coordination_number(indices)[source]
get_n_bonds()[source]

npl.core.profiler module

npl.core.profiler.profile(fnc)[source]

Module contents

class npl.core.BaseNanoparticle[source]

Bases: object

Represent a nanoparticle. a NeighborList object. Multiple energies, feature vectors, and local environments can be accessed by storing them with their respective key. BaseNanoparticle is a data holder class in the sense that all common calculations such as the calculation of feature vectors, atomic descriptors, or energies should This ensures that BaseNanoparticle remains as general as possible. For project-specific behavior, the Nanoparticle class, which inherits from BaseNanoparticle, should be used. Attributes:

atoms (AtomWrapper): An object that wraps atomic information. neighbor_list (NeighborList): An object that stores the neighbor list. adsorption_site_list (AdsorptionSiteList): An object that stores adsorption sites. energies (dict): A dictionary to store multiple energy values. local_environments (dict): A dictionary to store local environments. atom_features (dict): A dictionary to store atomic features. feature_vectors (dict): A dictionary to store feature vectors.

add_atoms(atoms, recompute_neighbor_list=True, crystal=False)[source]

Add atoms to the nanoparticle.

Neighbor list will be recomputed after the addition by default.

Parameters:

atoms: Atoms recompute_neighbor_list: bool

build_from_dictionary(particle_dict, geometrical_dict=None)[source]

Construct a nanoparticle based on a representation as dictionary.

Takes either one dictionary for the whole nanoparticle or two if one only specifies the geometry.

Parameter:

particle_dict: dict Dictionary containing all the necessary information to build a nanoparticle. See get_as_dictionary() for valid keys.

geometrical_dict: dict Dictionary containing positions and neighbor list. If particle_dict also contains geometrical information, geometrical_dict will still be used.

construct_adsorption_list()[source]
construct_neighbor_list(exclude_x=True, scale_factor=1.0)[source]

Construct neighbor list.

Vacancies denoted by symbol ‘X’ are excluded by the default.

get_adsorption_as_list()[source]
get_adsorption_list()[source]
get_all_symbols()[source]

Return list of symbols that occur at least once in the particle

get_as_dictionary(fields=None)[source]

Return the nanoparticle in the form of a JSON-compatible dictionary.

Parameters:

fields: list of str

Specifies which piece of information the user wants to save. Accepted values are: ‘energies’, ‘symbols’, ‘positions’, ‘atom_features’, ‘local_environments’, ‘neighbor_list’, ‘feature_vectors’.

get_ase_atoms(indices=None, exclude_x=True)[source]

Return an ase Atoms object representing the nanoparticle.

By default all atoms will be returned except vacancies.

Parameters:

indices: list/array of int Only the selected atoms will be returned. If None is given, all indices will be returned by default.

exclude_x: bool Exclude vacancies denoted by symbol ‘X’ from the atoms object. Necessary e.g. for energy calculations

get_atom_feature(feature_key, index)[source]

Retrieve a specific feature of an atom by its index.

Args:

feature_key (str): The key corresponding to the desired feature. index (int): The index of the atom for which the feature is to be retrieved.

Returns:

The value of the specified feature for the atom at the given index.

get_atom_features(feature_key)[source]

Retrieve or initialize the features of an atom based on the given feature key.

If the feature key does not exist in the atom_features dictionary, it initializes an empty dictionary for that feature key.

Args:

feature_key (str): The key representing the specific feature of the atom.

Returns:

dict: The dictionary containing the features associated with the given feature key.

get_atom_indices_from_coordination_number(coordination_numbers, symbol=None)[source]

Return atom indices of atoms with certain coordination numbers.

In addition, the search can be restricted to a spcific symbol.

Parameters:

coordination_numbers : list/array of int symbol : str

get_atoms(indices)[source]

Retrieve atoms based on the provided indices.

Parameters: indices (list or array-like): A list or array of indices specifying which atoms to retrieve.

Returns: list: A list of atoms corresponding to the specified indices.

get_atoms_in_the_surface_plane(atom_idx, edges_corner=False)[source]

Get the atoms in the surface plane of a nanoparticle.

Parameters:

atom_idxint

The index of the atom for which to find the surface plane atoms.

edges_cornerbool, optional

If True, include atoms at the edges and corners of the surface plane. Default is False.

Returns:

list

A list of atom indices that are in the surface plane.

get_coordination_atoms(atom_idx)[source]

Get the coordination atoms for a given atom index.

Parameters: atom_idx (int): The index of the atom for which to find the coordination atoms.

Returns: list: A list of coordination atoms for the specified atom index.

get_coordination_number(atom_idx)[source]

Get the coordination number for a given atom.

The coordination number is the number of nearest neighbors surrounding a specific atom in the nanoparticle.

Parameters: atom_idx (int): The index of the atom for which to get the coordination number.

Returns: int: The coordination number of the specified atom.

get_energy(energy_key)[source]
get_feature_vector(feature_key)[source]

Retrieve the feature vector associated with the given feature key.

Args:

feature_key (str): The key corresponding to the desired feature vector.

Returns:

numpy.ndarray: The feature vector associated with the provided feature key.

Raises:

KeyError: If the feature_key is not found in the feature_vectors dictionary.

get_generalized_coordination_number(indices)[source]

Calculate the generalized coordination number for the given indices.

Parameters: indices (list or array-like): The indices of the atoms for which the

generalized coordination number is to be calculated.

Returns: float: The generalized coordination number for the specified indices.

get_generalized_coordination_numbers(sites)[source]

Calculate the generalized coordination numbers for a list of sites.

This method iterates over a list of sites, calculates the generalized coordination number for each site using the get_generalized_coordination_number method, and groups the sites by their generalized coordination numbers in a dictionary.

Args:

sites (list): A list of sites for which to calculate the generalized coordination numbers.

Returns:
dict: A dictionary where the keys are generalized coordination numbers and the values

are lists of sites that have the corresponding generalized coordination number.

get_geometrical_data()[source]

Return the geometrical information of the nanoparticle as dictionary.

This function returns a dict containing positions and the neighbor list, but not the symbols. In that way, nanoparticles with different orderings can share the same geometry.

get_indices()[source]

Convenience function for range(n_atoms).

get_indices_by_symbol(symbol)[source]

Return indices of all atoms of the respective symbol.

Parameters:

symbol: str

get_indices_of_adsorbates()[source]

Retrieve the indices of adsorbates.

This method returns the indices of adsorption sites that are occupied by adsorbates.

Returns:

list: A list of indices where adsorbates are present.

get_local_environment(atom_idx)[source]

Retrieve the local environment of a specified atom.

Parameters: atom_idx (int): The index of the atom for which the local environment is to be retrieved.

Returns: object: The local environment corresponding to the specified atom index.

get_local_environments()[source]

Retrieve the local environments of the nanoparticle.

Returns:

list: A list containing the local environments.

get_n_atoms()[source]

Return the number of atoms.

get_n_atoms_of_symbol(symbol)[source]
get_n_bonds()[source]

Return the number of bonds, requires valid neighbor list.

get_neighbor_list()[source]

Retrieve the list of neighboring particles.

Returns:

list: A list containing the neighboring particles.

get_number_of_adsorbates()[source]

Get the number of adsorbates on the nanoparticle.

This method retrieves the number of adsorbates from the adsorption site list.

Returns:

int: The number of adsorbates.

get_occupation_status_by_indices(status)[source]

Retrieve the occupation status of adsorption sites by their indices.

Args:

status (list or array-like): A list or array of indices representing the adsorption sites.

Returns:

list: A list of occupation statuses corresponding to the provided indices.

get_occupation_vector()[source]

Retrieve the occupation vector from the adsorption site list.

Returns:

list: A list representing the occupation vector of the adsorption sites.

get_position(idx)[source]
get_site_atom_indices(index)[source]
get_stoichiometry()[source]
get_symbol(index)[source]

Return symbol of the given index.

get_symbols(indices=None)[source]

Return the elements in order of the passed indices.

By default symbols for all atoms are returned.

Parameters:

indices : list/array of int

get_total_number_of_sites()[source]
has_energy(energy_key)[source]
is_pure()[source]

Check if the nanoparticle is composed of a single element.

Returns:

bool: True if the nanoparticle is composed of a single element, False otherwise.

load_npl_format(filename, filename_geometry=None)[source]

Load a nanoparticle file in the NPL format.

Files are loaded using pickle.

Parameter:

filename: str Filename of the particle.

filename_geometry: str Filename of geometrical data.

random_occupation(number_of_adsorbates)[source]
random_ordering(stoichiometry)[source]

Create a random chemical ordering for the particle with the given stoichiometry.

Parameters:

stoichiometry: dict Dictionary containing key-value pairs of the form symbol - number of atoms. Fractions are also supported, but care for round-off errors.

Example:

random_ordering({‘Pt’ : 79}

random_ordering({‘Pt’ : 0.5, ‘Au’ : 0.5})

read(filename, construct_neighbor_list=True, energy_key=None, crystal_structure=False)[source]

Wrapper class around ase.io.read.

By default a neighbor list will be constructed. Energies that are present in the atoms object, e.g. from after a DFT calculation can be given an individual energy key.

Parameters:

filename: str construct_neighbor_list: bool energy_key : str

remove_atoms(atom_indices, recompute_neighbor_list=True)[source]

Remove atoms from the nanoparticle.

Neighbor list will be recomputed after the removal by default.

Parameters:

atom_indices: list/array of int Indices of the atoms to be removed.

recompute_neighbor_list: bool

save_npl_format(filename, fields, filename_geometry=None)[source]

Save the nanoparticle by first exporting it to a dictionary and then using pickle.

The nanoparticle can be stored into two separate files, one of which holds the geometry (i.e. positions and neighbor list, not the symbols!). This allows to reuse the same geometry for several particles with different ordering.

Parameters:

filename: str filename.

fields: list of str Specify the piece of information to save. See get_as_dictionary() for explanation.

filename_geometry: str Filename of file in which the geometrical information will be stored. This is independent of the fields variable.

set_atom_feature(feature_key, index, atom_feature)[source]

Sets the feature of a specific atom in the nanoparticle.

Parameters: feature_key (str): The key identifying the feature to be set. index (int): The index of the atom whose feature is to be set. atom_feature: The new feature value to be assigned to the atom.

Returns: None

set_atom_features(atom_features, feature_key)[source]

Sets the features of an atom in the nanoparticle.

Parameters: atom_features (dict): A dictionary containing the features of the atom. feature_key (str): The key under which the atom features will be stored in the atom_features dictionary.

Returns: None

set_energy(energy_key, energy)[source]
set_feature_vector(feature_key, feature_vector)[source]
set_local_environment(atom_idx, local_environment)[source]

Sets the local environment for a specified atom.

Parameters: atom_idx (int): The index of the atom for which the local environment is being set. local_environment (object): The local environment to be assigned to the atom.

set_local_environments(local_environments)[source]

Sets the local environments for the nanoparticle.

Parameters: local_environments (dict): A dictionary containing the local environments to be set.

swap_status(index_pairs)[source]

Swap the status of adsorption sites based on the provided index pairs.

Parameters: index_pairs (list of tuple): A list of tuples where each tuple contains two indices.

The status of the adsorption sites at these indices will be swapped.

swap_symbols(index_pairs)[source]

Swap the elements of the specified pairs.

Parameters:

index_pairs: list of tuple List that contains tuples which contain two indices, respectively, of atoms where the symbols will be exchanged.

transform_atoms(atom_indices, new_symbols)[source]

Change the symbol for the given atoms.

The first atom will be changed to the first new symbol, the second atom to the second new symbol etc.

Parameters:

atom_indices: list/array of int

new_symbols: list of str

translate_atoms_positions(position)[source]

Shifts the origin of the coordinates towards a given position.

Useful to center the origin on an atom, when the position passed are the coordinates of the atom.

Parameters:

position: array Array that contains x y z coordinates.

write(filename)[source]

Wrapper around the ase.io.write method.

NPL specific information will NOT be stored, including energies

Parameters:

filename: str

class npl.core.FindAdsorptionSites[source]

Bases: object

Class that identify and place add atoms based on the Generalized coordination Numbers of the nanoparticles

find_atom_plane_vec(particle, atom_idx)[source]
find_direction_for_edges(particle, atom_idx, center_of_mass)[source]
find_plane_for_bridge_atoms(particle, indices)[source]
get_bridge_sites(particle)[source]
get_hollow_sites(particle)[source]
get_ontop_sites(particle)[source]
class npl.core.Nanoparticle[source]

Bases: BaseNanoparticle

adjust_stoichiometry(target_stoichiometry)[source]
truncated_octahedron(height, cutoff, stoichiometry, lattice_constant=3.9, alloy=False)[source]
class npl.core.NeighborList[source]

Bases: object

construct(atoms, scale_factor=1.0, npl=True, cutoffs=None)[source]
get_atom_indices_from_coordination_number(atoms, coordination_numbers, symbol=None)[source]

Return atom indices of atoms with certain coordination numbers.

In addition, the search can be restricted to a spcific symbol.

Parameters:

coordination_numbers : list/array of int symbol : str

get_atoms_in_the_surface_plane(atom_idx, edges_corner=False)[source]

Find atoms within the same surface, excluding bulk atoms, atom must be in a terrace position. To include edges and cornes edges_corners=True

get_coordination_atoms(atom_idx)[source]
get_coordination_number(atom_idx)[source]
get_generalized_coordination_number(indices)[source]
get_max_coordination_number(indices)[source]
get_n_bonds()[source]