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

ObjCryst::DiffractionDataSingleCrystal Class Reference

DiffractionData object for Single Crystal analysis. More...

Inheritance diagram for ObjCryst::DiffractionDataSingleCrystal:

ObjCryst::ScatteringData ObjCryst::RefinableObj List of all members.

Public Methods

 DiffractionDataSingleCrystal (Crystal &cryst)
 Constructor, with an assigned crystal structure.

 DiffractionDataSingleCrystal (const DiffractionDataSingleCrystal &old)
 Copy constructor.

virtual DiffractionDataSingleCrystal * CreateCopy () const
 So-called virtual copy constructor.

virtual const string & GetClassName () const
 Name for this class ("RefinableObj", "Crystal",...).

const CrystVector_REAL & GetIcalc () const
 returns the calculated diffracted intensity.

const CrystVector_REAL & GetIobs () const
 Return the array of observed intensities for all peaks.

void SetIobs (const CrystVector_REAL &)
 Return the array of observed intensities for all peaks.

const CrystVector_REAL & GetSigma () const
 Return the array of sigmas for observed intensities, for all peaks.

void SetSigma (const CrystVector_REAL &)
 Return the array of sigmas for observed intensities, for all peaks.

void SetIobsToIcalc ()
 Set Iobs to current values of Icalc. Mostly used for tests.

const CrystVector_REAL & GetWeight () const
 Return the weights (for each reflection) used for computing Rw.

void SetWeight (const CrystVector_REAL &)
 Change the weights (for each reflection) used for computing Rw.

void SetHklIobs (const CrystVector_long &h, const CrystVector_long &k, const CrystVector_long &l, const CrystVector_REAL &iObs, const CrystVector_REAL &sigma)
 input H,K,L, Iobs and Sigma

void ImportHklIobs (const string &fileName, const long nbRefl, const int skipLines=0)
 Import h,k,l,I form a file.

void ImportHklIobsSigma (const string &fileName, const long nbRefl, const int skipLines=0)
 Import h,k,l,I,Sigma form a file.

void ImportHklIobsSigmaJanaM91 (const string &fileName)
 Import h,k,l,I,Sigma form a Jana98 '*.m91' file.

virtual REAL GetRw () const
 Return the Crystal R-factor (weighted).

virtual REAL GetR () const
 Return the Crystal R-factor (unweighted).

virtual REAL GetChi2 () const
 Return conventionnal Chi^2.

virtual void FitScaleFactorForRw ()
 Compute the best scale factor minimising Rw.

virtual void FitScaleFactorForR ()
 Compute the best scale factor minimising R.

virtual REAL GetBestRFactor ()
 Compute the best scale factor to minimize R, apply this scale factor and return the R value obtained.

virtual void SetSigmaToSqrtIobs ()
 Set sigma for all observed intensities to sqrt(obs).

virtual void SetWeightToInvSigma2 (const REAL minRelatSigma=1e-4)
 Set the weight for all observed intensities to 1/sigma^2.

REAL GetScaleFactor () const
 Scale factor (applied to Icalc to match Iobs).

virtual void PrintObsData () const
 Print H, K, L Iobs sigma for all reflections.

virtual void PrintObsCalcData () const
 Print H, K, L Iobs sigma Icalc for all reflections Iobs and sigma (if given) are scaled to Icalc (if available).

void SaveHKLIobsIcalc (const string &filename="hklIobsIcalc.out")
 Save H,K,L Iobs Icalc to a file, text format, 3 columns theta Iobs Icalc.

virtual void GlobalOptRandomMove (const REAL mutationAmplitude, const RefParType *type=gpRefParTypeObjCryst)
 Make a random move of the current configuration.

virtual REAL GetLogLikelihood () const
 Get -log(likelihood) of the current configuration for the object.

virtual unsigned int GetNbLSQFunction () const
 Number of LSQ functions.

virtual const CrystVector_REAL & GetLSQCalc (const unsigned int) const
 Get the current calculated value for the LSQ function.

virtual const CrystVector_REAL & GetLSQObs (const unsigned int) const
 Get the observed values for the LSQ function.

virtual const CrystVector_REAL & GetLSQWeight (const unsigned int) const
 Get the weight values for the LSQ function.

virtual void XMLOutput (ostream &os, int indent=0) const
 Output to stream in well-formed XML.

virtual void XMLInput (istream &is, const XMLCrystTag &tag)
 Input From stream.

virtual const RadiationGetRadiation () const
 Get the radiation object for this data.

virtual void SetRadiationType (const RadiationType radiation)
 Set : neutron or x-ray experiment ? Wavelength ?

void SetWavelength (const REAL)
 Set the (monochromatic) wavelength of the beam.

void SetWavelength (const string &XRayTubeElementName, const REAL alpha2Alpha2ratio=0.5)
 \ brief Set X-Ray tube radiation.

void SetEnergy (const REAL)
 Set the (monochromatic) energy of the beam.


Private Methods

void CalcIcalc () const
 Calc intensities.

virtual CrystVector_long SortReflectionByTheta (const REAL maxTheta=-1.)
void InitOptions ()
 Init options (currently only twinning).

void PrepareTwinningCalc () const
 Determine the index of reflections to be summed because of twinning.


Private Attributes

bool mHasObservedData
 Are there observed intensities ?

CrystVector_REAL mObsIntensity
 Observed intensity (after ABS and LP corrections).

CrystVector_REAL mObsSigma
 Sigma for observed intensities (either individual reflections or spectrum).

CrystVector_REAL mWeight
 weight for computing R-Factor, for each observed value.

CrystVector_REAL mCalcIntensity
 Calculated intensities.

REAL mScaleFactor
 Scale factor.

REAL mChi2
 Chi^2.

RefinableObjClock mClockIcalc
 Last time Icalc was computed.

RefinableObjClock mClockScaleFactor
 Last modification of the scale factor.

RefinableObjClock mClockChi2
 Clock the last time Chi^2 was computed.

RefObjOpt mTwinningOption
 Option for the type of twinning.

CrystVector_REAL mTwinnedIobsSum
 The observed intensities summed on all reflections that are (or could be) overlapped dur to a twinning.

CrystVector_REAL mTwinnedIcalcSum
 The calculated intensities summed on all reflections that are (or could be) overlapped dur to a twinning.

CrystVector_REAL mTwinnedWeight
 The weight on each reflection sum in case of twinning.

CrystVector_long mTwinnedGroupIndex
 The index of reflections which need to be summed.

RefinableObjClock mClockPrepareTwinningCorr
 Clock for twinning, when the preparation of twiinning correction was last made.


Detailed Description

DiffractionData object for Single Crystal analysis.

Currently this handles only in the simplest way single crystal dat: ie only data which has been completely corrected for Lorentz/Polarization and absorption.

What needs to be developped: define the geometry of the experiment (incident and emerging angles), the polarization of the beam, etc...


Member Function Documentation

virtual void ObjCryst::DiffractionDataSingleCrystal::FitScaleFactorForR   [virtual]
 

Compute the best scale factor minimising R.

The computed scale factor is immediatly applied to Icalc

virtual void ObjCryst::DiffractionDataSingleCrystal::FitScaleFactorForRw   [virtual]
 

Compute the best scale factor minimising Rw.

The computed scale factor is immediatly applied to Icalc

virtual REAL ObjCryst::DiffractionDataSingleCrystal::GetChi2   [virtual]
 

Return conventionnal Chi^2.

Returns:

virtual const string& ObjCryst::DiffractionDataSingleCrystal::GetClassName   [virtual]
 

Name for this class ("RefinableObj", "Crystal",...).

This is only useful to distinguish different classes when picking up objects from the RefinableObj Global Registry

Reimplemented from ObjCryst::RefinableObj.

const CrystVector_REAL& ObjCryst::DiffractionDataSingleCrystal::GetIcalc  
 

returns the calculated diffracted intensity.

This is an array of calculated intensities for each reflections in the single crystal case, and the array with the full powder powder profile for powder diffraction.

virtual REAL ObjCryst::DiffractionDataSingleCrystal::GetLogLikelihood   [virtual]
 

Get -log(likelihood) of the current configuration for the object.

By default (no likelihood evaluation available), this is equal to 0.

This call should not be recursive, it is the task of the algorithm to get the sum of likelihoods for all objects invlolved.

Note:
contrary to the old "Cost Function" approach, with log(Likelihood) there is no 'choice' of cost function, so that it is the task of the object to give the optimized likelihood (possibly with user options).
\warning: this is in under heavy development, so expect changes...

Reimplemented from ObjCryst::RefinableObj.

virtual REAL ObjCryst::DiffractionDataSingleCrystal::GetR   [virtual]
 

Return the Crystal R-factor (unweighted).

Returns:

virtual REAL ObjCryst::DiffractionDataSingleCrystal::GetRw   [virtual]
 

Return the Crystal R-factor (weighted).

Returns:

virtual void ObjCryst::DiffractionDataSingleCrystal::GlobalOptRandomMove const REAL    mutationAmplitude,
const RefParType   type = gpRefParTypeObjCryst
[virtual]
 

Make a random move of the current configuration.

This is for global optimization algorithms. the moves for each parameter are less than their global optimization step, multiplied by the mutation amplitude.

\warning: this makes a random move for the parameter declared for this object, and it is the duty of the object to decide whether the included objects should be moved and how. (eg an algorithm should only call for a move with the top object, and this object decides how he and his sub-objects moves). By default (RefinableObj implementation) all included objects are moved recursively.

RefinableObj::

Parameters:
mutationAmplitude:  multiplier for the maximum move amplitude, for all parameters
type:  restrain the change exclusively to parameters of a given type (same type or descendant from this RefParType).

Reimplemented from ObjCryst::RefinableObj.

void ObjCryst::DiffractionDataSingleCrystal::ImportHklIobs const string &    fileName,
const long    nbRefl,
const int    skipLines = 0
 

Import h,k,l,I form a file.

The file is assumed to correspond to a single crystal diffraction file.

Parameters:
fileName  The name of the data file. This file should be formatted with H,k,l, Iobs separated by spaces.
nbRefl  The number of reflections to extract.
skipLines  The number of lines to skip at the beginning of the file.

void ObjCryst::DiffractionDataSingleCrystal::ImportHklIobsSigma const string &    fileName,
const long    nbRefl,
const int    skipLines = 0
 

Import h,k,l,I,Sigma form a file.

The file is assumed to correspond to a single crystal diffraction file.

Parameters:
fileName  The name of the data file. This file should be formatted with H,k,l, Iobs and Sigma separated by spaces.
nbRefl  The number of reflections to extract.
skipLines  The number of lines to skip at the beginning of the file.

void ObjCryst::DiffractionDataSingleCrystal::ImportHklIobsSigmaJanaM91 const string &    fileName
 

Import h,k,l,I,Sigma form a Jana98 '*.m91' file.

The file is assumed to correspond to a single crystal diffraction file.

Parameters:
fileName  The name of the data file.

void ObjCryst::DiffractionDataSingleCrystal::PrepareTwinningCalc   [private]
 

Determine the index of reflections to be summed because of twinning.

The reflections must have been sorted by increasing theta beforehand.

void ObjCryst::DiffractionDataSingleCrystal::SaveHKLIobsIcalc const string &    filename = "hklIobsIcalc.out"
 

Save H,K,L Iobs Icalc to a file, text format, 3 columns theta Iobs Icalc.

If Iobs is missing, the column is omitted.

void ObjCryst::DiffractionDataSingleCrystal::SetHklIobs const CrystVector_long &    h,
const CrystVector_long &    k,
const CrystVector_long &    l,
const CrystVector_REAL &    iObs,
const CrystVector_REAL &    sigma
 

input H,K,L, Iobs and Sigma

Parameters:
h,k,l:  REAL arrays (vectors with NbRefl elements -same size) with the h, k and l coordinates of all reflections.
iobs,sigma:  REAL arrays (vectors with NbRefl elements -same size) with the Observed intensity and sigma for all reflections.

void ObjCryst::DiffractionDataSingleCrystal::SetWavelength const string &    XRayTubeElementName,
const REAL    alpha2Alpha2ratio = 0.5
 

\ brief Set X-Ray tube radiation.

Parameters:
XRayTubeElementName  : name of the anticathode element name. Known ones are Cr, Fe, Cu, Mo, Ag.
alpha2Alpha2ratio:  Kalpha2/Kalpha1 ratio (0.5 by default)
the average wavelength is calculated using the alpha2/alpha1 weight. All structure factors computation are made using the average wavelength, and for powder diffraction, profiles are output at the alpha1 and alpha2 ratio for the calculated pattern.

NOTE : if the name of the wavelength is generic (eg"Cu"), then the program considers that there are both Alpha1 and Alpha2, and thus automatically changes the WavelengthType to WAVELENGTH_ALPHA12. If instead either alpha1 or alpha2 (eg "CuA1") is asked for, the WavelengthType is set to WAVELENGTH_MONOCHROMATIC. In both cases, the radiation type is set to X-Ray.

virtual void ObjCryst::DiffractionDataSingleCrystal::SetWeightToInvSigma2 const REAL    minRelatSigma = 1e-4 [virtual]
 

Set the weight for all observed intensities to 1/sigma^2.

For sigmas which are smaller than minRelatSigma times the max value of sigma, the output weight is set to 0.

virtual CrystVector_long ObjCryst::DiffractionDataSingleCrystal::SortReflectionByTheta const REAL    maxTheta = -1. [private, virtual]
 

For internal use only.

sort reflections by theta values (also get rid of [0,0,0] if present) If maxTheta >0, then only reflections where theta<maxTheta are kept

Returns:
an array with the subscript of the kept reflections (for inherited classes)

Reimplemented from ObjCryst::ScatteringData.

virtual void ObjCryst::DiffractionDataSingleCrystal::XMLInput istream &    is,
const XMLCrystTag   tag
[virtual]
 

Input From stream.

Todo:
Add an bool XMLInputTag(is,tag) function to recognize all the tags from the stream. So that each inherited class can use the XMLInputTag function from its parent (ie take advantage of inheritance). The children class would first try to interpret the tag, then if unsuccessful would pass it to its parent (thus allowing overloading), etc...

Reimplemented from ObjCryst::RefinableObj.

virtual void ObjCryst::DiffractionDataSingleCrystal::XMLOutput ostream &    os,
int    indent = 0
const [virtual]
 

Output to stream in well-formed XML.

Todo:
Use inheritance.. as for XMLInputTag()...

Reimplemented from ObjCryst::RefinableObj.


Member Data Documentation

CrystVector_REAL ObjCryst::DiffractionDataSingleCrystal::mObsIntensity [private]
 

Observed intensity (after ABS and LP corrections).

In the single crystal case, this is a list of intensity corresponding to (h,k,l). For a powder sample, this is a list of all peaks intensities.

REAL ObjCryst::DiffractionDataSingleCrystal::mScaleFactor [private]
 

Scale factor.

It is applied when computing intensities. The scale applies to intensities

CrystVector_long ObjCryst::DiffractionDataSingleCrystal::mTwinnedGroupIndex [private]
 

The index of reflections which need to be summed.

They must have been sorted by increasing theta values. Each entry marks the beginning of a new batch of reflections to be summed.

CrystVector_REAL ObjCryst::DiffractionDataSingleCrystal::mTwinnedWeight [private]
 

The weight on each reflection sum in case of twinning.

The sum is the inverse of the sum of all sigma^2


The documentation for this class was generated from the following file:
Generated on Wed Jun 25 23:26:11 2003 for ObjCryst++ by doxygen1.2.18