Skip to content

Commit 169ea11

Browse files
committed
Updated docs
1 parent 28a23c4 commit 169ea11

12 files changed

Lines changed: 849 additions & 68 deletions

docs/source/development.rst

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Installation
2+
3+
## Requirements
4+
5+
bsym requires Python 3.10 or later.
6+
7+
## Standard Installation
8+
9+
Install from PyPI:
10+
```bash
11+
pip install bsym
12+
```
13+
14+
## Installation from Source
15+
16+
Clone the repository and install:
17+
```bash
18+
git clone https://github.com/bjmorgan/bsym.git
19+
cd bsym
20+
pip install .
21+
```
22+
23+
## Development Installation
24+
25+
For development work (running tests, building documentation):
26+
```bash
27+
git clone https://github.com/bjmorgan/bsym.git
28+
cd bsym
29+
pip install -e ".[dev]"
30+
```
31+
32+
## Verifying Installation
33+
```python
34+
import bsym
35+
print(bsym.__version__)
36+
```
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Introduction to bsym
2+
3+
## What is bsym?
4+
5+
bsym is a Python package for working with symmetry operations and enumerating symmetry-inequivalent configurations. It provides tools for:
6+
7+
- Defining abstract configuration spaces and their symmetry operations
8+
- Finding all unique arrangements of objects that respect symmetry constraints
9+
- Generating symmetry-inequivalent crystal structures with substitutional disorder
10+
11+
## What Problems Does bsym Solve?
12+
13+
### The Configuration Counting Problem
14+
15+
Consider a crystal with 16 anion sites where you want to substitute 8 oxygen atoms for 8 fluorine atoms. Without considering symmetry, there are $\binom{16}{8} = 12,870$ possible arrangements. However, if the crystal has symmetry operations (rotations, reflections, translations), many of these arrangements are equivalent - they're just the same structure viewed from different angles or shifted in space.
16+
17+
bsym identifies which arrangements are truly unique, dramatically reducing the number of structures you need to consider. For example, a high-symmetry crystal might have only a few dozen unique arrangements instead of thousands.
18+
19+
### Why This Matters
20+
21+
**For computational materials science:**
22+
- Generate training sets for machine learning with only symmetry-inequivalent structures
23+
- Calculate configuration-dependent properties efficiently
24+
- Build phase diagrams by exploring composition space systematically
25+
- Study defects and disorder without redundant calculations
26+
27+
**For mathematical and theoretical work:**
28+
- Explore combinatorial problems with symmetry constraints
29+
- Study group theory applications
30+
- Develop enumeration algorithms
31+
32+
**For general research:**
33+
- Avoid wasting computational resources on equivalent configurations
34+
- Ensure systematic coverage of configuration space
35+
- Calculate degeneracies for statistical mechanics
36+
37+
## Key Features
38+
39+
### Abstract Configuration Spaces
40+
41+
Work with symmetry at a mathematical level, independent of any physical system:
42+
```python
43+
from bsym import ConfigurationSpace, SymmetryGroup
44+
45+
config_space = ConfigurationSpace(objects=[1, 2, 3, 4])
46+
unique_configs = config_space.unique_configurations({1: 2, 0: 2})
47+
```
48+
49+
### Crystallographic Interface
50+
51+
Integration with pymatgen for crystal structure generation:
52+
```python
53+
from bsym.interface.pymatgen import unique_structure_substitutions
54+
55+
unique_structures = unique_structure_substitutions(
56+
parent_structure, 'F', {'O': 8, 'F': 8}
57+
)
58+
```
59+
60+
### Efficient Algorithms
61+
62+
- Smart enumeration that only performs symmetry analysis when needed
63+
- Species exchange optimization for composition enumeration
64+
- Progress tracking for large systems
65+
66+
### Degeneracy Tracking
67+
68+
Each unique configuration includes its degeneracy - the number of symmetry-equivalent arrangements it represents. This is essential for statistical mechanics calculations.
69+
70+
## Who is bsym For?
71+
72+
**Computational materials scientists** studying:
73+
- Solid solutions and substitutional disorder
74+
- Defect configurations
75+
- Surface adsorption patterns
76+
- Magnetic ordering
77+
78+
**Researchers in related fields** working on:
79+
- Combinatorial problems with symmetry
80+
- Group theory applications
81+
- Enumeration algorithms
82+
83+
**Students** learning about:
84+
- Crystallographic symmetry
85+
- Group theory
86+
- Configuration spaces
87+
88+
## The Approach
89+
90+
bsym separates the mathematical logic of symmetry from the physical details of specific systems:
91+
92+
1. **Abstract representation**: Configurations are vectors of integers, symmetry operations are permutations
93+
2. **Efficient computation**: Symmetry operations implemented as numpy array indexing, with hash-based configuration lookup
94+
3. **Physical interpretation**: Map results back to structures, coordinates, etc. when needed
95+
96+
This separation makes the algorithms system-agnostic and computationally efficient.
97+
98+
## What's Next?
99+
100+
- **[Installation](installation.md)**: Get bsym installed
101+
- **[Quickstart](quickstart.md)**: Try hands-on examples
102+
- **[User Guide](../user_guide/index.rst)**: Detailed tutorials for specific tasks
103+
- **[Theory](../theory/index.rst)**: Understand the concepts and algorithms
104+
105+
## Further Reading
106+
107+
For the theoretical background and detailed algorithm descriptions:
108+
- [Configuration Spaces](../theory/configuration_spaces.md)
109+
- [Symmetry Operations](../theory/symmetry_operations.md)
110+
- [Unique Configuration Enumeration](../theory/unique_configurations.md)
111+
112+
For practical applications:
113+
- [Basic Substitutions](../user_guide/basic_substitutions.ipynb)
114+
- [Varying Composition](../user_guide/varying_composition.ipynb)
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
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+
![Square configuration space](../theory/figures/square_configuration_space.pdf)
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)

docs/source/index.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ bsym - A basic symmetry module
1010
:caption: Contents:
1111

1212
getting_started/index
13-
theory/index
1413
user_guide/index
14+
theory/index
1515
api/modules
16-
examples/bsym_examples
1716

1817
Indices and tables
1918
==================

docs/source/installation.rst

Lines changed: 0 additions & 26 deletions
This file was deleted.

docs/source/introduction.rst

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)