Skip to content

PENTRC - NEW FEATURE - Optional supplied collision rates (kinetic_format="rates-v1") - #345

Merged
logan-nc merged 2 commits into
developfrom
pentrc-supplied-rates
Oct 20, 2026
Merged

logan-nc merged 2 commits into
developfrom
pentrc-supplied-rates

Conversation

@logan-nc

Copy link
Copy Markdown
Contributor

Reopens #338 against develop. #338 was approved but merged into its stacked base pentrc-edge-collisionality after #336 had already merged, so its changes never reached develop. This branch is the same content, plus 8b6f0d6, which nests the kinetic_format check inside if(present(format)) as suggested in the #338 review.

This is a slim version of the supplied-rate feature from #322, rebuilt on #336's way of handling ν.

What it does

Setting kinetic_format = "rates-v1" in PENT_INPUT reads a 9-column kinetic_file:

psi_n  n_i  n_e  T_i  T_e  omega_E  logLambda  nu_i(s^-1)  nu_e(s^-1)

The last three columns replace PENTRC's internal Coulomb/impurity collision model. The format and keyword are the same as #322, so existing adapter files work unchanged.

Default: "legacy" is the default and leaves behavior unchanged.

Validation: the run stops with a clear error stop message if:

  • rates-v1 gets a table without exactly 9 columns;
  • logLambda, nu_i or nu_e is non-positive;
  • kinetic_format is not one of the two values.

Interpolation:

  • The supplied columns are interpolated in log on the input table with the same pchip fit as n and T, then exponentiated onto read_kin's 101 nodes. This keeps the nodes positive, even when extrapolating past the end of the table.
  • From there the columns go through PENTRC - BUG FIX - Stop the edge collision frequency spline from ringing (#321) #336's existing pchip ν slopes, so ν stays positive between nodes as well.
  • No changes to torque.F90 or the integrand.

nfac/tfac: these scale n and T after ν is set, so they don't rescale supplied ν. This matches the behavior #322 documents.

DCON: kin_flag passes the same kinetic_format (dcon/dcon.F), so DCON and PENTRC read the table the same way.

Diff: +37/−10 in 4 files. There is no new build target, test harness or generated code, because the testing setup is frozen for this release.

How it differs from #322

#322 here
Where ν is evaluated exactly from a log-spline at each query, through new kin_eval wrappers the 101-node kin grid with pchip slopes
Rotation of exactly 0 kept goes through the existing replacement of 0 with 1e-9
wpfac required to be 1 unrestricted (with 1, the rotation manipulation already does nothing)
Input validation at every query, with bit-level finite checks once, when the table is read
Generated code, build targets, Python oracles added none

Verification

These were throwaway runs on feynman of the regression_solovev_kinetic_example chain (DCON with kin_flag → GPEC → PENTRC), built with gfortran. They compare this branch against #336.

run PENTRC T_total (fgar) δW_k total DCON W_t eigenvalues
#336, legacy 5.703490e-3 2.122400e-5 16.65462609, 216.66187207
this PR, legacy bit-identical bit-identical bit-identical
this PR, 9-column file without kinetic_format bit-identical (extra columns ignored, as before) bit-identical bit-identical
this PR, rates-v1 round trip* 5.703994e-3 (+8.8e-5 rel.) 2.122443e-5 (+2.1e-5 rel.) 16.65462844, 216.66187123

*In the round trip, the legacy formula's logΛ, ν_i and ν_e were written into the example's own table as columns 7–9 and fed back in with rates-v1.

  • Inside the table: supplied ν_i matches the legacy ν_i to ≤ 5e-7 relative for ψ < 0.99.
  • Last 0.01 in ψ: the two differ there because the paths extrapolate differently past the table's end (ψ = 0.998).
    • Legacy floors T at 1 meV, which puts ν ≈ 1e12 at ψ = 1.
    • rates-v1 extrapolates log ν smoothly, which puts ν ≈ 1e9 there.
    • Both values are far into the collisional regime, so torque moves by only 9e-5.

All PENTRC output files from the two legacy runs are bit-identical. The DCON outputs differ only in their CPU and wall-time stamps.

The three bad inputs (8 columns, a negative ν, kinetic_format="rates_v1") each stop with their message.

https://claude.ai/code/session_01VMDGyfQKRZQMdk3NJXsKQE

🤖 Generated with Claude Code

logan-nc and others added 2 commits October 19, 2026 06:14
…format="rates-v1"

With kinetic_format="rates-v1" in PENT_INPUT, the kinetic_file carries three
extra columns (logLambda, nu_i, nu_e in s^-1) that replace the internal
collision model. They are interpolated in log on the table so nodes stay
positive, and they reuse the pchip nu slopes from the edge-collisionality fix.
The default "legacy" path is unchanged. DCON kin_flag passes the same format.

Slim replacement for the supplied-rates part of #322 on top of #336.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VMDGyfQKRZQMdk3NJXsKQE
Fortran does not guarantee short-circuit evaluation, so the combined
present(format) .and. format /= "legacy" test could read an absent
argument. Every caller passes it today; this nests the check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VMDGyfQKRZQMdk3NJXsKQE
@logan-nc
logan-nc requested a review from krystophny October 20, 2026 03:55
@logan-nc
logan-nc merged commit 1ee77be into develop Oct 20, 2026
3 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