28double UnitConversion::run(
const std::string &src,
const std::string &dest,
const double srcValue,
const double l1,
32 if ((srcUnit->unitID() ==
"dSpacing") || (destUnit->unitID() ==
"dSpacing")) {
33 throw std::runtime_error(
"This signature is deprecated for d Spacing unit conversions");
39double UnitConversion::run(
const std::string &src,
const std::string &dest,
const double srcValue,
const double l1,
62 double factor(0.0), power(0.0);
66 return convertViaTOF(srcUnit, destUnit, srcValue, l1, emode, params);
83 return factor * std::pow(srcValue, power);
114 throw std::invalid_argument(
"UnitConversion::convertViaTOF - Unknown emode " +
std::to_string(emode));
131 double wavelengthFactor(0.0), wavelengthPower(0.0);
132 energyUnit.
quickConversion(
"Wavelength", wavelengthFactor, wavelengthPower);
134 const double stheta = std::sin(theta);
136 double wavelength = wavelengthFactor * std::pow(
efixed, wavelengthPower);
138 return 4.0 * M_PI * stheta / wavelength;
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
static double convertQuickly(const double srcValue, const double factor, const double power)
Perform a quick conversion.
static double convertViaTOF(Unit &srcUnit, Unit &destUnit, const double srcValue, const double l1, const DeltaEMode::Type emode, const UnitParametersMap ¶ms)
Convert through TOF.
static double convertToElasticQ(const double theta, const double efixed)
Convert to ElasticQ from Energy.
static double run(const std::string &src, const std::string &dest, const double srcValue, const double l1, const double l2, const double theta, const DeltaEMode::Type emode, const double efixed)
Convert a single value between the given units (as strings)
The base units (abstract) class.
double convertSingleToTOF(const double xvalue, const double &l1, const int &emode, const UnitParametersMap ¶ms)
Convert from the concrete unit to time-of-flight.
double convertSingleFromTOF(const double xvalue, const double &l1, const int &emode, const UnitParametersMap ¶ms)
Convert from the time-of-flight to the concrete unit.
bool quickConversion(const Unit &destination, double &factor, double &power) const
Is conversion by constant multiplication possible?
Energy in milli-electronvolts.
std::unordered_map< UnitParams, double > UnitParametersMap
std::shared_ptr< Unit > Unit_sptr
Shared pointer to the Unit base class.
std::string to_string(const wide_integer< Bits, Signed > &n)
Type
Define the available energy transfer modes It is important to assign enums proper numbers,...