Mantid
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Mantid::Kernel::Units::dSpacing Class Reference

d-Spacing in Angstrom More...

#include <Unit.h>

Inheritance diagram for Mantid::Kernel::Units::dSpacing:
Mantid::Kernel::Unit

Public Member Functions

double calcTofMax (const double difc, const double difa, const double tzero, const double tofmax=0.)
 
double calcTofMin (const double difc, const double difa, const double tzero, const double tofmin=0.)
 
const std::string caption () const override
 The full name of the unit. More...
 
Unitclone () const override
 
double conversionTOFMax () const override
 This function returns maximal TOF value still reversibly convertible into the unit. More...
 
double conversionTOFMin () const override
 some units can be converted from TOF only in the range of TOF ; This function returns minimal TOF value still reversibly convertible into the unit. More...
 
 dSpacing ()
 Constructor. More...
 
void init () override
 Finalize the initialization. More...
 
const UnitLabel label () const override
 A label for the unit to be printed on axes,. More...
 
double singleFromTOF (const double tof) const override
 DIFA * d^2 + DIFC * d + T0 - TOF = 0. More...
 
double singleToTOF (const double x) const override
 Convert a single X value to TOF. More...
 
const std::string unitID () const override
 "dSpacing" More...
 
- Public Member Functions inherited from Mantid::Kernel::Unit
virtual const std::string caption () const =0
 The full name of the unit. More...
 
virtual Unitclone () const =0
 
virtual std::pair< double, double > conversionRange () const
 The range where conversion to TOF from given units is monotonic and reversible. More...
 
virtual double conversionTOFMax () const =0
 This function returns maximal TOF value still reversibly convertible into the unit. More...
 
virtual double conversionTOFMin () const =0
 some units can be converted from TOF only in the range of TOF ; This function returns minimal TOF value still reversibly convertible into the unit. More...
 
double convertSingleFromTOF (const double xvalue, const double &l1, const int &emode, const UnitParametersMap &params)
 Convert from the time-of-flight to the concrete unit. More...
 
double convertSingleToTOF (const double xvalue, const double &l1, const int &emode, const UnitParametersMap &params)
 Convert from the concrete unit to time-of-flight. More...
 
void fromTOF (std::vector< double > &xdata, std::vector< double > &ydata, const double &_l1, const int &_emode, const UnitParametersMap &params)
 
void fromTOF (std::vector< double > &xdata, std::vector< double > &ydata, const double &_l1, const int &_emode, std::initializer_list< std::pair< const UnitParams, double > > params)
 Convert from time-of-flight to the concrete unit. More...
 
virtual void init ()=0
 Finalize the initialization. More...
 
void initialize (const double &_l1, const int &_emode, const UnitParametersMap &params)
 Initialize the unit to perform conversion using singleToTof() and singleFromTof() More...
 
virtual bool isConvertible () const
 Returns if the unit can be used in conversions. More...
 
bool isInitialized () const
 
virtual const UnitLabel label () const =0
 A label for the unit to be printed on axes,. More...
 
bool operator!= (const Unit &u) const
 
bool operator== (const Unit &u) const
 
bool quickConversion (const Unit &destination, double &factor, double &power) const
 Is conversion by constant multiplication possible? More...
 
bool quickConversion (std::string destUnitName, double &factor, double &power) const
 Is conversion by constant multiplication possible? More...
 
virtual double singleFromTOF (const double tof) const =0
 Convert a single tof value to this unit. More...
 
virtual double singleToTOF (const double x) const =0
 Convert a single X value to TOF. More...
 
void toTOF (std::vector< double > &xdata, std::vector< double > &ydata, const double &_l1, const int &_emode, const UnitParametersMap &params)
 
void toTOF (std::vector< double > &xdata, std::vector< double > &ydata, const double &_l1, const int &_emode, std::initializer_list< std::pair< const UnitParams, double > > params)
 Convert from the concrete unit to time-of-flight. More...
 
 Unit ()
 (Empty) Constructor More...
 
virtual const std::string unitID () const =0
 The name of the unit. More...
 
virtual ~Unit ()=default
 Virtual destructor. More...
 

Protected Member Functions

void validateUnitParams (const int emode, const UnitParametersMap &params) override
 
- Protected Member Functions inherited from Mantid::Kernel::Unit
void addConversion (std::string to, const double &factor, const double &power=1.0) const
 Add a 'quick conversion' from the unit class on which this method is called. More...
 
virtual void validateUnitParams (const int emode, const UnitParametersMap &params)
 

Protected Attributes

double difa
 
double difc
 
std::string toDSpacingError
 
double tzero
 
- Protected Attributes inherited from Mantid::Kernel::Unit
int emode
 emode :: The energy mode (0=elastic, 1=direct geometry, 2=indirect geometry) More...
 
bool initialized
 The unit values have been initialized. More...
 
double l1
 l1 :: The source-sample distance (in metres) More...
 
const UnitParametersMapm_params
 additional parameters l2 :: distance from sample to detector (in metres) twoTheta :: scattering angle in radians efixed :: Value of fixed energy: EI (emode=1) or EF (emode=2) (in meV) difc :: diffractometer constant DIFC More...
 

Detailed Description

d-Spacing in Angstrom

Definition at line 383 of file Unit.h.

Constructor & Destructor Documentation

◆ dSpacing()

Mantid::Kernel::Units::dSpacing::dSpacing ( )

Constructor.

Definition at line 586 of file Unit.cpp.

Referenced by clone().

Member Function Documentation

◆ calcTofMax()

double Mantid::Kernel::Units::dSpacing::calcTofMax ( const double  difc,
const double  difa,
const double  tzero,
const double  tofmax = 0. 
)

◆ calcTofMin()

double Mantid::Kernel::Units::dSpacing::calcTofMin ( const double  difc,
const double  difa,
const double  tzero,
const double  tofmin = 0. 
)

◆ caption()

const std::string Mantid::Kernel::Units::dSpacing::caption ( ) const
inlineoverridevirtual

The full name of the unit.

Returns
The unit caption

Implements Mantid::Kernel::Unit.

Definition at line 386 of file Unit.h.

◆ clone()

Unit * Mantid::Kernel::Units::dSpacing::clone ( ) const
overridevirtual
Returns
a cloned instance of the other

Implements Mantid::Kernel::Unit.

Definition at line 594 of file Unit.cpp.

References dSpacing().

◆ conversionTOFMax()

double Mantid::Kernel::Units::dSpacing::conversionTOFMax ( ) const
overridevirtual

This function returns maximal TOF value still reversibly convertible into the unit.

Implements Mantid::Kernel::Unit.

Definition at line 740 of file Unit.cpp.

References difa, difc, singleToTOF(), and tzero.

Referenced by calcTofMax().

◆ conversionTOFMin()

double Mantid::Kernel::Units::dSpacing::conversionTOFMin ( ) const
overridevirtual

some units can be converted from TOF only in the range of TOF ; This function returns minimal TOF value still reversibly convertible into the unit.

Implements Mantid::Kernel::Unit.

Definition at line 725 of file Unit.cpp.

References difa, difc, singleToTOF(), and tzero.

Referenced by calcTofMin().

◆ init()

void Mantid::Kernel::Units::dSpacing::init ( )
overridevirtual

◆ label()

const UnitLabel Mantid::Kernel::Units::dSpacing::label ( ) const
overridevirtual

A label for the unit to be printed on axes,.

See also
UnitLabel
Returns
The unit label

Implements Mantid::Kernel::Unit.

Definition at line 592 of file Unit.cpp.

References Mantid::Kernel::Units::Symbol::Angstrom.

◆ singleFromTOF()

double Mantid::Kernel::Units::dSpacing::singleFromTOF ( const double  tof) const
overridevirtual

DIFA * d^2 + DIFC * d + T0 - TOF = 0.

Use the citardauq formula to solve quadratic in order to minimise loss of precision. citardauq (quadratic spelled backwards) is an alternate formulation of the quadratic formula. DIFC and sqrt term are often similar and the "classic" quadratic formula involves calculating their difference in the numerator

          2*(T0 - TOF)                                            (T0 - TOF)

d = ----------------------------------------— = ------------------------------------------------— -DIFC -+ SQRT(DIFC^2 - 4*DIFA*(T0 - TOF)) 0.5 * DIFC (-1 -+ SQRT(1 - 4*DIFA*(T0 - TOF)/DIFC^2)

the variables in this formulation are the same as the quadratic formula a = difa square term b = DIFC linear term - assumed to be positive c = T0 - TOF constant term

Implements Mantid::Kernel::Unit.

Definition at line 675 of file Unit.cpp.

References difa, difc, Mantid::Kernel::Unit::isInitialized(), toDSpacingError, and tzero.

Referenced by Mantid::Algorithms::PDCalibration::exec().

◆ singleToTOF()

double Mantid::Kernel::Units::dSpacing::singleToTOF ( const double  x) const
overridevirtual

Convert a single X value to TOF.

Parameters
xvalue to convert
Returns
the TOF as converted.

Implements Mantid::Kernel::Unit.

Definition at line 649 of file Unit.cpp.

References difa, difc, Mantid::Kernel::Unit::isInitialized(), tzero, and Mantid::Geometry::x.

Referenced by conversionTOFMax(), and conversionTOFMin().

◆ unitID()

const std::string Mantid::Kernel::Units::dSpacing::unitID ( ) const
overridevirtual

"dSpacing"

Implements Mantid::Kernel::Unit.

Referenced by validateUnitParams().

◆ validateUnitParams()

void Mantid::Kernel::Units::dSpacing::validateUnitParams ( const int  emode,
const UnitParametersMap params 
)
overrideprotectedvirtual

Member Data Documentation

◆ difa

double Mantid::Kernel::Units::dSpacing::difa
protected

◆ difc

double Mantid::Kernel::Units::dSpacing::difc
protected

◆ toDSpacingError

std::string Mantid::Kernel::Units::dSpacing::toDSpacingError
protected

Definition at line 402 of file Unit.h.

Referenced by singleFromTOF(), and validateUnitParams().

◆ tzero

double Mantid::Kernel::Units::dSpacing::tzero
protected

The documentation for this class was generated from the following files: