Skip to content

Milestone B (G9P): V2 3-package cutover, SCAPS/Hysteresis alignment, perovskite-sim retirement, and V2 docs - #28

Merged
ShaneLogic merged 46 commits into
mainfrom
devel
Nov 23, 2026
Merged

ShaneLogic merged 46 commits into
mainfrom
devel

Conversation

@ShaneLogic

Copy link
Copy Markdown
Owner

Summary

This PR delivers the complete Waves 3–4 architecture refactor (G9P), two-round first-principles SCAPS-1D & Mobile-Ion Hysteresis alignment, complete retirement of the legacy /perovskite-sim/ directory, and the V2 documentation & pure-Arial figure overhaul (46 commits, +101,824 / -677,602 lines across 2,108 files).

1. Unified V2 3-Package Product & Workstation Cutover (P04–P09, G9P)

  • Single-source 3-package layout under src/:
    • solarlab (0.1.0): Core 1D/2D coupled semiconductor-ionic-defect drift-diffusion engine, log-activity sparse assembler, packaged DefaultCatalog, optical (n, k) resources, presets, and solarlab CLI (solarlab check-install --require-no-legacy, solarlab steady-jv).
    • solarlab_server: FastAPI/SSE workstation service, SQLite RunStore, schema-bound configuration preview, and isolated worker execution (solarlab-server).
    • solarlab_research: Decoupled multi-precision/interval qualification & research drivers (solarlab-cbo-scan, solarlab-r1-short-window, solarlab-r1-verify-sources).
  • Dynamic, multivalent & metastable 1D defects + AC/C–f/transients (P04-10, P05-03b, P05-04b) and prospective V2 physics closures (P08-01..P08-05): sub-face series dielectric capacitance, half-endpoint control-volume geometry, reciprocal unequal-DOS thermionic emission, and spectral control-volume Beer–Lambert optics.
  • Full web/ React/TypeScript SPA cutover (P09-02) onto V2 solarlab configuration schemas and server endpoints, with zero legacy perovskite_sim or backend imports enforced by import-linter (12/12 contracts).

2. First-Principles SCAPS-1D & Dynamic Hysteresis Alignment (Zero Fudge Factors)

  • SCAPS-1D 262-Case Matrix (ScapsComparisonContractV1.json):
    • Added explicit opt-in interface_band_reference_mode='scaps_interface_extrema' and analytical 7-level untruncated Gauss–Hermite interface trap quadrature (SCAPS_GAUSSIAN_INTERFACE_QUADRATURE) with exact Kirchhoff balance and analytical IFT Jacobians (0-ULP change on default single_level path).
    • 262 / 262 cases converge (0 failures): 94.0% (233/248) achieve |ΔVoc| <= 30 mV, median |ΔVoc| = 11.7 mV (+1.91 mV on scaps_base), P90 |ΔVoc| = 25.93 mV, median |ΔFF| = 0.53%, median |ΔPCE| = 0.20%.
  • Dynamic Mobile-Ion Hysteresis 45-Case Matrix (HysteresisReferenceContractV2.json):
    • Synchronized 7-stage protocol initial uniform ion profile, full steric exclusion flux (ion_steric_diffusion_only=False), dual-mesh absorber generation, and exact-conserving geometric Backward Euler substeps.
    • 45 / 45 cases complete (0 failures): median |ΔHI_norm| = 5.6e-4 (95.6% <= 5e-3), max relative mobile-ion inventory drift <= 1.80e-13.

3. Legacy /perovskite-sim/ Retirement & Repository Slimming

  • Physically retired /perovskite-sim/ (1,049 files) and untracked local .claude/ + skills-lock.json via .gitignore, reducing tracked files from 2,654 to 1,024 (-674k lines).
  • Promoted active reference assets to canonical top-level paths (docs/contracts/, reproducibility/, tests/fixtures/configs/), documented retired closures in docs/RetiredModelsV1.md, and preserved the pre-slim snapshot at tag archive/pre-slim-be973ac5 (be973ac5e1aa46c5c21eaa79c42b402d25a76eb3).

4. V2 README Hierarchy, GitHub MathJax Macro Guard & Pure-Arial Figures

  • Restructured README.md, examples/research_1d/README.md, examples/research_2d/README.md, docs/contracts/README.md, and reproducibility/README.md (2,313 -> 676 lines total, eliminating cross-path duplication and covering all 10 2D modules).
  • Replaced GitHub-disallowed MathJax macros (\operatorname, \choose, single-line $$) and added tests/ci/test_markdown_contracts.py static guard.
  • Added reproducible scripts/generate_readme_figures.py generating 5 native-Arial (300 DPI) V2 architecture/physics/validation figures under docs/figures/.

Scope & Scientific Governance Boundary

  • Engineering delivery and formal external scientific qualification remain strictly separated: all CLI/package/benchmark receipts preserve scientific_qualification = False, frozen reference contract thresholds remain unmodified, and decoupled RS-G7 (R1 100 s L2/L3) research certification remains on its independent track.

Verification

  • GitHub Actions Refactor checks (devel HEAD d21fa46) — 9/9 Jobs Green:
    • Run: https://github.com/ShaneLogic/SolarLab/actions/runs/45114221763
    • static, binding, frontend (Vitest 963 passed + Vite production build), core (3.11.16 & 3.13.15), packages (3.11.16 & 3.13.15 including ruff, mypy across 314 files, schema check, release-bundle wheel/sdist build, and outside-checkout import check), and backend (3.11.16 & 3.13.15 including isolated scan_execution and supervisor_control_failure pools).

- Surface declared vs historical-effective SCAPS and device optical coherence
  (inspect_scaps_optical_coherence, inspect_device_optical_coherence,
  BehaviorContext.optical_coherence_diagnostics, ConfigurationMigration.export,
  LegacyWire.export) with P08-04 ownership tag and zero optical physics or v2
  PreparedDevice word changes (P03-04).
- Represent complete AST-pinned R1 implicit material behavior flags in
  inspect_r1_material_behavior and BehaviorContext(driver="r1_material"),
  fixing MULTIVALENT_VERSION QF-DC detection and guarding LegacyExecutionContext,
  ExecutionEngine, and IdentityInputs to require R1ExecutionContext (P03-04, P03-05).
- Propagate tandem subcell diagnostics in migrate_configuration and synchronize
  SCAPS bulk_defects / scaps_defect_metadata edits (single-field edits,
  singular-to-plural promotion, clear, N_peak_cm3 edits, and conflict guards)
  in prepare_legacy_wire (P03-06, P03-07).
- Update PublicAPI.json for solarlab.config.behavior and add regression tests
  across behavior, migration/wire roundtrip, cache/binding invalidation, and
  target-profile release/historical provenance verification (P03-01..07).
- P05-02b: genuine DC Suns-V_oc (suns_voc.py), cold temperature-rebound V_oc(T) (voc_t.py), DC dark J-V with curvature-window diode extraction (dark_jv.py), and Backward Euler piecewise/triangular waveform J-V with displacement-inclusive PV/conjugate current reporting (waveform_jv.py).

- P05-03a: small-signal AC C-f / C-V / Mott-Schottky with apparent_built_in_voltage_V, active vs frozen ionic modes, and inductive/0-Hz refusal (mott_schottky.py); monochromatic EQE with closed PhotonBudget and J_sc_eqe_A_m2 (eqe.py); and Rau reciprocity EL spectrum with radiative vs total recombination decomposition (el_spectrum.py).

- Add T1/T2/T4 analytic, coupled-ionic, and perovskite_sim parity test suites across 5 test modules.
…, and catalog dispatch [M]

- P06-07: add startup SHA-256 schema/registry handshake verification
  (`schema-handshake.ts`) across `/configuration-schema` and `/experiments`
  (`X-Solarlab-Registry`, `X-Solarlab-Job-Schema`, `ETag`, payload digest),
  rendering an explicit `[role="alert"]` mismatch banner and mounting
  `ConfigurationWorkstation` across all 5 canonical preparation modes
  (`device`, `tandem`, `jv`, `spatial`, `sweep`).
- P06-07: propagate stable-ID renames and surface dangling-reference,
  topology-order, duplicate-ID, duplicate-contact-side, and sweep-axis target
  diagnostics in `device-edits.ts`, `device-editor.ts`, and `sweep.ts`, with
  lossless round-trip regression coverage for spatial defect profiles,
  composition grading, n-k optical resources, and 2T tandem stacks.
- P06-08: replace frontend `TIER_FLAGS` / `deviceSnapshot.device.mode`
  post-run physics guessing with backend execution-manifest receipt extraction
  (`execution-physics.ts`), surfacing `scientific_qualification === false`
  (`Unqualified · Engineering Preview`) and explicit diagnostic banners/badges
  for failed sweep/trajectory points, non-identifiable `tau === null` +
  `non_identifiable_reason`, and unbracketed/invalid `V_oc`.
- P06-08: replace hardcoded experiment switch/union dispatch with declarative
  `EXPERIMENT_CATALOG` + plot renderer catalog and delete unreachable legacy
  modules (`panels/degradation.ts`, `panes/current-decomp-pane.ts`,
  `panes/spatial-pane.ts`).
…n experiments

- P04-13 external circuit, thermal balance, electrothermal, and 2T tandem:
  - external_circuit.py: post-processing and strict self-consistent forward/reverse
    monotone J-V wrappers for R_series and R_shunt without altering bulk PDEs.
  - thermal_balance.py: 0D module energy balance (Q_in = P_elec + Q_conv + Q_rad),
    convective/radiative linearized derivatives, and Brent equilibrium T_eq solver.
  - electrothermal.py: fresh-state-per-temperature isothermal J-V family (steady_jv
    and transient_jv_strict with mobile ions) and bracketed Brent operating-point
    energy-balance closure across device_plus_lumped_parasitics.
  - tandem_jv.py: full-stack joint TMM optics across [top, junction, bottom,
    back_reflector] with spectral photon-budget closure and parasitic exclusion,
    per-subcell electrical compilation with distinct identities, and Kirchhoff
    series-matched 2T J-V synthesis.
- P05-04a charge-conserving open-circuit, TPV, and degradation snapshots:
  - open_circuit.py: bordered sparse (M + 1) floating-terminal Backward Euler
    integrator enforcing Gauss-Maxwell total port current I_carrier + I_ion + dD/dt = 0
    on all faces and telescoping port-charge conservation.
  - tpv.py: explicit steady (ion-free) or finite-time soaked (mobile-ion)
    preconditioning, paired pulsed vs unpulsed control subtraction on identical
    time grids, and gated single-exponential decay extraction refusing truncated,
    non-monotonic, or multi-exponential traces.
  - degradation.py: frozen-ion electronic snapshot J-V sweeps preserving exact
    pointwise ion densities across all single/dual/shared-site species and
    coupled irreversible stress-damage absorber rebind snapshots.
- Add 18 unit, integration, conservation, and live legacy-parity tests.
…sheet-charge closures onto unified assembly (P04-09)
…unded WKB tunnelling onto unified assembly (P04-12)
…d metastable 1D defects plus defect/ion AC, C-f, and transients onto unified assembly (P04-10, P05-03b, P05-04b)
…namic charge-closure refusals (P04-10, P05-03b, P05-04b)

- Eliminate O(1e-11..1e-9 A/m^2/V) floating-point cancellation in dark 0 V
  and low-bias small-signal AC on both p-i-n and n-i-p across bulk-defect,
  two-sided interface-defect, and coupled defect+ion stacks:
  * Lift the small-signal unknown along MOVING_LIFT (dV on the positive
    electrode and adjacent transport layer) so cross-face Scharfetter-Gummel
    tangents avoid O(1/V_T) contact-potential subtraction.
  * Add direct quasi-Fermi IFT sensitivities (*_qf, *_common_qf) and exact
    flux-sum stabilization in two_sided.py so two-sided trace tangents avoid
    stiff-side common-mode (O(1e24 - 1e24)) cancellation.
  * Tighten default AC FrequencyOptions relative_tolerance to 1e-14 with
    iterative refinement and retain exact ion inventory conservation across
    all frequencies f >= 0.
- Compute DefectIonImpedanceResult.maximum_maxwell_spread_A_m2_V over the
  Maxwell-conserving sweeps (coupled, frozen_ions) and document asymptotic
  frozen-trap closures.
- Enforce pre-solve CapabilityError refusals for neutral bulk defects under
  dynamic_bulk_defects=True and non-equilibrium_referenced interface charge
  closure under dynamic_interface_defects=True across compile, impedance,
  and transient entry points.
- Add dark 0 V p-i-n and n-i-p AC passivity, 0 Hz FD slope, Maxwell spread,
  and capability refusal regression tests.
…on step guards (#128)

- Look up electronic contact exchanges via (ELECTRON/HOLE, side) and preserve
  CarrierExchange's +x outward_normal sign on both contacts in steady DC and
  BDF step accounting (dynamic_defects_1d.py).
- Require at least one Newton step for nonzero initial residuals and tighten
  post-step residual fallback in _damped_newton_solve and _solve_bdf_step_newton
  so doped selective-contact stacks converge to step tolerance before exit.
- Add selective (S_n, S_p) and blocking contact regression tests on both p-i-n
  and n-i-p orientations across DC, dark 0 V FD impedance, and BDF2 transient.
…dget, and SCAPS stress certification (P08-04)
…interface verification to solarlab_research (P07-01, P07-02)
…lone CLI, and exclude perovskite-sim from target wheel/sdist (P09-01)
…on lock to V2 solarlab

- Sever all production imports of solarlab_server.legacy_engine from
  job_service, registered_worker, app, and routes/legacy while retaining
  legacy_engine/__init__.py on disk for P09-03 retirement boundary checks.
- Narrow JobSubmission.engine to Literal['solarlab'], default worker_binding
  to engine='solarlab', retire POST /api/jobs and synchronous POST /api/*
  with HTTP 410, and preserve 100% solver-free historical RunStore readback
  (legacy_result + GET /api/jobs/{id}/events & /result) with zero legacy
  imports.
- Add SPA _web_dist static asset serving in create_app and add
  solarlab_server.cli:main with single-thread BLAS and assembled equation
  enforcement.
- Lock production worker preparation and verify_selection in
  solarlab.equations.implementation to 'assembled' (retiring
  NEWCORE_EQUATIONS=legacy in worker/server execution while preserving
  explicit in-process equation_implementation(LEGACY) for unit parity tests).
- Cut over web workstation, panels, and Vite/Docker configs from legacy
  /api/* endpoints to V2 solarlab_server endpoints (v2-workstation-client,
  v2-job-client, /configs, /materials, /configuration-preview/*, /experiments,
  /jobs, /runs/.../events, /results/...), preserving UNQUALIFIED badges.
…ry layout

- Remove legacy /perovskite-sim/ tree (1,049 files), expired transition manifests,
  obsolete prototype scripts, and pure legacy-parity test modules (pre-slim snapshot
  anchored at local tag archive/pre-slim-be973ac5).
- Untrack local .claude/ skills and skills-lock.json (491 files) via .gitignore
  while keeping local files intact on disk.
- Promote active non-code assets to canonical top-level paths:
  - tests/fixtures/configs/ (52 YAML device test fixtures)
  - docs/contracts/ (34 active physics/protocol contract documents)
  - reproducibility/{AnalyticGatesV1.json,ScapsParams.xlsx}
  - web/src/workstation/panes/__fixtures__/IonDiffusivityFigureReference.json
- Migrate remaining unit, integration, refactor, runtime, CI, and benchmark helpers
  onto packaged solarlab.materials resources with zero changes to src/.
- Update CLAUDE.md, README.md, docs/DevelopmentGuide.md, docs/RetiredModelsV1.md,
  pyproject.toml, .github/workflows/ci.yml, and .dockerignore.
…cros, and refresh Arial figures

- Rewrite root README.md, examples/research_1d/README.md, and
  examples/research_2d/README.md (2,313 -> 584 lines across those three,
  eliminating cross-path duplication and updating all architecture, solver,
  and 262-case SCAPS / 45-case hysteresis benchmark summaries to V2).
- Add structured index READMEs for docs/contracts/ (34 specifications) and
  reproducibility/ (6 frozen contracts and benchmark drivers).
- Fix GitHub MathJax macro errors (\operatorname -> \mathrm, \choose -> \binom,
  and standalone multi-line 97238 fences) across README.md and docs/**/*.md, and
  enforce macro/link checks in tests/ci/test_markdown_contracts.py.
- Add scripts/generate_readme_figures.py enforcing strict native Arial
  typography at 300 DPI and replace 9 legacy figures with 5 V2 core figures
  (ArchitectureFlowV2, DevicePhysicsOverviewV2, SolverTopologyV2,
  ValidationScapsOverviewV2, ValidationHysteresisOverviewV2).

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @ShaneLogic, this pull request is too large to review

It changes 2,113 files. Sourcery can review pull requests with up to 300 changed files.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T05:22:54.095375Z d21fa46 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d21fa46f92

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread web/src/v2-job-client.ts

export async function startJob(
kind: DispatchableJobKind,
_device: unknown,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Use the selected device when submitting a run

When a workstation user runs with a configuration other than the route’s first registered device, the panes call startJob without configPath, so selectRouteDevice(..., null, ...) chooses ids[0] and this _device argument is ignored. The server therefore simulates its first registered device while the run is saved with the user’s selected deviceSnapshot, silently associating results with the wrong model. Bind the submission to the active configuration or reject it when that configuration is not installed.

Useful? React with 👍 / 👎.

Comment thread web/src/v2-job-client.ts
Comment on lines +126 to +129
if (kind === 'jv' || kind === 'dark_jv') {
selectedEntry = bindings.find(
b => b.engine === 'solarlab' && b.driver === 'steady_jv' && b.scope === STEADY_SCOPE,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reject transient J–V selections on the steady route

When a user runs a plain J–V sweep with the pane’s default Transient (Radau) selection, the pane passes params.solver here but this branch selects steady_jv solely from kind; the submitted payload then contains only a voltage grid and drops the solver and scan-rate settings. The run is reported as the selected transient experiment even though it is a static sweep, losing dynamic and hysteresis effects without warning. Route supported solver modes to matching V2 drivers or reject unsupported selections before accepting the run.

Useful? React with 👍 / 👎.

@ShaneLogic
ShaneLogic merged commit 3a8abab into main Nov 23, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant