FOX/ObjCryst++  1.10.X (development)
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  virtual void GLInitDisplayList(const bool onlyIndependentAtoms=false,
279  const REAL xMin=-.1,const REAL xMax=1.1,
280  const REAL yMin=-.1,const REAL yMax=1.1,
281  const REAL zMin=-.1,const REAL zMax=1.1,
282  const bool displayEnantiomer=false,
283  const bool displayNames=false,
284  const bool hideHydrogens=false)const;
294  virtual void SetUseGlobalScatteringPower(const bool useIt);
295  virtual void XMLOutput(ostream &os,int indent=0)const;
296  virtual void XMLInput(istream &is,const XMLCrystTag &tag);
297  //virtual void XMLInputOld(istream &is,const IOCrystTag &tag);
298  virtual void GetGeneGroup(const RefinableObj &obj,
299  CrystVector_uint & groupIndex,
300  unsigned int &firstGroup) const;
301  virtual void GlobalOptRandomMove(const REAL mutationAmplitude,
302  const RefParType *type=gpRefParTypeObjCryst);
304  const CrystVector_REAL& GetXCoord() const;
306  const CrystVector_REAL& GetYCoord() const;
308  const CrystVector_REAL& GetZCoord() const;
309  virtual void EndOptimization();
338  void ImportFenskeHallZMatrix(istream &is,bool named=false);
343  void ExportFenskeHallZMatrix(ostream &os);
345  void SetCenterAtomIndex(const unsigned int);
347  unsigned int GetCenterAtomIndex()const;
348  protected:
355  void UpdateCoordinates() const;
362  void UpdateScattCompList() const;
377  CrystMatrix_long m3DDisplayIndex;
381  long mNbAtom;
382  private:
384  virtual void InitRefParList();
385 
388 
394  CrystVector_int mComponentIndex;
395 
420  REAL mPhi,mChi,mPsi;
421 
427 
429  mutable CrystMatrix_REAL mPhiChiPsiMatrix;
430 
434 
438 
441  mutable CrystVector_REAL mXCoord,mYCoord,mZCoord;
444  ZMoveMinimizer *mpZMoveMinimizer;
445  #ifdef __WX__CRYST__
446  public:
447  virtual WXCrystObjBasic* WXCreate(wxWindow*);
448  friend class WXZScatterer;
449  #endif
450 };
451 
452 //######################################################################
453 //
454 // Different types of regular polyhedra
455 //
456 //######################################################################
457 
458 enum RegularPolyhedraType { TETRAHEDRON, OCTAHEDRON, SQUARE_PLANE, CUBE, ANTIPRISM_TETRAGONAL,
459  PRISM_TETRAGONAL_MONOCAP, PRISM_TETRAGONAL_DICAP,
460  PRISM_TRIGONAL,PRISM_TRIGONAL_TRICAPPED,
461  ICOSAHEDRON, TRIANGLE_PLANE};
462 
463 //######################################################################
470 //######################################################################
471 class ZPolyhedron: public ZScatterer
472 {
473  public:
492  ZPolyhedron( const RegularPolyhedraType type, Crystal &cryst,
493  const REAL x, const REAL y, const REAL z,
494  const string &name, const ScatteringPower *centralAtomPow,
495  const ScatteringPower *periphAtomPow,const REAL centralPeriphDist,
496  const REAL ligandPopu=1,
497  const REAL phi=0., const REAL chi=0., const REAL psi=0.);
499  ZPolyhedron(const ZPolyhedron&);
502  virtual ZPolyhedron* CreateCopy() const;
503 
504  /* \brief Copy constructor
505  *
506  ZPolyhedron(const ZPolyhedron &old);
507  */
508  protected:
509  private:
510  //Prepare refinable parameters for the scatterer object
511  //virtual void InitRefParList();
512 
514  RegularPolyhedraType mPolyhedraType;
515 };
516 
517 }//namespace
518 #include "ObjCryst/ObjCryst/Crystal.h"
519 
520 #endif //_OBJCRYST_ZSCATTERER_H_
const CrystVector_REAL & GetZCoord() const
Get the list of all ZAtom cartesian x coordinates.
CrystVector_int mComponentIndex
Index of atoms in the ScatteringComponentList.
Definition: ZScatterer.h:394
const REAL & GetZBondLength() const
Const access to bondlength parameter.
Definition: ZScatterer.cpp:98
const CrystVector_REAL & GetYCoord() const
Get the list of all ZAtom cartesian x coordinates.
void SetScatteringPower(const ScatteringPower *)
Set the ScatteringPower.
Definition: ZScatterer.cpp:108
unsigned int GetCenterAtomIndex() const
Get 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
void UpdateCoordinates() const
Update the atom coordinates (in real units, in Angstroems).
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
REAL GetZAtomY(const int i) const
Get the Y fractionnal coordinate of atom i.
Definition: ZScatterer.cpp:439
virtual REAL GetForwardScatteringFactor(const RadiationType) const
Get the scattering factor at (0,0,0).
CrystMatrix_REAL mPhiChiPsiMatrix
Rotation matrix for the orientation of the scatterer.
Definition: ZScatterer.h:429
virtual CrystVector_REAL GetTemperatureFactor(const ScatteringData &data, const int spgSymPosIndex=0) const
Get the temperature factor for all reflections of a given ScatteringData object.
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
REAL GetZAtomZ(const int i) const
Get the Z fractionnal coordinate of atom i.
Definition: ZScatterer.cpp:440
We need to record exactly when refinable objects have been modified for the last time (to avoid re-co...
Definition: RefinableObj.h:138
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
const CrystVector_REAL & GetXCoord() const
Get the list of all ZAtom cartesian x coordinates.
void SetZBondLength(const int i, const REAL)
Access to bondlength parameter, for the i-th row in the Z-Matrix.
Definition: ZScatterer.cpp:457
ZScatterer * mpScatt
the ZScatterer in which this atom is included.
Definition: ZScatterer.h:147
ScatteringComponentList mScattCompList
The list of scattering components.
Definition: ZScatterer.h:379
virtual void InitRefParList()
Prepare refinable parameters for the scatterer object.
wxCryst class for ZScatterer objects
Definition: wxZScatterer.h:46
RefinableObjClock mClockCoord
Last time the cartesian coordinates were computed.
Definition: ZScatterer.h:443
void SetChi(const REAL)
Access to chi parameter (overall orientation of the scatterer)
Definition: ZScatterer.cpp:435
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
virtual string GetComponentName(const int i) const
Name for the i-th component of this scatterer.
Definition: ZScatterer.cpp:417
Class to minimize conformation changes for random moves.
Definition: ZScatterer.h:168
virtual REAL GetLogLikelihood() const
Get -log(likelihood) of the current configuration for the object.
Definition: ZScatterer.cpp:153
const REAL & GetZAngle() const
Const access to the angle parameter.
Definition: ZScatterer.cpp:99
Global Scattering Power.
Definition: ZScatterer.h:52
void Print() const
Print a single line of information about this scatterer.
Definition: ZScatterer.cpp:422
long mCenterAtomIndex
Index of the atom used as a pivot (the scatterer is rotated around this atom).
Definition: ZScatterer.h:426
Class to compute structure factors for a set of reflections and a Crystal.
ZScatterer * mpZScatterer
a copy of the ZScatterer associated to this object
Definition: ZScatterer.h:74
void SetOccupancy(const REAL)
Access to the dihedral angle parameter.
Definition: ZScatterer.cpp:107
virtual CrystMatrix_REAL GetResonantScattFactReal(const ScatteringData &data, const int spgSymPosIndex=0) const
Get the real part of the resonant scattering factor.
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
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
virtual int GetNbComponent() const
Number of components in the scatterer (eg number of point scatterers)
Definition: ZScatterer.cpp:405
Generic Refinable Object.
Definition: RefinableObj.h:752
REAL GetZBondLength(const int i) const
Const access to bondlength parameter, for the i-th row in the Z-Matrix.
Definition: ZScatterer.cpp:450
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
CrystVector_REAL mXCoord
Storage for Cartesian coordinates.
Definition: ZScatterer.h:441
long mNbDummyAtom
Number of "dummy" atoms in the structure.
Definition: ZScatterer.h:387
void SetPhi(const REAL)
Access to phi parameter (overall orientation of the scatterer)
Definition: ZScatterer.cpp:434
Abstract base class for all objects in wxCryst.
Definition: wxCryst.h:127
virtual CrystVector_REAL GetScatteringFactor(const ScatteringData &data, const int spgSymPosIndex=0) const
Get the Scattering factor for all reflections of a given ScatteringData object.
Base object for Monte-Carlo Global Optimization methods.
const REAL & GetOccupancy() const
Const access to the ocupancy parameter.
Definition: ZScatterer.cpp:101
const ZScatterer & GetZScatterer() const
Get the ZScatterer associated to this ZAtom.
Definition: ZScatterer.cpp:92
void ExportFenskeHallZMatrix(ostream &os)
Export to Fenske-Hall ZMatrix file.
ObjRegistry< ZAtom > mZAtomRegistry
Registry for ZAtoms in this Scatterer.
Definition: ZScatterer.h:423
virtual ZPolyhedron * CreateCopy() const
const ScatteringPower * mpScattPow
The ScatteringPower corresponding to this atom.
Definition: ZScatterer.h:138
REAL mPhi
Angles giving the orientation of the ZScatterer (stored in radian)
Definition: ZScatterer.h:420
void SetZAngle(const REAL)
Access to the angle parameter.
Definition: ZScatterer.cpp:105
string mName
Name for this atom.
Definition: ZScatterer.h:145
Class to store POV-Ray output options.
Definition: General.h:175
Class for individual atoms in a ZScatterer Object.
Definition: ZScatterer.h:86
virtual void SetUseGlobalScatteringPower(const bool useIt)
use a Global scattering power for this scatterer ?
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 UpdateScattCompList() const
Update the scattering component list, ie compute all atom positions from the bonds/angles/dihedral an...
void ImportFenskeHallZMatrix(istream &is, bool named=false)
Import "Fenske-Hall" ZMatrix file (fhz in the babel program http://www.eyesopen.com/babel.html\ example: use "./babel -ipdb foo.pdb -ofhz foo.fhz -d", to convert a pdb file to a Z-Matrix file (the -d removes hydrogen atoms)
CrystMatrix_long m3DDisplayIndex
For 3D display of the structure, bonds, triangular and quadric faces can be displayed.
Definition: ZScatterer.h:377
virtual CrystMatrix_REAL GetResonantScattFactImag(const ScatteringData &data, const int spgSymPosIndex=0) const
Get the imaginary part of the resonant scattering factor.
virtual void GLInitDisplayList(const bool onlyIndependentAtoms=false, const REAL xMin=-.1, const REAL xMax=1.1, const REAL yMin=-.1, const REAL yMax=1.1, const REAL zMin=-.1, const REAL zMax=1.1, const bool displayEnantiomer=false, const bool displayNames=false, const bool hideHydrogens=false) const
Definition: ZScatterer.cpp:646
bool mUseGlobalScattPow
Does the ZScatterer use a global scattering power ?
Definition: ZScatterer.h:433
virtual void EndOptimization()
This should be called by any optimization class at the end of an optimization.
virtual const ScatteringComponentList & GetScatteringComponentList() const
Get the list of all scattering components for this scatterer.
Definition: ZScatterer.cpp:410
long mNbAtom
Total number of atoms in the structure.
Definition: ZScatterer.h:381
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
REAL GetPhi() const
Access to phi parameter (overall orientation of the scatterer)
Definition: ZScatterer.cpp:430
virtual const string & GetClassName() const
Name for this class ("RefinableObj", "Crystal",...).
Definition: ZScatterer.cpp:311
void SetZDihedralAngle(const REAL)
Access to the dihedral angle parameter.
Definition: ZScatterer.cpp:106
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
ZScatterer: the basic type of complex scatterers, where atom positions are defined using a standard "...
Definition: ZScatterer.h:190
virtual void GetGeneGroup(const RefinableObj &obj, CrystVector_uint &groupIndex, unsigned int &firstGroup) const
Get the gene group assigned to each parameter.
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
Definition: Atom.cpp:47
void SetCenterAtomIndex(const unsigned int)
Set the index of the central atom (around which the rotation is made)
const REAL & GetZDihedralAngle() const
Const access to the dihedral angle parameter.
Definition: ZScatterer.cpp:100
REAL GetChi() const
Access to chi parameter (overall orientation of the scatterer)
Definition: ZScatterer.cpp:431
REAL mBondLength
Bond length, angle and dihedral angle.
Definition: ZScatterer.h:143
virtual REAL GetRadius() const
Return the physical radius of this type of scatterer (for 3D display purposes).
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
RadiationType
Type of radiation used.
Definition: General.h:94
Crystal class: Unit cell, spacegroup, scatterers.
Definition: Crystal.h:97
void SetPsi(const REAL)
Access to psi parameter (overall orientation of the scatterer)
Definition: ZScatterer.cpp:436
void Init()
Initialization of the object, used by all constructors, and operator=.
class to input or output a well-formatted xml beginning or ending tag.
const ObjRegistry< ZAtom > & GetZAtomRegistry() const
Access to the registry of ZAtoms.
Definition: ZScatterer.cpp:466
REAL GetPsi() const
Access to psi parameter (overall orientation of the scatterer)
Definition: ZScatterer.cpp:432
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
class of refinable parameter types.
Definition: RefinableObj.h:78
list of scattering positions in a crystal, associated with the corresponding occupancy and a pointer ...
virtual ostream & POVRayDescription(ostream &os, const CrystalPOVRayOptions &options) const
Definition: ZScatterer.cpp:469
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.
GlobalScatteringPower * mpGlobalScattPow
the global scattering power used, if mUseGlobalScattPow=true
Definition: ZScatterer.h:437
virtual void GlobalOptRandomMove(const REAL mutationAmplitude, const RefParType *type=gpRefParTypeObjCryst)
Make a random move of the current configuration.
Generic type of scatterer: can be an atom, or a more complex assembly of atoms.
Definition: Scatterer.h:130
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 GetZAtomX(const int i) const
Get the X fractionnal coordinate of atom i.
Definition: ZScatterer.cpp:438
ZPolyhedron: a Scatterer to describe polyhedras such as octahedron, tetrahedron, square plane...
Definition: ZScatterer.h:471
virtual ZScatterer * CreateCopy() const
Definition: ZScatterer.cpp:306
const RefParType * gpRefParTypeObjCryst
Top RefParType for the ObjCryst++ library.
Object Registry.
Definition: RefinableObj.h:643
void SetZBondLength(const REAL)
Access to bondlength parameter.
Definition: ZScatterer.cpp:104
const ScatteringPower * GetScatteringPower() const
ScatteringPower for this atom.
Definition: ZScatterer.cpp:102
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
Abstract Base Class to describe the scattering power of any Scatterer component in a crystal...