19 #ifndef _OBJCRYST_SCATTERINGDATA_H_
20 #define _OBJCRYST_SCATTERINGDATA_H_
22 #include "ObjCryst/CrystVector/CrystVector.h"
24 #include "ObjCryst/ObjCryst/General.h"
26 #include "ObjCryst/ObjCryst/SpaceGroup.h"
27 #include "ObjCryst/ObjCryst/ScatteringPower.h"
28 #include "ObjCryst/ObjCryst/Scatterer.h"
29 #include "ObjCryst/ObjCryst/Crystal.h"
41 #ifndef HAVE_SSE_MATHFUN
43 void InitLibCrystTabulCosine();
44 void DeleteLibCrystTabulCosine();
45 void InitLibCrystTabulExp();
46 void DeleteLibCrystTabulExp();
83 extern const RefParType *gpRefParTypeRadiation;
84 extern const RefParType *gpRefParTypeRadiationWavelength;
93 #ifndef HAVE_SSE_MATHFUN
94 InitLibCrystTabulCosine();
95 InitLibCrystTabulExp();
115 gpRefParTypeRadiationWavelength=
new RefParType(gpRefParTypeRadiation,
"Wavelength");
122 #ifndef HAVE_SSE_MATHFUN
123 DeleteLibCrystTabulCosine();
124 DeleteLibCrystTabulExp();
139 delete gpRefParTypeRadiation;
140 delete gpRefParTypeRadiationWavelength;
154 gpRefParTypeRadiation=0;
155 gpRefParTypeRadiationWavelength=0;
204 Radiation(
const string &XRayTubeElementName,
const REAL alpha2Alpha2ratio=0.5);
244 void SetWavelength(
const string &XRayTubeElementName,
const REAL alpha2Alpha2ratio=0.5);
255 virtual void XMLOutput(ostream &os,
int indent=0)
const;
260 REAL GetLinearPolarRate()
const;
261 void SetLinearPolarRate(
const REAL f);
333 virtual void SetHKL(
const CrystVector_REAL &h,
334 const CrystVector_REAL &k,
335 const CrystVector_REAL &l);
352 const bool unique=
false);
372 const bool unique=
false);
393 const CrystVector_REAL&
GetH()
const;
395 const CrystVector_REAL&
GetK()
const;
397 const CrystVector_REAL&
GetL()
const;
400 const CrystVector_REAL&
GetH2Pi()
const;
403 const CrystVector_REAL&
GetK2Pi()
const;
406 const CrystVector_REAL&
GetL2Pi()
const;
408 const CrystVector_REAL&
GetReflX()
const;
410 const CrystVector_REAL&
GetReflY()
const;
412 const CrystVector_REAL&
GetReflZ()
const;
418 const CrystVector_REAL&
GetTheta()
const;
424 std::map<RefinablePar*, CrystVector_REAL> & GetFhklCalcSq_FullDeriv(std::set<RefinablePar *> &vPar);
466 const bool enableRestraints=
false);
485 virtual void SetHKL(
const CrystVector_REAL &h,
486 const CrystVector_REAL &k,
487 const CrystVector_REAL &l)
const;
504 const bool unique=
false)
const;
524 const bool unique=
false)
const;
551 virtual const CrystMatrix_REAL&
GetBMatrix()
const;
576 void CalcStructFactor_FullDeriv(std::set<RefinablePar *> &vPar);
582 void CalcGeomStructFactor_FullDeriv(std::set<RefinablePar*> &vPar);
596 mutable CrystVector_REAL
mH, mK, mL ;
598 mutable CrystVector_long
mIntH, mIntK, mIntL ;
600 mutable CrystVector_REAL
mH2Pi, mK2Pi, mL2Pi ;
602 mutable CrystVector_REAL
mX, mY, mZ ;
615 mutable std::map<RefinablePar*, CrystVector_REAL> mFhklCalcReal_FullDeriv, mFhklCalcImag_FullDeriv ;
618 mutable std::map<RefinablePar*, CrystVector_REAL> mFhklCalcSq_FullDeriv;
657 mutable map<const ScatteringPower*,REAL>
mvFprime,mvFsecond;
666 mutable map<const ScatteringPower*,CrystVector_REAL>
mvRealGeomSF,mvImagGeomSF;
667 mutable map<RefinablePar*,map<const ScatteringPower*,CrystVector_REAL> > mvRealGeomSF_FullDeriv,mvImagGeomSF_FullDeriv;
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
const RefParType * gpRefParTypeScattDataCorrIntPO_Direction
Parameter type for preferred orientation direction.
const RefParType * gpRefParTypeScattDataScale
Type for scattering data scale factors.
const RefParType * gpRefParTypeScattDataProfileWidth
Type for reflection profile width.
RadiationType
Type of radiation used.
const RefParType * gpRefParTypeScattDataCorrIntAbsorp
Parameter type for absorption correction.
WavelengthType
Incident beam characteristics : monochromatic, X-Ray tube with Alpha1 and alpha2, MAD (a few waveleng...
const RefParType * gpRefParTypeScattDataCorrPos
Parameter type for correction to peak positions.
const RefParType * gpRefParTypeScattDataProfile
Type for reflection profile.
const RefParType * gpRefParTypeScattDataCorrIntPO_Fraction
Parameter type for fraction of preferred orientation.
const RefParType * gpRefParTypeScattDataBackground
Parameter type for background intensity.
const RefParType * gpRefParTypeObjCryst
Top RefParType for the ObjCryst++ library.
const RefParType * gpRefParTypeScattDataCorr
Generic type for scattering data correction parameter.
const RefParType * gpRefParTypeScattDataProfileType
Type for reflection profiles type (e.g. gaussian/lorentzian mix)
const RefParType * gpRefParTypeScattDataCorrInt_Ellipsoid
Parameter type for the ellipsoid coefficient.
const RefParType * gpRefParTypeScattDataCorrIntPO_Amplitude
Parameter type for the amplitude of preferred orientation.
const RefParType * gpRefParTypeScattDataCorrInt
Generic type for correction to calculated intensities.
const RefParType * gpRefParTypeScattDataProfileAsym
Type for reflection profile asymmetry.
const RefParType * gpRefParTypeScattData
Generic type for scattering data.
const RefParType * gpRefParTypeScattDataCorrIntPolar
Parameter type for polarization correction.
const RefParType * gpRefParTypeScattDataCorrIntExtinc
Parameter type for extinction correction.
Crystal class: Unit cell, spacegroup, scatterers.
Class to define the radiation (type, monochromaticity, wavelength(s)) of an experiment.
REAL mLinearPolarRate
Linear Polarization Rate (default:0, X-Ray tube unmonochromatized)
void Print() const
Print to screen/console the charcteristics of the radiation.
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
CrystVector_REAL mWavelength
Wavelength of the Experiment, in Angstroems.
string mXRayTubeName
Name of the X-Ray tube used, if relevant.
RefObjOpt mRadiationType
Neutron ? X-Ray ? (Electron: unimplemented)
REAL GetXRayTubeAlpha2Alpha1Ratio() const
Get the Kalpha2/Kalpha1 ratio.
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
WavelengthType GetWavelengthType() const
Get the Wavelength type (monochromatic, Alpha1+Alpha2, Time Of Flight...)
REAL mXRayTubeDeltaLambda
Absolute difference between alpha1 and alpha2, in angstroems.
const CrystVector_REAL & GetWavelength() const
Get the wavelength(s) in Angstroems.
REAL mXRayTubeAlpha2Alpha1Ratio
Ratio alpha2/alpha1 (should be 0.5)
REAL GetXRayTubeDeltaLambda() const
Get the wavelength difference for Alpha1 and Alpha2.
const RefinableObjClock & GetClockWavelength() const
Last time the wavelength has been changed.
void SetRadiationType(const RadiationType)
Set the radiation type (X-Rays, Neutron)
RefObjOpt mWavelengthType
monochromatic ? Alpha1 & Alpha2 ? Multi-Wavelength ?
const RefinableObjClock & GetClockRadiation() const
Last time the nature (X-Rays/Neutron, number of wavelengths)radiation has been changed.
Radiation()
Default constructor.
void SetWavelength(const REAL)
Set the (monochromatic) wavelength of the beam.
virtual const string & GetClassName() const
Name for this class ("RefinableObj", "Crystal",...).
void SetWavelengthType(const WavelengthType &type)
Set the Wavelength type (monochromatic, Alpha1+Alpha2, Time Of Flight...)
RadiationType GetRadiationType() const
Get the radiation type (X-Rays, Neutron)
Class to compute structure factors for a set of reflections and a Crystal.
long mNbReflUsed
Number of reflections which are below the max.
RefinableObjClock mClockNbReflUsed
Clock recording the last time the number of reflections used has increased.
virtual void SetHKL(const CrystVector_REAL &h, const CrystVector_REAL &k, const CrystVector_REAL &l)
input H,K,L
CrystVector_REAL mSinThetaLambda
for the crystal and the reflections in ReciprSpace
const RefinableObjClock & GetClockNbReflBelowMaxSinThetaOvLambda() const
Clock the last time the number of reflections used was changed.
map< const ScatteringPower *, CrystVector_REAL > mvScatteringFactor
Scattering factors for each ScatteringPower, as vectors with NbRefl elements.
map< const ScatteringPower *, REAL > mvFprime
Anomalous X-Ray scattering term f' and f" are stored here for each ScatteringPower We store here only...
virtual const Radiation & GetRadiation() const =0
Get the radiation object for this data.
const map< const ScatteringPower *, CrystVector_REAL > & GetScatteringFactor() const
Scattering factors for each ScatteringPower, as vectors with NbRefl elements.
REAL mGlobalBiso
Global Biso, affecting the overall structure factor for all reflections (but not the structure factor...
RefinableObjClock mClockStructFactor
Clock for the structure factor.
virtual void PrintFhklCalc(ostream &os=cout) const
Print H, K, L F^2 Re(F) Im(F) theta sin(theta)/lambda for all reflections.
void CalcGeomStructFactor() const
Compute the 'Geometrical Structure Factor' for each ScatteringPower of the Crystal.
RefinableObjClock mClockFhklObsSq
Last time observed squared structure factors were altered.
RefinableObjClock mClockGlobalTemperatureFact
last time the global temperature factor was computed
const CrystVector_REAL & GetH2Pi() const
Return the 1D array of H coordinates for all reflections, multiplied by 2*pi.
RefinableObjClock mClockTheta
Clock the last time theta was computed.
const CrystVector_REAL & GetSinThetaOverLambda() const
Return an array with for all reflections.
const CrystVector_REAL & GetK() const
Return the 1D array of K coordinates for all reflections.
void CalcScattFactor() const
REAL GetMaxSinThetaOvLambda() const
Get the maximum value for sin(theta)/lambda.
bool mIgnoreImagScattFact
Ignore imaginary part of scattering factor.
virtual void GenHKLFullSpace(const REAL maxTheta, const bool unique=false)
Generate a list of h,k,l to describe a full reciprocal space, up to a given maximum theta value.
CrystVector_REAL GetWavelength() const
wavelength of the experiment (in Angstroems)
void CalcLuzzatiFactor() const
Calculate the Luzzati factor associated to each ScatteringPower and each reflection,...
RefinableObjClock mClockThermicFact
Clock the last time temperature factors were computed.
bool IsIgnoringImagScattFact() const
If true, then the imaginary part of the scattering factor is ignored during Structure factor computat...
virtual void PrepareHKLarrays() const
const CrystVector_REAL & GetL2Pi() const
Return the 1D array of L coordinates for all reflections, multiplied by 2*pi.
const CrystVector_REAL & GetTheta() const
Return an array with theta values for all reflections.
const CrystVector_REAL & GetReflZ() const
Return the 1D array of orthonormal z coordinates for all reflections (recipr. space)
virtual void SetMaxSinThetaOvLambda(const REAL max)
Set the maximum value for sin(theta)/lambda.
virtual void SetCrystal(Crystal &crystal)
Set the crystal for this experiment.
virtual void SetApproximationFlag(const bool allow)
Enable or disable numerical approximations.
CrystVector_REAL mFhklCalcSq
F(HKL)^2 calc for each reflection.
void CalcStructFactVariance() const
Calculate the variance associated to the calculated structure factor.
const CrystVector_REAL & GetReflX() const
Return the 1D array of orthonormal x coordinates for all reflections (recipr. space)
virtual void GenHKLFullSpace2(const REAL maxsithsl, const bool unique=false)
Generate a list of h,k,l to describe a full reciprocal space, up to a given maximum theta value.
RefinableObjClock mClockStructFactorSq
Clock for the square modulus of the structure factor.
map< const ScatteringPower *, CrystVector_REAL > mvTemperatureFactor
Thermic factors for each ScatteringPower, as vectors with NbRefl elements.
const CrystVector_REAL & GetH() const
Return the 1D array of H coordinates for all reflections.
CrystVector_REAL mFhklObsSq
Observed squared structure factors (zero-sized if none)
const CrystVector_REAL & GetFhklCalcSq() const
Returns the Array of calculated |F(hkl)|^2 for all reflections.
void CalcGlobalTemperatureFactor() const
Compute the overall temperature factor affecting all reflections.
const CrystVector_REAL & GetFhklObsSq() const
Returns the vector of observed |F(hkl)|^2 for all reflections.
RadiationType GetRadiationType() const
Neutron or x-ray experiment ? Wavelength ?
bool mUseFastLessPreciseFunc
Use faster, but less precise, approximations for functions? (integer approximations to compute sin an...
virtual CrystVector_long SortReflectionBySinThetaOverLambda(const REAL maxSTOL=-1.) const
const RefinableObjClock & GetClockTheta() const
Clock the last time the sin(theta)/lambda and theta arrays were re-computed.
bool HasCrystal() const
Has a Crystal structure associated yet ?
CrystVector_int mExpectedIntensityFactor
Expected intensity factor for all reflections.
CrystVector_REAL mFhklCalcReal
real &imaginary parts of F(HKL)calc
CrystVector_REAL mFhklCalcVariance
The variance on all calculated structure factors, taking into account the positionnal errors and the ...
map< const ScatteringPower *, CrystVector_REAL > mvLuzzatiFactor
The Luzzati 'D' factor for each scattering power and each reflection.
Crystal * mpCrystal
Pointer to the crystal corresponding to this experiment.
RefinableObjClock mClockScattFactor
Clock the last time scattering factors were computed.
virtual void CalcResonantScattFactor() const
CrystVector_REAL mX
reflection coordinates in an orthonormal base
virtual ScatteringData * CreateCopy() const =0
So-called virtual copy constructor.
map< const ScatteringPower *, CrystVector_REAL > mvRealGeomSF
Geometrical Structure factor for each ScatteringPower, as vectors with NbRefl elements.
virtual void CalcSinThetaLambda() const
const CrystVector_REAL & GetL() const
Return the 1D array of L coordinates for all reflections.
RefinableObjClock mClockGlobalBiso
last time the global Biso factor was modified
void CalcStructFactor() const
Compute the overall structure factor (real and imaginary part).
long mNbRefl
Number of H,K,L reflections.
const CrystVector_REAL & GetFhklCalcImag() const
Access to imaginary part of F(hkl)calc.
virtual const CrystMatrix_REAL & GetBMatrix() const
Get access to the B matrix used to compute reflection positions.
CrystVector_REAL mH
H,K,L coordinates.
CrystVector_long mIntH
H,K,L integer coordinates.
CrystVector_long EliminateExtinctReflections()
REAL mMaxSinThetaOvLambda
Maximum sin(theta)/lambda for all calculations (10 by default).
void SetFhklObsSq(const CrystVector_REAL &obs)
Set the vector of observed |F(hkl)|^2 for all reflections.
virtual void PrintFhklCalcDetail(ostream &os=cout) const
Print H, K, L sin(theta)/lambda theta F^2 Re(F) Im(F) [Re(F) Im(F)]_i, where [Re(F) Im(F)]_i are the ...
RefinableObjClock mClockGeomStructFact
Clock the last time the geometrical structure factors were computed.
void SetIsIgnoringImagScattFact(const bool b)
If true, then the imaginary part of the scattering factor is ignored during Structure factor computat...
const CrystVector_REAL & GetReflY() const
Return the 1D array of orthonormal y coordinates for all reflections (recipr. space)
CrystVector_REAL mTheta
theta for the crystal and the HKL in ReciprSpace (in radians)
long GetNbRefl() const
Return the number of reflections in this experiment.
virtual long GetNbReflBelowMaxSinThetaOvLambda() const
Recalc, and get the number of reflections which should be actually used, due to the maximuml sin(thet...
CrystVector_REAL mGlobalTemperatureFactor
Global Biso factor.
void CalcTemperatureFactor() const
const Crystal & GetCrystal() const
Const access to the data's crystal.
RefinableObjClock mClockScattFactorResonant
Clock the last time resonant scattering factors were computed.
virtual void EndOptimization()
This should be called by any optimization class at the end of an optimization.
const CrystVector_REAL & GetFhklCalcReal() const
Access to real part of F(hkl)calc.
CrystVector_REAL mH2Pi
H,K,L coordinates, multiplied by 2PI.
const CrystVector_REAL & GetK2Pi() const
Return the 1D array of K coordinates for all reflections, multiplied by 2*pi.
RefinableObjClock mClockHKL
Clock for the list of hkl.
virtual void BeginOptimization(const bool allowApproximations=false, const bool enableRestraints=false)
This should be called by any optimization class at the begining of an optimization.
CrystVector_int mMultiplicity
Multiplicity for each reflections (mostly for powder diffraction)
class to input or output a well-formatted xml beginning or ending tag.
class of refinable parameter types.
We need to record exactly when refinable objects have been modified for the last time (to avoid re-co...
Generic Refinable Object.
Abstract base class for all objects in wxCryst.
WX Class for DiffractionDataSingleCrystal objects.
WX Class for PowderPattern objects.