Skip to main content

MEGNetSparse

Installation

pip install MEGNetSparse
  1. You must first install the torch and torch_geometric
  2. The notebook provided in the examples will only work with pymatgen==2023.1.30, so you may need to reinstall it.

Summary

The library implements MEGNet model for sparse representations of crystals with point defects. The essence of the method is depicted in the figure below: Sparse representation construction

Usage

The library consists of two main parts: the first is the construction of a sparse representation of a crystal with point defects, the second is the training of a MEGNet model on this representation.

Sparse representation construction

convert_to_sparse_representation(
    structure,
    unit_cell,
    supercell_size,
    skip_eos=True,
    skip_was=False,
    skip_state=False,
    copy_unit_cell_properties=False
)
  • structure : Structure - the structure to convert to sparse representation
  • unit_cell : Structure - unit cell of base material
  • supercell_size : List[int] - list with three integers to copy a cell along three coordinates
  • skip_eos : bool - if True will not add engineered features aka EOS to properties and will speed up computations
  • skip_was: bool - if True will not add the types of the atoms in the pristine material on the defect sites aka was to properties
  • skip_state : bool - if True will not add global state, which consists of a vector with the atomic numbers of the atoms present in the pristine material
  • copy_unit_cell_properties: bool - if True will also copy unit cell properties in case of name collisions structure properties will be overwritten

return : Structure - sparse representation of the structure

Model training

MEGNetTrainer(
    config,
    device,
)
  • config : dict - template config can be found in examples notebook
  • device : str - device in torch format
MEGNetTrainer.prepare_data(
    self,
    train_data,
    train_targets,
    test_data,
    test_targets,
    target_name,
):
  • train_data : List[Structure] - list of structures in sparse or dense representation. The model is agnostic to the representation and won't do the conversion; if you supply dense structures (aka ordinary pymatgen.Structure) the model will be roughly equal to ordinary MEGNet
  • train_targets : List[float32] - list of targets
  • test_data : List[Structure] - list of structures in sparse or dense representation
  • test_targets : List[float32] - list of targets
  • target_name : str - target name
MEGNetTrainer.train_one_epoch(self)

return : mae on train data, mse on train data

MEGNetTrainer.evaluate_on_test(
    self, 
    return_predictions=False
)

return : if return_predictions=True, mae on test data, predictions else only mae on test data

MEGNetTrainer.predict_structures(
    self, 
    structures_list
)
  • structures_list : List[Structure] - list of structures in the same representation (dense/sparse) as was used for training

return : predictions for structures

MEGNetTrainer.save(self, path)
  • path : str - where to store model data
MEGNetTrainer.load(self, path)
  • path : str - where to load model data from

Citation

Please cite the following paper if you use the library:

Kazeev, N., Al-Maeeni, A.R., Romanov, I. et al. Sparse representation for machine learning the properties of defects in 2D materials. npj Comput Mater 9, 113 (2023). https://doi.org/10.1038/s41524-023-01062-z

Release files for MEGNetSparse 0.0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for MEGNetSparse 0.0.10
File Size Uploaded
megnetsparse-0.0.10.tar.gz 296.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for MEGNetSparse 0.0.10
File Interpreter ABI Platform
megnetsparse-0.0.10-py3-none-any.whl Python 3 none any Details

Total release size: 310.1 kB

Release files / megnetsparse-0.0.10.tar.gz

Download URL megnetsparse-0.0.10.tar.gz
Size 296.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a8f50a8e1001d7ee47cdb9e902c5f47b7ba81c4e8c665bbfc8b20af6981a4958
BLAKE2b-256 checksum
How to use checksums
9348bc3e23dba2135a00e5cd0a08225947d0f1e752555f5a88ae28639c4dc663
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Release files / megnetsparse-0.0.10-py3-none-any.whl

Download URL megnetsparse-0.0.10-py3-none-any.whl
Size 13.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf778eaf4adce9392c21918ef85ec6a50155c61a7c17480be6be2864689306c5
BLAKE2b-256 checksum
How to use checksums
2250e23d91de8c88ad9741dce143cd645b722c061f4473c9411328a81403d7d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Release history Release notifications | RSS feed

This release

0.0.10 This release

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page