active_site_order

Active-site order utilities for compact KMC occupation vectors.

class kmcpy.structure.active_site_order.ActiveSiteOrder(primitive_site_count, original_site_count, primitive_active_indices, active_to_original, active_to_primitive, fixed_original_indices, supercell_shape, species_by_primitive_site, allowed_species_by_primitive_site, fingerprint, template_structure=None)[source]

Map full template sites to compact mutable active-site indices.

active_structure()[source]

Return active sites only, ordered by compact active index.

Return type:

Structure

as_dict()[source]

Serialize active-site order metadata without storing the full structure.

Return type:

dict[str, Any]

assert_same_order(other)[source]

Raise if another order or metadata payload describes a different site space.

Return type:

None

filter_active_structure(structure, tol=0.01)[source]

Filter a possibly full structure down to active sites by index metadata or position.

Return type:

Structure

classmethod from_dict(data)[source]

Restore serialized active-site order metadata.

Return type:

ActiveSiteOrder

classmethod from_lattice_structure(lattice_structure, supercell_shape=None)[source]

Build from a LatticeStructure instance.

Return type:

ActiveSiteOrder

classmethod from_structure_and_mapping(template_structure, site_mapping, supercell_shape=None)[source]

Build an active-site order from a full template and site mapping.

Return type:

ActiveSiteOrder

full_structure_with_properties()[source]

Return the full supercell with index-space site properties.

Return type:

Structure

classmethod load(file_path)

Loads a class from a provided json file.

Parameters:

file_path (os.PathLike) – The json file to load from.

Returns:

An instance of the class being reloaded.

Return type:

MSONable

save(json_path, mkdir=True, json_kwargs=None, pickle_kwargs=None, strict=True)

Utility that uses the standard tools of MSONable to convert the class to json format, but also save it to disk. In addition, this method intelligently uses pickle to individually pickle class objects that are not serializable, saving them separately. This maximizes the readability of the saved class information while allowing _any_ class to be at least partially serializable to disk.

For a fully MSONable class, only a class.json file will be saved to the location {save_dir}/class.json. For a partially MSONable class, additional information will be saved to the save directory at {save_dir}. This includes a pickled object for each attribute that e serialized.

Parameters:
  • file_path (os.PathLike) – The file to which to save the json object. A pickled object of the same name but different extension might also be saved if the class is not entirely MSONable.

  • mkdir (bool) – If True, makes the provided directory, including all parent directories.

  • json_kwargs (dict) – Keyword arguments to pass to the serializer.

  • pickle_kwargs (dict) – Keyword arguments to pass to pickle.dump.

  • strict (bool) – If True, will not allow you to overwrite existing files.

select_active_values(values)[source]

Return compact active-site values from active or full-supercell input.

Return type:

list[Any]

to_json()

Returns a json string representation of the MSONable object.

Return type:

str

unsafe_hash()

Returns an hash of the current object. This uses a generic but low performance method of converting the object to a dictionary, flattening any nested keys, and then performing a hash on the resulting object

validate_active_indices(indices, field_name='indices')[source]

Validate compact active-site indices.

Return type:

None

classmethod validate_monty_v1(_MSONable__input_value)

Pydantic validator with correct signature for pydantic v1.x

classmethod validate_monty_v2(_MSONable__input_value, _)

Pydantic validator with correct signature for pydantic v2.x