|
| 1 | +# Quickstart Guide |
| 2 | + |
| 3 | +This guide provides quick examples to get you started with bsym, covering both abstract configuration spaces and practical crystallographic applications. |
| 4 | + |
| 5 | +## Abstract Example: Symmetry-Inequivalent Arrangements |
| 6 | + |
| 7 | +This example shows how to find unique arrangements of objects in a symmetric space without requiring any crystallographic knowledge. |
| 8 | + |
| 9 | +### Problem: Four Sites in a Square |
| 10 | + |
| 11 | +Consider four sites arranged in a square. How many unique ways can we place 2 occupied and 2 vacant sites, accounting for the square's rotational and reflection symmetry? |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | +### Solution |
| 16 | +```python |
| 17 | +from bsym import ConfigurationSpace, SymmetryGroup, SymmetryOperation |
| 18 | + |
| 19 | +# Define C4v symmetry operations (square symmetry) |
| 20 | +e = SymmetryOperation.from_vector([1, 2, 3, 4], label='E') |
| 21 | +c4 = SymmetryOperation.from_vector([2, 3, 4, 1], label='C4') |
| 22 | +c4_inv = SymmetryOperation.from_vector([4, 1, 2, 3], label='C4i') |
| 23 | +c2 = SymmetryOperation.from_vector([3, 4, 1, 2], label='C2') |
| 24 | +sigma_x = SymmetryOperation.from_vector([4, 3, 2, 1], label='s_x') |
| 25 | +sigma_y = SymmetryOperation.from_vector([2, 1, 4, 3], label='s_y') |
| 26 | +sigma_ac = SymmetryOperation.from_vector([1, 4, 3, 2], label='s_ac') |
| 27 | +sigma_bd = SymmetryOperation.from_vector([3, 2, 1, 4], label='s_bd') |
| 28 | + |
| 29 | +# Create symmetry group |
| 30 | +c4v = SymmetryGroup([e, c4, c4_inv, c2, sigma_x, sigma_y, sigma_ac, sigma_bd]) |
| 31 | + |
| 32 | +# Create configuration space |
| 33 | +config_space = ConfigurationSpace( |
| 34 | + objects=['a', 'b', 'c', 'd'], |
| 35 | + symmetry_group=c4v |
| 36 | +) |
| 37 | + |
| 38 | +# Find unique configurations (2 occupied, 2 vacant) |
| 39 | +unique_configs = config_space.unique_configurations({1: 2, 0: 2}) |
| 40 | + |
| 41 | +print(f"Found {len(unique_configs)} unique configurations") |
| 42 | +for config in unique_configs: |
| 43 | + print(f"{config.tolist()}: degeneracy = {config.count}") |
| 44 | +``` |
| 45 | + |
| 46 | +**Output:** |
| 47 | +``` |
| 48 | +Found 2 unique configurations |
| 49 | +[0, 0, 1, 1]: degeneracy = 4 |
| 50 | +[0, 1, 0, 1]: degeneracy = 2 |
| 51 | +``` |
| 52 | + |
| 53 | +Without symmetry, there would be 6 distinct arrangements. With C<sub>4v</sub> symmetry, these reduce to just 2 unique patterns: |
| 54 | +- Adjacent sites occupied (4 equivalent arrangements) |
| 55 | +- Diagonal sites occupied (2 equivalent arrangements) |
| 56 | + |
| 57 | +### Next Steps |
| 58 | + |
| 59 | +- Learn about [configuration spaces](../theory/configuration_spaces.md) |
| 60 | +- Understand [symmetry operations](../theory/symmetry_operations.md) |
| 61 | +- Read about the [enumeration algorithm](../theory/unique_configurations.md) |
| 62 | + |
| 63 | +## Crystallographic Example: Disordered Structures |
| 64 | + |
| 65 | +This example shows how to generate symmetry-inequivalent crystal structures with substitutional disorder. |
| 66 | + |
| 67 | +### Problem: O/F Disorder in a Fluorite Structure |
| 68 | + |
| 69 | +Generate all unique structures for a 2×2×1 CaF<sub>2</sub> supercell where we substitute 8 oxygen atoms for 8 of the 16 fluorine atoms. |
| 70 | + |
| 71 | +### Solution |
| 72 | +```python |
| 73 | +from pymatgen.core import Structure |
| 74 | +from bsym.interface.pymatgen import unique_structure_substitutions |
| 75 | + |
| 76 | +# Load parent structure (CaF2 2x2x1 supercell) |
| 77 | +parent_structure = Structure.from_file('CaF2_supercell.cif') |
| 78 | +# Or create programmatically using pymatgen |
| 79 | + |
| 80 | +# Generate all unique O/F arrangements |
| 81 | +unique_structures = unique_structure_substitutions( |
| 82 | + structure=parent_structure, |
| 83 | + to_substitute='F', # Substitute on F sites |
| 84 | + site_distribution={'O': 8, 'F': 8} # 8 O, 8 F |
| 85 | +) |
| 86 | + |
| 87 | +print(f"Found {len(unique_structures)} symmetry-inequivalent structures") |
| 88 | + |
| 89 | +# Check degeneracies |
| 90 | +for i, structure in enumerate(unique_structures[:3]): |
| 91 | + n_equiv = structure.number_of_equivalent_configurations |
| 92 | + print(f"Structure {i}: represents {n_equiv} equivalent configurations") |
| 93 | + |
| 94 | +# Export structures |
| 95 | +for i, structure in enumerate(unique_structures): |
| 96 | + structure.to(filename=f'CaF2_O8F8_{i}.cif', fmt='cif') |
| 97 | +``` |
| 98 | + |
| 99 | +**Output:** |
| 100 | +``` |
| 101 | +Found 47 symmetry-inequivalent structures |
| 102 | +Structure 0: represents 192 equivalent configurations |
| 103 | +Structure 1: represents 192 equivalent configurations |
| 104 | +Structure 2: represents 96 equivalent configurations |
| 105 | +``` |
| 106 | + |
| 107 | +The `unique_structure_substitutions` function: |
| 108 | +1. Automatically detects the space group symmetry |
| 109 | +2. Identifies all symmetry-equivalent F sites |
| 110 | +3. Enumerates only the symmetry-inequivalent O/F arrangements |
| 111 | +4. Returns pymatgen `Structure` objects with degeneracy information |
| 112 | + |
| 113 | +### Exploring Multiple Compositions |
| 114 | + |
| 115 | +To generate structures across different O:F ratios: |
| 116 | +```python |
| 117 | +from bsym.interface.pymatgen import unique_structure_substitutions_by_composition |
| 118 | + |
| 119 | +# Generate structures for all O:F compositions |
| 120 | +all_structures = unique_structure_substitutions_by_composition( |
| 121 | + structure=parent_structure, |
| 122 | + to_substitute='F', |
| 123 | + species=['O', 'F'] |
| 124 | +) |
| 125 | + |
| 126 | +# Results organized by composition |
| 127 | +for composition, structures in all_structures.items(): |
| 128 | + n_O, n_F = composition |
| 129 | + print(f"CaO{n_O}F{n_F}: {len(structures)} unique structures") |
| 130 | +``` |
| 131 | + |
| 132 | +### Next Steps |
| 133 | + |
| 134 | +- See [Basic Substitutions](../user_guide/basic_substitutions.ipynb) for more examples |
| 135 | +- Learn about [varying composition](../user_guide/varying_composition.ipynb) |
| 136 | +- Understand [degeneracy tracking](../user_guide/fixed_composition.ipynb) |
| 137 | + |
| 138 | +## Key Concepts |
| 139 | + |
| 140 | +### Configuration Space |
| 141 | +An abstract vector space where you arrange different types of objects across discrete positions. |
| 142 | + |
| 143 | +### Symmetry Operations |
| 144 | +Transformations that map the configuration space onto itself (rotations, reflections, etc.). |
| 145 | + |
| 146 | +### Symmetry-Inequivalent Configurations |
| 147 | +The minimal set of configurations where no two can be transformed into each other by symmetry operations. |
| 148 | + |
| 149 | +### Degeneracy |
| 150 | +The number of symmetry-equivalent configurations represented by each unique configuration. |
| 151 | + |
| 152 | +## Where to Go Next |
| 153 | + |
| 154 | +**For abstract/mathematical applications:** |
| 155 | +- [Theory: Configuration Spaces](../theory/configuration_spaces.md) |
| 156 | +- [Theory: Symmetry Operations](../theory/symmetry_operations.md) |
| 157 | + |
| 158 | +**For crystallographic applications:** |
| 159 | +- [User Guide: Basic Substitutions](../user_guide/basic_substitutions.ipynb) |
| 160 | +- [User Guide: Varying Composition](../user_guide/varying_composition.ipynb) |
| 161 | + |
| 162 | +**For understanding the algorithms:** |
| 163 | +- [Theory: Unique Configuration Enumeration](../theory/unique_configurations.md) |
| 164 | +- [Theory: Composition Enumeration](../theory/composition_enumeration.md) |
0 commit comments