FOX/ObjCryst++  2022
ZScatterer.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_ZSCATTERER_H_
20 #define _OBJCRYST_ZSCATTERER_H_
21 
22 #include "ObjCryst/CrystVector/CrystVector.h"
23 
24 #include "ObjCryst/ObjCryst/General.h"
25 
26 #include "ObjCryst/ObjCryst/ScatteringPower.h"
27 #include "ObjCryst/ObjCryst/Scatterer.h"
28 #include "ObjCryst/RefinableObj/GlobalOptimObj.h"
29 
30 #include <string>
31 
32 namespace ObjCryst
33 {
34 class ZScatterer;
35 //######################################################################
36 //
37 // GLOBAL SCATTERING POWER
50 //######################################################################
51 
53 {
54  public:
56  GlobalScatteringPower(const ZScatterer &scatt);
60  void Init(const ZScatterer &scatt);
61  virtual CrystVector_REAL GetScatteringFactor(const ScatteringData &data,
62  const int spgSymPosIndex=0) const;
63  virtual REAL GetForwardScatteringFactor(const RadiationType) const;
64  virtual CrystVector_REAL GetTemperatureFactor(const ScatteringData &data,
65  const int spgSymPosIndex=0) const;
66  virtual CrystMatrix_REAL GetResonantScattFactReal(const ScatteringData &data,
67  const int spgSymPosIndex=0) const;
68  virtual CrystMatrix_REAL GetResonantScattFactImag(const ScatteringData &data,
69  const int spgSymPosIndex=0) const;
70  virtual REAL GetRadius()const;
71  protected:
72  virtual void InitRefParList();
75  private:
76  // Avoid compiler warnings. Explicitly hide the base-class method.
77  void Init();
78 };
79 
80 //######################################################################
84 //######################################################################
85 
86 class ZAtom
87 {
88  public:
89  ZAtom(ZScatterer &scatt,const ScatteringPower *pow,
90  const long atomBond=0, const REAL bondLength=1,
91  const long atomAngle=0, const REAL bondAngle=M_PI,
92  const long atomDihedral=0, const REAL dihedralAngle=M_PI,
93  const REAL popu=1., const string &name="");
94  ~ZAtom();
95  const string& GetClassName()const;
96  const string& GetName()const;
97  void SetName(const string&);
99  const ZScatterer& GetZScatterer()const;
102 
105  long GetZBondAtom()const;
108  long GetZAngleAtom()const;
111  long GetZDihedralAngleAtom()const;
112 
114  const REAL& GetZBondLength()const;
116  const REAL& GetZAngle()const;
118  const REAL& GetZDihedralAngle()const;
120  const REAL& GetOccupancy()const;
122  const ScatteringPower* GetScatteringPower()const;
123 
125  void SetZBondLength(const REAL);
127  void SetZAngle(const REAL);
129  void SetZDihedralAngle(const REAL);
131  void SetOccupancy(const REAL);
133  void SetScatteringPower(const ScatteringPower*);
134  void XMLOutput(ostream &os,int indent=0)const;
135  void XMLInput(istream &is,const XMLCrystTag &tag);
136  private:
141  long mAtomBond,mAtomAngle,mAtomDihed;
143  REAL mBondLength,mAngle,mDihed,mOccupancy;
145  string mName;
148 
149  friend class ZScatterer; //So that RefinablePar can be declared in ZScatterer
150 
151  #ifdef __WX__CRYST__
152  public:
153  WXCrystObjBasic* WXCreate(wxWindow *parent);
154  WXCrystObjBasic* WXGet();
155  void WXDelete();
156  void WXNotifyDelete();
157  private:
158  WXCrystObjBasic *mpWXCrystObj;
159  friend class WXZAtom;
160  #endif
161 };
162 //######################################################################
167 //######################################################################
169 {
170  public:
171  ZMoveMinimizer(ZScatterer &scatt);
172  ~ZMoveMinimizer();
173  virtual REAL GetLogLikelihood()const;
174  void RecordConformation();
175  void SetZAtomWeight(const CrystVector_REAL weight);
176  void MinimizeChange(long nbTrial=10000);
177  private:
178  ZScatterer *mpZScatt;
179  MonteCarloObj mOptimObj;
180  CrystVector_REAL mXCoord0,mYCoord0,mZCoord0;
181  CrystVector_REAL mAtomWeight;
182 };
183 
184 //######################################################################
188 //######################################################################
189 
190 class ZScatterer: public Scatterer
191 {
192  public:
201  ZScatterer(const string &name,Crystal &cryst,
202  const REAL x=0.,const REAL y=0.,const REAL z=0.,
203  const REAL phi=0.,const REAL chi=0., const REAL psi=0.);
207  ZScatterer(const ZScatterer &old);
208  ~ZScatterer();
211  virtual ZScatterer* CreateCopy() const;
212  virtual const string& GetClassName() const;
216  void AddAtom(const string &name,const ScatteringPower *pow,
217  const long atomBond, const REAL bondLength,
218  const long atomAngle, const REAL bondAngle,
219  const long atomDihedral, const REAL dihedralAngle,
220  const REAL popu=1.);
221 
222  virtual int GetNbComponent() const;
224  virtual string GetComponentName(const int i) const;
225 
227  void Print() const;
228 
230  REAL GetPhi()const;
232  REAL GetChi()const;
234  REAL GetPsi()const;
236  void SetPhi(const REAL);
238  void SetChi(const REAL);
240  void SetPsi(const REAL);
241 
243  REAL GetZAtomX(const int i)const;
245  REAL GetZAtomY(const int i)const;
247  REAL GetZAtomZ(const int i)const;
250  long GetZBondAtom(const int i)const;
253  long GetZAngleAtom(const int i)const;
256  long GetZDihedralAngleAtom(const int i)const;
257 
259  REAL GetZBondLength(const int i)const;
261  REAL GetZAngle(const int i)const;
263  REAL GetZDihedralAngle(const int i)const;
264 
266  void SetZBondLength(const int i,const REAL);
268  void SetZAngle(const int i,const REAL);
270  void SetZDihedralAngle(const int i,const REAL);
271 
273  const ObjRegistry<ZAtom>& GetZAtomRegistry()const;
275  virtual ostream& POVRayDescription(ostream &os,
276  const CrystalPOVRayOptions &options)const;
277 
278 #ifdef OBJCRYST_GL
279  virtual void GLInitDisplayList(const bool onlyIndependentAtoms=false,
280  const REAL xMin=-.1,const REAL xMax=1.1,
281  const REAL yMin=-.1,const REAL yMax=1.1,
282  const REAL zMin=-.1,const REAL zMax=1.1,
283  const bool displayEnantiomer=false,
284  const bool displayNames=false,
285  const bool hideHydrogens=false,
286  const REAL fadeDistance=0,
287  const bool fullMoleculeInLimits=false)const;
288 #endif // OBJCRYST_GL
289 
299  virtual void SetUseGlobalScatteringPower(const bool useIt);
300  virtual void XMLOutput(ostream &os,int indent=0)const;
301  virtual void XMLInput(istream &is,const XMLCrystTag &tag);
302  //virtual void XMLInputOld(istream &is,const IOCrystTag &tag);
303  virtual void GetGeneGroup(const RefinableObj &obj,
304  CrystVector_uint & groupIndex,
305  unsigned int &firstGroup) const;
306  virtual void GlobalOptRandomMove(const REAL mutationAmplitude,
307  const RefParType *type=gpRefParTypeObjCryst);
309  const CrystVector_REAL& GetXCoord() const;
311  const CrystVector_REAL& GetYCoord() const;
313  const CrystVector_REAL& GetZCoord() const;
314  virtual void EndOptimization();
343  void ImportFenskeHallZMatrix(istream &is,bool named=false);
348  void ExportFenskeHallZMatrix(ostream &os);
350  void SetCenterAtomIndex(const unsigned int);
352  unsigned int GetCenterAtomIndex()const;
355  std::size_t size() const;
360  vector<ZAtom*>::const_iterator begin() const;
365  vector<ZAtom*>::const_iterator end() const;
366  protected:
373  void UpdateCoordinates() const;
380  void UpdateScattCompList() const;
395  CrystMatrix_long m3DDisplayIndex;
399  long mNbAtom;
400  private:
402  virtual void InitRefParList();
403 
406 
412  CrystVector_int mComponentIndex;
413 
438  REAL mPhi,mChi,mPsi;
439 
445 
447  mutable CrystMatrix_REAL mPhiChiPsiMatrix;
448 
452 
456 
459  mutable CrystVector_REAL mXCoord,mYCoord,mZCoord;
462  ZMoveMinimizer *mpZMoveMinimizer;
463  #ifdef __WX__CRYST__
464  public:
465  virtual WXCrystObjBasic* WXCreate(wxWindow*);
466  friend class WXZScatterer;
467  #endif
468 };
469 
470 //######################################################################
471 //
472 // Different types of regular polyhedra
473 //
474 //######################################################################
475 
476 enum RegularPolyhedraType { TETRAHEDRON, OCTAHEDRON, SQUARE_PLANE, CUBE, ANTIPRISM_TETRAGONAL,
477  PRISM_TETRAGONAL_MONOCAP, PRISM_TETRAGONAL_DICAP,
478  PRISM_TRIGONAL,PRISM_TRIGONAL_TRICAPPED,
479  ICOSAHEDRON, TRIANGLE_PLANE};
480 
481 //######################################################################
488 //######################################################################
489 class ZPolyhedron: public ZScatterer
490 {
491  public:
510  ZPolyhedron( const RegularPolyhedraType type, Crystal &cryst,
511  const REAL x, const REAL y, const REAL z,
512  const string &name, const ScatteringPower *centralAtomPow,
513  const ScatteringPower *periphAtomPow,const REAL centralPeriphDist,
514  const REAL ligandPopu=1,
515  const REAL phi=0., const REAL chi=0., const REAL psi=0.);
517  ZPolyhedron(const ZPolyhedron&);
520  virtual ZPolyhedron* CreateCopy() const;
521 
522  /* \brief Copy constructor
523  *
524  ZPolyhedron(const ZPolyhedron &old);
525  */
526  protected:
527  private:
528  //Prepare refinable parameters for the scatterer object
529  //virtual void InitRefParList();
530 
532  RegularPolyhedraType mPolyhedraType;
533 };
534 
535 }//namespace
536 #include "ObjCryst/ObjCryst/Crystal.h"
537 
538 #endif //_OBJCRYST_ZSCATTERER_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.
Crystal class: Unit cell, spacegroup, scatterers.
Definition: Crystal.h:98
Class to store POV-Ray output options.
Definition: General.h:178
Generic type of scatterer: can be an atom, or a more complex assembly of atoms.
Definition: Scatterer.h:131
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.
list of scattering positions in a crystal, associated with the corresponding occupancy and a pointer ...
Global Scattering Power.
Definition: ZScatterer.h:53
virtual CrystVector_REAL GetTemperatureFactor(const ScatteringData &data, const int spgSymPosIndex=0) const
Get the temperature factor for all reflections of a given ScatteringData object.
virtual REAL GetForwardScatteringFactor(const RadiationType) const
Get the scattering factor at (0,0,0).
virtual CrystMatrix_REAL GetResonantScattFactReal(const ScatteringData &data, const int spgSymPosIndex=0) const
Get the real part of the resonant scattering factor.
ZScatterer * mpZScatterer
a copy of the ZScatterer associated to this object
Definition: ZScatterer.h:74
void Init()
Initialization of the object, used by all constructors, and operator=.
virtual CrystMatrix_REAL GetResonantScattFactImag(const ScatteringData &data, const int spgSymPosIndex=0) const
Get the imaginary part of the resonant scattering factor.
virtual REAL GetRadius() const
Return the physical radius of this type of scatterer (for 3D display purposes).
virtual CrystVector_REAL GetScatteringFactor(const ScatteringData &data, const int spgSymPosIndex=0) const
Get the Scattering factor for all reflections of a given ScatteringData object.
Class for individual atoms in a ZScatterer Object.
Definition: ZScatterer.h:87
long GetZAngleAtom() const
Index of the 2nd atom used to define the atom in the Z-Matrix (the one from which the angle is calcul...
Definition: ZScatterer.cpp:96
const REAL & GetZDihedralAngle() const
Const access to the dihedral angle parameter.
Definition: ZScatterer.cpp:100
long GetZDihedralAngleAtom() const
Index of the 3rd atom used to define the atom in the Z-Matrix (the one from which the dihedral angle ...
Definition: ZScatterer.cpp:97
void SetZDihedralAngle(const REAL)
Access to the dihedral angle parameter.
Definition: ZScatterer.cpp:106
const ScatteringPower * mpScattPow
The ScatteringPower corresponding to this atom.
Definition: ZScatterer.h:138
const ZScatterer & GetZScatterer() const
Get the ZScatterer associated to this ZAtom.
Definition: ZScatterer.cpp:92
void SetScatteringPower(const ScatteringPower *)
Set the ScatteringPower.
Definition: ZScatterer.cpp:108
void SetOccupancy(const REAL)
Access to the dihedral angle parameter.
Definition: ZScatterer.cpp:107
long mAtomBond
The index (in the ZScatterer) of the atoms which are used to define the position of this atom.
Definition: ZScatterer.h:141
void SetZAngle(const REAL)
Access to the angle parameter.
Definition: ZScatterer.cpp:105
string mName
Name for this atom.
Definition: ZScatterer.h:145
ZScatterer * mpScatt
the ZScatterer in which this atom is included.
Definition: ZScatterer.h:147
REAL mBondLength
Bond length, angle and dihedral angle.
Definition: ZScatterer.h:143
void SetZBondLength(const REAL)
Access to bondlength parameter.
Definition: ZScatterer.cpp:104
long GetZBondAtom() const
Index of the 1st atom used to define the atom in the Z-Matrix (the one from which the bondlength is c...
Definition: ZScatterer.cpp:95
const REAL & GetZBondLength() const
Const access to bondlength parameter.
Definition: ZScatterer.cpp:98
const REAL & GetZAngle() const
Const access to the angle parameter.
Definition: ZScatterer.cpp:99
const ScatteringPower * GetScatteringPower() const
ScatteringPower for this atom.
Definition: ZScatterer.cpp:102
const REAL & GetOccupancy() const
Const access to the ocupancy parameter.
Definition: ZScatterer.cpp:101
Class to minimize conformation changes for random moves.
Definition: ZScatterer.h:169
virtual REAL GetLogLikelihood() const
Get -log(likelihood) of the current configuration for the object.
Definition: ZScatterer.cpp:153
ZScatterer: the basic type of complex scatterers, where atom positions are defined using a standard "...
Definition: ZScatterer.h:191
void ImportFenskeHallZMatrix(istream &is, bool named=false)
Import "Fenske-Hall" ZMatrix file (fhz in the babel program http://www.eyesopen.com/babel....
REAL GetZAtomX(const int i) const
Get the X fractionnal coordinate of atom i.
Definition: ZScatterer.cpp:438
void SetZAngle(const int i, const REAL)
Access to the angle parameter, for the i-th row in the Z-Matrix.
Definition: ZScatterer.cpp:460
virtual void GlobalOptRandomMove(const REAL mutationAmplitude, const RefParType *type=gpRefParTypeObjCryst)
Make a random move of the current configuration.
void SetCenterAtomIndex(const unsigned int)
Set the index of the central atom (around which the rotation is made)
ZScatterer(const string &name, Crystal &cryst, const REAL x=0., const REAL y=0., const REAL z=0., const REAL phi=0., const REAL chi=0., const REAL psi=0.)
ZScatterer constructor.
Definition: ZScatterer.cpp:214
std::size_t size() const
STL access to registry of Zatom size.
virtual ZScatterer * CreateCopy() const
Definition: ZScatterer.cpp:306
const ObjRegistry< ZAtom > & GetZAtomRegistry() const
Access to the registry of ZAtoms.
Definition: ZScatterer.cpp:466
GlobalScatteringPower * mpGlobalScattPow
the global scattering power used, if mUseGlobalScattPow=true
Definition: ZScatterer.h:455
REAL mPhi
Angles giving the orientation of the ZScatterer (stored in radian)
Definition: ZScatterer.h:438
long GetZBondAtom(const int i) const
Index of the 1st atom used to define the i-th atom in the Z-Matrix (the one from which the bondlength...
Definition: ZScatterer.cpp:441
REAL GetZAtomZ(const int i) const
Get the Z fractionnal coordinate of atom i.
Definition: ZScatterer.cpp:440
virtual void InitRefParList()
Prepare refinable parameters for the scatterer object.
void ExportFenskeHallZMatrix(ostream &os)
Export to Fenske-Hall ZMatrix file.
RefinableObjClock mClockCoord
Last time the cartesian coordinates were computed.
Definition: ZScatterer.h:461
long mCenterAtomIndex
Index of the atom used as a pivot (the scatterer is rotated around this atom).
Definition: ZScatterer.h:444
virtual int GetNbComponent() const
Number of components in the scatterer (eg number of point scatterers)
Definition: ZScatterer.cpp:405
CrystVector_REAL mXCoord
Storage for Cartesian coordinates.
Definition: ZScatterer.h:459
const CrystVector_REAL & GetXCoord() const
Get the list of all ZAtom cartesian x coordinates.
REAL GetPhi() const
Access to phi parameter (overall orientation of the scatterer)
Definition: ZScatterer.cpp:430
void SetZDihedralAngle(const int i, const REAL)
Access to the dihedral angle parameter, for the i-th row in the Z-Matrix.
Definition: ZScatterer.cpp:463
virtual void EndOptimization()
This should be called by any optimization class at the end of an optimization.
virtual string GetComponentName(const int i) const
Name for the i-th component of this scatterer.
Definition: ZScatterer.cpp:417
REAL GetPsi() const
Access to psi parameter (overall orientation of the scatterer)
Definition: ZScatterer.cpp:432
void SetPhi(const REAL)
Access to phi parameter (overall orientation of the scatterer)
Definition: ZScatterer.cpp:434
long GetZDihedralAngleAtom(const int i) const
Index of the 3rd atom used to define the i-th atom in the Z-Matrix (the one from which the dihedral a...
Definition: ZScatterer.cpp:447
REAL GetZAtomY(const int i) const
Get the Y fractionnal coordinate of atom i.
Definition: ZScatterer.cpp:439
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
ObjRegistry< ZAtom > mZAtomRegistry
Registry for ZAtoms in this Scatterer.
Definition: ZScatterer.h:441
REAL GetChi() const
Access to chi parameter (overall orientation of the scatterer)
Definition: ZScatterer.cpp:431
REAL GetZAngle(const int i) const
Const access to the angle parameter, for the i-th row in the Z-Matrix.
Definition: ZScatterer.cpp:452
virtual void GetGeneGroup(const RefinableObj &obj, CrystVector_uint &groupIndex, unsigned int &firstGroup) const
Get the gene group assigned to each parameter.
bool mUseGlobalScattPow
Does the ZScatterer use a global scattering power ?
Definition: ZScatterer.h:451
const CrystVector_REAL & GetZCoord() const
Get the list of all ZAtom cartesian x coordinates.
CrystMatrix_long m3DDisplayIndex
For 3D display of the structure, bonds, triangular and quadric faces can be displayed.
Definition: ZScatterer.h:395
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
ScatteringComponentList mScattCompList
The list of scattering components.
Definition: ZScatterer.h:397
void UpdateCoordinates() const
Update the atom coordinates (in real units, in Angstroems).
const CrystVector_REAL & GetYCoord() const
Get the list of all ZAtom cartesian x coordinates.
CrystVector_int mComponentIndex
Index of atoms in the ScatteringComponentList.
Definition: ZScatterer.h:412
unsigned int GetCenterAtomIndex() const
Get the index of the central atom (around which the rotation is made)
virtual const string & GetClassName() const
Name for this class ("RefinableObj", "Crystal",...).
Definition: ZScatterer.cpp:311
void Print() const
Print a single line of information about this scatterer.
Definition: ZScatterer.cpp:422
vector< ZAtom * >::const_iterator begin() const
low-level access to the underlying vector of ZAtom begin().
void AddAtom(const string &name, const ScatteringPower *pow, const long atomBond, const REAL bondLength, const long atomAngle, const REAL bondAngle, const long atomDihedral, const REAL dihedralAngle, const REAL popu=1.)
Add an atom to the Zscatterer.
Definition: ZScatterer.cpp:317
virtual ostream & POVRayDescription(ostream &os, const CrystalPOVRayOptions &options) const
Definition: ZScatterer.cpp:469
void SetChi(const REAL)
Access to chi parameter (overall orientation of the scatterer)
Definition: ZScatterer.cpp:435
vector< ZAtom * >::const_iterator end() const
low-level access to the underlying vector of ZAtom end().
void SetZBondLength(const int i, const REAL)
Access to bondlength parameter, for the i-th row in the Z-Matrix.
Definition: ZScatterer.cpp:457
void UpdateScattCompList() const
Update the scattering component list, ie compute all atom positions from the bonds/angles/dihedral an...
long mNbDummyAtom
Number of "dummy" atoms in the structure.
Definition: ZScatterer.h:405
REAL GetZDihedralAngle(const int i) const
Const access to the dihedral angle parameter, for the i-th row in the Z-Matrix.
Definition: ZScatterer.cpp:454
REAL GetZBondLength(const int i) const
Const access to bondlength parameter, for the i-th row in the Z-Matrix.
Definition: ZScatterer.cpp:450
CrystMatrix_REAL mPhiChiPsiMatrix
Rotation matrix for the orientation of the scatterer.
Definition: ZScatterer.h:447
void SetPsi(const REAL)
Access to psi parameter (overall orientation of the scatterer)
Definition: ZScatterer.cpp:436
long mNbAtom
Total number of atoms in the structure.
Definition: ZScatterer.h:399
long GetZAngleAtom(const int i) const
Index of the 2nd atom used to define the i-th atom in the Z-Matrix (the one from which the angle is c...
Definition: ZScatterer.cpp:444
virtual void SetUseGlobalScatteringPower(const bool useIt)
use a Global scattering power for this scatterer ?
virtual const ScatteringComponentList & GetScatteringComponentList() const
Get the list of all scattering components for this scatterer.
Definition: ZScatterer.cpp:410
ZPolyhedron: a Scatterer to describe polyhedras such as octahedron, tetrahedron, square plane,...
Definition: ZScatterer.h:490
virtual ZPolyhedron * CreateCopy() const
ZPolyhedron(const RegularPolyhedraType type, Crystal &cryst, const REAL x, const REAL y, const REAL z, const string &name, const ScatteringPower *centralAtomPow, const ScatteringPower *periphAtomPow, const REAL centralPeriphDist, const REAL ligandPopu=1, const REAL phi=0., const REAL chi=0., const REAL psi=0.)
ZPolyhedron constructor.
Base object for Monte-Carlo Global Optimization methods.
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 ZScatterer objects
Definition: wxZScatterer.h:48