FOX/ObjCryst++  1.10.X (development)
ScatteringPower.h
1 /* ObjCryst++ Object-Oriented Crystallographic Library
2  (c) 2000-2002 Vincent Favre-Nicolin vincefn@users.sourceforge.net
3  2000-2001 University of Geneva (Switzerland)
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 #ifndef _OBJCRYST_SCATTPOWER_H_
20 #define _OBJCRYST_SCATTPOWER_H_
21 
22 #include "ObjCryst/CrystVector/CrystVector.h"
23 #include "ObjCryst/ObjCryst/General.h"
24 #include "ObjCryst/RefinableObj/RefinableObj.h"
25 
26 
27 //#include <stdlib.h>
28 //#include <string>
29 //#include <iomanip>
30 //#include <cmath>
31 //#include <typeinfo>
32 //#include <fstream>
33 //#include <ctime>
34 
35 // forward declaration to avoid including boost headers
36 namespace cctbx { namespace eltbx { namespace xray_scattering {class gaussian;}}}
37 
38 namespace ObjCryst
39 {
40 extern const RefParType *gpRefParTypeScattPow;
41 extern const RefParType *gpRefParTypeScattPowResonant;
42 extern const RefParType *gpRefParTypeScattPowTemperature;
43 extern const RefParType *gpRefParTypeScattPowTemperatureIso;
44 extern const RefParType *gpRefParTypeScattPowTemperatureAniso;
46 {
47  public:
49  {
50  if (mCount++ == 0)
51  {
52  gpRefParTypeScattPow=new RefParType(gpRefParTypeObjCryst,"Scattering Power");
53  gpRefParTypeScattPowResonant=new RefParType(gpRefParTypeScattPow,"Resonant Scatt.");
54  gpRefParTypeScattPowTemperature=new RefParType(gpRefParTypeScattPow,"Temperature");
55  gpRefParTypeScattPowTemperatureIso=new RefParType(gpRefParTypeScattPowTemperature,"Isotropic");
56  gpRefParTypeScattPowTemperatureAniso=new RefParType(gpRefParTypeScattPowTemperatureIso,"Anisotropic");
57  }
58  }
60  {
61  if (--mCount == 0)
62  {
63  delete gpRefParTypeScattPow;
64  delete gpRefParTypeScattPowResonant;
65  delete gpRefParTypeScattPowTemperature;
66  delete gpRefParTypeScattPowTemperatureIso;
67  delete gpRefParTypeScattPowTemperatureAniso;
68  gpRefParTypeScattPow=0;
69  gpRefParTypeScattPowResonant=0;
70  gpRefParTypeScattPowTemperature=0;
71  gpRefParTypeScattPowTemperatureIso=0;
72  gpRefParTypeScattPowTemperatureAniso=0;
73  }
74  }
75  private:
76  static long mCount;
77 };
78 static NiftyStaticGlobalObjectsInitializer_ScatteringPower NiftyStaticGlobalObjectsInitializer_ScatteringPower_counter;
79 
80  class ScatteringData;//forward declaration :KLUDGE: ?
81 //######################################################################
82 //
83 // SCATTERING POWER
109 //######################################################################
110 class ScatteringPower:virtual public RefinableObj
111 {
112  public:
113  ScatteringPower();
114  ScatteringPower(const ScatteringPower& old);
115  virtual ~ScatteringPower();
116  virtual const string& GetClassName() const;
117  virtual void operator=(const ScatteringPower& rhs);
132  virtual CrystVector_REAL GetScatteringFactor(const ScatteringData &data,
133  const int spgSymPosIndex=-1) const=0;
136  virtual REAL GetForwardScatteringFactor(const RadiationType) const=0;
150  virtual CrystVector_REAL GetTemperatureFactor(const ScatteringData &data,
151  const int spgSymPosIndex=-1) const=0;
167  virtual CrystMatrix_REAL GetResonantScattFactReal(const ScatteringData &data,
168  const int spgSymPosIndex=-1) const=0;
184  virtual CrystMatrix_REAL GetResonantScattFactImag(const ScatteringData &data,
185  const int spgSymPosIndex=-1) const=0;
187  virtual bool IsScatteringFactorAnisotropic()const;
189  virtual bool IsTemperatureFactorAnisotropic()const;
191  virtual bool IsResonantScatteringAnisotropic()const;
195  virtual const string& GetSymbol() const;
199  REAL GetBiso() const;
203  REAL& GetBiso();
207  virtual void SetBiso(const REAL newB);
212  REAL GetBij(const size_t &i, const size_t &j) const;
224  REAL GetBij(const size_t &idx) const;
229  virtual void SetBij(const size_t &i, const size_t &j, const REAL newB);
241  virtual void SetBij(const size_t &idx, const REAL newB);
246  bool IsIsotropic()const ;
249  long GetDynPopCorrIndex()const;
251  long GetNbScatteringPower()const;
255  const string& GetColourName()const;
257  const float* GetColourRGB()const;
259  void SetColour(const string& colorName);
261  void SetColour(const float r,const float g,const float b);
264  virtual REAL GetRadius()const=0;
265  virtual void GetGeneGroup(const RefinableObj &obj,
266  CrystVector_uint & groupIndex,
267  unsigned int &firstGroup) const;
273  void SetMaximumLikelihoodPositionError(const REAL mle);
277  void SetMaximumLikelihoodNbGhostAtom(const REAL nb);
281  virtual REAL GetFormalCharge()const;
282  virtual void SetFormalCharge(const REAL charge);
283  protected:
284  virtual void InitRefParList()=0;
286  virtual void Init();
288  virtual void InitRGBColour();
293  REAL mBiso;
301  mutable CrystVector_REAL mBeta;
303  CrystVector_REAL mB;
307  string mColourName;
309  float mColourRGB[3];
310  // Maximum Likelihood
314  RefinableObjClock mMaximumLikelihoodParClock;
325 };
326 
329 
330 //######################################################################
331 //
332 // SCATTERING POWER ATOM
336 //######################################################################
337 
339 {
340  public:
351  ScatteringPowerAtom(const string &name,const string &symbol,const REAL bIso=1.0);
354  virtual const string& GetClassName() const;
356  void Init(const string &name,const string &symbol,const REAL bIso=1.0);
357  virtual CrystVector_REAL GetScatteringFactor(const ScatteringData &data,
358  const int spgSymPosIndex=0) const;
359  virtual REAL GetForwardScatteringFactor(const RadiationType) const;
360  virtual CrystVector_REAL GetTemperatureFactor(const ScatteringData &data,
361  const int spgSymPosIndex=0) const;
362  virtual CrystMatrix_REAL GetResonantScattFactReal(const ScatteringData &data,
363  const int spgSymPosIndex=0) const;
364  virtual CrystMatrix_REAL GetResonantScattFactImag(const ScatteringData &data,
365  const int spgSymPosIndex=0) const;
367  void SetSymbol(const string &symbol) ;
369  virtual const string& GetSymbol() const;
375  string GetElementName() const;
377  int GetAtomicNumber() const;
379  REAL GetRadius() const;
381  REAL GetCovalentRadius() const;
383  unsigned int GetMaxCovBonds() const;
384  virtual void Print()const;
385  virtual void XMLOutput(ostream &os,int indent=0)const;
386  virtual void XMLInput(istream &is,const XMLCrystTag &tag);
387  //virtual void XMLInputOld(istream &is,const IOCrystTag &tag);
388  protected:
393  void InitAtScattCoeffsWK95();
398  virtual void InitRefParList();
404  string mSymbol;
407 
411  cctbx::eltbx::xray_scattering::gaussian *mpGaussian;
412 
419  REAL mNeutronScattLengthReal,mNeutronScattLengthImag;
420 
422  REAL mRadius;
426  unsigned int mMaxCovBonds;
427 
435  private:
436  // Avoid compiler warnings. Explicitly hide the base-class method.
437  void Init();
438  #ifdef __WX__CRYST__
439  public:
440  virtual WXCrystObjBasic* WXCreate(wxWindow*);
441  friend class WXScatteringPowerAtom;
442  #endif
443 };
446 
447 //######################################################################
448 //
449 // SCATTERING COMPONENT
454 //######################################################################
456 {
457  // Default Constructor
459  bool operator==(const ScatteringComponent& rhs)const;
460  bool operator!=(const ScatteringComponent& rhs)const;
462  void Print() const;
464  REAL mX,mY,mZ,mOccupancy;
479  mutable REAL mDynPopCorr;
480  // The scatterer to which this component is associated
481  // Scatterer *mScatterer;
482 };
483 
484 //######################################################################
485 //
486 // SCATTERING COMPONENT LIST
491 //######################################################################
493 {
494  public:
496  ScatteringComponentList(const long nbComponent);
501  void Reset();
503  const ScatteringComponent& operator()(const long i) const;
504  ScatteringComponent& operator()(const long i);
506  long GetNbComponent() const;
508  void operator=(const ScatteringComponentList &rhs);
510  bool operator==(const ScatteringComponentList &rhs)const;
512  void operator+=(const ScatteringComponentList &rhs);
514  void operator+=(const ScatteringComponent &rhs);
516  void operator++();
518  void operator--();
520  void Print() const;
521  protected:
523  vector<ScatteringComponent> mvScattComp;
524 };
525 
526 }//namespace
527 #include "ObjCryst/ObjCryst/ScatteringData.h"
528 
529 #endif //_OBJCRYST_SCATTPOWER_H_
string mColourName
Colour for this ScatteringPower (from POVRay)
virtual REAL GetForwardScatteringFactor(const RadiationType) const
Get the scattering factor at (0,0,0).
virtual CrystMatrix_REAL GetResonantScattFactImag(const ScatteringData &data, const int spgSymPosIndex=0) const
Get the imaginary part of the resonant scattering factor.
virtual CrystVector_REAL GetTemperatureFactor(const ScatteringData &data, const int spgSymPosIndex=0) const
Get the temperature factor for all reflections of a given ScatteringData object.
REAL GetMaximumLikelihoodNbGhostAtom() const
Maximum Likelihood: get the number of ghost elements per asymmetric unit.
const string & GetColourName() const
Get the (POV-Ray) name associated to the color (if any)
virtual bool IsTemperatureFactorAnisotropic() const
Is the thermic factor anisotropic ?
void SetColour(const string &colorName)
Set the colour from the associated POV-Ray name.
const RefinableObjClock & GetMaximumLikelihoodParClock() const
Get the clock value for the last change on the maximum likelihood parameters (positionnal error...
virtual bool IsScatteringFactorAnisotropic() const
Is the scattering factor anisotropic ?
virtual CrystMatrix_REAL GetResonantScattFactReal(const ScatteringData &data, const int spgSymPosIndex=-1) const =0
Get the real part of the resonant scattering factor.
long GetDynPopCorrIndex() const
Get the number identifying this kind of scatterer, used to decide whether two scatterers are equivale...
REAL mNeutronScattLengthReal
Neutron Bond Coherent Scattering lengths.
A scattering position in a crystal, associated with the corresponding occupancy and a pointer to the ...
long GetNbComponent() const
Number of components.
We need to record exactly when refinable objects have been modified for the last time (to avoid re-co...
Definition: RefinableObj.h:138
virtual bool IsResonantScatteringAnisotropic() const
Are the resonant scattering terms anisotropic ?
bool operator==(const ScatteringComponentList &rhs) const
Compare two lists.
REAL mCovalentRadius
Covalent Radius for this atom, in Angstroems (from cctbx)
REAL GetMaximumLikelihoodPositionError() const
Maximum Likelihood: get the estimated error (sigma) on the positions for this kind of element...
virtual const string & GetClassName() const
Name for this class ("RefinableObj", "Crystal",...).
unsigned int GetMaxCovBonds() const
Maximum number of covalent bonds (from openbabel element.txt)
void Print() const
Print the list of Scattering components. For debugging.
const ScatteringComponent & operator()(const long i) const
Access to a component.
virtual REAL GetRadius() const =0
Return the physical radius of this type of scatterer (for 3D display purposes).
Class to compute structure factors for a set of reflections and a Crystal.
bool mIsIsotropic
Is the scattering isotropic ?
Generic Refinable Object.
Definition: RefinableObj.h:752
REAL mDynPopCorr
Dynamical Population Correction.
REAL GetBij(const size_t &i, const size_t &j) const
Returns the anisotropic temperature B factor for (i, j) pair.
virtual CrystVector_REAL GetTemperatureFactor(const ScatteringData &data, const int spgSymPosIndex=-1) const =0
Get the temperature factor for all reflections of a given ScatteringData object.
void operator++()
Add component (the whole list should be updated after that)
REAL mBiso
Temperature isotropic B factor.
Abstract base class for all objects in wxCryst.
Definition: wxCryst.h:127
long GetNbScatteringPower() const
Total number of ScatteringPower object.
virtual void SetBij(const size_t &i, const size_t &j, const REAL newB)
Sets the anisotropic temperature B factor for (i, j) pair.
const RefinableObjClock & GetLastChangeClock() const
ObjCrystClock time when the last modification was made to the object.
REAL mX
Coordinates of scattering positions i the crystal with the corresponding occupancy.
virtual void Init()
Initialization of the object, used by all constructors, and operator=.
cctbx::eltbx::xray_scattering::gaussian * mpGaussian
Pointer to cctbx's gaussian describing the thomson x-ray scattering factor.
bool IsIsotropic() const
Returns true if the scattering power is isotropic, else false.
CrystVector_REAL mB
Anisotropic B(ij)
const ScatteringPower * mpScattPow
The ScatteringPower associated with this position.
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
virtual const string & GetSymbol() const
Returns the symbol ('Ta', 'O2-',...) of the atom.
void operator+=(const ScatteringComponentList &rhs)
Add another list of components.
void SetSymbol(const string &symbol)
Set the symbol for this atom.
vector< ScatteringComponent > mvScattComp
The vector of components.
virtual CrystMatrix_REAL GetResonantScattFactImag(const ScatteringData &data, const int spgSymPosIndex=-1) const =0
Get the imaginary part of the resonant scattering factor.
REAL GetRadius() const
Atomic radius for this atom or ion, in Angstroems (ICSD table from cctbx)
virtual CrystMatrix_REAL GetResonantScattFactReal(const ScatteringData &data, const int spgSymPosIndex=0) const
Get the real part of the resonant scattering factor.
virtual CrystVector_REAL GetScatteringFactor(const ScatteringData &data, const int spgSymPosIndex=0) const
Get the Scattering factor for all reflections of a given ScatteringData object.
virtual void GetGeneGroup(const RefinableObj &obj, CrystVector_uint &groupIndex, unsigned int &firstGroup) const
Get the gene group assigned to each parameter.
REAL mMaximumLikelihoodNbGhost
Number of ghost atoms in the asymmetric unit.
virtual void SetBiso(const REAL newB)
Sets the isotropic temperature B factor.
void operator=(const ScatteringComponentList &rhs)
Assignement operator.
ObjRegistry< ScatteringPowerAtom > gScatteringPowerAtomRegistry("Global ScatteringPowerAtom Registry")
Global registry for all ScatteringPowerAtom objects.
string mSymbol
Symbol of this atom.
void Print() const
Print one line oabout this component.
void Init()
Initialization of the object, used by all constructors, and operator=.
virtual const string & GetClassName() const
Name for this class ("RefinableObj", "Crystal",...).
REAL mNeutronAbsCrossSection
Neutron Absorption cross section (barn)
float mColourRGB[3]
Colour for this ScatteringPower using RGB.
ObjRegistry< ScatteringPower > gScatteringPowerRegistry("Global ScatteringPower Registry")
Global registry for all ScatteringPower objects.
RefinableObjClock mClock
Clock.
int GetAtomicNumber() const
Atomic number for this atom.
virtual REAL GetForwardScatteringFactor(const RadiationType) const =0
Get the scattering factor at (0,0,0).
wxCryst class for ScatteringPowerAtom
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
Definition: Atom.cpp:47
The Scattering Power for an Atom.
REAL mFormalCharge
Formal Charge.
REAL mMaximumLikelihoodPositionError
estimated error (sigma) on the positions for this type of element.
void SetMaximumLikelihoodPositionError(const REAL mle)
Maximum Likelihood: set the estimated error (sigma) on the positions for this kind of element...
int mAtomicNumber
atomic number (Z) for the atom
RadiationType
Type of radiation used.
Definition: General.h:94
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
virtual CrystVector_REAL GetScatteringFactor(const ScatteringData &data, const int spgSymPosIndex=-1) const =0
Get the Scattering factor for all reflections of a given ScatteringData object.
long mDynPopCorrIndex
number identifying this kind of scatterer, for the dynamical occupancy correction.
REAL GetBiso() const
Returns the isotropic temperature B factor.
class to input or output a well-formatted xml beginning or ending tag.
class of refinable parameter types.
Definition: RefinableObj.h:78
list of scattering positions in a crystal, associated with the corresponding occupancy and a pointer ...
REAL mRadius
Radius of the atom or ion, in Angstroems (ICSD table from cctbx)
virtual const string & GetSymbol() const
Symbol for this Scattering power (the atom name for atoms)
string GetElementName() const
Returns the standard name of the element (ie "hydrogen", "tantalum",..).
const RefParType * gpRefParTypeObjCryst
Top RefParType for the ObjCryst++ library.
Object Registry.
Definition: RefinableObj.h:643
void SetMaximumLikelihoodNbGhostAtom(const REAL nb)
Maximum Likelihood: set the number of ghost elements per asymmetric unit.
REAL GetCovalentRadius() const
Covalent Radius for this atom, in Angstroems (from cctbx)
void operator--()
Remove component (the whole list should be updated after that)
virtual void InitRGBColour()
Get RGB Colour coordinates from Colour Name.
const float * GetColourRGB() const
Get the float[3] array of RGB components defining the colour of this scattering power.
CrystVector_REAL mBeta
Anisotropic Beta(ij)
Abstract Base Class to describe the scattering power of any Scatterer component in a crystal...
unsigned int mMaxCovBonds
Maximum number of covalent bonds.