Repository navigation
Conversation
The gammaEnergyKev, correctionFactor and uncertainty fields bind to <input type="number">, so bind:value yields a number (or null when empty), but the submit/validation code called .trim() on them and threw "trim is not a function" as soon as a value was entered. Hold the three fields as number | null and adjust validation, submit payload and reset.
galegozi
force-pushed
the
7.2-fission-correction-table
branch
from
September 2, 2026 19:36
2de0b9c to
c2ea084
Compare
Applies the fission-interference correction on the Review step: C_target^U = k*(C_target^S + f*C_fissile^S) - f*C_fissile^U - everythingMath: expose the combined correction factor k (combinedCorrectionFactor) via an extracted getCombinedCorrectionFactor; getUnknownConcentration now calls it. Export the unit-conversion helpers. - NAAMath/fissionCorrectionMath.ts: the corrected-value formula (mass-fraction space) and the corrected uncertainty as the Pythagorean norm of the relative errors of the two predicted concentrations and the fission factor. - utils/fissionResults.ts: computeFissionResults resolves f from the Step 1 choice, C_target^S / C_fissile^S from the target's linked reference, C_fissile^U from the computed fissile result, k from combinedCorrectionFactor. Auto-applies when inputs resolve; otherwise the cell keeps the uncorrected value with a note. - Review UI: main table shows corrected value +/- sigma with a dagger marker; a "Fission interference corrections" breakdown table; a collapsed uncorrected table. CSV export mirrors all of it. - Step 1 manual-factor path now also captures a fissile parent. Tests: fissionCorrectionMath.spec, fissionResults.spec, everythingMath k exposure, e2e/fissionCorrection (full Ce/U run).
Previously the correction was blocked when the fissile element (e.g. uranium) was not one of the analysed isotopes. Now the Review step prompts for the fissile concentration in the standard and in each unknown, explains that they're needed for the correction, and applies it once entered. - FissionManualEntry (draft field fissionManualFissile), keyed by target isotope: unit + inStandard + per-unknown value/uncertainty. - computeFissionResults resolves C_fissile^S / C_fissile^U from the analysed fissile isotope when present, otherwise from the manual entry; sets needsFissileInput on the result when a value is still missing. Only a missing fissile parent (Step 1) is a hard block now. - Review UI renders number inputs per blocked target isotope; a $effect seeds a backing entry. The manual C_fissile^U uncertainty feeds the Pythagorean-norm propagation. Tests: fissionResults.spec (manual-input apply + prompt paths), analysisDraft.spec (round-trip), e2e/fissionCorrection (no-uranium run).
The correction is only computed when a uranium isotope is part of the
analysis, so its measured concentration is what the fission term is
scaled against. Without uranium the fission-prone isotopes raise an
informational warning that can be dismissed ("no uranium in the sample")
or acted on:
- "Choose uranium from the catalog" fills the Step 1 catalog search with
"uranium" and scrolls the browser into view
- "Add a custom uranium isotope" appends an isotope pre-filled as
Uranium / "U-" for the user to finish, and scrolls its card into view
Both offered together when the catalog is available. The fissile-parent
choice is restricted to U-235 / U-238. The hand-entered fissile
concentration path is left in place but is now unreachable.
IsotopeViewer gains a bindable searchTerm; CollapsibleCard gains an
optional id for scroll anchoring.
La-140 from uranium fission grows in almost entirely through its precursor Ba-140, so the flat catalog constant A can't be used directly. When the interfering isotope is La-140 the per-sample factor becomes f = A · [exp(-lambda_Ba·m) - exp(-lambda_La·m)] · exp(lambda_La·t) with m = half the irradiation time and t = the decay time, evaluated separately for the standard and each unknown (so f_S != f_U). The corrected concentration is k·(C_target^S + f_S·C_fissile^S) - f_U·C_fissile^U; fissionCorrectedMassFraction gains an optional fInUnknown for this. lambda_La comes from the La-140 isotope. lambda_Ba is resolved from a hand-entered Ba-140 half-life, an analysed Ba-140 isotope, or the isotope catalog; when none is available the Review step shows a red error and the correction is withheld until the half-life is supplied. The Step 1 La-140 panel also carries the Ba-140 half-life field (auto-filled when resolved). The breakdown table shows f_S / f_U for La-140 and the formula note explains the per-sample factor.
New /help/api page documenting every /api/* endpoint — query params, request/response shapes, the append vs replace modes, status codes, and how the two-layer write auth works. Linked from the user Help page and the Admin guide (which previously only pointed at README.md).
…-dismiss reviewed warnings - Label every fission-correction display with which math applies: "Standard correction — flat factor" or "Special correction — Ba-140 in-growth" (Step 1 summary, per-isotope panel, Review breakdown). - Ba-140 half-life now actually pre-fills the input once resolved from an analysed isotope or the catalog, and says where it came from; a "Use pre-filled value" button reverts a hand-entered override. - Once a fission-interference choice is recorded, the per-isotope panel collapses to a settled, non-warning summary line with a "Change" button instead of staying styled as an active warning; the Step 1 summary box only lists isotopes still awaiting review and disappears once none remain. - Drop thousands-separator commas from displayed gamma energies (toLocaleString() on plain numbers in proxyMeasurement.ts and +page.svelte); Date.toLocaleString() calls for timestamps are unaffected. Updated e2e coverage for the new reviewed/editing panel states and added a test for the Ba-140 half-life auto-fill. Along the way, fixed a Playwright gotcha: getByText(/regex/) matches raw DOM text, so it silently failed when the matched phrase was prettier-wrapped across a template line break; switched the affected assertions to plain-string getByText, which normalizes whitespace.
…ewed once complete - Add a radio choice to the La-140 fission panel: "Special — Ba-140 in-growth" (default) vs "Standard — flat factor". Standard skips the Ba-140 requirement entirely and behaves like a plain flat-factor isotope; the choice is saved as FissionChoice.useSpecialCorrection and read back into the same select on reopen. - A fission choice now only counts as reviewed once it's actually complete: for special-mode La-140 that means the Ba-140 half-life is resolved too, not just the factor. Previously applying a factor collapsed the panel to a settled state even when the correction couldn't run yet. This feeds unreviewedFissionCount, the Step 1 summary's unresolved list, and the per-isotope panel's collapse uniformly (isFissionCandidateReviewed). - Mode badges (Standard/Special) now reflect the actual chosen mode (including manual overrides), not just isotope identity. fissionResults.ts: the Bateman/in-growth path is skipped whenever useSpecialCorrection is explicitly false, falling back to a flat factor with no Ba-140 half-life needed.
…d of requiring it as an isotope Step 1's factor picker no longer requires uranium to be an analysed isotope - it's always offered for a fission-interference candidate. When uranium isn't analysed, a note explains its concentration will be typed in on the reference material and unknowns instead (the "add it as a custom isotope" / "choose it from the catalog" shortcuts remain as an alternative, just no longer required). The reference-material card (Step 2) and each unknown's card (Step 3) now show a "Uranium concentration" input whenever a fission choice needs it and uranium isn't analysed - reusing the existing FissionManualEntry / manualFissile data model and precedence (an analysed isotope's computed value always wins over a typed-in one; this is purely the fallback). Moved out of the Review step, which now just points back to Steps 2/3 if something's still missing instead of rendering the inputs itself. computeFissionResults is no longer gated on hasUraniumAnalyzed at the call site; unreviewedFissionCount follows suit. Updated fissionInterference.test.ts and fissionCorrection.test.ts for the ungated factor picker and the relocated manual-entry fields.
…ndard recommended for epithermal
…asked The "Uranium concentration" inputs on the reference material and unknown cards were gated on the target isotope's comparator result already being computable (needs valid counts on both a reference and an unknown first) - so on a fresh card there was nowhere to type it in yet. They now appear as soon as a fission correction factor is picked in Step 1 and uranium isn't analysed, via a new fissionUraniumEntryTargets derived that doesn't wait on computeFissionResults. That exposed a real bug: the manual entry's unit could get created before a reference material existed (and so before its unit was knowable), and was never updated afterwards - stuck blank forever, silently breaking the concentration conversion by a factor of 1e6. Fixed by keeping the entry's unit in sync once it's known, not just at creation. fissionFissileInputGroups (computed-result-driven) is now only used for the Review-step pointer note, which is what it's for.
…tion When "Load known concentrations from a datasheet" picks up a uranium row (bare "Uranium"/"U", or a specific isotope like "U-238") and uranium isn't one of the analysed isotopes, fill the "Uranium in this reference material" fission field from it automatically instead of requiring the user to retype a number they already have. Only fills an empty field (never overwrites a hand-entered value), converted into whatever unit the target isotope uses. findDatasheetEntryForElement (catalogWrite.ts) matches a datasheet row to an element symbol the same way applyDatasheetToReference matches isotopes, preferring a bare element-level row over a specific isotope's. No e2e coverage: the datasheet loader is gated behind sign-in, which only works on the real deployment. Added unit tests for the new matching function instead.
Unknown materials no longer need counts for every analysed isotope: they get the same "measured isotopes" toggles reference materials already had (an empty selection still means "all", so existing drafts are unaffected). Uncovered isotope/unknown combinations compute to undefined and render as "not measured" in the results table, CSV export, and the fission prompts rather than producing a bogus zero-input result. Fission uranium-concentration entry now clearly appears on every reference material, with a note pointing at the Isotope assignment panel whenever an isotope is still covered by more than one reference material. Adds e2e coverage for both flows plus the earlier La-140 hand-typed uranium case.
…the isotope Previously the hand-entered "uranium in this reference material" box only rendered on the single reference material the isotope was auto-linked to. With two reference materials that both cover every isotope (no coverage checkboxes set), both fission targets linked to the same one, so its card showed both boxes and the other card showed none. The box now appears on every reference material that covers the target isotope. While more than one does, the same value is shown on each with a note to narrow the coverage (the per-isotope checkboxes, or the Isotope assignment row); setting coverage to one isotope per material leaves each box on exactly its card. Persisted state is unchanged, so this takes effect on reload without rebuilding the analysis.
…ed the isotope The "uranium in this reference material" box was tied to whichever single reference the isotope resolved to. With two reference materials (one per isotope) the fission target could resolve to the other material — or to none, when a material's coverage checkboxes or catalog match set didn't list it — so its box never appeared on the card the user thinks of as "the one for this isotope". Now a reference material "owns" a fission target when it either covers the isotope or has counts for it; the box shows only on that one when exactly one material owns it, and on every material otherwise (all bound to the one value, with the note explaining how to narrow it down). The reference-resolution effect also falls back to a material that has a certified value or counts for the isotope before defaulting to the first. Also guards the target list against a non-numeric or dismissed factor.
…ross targets The special La-140 correction IS the factor: choosing it (the default) applies the constant straight away — a thermal La-140 catalog row, else the built-in 0.00233 ± 0.00012 (U-235) — instead of waiting for a typed factor. Without a stored choice lanthanum never became a fission target, which is why its uranium fields didn't appear on Steps 2/3. The special panel now shows the constant in place of the factor inputs; switching to Standard drops it so a flat factor can be picked. Hand-typed uranium is per sample, so typing it for one fission target (La, say) pre-fills the same field for the others (Ce). A pre-filled field keeps following while it matches and is left alone once typed differently; a target whose fields appear later starts pre-filled, and values convert between ppm and %.
The Predicted Concentrations table (plus the collapsed uncorrected table and the CSV export) now groups isotope columns by element and sorts both axes so each unknown's measured values run down a top-left to bottom-right diagonal: element groups ordered by the first unknown that measured them, unknowns by their first/last measured column. Unmeasured isotopes and unknowns go last; entry order breaks remaining ties, so a fully measured table keeps its rows as entered.
…pec.ts IsotopeViewer/ReferenceMaterialViewer read `$env/dynamic/public`, which in the browser resolves to `globalThis.__sveltekit_dev.env` — set by SvelteKit's client bootstrap, which component tests don't run. Add a client-project setup file that provides the empty public env, so the import resolves and PUBLIC_* overrides fall back to their defaults. Also update the "blocks leaving Select Isotopes" test: the step nav is now rendered above and below the step, so target the first "Next" button.
The f column showed "f_S / f_U" unlabelled for La-140 on the special correction. Split it into labelled f_S (standard) and f_U (unknown) columns, captioned with where each comes from, and add a Step 1 factor ± uncertainty column. Add a plain-language explanation and a definition of every symbol above the table, units on every concentration, a "Fission contribution" (corrected − uncorrected) column and the corrected uncertainty as a percent. The CSV export only wrote f_U, losing f_S for La-140; it now carries the method, Step 1 factor and uncertainty, f_S, f_U, unit, fission contribution and percent uncertainty, with descriptive headers. FissionResult gains baseFactor / baseFactorUncertainty (the Step 1 factor).
galegozi
force-pushed
the
7.2-fission-correction-table
branch
from
December 3, 2026 00:24
3d8824e to
6421bd0
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This version implements fission correction and includes some improvements to the UI.