Skip to content

Commit 7bc0c03

Browse files
priyanshluniaclaude
andcommitted
Merge origin/develop into bugfix/366-ca-uninitialized
Resolved against develop's post-#365 writer: ca_left/ca_right now guard on (diag !== nothing && diag.ca_populated) with rank-4 zero-extent sentinels; dropped the ca_populated save/restore hunks in the deleted _populate_dense_xi_via_serial_el!. Also repaired conflict markers committed to develop in docs/development/regression-harness.md (kept both sides, dropped the stale 'thread counts not forced' paragraph superseded by -t auto). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2 parents 61b40d6 + 9be3ac5 commit 7bc0c03

143 files changed

Lines changed: 12356 additions & 1959 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/agent-memory/fortran-physics-reviewer/MEMORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
- [KineticForces (NTV) Audit Checklist](kinetic_ntv_map.md) — pentrc->KineticForces map, Logan 2015 matrices, what to verify
66
- [InnerLayer (Resistive) Audit Checklist](resistive_layer_map.md) — rmatch->InnerLayer map, GGJ Wasow basis / Δ′, what to verify
77
- [Galerkin Δ′ Assembly Map](galerkin_assembly_map.md) — gal.f<->GalerkinAssembly.jl; resonant sign chain verified; PASS
8+
- [reg_spot vs singfac_min audit](reg_spot_regularization.md) — reg_spot field-recon smoothing CORRECT; distinct from singfac_min ODE gate

.claude/agent-memory/fortran-physics-reviewer/kinetic_ntv_map.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,60 @@ the Fortran `pentrc/` sources (file mapping in fortran_correspondence_map.md).
3131
- **Normalization**: torque Im(T)=2n·δW_k (Eq. 19) and diamagnetic-frequency sign/factor conventions match Fortran `torque.F90`.
3232
- **Mode indexing**: m, n ranges and block packing over n stay consistent with ForceFreeStates.
3333
- **Method variants**: FGAR/TGAR/PGAR/RLAR/CLAR/FCGL/TMM/WMM each present, not stubbed to a single fallback.
34+
35+
## Multi-ion (D-T) NTV — composition/collisionality (2026-07)
36+
Both Fortran PENTRC (`inputs.f90:236-243`, `read_kin`) and Julia (`KineticProfiles.jl:261-278`)
37+
support ONE main ion (zi,mi) + ONE impurity (zimp,mimp) per run. Correct multi-main-ion NTV is
38+
an EXTENSION beyond Fortran, but consistent with Logan-Park 2013's pitch-angle (Lorentz) model.
39+
- Zeff = Σ_s Z_s² n_s / n_e; quasineutrality n_e = Σ_s Z_s n_s (all ions incl. impurity).
40+
- Bug in current D-T split (run D, then T, each with ni=Ni/2): the `ni` column sets BOTH species
41+
density AND Zeff via z = zimp-(n_i/n_e)zi(zimp-zi). With ni=Ni/2 it treats the missing half as
42+
high-Z impurity → Zeff≈3.7 instead of true ≈1–1.4. Corrupts zpitch → nue,nui.
43+
- Correct collisionality: ν_a ∝ Z_a² lnΛ · Σ_b n_b Z_b² /(√m_a T_a^{3/2}) = ∝ Z_a² lnΛ·(n_e·Zeff_true).
44+
The zpitch(Zeff) polynomial is a main-ion+impurity closure (momentum-restoring correction); the
45+
MINIMAL fix is to feed the TRUE (full-composition) Zeff into the existing zpitch/ν formulas.
46+
- Additivity: τ = Σ_s τ_s. Lorentz operator is additive over field species; species couple only
47+
through shared δB, shared ω_E, shared Zeff/ν. Additive at this theory's order.
48+
- What changes single→multi: Zeff, zpitch, nue, nui (→nueff). UNCHANGED for equal-shape D-T:
49+
wdian/wdiat (log-derivative, density factor cancels), wtran/wbhat/wdhat/wgyro (already per-species),
50+
and the resonant-density prefactor (Ni/2 per species is correct).
51+
- ASIDE (separate fidelity bug, same code block): Fortran `inputs.f90:238` uses natural log for lnΛ;
52+
Julia `KineticProfiles.jl:270` uses log10 — diverges away from the n=1e20,T=1keV reference point.
53+
54+
## Multi-ion NTV — full-composition species set (2026-07 audit, PASS-with-caveats)
55+
Reviewed `resolve_ntv_species` (KineticProfiles.jl ~214-266) + `compute_calculated_kinetic_matrices`
56+
(CalculatedKineticMatrices.jl ~96-151). Verdict: physics is sound.
57+
- ν_s field-density RECONCILIATION (supersedes the earlier "should be n_e·Zeff" note above):
58+
code uses `ν_s = (zpitch/3.5e17)·z_s²·n_main·lnΛ/(√m_s·T_i^1.5)`, i.e. field density = zpitch·n_main
59+
(n_main = Σ MAIN-ion densities, no impurity, unweighted). This is CORRECT and MORE faithful to
60+
single-ion PENTRC than n_e·Zeff: PENTRC's design is zpitch·n_i, NOT Σ_b n_b Z_b². The two are NOT
61+
numerically equal (Zeff=1.5, C6, n_i/n_e=0.9 → zpitch·n_i = 1.225·n_e vs n_e·Zeff = 1.5·n_e, ~18%
62+
apart); that gap IS the intended momentum-restoring design difference that zpitch(Zeff) carries.
63+
n_main vs n_e·Zeff is a deliberate PENTRC-fidelity choice, exact in the z=1 main-ion domain.
64+
- z_s² test-particle factor: CORRECT and correctly placed (deflection freq ∝ test charge²). Single-ion
65+
had no z² only because zi=1. Reduces EXACTLY to single-ion nui for one z=1,fraction=1 ion (verified).
66+
- Impurity as its own test species: field density zpitch·n_main is NOT undercounting — the impurity's
67+
z_imp² contribution is already folded into Zeff inside zpitch. CAVEAT: zpitch is strictly a main-ion
68+
momentum-restoring closure; reusing it for the impurity/electron ν is an approximation beyond the
69+
single-ion theory. Acceptable (impurity δW ∝ n_imp is small); worth a one-line annotation.
70+
- Electron descriptor passes `ns[1]` (first ion's density) as its `ni_spline` — HARMLESS: the kernel
71+
`_setup_surface_state` (Torque.jl:659-664) reads `ne_spline` (full shared n_e) when electron=true,
72+
never ni_spline. Electron n_s = full n_e (correct). Cosmetic smell only.
73+
- Self-consistent δW summation (CalculatedKineticMatrices.jl:112-148): kw_flat/kt_flat are PURELY the
74+
kinetic matrices (Logan 7.30-7.35), every term ∝ species phase-space density n_s·f0_s — NO species-
75+
independent baseline. Fluid F,K,G added ONCE downstream in _compute_fkg_matrices!, outside the
76+
species loop. So `+=` over species is clean additivity; NOTHING in kw is wrongly ×species-count.
77+
→ TC-24 n=3 δW +0.066(D) → −0.10(D+T+C+e) sign flip is PLAUSIBLE physics near marginal stability,
78+
NOT a double-count. Dominant driver: the newly-ON electron channel (full n_e, opposite precession).
79+
DECISIVE cheap diagnostic to confirm: run D(½)+T(½) with electron=OFF, impurity absent — should
80+
return ≈ +0.066 (single-ion D). If D+T alone ≈ +0.066, the whole shift is electron+impurity = physical.
81+
82+
## Single-ion nui vs multi-species z_s² (#339, 2026-07 decision)
83+
Fortran PENTRC `inputs.f90:240-241` single-ion nui = (zpitch/3.5e17)·n_i·lnΛ/(√mi·T_i^1.5) has
84+
NO explicit zi² (implicitly assumes zi=1, main ion hydrogenic). Julia `load_kinetic_profiles`
85+
(~L416) is a faithful exact port. Multi-species `_nu` (~L253) adds explicit test-particle z_s²
86+
(the physically correct pitch-angle/Lorentz form; zpitch is the field-side momentum-restoring
87+
factor of Zeff, independent of test charge — no double count). RECOMMENDATION: option (a) ADD
88+
zi² to single-ion nui. It is numerically identical for the default zi=1 (regression byte-identical),
89+
makes single-ion the true 1-species special case of `_nu`, and only "deviates" from Fortran in the
90+
exotic zi≠1 case where Fortran is physically wrong anyway. Annotate as a documented improvement.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
name: reg_spot vs singfac_min regularization audit
3+
description: Verdict on GPEC-Julia reg_spot (field-reconstruction smoothing) port and its distinction from singfac_min (ODE crossing gate)
4+
metadata:
5+
type: project
6+
---
7+
8+
## Verdict (audited FieldReconstruction.jl, no local Fortran repo available)
9+
`reg_spot` port judged CORRECT-WITH-CAVEATS (caveat = Fortran verified from GPEC `xm*` convention + physics + known default, not from on-disk source).
10+
11+
## reg_spot — field-reconstruction smoothing (PerturbedEquilibrium)
12+
- Factor form: `reg_factor = singfac²/(singfac²+reg_spot²)`, singfac = m - n·q. Correct GPEC form. → 0 at rational surface, → 1 away. Applied in singfac-space, NOT ψ-space.
13+
- Default 5e-2 = 0.05 (PerturbedEquilibriumStructs.jl:50). Matches GPEC gpec_input namelist default.
14+
- Quantities regularized (matches GPEC `xm*` modified-quantity convention):
15+
- xmp1 = ξ^ψ' (FieldReconstruction.jl:393-395)
16+
- xms (clebsch_alpha) computed FROM regularized xmp1 via xms=-A⁻¹(B·xmp1_reg+C·xsp) (line 398-415, gpeq_sol)
17+
- xmt/xmz = regularized ξ^θ,ξ^ζ (line 584-594, gpeq_contra); xwt/xwz kept unregularized
18+
- b^θ_reg,b^ζ_reg inherit reg via xmp1/xms (compute_modified_field_modes)
19+
- LEFT UNREGULARIZED: ξ^ψ primitive (xsp / clebsch_psi = copy, line 356; xwp uses raw xsp). CORRECT — ξ^ψ (normal disp) is finite at rational surface; only 1/singfac-divergent tangential/derivative quantities are softened.
20+
21+
## singfac_min — DISTINCT mechanism (ForceFreeStates ODE crossing gate)
22+
- Default 1e-4 (ForceFreeStatesStructs.jl:267), "Matches Fortran STRIDE". Gates singular-surface crossings during EL ODE integration (EulerLagrange.jl:466-519, GeneralizedPerturbedEquilibrium.jl:426).
23+
- SingularCoupling.jl:204 uses `spot = 5e-4` as an offset (5e-4/|n·q1|) to evaluate bwp1 at lpsi/rpsi — labeled "matches Fortran default singfac_min". This is the ψ-offset for one-sided derivative eval, a THIRD distinct use, not reg_spot.
24+
- reg_spot (0.05, singfac-space smoothing of reconstructed fields) and singfac_min (1e-4, ODE crossing gate) are separate; both ported.

.claude/commands/release-notes.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
description: Draft the Unreleased section of CHANGELOG.md from merged pull requests
3+
argument-hint: "[--since <ref|date>] [--write]"
4+
allowed-tools: Bash(gh:*), Bash(git:*), Read, Edit
5+
---
6+
7+
Draft release notes from merged pull requests and place them in the `## Unreleased`
8+
section of `CHANGELOG.md`.
9+
10+
Arguments: `$ARGUMENTS`
11+
12+
## Determining the range
13+
14+
Use `--since` if given (a git ref or an ISO date). Otherwise use the most recent
15+
version tag:
16+
17+
```bash
18+
git tag -l 'v*' --sort=-v:refname | head -1
19+
```
20+
21+
The repository may have no version tags yet. If there is none and no `--since` was
22+
given, **stop and ask** which starting point to use rather than defaulting to the
23+
whole history.
24+
25+
Convert the starting point to a date, then list merged PRs:
26+
27+
```bash
28+
gh pr list --state merged --base develop --limit 200 \
29+
--search "merged:>=<date>" \
30+
--json number,title,mergedAt,body,labels,author
31+
```
32+
33+
## Building each entry
34+
35+
For every PR, parse the `## Release note` block from its body:
36+
37+
- **Audience**`developers` entries are omitted from the notes entirely.
38+
- **Numerical impact** — text after this label, minus the `_(harness @ sha)_` stamp.
39+
- **Migration** — what a user must change.
40+
- The prose sentences below the fields are the entry text.
41+
42+
Parse the title as `Area[.Submodule] - TAG[!] - Summary`.
43+
44+
Place each entry:
45+
46+
- **Any title with `!`** goes in `Changed results & breaking changes`, regardless of
47+
its tag. Give the numerical impact and the migration text, not just the summary.
48+
This section is the reason the mark exists — never let a marked change appear only
49+
under its tag.
50+
- Otherwise map the tag to its section: `FEATURE` → New capabilities, `BUGFIX` → Bug
51+
fixes, `PERF` → Performance, `API` → Interface & format changes, `DEPRECATION`
52+
Deprecations, `DOCS` → Documentation.
53+
- `MINOR`, `REFACTOR`, and `TEST` are omitted unless marked with `!`.
54+
55+
Within a section, group by Area, ordering areas by entry count. Write in the past
56+
tense, in terms a GPEC user would recognize, and end each entry with the PR number
57+
in parentheses.
58+
59+
## Gaps
60+
61+
Some PRs will have no parseable block. **List them explicitly at the end of your
62+
report as unprocessed, with their numbers and titles.** Do not invent an entry from
63+
a title or a diff — an unreported change is a visible gap, whereas a fabricated one
64+
is indistinguishable from a real entry and corrupts the record.
65+
66+
Also report any PR whose block says `Audience: users` but whose prose is empty.
67+
68+
## Output
69+
70+
Print the drafted sections for review. Only edit `CHANGELOG.md` if `--write` was
71+
passed; leave sections with no entries in place and empty. Never invent a version
72+
number or move entries out of `## Unreleased` — releasing is a human decision.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!--
2+
Title this PR the same way you title a commit: Area - TAG - Imperative summary
3+
Append ! to the TAG if results move or an interface changes: Equilibrium - BUGFIX! - ...
4+
Conventions: docs/development/naming.md
5+
-->
6+
7+
## Release note
8+
9+
<!-- Delete the option that does not apply and replace every <placeholder>. -->
10+
11+
- **Audience:** users | developers
12+
- **Numerical impact:** none | <what moved> _(harness @ <sha>)_
13+
- **Migration:** none | <what a user must change>
14+
15+
<One to three sentences a user of GPEC would understand: what you can now do, or what was wrong.>
16+
17+
## Regression report
18+
19+
<!--
20+
Required on every PR (docs/development/regression-harness.md). Paste the report below and
21+
put the commit you ran it at in the harness stamp above; CI fails if src/ changed afterwards.
22+
23+
regress --cases diiid_n1 --refs develop,local
24+
-->
25+
26+
```
27+
```
28+
29+
## Notes for reviewers
30+
31+
<!-- Anything that is not obvious from the diff. Delete if there is nothing. -->
32+
33+
---
34+
35+
Set an **assignee** and at least one **human reviewer**; if you are not ready to name them, open this as a **draft**. Lead developers to ask are listed in `docs/development/contributors.md`. Labels are applied automatically from the title.

.github/workflows/auto-merge.yaml

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)