tof.InelasticSample#
- class tof.InelasticSample(distance, name, func)[source]#
An inelastic sample component changes the energy of the neutrons that pass through it, but does not block any.
- Parameters:
distance (
Variable) – The distance from the source to the inelastic sample.name (
str) – The name of the inelastic sample.func (
Callable[[Variable],Variable]) – The change in energy applied to the neutrons as they pass through the inelastic sample. This should be a function or callable that takes the incident energy and returns the final energy.
Methods
__init__(distance, name, func)apply(neutrons)Apply the change in energy to the given neutrons.
as_dict()Return the inelastic sample as a dictionary.
as_json()Return the inelastic sample as a JSON-serializable dictionary.
as_readonly(neutrons)from_json(name, params)Create an inelastic sample from a JSON-serializable dictionary.
Attributes
kind- apply(neutrons)[source]#
Apply the change in energy to the given neutrons. The convention is that
\[\Delta E = E_i - E_f\]where \(E_i\) is the initial energy and \(E_f\) is the final energy.
Neutrons that would end up with a negative final energy are removed from the output by setting their wavelength to NaN. This is done to avoid issues with neutrons that would have a negative final energy being plotted with a very large wavelength.