Skip to main content

energy_to_tof

Function energy_to_tof 

Source
pub fn energy_to_tof(energy_ev: f64, flight_path_m: f64) -> f64
Expand description

Convert neutron energy (eV) to time-of-flight (μs) given flight path (m).

§Domain contract

Mirrors tof_to_energy: returns f64::NAN unless both arguments are finite and strictly positive. A non-positive or non-finite energy_ev (the unguarded formula takes √energy, so a negative energy would yield a NaN velocity and energy_ev == 0 would yield +∞), and a non-positive or non-finite flight_path_m (which would yield a zero or negative TOF — a physically impossible time), are all rejected. This keeps the two directions consistent — both refuse out-of-domain input instead of returning a plausible-looking number.