columx 2.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- columx-2.3.0/CHANGELOG.md +55 -0
- columx-2.3.0/LICENSE +21 -0
- columx-2.3.0/MANIFEST.in +7 -0
- columx-2.3.0/PKG-INFO +196 -0
- columx-2.3.0/README.md +161 -0
- columx-2.3.0/columx/__init__.py +106 -0
- columx-2.3.0/columx/aberration.py +565 -0
- columx-2.3.0/columx/abtem_interface.py +259 -0
- columx-2.3.0/columx/cbed.py +357 -0
- columx-2.3.0/columx/column.py +901 -0
- columx-2.3.0/columx/constants.py +200 -0
- columx-2.3.0/columx/coulomb.py +545 -0
- columx-2.3.0/columx/crystal.py +706 -0
- columx-2.3.0/columx/deflection.py +785 -0
- columx-2.3.0/columx/dpc.py +560 -0
- columx-2.3.0/columx/eels.py +802 -0
- columx-2.3.0/columx/electrostatic_paraxial.py +688 -0
- columx-2.3.0/columx/fem2d.py +1069 -0
- columx-2.3.0/columx/field.py +600 -0
- columx-2.3.0/columx/glaser.py +181 -0
- columx-2.3.0/columx/hrtem.py +588 -0
- columx-2.3.0/columx/instruments.py +265 -0
- columx-2.3.0/columx/lens_cascade.py +578 -0
- columx-2.3.0/columx/multipole.py +482 -0
- columx-2.3.0/columx/multislice.py +361 -0
- columx-2.3.0/columx/paraxial.py +278 -0
- columx-2.3.0/columx/ray3d.py +251 -0
- columx-2.3.0/columx/source.py +552 -0
- columx-2.3.0/columx/stem.py +635 -0
- columx-2.3.0/columx/wave.py +845 -0
- columx-2.3.0/columx.egg-info/PKG-INFO +196 -0
- columx-2.3.0/columx.egg-info/SOURCES.txt +47 -0
- columx-2.3.0/columx.egg-info/dependency_links.txt +1 -0
- columx-2.3.0/columx.egg-info/entry_points.txt +3 -0
- columx-2.3.0/columx.egg-info/requires.txt +17 -0
- columx-2.3.0/columx.egg-info/top_level.txt +1 -0
- columx-2.3.0/docs/architecture.md +119 -0
- columx-2.3.0/pyproject.toml +57 -0
- columx-2.3.0/requirements.txt +5 -0
- columx-2.3.0/setup.cfg +4 -0
- columx-2.3.0/tests/absolute_validation.py +201 -0
- columx-2.3.0/tests/benchmark_mebs.py +954 -0
- columx-2.3.0/tests/comprehensive_comparison.py +409 -0
- columx-2.3.0/tests/independent_validation.py +489 -0
- columx-2.3.0/tests/mebs_audit.py +298 -0
- columx-2.3.0/tests/test_all.py +1014 -0
- columx-2.3.0/tests/test_crystal_stem.py +301 -0
- columx-2.3.0/tests/test_new_physics.py +356 -0
- columx-2.3.0/web/index.html +275 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to ColumX are documented in this file.
|
|
4
|
+
|
|
5
|
+
## [2.3.0] — 2026-06-26
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- **CBED module** (`cbed`): Convergent beam electron diffraction with disk geometry, HOLZ rings, symmetry analysis, kinematical approximation
|
|
9
|
+
- **EELS module** (`eels`): Zero-loss peak, plasmon peaks, core-loss edges, elemental fingerprinting, thickness estimation (log-ratio and plural scattering)
|
|
10
|
+
- **HRTEM module** (`hrtem`): WPOA linear imaging, multislice nonlinear imaging, defocus series, power spectrum, Scherzer imaging
|
|
11
|
+
- **DPC module** (`dpc`): Segmented detector, center-of-mass shift, quantitative electric/magnetic field and charge density reconstruction
|
|
12
|
+
- **Web API**: FastAPI REST API with 6 endpoints covering Glaser, CTF, Probe, Multislice, Crystal, STEM
|
|
13
|
+
- **Web Frontend**: Vue3 + Plotly.js single-page application with interactive charts
|
|
14
|
+
- **Instrument presets**: Titan, Themis, ARM200F, ARM300F2
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
- Project renamed from TEMGYM Super to ColumX
|
|
18
|
+
- GUI upgraded from 16 to 20 panels with full MainWindow integration
|
|
19
|
+
- 269 tests across 8 test files
|
|
20
|
+
|
|
21
|
+
## [2.2.0] — 2026-06-25
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
- **Crystal module** (`crystal`): Kirkland parameterized scattering factors, 7 built-in crystal structures (Si, Ge, GaAs, SiC, MgO, Al, Au), projected potential calculation, 3D potential, mean inner potential, d-spacing table
|
|
25
|
+
- **STEM module** (`stem`): 2D STEM probe, annular detectors (BF/ADF/HAADF), Z-contrast imaging, HAADF cross-section, Z-contrast ratio
|
|
26
|
+
|
|
27
|
+
## [2.1.0] — 2026-06-23
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
- **5th-order aberrations**: C5 with hybrid Seidel/Glaser approach, S5, Krivanek standard naming interface
|
|
31
|
+
- **Multislice engine** (`multislice`): FFT-based wave propagation, phase grating/amorphous/weak phase object specimen models, abTEM interface
|
|
32
|
+
- **Cs/Cc adaptive power**: `cs_power='auto'` and `cc_power='auto'` with Glaser-formula optimization
|
|
33
|
+
- **Instruments library**: Pre-configured microscope setups
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
- Cs accuracy < 0.04%, Cc accuracy < 0.02% (200 kV objective lens vs MEBS)
|
|
37
|
+
|
|
38
|
+
## [2.0.0] — 2026-06-22
|
|
39
|
+
|
|
40
|
+
### Added
|
|
41
|
+
- **MEBS compatibility mode**: `match_mebs=True` replicates MEBS mixed relativistic convention (non-relativistic V in paraxial, relativistic V* in Seidel integrals)
|
|
42
|
+
- **Dual solver architecture**: M/theta solver with 0.006% accuracy
|
|
43
|
+
- **Lens cascade** (`lens_cascade`): Multi-lens systems with Conrady aberration propagation
|
|
44
|
+
- **Electrostatic paraxial** (`electrostatic_paraxial`): Full electrostatic paraxial ODE solver + aberrations
|
|
45
|
+
|
|
46
|
+
## [1.0.0] — 2026-06-21
|
|
47
|
+
|
|
48
|
+
### Added
|
|
49
|
+
- Initial release with 13 core modules: `constants`, `paraxial`, `ray3d`, `glaser`, `aberration`, `fem2d`, `field`, `multipole`, `source`, `wave`, `deflection`, `coulomb`, `column`
|
|
50
|
+
- Glaser analytical magnetic lens model
|
|
51
|
+
- Paraxial ray equation solver with g/h ray basis
|
|
52
|
+
- Seidel aberration integrals (Cs, Cc)
|
|
53
|
+
- 3D relativistic Lorentz force ray tracing
|
|
54
|
+
- 2D FEM field solver
|
|
55
|
+
- PySide6 desktop GUI with 13 panels
|
columx-2.3.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ColumX Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
columx-2.3.0/MANIFEST.in
ADDED
columx-2.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: columx
|
|
3
|
+
Version: 2.3.0
|
|
4
|
+
Summary: Advanced electron optics simulation platform for TEM/STEM/SEM column design
|
|
5
|
+
Author: ColumX Contributors
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/allen-li1231/ColumX
|
|
8
|
+
Project-URL: Documentation, https://github.com/allen-li1231/ColumX#readme
|
|
9
|
+
Project-URL: Issues, https://github.com/allen-li1231/ColumX/issues
|
|
10
|
+
Keywords: electron-optics,transmission-electron-microscopy,TEM,STEM,aberration,multislice,glaser-lens,paraxial,simulation
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Requires-Dist: numpy>=1.24.0
|
|
22
|
+
Requires-Dist: scipy>=1.10.0
|
|
23
|
+
Provides-Extra: gui
|
|
24
|
+
Requires-Dist: PySide6>=6.5; extra == "gui"
|
|
25
|
+
Provides-Extra: api
|
|
26
|
+
Requires-Dist: fastapi>=0.104.0; extra == "api"
|
|
27
|
+
Requires-Dist: uvicorn[standard]>=0.24.0; extra == "api"
|
|
28
|
+
Requires-Dist: pydantic>=2.0.0; extra == "api"
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
31
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
32
|
+
Provides-Extra: all
|
|
33
|
+
Requires-Dist: columx[api,dev,gui]; extra == "all"
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
|
|
36
|
+
# ColumX
|
|
37
|
+
|
|
38
|
+
**Advanced Electron Optics Simulation Platform for TEM/STEM/SEM Column Design**
|
|
39
|
+
|
|
40
|
+
ColumX is a comprehensive Python library for electron optics simulation, covering paraxial ray tracing, aberration calculation, wave optics, multislice propagation, crystal potentials, and full TEM/STEM column modeling. It is designed for researchers and engineers working on electron microscope column design, beam physics analysis, and image simulation.
|
|
41
|
+
|
|
42
|
+
## Features
|
|
43
|
+
|
|
44
|
+
ColumX provides 20 physics modules organized into four layers:
|
|
45
|
+
|
|
46
|
+
**Ray Optics** — `paraxial`, `ray3d`, `glaser`, `aberration`, `electrostatic_paraxial`
|
|
47
|
+
Magnetic and electrostatic lens modeling with Glaser analytical fields, adaptive-power Seidel aberration integrals (Cs < 0.04%, Cc < 0.02% vs MEBS), 5th-order aberration framework (C5, S5, Krivanek naming), and 3D relativistic Lorentz ray tracing.
|
|
48
|
+
|
|
49
|
+
**Wave Optics** — `wave`, `multislice`, `crystal`
|
|
50
|
+
Contrast transfer function with spatial/temporal coherence envelopes, STEM probe formation, FFT-based multislice propagation engine, and crystal structure module with Kirkland scattering factors for 7 built-in crystal presets (Si, Ge, GaAs, SiC, MgO, Al, Au).
|
|
51
|
+
|
|
52
|
+
**Advanced Imaging** — `stem`, `cbed`, `eels`, `hrtem`, `dpc`
|
|
53
|
+
STEM imaging chain (probe, annular detectors BF/ADF/HAADF, Z-contrast), convergent beam electron diffraction with HOLZ lines, EELS spectrum simulation with thickness measurement, HRTEM imaging (WPOA linear and multislice nonlinear), and differential phase contrast with electric/magnetic field reconstruction.
|
|
54
|
+
|
|
55
|
+
**Column & Infrastructure** — `column`, `lens_cascade`, `multipole`, `source`, `deflection`, `coulomb`, `fem2d`, `field`, `instruments`, `constants`
|
|
56
|
+
Full TEM column simulator, multi-lens cascade with Conrady aberration propagation, multipole elements, electron gun models (thermionic/field emission/Schottky), scanning deflection, space charge and Boersch effect, 2D FEM field solver, and instrument presets (Titan, Themis, ARM200F, ARM300F2).
|
|
57
|
+
|
|
58
|
+
## Installation
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# Core library
|
|
62
|
+
pip install columx
|
|
63
|
+
|
|
64
|
+
# With GUI (PySide6)
|
|
65
|
+
pip install "columx[gui]"
|
|
66
|
+
|
|
67
|
+
# With web API (FastAPI)
|
|
68
|
+
pip install "columx[api]"
|
|
69
|
+
|
|
70
|
+
# Everything
|
|
71
|
+
pip install "columx[all]"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### From Source
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
git clone https://github.com/allen-li1231/ColumX.git
|
|
78
|
+
cd ColumX
|
|
79
|
+
pip install -e ".[all]"
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Quick Start
|
|
83
|
+
|
|
84
|
+
### Glaser Lens
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from columx import GlaserLens
|
|
88
|
+
|
|
89
|
+
lens = GlaserLens(V=200e3, B0=0.5, a=3e-3, z0=-30e-3, zf=60e-3)
|
|
90
|
+
print(f"Focal length: {lens.analytical_efl()*1e3:.2f} mm")
|
|
91
|
+
print(f"Magnification: {lens.analytical_magnification():.3f}")
|
|
92
|
+
print(lens.summary())
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### CTF and Probe
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
from columx import ContrastTransferFunction, STEMProbe
|
|
99
|
+
|
|
100
|
+
ctf = ContrastTransferFunction(V=200e3, Cs=1.2e-3, Cc=1.2e-3, defocus=-50e-9)
|
|
101
|
+
print(f"Scherzer resolution: {ctf.scherzer_resolution()*1e10:.2f} A")
|
|
102
|
+
|
|
103
|
+
probe = STEMProbe(V=200e3, Cs=1e-3, alpha=10e-3)
|
|
104
|
+
print(f"Probe FWHM: {probe.probe_size()*1e10:.2f} A")
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Multislice Simulation
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from columx import MultisliceEngine
|
|
111
|
+
from columx.multislice import phase_grating_potential
|
|
112
|
+
import numpy as np
|
|
113
|
+
|
|
114
|
+
V = np.stack([phase_grating_potential(
|
|
115
|
+
nx=128, ny=128, Lx=5e-9, Ly=5e-9,
|
|
116
|
+
period=1e-9, amplitude=10.0
|
|
117
|
+
)] * 20)
|
|
118
|
+
|
|
119
|
+
engine = MultisliceEngine(V=200e3, nx=128, ny=128, Lx=5e-9, Ly=5e-9, dz=0.5e-9)
|
|
120
|
+
psi_exit = engine.run(V)
|
|
121
|
+
dp = engine.diffraction_pattern(psi_exit)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Crystal Potential
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
from columx import CrystalStructure, projected_potential
|
|
128
|
+
|
|
129
|
+
si = CrystalStructure.from_preset("Si")
|
|
130
|
+
V_proj, info = projected_potential(si, nx=256)
|
|
131
|
+
print(f"MIP: {info['MIP_V']:.1f} V")
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Web API
|
|
135
|
+
|
|
136
|
+
Start the REST API server:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
python run_web.py
|
|
140
|
+
# → http://127.0.0.1:8000 (interactive frontend)
|
|
141
|
+
# → http://127.0.0.1:8000/docs (OpenAPI documentation)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Endpoints: `POST /api/glaser/compute`, `POST /api/wave/ctf`, `POST /api/wave/probe`, `POST /api/multislice/simulate`, `POST /api/crystal/potential`, `POST /api/stem/probe`.
|
|
145
|
+
|
|
146
|
+
## Desktop GUI
|
|
147
|
+
|
|
148
|
+
Launch the PySide6 desktop application with 20 interactive panels:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
python gui/columx_gui.py
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Testing
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
cd tests
|
|
158
|
+
python test_all.py # Core modules (13 modules)
|
|
159
|
+
python test_new_physics.py # v2.0+ modules
|
|
160
|
+
python test_crystal_stem.py # Crystal + STEM + CBED + EELS + HRTEM + DPC
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
269 tests covering all 20 modules.
|
|
164
|
+
|
|
165
|
+
## Architecture
|
|
166
|
+
|
|
167
|
+
```
|
|
168
|
+
columx/
|
|
169
|
+
├── columx/ # 20 physics modules (13,000+ lines)
|
|
170
|
+
├── api/ # FastAPI REST API layer
|
|
171
|
+
├── web/ # Vue3 + Plotly.js frontend
|
|
172
|
+
├── gui/ # PySide6 desktop GUI (20 panels)
|
|
173
|
+
├── tests/ # 269 tests across 8 test files
|
|
174
|
+
└── docs/ # Architecture documentation
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Validation
|
|
178
|
+
|
|
179
|
+
ColumX has been systematically validated against MEBS (Munro's Electron Beam Software):
|
|
180
|
+
|
|
181
|
+
- **Paraxial**: M and theta accuracy 0.006%
|
|
182
|
+
- **Aberrations**: Cs < 0.04%, Cc < 0.02% (200 kV, objective lens)
|
|
183
|
+
- **5th order**: C5 verified against Krivanek analytical values
|
|
184
|
+
- **MEBS compatibility**: `match_mebs=True` mode replicates MEBS mixed relativistic convention
|
|
185
|
+
|
|
186
|
+
## References
|
|
187
|
+
|
|
188
|
+
1. Glaser, W. *Grundlagen der Elektronenoptik* (Springer, 1952)
|
|
189
|
+
2. Hawkes, P.W. & Kasper, E. *Principles of Electron Optics* (Academic Press, 1989)
|
|
190
|
+
3. Reimer, L. *Transmission Electron Microscopy* 5th ed. (Springer, 2013)
|
|
191
|
+
4. Krivanek, O.L. et al. *Ultramicroscopy* 110 (2010) 571-585
|
|
192
|
+
5. Kirkland, E.J. *Advanced Computing in Electron Microscopy* 2nd ed. (Springer, 2010)
|
|
193
|
+
|
|
194
|
+
## License
|
|
195
|
+
|
|
196
|
+
MIT License. See [LICENSE](LICENSE).
|
columx-2.3.0/README.md
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# ColumX
|
|
2
|
+
|
|
3
|
+
**Advanced Electron Optics Simulation Platform for TEM/STEM/SEM Column Design**
|
|
4
|
+
|
|
5
|
+
ColumX is a comprehensive Python library for electron optics simulation, covering paraxial ray tracing, aberration calculation, wave optics, multislice propagation, crystal potentials, and full TEM/STEM column modeling. It is designed for researchers and engineers working on electron microscope column design, beam physics analysis, and image simulation.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
ColumX provides 20 physics modules organized into four layers:
|
|
10
|
+
|
|
11
|
+
**Ray Optics** — `paraxial`, `ray3d`, `glaser`, `aberration`, `electrostatic_paraxial`
|
|
12
|
+
Magnetic and electrostatic lens modeling with Glaser analytical fields, adaptive-power Seidel aberration integrals (Cs < 0.04%, Cc < 0.02% vs MEBS), 5th-order aberration framework (C5, S5, Krivanek naming), and 3D relativistic Lorentz ray tracing.
|
|
13
|
+
|
|
14
|
+
**Wave Optics** — `wave`, `multislice`, `crystal`
|
|
15
|
+
Contrast transfer function with spatial/temporal coherence envelopes, STEM probe formation, FFT-based multislice propagation engine, and crystal structure module with Kirkland scattering factors for 7 built-in crystal presets (Si, Ge, GaAs, SiC, MgO, Al, Au).
|
|
16
|
+
|
|
17
|
+
**Advanced Imaging** — `stem`, `cbed`, `eels`, `hrtem`, `dpc`
|
|
18
|
+
STEM imaging chain (probe, annular detectors BF/ADF/HAADF, Z-contrast), convergent beam electron diffraction with HOLZ lines, EELS spectrum simulation with thickness measurement, HRTEM imaging (WPOA linear and multislice nonlinear), and differential phase contrast with electric/magnetic field reconstruction.
|
|
19
|
+
|
|
20
|
+
**Column & Infrastructure** — `column`, `lens_cascade`, `multipole`, `source`, `deflection`, `coulomb`, `fem2d`, `field`, `instruments`, `constants`
|
|
21
|
+
Full TEM column simulator, multi-lens cascade with Conrady aberration propagation, multipole elements, electron gun models (thermionic/field emission/Schottky), scanning deflection, space charge and Boersch effect, 2D FEM field solver, and instrument presets (Titan, Themis, ARM200F, ARM300F2).
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Core library
|
|
27
|
+
pip install columx
|
|
28
|
+
|
|
29
|
+
# With GUI (PySide6)
|
|
30
|
+
pip install "columx[gui]"
|
|
31
|
+
|
|
32
|
+
# With web API (FastAPI)
|
|
33
|
+
pip install "columx[api]"
|
|
34
|
+
|
|
35
|
+
# Everything
|
|
36
|
+
pip install "columx[all]"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### From Source
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
git clone https://github.com/allen-li1231/ColumX.git
|
|
43
|
+
cd ColumX
|
|
44
|
+
pip install -e ".[all]"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Quick Start
|
|
48
|
+
|
|
49
|
+
### Glaser Lens
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from columx import GlaserLens
|
|
53
|
+
|
|
54
|
+
lens = GlaserLens(V=200e3, B0=0.5, a=3e-3, z0=-30e-3, zf=60e-3)
|
|
55
|
+
print(f"Focal length: {lens.analytical_efl()*1e3:.2f} mm")
|
|
56
|
+
print(f"Magnification: {lens.analytical_magnification():.3f}")
|
|
57
|
+
print(lens.summary())
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### CTF and Probe
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from columx import ContrastTransferFunction, STEMProbe
|
|
64
|
+
|
|
65
|
+
ctf = ContrastTransferFunction(V=200e3, Cs=1.2e-3, Cc=1.2e-3, defocus=-50e-9)
|
|
66
|
+
print(f"Scherzer resolution: {ctf.scherzer_resolution()*1e10:.2f} A")
|
|
67
|
+
|
|
68
|
+
probe = STEMProbe(V=200e3, Cs=1e-3, alpha=10e-3)
|
|
69
|
+
print(f"Probe FWHM: {probe.probe_size()*1e10:.2f} A")
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Multislice Simulation
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from columx import MultisliceEngine
|
|
76
|
+
from columx.multislice import phase_grating_potential
|
|
77
|
+
import numpy as np
|
|
78
|
+
|
|
79
|
+
V = np.stack([phase_grating_potential(
|
|
80
|
+
nx=128, ny=128, Lx=5e-9, Ly=5e-9,
|
|
81
|
+
period=1e-9, amplitude=10.0
|
|
82
|
+
)] * 20)
|
|
83
|
+
|
|
84
|
+
engine = MultisliceEngine(V=200e3, nx=128, ny=128, Lx=5e-9, Ly=5e-9, dz=0.5e-9)
|
|
85
|
+
psi_exit = engine.run(V)
|
|
86
|
+
dp = engine.diffraction_pattern(psi_exit)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Crystal Potential
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from columx import CrystalStructure, projected_potential
|
|
93
|
+
|
|
94
|
+
si = CrystalStructure.from_preset("Si")
|
|
95
|
+
V_proj, info = projected_potential(si, nx=256)
|
|
96
|
+
print(f"MIP: {info['MIP_V']:.1f} V")
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Web API
|
|
100
|
+
|
|
101
|
+
Start the REST API server:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
python run_web.py
|
|
105
|
+
# → http://127.0.0.1:8000 (interactive frontend)
|
|
106
|
+
# → http://127.0.0.1:8000/docs (OpenAPI documentation)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Endpoints: `POST /api/glaser/compute`, `POST /api/wave/ctf`, `POST /api/wave/probe`, `POST /api/multislice/simulate`, `POST /api/crystal/potential`, `POST /api/stem/probe`.
|
|
110
|
+
|
|
111
|
+
## Desktop GUI
|
|
112
|
+
|
|
113
|
+
Launch the PySide6 desktop application with 20 interactive panels:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
python gui/columx_gui.py
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Testing
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
cd tests
|
|
123
|
+
python test_all.py # Core modules (13 modules)
|
|
124
|
+
python test_new_physics.py # v2.0+ modules
|
|
125
|
+
python test_crystal_stem.py # Crystal + STEM + CBED + EELS + HRTEM + DPC
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
269 tests covering all 20 modules.
|
|
129
|
+
|
|
130
|
+
## Architecture
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
columx/
|
|
134
|
+
├── columx/ # 20 physics modules (13,000+ lines)
|
|
135
|
+
├── api/ # FastAPI REST API layer
|
|
136
|
+
├── web/ # Vue3 + Plotly.js frontend
|
|
137
|
+
├── gui/ # PySide6 desktop GUI (20 panels)
|
|
138
|
+
├── tests/ # 269 tests across 8 test files
|
|
139
|
+
└── docs/ # Architecture documentation
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Validation
|
|
143
|
+
|
|
144
|
+
ColumX has been systematically validated against MEBS (Munro's Electron Beam Software):
|
|
145
|
+
|
|
146
|
+
- **Paraxial**: M and theta accuracy 0.006%
|
|
147
|
+
- **Aberrations**: Cs < 0.04%, Cc < 0.02% (200 kV, objective lens)
|
|
148
|
+
- **5th order**: C5 verified against Krivanek analytical values
|
|
149
|
+
- **MEBS compatibility**: `match_mebs=True` mode replicates MEBS mixed relativistic convention
|
|
150
|
+
|
|
151
|
+
## References
|
|
152
|
+
|
|
153
|
+
1. Glaser, W. *Grundlagen der Elektronenoptik* (Springer, 1952)
|
|
154
|
+
2. Hawkes, P.W. & Kasper, E. *Principles of Electron Optics* (Academic Press, 1989)
|
|
155
|
+
3. Reimer, L. *Transmission Electron Microscopy* 5th ed. (Springer, 2013)
|
|
156
|
+
4. Krivanek, O.L. et al. *Ultramicroscopy* 110 (2010) 571-585
|
|
157
|
+
5. Kirkland, E.J. *Advanced Computing in Electron Microscopy* 2nd ed. (Springer, 2010)
|
|
158
|
+
|
|
159
|
+
## License
|
|
160
|
+
|
|
161
|
+
MIT License. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ColumX v2.3.0 — Advanced Electron Optics Simulation Platform
|
|
3
|
+
====================================================================
|
|
4
|
+
对标 MEBS (Munro's Electron Beam Software) 全模块功能
|
|
5
|
+
|
|
6
|
+
v2.3 改进:
|
|
7
|
+
- CBED会聚束衍射 (cbed): 圆盘花样, HOLZ线, 对称性分析, 运动学近似
|
|
8
|
+
- EELS能谱 (eels): ZLP, 等离子体峰, 核心损失边, 元素指纹, 厚度测量
|
|
9
|
+
- HRTEM像模拟 (hrtem): WPOA线性成像, Multislice非线性, 欠焦系列, 功率谱
|
|
10
|
+
- DPC场映射 (dpc): 分段探测器, 质心偏移, 电场/磁场/电荷密度定量
|
|
11
|
+
|
|
12
|
+
v2.2 改进:
|
|
13
|
+
- 晶体势场模块 (crystal): Kirkland散射因子, 7种内置晶体结构, 投影势计算
|
|
14
|
+
- STEM成像链路 (stem): 2D探针, 环形探测器(BF/ADF/HAADF), Z-contrast成像
|
|
15
|
+
|
|
16
|
+
v2.1 改进:
|
|
17
|
+
- Cc自适应幂次 (cc_power='auto'): Glaser公式q=1.0-2.97×B/B0, Cc精度<0.02%
|
|
18
|
+
- 5阶像差框架: C5混合Seidel/Glaser, S5, Krivanek标准命名接口
|
|
19
|
+
- Multislice波传播: FFT传播引擎, 相位光栅/弱相位物体/非晶样品模型
|
|
20
|
+
- Cs/Cc精度: Cs<0.04%, Cc<0.02% (obj_v2 200kV vs MEBS)
|
|
21
|
+
|
|
22
|
+
v2.0 改进:
|
|
23
|
+
- MEBS兼容模式 (match_mebs): 近轴方程使用V(非相对论), 像差积分使用V*(相对论)
|
|
24
|
+
- 双求解器架构: M/θ精度0.006%, Cs/Cc精度0.0%/2.4%
|
|
25
|
+
- Cs自适应幂次 (cs_power='auto'): Glaser公式p从4.0优化为4.0+0.383×B/B0
|
|
26
|
+
- 多透镜级联模块 (lens_cascade): Conrady像差传播
|
|
27
|
+
- 静电透镜求解器 (electrostatic_paraxial): 完整静电近轴ODE
|
|
28
|
+
|
|
29
|
+
Modules:
|
|
30
|
+
constants — Physical constants and relativistic utilities
|
|
31
|
+
ray3d — 3D relativistic Lorentz force ray tracing
|
|
32
|
+
paraxial — Paraxial ray equation solver (g/h rays, MEBS compat)
|
|
33
|
+
glaser — Glaser bell-shaped magnetic lens model
|
|
34
|
+
aberration — Hybrid Seidel/Glaser aberration (Cs, Cc, C5, adaptive p/q)
|
|
35
|
+
fem2d — 2D FEM field solver (SOFEM equivalent)
|
|
36
|
+
field — Field interpolation utilities
|
|
37
|
+
multipole — Multipole elements (quad, hex, octupole)
|
|
38
|
+
source — Electron gun emission models
|
|
39
|
+
wave — Wave optics: CTF, probe formation, diffraction
|
|
40
|
+
deflection — Scanning deflection and dynamic correction
|
|
41
|
+
coulomb — Coulomb interactions (trajectory displacement, Boersch)
|
|
42
|
+
column — Full TEM column simulator
|
|
43
|
+
lens_cascade — Multi-lens cascade with Conrady aberration propagation
|
|
44
|
+
electrostatic_paraxial — Electrostatic paraxial ODE solver + aberrations
|
|
45
|
+
multislice — Multislice wave propagation engine
|
|
46
|
+
crystal — Crystal structure, scattering factors, projected potential
|
|
47
|
+
stem — STEM imaging chain: probe, detectors, Z-contrast
|
|
48
|
+
cbed — Convergent beam electron diffraction
|
|
49
|
+
eels — Electron energy loss spectroscopy
|
|
50
|
+
hrtem — High-resolution TEM image simulation
|
|
51
|
+
dpc — Differential phase contrast STEM imaging
|
|
52
|
+
"""
|
|
53
|
+
__version__ = "2.3.0"
|
|
54
|
+
|
|
55
|
+
__all__ = [
|
|
56
|
+
'constants', 'ray3d', 'paraxial', 'glaser', 'aberration',
|
|
57
|
+
'fem2d', 'field', 'multipole', 'source', 'wave',
|
|
58
|
+
'deflection', 'coulomb', 'column', 'lens_cascade',
|
|
59
|
+
'electrostatic_paraxial', 'multislice', 'abtem_interface',
|
|
60
|
+
'instruments', 'crystal', 'stem',
|
|
61
|
+
'cbed', 'eels', 'hrtem', 'dpc',
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
# Convenience re-exports
|
|
65
|
+
from .constants import (
|
|
66
|
+
q, m, c_light, h_planck, hbar, k_B, eps0, mu0,
|
|
67
|
+
relativistic_voltage, alpha_paraxial, electron_wavelength,
|
|
68
|
+
electron_velocity, gamma_factor,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
from .paraxial import ParaxialSolver
|
|
72
|
+
from .glaser import GlaserLens
|
|
73
|
+
from .aberration import AberrationCalculator
|
|
74
|
+
from .ray3d import trace_ray, trace_rays
|
|
75
|
+
from .field import FieldInterpolator1D, FieldInterpolator2D, FieldMap
|
|
76
|
+
from .multipole import QuadrupoleLens, MultipoleCascade, drift_matrix, thin_lens_matrix
|
|
77
|
+
from .source import ThermionicEmitter, FieldEmitter, SchottkyEmitter, GunOptics
|
|
78
|
+
from .wave import ContrastTransferFunction, STEMProbe
|
|
79
|
+
from .deflection import Deflector, ScanGenerator, WienFilter
|
|
80
|
+
from .coulomb import SpaceCharge, TrajectoryDisplacement
|
|
81
|
+
from .column import TEMColumn, PredefinedColumns
|
|
82
|
+
from .lens_cascade import LensCascade, ConradyPropagation
|
|
83
|
+
from .electrostatic_paraxial import ElectrostaticParaxialSolver, ElectrostaticAberrationCalculator
|
|
84
|
+
from .multislice import MultisliceEngine, interaction_parameter
|
|
85
|
+
from .abtem_interface import krivanek_to_polar, aberration_to_abtem
|
|
86
|
+
from .instruments import get_instrument, list_instruments, setup_simulation
|
|
87
|
+
from .crystal import (
|
|
88
|
+
CrystalStructure, Atom, projected_potential, potential_3d_from_crystal,
|
|
89
|
+
mean_inner_potential, scattering_factor_kirkland, d_spacings,
|
|
90
|
+
)
|
|
91
|
+
from .stem import (
|
|
92
|
+
STEMProbe2D, AnnularDetector, STEMImage,
|
|
93
|
+
haadf_cross_section, z_contrast_ratio,
|
|
94
|
+
)
|
|
95
|
+
from .cbed import CBEDPattern, disk_geometry, analyze_symmetry, holz_rings, cbed_from_crystal
|
|
96
|
+
from .eels import (
|
|
97
|
+
EELSSpectrum, EELSQuantification, plasmon_energy,
|
|
98
|
+
edge_onset, differential_cross_section, estimate_thickness,
|
|
99
|
+
)
|
|
100
|
+
from .hrtem import (
|
|
101
|
+
HRTEMImage, power_spectrum, image_contrast, projected_phase_image, scherzer_image,
|
|
102
|
+
)
|
|
103
|
+
from .dpc import (
|
|
104
|
+
DPCImage, SegmentedDetector, electric_field_from_dpc,
|
|
105
|
+
magnetic_field_from_dpc, charge_density_from_dpc, dpc_magnitude,
|
|
106
|
+
)
|