Download examples/01_structures_and_transforms.py from tmepass000/matter-os: direct link, hf CLI and curl.
- Browser
- Download file 876 Bytes
-
https://huggingface.co/tmepass000/matter-os/resolve/main/examples/01_structures_and_transforms.py
- Command line
-
hf download hf://tmepass000/matter-os/examples/01_structures_and_transforms.py
-
curl -L -o 01_structures_and_transforms.py https://huggingface.co/tmepass000/matter-os/resolve/main/examples/01_structures_and_transforms.py
876 Bytes
| """Unified representation, format round-trip and reversible transformations (no database needed).""" | |
| import sys; from pathlib import Path; sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) | |
| from ase.build import bulk, molecule | |
| from core.io import dumps, loads | |
| from core.representation import MatterStructure | |
| from discovery import transformations as tf | |
| ms = MatterStructure.from_ase(molecule("CH3OH")) | |
| print(ms.formula(), "electrons:", ms.n_electrons(), "bonds:", len(ms.graph()["edges"])) | |
| print("SDF round trip ok:", loads(dumps(ms, "sdf"), "sdf").content_hash() == ms.content_hash()) | |
| cu = MatterStructure.from_ase(bulk("Cu", "fcc", a=3.6, cubic=True)) | |
| print("space group:", cu.symmetry()["international"]) | |
| s = tf.substitute(cu, 0, "Au"); print("substituted:", s.formula(), "lineage:", s.lineage[-1]["operation"]) | |
| print("inverted back:", tf.invert(s).formula()) | |