{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# UUID and Lineage Tracking in ASSYST\n", "\n", "This notebook demonstrates how ASSYST tracks the derivation history of structures using UUIDs." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from assyst.crystals import pyxtal\n", "from assyst.perturbations import Rattle, Stretch, Series\n", "from assyst.relax import Relax\n", "from assyst.calculators import Morse\n", "import ase" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1. Initial Structure Generation\n", "\n", "When we generate a structure with `pyxtal`, it automatically receives a UUID and a seed." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "atoms = pyxtal(225, species=['Cu'], num_ions=[4])\n", "print(f\"Current UUID: {atoms.info['uuid']}\")\n", "print(f\"Seed UUID: {atoms.info['seed']}\")\n", "print(f\"Lineage: {atoms.info.get('lineage', [])}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 2. Relaxation\n", "\n", "Relaxation creates a new structure with a new UUID and updates the lineage." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "calc = Morse()\n", "relax = Relax(max_steps=5)\n", "\n", "atoms.calc = calc.get_calculator()\n", "relaxed = relax.relax(atoms)\n", "\n", "print(f\"Current UUID: {relaxed.info['uuid']}\")\n", "print(f\"Seed UUID: {relaxed.info['seed']}\")\n", "print(f\"Lineage: {relaxed.info['lineage']}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 3. Applying Perturbations\n", "\n", "Perturbations further extend the lineage." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "rattle = Rattle(sigma=0.05)\n", "perturbed = rattle(relaxed.copy())\n", "\n", "print(f\"Current UUID: {perturbed.info['uuid']}\")\n", "print(f\"Seed UUID: {perturbed.info['seed']}\")\n", "print(f\"Lineage: {perturbed.info['lineage']}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 4. Multiple Steps\n", "\n", "Lineage accumulates as we apply more modifications." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "stretch = Stretch(hydro=0.05, shear=0.05)\n", "final = stretch(perturbed.copy())\n", "\n", "print(f\"Current UUID: {final.info['uuid']}\")\n", "print(f\"Seed UUID: {final.info['seed']}\")\n", "print(f\"Lineage: {final.info['lineage']}\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.3" } }, "nbformat": 4, "nbformat_minor": 4 }