Skip to content

Pass a NaN flow rate through IonisationChamber as a NaN signal - #20

Merged
jhdark merged 1 commit into
pathsim:masterfrom
jhdark:ionisation-chamber-nan-flow
Nov 4, 2026
Merged

jhdark merged 1 commit into
pathsim:masterfrom
jhdark:ionisation-chamber-nan-flow

Conversation

@jhdark

@jhdark jhdark commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #17 (#4).

IonisationChamber computed the concentration as flux_in / flow_rate if flow_rate > 0 else 0.0. Because nan > 0 is False, a NaN flow rate gave a signal of exactly 0, so a broken upstream block looked like a clean "nothing detected". It now gives a NaN signal; the flux still passes through unchanged.

ic = IonisationChamber()
ic.inputs[0], ic.inputs[1] = 100.0, float("nan")
ic.update(None)
ic.outputs[1]   # before: 0.0, after: nan

Zero and negative flow rates still give a zero signal, as before. I didn't make a negative flow raise: implicit solvers can try negative values while iterating, so raising inside update could stop a valid run.

Adds a regression test, which fails on the current code.

Open question, not changed here: detection_efficiency (and the value returned by func_efficiency) is only checked to be non-negative, so values above 1 are accepted. That's fine if it is meant as a calibration factor, but if it is strictly an efficiency, it should be limited to [0, 1].

@jhdark
jhdark merged commit e38a984 into pathsim:master Nov 4, 2026
5 checks passed
@jhdark
jhdark deleted the ionisation-chamber-nan-flow branch November 4, 2026 13:49
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