|
1 | 1 | # SPG (Spin Point Groups) Library |
2 | 2 |
|
3 | | -SPG is a Lean 4 library for analyzing Spin Point Groups, Magnetic Point Groups (MPGs), and symmetry breaking phenomena in condensed matter physics. It provides tools to define magnetic symmetries, generate group closures, and verify physical properties such as allowed electric polarization. |
| 3 | +> [中文文档 (Chinese Documentation)](README_zh.md) |
4 | 4 |
|
5 | | -## Installation |
| 5 | +SPG is a Lean 4 library designed for exact algebraic analysis of magnetic point groups and their representations in condensed matter physics. |
6 | 6 |
|
7 | | -Add the following dependency to your `lakefile.lean`: |
| 7 | +Unlike numerical tools (Python/MATLAB), SPG operates entirely over the field of rational numbers (`ℚ`), ensuring that all symmetry checks, invariant generations, and "forbidden term" classifications are mathematically exact and decidable. |
8 | 8 |
|
9 | | -```lean |
10 | | -require SPG from git |
11 | | - "https://github.com/tsurumi-yizhou/SPG.git" |
12 | | -``` |
| 9 | +## Key Features |
13 | 10 |
|
14 | | -Then update dependencies: |
| 11 | +* **Exact Algebra**: No floating-point errors. Matrices and coefficients are `ℚ`. |
| 12 | +* **Invariant Analysis**: Automated solving of linear equations to find allowed k·p Hamiltonian terms (e.g., checking for altermagnetism). |
| 13 | +* **Symmetry Breaking**: Calculate Magnetic Point Groups (MPG) from a given magnetic order parameter. |
| 14 | +* **Physical Properties**: Verify macroscopic properties like allowed electric polarization or net magnetization. |
15 | 15 |
|
16 | | -```bash |
17 | | -lake update |
18 | | -``` |
| 16 | +## Quick Start |
19 | 17 |
|
20 | | -## Usage Guide |
| 18 | +### Installation |
21 | 19 |
|
22 | | -This section demonstrates how to use the library to analyze magnetic symmetries. |
| 20 | +Add to your `lakefile.lean`: |
23 | 21 |
|
24 | | -### 1. Import Modules |
| 22 | +```lean |
| 23 | +require SPG from git |
| 24 | + "https://github.com/tsurumi-yizhou/SPG.git" |
| 25 | +``` |
25 | 26 |
|
26 | | -Import the main library to access all core functionalities: |
| 27 | +### Example: Checking Altermagnetism |
27 | 28 |
|
28 | 29 | ```lean |
29 | 30 | import SPG |
30 | 31 |
|
31 | 32 | open SPG |
32 | 33 | open SPG.Interface |
33 | 34 | open SPG.Algebra |
34 | | -open SPG.Physics |
| 35 | +open SPG.Physics.Hamiltonian |
35 | 36 | open SPG.Geometry.SpatialOps |
36 | | -``` |
37 | 37 |
|
38 | | -### 2. Define Group Generators |
| 38 | +-- Define a group generator: C4z * TimeReversal |
| 39 | +def g_C4z_T : SPGElement := Op[mat_4_z, ^-1] |
| 40 | +def g_C2x : SPGElement := Op[mat_2_x, ^1] |
| 41 | +def g_Inv : SPGElement := Op[mat_inv, ^1] |
39 | 42 |
|
40 | | -Use the `Op[spatial, spin]` syntax to define group elements. |
41 | | -* `^1`: Identity spin operation (non-magnetic). |
42 | | -* `^-1`: Time-reversal operation (spin flip). |
| 43 | +-- Generate the full group |
| 44 | +def my_group : List SPGElement := generate_group [g_C4z_T, g_C2x, g_Inv] |
43 | 45 |
|
44 | | -```lean |
45 | | --- Example: 4-fold rotoinversion along z (non-magnetic) |
46 | | -def g1 : SPGElement := Op[mat_4bar_z, ^1] |
47 | | -
|
48 | | --- Example: 2-fold rotation along x combined with time-reversal |
49 | | -def g2 : SPGElement := Op[mat_2_x, ^-1] |
| 46 | +-- Check if d-wave spin splitting (kx^2 - ky^2)σz is allowed |
| 47 | +-- This is the hallmark of d-wave altermagnetism |
| 48 | +def p_dwave : Poly := (kx * kx) - (ky * ky) |
| 49 | +#eval isInvariantHam my_group (singleTerm p_dwave .z) |
50 | 50 | ``` |
51 | 51 |
|
52 | | -### 3. Generate Group Closure |
53 | | - |
54 | | -Use `generate_group` to compute the full group from a set of generators. |
55 | | - |
56 | | -```lean |
57 | | -def my_group : List SPGElement := generate_group [g1, g2] |
58 | | -
|
59 | | --- Check group order |
60 | | -#eval my_group.length |
61 | | -``` |
62 | | - |
63 | | -### 4. Symmetry Breaking Analysis |
64 | | - |
65 | | -Given a magnetic ordering vector (Neel vector), compute the Magnetic Point Group (MPG). The MPG consists of all elements in the original group that leave the magnetic vector invariant. |
66 | | - |
67 | | -```lean |
68 | | -def neel_vector : Vec3 := ![1, 1, 0] |
69 | | -
|
70 | | --- Compute the Magnetic Point Group |
71 | | -def my_mpg : List SPGElement := get_mpg my_group neel_vector |
72 | | -
|
73 | | --- Check the size of the MPG |
74 | | -#eval my_mpg.length |
75 | | -``` |
76 | | - |
77 | | -### 5. Physical Property Verification |
78 | | - |
79 | | -Verify if the resulting symmetry group allows specific physical properties, such as spontaneous polarization along the z-axis. |
80 | | - |
81 | | -```lean |
82 | | --- Returns true if z-polarization is allowed, false otherwise |
83 | | -#eval allows_z_polarization my_mpg |
84 | | -``` |
85 | | - |
86 | | -### 6. Formal Proof |
87 | | - |
88 | | -Physical conclusions can be formally verified using `native_decide`. |
89 | | - |
90 | | -```lean |
91 | | -theorem polarization_allowed : |
92 | | - (allows_z_polarization my_mpg) = true := by |
93 | | - native_decide |
94 | | -``` |
95 | | - |
96 | | -## Core Modules |
97 | | - |
98 | | -* **SPG.Interface.Notation**: Syntax definitions for `Op[...]`, `^1`, etc. |
99 | | -* **SPG.Algebra.Group**: Algorithms for finite group generation. |
100 | | -* **SPG.Physics.SymmetryBreaking**: Functions for MPG extraction and property verification. |
101 | | -* **SPG.Geometry.SpatialOps**: Predefined spatial operation matrices (e.g., `mat_4bar_z`). |
102 | | -* **SPG.Demo.Altermagnet**: Example implementation for d-wave altermagnet. |
103 | | - |
104 | | -## Notes |
| 52 | +## Documentation |
105 | 53 |
|
106 | | -* **Precision**: All matrix and vector operations use `Rational` numbers (`ℚ`) to ensure exact results and decidability. |
107 | | -* **Scope**: The `generate_group` function is optimized for finite Point Groups. |
| 54 | +For a detailed guide on the physical model, implementation details, and advanced usage, please refer to the **[Chinese Documentation](README_zh.md)** (currently the most comprehensive guide). |
108 | 55 |
|
109 | | -## Acknowledgments |
| 56 | +## Source Code Map |
110 | 57 |
|
111 | | -Special thanks to **Gemini 3** for the contributions to the code structure and implementation details. |
| 58 | +* **[SPG/Algebra/Basic.lean](SPG/Algebra/Basic.lean)**: `SPGElement` definition. |
| 59 | +* **[SPG/Algebra/Actions.lean](SPG/Algebra/Actions.lean)**: Physical actions on polar/axial vectors. |
| 60 | +* **[SPG/Physics/Hamiltonian/Invariants.lean](SPG/Physics/Hamiltonian/Invariants.lean)**: Algorithms for finding invariant Hamiltonians. |
0 commit comments