diff --git a/CLAUDE.md b/CLAUDE.md index c5b2b610..316525a2 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -43,7 +43,7 @@ test, and be understood: | Active reference contracts and benchmark baselines | `reproducibility/` | CamelCase (`ScapsComparisonContractV1.json`, `HysteresisReferenceContractV2.json`, `ScapsParams.xlsx`) | | Operational developer and extension guidance | `docs/` | Multi-word CamelCase, such as `DevelopmentGuide.md` | | Retired models, falsified closures, and historical witness ledger | `docs/RetiredModelsV1.md` | Multi-word CamelCase with version suffix (`RetiredModelsV1.md`) | -| Figures the root README embeds | `docs/figures/` | CamelCase, no date; regenerate under a new `V` and update the README link | +| Figures the root README embeds | `docs/figures/` | Versionless multi-word CamelCase, no date (`ValidationScapsOverview.png`) | **Archive (iCloud `projects/solarlab/`, never in git)** — everything else: diff --git a/README.md b/README.md index e476ce88..b0af42e8 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,8 @@ Xuan-Yan Chen · Longhan Zhang · Zecheng Gan* · Chang Yan& | # | Section | Scope | |--:|:--------|:------| | 1 | [Overview & Highlights](#1-overview--highlights) | Platform positioning and core design pillars | -| 2 | [Architecture & Repository Layout](#2-architecture--repository-layout) | Three-package V2 layout and navigation map | -| 3 | [Quickstart](#3-quickstart) | Environment setup, CLI, V2 server, and web workstation | +| 2 | [Architecture & Repository Layout](#2-architecture--repository-layout) | Three-package layout and navigation map | +| 3 | [Quickstart](#3-quickstart) | Environment setup, CLI, server, and web workstation | | 4 | [Experiment & Capability Matrix](#4-experiment--capability-matrix) | 1D, 2D, tandem, screening, and UI capabilities | | 5 | [Governing Physics & Numerical Method](#5-governing-physics--numerical-method) | PDEs, heterointerfaces, optics, and unified sparse assembly | | 6 | [Validation Benchmarks & Scope](#6-validation-benchmarks--scope) | 262-case SCAPS & 45-case hysteresis alignment vs formal qualification | @@ -46,26 +46,26 @@ Xuan-Yan Chen · Longhan Zhang · Zecheng Gan* · Chang Yan& - **Unified Sparse Equation Assembly (`solarlab.equations.assembly`)** — Positive log-activity carrier variables $(z_n, z_p)$ guarantee $n > 0$ and $p > 0$ at every iterate without density clipping, while shared `SystemLayout` + `Term` contracts assemble exact sparse analytical Jacobians across 1D DC, transient, small-signal AC, and 2D microstructure solves. - **Strict Conservation & Reciprocity** — Cancellation-free `expm1` control-volume inventories maintain ionic mass conservation below $1.8 \times 10^{-13}$ relative drift; heterojunctions enforce per-side DOS Bethe/Richardson thermionic reciprocity, two-sided / 7-level Gaussian interface SRH, and series-dielectric face capacitance. - **End-to-End Cryptographic Provenance (`RunStore` & `ExecutionManifest`)** — Every configuration, optical table, protocol, and compiled solver state is content-hashed (`H_input`, `H_physics`, `H_execution`). Completed runs and failed prefixes are persisted losslessly for solver-free readback. -- **Enforced Package Isolation** — `solarlab` (core physics & solvers), `solarlab_server` (V2 HTTP/SSE job service & bundled SPA), and `solarlab_research` (`R1` codec & `CBO` scan CLIs) obey 12 machine-checked `import-linter` boundary contracts. +- **Enforced Package Isolation** — `solarlab` (core physics & solvers), `solarlab_server` (HTTP/SSE job service & bundled SPA), and `solarlab_research` (`R1` codec & `CBO` scan CLIs) obey 12 machine-checked `import-linter` boundary contracts. > [!NOTE] -> `devel` is the shared V2 engineering baseline (`solarlab==0.1.0`); `AIMC` is the separate research branch for microscopic aging models. For contributor rules and retired legacy provenance, see [DevelopmentGuide.md](docs/DevelopmentGuide.md) and [RetiredModelsV1.md](docs/RetiredModelsV1.md). +> `devel` is the shared engineering baseline (`solarlab==0.1.0`); `AIMC` is the separate research branch for microscopic aging models. For contributor rules and retired legacy provenance, see [DevelopmentGuide.md](docs/DevelopmentGuide.md) and [RetiredModelsV1.md](docs/RetiredModelsV1.md). --- ## 2. Architecture & Repository Layout

- SolarLab V2 simulation and provenance pipeline + SolarLab simulation and provenance pipeline

```text SolarLab/ ├── src/ │ ├── solarlab/ Core kernel: config, materials, mesh, physics, equations, solvers, experiments, io -│ ├── solarlab_server/ V2 FastAPI/SSE job service, RunStore routes, ProcessSupervisor, and SPA serving +│ ├── solarlab_server/ FastAPI/SSE job service, RunStore routes, ProcessSupervisor, and SPA serving │ └── solarlab_research/ Research companion CLIs (solarlab-cbo-scan, solarlab-r1-short-window, r1-verify-sources) -├── web/ Vite + TypeScript + Plotly + GoldenLayout V2 workstation frontend +├── web/ Vite + TypeScript + Plotly + GoldenLayout workstation frontend ├── examples/ │ ├── research_1d/ 23 runnable 1D steady, AC, transient, mobile-ion, optical, and HTTP/process workflows │ └── research_2d/ 10 runnable 2D steady, J-V, grain-boundary, contact, field-mobility, and optical workflows @@ -117,9 +117,9 @@ npm --prefix web run build .venv/bin/solarlab-r1-short-window --help ``` -### 3. Launch the V2 Web Workstation +### 3. Launch the Web Workstation -Start the V2 `solarlab-server` backend (serves `/configs`, `/materials`, `/experiments`, `/jobs`, `/runs/.../events`, `/results/...`, and compiled `web/dist` on port `8000`): +Start the `solarlab-server` backend (serves `/configs`, `/materials`, `/experiments`, `/jobs`, `/runs/.../events`, `/results/...`, and compiled `web/dist` on port `8000`): ```bash .venv/bin/solarlab-server --store-dir ./var/solarlab/store --host 127.0.0.1 --port 8000 @@ -165,7 +165,7 @@ All characterisation workflows compile from the same validated device declaratio ## 5. Governing Physics & Numerical Method

- Device stack, heterojunction band bending, and 2D grain mesh + Device stack, heterojunction band bending, and 2D grain mesh

### 1. Electrostatics & Contact Potentials @@ -210,7 +210,7 @@ Optical generation integrates absorbed photon flux exactly over each electrical ### 5. Unified Solver Matrix

- SolarLab V2 unified equation assembly and solver matrix + SolarLab unified equation assembly and solver matrix

--- @@ -219,21 +219,21 @@ Optical generation integrates absorbed photon flux exactly over each electrical SolarLab separates **engineering verification**, **external solver alignment**, and **formal continuum scientific certification** (`scientific_qualification = False` until all external reference and continuum-refinement gates are independently closed; see [reproducibility/README.md](reproducibility/README.md)). -### 1. SCAPS-1D 262-Case Steady-State Alignment (`ScapsComparisonContractV1`) +### 1. SCAPS-1D 262-Case Steady-State Alignment

- SCAPS-1D 262-case alignment summary + SCAPS-1D 262-case zero-fit alignment summary

-Evaluated from an isolated `solarlab==0.1.0` wheel across all **262** single- and two-parameter sweeps (`scaps_cbo`, `scaps_nt_cbo`, `scaps_nt_et`, bulk/interface $N_t$ & $E_t$, donor doping) using 7-level Gaussian interface quadrature, flat-band work-function $V_{\mathrm{bi}}$, and two-stage $5\text{ mV}$ $V_{\mathrm{mpp}}/V_{\mathrm{oc}}$ certification: -- **Convergence:** `262 / 262` cases converged (`0` solver failures). -- **Accuracy across 248 numeric reference points:** `233 / 248` (**`94.0%`**) satisfy $|\Delta V_{\mathrm{oc}}| \le 30\text{ mV}$; median $|\Delta V_{\mathrm{oc}}| = 12.7\text{ mV}$ (`P90 = 25.9 mV`), median $|\Delta\mathrm{FF}| = 0.53\%$, median $|\Delta\mathrm{PCE}| = 0.20\%$. -- **Residual diagnosis:** Independent zero-Auger radiative-limit ablation (`C_{n,p} = 0`) confirmed that the remaining $\sim 25\text{ mV}$ open-circuit plateau offset originates from an undocumented radiative-limit setting in the external partner's proprietary SCAPS project file + bundled `.spe` spectrum table (reducing `scaps_nt_cbo` median $|\Delta V_{\mathrm{oc}}|$ to `4.40 mV` and overall $|\Delta V_{\mathrm{oc}}| \le 20\text{ mV}$ coverage to `88.7%`). +Evaluated across all **262** single- and two-parameter sweeps (`scaps_cbo`, `scaps_nt_cbo`, `scaps_nt_et`, bulk/interface $N_t$ & $E_t$, donor doping) using the verbatim partner SCAPS 3.3.10 baseline (`scaps_pvk_xy` + [ScapsAm15g1Sun.spe](reproducibility/ScapsAm15g1Sun.spe), driven by [scaps_native_pvk_xy.py](scripts/benchmarks/scaps_native_pvk_xy.py)) with **zero empirical calibration factors** (`het_recomb_despike = 0`, no work-function offsets, no interface-state attenuation, 7-level Gaussian `PVK/ETL` quadrature, and recalculated flat-band contacts): +- **Convergence & Gate Closure:** `262 / 262` cases converged (`0` solver failures); **`221 / 248` (`89.1%`)** numeric reference points pass **all four** strict pointwise contract gates simultaneously ($V_{\mathrm{oc}}$: `236/248` [`95.2%`], $J_{\mathrm{sc}}$: `239/248` [`96.4%`], $\mathrm{FF}$: `221/248` [`89.1%`], $\mathrm{PCE}$: `235/248` [`94.8%`]), achieving `100%` pass across 11 of the 14 groups (including the full 56-case 2D `scaps_nt_et` grid). +- **Pointwise Accuracy:** Median $|\Delta V_{\mathrm{oc}}| = 0.60\text{ mV}$ (`P90 = 1.01 mV`, `96.0%` $\le 5\text{ mV}$), median $|\Delta J_{\mathrm{sc}}| = 0.0088\text{ mA cm}^{-2}$, median $|\Delta\mathrm{FF}| = 0.031\%$, and median $|\Delta\mathrm{PCE}| = 0.009\%$. +- **Boundary Regime Localization:** The remaining 27 tolerance-exceeding points localize to steep positive conduction-band spikes ($\Delta E_c \ge +0.30\text{ eV}$ in `scaps_cbo` / `scaps_nt_cbo`, plus high-doping $N_{D,\mathrm{PVK}} = 10^{18}\text{ cm}^{-3}$), where finite-difference mesh placement across the sub-nanometre heterointerface barrier governs S-curve knee sensitivity. -### 2. 45-Case Dynamic Mobile-Ion Hysteresis Benchmark (`HysteresisReferenceContractV2`) +### 2. 45-Case Dynamic Mobile-Ion Hysteresis Benchmark

- 45-case dynamic mobile-ion hysteresis benchmark summary + 45-case dynamic mobile-ion hysteresis benchmark summary

Evaluated across the **45-case** 7-stage preconditioning + forward/reverse scan matrix spanning 6 decades of ion diffusivity, mobile-ion density, and scan rate: @@ -250,7 +250,8 @@ Evaluated across the **45-case** 7-stage preconditioning + forward/reverse scan | Preset ID | Stack Topology | Mobile Ions | Optics | Primary Role | |:----------|:---------------|:-----------:|:------:|:-------------| | `classical_pin` | HTL / Absorber / ETL | No | Beer–Lambert | Default CLI & 1D/2D steady-state baseline | -| `scaps_mirror_v2` | Glass / Spiro-OMeTAD / $\mathrm{MAPbI_3}$ / $\mathrm{TiO_2}$ | No | TMM / Spectral BL | SCAPS-1D heterojunction & defect benchmark stack | +| `scaps_pvk_xy` | SAM / Perovskite / $\mathrm{C_{60}}$ | No | TMM / Spectral BL | Native zero-fit SCAPS-1D benchmark baseline (`PVK-xy.scaps`) | +| `scaps_mirror_v2` | Glass / Spiro-OMeTAD / $\mathrm{MAPbI_3}$ / $\mathrm{TiO_2}$ | No | TMM / Spectral BL | Historical PDF-table SCAPS contract stack | | `calado2016_ion_sweep` | HTL / Perovskite / ETL | Yes | Uniform / BL | Workstation dynamic ion-hysteresis waveform preset | | `calado2016_fig1f` | Calado 2016 SI Table 1 stack | Yes | Beer–Lambert | Literature scan-rate hysteresis comparison preset | diff --git a/docs/contracts/README.md b/docs/contracts/README.md index cdcb4428..607aa537 100644 --- a/docs/contracts/README.md +++ b/docs/contracts/README.md @@ -14,7 +14,7 @@ For cross-cutting solver architecture and extension rules, see [../DevelopmentGu | [InterfaceChargeClosurePolicy.md](InterfaceChargeClosurePolicy.md) | Equilibrium-referenced vs absolute interface sheet-charge Gauss closure | | [PhysicalInterfaceCboScan.md](PhysicalInterfaceCboScan.md) | Conduction-band offset ($\Delta E_c$) scan protocol and numerical contraction gates | | [WkbTunnellingFamilyContract.md](WkbTunnellingFamilyContract.md) | Nonlocal WKB barrier tunnelling constitutive family | -| [ResolvedIntrabandTunnellingContractV2.md](ResolvedIntrabandTunnellingContractV2.md) | Node-resolved intraband heterojunction tunnelling closure (V2) | +| [ResolvedIntrabandTunnellingContractV2.md](ResolvedIntrabandTunnellingContractV2.md) | Node-resolved intraband heterojunction tunnelling closure | ## 2. Bulk & Interface Defect Thermodynamics (DC, Transient & AC) diff --git a/docs/figures/ArchitectureFlow.png b/docs/figures/ArchitectureFlow.png new file mode 100644 index 00000000..6c4a7d70 Binary files /dev/null and b/docs/figures/ArchitectureFlow.png differ diff --git a/docs/figures/ArchitectureFlowV2.png b/docs/figures/ArchitectureFlowV2.png deleted file mode 100644 index 2787da4b..00000000 Binary files a/docs/figures/ArchitectureFlowV2.png and /dev/null differ diff --git a/docs/figures/DevicePhysicsOverviewV2.png b/docs/figures/DevicePhysicsOverview.png similarity index 100% rename from docs/figures/DevicePhysicsOverviewV2.png rename to docs/figures/DevicePhysicsOverview.png diff --git a/docs/figures/SolverTopology.png b/docs/figures/SolverTopology.png new file mode 100644 index 00000000..9b833403 Binary files /dev/null and b/docs/figures/SolverTopology.png differ diff --git a/docs/figures/SolverTopologyV2.png b/docs/figures/SolverTopologyV2.png deleted file mode 100644 index c9e4d470..00000000 Binary files a/docs/figures/SolverTopologyV2.png and /dev/null differ diff --git a/docs/figures/ValidationHysteresisOverview.png b/docs/figures/ValidationHysteresisOverview.png new file mode 100644 index 00000000..24445cbd Binary files /dev/null and b/docs/figures/ValidationHysteresisOverview.png differ diff --git a/docs/figures/ValidationHysteresisOverviewV2.png b/docs/figures/ValidationHysteresisOverviewV2.png deleted file mode 100644 index f24b1155..00000000 Binary files a/docs/figures/ValidationHysteresisOverviewV2.png and /dev/null differ diff --git a/docs/figures/ValidationScapsOverview.png b/docs/figures/ValidationScapsOverview.png new file mode 100644 index 00000000..26437a7e Binary files /dev/null and b/docs/figures/ValidationScapsOverview.png differ diff --git a/docs/figures/ValidationScapsOverviewV2.png b/docs/figures/ValidationScapsOverviewV2.png deleted file mode 100644 index cb61614a..00000000 Binary files a/docs/figures/ValidationScapsOverviewV2.png and /dev/null differ diff --git a/examples/research_1d/README.md b/examples/research_1d/README.md index ef8b9361..baa6705a 100644 --- a/examples/research_1d/README.md +++ b/examples/research_1d/README.md @@ -2,7 +2,7 @@ Runnable one-dimensional research examples exercising `solarlab`'s configuration compiler, unified sparse equation assembly, nonlinear/time/frequency-domain solvers, and lossless `RunStore` persistence. -For repository installation, V2 server startup, and governing PDEs, see the root [README.md](../../README.md) and [DevelopmentGuide.md](../../docs/DevelopmentGuide.md). Run all commands below from the repository root with single-thread BLAS: +For repository installation, server startup, and governing PDEs, see the root [README.md](../../README.md) and [DevelopmentGuide.md](../../docs/DevelopmentGuide.md). Run all commands below from the repository root with single-thread BLAS: ```sh export OMP_NUM_THREADS=1 OPENBLAS_NUM_THREADS=1 MKL_NUM_THREADS=1 diff --git a/reproducibility/README.md b/reproducibility/README.md index 9a090a3f..f9213e9f 100644 --- a/reproducibility/README.md +++ b/reproducibility/README.md @@ -1,6 +1,6 @@ # Reproducibility & Reference Contracts -This directory holds the **6 frozen machine-readable contracts and reference datasets** used by SolarLab's analytical gates, external benchmark harnesses (`scripts/benchmarks/`), and release-bundle validators (`solarlab.reproducibility.release`). +This directory holds the **7 frozen machine-readable contracts and reference datasets** used by SolarLab's analytical gates, external benchmark harnesses (`scripts/benchmarks/`), and release-bundle validators (`solarlab.reproducibility.release`). > [!IMPORTANT] > Engineering verification, external solver alignment, and formal scientific qualification are tracked separately (`scientific_qualification = False` unless every declared continuum and external reference gate is independently satisfied). Do not relax frozen thresholds or overwrite contract digests without a versioned contract bump. @@ -10,8 +10,9 @@ This directory holds the **6 frozen machine-readable contracts and reference dat | File | Role | Primary Consumers | |:-----|:-----|:------------------| | [AnalyticGatesV1.json](AnalyticGatesV1.json) | Closed-form analytical tolerances for electrostatics, Bernoulli/SG fluxes, Beer–Lambert/TMM photon conservation, and AC admittance | `tests/unit/`, `tests/refactor/test_release_bundle.py` | -| [ScapsComparisonContractV1.json](ScapsComparisonContractV1.json) | 262-case SCAPS-1D single- and two-parameter sweep definitions, coordinate grids, and reference comparison schema | `scripts/benchmarks/scaps_reference.py`, `scripts/benchmarks/p09_candidate_validation.py` | +| [ScapsComparisonContractV1.json](ScapsComparisonContractV1.json) | 262-case SCAPS-1D single- and two-parameter sweep definitions, coordinate grids, and reference comparison schema | `scripts/benchmarks/scaps_native_pvk_xy.py`, `scripts/benchmarks/scaps_reference.py`, `scripts/benchmarks/p09_candidate_validation.py` | | [ScapsParams.xlsx](ScapsParams.xlsx) | Original read-only 13-sheet SCAPS-1D partner parameter & reference metric workbook | `scripts/benchmarks/scaps_reference.py` | +| [ScapsAm15g1Sun.spe](ScapsAm15g1Sun.spe) | Native SCAPS 3.3.10 120-bin AM1.5G 1-sun incident power table (`305–4045 nm`, `1000 W/m²`) | `scripts/benchmarks/scaps_native_pvk_xy.py` | | [HysteresisReferenceContractV2.json](HysteresisReferenceContractV2.json) | 7-stage dynamic mobile-ion hysteresis protocol, 4-axis independent refinement hierarchy, and `1/3` reference-error / `bounded_failure` rules | `scripts/benchmarks/hysteresis_reference.py`, `tests/refactor/test_hysteresis_reference.py` | | [PerformanceCasesV1.json](PerformanceCasesV1.json) | Locked 1D/2D runtime & scaling benchmark cases (`TransientJvN80`, `TransientJvN200`, 2D sparse scaling) | `scripts/benchmarks/p09_candidate_validation.py`, `scripts/benchmarks/runtime_timing.py` | | [RefactorReferenceManifestV1.json](RefactorReferenceManifestV1.json) | Cryptographic provenance manifest pinning historical reference inputs and archival digests | `src/solarlab/reproducibility/`, `tests/refactor/` | @@ -20,8 +21,9 @@ This directory holds the **6 frozen machine-readable contracts and reference dat | Script | Purpose | |:-------|:--------| -| [../scripts/benchmarks/p09_candidate_validation.py](../scripts/benchmarks/p09_candidate_validation.py) | Isolated-wheel candidate validation across SCAPS 262, Hysteresis 45, and performance cases | -| [../scripts/benchmarks/scaps_reference.py](../scripts/benchmarks/scaps_reference.py) | Standalone SCAPS-1D 262-case suite runner & scorecard generator | +| [../scripts/benchmarks/scaps_native_pvk_xy.py](../scripts/benchmarks/scaps_native_pvk_xy.py) | Native zero-fit SCAPS-1D 262-case driver (`scaps_pvk_xy.yaml` + `ScapsAm15g1Sun.spe`, `89.1%` all-4-gate pass, median $\lvert\Delta V_{\mathrm{oc}}\rvert = 0.60\text{ mV}$) | +| [../scripts/benchmarks/p09_candidate_validation.py](../scripts/benchmarks/p09_candidate_validation.py) | Isolated-wheel candidate validation across historical `scaps_mirror_v2`, Hysteresis 45, and performance cases | +| [../scripts/benchmarks/scaps_reference.py](../scripts/benchmarks/scaps_reference.py) | Standalone historical SCAPS-1D (`scaps_mirror_v2`) 262-case suite runner & scorecard generator | | [../scripts/benchmarks/hysteresis_reference.py](../scripts/benchmarks/hysteresis_reference.py) | Decoupled 7-stage dynamic ion-hysteresis reference & 4-axis refinement driver | | [../scripts/benchmarks/hysteresis_current_bounds.py](../scripts/benchmarks/hysteresis_current_bounds.py) | Exact rational/interval terminal current & Gauss enclosure verifier on saved trajectories | | [../scripts/benchmarks/hysteresis_mobile_bounds.py](../scripts/benchmarks/hysteresis_mobile_bounds.py) | Semidiscrete mobile-ion inventory & flux bound verifier | diff --git a/reproducibility/ScapsAm15g1Sun.spe b/reproducibility/ScapsAm15g1Sun.spe new file mode 100644 index 00000000..f8d9218c --- /dev/null +++ b/reproducibility/ScapsAm15g1Sun.spe @@ -0,0 +1,136 @@ +> Air Mass 1.5 global spectrum, on a horizontal plane +> data from Hulstrom, Bird and Riordan, Solar Cells, vol 15, 365-391 (1985) +> also in cited in: Partain, Solar Cells and their applications, Wiley 1995, p. 532 +> first column is wavelength in nm +> second column, is incident power, in W/m2, +> in a wavelength range from half-away the preceeding lambda-interval +> to half-away the next lambda-interval +> april 2008: in contrast to earlier SCAPS sprectra: +> all the Hulström wavelengths are retained +> second order Simpson for the numerical integration (instead of first order = trapezium rule) +> the total incident power (summing the data in the second column) is 962.58 W/m2 +> in this table, the spectrum is normalised to 1 sun incident power (1000 W/m2) by multiplying the second column with 1000/962.58130 +> Up to SCAPS2.7: the original SCAPS spectra were called "AM...spe", and the spectra with the adaptions of april 2008: "New AM...spe" +> In SCAPS2.8: the original SCAPS spectra are still available as "old AM...spe"; and the spectra with the adaptions of april 2008 are called "AM...spe" +> +>lambda (nm) P(W/m2) +305.0 0.04800 +310.0 0.23238 +315.0 0.54450 +320.0 0.90135 +325.0 1.28742 +330.0 1.88289 +335.0 1.98457 +340.0 2.15306 +345.0 2.22299 +350.0 3.65008 +360.0 5.34591 +370.0 6.54581 +380.0 7.08628 +390.0 7.57170 +400.0 9.95916 +410.0 11.44670 +420.0 11.68187 +430.0 11.15997 +440.0 13.02812 +450.0 15.09041 +460.0 15.89996 +470.0 15.91177 +480.0 16.13227 +490.0 15.53414 +500.0 15.54154 +510.0 15.70997 +520.0 15.10392 +530.0 15.60647 +540.0 15.56661 +550.0 23.28738 +570.0 29.95176 +590.0 28.43396 +610.0 29.38973 +630.0 28.80925 +650.0 28.39838 +670.0 27.29172 +690.0 23.75072 +710.0 17.68235 +718.0 7.41233 +724.0 11.80100 +740.0 17.21923 +753.0 10.77465 +758.0 5.56304 +763.0 3.79513 +768.0 8.67959 +780.0 17.84488 +800.0 19.15106 +816.0 10.61303 +824.0 6.53929 +832.0 7.26152 +840.0 13.45886 +860.0 19.43966 +880.0 20.55956 +905.0 13.59171 +915.0 6.81306 +925.0 4.97575 +930.0 2.47678 +937.0 2.53067 +948.0 4.77279 +965.0 8.20990 +980.0 9.33587 +994.0 21.93074 +1040.0 26.39676 +1070.0 18.50298 +1100.0 10.41107 +1120.0 2.49641 +1130.0 1.45884 +1137.0 2.72242 +1161.0 6.96365 +1180.0 8.60153 +1200.0 12.00256 +1235.0 20.93583 +1290.0 17.42957 +1320.0 7.30847 +1350.0 1.86257 +1395.0 0.57198 +1443.0 1.69503 +1463.0 1.66614 +1477.0 1.98705 +1497.0 3.96003 +1520.0 5.31758 +1539.0 5.19100 +1558.0 5.29055 +1578.0 4.24367 +1592.0 3.91570 +1610.0 4.43194 +1630.0 4.34685 +1646.0 5.60431 +1678.0 10.05307 +1740.0 9.79486 +1800.0 2.66783 +1860.0 0.32569 +1920.0 0.16752 +1960.0 0.80785 +1985.0 1.67246 +2005.0 1.10419 +2035.0 2.56887 +2065.0 2.23780 +2100.0 3.53577 +2148.0 4.00654 +2198.0 4.42194 +2270.0 5.61576 +2360.0 5.22307 +2450.0 1.86556 +2494.0 0.73717 +2537.0 0.85958 +2941.0 0.90637 +2973.0 0.22564 +3005.0 0.25458 +3056.0 0.24642 +3132.0 0.29146 +3156.0 0.54884 +3204.0 0.17814 +3245.0 0.26120 +3317.0 0.52581 +3344.0 0.38099 +3450.0 1.36829 +3573.0 1.85006 +3765.0 2.27700 +4045.0 1.12998 diff --git a/scripts/benchmarks/scaps_native_pvk_xy.py b/scripts/benchmarks/scaps_native_pvk_xy.py new file mode 100644 index 00000000..5785e43e --- /dev/null +++ b/scripts/benchmarks/scaps_native_pvk_xy.py @@ -0,0 +1,531 @@ +"""Native zero-fit SCAPS-1D 262-case benchmark driver (PVK-xy.scaps + ScapsAm15g1Sun.spe). + +Evaluates the 262-case SCAPS-1D comparison matrix (1 base + 13 single/two-parameter +sweeps = 248 numeric reference points + 14 reference_missing points) using the +packaged ``scaps_pvk_xy.yaml`` zero-fit preset paired with the native SCAPS +120-bin AM1.5G spectrum (``reproducibility/ScapsAm15g1Sun.spe``) and SCAPS's +analytical ``sqrt(hv - Eg)`` layer absorption laws. + +Engineering alignment and formal scientific qualification remain explicitly +separated (``scientific_qualification = False``). +""" + +from __future__ import annotations + +import argparse +from concurrent.futures import ProcessPoolExecutor +from copy import deepcopy +from datetime import UTC, datetime +from decimal import Decimal +import hashlib +import json +import math +import multiprocessing +from pathlib import Path +import statistics +import sys +import time +from typing import Any + +import numpy as np +from numpy.typing import NDArray +from scipy.constants import c as SPEED_OF_LIGHT_M_S, e as ELEM_CHARGE_C, h as PLANCK_J_S +import yaml + +REPO_ROOT = Path(__file__).resolve().parents[2] +for _p in (str(REPO_ROOT / "src"), str(REPO_ROOT)): + if _p not in sys.path: + sys.path.insert(0, _p) + +from scripts.benchmarks.p09_candidate_validation import ( # noqa: E402 + MANIFEST_REL, + SCAPS_CONTRACT_REL, + SCAPS_CONTRACT_SHA256, + _decimal_ulp, + _file_sha256, + _host_environment_record, + _load_packaged_catalog_and_resources, + _loaded_forbidden_legacy_modules, + _prepare_scaps_yaml_device, + _run_scaps_steady_jv_aligned, +) +from solarlab.device.compile_1d import compile_device_1d # noqa: E402 +from solarlab.materials import load_packaged_preset_sources # noqa: E402 +from solarlab.materials.resources import ResourceLibrary, ResourceTable # noqa: E402 +from solarlab.materials.source import SourceDocument # noqa: E402 +from solarlab.mesh import PHYSICAL_BOUNDARY_TWO_SIDED_V1 # noqa: E402 +from solarlab.physics.interface_transport import ( # noqa: E402 + SCAPS_EFFECTIVE_VELOCITY_THERMIONIC_V1, +) +from solarlab.physics.recombination import ( # noqa: E402 + SCAPS_GAUSSIAN_INTERFACE_QUADRATURE, + SCAPS_INTERFACE_EXTREMA_ANCHOR, +) +from solarlab.solvers.nonlinear.steady_1d import SteadyOptions # noqa: E402 + +SCAPS_SPE_REL = "reproducibility/ScapsAm15g1Sun.spe" +SCAPS_SPE_SHA256 = "e357f1237fe82182e51b94426fe90bda2f248f7f1246084d42c46aad78cf03f2" + +# Scan coordinate mapping faithful to PVK-xy.scaps (Reference=3: above highest EV) +PVK_XY_RULES: dict[str, tuple[tuple[str, str, str, str, str], ...]] = { + "scaps_cbo": (("CBO", "layer", "SCAPS_ETL", "chi_eV", "eV"),), + "scaps_etl_donor": (("N_D", "layer", "SCAPS_ETL", "N_D_cm3", "cm^-3"),), + "scaps_pvk_donor": (("N_D", "layer", "SCAPS_PVK", "N_D_cm3", "cm^-3"),), + "scaps_nt_htl_pvk": (("Nt", "interface", "HTL/PVK", "N_t_cm2", "cm^-2"),), + "scaps_nt_pvk_cb": (("Nt", "bulk_defect", "Perovskite-CB", "N_t_cm3", "cm^-3"),), + "scaps_nt_pvk_vb": (("Nt", "bulk_defect", "Perovskite-VB", "N_t_cm3", "cm^-3"),), + "scaps_nt_pvk_etl": (("Nt", "interface", "PVK/ETL", "N_t_cm2", "cm^-2"),), + "scaps_et_htl_pvk": (("Et", "interface", "HTL/PVK", "E_t_eV_above_vb", "eV"),), + "scaps_et_pvk_cb": (("Et", "bulk_defect", "Perovskite-CB", "E_t_eV_below_cb", "eV"),), + "scaps_et_pvk_vb": (("Et", "bulk_defect", "Perovskite-VB", "E_t_eV_above_vb", "eV"),), + "scaps_et_pvk_etl": (("Et", "interface", "PVK/ETL", "E_t_eV_above_vb", "eV"),), + "scaps_nt_et": ( + ("Nt", "interface", "PVK/ETL", "N_t_cm2", "cm^-2"), + ("Et", "interface", "PVK/ETL", "E_t_eV_above_vb", "eV"), + ), + "scaps_nt_cbo": ( + ("Nt", "interface", "PVK/ETL", "N_t_cm2", "cm^-2"), + ("CBO", "layer", "SCAPS_ETL", "chi_eV", "eV"), + ), +} + +_NATIVE_OPTICAL_BY_LAYER: dict[str, str] = { + "SCAPS_HTL": "scaps_sam_sqrt", + "SCAPS_PVK": "scaps_pvk_sqrt", + "SCAPS_ETL": "scaps_c60_sqrt", +} + + +def load_native_pvk_xy_template() -> dict[str, Any]: + """Load packaged ``scaps_pvk_xy.yaml`` and bind native SCAPS sqrt(hv-Eg) optical keys.""" + src = next( + doc for doc in load_packaged_preset_sources() if doc.id == "scaps_pvk_xy.yaml" + ) + doc = yaml.safe_load(src.content.decode("utf-8")) + if not isinstance(doc, dict): + raise ValueError("scaps_pvk_xy.yaml must decode to a mapping") + for layer in doc["layers"]: + name = str(layer["name"]) + if name in _NATIVE_OPTICAL_BY_LAYER: + layer["optical_material"] = _NATIVE_OPTICAL_BY_LAYER[name] + return doc + + +def build_native_scaps_resources( + base_resources: ResourceLibrary, spe_path: Path +) -> ResourceLibrary: + """Build ResourceLibrary from ScapsAm15g1Sun.spe + SCAPS sqrt(hv - Eg) absorption.""" + if _file_sha256(spe_path) != SCAPS_SPE_SHA256: + raise RuntimeError(f"{spe_path} SHA-256 mismatch against pinned SCAPS .spe digest") + spe_lines = spe_path.read_text(encoding="latin-1").splitlines() + wls_nm_list: list[float] = [] + p_bin_list: list[float] = [] + for line in spe_lines: + stripped = line.strip() + if stripped and not stripped.startswith(">"): + wl_s, pw_s = stripped.split() + wls_nm_list.append(float(wl_s)) + p_bin_list.append(float(pw_s)) + wl_nm: NDArray[np.float64] = np.asarray(wls_nm_list, dtype=np.float64) + wl_m: NDArray[np.float64] = wl_nm * 1.0e-9 + p_w_m2: NDArray[np.float64] = np.asarray(p_bin_list, dtype=np.float64) + + # Exact dual trapezoid bin widths matching SCAPS .spe interval definition + w_m = np.empty_like(wl_m) + w_m[0] = 0.5 * (wl_m[1] - wl_m[0]) + w_m[1:-1] = 0.5 * (wl_m[2:] - wl_m[:-2]) + w_m[-1] = 0.5 * (wl_m[-1] - wl_m[-2]) + phi_per_m = (p_w_m2 * wl_m / (PLANCK_J_S * SPEED_OF_LIGHT_M_S)) / w_m + + spec_rows = ["wavelength_nm,spectral_flux_m-2_s-1_m-1"] + [ + f"{w:.6f},{fl:.14e}" for w, fl in zip(wl_nm, phi_per_m, strict=True) + ] + am15_spe_table = ResourceTable( + "am15g", + "spectrum", + SourceDocument("scaps://ScapsAm15g1Sun.spe", ("\n".join(spec_rows) + "\n").encode("utf-8")), + ) + + hv_eV = (PLANCK_J_S * SPEED_OF_LIGHT_M_S) / (ELEM_CHARGE_C * wl_m) + + def _nk(name: str, eg: float) -> ResourceTable: + alpha = np.where( + hv_eV > eg, + (1.0e7 / math.sqrt(eg)) * np.sqrt(np.maximum(hv_eV - eg, 0.0)), + 0.0, + ) + k_arr = alpha * wl_m / (4.0 * math.pi) + rows = ["wavelength_nm,n,k"] + [ + f"{w:.6f},1.0,{kv:.14e}" for w, kv in zip(wl_nm, k_arr, strict=True) + ] + return ResourceTable( + name, + "nk", + SourceDocument(f"scaps://{name}.csv", ("\n".join(rows) + "\n").encode("utf-8")), + ) + + tables = tuple( + am15_spe_table if (t.name == "am15g" and t.kind == "spectrum") else t + for t in base_resources.tables + ) + ( + _nk("scaps_sam_sqrt", 3.25), + _nk("scaps_pvk_sqrt", 1.53), + _nk("scaps_c60_sqrt", 1.90), + ) + return ResourceLibrary(tables) + + +def apply_case_updates( + template_doc: dict[str, Any], group_id: str, coordinates: list[Any] +) -> tuple[dict[str, Any], list[dict[str, Any]]]: + doc = deepcopy(template_doc) + if group_id == "scaps_base": + return doc, [] + rules = PVK_XY_RULES[group_id] + pvk = next(lay for lay in doc["layers"] if lay["name"] == "SCAPS_PVK") + chi_pvk = Decimal(str(pvk["chi_eV"])) + updates: list[dict[str, Any]] = [] + for (axis, kind, target_name, field_name, unit), raw_val in zip( + rules, coordinates, strict=True + ): + val = float(Decimal(str(chi_pvk - Decimal(str(raw_val)))) if axis == "CBO" else Decimal(str(raw_val))) + if kind == "layer": + layer = next(lay for lay in doc["layers"] if lay["name"] == target_name) + layer[field_name] = val + elif kind == "bulk_defect": + defect = next( + d + for lay in doc["layers"] + for d in lay.get("bulk_defects", ()) + if d.get("name") == target_name + ) + defect.pop("E_t_eV_below_cb", None) if field_name.startswith("E_t_") else None + defect.pop("E_t_eV_above_vb", None) if field_name.startswith("E_t_") else None + defect[field_name] = val + elif kind == "interface": + iface = next(it for it in doc["interfaces"] if it["target"] == target_name) + if field_name.startswith("E_t_"): + iface.pop("E_t_eV_below_cb", None) + iface.pop("E_t_eV_above_vb", None) + iface[field_name] = val + if field_name == "N_t_cm2" and iface.get("distribution") == "gaussian": + e_char = float(iface.get("E_char_eV", 0.10)) + iface["N_peak_cm3"] = float(val) / (math.sqrt(math.pi) * e_char) + updates.append( + {"axis": axis, "target": target_name, "field": field_name, "value": val, "unit": unit} + ) + return doc, updates + + +_WORKER_CTX: dict[str, Any] = {} + + +def _init_worker(spe_path_str: str) -> None: + defaults, base_res = _load_packaged_catalog_and_resources() + _WORKER_CTX["defaults"] = defaults + _WORKER_CTX["resources"] = build_native_scaps_resources(base_res, Path(spe_path_str)) + + +def _eval_case(task: dict[str, Any]) -> dict[str, Any]: + if not _WORKER_CTX: + _init_worker(str(REPO_ROOT / SCAPS_SPE_REL)) + defaults = _WORKER_CTX["defaults"] + resources = _WORKER_CTX["resources"] + cid = str(task["id"]) + gid = str(task["group_id"]) + coords = list(task["coordinates"]) + ref_status = str(task["reference_status"]) + ref_values = task["reference_values"] + gates_spec = task["pointwise_gates"] + res_floors = task["resolution_floor"] + + t0 = time.perf_counter() + doc, updates = apply_case_updates(task["template_doc"], gid, coords) + yb = yaml.safe_dump(doc, sort_keys=False).encode("utf-8") + eff_sha = hashlib.sha256(yb).hexdigest() + prepared = _prepare_scaps_yaml_device( + yb, + source_id=f"scaps_pvk_xy://{cid}", + device_id=cid.replace(":", "_"), + defaults=defaults, + resources=resources, + ) + opts = SteadyOptions( + continuity_tolerance_A_m2=1.0e-4, + current_spread_tolerance_A_m2=1.0e-4, + ) + is_high_cbo = ( + gid in ("scaps_cbo", "scaps_nt_cbo") + and len(coords) >= 1 + and float(coords[-1]) >= 0.39 + ) + ladder = ( + (15, 10, 8) + if (is_high_cbo and float(coords[-1]) <= 0.41) + else ((10, 8, 6) if is_high_cbo else (25, 15, 10)) + ) + + cand_metrics: dict[str, float | None] | None = None + solver_error: str | None = None + evaluated_points = 0 + compiled_id: str | None = None + route = "none" + for n_int in ladder: + try: + comp = compile_device_1d( + prepared, + intervals_per_layer=n_int, + interface_topology="two_sided_trace", + geometry_name=PHYSICAL_BOUNDARY_TWO_SIDED_V1, + thermionic_mode=SCAPS_EFFECTIVE_VELOCITY_THERMIONIC_V1, + interface_band_reference_mode=SCAPS_INTERFACE_EXTREMA_ANCHOR, + interface_defect_distribution_mode=SCAPS_GAUSSIAN_INTERFACE_QUADRATURE, + optical_model="beer_lambert_spectral", + allow_legacy_benchmark_deck=True, + ) + m, evaluated_points = _run_scaps_steady_jv_aligned( + comp, np.linspace(0.0, 1.45, 37), opts + ) + cand_metrics = { + "Voc_V": m.open_circuit_voltage_V, + "Jsc_mA_cm2": float(m.short_circuit_current_A_m2) * 0.1, + "FF_percent": float(m.fill_factor) * 100.0, + "PCE_percent": float(m.efficiency) * 100.0, + } + compiled_id = comp.identity + route = f"n{n_int}" + solver_error = None + break + except Exception as exc: + solver_error = f"{type(exc).__name__}: {exc}" + + elapsed_s = time.perf_counter() - t0 + metric_comparisons: dict[str, Any] = {} + if ref_status == "reference_missing" or ref_values is None: + disposition = "reference_missing" + elif solver_error is not None or cand_metrics is None: + disposition = "solver_failed" + else: + all_passed = True + for q_name, g_rule in gates_spec.items(): + ref_v = float(ref_values[q_name]) + cand_raw = cand_metrics[q_name] + assert cand_raw is not None + cand_v = float(cand_raw) + u_rep = _decimal_ulp(ref_v, float(res_floors.get(q_name, 1.0e-6))) + allowance = float(g_rule["atol"]) + float(g_rule["rtol"]) * abs(ref_v) + u_rep + diff = abs(cand_v - ref_v) + passed = bool(diff <= allowance) + all_passed = all_passed and passed + metric_comparisons[q_name] = { + "candidate": cand_v, + "reference": ref_v, + "signed_diff": cand_v - ref_v, + "abs_diff": diff, + "u_report": u_rep, + "allowance": allowance, + "passed": passed, + } + disposition = ( + "passed_external_gate" if all_passed else "exceeded_external_tolerance" + ) + + return { + "id": cid, + "group_id": gid, + "coordinates": coords, + "reference_status": ref_status, + "disposition": disposition, + "continuation_route": route, + "effective_yaml_sha256": eff_sha, + "compiled_identity": compiled_id, + "evaluated_bias_points": evaluated_points, + "elapsed_s": elapsed_s, + "updates": updates, + "candidate_metrics": cand_metrics, + "reference_metrics": ref_values, + "metric_comparisons": metric_comparisons, + "error": solver_error, + } + + +def main(argv: list[str] | None = None) -> int: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument( + "--output", + type=Path, + default=REPO_ROOT / "outputs" / "scaps_native_pvk_xy_262.json", + help="Destination JSON path for full per-case scorecard.", + ) + parser.add_argument("--workers", type=int, default=4) + parser.add_argument("--max-cases", type=int, default=None) + args = parser.parse_args(argv) + + contract_path = REPO_ROOT / SCAPS_CONTRACT_REL + if _file_sha256(contract_path) != SCAPS_CONTRACT_SHA256: + raise RuntimeError("ScapsComparisonContractV1.json SHA-256 mismatch") + contract = json.loads(contract_path.read_text(encoding="utf-8")) + manifest_path = REPO_ROOT / MANIFEST_REL + manifest = json.loads(manifest_path.read_text(encoding="utf-8")) + spe_path = REPO_ROOT / SCAPS_SPE_REL + + template_doc = load_native_pvk_xy_template() + floors_by_group = { + row["group_id"]: dict(row["reported_column_resolution_floor"]) + for row in contract["reported_precision"]["per_group"] + } + floors_by_group["scaps_base"] = { + "Voc_V": 1.0e-4, + "Jsc_mA_cm2": 1.0e-6, + "FF_percent": 1.0e-2, + "PCE_percent": 1.0e-2, + } + + tasks: list[dict[str, Any]] = [ + { + "id": "scaps_base", + "group_id": "scaps_base", + "coordinates": [], + "reference_status": "reported_rounded_base", + "reference_values": dict(manifest["scaps"]["base"]["values"]), + "template_doc": template_doc, + "pointwise_gates": contract["pointwise_gates"], + "resolution_floor": floors_by_group["scaps_base"], + } + ] + for grp in manifest["scaps"]["groups"]: + gid = str(grp["id"]) + for pt in grp["points"]: + tasks.append( + { + "id": f"{gid}:row{pt['worksheet_row']}", + "group_id": gid, + "coordinates": list(pt["coordinates"]), + "reference_status": pt["status"], + "reference_values": pt.get("values"), + "template_doc": template_doc, + "pointwise_gates": contract["pointwise_gates"], + "resolution_floor": floors_by_group[gid], + } + ) + if args.max_cases is not None: + tasks = tasks[: args.max_cases] + + t0 = time.perf_counter() + if args.workers <= 1: + _init_worker(str(spe_path)) + rows = [_eval_case(t) for t in tasks] + else: + ctx = multiprocessing.get_context("spawn") + with ProcessPoolExecutor( + max_workers=args.workers, + mp_context=ctx, + initializer=_init_worker, + initargs=(str(spe_path),), + ) as pool: + rows = list(pool.map(_eval_case, tasks)) + wall_s = time.perf_counter() - t0 + + if _loaded_forbidden_legacy_modules(): + raise RuntimeError("Forbidden legacy module imported") + + numeric_rows = [ + r + for r in rows + if r["reference_status"] != "reference_missing" + and r["disposition"] != "solver_failed" + ] + voc_diffs_mV = [ + 1000.0 * r["metric_comparisons"]["Voc_V"]["abs_diff"] for r in numeric_rows + ] + jsc_diffs = [ + r["metric_comparisons"]["Jsc_mA_cm2"]["abs_diff"] for r in numeric_rows + ] + ff_diffs = [r["metric_comparisons"]["FF_percent"]["abs_diff"] for r in numeric_rows] + pce_diffs = [ + r["metric_comparisons"]["PCE_percent"]["abs_diff"] for r in numeric_rows + ] + + def _pct(vals: list[float], q: float) -> float: + if not vals: + return 0.0 + s = sorted(vals) + idx = min(len(s) - 1, max(0, math.ceil(q * len(s)) - 1)) + return float(s[idx]) + + counts = { + "total_executed": len(rows), + "numeric_evaluated": len(numeric_rows), + "passed_external_gate": sum( + 1 for r in rows if r["disposition"] == "passed_external_gate" + ), + "exceeded_external_tolerance": sum( + 1 for r in rows if r["disposition"] == "exceeded_external_tolerance" + ), + "reference_missing": sum( + 1 for r in rows if r["disposition"] == "reference_missing" + ), + "solver_failed": sum(1 for r in rows if r["disposition"] == "solver_failed"), + "per_metric_passed": { + q: sum(1 for r in numeric_rows if r["metric_comparisons"][q]["passed"]) + for q in ("Voc_V", "Jsc_mA_cm2", "FF_percent", "PCE_percent") + }, + "voc_error_buckets": { + "le_1mV": sum(1 for v in voc_diffs_mV if v <= 1.0), + "le_2mV": sum(1 for v in voc_diffs_mV if v <= 2.0), + "le_5mV": sum(1 for v in voc_diffs_mV if v <= 5.0), + "le_10mV": sum(1 for v in voc_diffs_mV if v <= 10.0), + "le_20mV": sum(1 for v in voc_diffs_mV if v <= 20.0), + "le_30mV": sum(1 for v in voc_diffs_mV if v <= 30.0), + }, + "error_quantiles": { + "Voc_mV": { + "median": statistics.median(voc_diffs_mV) if voc_diffs_mV else 0.0, + "p90": _pct(voc_diffs_mV, 0.90), + "max": max(voc_diffs_mV, default=0.0), + }, + "Jsc_mA_cm2": { + "median": statistics.median(jsc_diffs) if jsc_diffs else 0.0, + "p90": _pct(jsc_diffs, 0.90), + "max": max(jsc_diffs, default=0.0), + }, + "FF_pct": { + "median": statistics.median(ff_diffs) if ff_diffs else 0.0, + "p90": _pct(ff_diffs, 0.90), + "max": max(ff_diffs, default=0.0), + }, + "PCE_pct": { + "median": statistics.median(pce_diffs) if pce_diffs else 0.0, + "p90": _pct(pce_diffs, 0.90), + "max": max(pce_diffs, default=0.0), + }, + }, + } + + payload = { + "schema": "solarlab.scaps_native_pvk_xy_alignment.v1", + "generated_at": datetime.now(UTC).isoformat(), + "run_role": "native_zero_fit_scaps_alignment", + "scientific_qualification": False, + "physical_certificate_status": "not_evaluated", + "source_provenance": { + "preset_id": "scaps_pvk_xy.yaml", + "am15g_spe_rel": SCAPS_SPE_REL, + "am15g_spe_sha256": _file_sha256(spe_path), + "scaps_contract_sha256": SCAPS_CONTRACT_SHA256, + "manifest_sha256": _file_sha256(manifest_path), + "zero_empirical_calibration_factors": True, + }, + "wall_elapsed_s": wall_s, + "environment": _host_environment_record(False), + "summary_counts": counts, + "cases": rows, + } + args.output.parent.mkdir(parents=True, exist_ok=True) + args.output.write_text(json.dumps(payload, indent=2) + "\n", encoding="utf-8") + print(json.dumps({"summary_counts": counts, "wall_s": round(wall_s, 2)}, indent=2)) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/scripts/generate_readme_figures.py b/scripts/generate_readme_figures.py index e2a8ad74..5f79f42a 100644 --- a/scripts/generate_readme_figures.py +++ b/scripts/generate_readme_figures.py @@ -1,9 +1,9 @@ -"""Generate the V2 SolarLab README figures in strict native Arial typography. +"""Generate the SolarLab README figures in strict native Arial typography. Every figure renders at 300 DPI using genuine Arial (Regular, Bold, Italic, and custom Arial mathtext) with zero DejaVu/Computer-Modern fallback. Validation -series come from the verified V2 benchmark baselines: - - scaps_full_262.json (sha256: ebc97099e0bfff07..., 262/262 converged) +series come from the verified benchmark baselines: + - scaps_pvk_xy_spe_full_262.json (sha256: a77bec53bbfc51d3..., 262/262 converged) - hysteresis_full_45.json (sha256: 9cbc22b7f955a2bd..., 45/45 completed) """ @@ -19,6 +19,7 @@ import matplotlib.font_manager as fm # noqa: E402 import matplotlib.pyplot as plt # noqa: E402 from matplotlib.patches import FancyArrowPatch, FancyBboxPatch, Rectangle # noqa: E402 +from matplotlib.ticker import NullFormatter, ScalarFormatter # noqa: E402 import numpy as np # noqa: E402 @@ -77,21 +78,21 @@ def configure_strict_arial() -> None: ) -# Verified V2 benchmark arrays (scaps_full_262: ebc97099..., hysteresis_full_45: 9cbc22b7...) +# Verified benchmark arrays (scaps_pvk_xy_spe_full_262: a77bec53..., hysteresis_full_45: 9cbc22b7...) BENCHMARK_DATA: dict[str, Any] = { "scaps_cbo": { "x": [-1.0, -0.75, -0.5, -0.25, -0.2, -0.16, -0.1, -0.05, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5], "sl_voc": [ - 0.40965, 0.5949, 0.8435, 1.09308, 1.1417, 1.1772, 1.21152, - 1.22169, 1.22453, 1.22519, 1.22479, 1.22436, 1.22291, 1.1988, + 0.3327, 0.58123, 0.83122, 1.08077, 1.12974, 1.16805, 1.21776, + 1.24049, 1.2487, 1.25138, 1.25112, 1.25068, 1.24956, 1.23269, ], "ref_voc": [ 0.33235, 0.58095, 0.83085, 1.08049, 1.12931, 1.16755, 1.2172, 1.24004, 1.2477, 1.25039, 1.25016, 1.24994, 1.24884, 1.22832, ], "sl_pce": [ - 7.7913, 12.0835, 18.1971, 24.4467, 25.6948, 26.6634, 27.9234, - 28.5187, 28.7147, 28.7561, 28.7249, 28.4147, 11.2441, 0.3175, + 5.8563, 11.8335, 18.0781, 24.4183, 25.6913, 26.7016, 28.1567, + 29.1276, 29.6316, 29.8142, 29.8, 29.6948, 22.5243, 1.5126, ], "ref_pce": [ 5.8685, 11.8314, 18.0802, 24.4188, 25.6782, 26.6926, 28.1546, @@ -100,42 +101,40 @@ def configure_strict_arial() -> None: }, "scaps_nt_pvk_etl": { "x": [1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15], - "sl_voc": [1.22517, 1.2246, 1.21911, 1.1772, 1.10095, 1.0336, 0.97169], + "sl_voc": [1.25044, 1.24922, 1.23632, 1.16805, 1.08912, 1.0234, 0.96852], "ref_voc": [1.24947, 1.24825, 1.23572, 1.16755, 1.08851, 1.02281, 0.96776], }, "scaps_nt_pvk_cb": { "x": [1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15], - "sl_voc": [1.17729, 1.17729, 1.17728, 1.1772, 1.1764, 1.16979, 1.14117], + "sl_voc": [1.16815, 1.16814, 1.16814, 1.16805, 1.16715, 1.15996, 1.12982], "ref_voc": [1.16765, 1.16765, 1.16764, 1.16755, 1.16668, 1.15956, 1.12908], }, "scaps_dvoc_mv": [ - 0.636, 0.9696, 1.0633, 2.2133, 2.7749, 3.1657, 3.1933, 3.599, 3.7288, 3.9384, - 3.9384, 4.0324, 4.0327, 4.0446, 4.0765, 4.0794, 4.1333, 4.3167, 4.5222, 4.5984, - 5.6842, 5.6852, 6.1656, 7.0217, 7.2574, 7.452, 7.736, 8.0484, 8.0597, 8.1132, - 8.2021, 8.2233, 8.9808, 9.0577, 9.0587, 9.1962, 9.1962, 9.1962, 9.1988, 9.2516, - 9.2768, 9.2792, 9.2792, 9.2792, 9.3106, 9.5135, 9.6021, 9.6152, 9.6221, 9.6341, - 9.6341, 9.6343, 9.6373, 9.6375, 9.6384, 9.6389, 9.6428, 9.6511, 9.6511, 9.6521, - 9.6521, 9.6521, 9.6521, 9.6521, 9.6521, 9.6521, 9.6521, 9.6521, 9.6521, 9.6521, - 9.6522, 9.6544, 9.66, 9.6646, 9.6666, 9.6676, 9.6678, 9.7081, 9.7081, 9.7082, - 9.7082, 9.7108, 9.7117, 9.7127, 9.7149, 9.7194, 9.7198, 9.7215, 9.7223, 9.8292, - 9.8302, 10.226, 10.4936, 10.5953, 10.6835, 10.7157, 10.7837, 10.7837, 10.8927, - 10.893, 10.9048, 10.9139, 11.008, 11.0506, 11.1615, 11.1682, 11.1689, 11.1967, - 11.1967, 11.2877, 11.6699, 12.0908, 12.3882, 12.3892, 12.4351, 12.4351, 12.5321, - 12.5323, 12.5413, 12.5869, 12.5878, 12.5879, 12.5931, 12.6525, 12.6535, 12.7466, - 12.7572, 12.9126, 13.293, 13.5843, 13.949, 13.95, 14.4639, 14.4649, 14.5176, - 14.873, 15.0496, 15.5684, 15.5684, 15.6392, 16.1658, 16.3256, 16.4677, 16.5888, - 16.6007, 16.6013, 16.6013, 16.6103, 16.6103, 16.6669, 16.8898, 17.6904, 18.305, - 18.3528, 18.3528, 19.357, 19.7762, 20.9241, 21.963, 22.1006, 22.5188, 22.5429, - 22.6416, 22.8942, 22.9442, 23.1623, 23.1623, 23.5934, 23.6379, 23.6461, 23.6543, - 23.6554, 23.6554, 23.6554, 23.6564, 23.6564, 23.6885, 23.8528, 23.8865, 24.1335, - 24.2194, 24.3042, 24.3043, 24.3055, 24.3057, 24.3057, 24.3057, 24.3057, 24.3057, - 24.3084, 24.3249, 24.4834, 24.4846, 24.6788, 24.8509, 24.9136, 24.9339, 24.9712, - 25.0522, 25.118, 25.1363, 25.2002, 25.2002, 25.3698, 25.37, 25.37, 25.3875, - 25.3886, 25.4104, 25.4146, 25.4154, 25.4216, 25.5732, 25.5732, 25.5875, 25.5889, - 25.5899, 25.7087, 25.7106, 25.7258, 25.7324, 25.7886, 25.931, 25.931, 26.4155, - 27.061, 27.324, 27.6512, 28.0125, 28.493, 29.4777, 29.5267, 29.5267, 31.0909, - 31.7394, 32.8765, 40.4365, 46.1003, 48.5775, 51.7165, 57.4864, 62.7635, 75.4636, - 77.2989, 77.2999, 83.0609, 83.904, 87.1866, + 0.018, 0.0845, 0.133, 0.1414, 0.2235, 0.2786, 0.2788, 0.2796, 0.2798, 0.3204, + 0.3214, 0.3487, 0.3497, 0.3555, 0.3659, 0.3669, 0.3765, 0.387, 0.3888, 0.3982, + 0.4019, 0.4072, 0.4075, 0.4149, 0.4238, 0.4302, 0.4312, 0.4482, 0.4482, 0.4512, + 0.4537, 0.4578, 0.4679, 0.4711, 0.4783, 0.4826, 0.4826, 0.4827, 0.4828, 0.4857, + 0.4857, 0.486, 0.486, 0.486, 0.4872, 0.4892, 0.4893, 0.4958, 0.4966, 0.4968, + 0.4968, 0.4973, 0.4976, 0.4981, 0.4981, 0.4981, 0.4981, 0.4982, 0.4986, 0.4999, + 0.5002, 0.5002, 0.5002, 0.5003, 0.5007, 0.5008, 0.5008, 0.5009, 0.5009, 0.5011, + 0.5011, 0.5012, 0.5012, 0.5012, 0.5012, 0.5012, 0.5012, 0.5012, 0.5012, 0.5012, + 0.5012, 0.5012, 0.5012, 0.5012, 0.5012, 0.5012, 0.5013, 0.5013, 0.5015, 0.5017, + 0.5017, 0.5021, 0.5045, 0.5075, 0.5083, 0.5139, 0.5146, 0.5172, 0.5172, 0.521, + 0.5361, 0.5444, 0.5574, 0.5584, 0.5658, 0.5707, 0.571, 0.5825, 0.5853, 0.5915, + 0.5915, 0.5916, 0.5917, 0.5926, 0.5926, 0.5926, 0.5939, 0.5969, 0.6016, 0.6016, + 0.6016, 0.602, 0.6026, 0.6026, 0.6028, 0.604, 0.604, 0.604, 0.6043, 0.6072, + 0.6073, 0.6079, 0.6082, 0.609, 0.6145, 0.631, 0.6391, 0.6567, 0.6576, 0.6584, + 0.6636, 0.6736, 0.678, 0.6784, 0.679, 0.6881, 0.6887, 0.707, 0.7193, 0.7193, + 0.7223, 0.741, 0.746, 0.746, 0.7463, 0.7463, 0.7467, 0.7469, 0.7488, 0.7533, + 0.7535, 0.7622, 0.7622, 0.7622, 0.7637, 0.765, 0.7651, 0.7658, 0.7744, 0.7768, + 0.7774, 0.7935, 0.7937, 0.8171, 0.8171, 0.8458, 0.854, 0.8547, 0.8905, 0.9059, + 0.9282, 0.9408, 0.9434, 0.9557, 0.9604, 0.9608, 0.9613, 0.9625, 0.9625, 0.9647, + 0.9661, 0.9662, 0.9664, 0.9703, 0.9703, 0.9703, 0.9706, 0.9706, 0.9706, 0.9707, + 0.9709, 0.971, 0.9711, 0.9713, 0.9713, 0.9714, 0.9714, 0.9714, 0.9714, 0.9726, + 0.9737, 0.9738, 0.9808, 0.9812, 0.9856, 0.9856, 0.9943, 1.0024, 1.0024, 1.0041, + 1.005, 1.0057, 1.0065, 1.0092, 1.0136, 1.0207, 1.0277, 1.028, 1.03, 1.0316, + 1.1276, 1.3703, 1.3759, 1.3839, 1.4258, 1.4595, 4.3605, 4.3605, 5.105, 5.141, + 5.1466, 9.3974, 12.1782, 12.8419, 14.2088, 16.2183, 16.2691, 48.7746, ], "hyst_diffusivity": { "x": [round(0.1 * i, 1) for i in range(21)], @@ -314,7 +313,7 @@ def _clean_axes(ax: plt.Axes) -> None: def generate_architecture_flow() -> Path: - """1. ArchitectureFlowV2.png: End-to-end V2 dataflow and package boundaries.""" + """1. ArchitectureFlow.png: End-to-end dataflow and package boundaries.""" fig, ax = plt.subplots(figsize=(13.6, 4.4), dpi=DPI) ax.set_xlim(0.0, 1.0) ax.set_ylim(0.0, 1.0) @@ -324,7 +323,7 @@ def generate_architecture_flow() -> Path: ax.text( 0.02, 0.93, - "SolarLab V2 End-to-End Simulation & Provenance Pipeline", + "SolarLab End-to-End Simulation & Provenance Pipeline", fontsize=13.5, fontweight="bold", color=C_INK, @@ -429,7 +428,7 @@ def generate_architecture_flow() -> Path: pkg_specs = [ (0.035, 0.335, "src/solarlab · Core Physics, Mesh, Assembler & Solvers", C_BLUE), - (0.385, 0.315, "src/solarlab_server · V2 HTTP/SSE API & SPA", C_TEAL), + (0.385, 0.315, "src/solarlab_server · HTTP/SSE API & SPA", C_TEAL), (0.715, 0.250, "src/solarlab_research · R1 & CBO CLIs", C_PURPLE), ] for px, pw, label, col in pkg_specs: @@ -445,14 +444,14 @@ def generate_architecture_flow() -> Path: va="center", ) - out = OUT_DIR / "ArchitectureFlowV2.png" + out = OUT_DIR / "ArchitectureFlow.png" fig.savefig(out, dpi=DPI, bbox_inches="tight", pad_inches=0.12, facecolor="white") plt.close(fig) return out def generate_device_physics_overview() -> Path: - """2. DevicePhysicsOverviewV2.png: 1D stack/contacts, band diagram, and 2D grain mesh.""" + """2. DevicePhysicsOverview.png: 1D stack/contacts, band diagram, and 2D grain mesh.""" fig = plt.figure(figsize=(13.8, 4.7), dpi=DPI, facecolor="white") gs = fig.add_gridspec(1, 3, width_ratios=[1.08, 1.15, 0.97], wspace=0.20) @@ -557,15 +556,12 @@ def generate_device_physics_overview() -> Path: ax_c.text(0.0, 0.96, "(c) 2D Grain & Ion Mesh ($N_y$ × $N_x$)", fontsize=11.5, fontweight="bold", color=C_INK) mx0, my0, mw, mh = 0.10, 0.35, 0.80, 0.49 - # Background layer bands in 2D mesh ax_c.add_patch(Rectangle((mx0, my0 + 0.37), mw, 0.12, facecolor="#DBEAFE", edgecolor="none")) ax_c.add_patch(Rectangle((mx0, my0 + 0.12), mw, 0.25, facecolor="#FEF3C7", edgecolor="none")) ax_c.add_patch(Rectangle((mx0, my0), mw, 0.12, facecolor="#CCFBF1", edgecolor="none")) - # Vertical grain-boundary strip inside absorber ax_c.add_patch( Rectangle((mx0 + 0.35, my0 + 0.12), 0.10, 0.25, facecolor="#FCA5A5", alpha=0.85, edgecolor=C_CORAL, lw=1.1) ) - # Grid lines for gx in np.linspace(mx0, mx0 + mw, 7): ax_c.plot([gx, gx], [my0, my0 + mh], color="#94A3B8", lw=0.75) for gy in np.linspace(my0, my0 + mh, 7): @@ -599,14 +595,14 @@ def generate_device_physics_overview() -> Path: linespacing=1.38, ) - out = OUT_DIR / "DevicePhysicsOverviewV2.png" + out = OUT_DIR / "DevicePhysicsOverview.png" fig.savefig(out, dpi=DPI, bbox_inches="tight", pad_inches=0.12, facecolor="white") plt.close(fig) return out def generate_solver_topology() -> Path: - """3. SolverTopologyV2.png: Active V2 solver matrix, unknowns, and certificates.""" + """3. SolverTopology.png: Unified solver matrix, unknowns, and certificates.""" fig, ax = plt.subplots(figsize=(13.6, 5.2), dpi=DPI) ax.set_xlim(0.0, 1.0) ax.set_ylim(0.0, 1.0) @@ -616,7 +612,7 @@ def generate_solver_topology() -> Path: ax.text( 0.02, 0.945, - "SolarLab V2 Unified Equation Assembly & Solver Matrix", + "SolarLab Unified Equation Assembly & Solver Matrix", fontsize=13.5, fontweight="bold", color=C_INK, @@ -713,23 +709,23 @@ def generate_solver_topology() -> Path: linespacing=1.35, ) - out = OUT_DIR / "SolverTopologyV2.png" + out = OUT_DIR / "SolverTopology.png" fig.savefig(out, dpi=DPI, bbox_inches="tight", pad_inches=0.12, facecolor="white") plt.close(fig) return out def generate_validation_scaps() -> Path: - """4. ValidationScapsOverviewV2.png: Verified 262-case SCAPS-1D alignment summary.""" + """4. ValidationScapsOverview.png: Native zero-fit 262-case SCAPS-1D alignment summary.""" fig = plt.figure(figsize=(13.8, 4.5), dpi=DPI, facecolor="white") - gs = fig.add_gridspec(1, 3, width_ratios=[1.05, 1.05, 1.0], wspace=0.25) + gs = fig.add_gridspec(1, 3, width_ratios=[1.05, 1.05, 1.02], wspace=0.25) # (a) CBO sweep (Voc) ax_a = fig.add_subplot(gs[0, 0]) _clean_axes(ax_a) cbo = BENCHMARK_DATA["scaps_cbo"] - ax_a.plot(cbo["x"], cbo["ref_voc"], "s--", color=C_INK, ms=5.0, lw=1.5, label="SCAPS-1D $V_{\\mathrm{oc}}$") - ax_a.plot(cbo["x"], cbo["sl_voc"], "o-", color=C_BLUE, ms=5.0, lw=2.0, label="SolarLab V2 $V_{\\mathrm{oc}}$") + ax_a.plot(cbo["x"], cbo["ref_voc"], "s--", color=C_INK, ms=5.6, lw=1.6, label="SCAPS-1D $V_{\\mathrm{oc}}$") + ax_a.plot(cbo["x"], cbo["sl_voc"], "o-", color=C_BLUE, ms=4.2, lw=1.9, label="SolarLab $V_{\\mathrm{oc}}$") ax_a.set_xlabel("Conduction-Band Offset Δ$E_{\\mathrm{c}}$ (eV)") ax_a.set_ylabel("Open-Circuit Voltage $V_{\\mathrm{oc}}$ (V)", color=C_INK) ax_a.set_xlim(-1.05, 0.55) @@ -738,10 +734,11 @@ def generate_validation_scaps() -> Path: ax_a.legend(loc="lower right", frameon=True, facecolor="white", edgecolor=C_LINE, fontsize=8.8) ax_a.text( -0.98, - 1.24, - "Cliff & spike trend aligned\nacross [−1.0, +0.5] eV", + 1.20, + "Native zero-fit parity\nMed |Δ$V_{\\mathrm{oc}}$| = 0.53 mV", fontsize=8.6, color=C_MUTED, + linespacing=1.35, bbox={"boxstyle": "round,pad=0.3", "facecolor": C_BG_SLATE, "edgecolor": C_LINE}, ) @@ -750,52 +747,72 @@ def generate_validation_scaps() -> Path: _clean_axes(ax_b) nt_if = BENCHMARK_DATA["scaps_nt_pvk_etl"] nt_bk = BENCHMARK_DATA["scaps_nt_pvk_cb"] - ax_b.semilogx(nt_if["x"], nt_if["ref_voc"], "s--", color=C_INK, ms=4.8, lw=1.4, label="SCAPS PVK/ETL $N_{\\mathrm{t}}$") - ax_b.semilogx(nt_if["x"], nt_if["sl_voc"], "o-", color=C_TEAL, ms=5.0, lw=2.0, label="SolarLab PVK/ETL $N_{\\mathrm{t}}$") - ax_b.semilogx(nt_bk["x"], nt_bk["ref_voc"], "^--", color=C_MUTED, ms=4.8, lw=1.3, label="SCAPS Bulk $N_{\\mathrm{t}}$") - ax_b.semilogx(nt_bk["x"], nt_bk["sl_voc"], "d-", color=C_AMBER, ms=5.0, lw=1.9, label="SolarLab Bulk $N_{\\mathrm{t}}$") + ax_b.semilogx(nt_if["x"], nt_if["ref_voc"], "s--", color=C_INK, ms=5.6, lw=1.5, label="SCAPS PVK/ETL $N_{\\mathrm{t}}$") + ax_b.semilogx(nt_if["x"], nt_if["sl_voc"], "o-", color=C_TEAL, ms=4.2, lw=1.9, label="SolarLab PVK/ETL $N_{\\mathrm{t}}$") + ax_b.semilogx(nt_bk["x"], nt_bk["ref_voc"], "^--", color=C_MUTED, ms=5.4, lw=1.4, label="SCAPS Bulk $N_{\\mathrm{t}}$") + ax_b.semilogx(nt_bk["x"], nt_bk["sl_voc"], "d-", color=C_AMBER, ms=4.2, lw=1.8, label="SolarLab Bulk $N_{\\mathrm{t}}$") ax_b.set_xlabel("Defect Parameter Scale ($10^9$ to $10^{15}$)") ax_b.set_ylabel("Open-Circuit Voltage $V_{\\mathrm{oc}}$ (V)") ax_b.set_ylim(0.93, 1.29) ax_b.set_title("(b) 7-Level Gaussian Defect Sweeps", fontweight="bold", color=C_INK, loc="left", pad=8) ax_b.legend(loc="lower left", frameon=True, facecolor="white", edgecolor=C_LINE, fontsize=8.3) - # (c) 248 Numeric Cases |ΔVoc| ECDF + # (c) 248 Numeric Cases |ΔVoc| ECDF (log scale to resolve sub-mV clustering) ax_c = fig.add_subplot(gs[0, 2]) _clean_axes(ax_c) dvoc = np.asarray(BENCHMARK_DATA["scaps_dvoc_mv"], dtype=float) ecdf_y = np.arange(1, dvoc.size + 1) / dvoc.size * 100.0 - ax_c.plot(dvoc, ecdf_y, color=C_BLUE, lw=2.3, label="|Δ$V_{\\mathrm{oc}}$| across 248 numeric cases") - ax_c.axvline(30.0, color=C_TEAL, lw=1.5, ls="--", label="30 mV alignment band (94.0%)") + ax_c.semilogx(dvoc, ecdf_y, color=C_BLUE, lw=2.3, label="|Δ$V_{\\mathrm{oc}}$| (248 cases)") + ax_c.axvline(2.0, color=C_TEAL, lw=1.5, ls="--", label="2 mV gate (95.2%)") ax_c.scatter([np.median(dvoc), np.percentile(dvoc, 90)], [50.0, 90.0], color=C_CORAL, zorder=5, s=34) - ax_c.set_xlim(0.0, 90.0) - ax_c.set_ylim(0.0, 103.0) + ax_c.set_xlim(0.012, 220.0) + ax_c.set_ylim(0.0, 103.5) + ax_c.set_xticks([0.02, 0.1, 0.5, 2.0, 10.0, 100.0]) + fmt = ScalarFormatter() + fmt.set_scientific(False) + ax_c.xaxis.set_major_formatter(fmt) + ax_c.set_xticklabels(["0.02", "0.1", "0.5", "2", "10", "100"]) + ax_c.xaxis.set_minor_formatter(NullFormatter()) ax_c.set_xlabel("Absolute Voltage Deviation |Δ$V_{\\mathrm{oc}}$| (mV)") ax_c.set_ylabel("Cumulative Cases (%)") - ax_c.set_title("(c) Full 262-Case Scorecard", fontweight="bold", color=C_INK, loc="left", pad=8) - ax_c.legend(loc="lower right", frameon=True, facecolor="white", edgecolor=C_LINE, fontsize=8.4) + ax_c.set_title("(c) Full 262-Case Zero-Fit Scorecard", fontweight="bold", color=C_INK, loc="left", pad=8) + ax_c.legend( + loc="upper left", + frameon=True, + facecolor="white", + edgecolor=C_LINE, + fontsize=7.9, + handlelength=1.6, + borderpad=0.35, + ) ax_c.text( - 33.5, - 42.0, + 0.975, + 0.055, "262 / 262 converged (0 failed)\n" - "Median |Δ$V_{\\mathrm{oc}}$| = 12.7 mV\n" - "P90 |Δ$V_{\\mathrm{oc}}$| = 25.9 mV\n" - "Median |ΔFF| = 0.53%\n" - "Median |ΔPCE| = 0.20%", - fontsize=8.6, + "221 / 248 (89.1%) pass all 4 gates\n" + "Median |Δ$V_{\\mathrm{oc}}$| = 0.60 mV\n" + "Median |Δ$J_{\\mathrm{sc}}$| = 0.009 mA $\\mathrm{cm}^{-2}$\n" + "Median |ΔFF| = 0.031%\n" + "Median |ΔPCE| = 0.009%", + transform=ax_c.transAxes, + ha="right", + va="bottom", + multialignment="left", + zorder=4, + fontsize=7.8, color=C_TEXT, - linespacing=1.42, - bbox={"boxstyle": "round,pad=0.35", "facecolor": C_BG_BLUE, "edgecolor": C_BLUE, "lw": 0.9}, + linespacing=1.36, + bbox={"boxstyle": "round,pad=0.32", "facecolor": C_BG_BLUE, "edgecolor": C_BLUE, "lw": 0.9}, ) - out = OUT_DIR / "ValidationScapsOverviewV2.png" + out = OUT_DIR / "ValidationScapsOverview.png" fig.savefig(out, dpi=DPI, bbox_inches="tight", pad_inches=0.12, facecolor="white") plt.close(fig) return out def generate_validation_hysteresis() -> Path: - """5. ValidationHysteresisOverviewV2.png: Verified 45-case dynamic ion hysteresis.""" + """5. ValidationHysteresisOverview.png: Verified 45-case dynamic ion hysteresis.""" fig = plt.figure(figsize=(13.8, 4.5), dpi=DPI, facecolor="white") gs = fig.add_gridspec(1, 3, width_ratios=[1.08, 1.05, 0.97], wspace=0.25) @@ -828,9 +845,9 @@ def generate_validation_hysteresis() -> Path: hd = BENCHMARK_DATA["hyst_diffusivity"] hn = BENCHMARK_DATA["hyst_density"] ax_b.plot(hd["x"], hd["ref_hi"], "s--", color=C_INK, ms=4.5, lw=1.3, label="Reference ($D_{\\mathrm{ion}}$ axis)") - ax_b.plot(hd["x"], hd["sl_hi"], "o-", color=C_BLUE, ms=4.6, lw=1.9, label="SolarLab V2 ($D_{\\mathrm{ion}}$ axis)") + ax_b.plot(hd["x"], hd["sl_hi"], "o-", color=C_BLUE, ms=4.6, lw=1.9, label="SolarLab ($D_{\\mathrm{ion}}$ axis)") ax_b.plot(hn["x"], hn["ref_hi"], "^--", color=C_MUTED, ms=4.5, lw=1.3, label="Reference ($P_0$ axis)") - ax_b.plot(hn["x"], hn["sl_hi"], "d-", color=C_TEAL, ms=4.6, lw=1.9, label="SolarLab V2 ($P_0$ axis)") + ax_b.plot(hn["x"], hn["sl_hi"], "d-", color=C_TEAL, ms=4.6, lw=1.9, label="SolarLab ($P_0$ axis)") ax_b.set_xlim(-0.05, 2.05) ax_b.set_ylim(-0.03, 1.06) ax_b.set_xlabel("Normalized Sweep Coordinate (0.0 to 2.0)") @@ -866,7 +883,7 @@ def generate_validation_hysteresis() -> Path: bbox={"boxstyle": "round,pad=0.35", "facecolor": C_BG_TEAL, "edgecolor": C_TEAL, "lw": 0.9}, ) - out = OUT_DIR / "ValidationHysteresisOverviewV2.png" + out = OUT_DIR / "ValidationHysteresisOverview.png" fig.savefig(out, dpi=DPI, bbox_inches="tight", pad_inches=0.12, facecolor="white") plt.close(fig) return out diff --git a/src/solarlab/materials/data/presets/scaps_pvk_xy.device.json b/src/solarlab/materials/data/presets/scaps_pvk_xy.device.json new file mode 100644 index 00000000..a73dfc54 --- /dev/null +++ b/src/solarlab/materials/data/presets/scaps_pvk_xy.device.json @@ -0,0 +1,274 @@ +{ + "contacts": [ + { + "S_n": "1.0E+5", + "S_p": "1.0E+3", + "id": "contact_left", + "layer": "layer_0", + "side": "left" + }, + { + "S_n": "1.0E+3", + "S_p": "1.0E+5", + "id": "contact_right", + "layer": "layer_2", + "side": "right" + } + ], + "electrical_grid": [], + "grain_boundaries": [], + "id": "scaps_pvk_xy", + "interfaces": [ + { + "defect": { + "calibration_factor": 1.0, + "energy_reference": "above_valence_band", + "id": "interface_defect_0", + "iface_state_calibration_factor": 1.0, + "kinetics": { + "sigma_n_m2": 1e-23, + "sigma_p_m2": 1e-23, + "thermal_velocity_n_m_s": 100000.0, + "thermal_velocity_p_m_s": 100000.0 + }, + "partner_metadata": { + "defect_id": "interface_defect_0", + "distribution": "single", + "energy_reference": "above_valence_band", + "trap_depth_eV": 0.3 + }, + "total_density_m2": 1e+16, + "trap_depth_eV": 0.3 + }, + "id": "interface_0", + "left": "layer_0", + "right": "layer_1" + }, + { + "defect": { + "calibration_factor": 1.0, + "energy_reference": "above_valence_band", + "id": "interface_defect_1", + "iface_state_calibration_factor": 1.0, + "kinetics": { + "sigma_n_m2": 1e-23, + "sigma_p_m2": 1e-23, + "thermal_velocity_n_m_s": 100000.0, + "thermal_velocity_p_m_s": 100000.0 + }, + "partner_metadata": { + "E_char_eV": 0.1, + "N_peak_m3": 5.641895835e+18, + "defect_id": "interface_defect_1", + "distribution": "gaussian", + "energy_reference": "above_valence_band", + "trap_depth_eV": 0.3 + }, + "total_density_m2": 1e+16, + "trap_depth_eV": 0.3 + }, + "id": "interface_1", + "left": "layer_1", + "right": "layer_2" + } + ], + "layers": [ + { + "bulk_defects": [ + { + "charge_transition": "unresolved", + "degeneracy": 1.0, + "distribution": { + "kind": "single_level", + "normalization": "integrated_total", + "total_density_m3": 1000000000000.0 + }, + "energy_level": { + "reference": "below_conduction_band", + "value_eV": 0.1 + }, + "id": "bulk_0", + "kinetics": { + "sigma_n_m2": 1e-19, + "sigma_p_m2": 1e-19, + "thermal_velocity_n_m_s": 100000.0, + "thermal_velocity_p_m_s": 100000.0 + }, + "name": "SAM-CB", + "neutral_reference": "unresolved" + }, + { + "charge_transition": "unresolved", + "degeneracy": 1.0, + "distribution": { + "kind": "single_level", + "normalization": "integrated_total", + "total_density_m3": 1000000000000.0 + }, + "energy_level": { + "reference": "above_valence_band", + "value_eV": 0.1 + }, + "id": "bulk_1", + "kinetics": { + "sigma_n_m2": 1e-19, + "sigma_p_m2": 1e-19, + "thermal_velocity_n_m_s": 100000.0, + "thermal_velocity_p_m_s": 100000.0 + }, + "name": "SAM-VB", + "neutral_reference": "unresolved" + } + ], + "defect_model": "effective_lifetime", + "defect_schema_version": "solarlab-explicit-bulk-defects-v1", + "id": "layer_0", + "name": "SCAPS_HTL", + "parameterization": "scaps", + "parameters": { + "Eg": 3.25, + "N_A": 1e+24, + "N_D": 0.0, + "Nc300": 2.5e+26, + "Nv300": 2.5e+26, + "chi": 2.4, + "eps_r": 11.75, + "mu_n": 1e-07, + "mu_p": 1e-07, + "optical_material": "spiro_OMeTAD", + "v_th": 100000.0 + }, + "role": "HTL", + "scaps_defect_metadata": [ + { + "defect_id": "bulk_0", + "distribution": "single", + "energy_reference": "below_conduction_band", + "trap_depth_eV": 0.1 + }, + { + "defect_id": "bulk_1", + "distribution": "single", + "energy_reference": "above_valence_band", + "trap_depth_eV": 0.1 + } + ], + "thickness": 2e-08 + }, + { + "bulk_defects": [ + { + "charge_transition": "unresolved", + "degeneracy": 1.0, + "distribution": { + "kind": "single_level", + "normalization": "integrated_total", + "total_density_m3": 1e+18 + }, + "energy_level": { + "reference": "below_conduction_band", + "value_eV": 0.1 + }, + "id": "bulk_0", + "kinetics": { + "sigma_n_m2": 1e-19, + "sigma_p_m2": 1e-19, + "thermal_velocity_n_m_s": 100000.0, + "thermal_velocity_p_m_s": 100000.0 + }, + "name": "Perovskite-CB", + "neutral_reference": "unresolved" + }, + { + "charge_transition": "unresolved", + "degeneracy": 1.0, + "distribution": { + "kind": "single_level", + "normalization": "integrated_total", + "total_density_m3": 1e+18 + }, + "energy_level": { + "reference": "above_valence_band", + "value_eV": 0.1 + }, + "id": "bulk_1", + "kinetics": { + "sigma_n_m2": 1e-19, + "sigma_p_m2": 1e-19, + "thermal_velocity_n_m_s": 100000.0, + "thermal_velocity_p_m_s": 100000.0 + }, + "name": "Perovskite-VB", + "neutral_reference": "unresolved" + } + ], + "defect_model": "effective_lifetime", + "defect_schema_version": "solarlab-explicit-bulk-defects-v1", + "id": "layer_1", + "name": "SCAPS_PVK", + "parameterization": "scaps", + "parameters": { + "B_rad": 1e-18, + "C_n": 2.3e-41, + "C_p": 2.3e-41, + "Eg": 1.53, + "N_A": 0.0, + "N_D": 1e+18, + "Nc300": 2e+24, + "Nv300": 1.8e+25, + "chi": 3.94, + "eps_r": 31.0, + "mu_n": 0.002, + "mu_p": 0.0002, + "optical_material": "MAPbI3", + "v_th": 100000.0 + }, + "role": "absorber", + "scaps_defect_metadata": [ + { + "defect_id": "bulk_0", + "distribution": "single", + "energy_reference": "below_conduction_band", + "trap_depth_eV": 0.1 + }, + { + "defect_id": "bulk_1", + "distribution": "single", + "energy_reference": "above_valence_band", + "trap_depth_eV": 0.1 + } + ], + "thickness": 8e-07 + }, + { + "id": "layer_2", + "name": "SCAPS_ETL", + "parameterization": "scaps", + "parameters": { + "Eg": 1.9, + "N_A": 0.0, + "N_D": 1e+24, + "Nc300": 8e+25, + "Nv300": 8e+25, + "chi": 4.1, + "eps_r": 4.2, + "mu_n": 1e-06, + "mu_p": 1e-09, + "optical_material": "C60", + "v_th": 100000.0 + }, + "role": "ETL", + "thickness": 2.5e-08 + } + ], + "schema_version": "solarlab.device-preparation.v1", + "settings": { + "Phi": "2.5E+21", + "T": "300.0", + "built_in_potential_mode": "semiconductor_work_function", + "dos_band_potentials": true, + "het_recomb_despike": "0.0", + "mode": "fast" + }, + "source_format": "scaps" +} diff --git a/src/solarlab/materials/data/presets/scaps_pvk_xy.v2.json b/src/solarlab/materials/data/presets/scaps_pvk_xy.v2.json new file mode 100644 index 00000000..3a71577f --- /dev/null +++ b/src/solarlab/materials/data/presets/scaps_pvk_xy.v2.json @@ -0,0 +1,290 @@ +{ + "default_catalog_sha256": "8de934eb0685b1d5fc4843002fceb4a8fdebdb4ac22896ec08a309991730130e", + "input": { + "contacts": [ + { + "S_n": "1.0E+5", + "S_p": "1.0E+3", + "id": "contact_left", + "layer": "layer_0", + "side": "left" + }, + { + "S_n": "1.0E+3", + "S_p": "1.0E+5", + "id": "contact_right", + "layer": "layer_2", + "side": "right" + } + ], + "electrical_grid": [], + "grain_boundaries": [], + "id": "scaps_pvk_xy", + "interfaces": [ + { + "defect": { + "calibration_factor": 1.0, + "energy_reference": "above_valence_band", + "id": "interface_defect_0", + "iface_state_calibration_factor": 1.0, + "kinetics": { + "sigma_n_m2": 1e-23, + "sigma_p_m2": 1e-23, + "thermal_velocity_n_m_s": 100000.0, + "thermal_velocity_p_m_s": 100000.0 + }, + "partner_metadata": { + "defect_id": "interface_defect_0", + "distribution": "single", + "energy_reference": "above_valence_band", + "trap_depth_eV": 0.3 + }, + "total_density_m2": 1e+16, + "trap_depth_eV": 0.3 + }, + "id": "interface_0", + "left": "layer_0", + "right": "layer_1" + }, + { + "defect": { + "calibration_factor": 1.0, + "energy_reference": "above_valence_band", + "id": "interface_defect_1", + "iface_state_calibration_factor": 1.0, + "kinetics": { + "sigma_n_m2": 1e-23, + "sigma_p_m2": 1e-23, + "thermal_velocity_n_m_s": 100000.0, + "thermal_velocity_p_m_s": 100000.0 + }, + "partner_metadata": { + "E_char_eV": 0.1, + "N_peak_m3": 5.641895835e+18, + "defect_id": "interface_defect_1", + "distribution": "gaussian", + "energy_reference": "above_valence_band", + "trap_depth_eV": 0.3 + }, + "total_density_m2": 1e+16, + "trap_depth_eV": 0.3 + }, + "id": "interface_1", + "left": "layer_1", + "right": "layer_2" + } + ], + "layers": [ + { + "bulk_defects": [ + { + "charge_transition": "unresolved", + "degeneracy": 1.0, + "distribution": { + "kind": "single_level", + "normalization": "integrated_total", + "total_density_m3": 1000000000000.0 + }, + "energy_level": { + "reference": "below_conduction_band", + "value_eV": 0.1 + }, + "id": "bulk_0", + "kinetics": { + "sigma_n_m2": 1e-19, + "sigma_p_m2": 1e-19, + "thermal_velocity_n_m_s": 100000.0, + "thermal_velocity_p_m_s": 100000.0 + }, + "name": "SAM-CB", + "neutral_reference": "unresolved" + }, + { + "charge_transition": "unresolved", + "degeneracy": 1.0, + "distribution": { + "kind": "single_level", + "normalization": "integrated_total", + "total_density_m3": 1000000000000.0 + }, + "energy_level": { + "reference": "above_valence_band", + "value_eV": 0.1 + }, + "id": "bulk_1", + "kinetics": { + "sigma_n_m2": 1e-19, + "sigma_p_m2": 1e-19, + "thermal_velocity_n_m_s": 100000.0, + "thermal_velocity_p_m_s": 100000.0 + }, + "name": "SAM-VB", + "neutral_reference": "unresolved" + } + ], + "defect_model": "effective_lifetime", + "defect_schema_version": "solarlab-explicit-bulk-defects-v1", + "id": "layer_0", + "name": "SCAPS_HTL", + "parameterization": "scaps", + "parameters": { + "Eg": 3.25, + "N_A": 1e+24, + "N_D": 0.0, + "Nc300": 2.5e+26, + "Nv300": 2.5e+26, + "chi": 2.4, + "eps_r": 11.75, + "mu_n": 1e-07, + "mu_p": 1e-07, + "optical_material": "spiro_OMeTAD", + "v_th": 100000.0 + }, + "role": "HTL", + "scaps_defect_metadata": [ + { + "defect_id": "bulk_0", + "distribution": "single", + "energy_reference": "below_conduction_band", + "trap_depth_eV": 0.1 + }, + { + "defect_id": "bulk_1", + "distribution": "single", + "energy_reference": "above_valence_band", + "trap_depth_eV": 0.1 + } + ], + "thickness": 2e-08 + }, + { + "bulk_defects": [ + { + "charge_transition": "unresolved", + "degeneracy": 1.0, + "distribution": { + "kind": "single_level", + "normalization": "integrated_total", + "total_density_m3": 1e+18 + }, + "energy_level": { + "reference": "below_conduction_band", + "value_eV": 0.1 + }, + "id": "bulk_0", + "kinetics": { + "sigma_n_m2": 1e-19, + "sigma_p_m2": 1e-19, + "thermal_velocity_n_m_s": 100000.0, + "thermal_velocity_p_m_s": 100000.0 + }, + "name": "Perovskite-CB", + "neutral_reference": "unresolved" + }, + { + "charge_transition": "unresolved", + "degeneracy": 1.0, + "distribution": { + "kind": "single_level", + "normalization": "integrated_total", + "total_density_m3": 1e+18 + }, + "energy_level": { + "reference": "above_valence_band", + "value_eV": 0.1 + }, + "id": "bulk_1", + "kinetics": { + "sigma_n_m2": 1e-19, + "sigma_p_m2": 1e-19, + "thermal_velocity_n_m_s": 100000.0, + "thermal_velocity_p_m_s": 100000.0 + }, + "name": "Perovskite-VB", + "neutral_reference": "unresolved" + } + ], + "defect_model": "effective_lifetime", + "defect_schema_version": "solarlab-explicit-bulk-defects-v1", + "id": "layer_1", + "name": "SCAPS_PVK", + "parameterization": "scaps", + "parameters": { + "B_rad": 1e-18, + "C_n": 2.3e-41, + "C_p": 2.3e-41, + "Eg": 1.53, + "N_A": 0.0, + "N_D": 1e+18, + "Nc300": 2e+24, + "Nv300": 1.8e+25, + "chi": 3.94, + "eps_r": 31.0, + "mu_n": 0.002, + "mu_p": 0.0002, + "optical_material": "MAPbI3", + "v_th": 100000.0 + }, + "role": "absorber", + "scaps_defect_metadata": [ + { + "defect_id": "bulk_0", + "distribution": "single", + "energy_reference": "below_conduction_band", + "trap_depth_eV": 0.1 + }, + { + "defect_id": "bulk_1", + "distribution": "single", + "energy_reference": "above_valence_band", + "trap_depth_eV": 0.1 + } + ], + "thickness": 8e-07 + }, + { + "id": "layer_2", + "name": "SCAPS_ETL", + "parameterization": "scaps", + "parameters": { + "Eg": 1.9, + "N_A": 0.0, + "N_D": 1e+24, + "Nc300": 8e+25, + "Nv300": 8e+25, + "chi": 4.1, + "eps_r": 4.2, + "mu_n": 1e-06, + "mu_p": 1e-09, + "optical_material": "C60", + "v_th": 100000.0 + }, + "role": "ETL", + "thickness": 2.5e-08 + } + ], + "schema_version": "solarlab.device-preparation.v1", + "settings": { + "Phi": "2.5E+21", + "T": "300.0", + "built_in_potential_mode": "semiconductor_work_function", + "dos_band_potentials": true, + "het_recomb_despike": "0.0", + "mode": "fast" + }, + "source_format": "scaps" + }, + "references": {}, + "resource_library_sha256": "6082eb3300b024b07e638fb7fca29dd88119e4c2db0403346bcd4bfe9f9fa60a", + "schema_version": "solarlab.configuration.v2", + "source": { + "id": "scaps_pvk_xy.yaml", + "sha256": "94a77c5cd866dcc63a6bd5da0a11189e9ebfca9cc9cd5c301a41d1cb67f41f6f" + }, + "sources": [ + { + "id": "scaps_pvk_xy.yaml", + "sha256": "94a77c5cd866dcc63a6bd5da0a11189e9ebfca9cc9cd5c301a41d1cb67f41f6f" + } + ] +} diff --git a/src/solarlab/materials/data/presets/scaps_pvk_xy.yaml b/src/solarlab/materials/data/presets/scaps_pvk_xy.yaml new file mode 100644 index 00000000..f3e20c02 --- /dev/null +++ b/src/solarlab/materials/data/presets/scaps_pvk_xy.yaml @@ -0,0 +1,127 @@ +# scaps_pvk_xy.yaml — Native zero-fit SCAPS-1D partner baseline (PVK-xy.scaps). +# +# Verbatim physical parameters extracted from the partner SCAPS 3.3.10 project +# definition (PVK-xy.scaps: SAM 20 nm / Perovskite 800 nm / C60 25 nm) with zero +# empirical calibration factors (het_recomb_despike = 0, no contact phi_B offset, +# no interface-state attenuation factors): +# +# 1. Contacts: recalculated semiconductor flat-band work functions with finite +# selective recombination velocities (SAM back: Sn=1e5, Sp=1e3 m/s; +# C60 front: Sn=1e3, Sp=1e5 m/s). +# 2. Absorber (SCAPS_PVK): Eg=1.53 eV, chi=3.94 eV, eps_r=31, Nc=2.0e18 cm^-3, +# Nv=1.8e19 cm^-3, mu_n=20 cm^2/(V s), mu_p=2.0 cm^2/(V s), Nd=1.0e12 cm^-3, +# B_rad=1.0e-12 cm^3/s, C_n=C_p=2.3e-29 cm^6/s, plus symmetric CB/VB shallow +# single-level bulk traps (sigma=1e-15 cm^2, Nt=1e12 cm^-3, 0.10 eV). +# 3. Heterointerfaces: both HTL/PVK (single) and PVK/ETL (7-level Gaussian, +# E_char=0.10 eV) anchor defect levels at Et=0.30 eV above the highest EV +# (SCAPS Reference=3) with sigma_n=sigma_p=1.0e-19 cm^2 and Nt=1.0e12 cm^-2. +# 4. Optics: packaged optical_material keys enable standalone TMM / spectral +# workstation runs; scripts/benchmarks/scaps_native_pvk_xy.py binds the +# native SCAPS AM1.5G 1 sun.spe table (reproducibility/ScapsAm15g1Sun.spe) +# and analytical sqrt(hv - Eg) absorption laws for exact 262-case parity. + +device: + T: 300.0 + Phi: 2.5e21 + mode: fast + dos_band_potentials: true + het_recomb_despike: 0.0 + built_in_potential_mode: semiconductor_work_function + S_n_left: 1.0e5 + S_p_left: 1.0e3 + S_n_right: 1.0e3 + S_p_right: 1.0e5 + +layers: + - name: SCAPS_HTL + role: HTL + thickness_nm: 20.0 + E_g_eV: 3.25 + chi_eV: 2.40 + eps_r: 11.75 + mu_n_cm2: 1.0e-3 + mu_p_cm2: 1.0e-3 + N_C_cm3: 2.5e20 + N_V_cm3: 2.5e20 + N_D_cm3: 0.0 + N_A_cm3: 1.0e18 + v_th_cm_s: 1.0e7 + optical_material: spiro_OMeTAD + bulk_defects: + - name: SAM-CB + sigma_n_cm2: 1.0e-15 + sigma_p_cm2: 1.0e-15 + N_t_cm3: 1.0e6 + E_t_eV_below_cb: 0.10 + distribution: single + - name: SAM-VB + sigma_n_cm2: 1.0e-15 + sigma_p_cm2: 1.0e-15 + N_t_cm3: 1.0e6 + E_t_eV_above_vb: 0.10 + distribution: single + + - name: SCAPS_PVK + role: absorber + thickness_nm: 800.0 + E_g_eV: 1.53 + chi_eV: 3.94 + eps_r: 31.0 + mu_n_cm2: 20.0 + mu_p_cm2: 2.0 + N_C_cm3: 2.0e18 + N_V_cm3: 1.8e19 + N_D_cm3: 1.0e12 + N_A_cm3: 0.0 + v_th_cm_s: 1.0e7 + B_rad_cm3_s: 1.0e-12 + C_n_cm6_s: 2.3e-29 + C_p_cm6_s: 2.3e-29 + optical_material: MAPbI3 + bulk_defects: + - name: Perovskite-CB + sigma_n_cm2: 1.0e-15 + sigma_p_cm2: 1.0e-15 + N_t_cm3: 1.0e12 + E_t_eV_below_cb: 0.10 + distribution: single + - name: Perovskite-VB + sigma_n_cm2: 1.0e-15 + sigma_p_cm2: 1.0e-15 + N_t_cm3: 1.0e12 + E_t_eV_above_vb: 0.10 + distribution: single + + - name: SCAPS_ETL + role: ETL + thickness_nm: 25.0 + E_g_eV: 1.90 + chi_eV: 4.10 + eps_r: 4.2 + mu_n_cm2: 1.0e-2 + mu_p_cm2: 1.0e-5 + N_C_cm3: 8.0e19 + N_V_cm3: 8.0e19 + N_D_cm3: 1.0e18 + N_A_cm3: 0.0 + v_th_cm_s: 1.0e7 + optical_material: C60 + +interfaces: + - target: HTL/PVK + sigma_n_cm2: 1.0e-19 + sigma_p_cm2: 1.0e-19 + N_t_cm2: 1.0e12 + v_th_cm_s: 1.0e7 + E_t_eV_above_vb: 0.30 + distribution: single + + - target: PVK/ETL + sigma_n_cm2: 1.0e-19 + sigma_p_cm2: 1.0e-19 + N_t_cm2: 1.0e12 + v_th_cm_s: 1.0e7 + E_t_eV_above_vb: 0.30 + distribution: gaussian + E_char_eV: 0.10 + N_peak_cm3: 5.641895835e12 diff --git a/src/solarlab/materials/packaged.py b/src/solarlab/materials/packaged.py index 4d522e40..80ba8eb1 100644 --- a/src/solarlab/materials/packaged.py +++ b/src/solarlab/materials/packaged.py @@ -78,12 +78,14 @@ PACKAGED_PRESET_NAMES: tuple[str, ...] = ( "classical_pin", + "scaps_pvk_xy", "scaps_mirror_v2", "calado2016_ion_sweep", "calado2016_fig1f", ) _SHIPPED_YAML_PRESETS: tuple[str, ...] = ( + "scaps_pvk_xy.yaml", "scaps_mirror_v2.yaml", "calado2016_ion_sweep.yaml", "calado2016_fig1f.yaml", diff --git a/tests/refactor/test_input_domain_closure.py b/tests/refactor/test_input_domain_closure.py index a92189aa..28e1348c 100644 --- a/tests/refactor/test_input_domain_closure.py +++ b/tests/refactor/test_input_domain_closure.py @@ -39,11 +39,11 @@ def encoded(value): return value -def test_all_55_inputs_reopen_without_aliases_or_changed_words(): +def test_all_56_inputs_reopen_without_aliases_or_changed_words(): defaults = load_packaged_default_catalog("matrix_v2") resources = load_packaged_resource_library(source_id_prefix="src/solarlab/materials/data") all_paths = sorted(FIXTURES.rglob("*.yaml")) + sorted(PRESETS.glob("*.yaml")) - assert len(all_paths) == 55 + assert len(all_paths) == 56 checked = [] for path in all_paths: rel = path.relative_to(ROOT).as_posix() @@ -84,7 +84,7 @@ def test_all_55_inputs_reopen_without_aliases_or_changed_words(): assert encoded(prepared.to_mapping()) == before assert not prepared.can_execute checked.append(rel) - assert len(checked) == 55 + assert len(checked) == 56 def test_all_actual_resources_own_immutable_exact_words(): diff --git a/tests/unit/materials/test_packaged_resources_and_cli.py b/tests/unit/materials/test_packaged_resources_and_cli.py index 7bdba0de..6757d884 100644 --- a/tests/unit/materials/test_packaged_resources_and_cli.py +++ b/tests/unit/materials/test_packaged_resources_and_cli.py @@ -93,7 +93,12 @@ def test_packaged_optical_resources_templates_and_presets_resolve_cleanly() -> N defaults = load_packaged_default_catalog() preset_sources = load_packaged_preset_sources() v2_docs = load_packaged_preset_v2_documents() - assert set(v2_docs) == {"scaps_mirror_v2", "calado2016_ion_sweep", "calado2016_fig1f"} + assert set(v2_docs) == { + "scaps_pvk_xy", + "scaps_mirror_v2", + "calado2016_ion_sweep", + "calado2016_fig1f", + } for name in PACKAGED_PRESET_NAMES: mapping = load_packaged_preset_device_mapping(name) diff --git a/web/src/preset-catalog.test.ts b/web/src/preset-catalog.test.ts index 4674f84d..b2c1c59d 100644 --- a/web/src/preset-catalog.test.ts +++ b/web/src/preset-catalog.test.ts @@ -11,12 +11,13 @@ describe('focused research preset catalog', () => { { name: 'driftfusion_calado2016_repro.yaml', namespace: 'shipped' }, { name: 'scaps_mirror_v2_robin_strong.yaml', namespace: 'shipped' }, { name: 'scaps_mirror_v2.yaml', namespace: 'shipped' }, + { name: 'scaps_pvk_xy.yaml', namespace: 'shipped' }, { name: 'my_scan.yaml', namespace: 'user' }, { name: 'my_tandem.yaml', namespace: 'user', device_type: 'tandem_2T' }, ] const original = structuredClone(entries) expect(researchPresetEntries(entries).map(e => e.name)).toEqual([ - 'scaps_mirror_v2.yaml', 'calado2016_ion_sweep.yaml', 'my_scan.yaml', + 'scaps_pvk_xy.yaml', 'scaps_mirror_v2.yaml', 'calado2016_ion_sweep.yaml', 'my_scan.yaml', ]) expect(entries).toEqual(original) }) @@ -30,7 +31,9 @@ describe('focused research preset catalog', () => { expect(researchPresetEntries([])).toEqual([]) }) - it('distinguishes the two studies and their reference physics modes', () => { + it('distinguishes the shipped studies and their reference physics modes', () => { + expect(presetLabel('scaps_pvk_xy.yaml')).toBe('SCAPS native (PVK-xy)') + expect(presetPreferredMode('scaps_pvk_xy.yaml')).toBe('fast') expect(presetLabel('scaps_mirror_v2.yaml')).toBe('SCAPS reproduction') expect(presetPreferredMode('scaps_mirror_v2.yaml')).toBe('fast') expect(presetPreferredMode('calado2016_fig1f.yaml')).toBeUndefined() diff --git a/web/src/preset-catalog.ts b/web/src/preset-catalog.ts index a1ba057e..b57dea32 100644 --- a/web/src/preset-catalog.ts +++ b/web/src/preset-catalog.ts @@ -13,6 +13,18 @@ export const RESEARCH_PRESETS: ReadonlyArray<{ mode: SimulationModeName description: ReferenceModelDescription }> = [ + { + name: 'scaps_pvk_xy.yaml', label: 'SCAPS native (PVK-xy)', mode: 'fast', + description: { + formulation: 'Native zero-fit SCAPS-1D heterojunction model', + mechanisms: [ + 'Electron and hole transport; recalculated flat-band contacts', + '7-level Gaussian PVK/ETL & single HTL/PVK interface SRH (Et = 0.30 eV above EV)', + 'Bulk SRH, radiative and Auger recombination with zero calibration factors', + ], + evidence: 'Native PVK-xy.scaps + AM1.5G .spe zero-fit alignment (median |dVoc| = 0.60 mV across 248 numeric cases).', + }, + }, { name: 'scaps_mirror_v2.yaml', label: 'SCAPS reproduction', mode: 'fast', description: {