pleiades.utils.units module
- class pleiades.utils.units.TimeUnitOptions(value)[source]
-
- s = 's'
- ms = 'ms'
- us = 'us'
- ns = 'ns'
- ps = 'ps'
- class pleiades.utils.units.EnergyUnitOptions(value)[source]
-
- meV = 'meV'
- eV = 'eV'
- keV = 'keV'
- MeV = 'MeV'
- GeV = 'GeV'
- J = 'J'
- class pleiades.utils.units.CrossSectionUnitOptions(value)[source]
-
- barn = 'barn'
- millibarn = 'millibarn'
- microbarn = 'microbarn'
- cm2 = 'cm^2'
- class pleiades.utils.units.DistanceUnitOptions(value)[source]
-
- cm = 'cm'
- nm = 'nm'
- pm = 'pm'
- m = 'm'
- angstrom = 'angstrom'
- pleiades.utils.units.convert_time_units(from_unit, to_unit)[source]
Convert time from one unit to another unit based on TimeUnitOptions options
- Parameters:
from_unit (TimeUnitOptions) – Unit to convert from.
to_unit (TimeUnitOptions) – Unit to convert to.
- Returns:
Time in the new unit.
- Return type:
- pleiades.utils.units.convert_distance_units(from_unit, to_unit)[source]
Convert distance from one unit to another unit based on DistanceUnitOptions options
- Parameters:
from_unit (DistanceUnitOptions) – Unit to convert from.
to_unit (DistanceUnitOptions) – Unit to convert to.
- Returns:
distance in the new unit.
- Return type:
- pleiades.utils.units.convert_to_energy(from_unit, to_unit)[source]
Convert energy from one unit to another unit based on EnergyUnitOptions options
- Parameters:
from_unit (EnergyUnitOptions) – Unit to convert from.
to_unit (EnergyUnitOptions) – Unit to convert to.
- Returns:
Energy in the new unit.
- Return type:
- pleiades.utils.units.convert_to_cross_section(from_unit, to_unit)[source]
Convert cross section from one unit to another unit based on CrossSectionUnitOptions options
- Parameters:
from_unit (CrossSectionUnitOptions) – Unit to convert from.
to_unit (CrossSectionUnitOptions) – Unit to convert to.
- Returns:
Cross section in the new unit.
- Return type:
- pleiades.utils.units.convert_array_from_time_to_lambda(time_array: ndarray, time_unit: TimeUnitOptions, distance_source_detector: float, distance_source_detector_unit: DistanceUnitOptions, detector_offset: float, detector_offset_unit: DistanceUnitOptions, lambda_unit: DistanceUnitOptions) ndarray[source]
Convert an array of time values to wavelength values.
- Parameters:
time_array (np.ndarray) – Array of time values.
time_unit (TimeUnitOptions) – Unit of the input time.
distance_source_detector (float) – Distance from the source to the detector.
distance_source_detector_unit (DistanceUnitOptions) – Unit of the distance.
detector_offset (float) – Offset of the detector.
detector_offset_unit (DistanceUnitOptions) – Unit of the offset.
lambda_unit (DistanceUnitOptions) – Unit of the output wavelength.
This is using the formula: lambda_m = h/(m_n * distance_source_detector_m) * (time_array_s + detector_offset_s)
- Returns:
Array of wavelength values.
- Return type:
np.ndarray
- pleiades.utils.units.convert_array_from_time_to_energy(time_array: ndarray, time_unit: TimeUnitOptions, distance_source_detector: float, distance_source_detector_unit: DistanceUnitOptions, detector_offset: float, detector_offset_unit: DistanceUnitOptions, energy_unit: EnergyUnitOptions) ndarray[source]
Convert an array of time values to energy values.
- Parameters:
time_array (np.ndarray) – Array of time values.
time_unit (TimeUnitOptions) – Unit of the input time.
distance_source_detector (float) – Distance from the source to the detector.
distance_source_detector_unit (DistanceUnitOptions) – Unit of the distance.
detector_offset (float) – Offset of the detector.
detector_offset_unit (DistanceUnitOptions) – Unit of the offset.
energy_unit (EnergyUnitOptions) – Unit of the output energy.
this is using the formula: E_ev = 1/2 m_n (L/t_tof)^2 / electron_volt
- where
t_tof = L/ v (L is the distance from the source to the detector in m, v is the velocity of the neutron in m/s). E is the kinetic energy of the neutron in eV.
- Returns:
Array of energy values.
- Return type:
np.ndarray
- pleiades.utils.units.calculate_number_density(material_density_g_cm3: float, thickness_mm: float, atomic_mass_amu: float) float[source]
Convert material properties to number density (atoms/barn).
Migrated from legacy/pleiades_old/simData.py for use in multi-isotope INP generation.
- Parameters:
material_density_g_cm3 – Material density in g/cm³
thickness_mm – Sample thickness in mm
atomic_mass_amu – Atomic mass in amu
- Returns:
Number density in atoms/barn (areal density)
- Return type:
Example
>>> # For Hafnium sample: density=13.31 g/cm³, thickness=5mm, mass=178.49 amu >>> density = calculate_number_density(13.31, 5.0, 178.49) >>> print(f"Number density: {density:.6e} atoms/barn")
Note
This calculation uses the same formula as the legacy code: areal_density = thickness * density * AVOGADRO / atomic_mass / CM2_TO_BARN
TODO: Future enhancement - auto-retrieve material density from element database