unitau 0.1.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.
Files changed (33) hide show
  1. unitau-0.1.0/LICENSE +21 -0
  2. unitau-0.1.0/PKG-INFO +118 -0
  3. unitau-0.1.0/README.md +83 -0
  4. unitau-0.1.0/pyproject.toml +57 -0
  5. unitau-0.1.0/setup.cfg +4 -0
  6. unitau-0.1.0/src/unitau/__init__.py +21 -0
  7. unitau-0.1.0/src/unitau/cli.py +276 -0
  8. unitau-0.1.0/src/unitau/constants.py +28 -0
  9. unitau-0.1.0/src/unitau/parsers/__init__.py +75 -0
  10. unitau-0.1.0/src/unitau/parsers/base.py +70 -0
  11. unitau-0.1.0/src/unitau/parsers/generic.py +131 -0
  12. unitau-0.1.0/src/unitau/parsers/qe.py +204 -0
  13. unitau-0.1.0/src/unitau/parsers/vasp.py +215 -0
  14. unitau-0.1.0/src/unitau/parsers/wien2k.py +376 -0
  15. unitau-0.1.0/src/unitau/physics/__init__.py +41 -0
  16. unitau-0.1.0/src/unitau/physics/adp.py +103 -0
  17. unitau-0.1.0/src/unitau/physics/imp.py +149 -0
  18. unitau-0.1.0/src/unitau/physics/matthiessen.py +205 -0
  19. unitau-0.1.0/src/unitau/physics/pop.py +189 -0
  20. unitau-0.1.0/src/unitau/transport/__init__.py +34 -0
  21. unitau-0.1.0/src/unitau/transport/boltztrap2_bridge.py +135 -0
  22. unitau-0.1.0/src/unitau/transport/interpolator.py +288 -0
  23. unitau-0.1.0/src/unitau/transport/onsager.py +312 -0
  24. unitau-0.1.0/src/unitau.egg-info/PKG-INFO +118 -0
  25. unitau-0.1.0/src/unitau.egg-info/SOURCES.txt +31 -0
  26. unitau-0.1.0/src/unitau.egg-info/dependency_links.txt +1 -0
  27. unitau-0.1.0/src/unitau.egg-info/entry_points.txt +2 -0
  28. unitau-0.1.0/src/unitau.egg-info/requires.txt +16 -0
  29. unitau-0.1.0/src/unitau.egg-info/top_level.txt +1 -0
  30. unitau-0.1.0/tests/test_cli.py +65 -0
  31. unitau-0.1.0/tests/test_parsers.py +173 -0
  32. unitau-0.1.0/tests/test_physics.py +244 -0
  33. unitau-0.1.0/tests/test_transport.py +100 -0
unitau-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Dr. Sabir Makhlouf
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.
unitau-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,118 @@
1
+ Metadata-Version: 2.4
2
+ Name: unitau
3
+ Version: 0.1.0
4
+ Summary: Unified Energy-Dependent Relaxation Time Engine for Thermoelectric Transport
5
+ Author-email: "Dr. Sabir Makhlouf" <sabir.makhlouf@gmail.com>
6
+ Maintainer-email: "Dr. Sabir Makhlouf" <sabir.makhlouf@gmail.com>
7
+ License: MIT
8
+ Keywords: thermoelectrics,boltzmann-transport,relaxation-time,dft,boltztrap2,physics
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Scientific/Engineering :: Physics
17
+ Classifier: Topic :: Scientific/Engineering :: Chemistry
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: numpy>=1.24
22
+ Requires-Dist: scipy>=1.10
23
+ Requires-Dist: spglib>=2.0
24
+ Requires-Dist: matplotlib>=3.7
25
+ Provides-Extra: boltztrap2
26
+ Requires-Dist: BoltzTraP2>=22.6.1; extra == "boltztrap2"
27
+ Provides-Extra: dev
28
+ Requires-Dist: pytest>=7.0; extra == "dev"
29
+ Requires-Dist: openpyxl>=3.1; extra == "dev"
30
+ Provides-Extra: all
31
+ Requires-Dist: BoltzTraP2>=22.6.1; extra == "all"
32
+ Requires-Dist: pytest>=7.0; extra == "all"
33
+ Requires-Dist: openpyxl>=3.1; extra == "all"
34
+ Dynamic: license-file
35
+
36
+ # `unitau`: Unified Energy-Dependent Relaxation Time Engine for Thermoelectric Transport
37
+
38
+ **Author:** Dr. Sabir Makhlouf (`sabir.makhlouf@gmail.com`)
39
+ **License:** MIT License (Copyright © 2026 Dr. Sabir Makhlouf)
40
+
41
+ `unitau` replaces the ubiquitous Constant Relaxation Time Approximation ($\tau = 10^{-14}\,\text{s}$) in first-principles thermoelectric transport workflows with a rigorously SI-unit-verified, energy-, temperature-, and carrier-concentration-dependent scattering engine built directly on DFT electronic densities of states and Fourier-interpolated band velocities.
42
+
43
+ ---
44
+
45
+ ## Key Physics & Formulation
46
+
47
+ `unitau` combines three dominant carrier-scattering channels via **Matthiessen's rule**:
48
+
49
+ $$\frac{1}{\tau_{\text{total}}(E, T, n)} = \frac{1}{\tau_{\text{ADP}}(E, T)} + \frac{1}{\tau_{\text{POP}}(E, T)} + \frac{1}{\tau_{\text{IMP}}(E, T, n)}$$
50
+
51
+ 1. **DOS-Weighted Acoustic Deformation Potential (ADP):**
52
+ $$\frac{1}{\tau_{\text{ADP}}(E, T)} = \frac{2\pi k_B T E_d^2}{\hbar C_{\text{eff}}} D_{\text{spin}}(E)$$
53
+ Uses the actual first-principles DFT spin-resolved density of states $D_{\text{spin}}(E)$ ($\text{states}\cdot\text{J}^{-1}\cdot\text{m}^{-3}$), naturally capturing multi-valley degeneracies, band convergence, and non-parabolicity without single-parabolic-band (SPB) approximations.
54
+
55
+ 2. **Polar Optical Phonon (Fröhlich POP):**
56
+ Computes absorption and emission scattering weighted by Bose–Einstein phonon occupancies $N_{\text{LO}}$ and Fermi–Dirac final-state occupancies in either **MRTA** (exact closed-form momentum-transfer angular integral) or **SERTA**, using $\varepsilon_0$, $\varepsilon_\infty$, $m_{\text{eff}}$, and $\omega_{\text{LO}}$ (with automatic Debye fallback $\hbar\omega_{\text{LO}} \approx k_B \Theta_D$ when phonon dispersion is unavailable). Rigorously vanishes when $\varepsilon_0 = \varepsilon_\infty$.
57
+
58
+ 3. **Ionized Impurity Scattering (Brooks–Herring IMP):**
59
+ Computes screened Coulomb scattering with generalized inverse screening length $\beta^2(T, \mu) = \frac{e^2}{\varepsilon_{\text{vac}} \varepsilon_0 k_B T} \int D_{\text{total}}(E) f_0(1 - f_0)\,dE$, seamlessly bridging non-degenerate Debye–Hückel and degenerate Thomas–Fermi screening.
60
+
61
+ 4. **Onsager Transport Integration & BoltzTraP2 Compatibility:**
62
+ Injects $\Sigma(E) = v^2(E) D(E) \tau(E, T, n)$ into the exact Onsager integrals $\mathcal{K}_0, \mathcal{K}_1, \mathcal{K}_2$ to compute $\sigma(T)$, $S(T)$, $\kappa_e(T)$, $\text{PF}(T) = S^2\sigma$, and $ZT(T) = \frac{S^2\sigma T}{\kappa_e + \kappa_L}$ under both CRTA ($\tau_0 = 10^{-14}\,\text{s}$) and `unitau`. Includes a pure-Python SPKA Fourier-star interpolator, `.bt2` reader/writer, and an optional bridge to Cython `BoltzTraP2` when installed.
63
+
64
+ ---
65
+
66
+ ## Supported DFT Parsers (`unitau.parsers`)
67
+
68
+ | Code / Format | File Types | Output Object |
69
+ | :--- | :--- | :--- |
70
+ | **VASP** | `vasprun.xml`, `vasprun.xml.gz`, `DOSCAR` | `ElectronicStructure`, `DosData` |
71
+ | **WIEN2k** | `.energy`/`.energyso` + `.struct` + `.scf`, `.dos1ev`, `.bt2` | `ElectronicStructure`, `DosData` |
72
+ | **Quantum ESPRESSO** | QEXSD `.xml`, `dos.x` (`dos.dat`) | `ElectronicStructure`, `DosData` |
73
+ | **Generic** | `.csv`, `.json` | `ElectronicStructure`, `DosData` |
74
+
75
+ ---
76
+
77
+ ## Installation
78
+
79
+ ```bash
80
+ pip install -e .
81
+ # With pytest & spreadsheet benchmark tools:
82
+ pip install -e ".[dev]"
83
+ ```
84
+
85
+ ---
86
+
87
+ ## Quick Start
88
+
89
+ ### CLI Usage
90
+ ```bash
91
+ unitau info
92
+ unitau parse path/to/vasprun.xml.gz
93
+ unitau run path/to/vasprun.xml.gz --ed 3.2 --ceff 78.4 --eps0 380 --eps-inf 26.2 --wlo-thz 3.2 --conc -1.69e19 --temps 325,525,725 --kappa-l 1.5 --band-gap 0.31
94
+ unitau scatter --temp 300 --eps0 380 --eps-inf 26.2 --wlo-thz 3.2 --conc 1e18
95
+ ```
96
+
97
+ ### Reproducing the 8-Material Manuscript Validation
98
+ ```bash
99
+ pytest
100
+ python benchmarks/run_paper_benchmark.py
101
+ ```
102
+ Outputs manuscript-ready tables (`paper_results/tables/`), 300-DPI figures (`paper_results/figures/`), provenance records (`benchmarks/PROVENANCE.md`), and the structured statistical validation report (`paper_results/PAPER_VALIDATION_REPORT.md`).
103
+
104
+ ---
105
+
106
+ ## Citation
107
+
108
+ If you use `unitau` in published work, please cite the software metadata in [`CITATION.cff`](CITATION.cff):
109
+
110
+ ```bibtex
111
+ @software{makhlouf_unitau_2026,
112
+ author = {Makhlouf, Sabir},
113
+ title = {unitau: Unified Energy-Dependent Relaxation Time Engine for Thermoelectric Transport},
114
+ year = {2026},
115
+ version = {0.1.0},
116
+ license = {MIT}
117
+ }
118
+ ```
unitau-0.1.0/README.md ADDED
@@ -0,0 +1,83 @@
1
+ # `unitau`: Unified Energy-Dependent Relaxation Time Engine for Thermoelectric Transport
2
+
3
+ **Author:** Dr. Sabir Makhlouf (`sabir.makhlouf@gmail.com`)
4
+ **License:** MIT License (Copyright © 2026 Dr. Sabir Makhlouf)
5
+
6
+ `unitau` replaces the ubiquitous Constant Relaxation Time Approximation ($\tau = 10^{-14}\,\text{s}$) in first-principles thermoelectric transport workflows with a rigorously SI-unit-verified, energy-, temperature-, and carrier-concentration-dependent scattering engine built directly on DFT electronic densities of states and Fourier-interpolated band velocities.
7
+
8
+ ---
9
+
10
+ ## Key Physics & Formulation
11
+
12
+ `unitau` combines three dominant carrier-scattering channels via **Matthiessen's rule**:
13
+
14
+ $$\frac{1}{\tau_{\text{total}}(E, T, n)} = \frac{1}{\tau_{\text{ADP}}(E, T)} + \frac{1}{\tau_{\text{POP}}(E, T)} + \frac{1}{\tau_{\text{IMP}}(E, T, n)}$$
15
+
16
+ 1. **DOS-Weighted Acoustic Deformation Potential (ADP):**
17
+ $$\frac{1}{\tau_{\text{ADP}}(E, T)} = \frac{2\pi k_B T E_d^2}{\hbar C_{\text{eff}}} D_{\text{spin}}(E)$$
18
+ Uses the actual first-principles DFT spin-resolved density of states $D_{\text{spin}}(E)$ ($\text{states}\cdot\text{J}^{-1}\cdot\text{m}^{-3}$), naturally capturing multi-valley degeneracies, band convergence, and non-parabolicity without single-parabolic-band (SPB) approximations.
19
+
20
+ 2. **Polar Optical Phonon (Fröhlich POP):**
21
+ Computes absorption and emission scattering weighted by Bose–Einstein phonon occupancies $N_{\text{LO}}$ and Fermi–Dirac final-state occupancies in either **MRTA** (exact closed-form momentum-transfer angular integral) or **SERTA**, using $\varepsilon_0$, $\varepsilon_\infty$, $m_{\text{eff}}$, and $\omega_{\text{LO}}$ (with automatic Debye fallback $\hbar\omega_{\text{LO}} \approx k_B \Theta_D$ when phonon dispersion is unavailable). Rigorously vanishes when $\varepsilon_0 = \varepsilon_\infty$.
22
+
23
+ 3. **Ionized Impurity Scattering (Brooks–Herring IMP):**
24
+ Computes screened Coulomb scattering with generalized inverse screening length $\beta^2(T, \mu) = \frac{e^2}{\varepsilon_{\text{vac}} \varepsilon_0 k_B T} \int D_{\text{total}}(E) f_0(1 - f_0)\,dE$, seamlessly bridging non-degenerate Debye–Hückel and degenerate Thomas–Fermi screening.
25
+
26
+ 4. **Onsager Transport Integration & BoltzTraP2 Compatibility:**
27
+ Injects $\Sigma(E) = v^2(E) D(E) \tau(E, T, n)$ into the exact Onsager integrals $\mathcal{K}_0, \mathcal{K}_1, \mathcal{K}_2$ to compute $\sigma(T)$, $S(T)$, $\kappa_e(T)$, $\text{PF}(T) = S^2\sigma$, and $ZT(T) = \frac{S^2\sigma T}{\kappa_e + \kappa_L}$ under both CRTA ($\tau_0 = 10^{-14}\,\text{s}$) and `unitau`. Includes a pure-Python SPKA Fourier-star interpolator, `.bt2` reader/writer, and an optional bridge to Cython `BoltzTraP2` when installed.
28
+
29
+ ---
30
+
31
+ ## Supported DFT Parsers (`unitau.parsers`)
32
+
33
+ | Code / Format | File Types | Output Object |
34
+ | :--- | :--- | :--- |
35
+ | **VASP** | `vasprun.xml`, `vasprun.xml.gz`, `DOSCAR` | `ElectronicStructure`, `DosData` |
36
+ | **WIEN2k** | `.energy`/`.energyso` + `.struct` + `.scf`, `.dos1ev`, `.bt2` | `ElectronicStructure`, `DosData` |
37
+ | **Quantum ESPRESSO** | QEXSD `.xml`, `dos.x` (`dos.dat`) | `ElectronicStructure`, `DosData` |
38
+ | **Generic** | `.csv`, `.json` | `ElectronicStructure`, `DosData` |
39
+
40
+ ---
41
+
42
+ ## Installation
43
+
44
+ ```bash
45
+ pip install -e .
46
+ # With pytest & spreadsheet benchmark tools:
47
+ pip install -e ".[dev]"
48
+ ```
49
+
50
+ ---
51
+
52
+ ## Quick Start
53
+
54
+ ### CLI Usage
55
+ ```bash
56
+ unitau info
57
+ unitau parse path/to/vasprun.xml.gz
58
+ unitau run path/to/vasprun.xml.gz --ed 3.2 --ceff 78.4 --eps0 380 --eps-inf 26.2 --wlo-thz 3.2 --conc -1.69e19 --temps 325,525,725 --kappa-l 1.5 --band-gap 0.31
59
+ unitau scatter --temp 300 --eps0 380 --eps-inf 26.2 --wlo-thz 3.2 --conc 1e18
60
+ ```
61
+
62
+ ### Reproducing the 8-Material Manuscript Validation
63
+ ```bash
64
+ pytest
65
+ python benchmarks/run_paper_benchmark.py
66
+ ```
67
+ Outputs manuscript-ready tables (`paper_results/tables/`), 300-DPI figures (`paper_results/figures/`), provenance records (`benchmarks/PROVENANCE.md`), and the structured statistical validation report (`paper_results/PAPER_VALIDATION_REPORT.md`).
68
+
69
+ ---
70
+
71
+ ## Citation
72
+
73
+ If you use `unitau` in published work, please cite the software metadata in [`CITATION.cff`](CITATION.cff):
74
+
75
+ ```bibtex
76
+ @software{makhlouf_unitau_2026,
77
+ author = {Makhlouf, Sabir},
78
+ title = {unitau: Unified Energy-Dependent Relaxation Time Engine for Thermoelectric Transport},
79
+ year = {2026},
80
+ version = {0.1.0},
81
+ license = {MIT}
82
+ }
83
+ ```
@@ -0,0 +1,57 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "unitau"
7
+ version = "0.1.0"
8
+ description = "Unified Energy-Dependent Relaxation Time Engine for Thermoelectric Transport"
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ authors = [
12
+ { name = "Dr. Sabir Makhlouf", email = "sabir.makhlouf@gmail.com" },
13
+ ]
14
+ maintainers = [
15
+ { name = "Dr. Sabir Makhlouf", email = "sabir.makhlouf@gmail.com" },
16
+ ]
17
+ requires-python = ">=3.10"
18
+ keywords = [
19
+ "thermoelectrics",
20
+ "boltzmann-transport",
21
+ "relaxation-time",
22
+ "dft",
23
+ "boltztrap2",
24
+ "physics",
25
+ ]
26
+ classifiers = [
27
+ "Development Status :: 4 - Beta",
28
+ "Intended Audience :: Science/Research",
29
+ "License :: OSI Approved :: MIT License",
30
+ "Programming Language :: Python :: 3",
31
+ "Programming Language :: Python :: 3.10",
32
+ "Programming Language :: Python :: 3.11",
33
+ "Programming Language :: Python :: 3.12",
34
+ "Topic :: Scientific/Engineering :: Physics",
35
+ "Topic :: Scientific/Engineering :: Chemistry",
36
+ ]
37
+ dependencies = [
38
+ "numpy>=1.24",
39
+ "scipy>=1.10",
40
+ "spglib>=2.0",
41
+ "matplotlib>=3.7",
42
+ ]
43
+
44
+ [project.optional-dependencies]
45
+ boltztrap2 = ["BoltzTraP2>=22.6.1"]
46
+ dev = ["pytest>=7.0", "openpyxl>=3.1"]
47
+ all = ["BoltzTraP2>=22.6.1", "pytest>=7.0", "openpyxl>=3.1"]
48
+
49
+ [project.scripts]
50
+ unitau = "unitau.cli:main"
51
+
52
+ [tool.setuptools.packages.find]
53
+ where = ["src"]
54
+
55
+ [tool.pytest.ini_options]
56
+ testpaths = ["tests"]
57
+ addopts = "-v"
unitau-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,21 @@
1
+ """unitau: Unified Energy-Dependent Relaxation Time Engine for Thermoelectric Transport."""
2
+
3
+ from unitau import constants, parsers, physics, transport
4
+
5
+ __version__ = "0.1.0"
6
+ __author__ = "Dr. Sabir Makhlouf"
7
+ __email__ = "sabir.makhlouf@gmail.com"
8
+ __license__ = "MIT"
9
+ __copyright__ = "Copyright (c) 2026 Dr. Sabir Makhlouf"
10
+
11
+ __all__ = [
12
+ "__author__",
13
+ "__copyright__",
14
+ "__email__",
15
+ "__license__",
16
+ "__version__",
17
+ "constants",
18
+ "parsers",
19
+ "physics",
20
+ "transport",
21
+ ]
@@ -0,0 +1,276 @@
1
+ """Command-line interface for unitau with mandatory scientific attribution banner."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import json
7
+ from pathlib import Path
8
+ import sys
9
+ from typing import Sequence
10
+
11
+ import numpy as np
12
+
13
+ from unitau import __author__, __copyright__, __email__, __license__, __version__
14
+ from unitau.constants import CRTA_DEFAULT_TAU_S, ELEMENTARY_CHARGE
15
+ from unitau.parsers import DosData, ElectronicStructure, auto_parse
16
+ from unitau.physics import (
17
+ ScatteringParameters,
18
+ adp_scattering_rate,
19
+ combine_matthiessen_rates,
20
+ imp_scattering_rate,
21
+ inverse_screening_length_sq,
22
+ pop_scattering_rate,
23
+ )
24
+ from unitau.transport import (
25
+ TransportGrid,
26
+ build_transport_grid,
27
+ has_boltztrap2,
28
+ interpolate_band_structure,
29
+ run_crta_and_unitau_sweep,
30
+ )
31
+
32
+ CITATION_BANNER = f"""================================================================================
33
+ unitau v{__version__} — Unified Energy-Dependent Relaxation Time Engine
34
+ Author : {__author__} <{__email__}>
35
+ License : {__license__} ({__copyright__})
36
+ Physics : Matthiessen(ADP[DFT-DOS] + Frohlich-POP + Brooks-Herring-IMP)
37
+ Citation : If used in publications, please cite {__author__} (CITATION.cff)
38
+ ================================================================================"""
39
+
40
+
41
+ def print_banner(stream=None, *, quiet: bool = False) -> None:
42
+ """Print the unitau attribution and citation banner."""
43
+ if not quiet:
44
+ print(CITATION_BANNER, file=stream or sys.stdout)
45
+
46
+
47
+ def _load_params_from_args(args: argparse.Namespace) -> tuple[ScatteringParameters, dict]:
48
+ cfg: dict = {}
49
+ if getattr(args, "config", None):
50
+ cfg = json.loads(Path(args.config).read_text(encoding="utf-8"))
51
+
52
+ def pick(attr: str, key: str, default=None):
53
+ val = getattr(args, attr, None)
54
+ return val if val is not None else cfg.get(key, default)
55
+
56
+ params = ScatteringParameters(
57
+ deformation_potential_ev=float(pick("ed", "deformation_potential_ev")),
58
+ elastic_modulus_gpa=float(pick("ceff", "elastic_modulus_gpa")),
59
+ eps_0=float(pick("eps0", "eps_0")),
60
+ eps_inf=float(pick("eps_inf", "eps_inf")),
61
+ effective_mass_m0=float(pick("meff", "effective_mass_m0", 1.0)),
62
+ freq_lo_thz=pick("wlo_thz", "freq_lo_thz"),
63
+ debye_temperature_k=pick("theta_d", "debye_temperature_k"),
64
+ pop_mode=str(pick("pop_mode", "pop_mode", "mrta")).lower(), # type: ignore[arg-type]
65
+ )
66
+ return params, cfg
67
+
68
+
69
+ def _cmd_info(args: argparse.Namespace) -> int:
70
+ print(f"Package : unitau v{__version__}")
71
+ print(f"Author : {__author__} ({__email__})")
72
+ print(f"License : {__license__}")
73
+ print(f"CRTA Default tau : {CRTA_DEFAULT_TAU_S:.2e} s")
74
+ print(f"BoltzTraP2 C-ext : {'available' if has_boltztrap2() else 'not installed (using pure-Python SPKA)'}")
75
+ return 0
76
+
77
+
78
+ def _cmd_parse(args: argparse.Namespace) -> int:
79
+ obj = auto_parse(args.input, volume_a3=args.volume)
80
+ if isinstance(obj, ElectronicStructure):
81
+ vbm = float(obj.energies_ev[:, obj.n_occ_bands - 1].max())
82
+ cbm = float(obj.energies_ev[:, obj.n_occ_bands].min())
83
+ print(f"Format : {obj.source_format}")
84
+ print(f"Formula : {obj.formula}")
85
+ print(f"Cell Volume : {obj.volume_a3:.3f} A^3 ({obj.volume_m3:.4e} m^3)")
86
+ print(f"NELECT / occ : {obj.nelect:.2f} / {obj.n_occ_bands} bands (dosweight={obj.dosweight})")
87
+ print(f"k-points / bands : {len(obj.kpoints_frac)} x {obj.energies_ev.shape[1]}")
88
+ print(f"Raw DFT Gap : {cbm - vbm:.4f} eV (VBM={vbm:.4f}, CBM={cbm:.4f} eV)")
89
+ else:
90
+ print(f"Format : {obj.source_format}")
91
+ print(f"Cell Volume : {obj.volume_a3:.3f} A^3")
92
+ print(f"Energy Grid : {len(obj.energy_ev)} pts [{obj.energy_ev.min():.3f}, {obj.energy_ev.max():.3f}] eV")
93
+ print(f"Fermi Level : {obj.fermi_ev:.4f} eV")
94
+ if obj.vbm_ev is not None and obj.cbm_ev is not None:
95
+ print(f"Estimated Gap : {obj.cbm_ev - obj.vbm_ev:.4f} eV")
96
+ return 0
97
+
98
+
99
+ def _cmd_run(args: argparse.Namespace) -> int:
100
+ obj = auto_parse(args.input, volume_a3=args.volume)
101
+ params, cfg = _load_params_from_args(args)
102
+ temps = [float(t) for t in (args.temps.split(",") if args.temps else cfg.get("temperatures_k", [300.0, 500.0, 700.0]))]
103
+ conc_cm3 = float(args.conc if args.conc is not None else cfg.get("carrier_conc_cm3", -1e19))
104
+ conc_m3 = conc_cm3 * 1e6
105
+
106
+ if isinstance(obj, ElectronicStructure):
107
+ eg = args.band_gap if args.band_gap is not None else cfg.get("band_gap_ev")
108
+ bands = interpolate_band_structure(
109
+ obj,
110
+ band_gap_ev=eg,
111
+ target_multiplier=args.mesh_mult,
112
+ band_window=args.band_window,
113
+ )
114
+ grid: TransportGrid = build_transport_grid(bands, formula=obj.formula)
115
+ kl = args.kappa_l if args.kappa_l is not None else cfg.get("kappa_l_w_mk")
116
+ kl_list = [kl] * len(temps) if (kl is None or np.ndim(kl) == 0) else kl
117
+ crta_res, unitau_res = run_crta_and_unitau_sweep(
118
+ grid,
119
+ temps,
120
+ conc_m3,
121
+ params,
122
+ kappa_l_series=kl_list,
123
+ use_dft_effective_mass=not args.fixed_mass,
124
+ )
125
+
126
+ print(f"\nMaterial: {obj.formula} | n = {conc_cm3:.3e} cm^-3 | E_g = {grid.cbm_ev - grid.vbm_ev:.3f} eV")
127
+ print(f"{'T[K]':>6s} | {'CRT_sig':>10s} {'CRT_S':>8s} {'CRT_ZT':>7s} | {'uni_sig':>10s} {'uni_S':>8s} {'<tau>[fs]':>10s} {'uni_ZT':>7s}")
128
+ print("-" * 82)
129
+ rows = []
130
+ for c, u in zip(crta_res, unitau_res):
131
+ cz = f"{c.zt:7.3f}" if c.zt is not None else " N/A"
132
+ uz = f"{u.zt:7.3f}" if u.zt is not None else " N/A"
133
+ print(
134
+ f"{u.temperature_k:6.1f} | {c.sigma_s_m:10.1f} {c.seebeck_uv_k:8.1f} {cz} | "
135
+ f"{u.sigma_s_m:10.1f} {u.seebeck_uv_k:8.1f} {u.avg_tau_s * 1e15:10.2f} {uz}"
136
+ )
137
+ rows.append(
138
+ {
139
+ "T_K": u.temperature_k,
140
+ "crta": {"sigma_S_m": c.sigma_s_m, "S_uV_K": c.seebeck_uv_k, "kappa_e_W_mK": c.kappa_e_w_mk, "PF_W_mK2": c.power_factor_w_mk2, "ZT": c.zt, "mobility_cm2_Vs": c.mobility_cm2_vs},
141
+ "unitau": {"sigma_S_m": u.sigma_s_m, "S_uV_K": u.seebeck_uv_k, "kappa_e_W_mK": u.kappa_e_w_mk, "PF_W_mK2": u.power_factor_w_mk2, "ZT": u.zt, "mobility_cm2_Vs": u.mobility_cm2_vs, "avg_tau_s": u.avg_tau_s, "m_cond_dft_m0": u.effective_mass_dft_m0},
142
+ }
143
+ )
144
+ if args.out:
145
+ Path(args.out).write_text(json.dumps({"formula": obj.formula, "carrier_conc_cm3": conc_cm3, "results": rows}, indent=2), encoding="utf-8")
146
+ else:
147
+ assert isinstance(obj, DosData)
148
+ T = temps[0]
149
+ r_adp = adp_scattering_rate(obj.dos_spin_si, T, params.deformation_potential_ev, params.elastic_modulus_gpa)
150
+ eps_j = np.abs(obj.energy_ev - obj.fermi_ev) * ELEMENTARY_CHARGE
151
+ r_pop = pop_scattering_rate(
152
+ eps_j, T, params.eps_0, params.eps_inf, params.effective_mass_m0,
153
+ freq_lo_thz=params.freq_lo_thz, debye_temperature_k=params.debye_temperature_k, mode=params.pop_mode
154
+ )
155
+ beta2 = inverse_screening_length_sq(T, params.eps_0, carrier_conc_m3=abs(conc_m3))
156
+ r_imp = imp_scattering_rate(eps_j, beta2, params.eps_0, params.effective_mass_m0, abs(conc_m3))
157
+ r_tot, tau_tot = combine_matthiessen_rates(r_adp, r_pop, r_imp)
158
+ near_f = int(np.argmin(np.abs(obj.energy_ev - obj.fermi_ev)))
159
+ print(f"DOS-only scattering evaluated at T={T:.1f} K: tau_total(E_F) = {tau_tot[near_f]:.3e} s")
160
+ if args.out:
161
+ Path(args.out).write_text(
162
+ json.dumps(
163
+ {
164
+ "temperature_k": T,
165
+ "energy_eV": obj.energy_ev.tolist(),
166
+ "tau_total_s": tau_tot.tolist(),
167
+ "rate_adp_s_inv": r_adp.tolist(),
168
+ "rate_pop_s_inv": r_pop.tolist(),
169
+ "rate_imp_s_inv": r_imp.tolist(),
170
+ },
171
+ indent=2,
172
+ ),
173
+ encoding="utf-8",
174
+ )
175
+ return 0
176
+
177
+
178
+ def _cmd_scatter(args: argparse.Namespace) -> int:
179
+ eps_ev = np.linspace(0.001, args.emax, args.npts)
180
+ eps_j = eps_ev * ELEMENTARY_CHARGE
181
+ beta2 = inverse_screening_length_sq(args.temp, args.eps0, carrier_conc_m3=abs(args.conc) * 1e6)
182
+ r_pop = pop_scattering_rate(
183
+ eps_j, args.temp, args.eps0, args.eps_inf, args.meff,
184
+ freq_lo_thz=args.wlo_thz, debye_temperature_k=args.theta_d, mode=args.pop_mode
185
+ )
186
+ r_imp = imp_scattering_rate(eps_j, beta2, args.eps0, args.meff, abs(args.conc) * 1e6)
187
+ print(f"T={args.temp:.1f} K | beta^2={beta2:.3e} m^-2 | E_kin in [0.001, {args.emax:.2f}] eV")
188
+ print(f"{'E_kin[eV]':>10s} | {'rate_POP[1/s]':>14s} | {'rate_IMP[1/s]':>14s}")
189
+ for i in range(0, len(eps_ev), max(1, len(eps_ev) // 8)):
190
+ print(f"{eps_ev[i]:10.4f} | {r_pop[i]:14.4e} | {r_imp[i]:14.4e}")
191
+ return 0
192
+
193
+
194
+ def build_parser() -> argparse.ArgumentParser:
195
+ parser = argparse.ArgumentParser(
196
+ prog="unitau",
197
+ description="Unified Energy-Dependent Relaxation Time Engine for Thermoelectric Transport",
198
+ )
199
+ parser.add_argument("-q", "--quiet", action="store_true", help="Suppress the citation banner")
200
+ sub = parser.add_subparsers(dest="command", required=True)
201
+
202
+ p_info = sub.add_parser("info", help="Show version, attribution, and environment info")
203
+ p_info.set_defaults(func=_cmd_info)
204
+
205
+ p_parse = sub.add_parser("parse", help="Inspect a DFT band structure or DOS file")
206
+ p_parse.add_argument("input", help="Path to DFT file (vasprun.xml[.gz], DOSCAR, .dos1ev, .energy, .bt2, QE xml/dos, CSV, JSON)")
207
+ p_parse.add_argument("--volume", type=float, default=None, help="Cell volume in A^3 (if omitted in DOS-only file)")
208
+ p_parse.set_defaults(func=_cmd_parse)
209
+
210
+ p_run = sub.add_parser("run", help="Run CRTA and unitau scattering + Onsager transport")
211
+ p_run.add_argument("input", help="Path to DFT input file")
212
+ p_run.add_argument("--config", help="Optional JSON parameter config file")
213
+ p_run.add_argument("--ed", type=float, help="Deformation potential E_d [eV]")
214
+ p_run.add_argument("--ceff", type=float, help="Effective elastic modulus C_eff [GPa]")
215
+ p_run.add_argument("--eps0", type=float, help="Static relative permittivity")
216
+ p_run.add_argument("--eps-inf", dest="eps_inf", type=float, help="High-frequency relative permittivity")
217
+ p_run.add_argument("--meff", type=float, help="Effective mass in m_0")
218
+ p_run.add_argument("--wlo-thz", dest="wlo_thz", type=float, help="LO phonon frequency [THz]")
219
+ p_run.add_argument("--theta-d", dest="theta_d", type=float, help="Debye temperature fallback [K]")
220
+ p_run.add_argument("--conc", type=float, help="Signed carrier concentration [cm^-3] (negative=n-type, positive=p-type)")
221
+ p_run.add_argument("--temps", help="Comma-separated temperatures [K], e.g. 300,500,700")
222
+ p_run.add_argument("--band-gap", dest="band_gap", type=float, help="Target scissor-corrected band gap [eV]")
223
+ p_run.add_argument("--kappa-l", dest="kappa_l", type=float, help="Lattice thermal conductivity [W/(m*K)]")
224
+ p_run.add_argument("--pop-mode", dest="pop_mode", choices=["mrta", "serta"], default=None)
225
+ p_run.add_argument("--mesh-mult", dest="mesh_mult", type=int, default=8)
226
+ p_run.add_argument("--band-window", dest="band_window", type=int, default=4)
227
+ p_run.add_argument("--fixed-mass", dest="fixed_mass", action="store_true", help="Use input --meff instead of DFT m*_cond")
228
+ p_run.add_argument("--volume", type=float, default=None)
229
+ p_run.add_argument("--out", help="Output JSON path")
230
+ p_run.set_defaults(func=_cmd_run)
231
+
232
+ p_scat = sub.add_parser("scatter", help="Quick analytical POP + IMP scattering rate diagnostic")
233
+ p_scat.add_argument("--temp", type=float, default=300.0)
234
+ p_scat.add_argument("--eps0", type=float, required=True)
235
+ p_scat.add_argument("--eps-inf", dest="eps_inf", type=float, required=True)
236
+ p_scat.add_argument("--meff", type=float, default=0.25)
237
+ p_scat.add_argument("--wlo-thz", dest="wlo_thz", type=float, default=None)
238
+ p_scat.add_argument("--theta-d", dest="theta_d", type=float, default=300.0)
239
+ p_scat.add_argument("--conc", type=float, default=1e18)
240
+ p_scat.add_argument("--emax", type=float, default=0.3)
241
+ p_scat.add_argument("--npts", type=int, default=50)
242
+ p_scat.add_argument("--pop-mode", dest="pop_mode", choices=["mrta", "serta"], default="mrta")
243
+ p_scat.set_defaults(func=_cmd_scatter)
244
+ return parser
245
+
246
+
247
+ def _normalize_negative_scientific(argv: Sequence[str]) -> list[str]:
248
+ """Bind negative scientific-notation values (e.g. ``--conc -1e19`` -> ``--conc=-1e19``) so argparse does not mistake them for flags."""
249
+ import re
250
+
251
+ sci_neg = re.compile(r"^-(?:\d+\.?\d*|\.\d+)[eE][+-]?\d+$")
252
+ tokens = list(argv)
253
+ out: list[str] = []
254
+ i = 0
255
+ while i < len(tokens):
256
+ tok = tokens[i]
257
+ if tok == "--conc" and i + 1 < len(tokens) and sci_neg.match(tokens[i + 1]):
258
+ out.append(f"--conc={tokens[i + 1]}")
259
+ i += 2
260
+ continue
261
+ out.append(tok)
262
+ i += 1
263
+ return out
264
+
265
+
266
+ def main(argv: Sequence[str] | None = None) -> int:
267
+ """CLI entrypoint."""
268
+ raw_argv = sys.argv[1:] if argv is None else argv
269
+ parser = build_parser()
270
+ args = parser.parse_args(_normalize_negative_scientific(raw_argv))
271
+ print_banner(quiet=args.quiet)
272
+ return int(args.func(args))
273
+
274
+
275
+ if __name__ == "__main__":
276
+ raise SystemExit(main())
@@ -0,0 +1,28 @@
1
+ """Physical constants and unit conversion factors in strict SI units (CODATA 2018/2022)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ # Exact SI defining constants
6
+ ELEMENTARY_CHARGE: float = 1.602176634e-19 # C (also 1 eV in J)
7
+ BOLTZMANN_CONSTANT: float = 1.380649e-23 # J / K
8
+ PLANCK_CONSTANT: float = 6.62607015e-34 # J * s
9
+ REDUCED_PLANCK: float = 1.0545718176461565e-34 # h / (2 * pi) [J * s]
10
+
11
+ # Fundamental measured SI constants (CODATA 2018/2022)
12
+ VACUUM_PERMITTIVITY: float = 8.8541878128e-12 # F / m = C^2 / (N * m^2)
13
+ ELECTRON_MASS: float = 9.1093837015e-31 # kg
14
+
15
+ # Unit conversions to SI
16
+ EV_TO_J: float = ELEMENTARY_CHARGE # 1 eV -> J
17
+ J_TO_EV: float = 1.0 / ELEMENTARY_CHARGE # 1 J -> eV
18
+ ANGSTROM_TO_M: float = 1e-10 # 1 A -> m
19
+ BOHR_TO_M: float = 5.29177210903e-11 # 1 a0 -> m
20
+ BOHR_TO_ANGSTROM: float = 0.529177210903 # 1 a0 -> A
21
+ HARTREE_TO_EV: float = 27.211386245988 # 1 Ha -> eV
22
+ RYDBERG_TO_EV: float = 13.605693122994 # 1 Ry -> eV
23
+ GPA_TO_PA: float = 1e9 # 1 GPa -> Pa (N/m^2 = J/m^3)
24
+ THZ_TO_RAD_S: float = 2.0 * 3.141592653589793 * 1e12 # nu [THz] -> omega [rad/s]
25
+ INV_CM_TO_RAD_S: float = 2.0 * 3.141592653589793 * 2.99792458e10 # nu~ [cm^-1] -> omega [rad/s]
26
+
27
+ # Default BoltzTraP2 Constant Relaxation Time Approximation (CRTA) value
28
+ CRTA_DEFAULT_TAU_S: float = 1e-14 # s