Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   Related Pages  

ScatteringData.h

00001 #ifndef _OBJCRYST_SCATTERINGDATA_H_
00002 #define _OBJCRYST_SCATTERINGDATA_H_
00003 
00004 #include "CrystVector/CrystVector.h"
00005 
00006 #include "ObjCryst/General.h"
00007 
00008 #include "ObjCryst/SpaceGroup.h"
00009 #include "ObjCryst/ScatteringPower.h"
00010 #include "ObjCryst/Scatterer.h"
00011 #include "ObjCryst/Crystal.h"
00012 
00013 //#include <stdlib.h>
00014 #include <string>
00015 //#include <iomanip>
00016 //#include <cmath>
00017 //#include <typeinfo>
00018 //#include <fstream>
00019 //#include <ctime>
00020 
00021 namespace ObjCryst
00022 {
00023 extern const RefParType *gpRefParTypeScattData;
00024 extern const RefParType *gpRefParTypeScattDataScale;
00025 extern const RefParType *gpRefParTypeScattDataProfile;
00026 extern const RefParType *gpRefParTypeScattDataProfileType;
00027 extern const RefParType *gpRefParTypeScattDataProfileWidth;
00028 extern const RefParType *gpRefParTypeScattDataProfileAsym;
00029 extern const RefParType *gpRefParTypeScattDataCorr;
00030 extern const RefParType *gpRefParTypeScattDataCorrInt;
00031 extern const RefParType *gpRefParTypeScattDataCorrIntAbsorp;
00032 extern const RefParType *gpRefParTypeScattDataCorrIntPolar;
00033 extern const RefParType *gpRefParTypeScattDataCorrIntExtinc;
00034 extern const RefParType *gpRefParTypeScattDataCorrPos;
00035 extern const RefParType *gpRefParTypeScattDataBackground;
00036 
00037 extern const RefParType *gpRefParTypeRadiation;
00038 extern const RefParType *gpRefParTypeRadiationWavelength;
00039 
00040 //######################################################################
00051 //######################################################################
00052 class Radiation: public RefinableObj
00053 {
00054    public:
00056       Radiation();
00063       Radiation(const RadiationType rad,const double wavelength);
00082       Radiation(const string &XRayTubeElementName,const double alpha2Alpha2ratio=0.5);
00084       Radiation(const Radiation&);
00085       ~Radiation();
00086       virtual const string GetClassName() const;
00087       
00088       void operator=(const Radiation&);
00089       
00091       RadiationType GetRadiationType()const;
00093       void SetRadiationType(const RadiationType);
00094       //Get the Wavelength type (monochromatic, Alpha1+Alpha2, ...)
00095       WavelengthType GetWavelengthType()const;
00099       const CrystVector_double& GetWavelength()const;
00101       void SetWavelength(const double );
00120       void SetWavelength(const string &XRayTubeElementName,const double alpha2Alpha2ratio=0.5);
00121       
00123       double GetXRayTubeDeltaLambda()const;
00125       double GetXRayTubeAlpha2Alpha1Ratio()const;
00126       
00128       const RefinableObjClock& GetClockWavelength()const ;
00130       const RefinableObjClock& GetClockRadiation()const ;
00131       virtual void XMLOutput(ostream &os,int indent=0)const;
00132       virtual void XMLInput(istream &is,const XMLCrystTag &tag);
00133       //virtual void XMLInputOld(istream &is,const IOCrystTag &tag);
00135       void Print()const;
00136    private:
00137       void InitOptions();
00139       RefObjOpt mRadiationType;
00141       RefObjOpt mWavelengthType;
00143       CrystVector_double mWavelength;
00146       string mXRayTubeName;
00148       double mXRayTubeDeltaLambda;
00150       double mXRayTubeAlpha2Alpha1Ratio;
00151       //Clocks
00152          RefinableObjClock mClockWavelength;
00153          RefinableObjClock mClockRadiation;
00154    #ifdef __WX__CRYST__
00155    public:
00156       virtual WXCrystObjBasic* WXCreate(wxWindow*);
00157       friend class WXRadiation;
00158    #endif
00159 };
00160 
00161 //######################################################################
00176 //######################################################################
00177 class ScatteringData: virtual public RefinableObj
00178 {
00179    public:
00180       ScatteringData();
00181       ScatteringData(const ScatteringData &old);
00182       ~ScatteringData();
00184       virtual ScatteringData* CreateCopy()const=0;
00185       
00191       virtual void SetHKL( CrystVector_double const &h,
00192                            CrystVector_double const &k,
00193                            CrystVector_double const &l);
00211       virtual void GenHKLFullSpace(const double maxTheta,
00212                                    const bool useMultiplicity=false);
00213       
00215       virtual void SetRadiationType(const RadiationType radiation);
00217       RadiationType GetRadiationType()const;
00218       
00222       virtual void SetCrystal(Crystal &crystal);
00224       const Crystal& GetCrystal()const ;
00226       Crystal& GetCrystal() ;
00227       
00229       long GetNbRefl() const;
00231       const CrystVector_double& GetH() const;
00233       const CrystVector_double& GetK() const;
00235       const CrystVector_double& GetL() const;
00238       const CrystVector_double& GetH2Pi() const;
00241       const CrystVector_double& GetK2Pi() const;
00244       const CrystVector_double& GetL2Pi() const;
00245       
00248       const CrystVector_double& GetSinThetaOverLambda()const;
00249    
00251       const CrystVector_double& GetFhklCalcSq() const;
00253       const CrystVector_double& GetFhklCalcReal() const;
00255       const CrystVector_double& GetFhklCalcImag() const;
00256       
00259       void SetWavelength(const double lambda);
00260       
00279       void SetWavelength(const string &XRayTubeElementName,const double alpha2Alpha1ratio=0.5);
00280       
00283       void SetEnergy(const double energy);
00285       CrystVector_double GetWavelength()const;
00286       
00289       void SetUseFastLessPreciseFunc(const bool useItOrNot);
00296       void SetIsIgnoringImagScattFact(const bool b);
00299       bool IsIgnoringImagScattFact() const;
00300       // Set an option so that only low-amgle reflections (theta < angle)
00301       // are used. See DiffractionData::mUseOnlyLowAngleData
00302       //virtual void SetUseOnlyLowAngleData(const bool useOnlyLowAngle,const double angle)=0;
00306       virtual void PrintFhklCalc()const;
00307 
00308    protected:
00311       virtual void PrepareHKLarrays() ;
00315       CrystVector_long SortReflectionByTheta(const double maxTheta=-1.);
00323       CrystVector_long EliminateExtinctReflections();
00324       
00325       //The following functions are used during the calculation of structure factors,
00333          virtual void PrepareCalcStructFactor()const;
00337          virtual void CalcSinThetaLambda()const;
00339          void CalcScattFactor()const;
00341          void CalcTemperatureFactor()const;
00345          virtual void CalcResonantScattFactor()const;
00346          
00358       void CalcStructFactor() const;
00359 
00364       void CalcGeomStructFactor(const ScatteringComponentList &scattCompList,
00365                                 const SpaceGroup &spg,
00366                                 const CrystVector_long &structFactorIndex,
00367                                 CrystVector_double* rsf2,
00368                                 CrystVector_double* isf2,
00369                                 bool useFastTabulatedTrigFunctions=false) const;
00370       
00372       long mNbRefl;
00374       CrystVector_double mH, mK, mL ;
00376       mutable CrystVector_long mIntH, mIntK, mIntL ;
00378       mutable CrystVector_double mH2Pi, mK2Pi, mL2Pi ;
00379 
00381       CrystVector_int mMultiplicity ;
00382       
00384       mutable CrystVector_double mFhklCalcReal, mFhklCalcImag ;
00386       mutable CrystVector_double mFhklCalcSq ;
00387       
00389       Radiation mRadiation;
00390       
00396       Crystal *mpCrystal;
00397       
00401       bool mUseFastLessPreciseFunc;
00402       
00403       //The Following members are only kept to avoid useless re-computation
00404       //during global refinements. They are used \b only by CalcStructFactor() 
00405       
00408          mutable CrystVector_double mSinThetaLambda;
00409 
00411          mutable CrystVector_double mTheta;
00412 
00415          mutable CrystVector_double mTanTheta;
00416 
00419          mutable CrystVector_double mFprime,mFsecond;
00420 
00422          mutable CrystVector_double* mpTemperatureFactor;
00423 
00425          mutable CrystVector_double* mpScatteringFactor;
00426       
00428          mutable CrystVector_double* mpRealGeomSF,*mpImagGeomSF;
00429       
00430       //Public Clocks
00432          RefinableObjClock mClockHKL;
00434          mutable RefinableObjClock mClockStructFactor;
00436          mutable RefinableObjClock mClockStructFactorSq;
00437       //Internal Clocks
00439          mutable RefinableObjClock mClockTheta;
00441          mutable RefinableObjClock mClockScattFactor;
00443          mutable RefinableObjClock mClockScattFactorResonant;
00445          mutable RefinableObjClock mClockGeomStructFact;
00447          mutable RefinableObjClock mClockThermicFact;
00448       
00449       // Info about the Scattering components and powers
00451          mutable const ScatteringComponentList* mpScattCompList;
00456          mutable CrystVector_long mScatteringPowerIndex;
00458          mutable CrystVector_long mScatteringPowerIndex2;
00460          mutable long mNbScatteringPower;
00461       // :TODO: This must be replaced by Clocks...
00462          mutable ScatteringComponentList mLastScattCompList;
00463          mutable bool mAnomalousNeedRecalc;
00464          mutable bool mThermicNeedRecalc;
00465          mutable bool mScattFactNeedRecalc;
00466          mutable bool mGeomFhklCalcNeedRecalc;
00467          mutable bool mFhklCalcNeedRecalc;
00468 
00481       bool mIgnoreImagScattFact;
00482       
00483       // Use only low angle data UNIMPLEMENTED
00484          /* \brief Flag forcing the use of only low-angle reflections
00485          *
00486          * Mainly for use during global optimizations, or more generally when
00487          * the program is far from the real structure. In this case high-angle reflection
00488          * are not significant and only lead to slower calculations and also in fooling
00489          * the optimization (bad agreement at low angle and good with the more numerous
00490          * high-angle reflections). By default this is set to \b false.
00491          *
00492          * This is intended for use mainly for powder diffraction but \e can also implemented
00493          * for other DiffractionData objects. (if not implemented, it should return
00494          * an exception).
00495          *
00496          * Practically, this means that any reflections below 
00497          * DiffractionData::mLowAngleReflectionLimit is simply ignored, not calculated,
00498          * not taken into account in statistics. But they should remain present in hkl arrays.
00499          *
00500          * Caveheat: for powder diffraction, a reflection just above the angular limit
00501          * will not be calculated but may be take partially into account in statistics.
00502          *
00503          * \warning This should only be used at the beginning of an optimization.
00504          *
00505          * \How this is done: when this flag is raised, a copy of all necessary data
00506          * (observed, sigmas, hkl arrays) is made, and stored until the flag is unraised.
00507          *
00508          * This may eventually be moved to inherited classes.
00509          */
00510          //bool mUseOnlyLowAngleData;
00511 
00512          /* \brief Limit (theta angle, radian) for the above option.
00513          *
00514          */
00515          //double mUseOnlyLowAngleDataLimit;
00516 };
00517 
00518 }//namespace ObjCryst
00519 #endif // _OBJCRYST_SCATTERINGDATA_H_

Generated on Wed Nov 14 19:48:36 2001 for ObjCryst++ by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001