FOX/ObjCryst++  2022
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);
121  virtual bool operator==(const ScatteringPower& rhs) const;
125  virtual bool operator!=(const ScatteringPower& rhs) const;
140  virtual CrystVector_REAL GetScatteringFactor(const ScatteringData &data,
141  const int spgSymPosIndex=-1) const=0;
144  virtual REAL GetForwardScatteringFactor(const RadiationType) const=0;
158  virtual CrystVector_REAL GetTemperatureFactor(const ScatteringData &data,
159  const int spgSymPosIndex=-1) const=0;
175  virtual CrystMatrix_REAL GetResonantScattFactReal(const ScatteringData &data,
176  const int spgSymPosIndex=-1) const=0;
192  virtual CrystMatrix_REAL GetResonantScattFactImag(const ScatteringData &data,
193  const int spgSymPosIndex=-1) const=0;
195  virtual bool IsScatteringFactorAnisotropic()const;
197  virtual bool IsTemperatureFactorAnisotropic()const;
199  virtual bool IsResonantScatteringAnisotropic()const;
203  virtual const string& GetSymbol() const;
207  REAL GetBiso() const;
211  REAL& GetBiso();
215  virtual void SetBiso(const REAL newB);
220  REAL GetBij(const size_t &i, const size_t &j) const;
232  REAL GetBij(const size_t &idx) const;
237  virtual void SetBij(const size_t &i, const size_t &j, const REAL newB);
249  virtual void SetBij(const size_t &idx, const REAL newB);
254  bool IsIsotropic()const ;
257  long GetDynPopCorrIndex()const;
259  long GetNbScatteringPower()const;
263  const string& GetColourName()const;
265  const float* GetColourRGB()const;
267  void SetColour(const string& colorName);
269  void SetColour(const float r,const float g,const float b);
272  virtual REAL GetRadius()const=0;
273  virtual void GetGeneGroup(const RefinableObj &obj,
274  CrystVector_uint & groupIndex,
275  unsigned int &firstGroup) const;
281  void SetMaximumLikelihoodPositionError(const REAL mle);
285  void SetMaximumLikelihoodNbGhostAtom(const REAL nb);
289  virtual REAL GetFormalCharge()const;
290  virtual void SetFormalCharge(const REAL charge);
291  protected:
292  virtual void InitRefParList()=0;
294  virtual void Init();
296  virtual void InitRGBColour();
301  REAL mBiso;
309  mutable CrystVector_REAL mBeta;
311  CrystVector_REAL mB;
315  string mColourName;
317  float mColourRGB[3];
318  // Maximum Likelihood
322  RefinableObjClock mMaximumLikelihoodParClock;
333 };
334 
337 
338 //######################################################################
339 //
340 // SCATTERING POWER ATOM
344 //######################################################################
345 
347 {
348  public:
359  ScatteringPowerAtom(const string &name,const string &symbol,const REAL bIso=1.0);
362  virtual const string& GetClassName() const;
364  void Init(const string &name,const string &symbol,const REAL bIso=1.0);
365  virtual CrystVector_REAL GetScatteringFactor(const ScatteringData &data,
366  const int spgSymPosIndex=0) const;
367  virtual REAL GetForwardScatteringFactor(const RadiationType) const;
368  virtual CrystVector_REAL GetTemperatureFactor(const ScatteringData &data,
369  const int spgSymPosIndex=0) const;
370  virtual CrystMatrix_REAL GetResonantScattFactReal(const ScatteringData &data,
371  const int spgSymPosIndex=0) const;
372  virtual CrystMatrix_REAL GetResonantScattFactImag(const ScatteringData &data,
373  const int spgSymPosIndex=0) const;
375  void SetSymbol(const string &symbol) ;
377  virtual const string& GetSymbol() const;
383  string GetElementName() const;
385  int GetAtomicNumber() const;
387  REAL GetAtomicWeight() const;
389  REAL GetRadius() const;
391  REAL GetCovalentRadius() const;
393  unsigned int GetMaxCovBonds() const;
394  virtual void Print()const;
395  virtual void XMLOutput(ostream &os,int indent=0)const;
396  virtual void XMLInput(istream &is,const XMLCrystTag &tag);
397  //virtual void XMLInputOld(istream &is,const IOCrystTag &tag);
398  protected:
408  virtual void InitRefParList();
414  string mSymbol;
419 
423  cctbx::eltbx::xray_scattering::gaussian *mpGaussian;
424 
431  REAL mNeutronScattLengthReal,mNeutronScattLengthImag;
432 
434  REAL mRadius;
438  unsigned int mMaxCovBonds;
439 
447  private:
448  // Avoid compiler warnings. Explicitly hide the base-class method.
449  void Init();
450  #ifdef __WX__CRYST__
451  public:
452  virtual WXCrystObjBasic* WXCreate(wxWindow*);
453  friend class WXScatteringPowerAtom;
454  #endif
455 };
458 
459 //######################################################################
460 //
461 // SCATTERING COMPONENT
466 //######################################################################
468 {
469  // Default Constructor
471  bool operator==(const ScatteringComponent& rhs)const;
472  bool operator!=(const ScatteringComponent& rhs)const;
474  void Print() const;
476  REAL mX,mY,mZ,mOccupancy;
479 
492  mutable REAL mDynPopCorr;
493  // The scatterer to which this component is associated
494  // Scatterer *mScatterer;
495 };
496 
497 //######################################################################
498 //
499 // SCATTERING COMPONENT LIST
504 //######################################################################
506 {
507  public:
509  ScatteringComponentList(const long nbComponent);
514  void Reset();
516  const ScatteringComponent& operator()(const long i) const;
517  ScatteringComponent& operator()(const long i);
519  long GetNbComponent() const;
521  void operator=(const ScatteringComponentList &rhs);
523  bool operator==(const ScatteringComponentList &rhs)const;
525  void operator+=(const ScatteringComponentList &rhs);
527  void operator+=(const ScatteringComponent &rhs);
529  void operator++();
531  void operator--();
533  void Print() const;
534  protected:
536  vector<ScatteringComponent> mvScattComp;
537 };
538 
539 }//namespace
540 #include "ObjCryst/ObjCryst/ScatteringData.h"
541 
542 #endif //_OBJCRYST_SCATTPOWER_H_
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
Definition: doc-main.h:25
RadiationType
Type of radiation used.
Definition: General.h:96
const RefParType * gpRefParTypeObjCryst
Top RefParType for the ObjCryst++ library.
ObjRegistry< ScatteringPower > gScatteringPowerRegistry("Global ScatteringPower Registry")
Global registry for all ScatteringPower objects.
ObjRegistry< ScatteringPowerAtom > gScatteringPowerAtomRegistry("Global ScatteringPowerAtom Registry")
Global registry for all ScatteringPowerAtom objects.
Class to compute structure factors for a set of reflections and a Crystal.
Abstract Base Class to describe the scattering power of any Scatterer component in a crystal.
float mColourRGB[3]
Colour for this ScatteringPower using RGB.
long mDynPopCorrIndex
number identifying this kind of scatterer, for the dynamical occupancy correction.
CrystVector_REAL mBeta
Anisotropic Beta(ij)
REAL mFormalCharge
Formal Charge.
string mColourName
Colour for this ScatteringPower (from POVRay)
REAL mMaximumLikelihoodPositionError
estimated error (sigma) on the positions for this type of element.
virtual void Init()
Initialization of the object, used by all constructors, and operator=.
bool mIsIsotropic
Is the scattering isotropic ?
bool IsIsotropic() const
Returns true if the scattering power is isotropic, else false.
const float * GetColourRGB() const
Get the float[3] array of RGB components defining the colour of this scattering power.
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.
REAL GetBiso() const
Returns the isotropic temperature B factor.
virtual CrystMatrix_REAL GetResonantScattFactReal(const ScatteringData &data, const int spgSymPosIndex=-1) const =0
Get the real part of the resonant scattering factor.
virtual void SetBiso(const REAL newB)
Sets the isotropic temperature B factor.
REAL mMaximumLikelihoodNbGhost
Number of ghost atoms in the asymmetric unit.
const RefinableObjClock & GetLastChangeClock() const
ObjCrystClock time when the last modification was made to the object.
virtual bool IsScatteringFactorAnisotropic() const
Is the scattering factor anisotropic ?
virtual bool operator==(const ScatteringPower &rhs) const
Comparison operator.
long GetNbScatteringPower() const
Total number of ScatteringPower object.
REAL GetBij(const size_t &i, const size_t &j) const
Returns the anisotropic temperature B factor for (i, j) pair.
const string & GetColourName() const
Get the (POV-Ray) name associated to the color (if any)
CrystVector_REAL mB
Anisotropic B(ij)
virtual const string & GetClassName() const
Name for this class ("RefinableObj", "Crystal",...).
REAL GetMaximumLikelihoodNbGhostAtom() const
Maximum Likelihood: get the number of ghost elements per asymmetric unit.
RefinableObjClock mClock
Clock.
long GetDynPopCorrIndex() const
Get the number identifying this kind of scatterer, used to decide whether two scatterers are equivale...
const RefinableObjClock & GetMaximumLikelihoodParClock() const
Get the clock value for the last change on the maximum likelihood parameters (positionnal error,...
virtual REAL GetForwardScatteringFactor(const RadiationType) const =0
Get the scattering factor at (0,0,0).
virtual CrystMatrix_REAL GetResonantScattFactImag(const ScatteringData &data, const int spgSymPosIndex=-1) const =0
Get the imaginary part of the resonant scattering factor.
void SetMaximumLikelihoodNbGhostAtom(const REAL nb)
Maximum Likelihood: set the number of ghost elements per asymmetric unit.
REAL mBiso
Temperature isotropic B factor.
virtual void GetGeneGroup(const RefinableObj &obj, CrystVector_uint &groupIndex, unsigned int &firstGroup) const
Get the gene group assigned to each parameter.
virtual REAL GetRadius() const =0
Return the physical radius of this type of scatterer (for 3D display purposes).
void SetColour(const string &colorName)
Set the colour from the associated POV-Ray name.
virtual bool IsResonantScatteringAnisotropic() const
Are the resonant scattering terms anisotropic ?
virtual void InitRGBColour()
Get RGB Colour coordinates from Colour Name.
REAL GetMaximumLikelihoodPositionError() const
Maximum Likelihood: get the estimated error (sigma) on the positions for this kind of element.
void SetMaximumLikelihoodPositionError(const REAL mle)
Maximum Likelihood: set the estimated error (sigma) on the positions for this kind of element.
virtual bool IsTemperatureFactorAnisotropic() const
Is the thermic factor anisotropic ?
virtual void SetBij(const size_t &i, const size_t &j, const REAL newB)
Sets the anisotropic temperature B factor for (i, j) pair.
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.
virtual bool operator!=(const ScatteringPower &rhs) const
Comparison operator.
virtual const string & GetSymbol() const
Symbol for this Scattering power (the atom name for atoms)
The Scattering Power for an Atom.
REAL mNeutronAbsCrossSection
Neutron Absorption cross section (barn)
string GetElementName() const
Returns the standard name of the element (ie "hydrogen", "tantalum",..).
virtual const string & GetSymbol() const
Returns the symbol ('Ta', 'O2-',...) of the atom.
REAL mCovalentRadius
Covalent Radius for this atom, in Angstroems (from cctbx)
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 CrystMatrix_REAL GetResonantScattFactReal(const ScatteringData &data, const int spgSymPosIndex=0) const
Get the real part of the resonant scattering factor.
REAL GetCovalentRadius() const
Covalent Radius for this atom, in Angstroems (from cctbx)
virtual CrystMatrix_REAL GetResonantScattFactImag(const ScatteringData &data, const int spgSymPosIndex=0) const
Get the imaginary part of the resonant scattering factor.
REAL mRadius
Radius of the atom or ion, in Angstroems (ICSD table from cctbx)
REAL GetAtomicWeight() const
Atomic weight (g/mol) for this atom.
void SetSymbol(const string &symbol)
Set the symbol for this atom.
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
REAL mNeutronScattLengthReal
Neutron Bond Coherent Scattering lengths.
string mSymbol
Symbol of this atom.
unsigned int GetMaxCovBonds() const
Maximum number of covalent bonds (from openbabel element.txt)
virtual const string & GetClassName() const
Name for this class ("RefinableObj", "Crystal",...).
REAL GetRadius() const
Atomic radius for this atom or ion, in Angstroems (ICSD table from cctbx)
void Init()
Initialization of the object, used by all constructors, and operator=.
virtual REAL GetForwardScatteringFactor(const RadiationType) const
Get the scattering factor at (0,0,0).
int mAtomicNumber
atomic number (Z) for the atom
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
int GetAtomicNumber() const
Atomic number for this atom.
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 mAtomicWeight
atomic weight (g/mol) for the atom
unsigned int mMaxCovBonds
Maximum number of covalent bonds.
cctbx::eltbx::xray_scattering::gaussian * mpGaussian
Pointer to cctbx's gaussian describing the thomson x-ray scattering factor.
A scattering position in a crystal, associated with the corresponding occupancy and a pointer to the ...
const ScatteringPower * mpScattPow
The ScatteringPower associated with this position.
REAL mDynPopCorr
Dynamical Population Correction.
REAL mX
Coordinates of scattering positions i the crystal with the corresponding occupancy.
void Print() const
Print one line oabout this component.
list of scattering positions in a crystal, associated with the corresponding occupancy and a pointer ...
bool operator==(const ScatteringComponentList &rhs) const
Compare two lists.
vector< ScatteringComponent > mvScattComp
The vector of components.
const ScatteringComponent & operator()(const long i) const
Access to a component.
void operator+=(const ScatteringComponentList &rhs)
Add another list of components.
void operator++()
Add component (the whole list should be updated after that)
void operator=(const ScatteringComponentList &rhs)
Assignement operator.
long GetNbComponent() const
Number of components.
void Print() const
Print the list of Scattering components. For debugging.
void operator--()
Remove component (the whole list should be updated after that)
class to input or output a well-formatted xml beginning or ending tag.
class of refinable parameter types.
Definition: RefinableObj.h:80
We need to record exactly when refinable objects have been modified for the last time (to avoid re-co...
Definition: RefinableObj.h:140
Object Registry.
Definition: RefinableObj.h:645
Generic Refinable Object.
Definition: RefinableObj.h:784
Abstract base class for all objects in wxCryst.
Definition: wxCryst.h:128
wxCryst class for ScatteringPowerAtom