{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Fixed Composition Substitutions\n", "\n", "This guide demonstrates how to perform sequential substitutions and track the full configuration degeneracy across multiple substitution steps.\n", "\n", "## Sequential Substitutions\n", "\n", "When performing multiple substitutions in sequence, each step generates new symmetry-inequivalent structures. Understanding how degeneracy accumulates across these steps is important for statistical mechanics calculations.\n", "\n", "### The Li-Na-Mg Example\n", "\n", "Let's start with the same 4×4 lithium lattice from the basic substitutions example, and perform two sequential substitutions." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Created structure with 16 Li sites\n" ] } ], "source": [ "import numpy as np\n", "from pymatgen.core import Structure, Lattice\n", "from bsym.interface.pymatgen import unique_structure_substitutions\n", "\n", "# Create a 4×4 square lattice\n", "coords = np.array([[0.0, 0.0, 0.0]])\n", "atom_list = ['Li']\n", "lattice = Lattice.from_parameters(a=1.0, b=1.0, c=1.0, alpha=90, beta=90, gamma=90)\n", "parent_structure = Structure(lattice, atom_list, coords) * [4, 4, 1]\n", "\n", "print(f\"Created structure with {len(parent_structure)} Li sites\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 1: Substitute Li → Na\n", "\n", "First, we substitute one lithium with sodium:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Number of unique structures after Na substitution: 1\n", "Degeneracy: 16\n" ] } ], "source": [ "unique_structures = unique_structure_substitutions(\n", " parent_structure,\n", " 'Li',\n", " {'Na': 1, 'Li': 15}\n", ")\n", "\n", "print(f\"Number of unique structures after Na substitution: {len(unique_structures)}\")\n", "na_substituted = unique_structures[0]\n", "print(f\"Degeneracy: {na_substituted.number_of_equivalent_configurations}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "As we saw before, due to the high symmetry of the square lattice, we get one unique structure with 16 equivalent configurations." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 2: Substitute Li → Mg\n", "\n", "Now we take the Na-substituted structure and perform a second substitution, replacing one more Li with Mg. The Li→Na substitution has broken the symmetry of the parent lattice, so we now get multiple unique structures:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Number of unique structures: 5\n" ] } ], "source": [ "unique_structures_with_mg = unique_structure_substitutions(\n", " na_substituted,\n", " 'Li',\n", " {'Mg': 1, 'Li': 14}\n", ")\n", "\n", "print(f\"Number of unique structures: {len(unique_structures_with_mg)}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We now have five symmetry-inequivalent configurations, distinguished by the distance between the Na and Mg atoms:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "