ColumX
ColumX v2.3.6 — Advanced Electron Optics Simulation Platform © 2024-2026 Shuimu Scientific. All rights reserved. columx.com | PyPI | Documentation
Advanced Electron Optics Simulation Platform for TEM/STEM/SEM Column Design
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.
Features
ColumX provides 25 physics modules organized into four layers:
Ray Optics — paraxial, ray3d, glaser, aberration, electrostatic_paraxial
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.
Wave Optics — wave, multislice, crystal
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, Au, Al, Cu, Fe, GaAs, SrTiO3).
Advanced Imaging — stem, cbed, eels, hrtem, dpc
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.
Column & Infrastructure — column, lens_cascade, multipole, source, deflection, coulomb, fem2d, field, instruments, constants
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).
FEM Field Solver
ColumX includes a comprehensive 2D finite element method (FEM) field solver with both linear and nonlinear capabilities:
- CST (Constant Strain Triangle): Linear and nonlinear magnetostatic solver with first-order triangular elements
- SOFEM (Second-Order Finite Element Method): 6-node quadratic triangles for higher accuracy field solutions
- Newton-Raphson full tangent stiffness solver: Armijo backtracking line search for robust nonlinear convergence
- Multi-material support: Element-level permeability assignment with differentiated pole/yoke permeability (
assign_materials()) - B-H nonlinear curve support: Built-in
bh_mild_steelcurve and custom B-H curve input for realistic iron saturation modeling - Deep saturation convergence: Verified up to NI=15,000 A-turns (B > 2.5 T)
- 48 comprehensive physics tests: Covering multi-material, NR convergence, deep saturation, and SOFEM physics
- NR residual history tracking:
_nr_residual_historyattribute for convergence analysis
from columx.fem2d import AxisymmetricLens, bh_mild_steel
solver, coil_info = AxisymmetricLens.magnetic_lens_full(
NI=3000, r_pole=0.005, gap=0.004,
z_positions=(-0.04, 0.04), r_max=0.05,
iron_mu_r=2000.0, iron_bh_curve=bh_mild_steel,
iron_r_outer=0.035, pole_length=0.012, yoke_width=0.006,
nr=25, nz=50,
)
A = solver.solve_magnetic_newton_raphson(
A_func=coil_info['J_func'], max_iter=30, tol=1e-4,
)
# SOFEM second-order solver
from columx.sofem import magnetic_lens_sofem
solver2, ci2 = magnetic_lens_sofem(
NI=3000, r_pole=0.005, gap=0.004,
z_positions=(-0.04, 0.04), r_max=0.05,
iron_mu_r=2000.0, iron_bh_curve=bh_mild_steel,
iron_r_outer=0.035, pole_length=0.012, yoke_width=0.006,
nr=20, nz=40,
)
A2 = solver2.solve_magnetic_newton_raphson(A_func=ci2['J_func'])
Documentation
See the User Guide for detailed API reference, code examples for all 25 modules, web API endpoints, and GUI usage instructions.
For the desktop GUI manual, see ColumX GUI Manual.
Installation
# Core library
pip install columx
# With GUI (PySide6)
pip install "columx[gui]"
# With web API (FastAPI)
pip install "columx[api]"
# Everything
pip install "columx[all]"
From Source
Note: For production use, we recommend installing via pip. Building from source is intended for developers and contributors.
git clone https://github.com/alongai/ColumX.git
cd ColumX
pip install -e ".[all]"
Quick Start
Glaser Lens
from columx import GlaserLens
lens = GlaserLens(V=200e3, B0=0.5, a=3e-3, z0=-30e-3, zf=60e-3)
print(f"Focal length: {lens.analytical_efl()*1e3:.2f} mm")
print(f"Magnification: {lens.analytical_magnification():.3f}")
print(lens.summary())
CTF and Probe
from columx import ContrastTransferFunction, STEMProbe
ctf = ContrastTransferFunction(V=200e3, Cs=1.2e-3, Cc=1.2e-3, defocus=-50e-9)
print(f"Scherzer resolution: {ctf.scherzer_resolution()*1e10:.2f} A")
probe = STEMProbe(V=200e3, Cs=1e-3, alpha=10e-3)
print(f"Probe FWHM: {probe.probe_size()*1e10:.2f} A")
Multislice Simulation
from columx import MultisliceEngine
from columx.multislice import phase_grating_potential
import numpy as np
V = np.stack([phase_grating_potential(
nx=128, ny=128, Lx=5e-9, Ly=5e-9,
period=1e-9, amplitude=10.0
)] * 20)
engine = MultisliceEngine(V=200e3, nx=128, ny=128, Lx=5e-9, Ly=5e-9, dz=0.5e-9)
psi_exit = engine.run(V)
dp = engine.diffraction_pattern(psi_exit)
Crystal Potential
from columx import CrystalStructure, projected_potential
si = CrystalStructure.from_preset("Si")
V_proj, info = projected_potential(si, nx=256)
print(f"MIP: {info['MIP_V']:.1f} V")
Web API
Start the REST API server:
python run_web.py
# → http://127.0.0.1:8000 (interactive frontend)
# → http://127.0.0.1:8000/docs (OpenAPI documentation)
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.
Desktop GUI
Launch the PySide6 desktop application with 20 interactive panels including FEM CST/SOFEM field solver:
python gui/columx_gui.py
Testing
cd tests
python test_all.py # Core modules (13 modules)
python test_new_physics.py # v2.0+ modules
python test_crystal_stem.py # Crystal + STEM + CBED + EELS + HRTEM + DPC
317 tests covering all 25 modules.
Architecture
columx/
├── columx/ # 25 physics modules (13,000+ lines)
├── api/ # FastAPI REST API layer
├── web/ # Vue3 + Plotly.js frontend
├── gui/ # PySide6 desktop GUI (20 panels)
├── tests/ # 317 tests across 10 test files
└── docs/ # Architecture documentation
Validation
ColumX has been systematically validated against MEBS (Munro's Electron Beam Software):
- Paraxial: M and theta accuracy 0.006%
- Aberrations: Cs < 0.04%, Cc < 0.02% (200 kV, objective lens)
- 5th order: C5 verified against Krivanek analytical values
- MEBS compatibility:
match_mebs=Truemode replicates MEBS mixed relativistic convention
References
- Glaser, W. Grundlagen der Elektronenoptik (Springer, 1952)
- Hawkes, P.W. & Kasper, E. Principles of Electron Optics (Academic Press, 1989)
- Reimer, L. Transmission Electron Microscopy 5th ed. (Springer, 2013)
- Krivanek, O.L. et al. Ultramicroscopy 110 (2010) 571-585
- Kirkland, E.J. Advanced Computing in Electron Microscopy 2nd ed. (Springer, 2010)
License
ColumX is proprietary software developed by Shuimu Scientific. Community Edition is available under GPL v3. Professional and Enterprise editions require a commercial license. See LICENSE for full terms.
Release files for columx 2.3.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| columx-2.3.7.tar.gz | 475.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| columx-2.3.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 805.9 kB
Release files / columx-2.3.7.tar.gz
| Download URL | columx-2.3.7.tar.gz |
|---|---|
| Size | 475.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7f676507c4ea49fc2528d64769de2fd60f2111cc32b0965bd35142e45f5c7ea7
|
|
BLAKE2b-256 checksum How to use checksums |
a63c3a1d5f6d79e45b206e809fe57f5135d3fa9e5d099d1a7a54b28b91eb5179
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / columx-2.3.7-py3-none-any.whl
| Download URL | columx-2.3.7-py3-none-any.whl |
|---|---|
| Size | 330.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f5fc3f7f3baadbf91aeb254ba4ae2856f5fef80092b47e0548581f14c2ab92cf
|
|
BLAKE2b-256 checksum How to use checksums |
0541c5acac9c468bfd9f04bf2795ec063ad6b5a28ef738f79c303ea13ae2f0c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|