FOX/ObjCryst++  1.10.X (development)
Molecule.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; version 2 of the License.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 /* Molecule.h
19 * header file for the Molecule scatterer
20 *
21 */
22 #ifndef _OBJCRYST_MOLECULE_H_
23 #define _OBJCRYST_MOLECULE_H_
24 
25 #include <string>
26 #include <vector>
27 #include <map>
28 #include <set>
29 #include <list>
30 
31 #include "ObjCryst/ObjCryst/General.h"
32 #include "ObjCryst/ObjCryst/ScatteringPower.h"
33 #include "ObjCryst/ObjCryst/Scatterer.h"
34 
35 
36 namespace ObjCryst
37 {
38 class MolAtom;
39 class MolBond;
40 class Molecule;
41 
43 struct XYZ
44 {
45  XYZ(REAL x=0,REAL y=0,REAL z=0);
46  REAL x,y,z;
47 };
48 
58 class MolAtom
59 {
60  public:
64  MolAtom(const REAL x, const REAL y, const REAL z,
65  const ScatteringPower *pPow, const string &name,
66  Molecule &parent);
71  virtual ~MolAtom();
72  void SetName(const string &name);
73  const string& GetName()const;
74  string& GetName();
75  const Molecule& GetMolecule()const;
76  Molecule& GetMolecule();
77  const REAL& X()const;
78  const REAL& Y()const;
79  const REAL& Z()const;
80  REAL& X();
81  REAL& Y();
82  REAL& Z();
83  REAL GetX()const;
84  REAL GetY()const;
85  REAL GetZ()const;
86  REAL GetOccupancy()const;
88  void SetX(const REAL)const;
94  void SetY(const REAL)const;
95  void SetZ(const REAL)const;
97  void SetOccupancy(const REAL);
102  bool IsDummy()const;
103  const ScatteringPower& GetScatteringPower()const;
104  void SetScatteringPower(const ScatteringPower&);
105  virtual void XMLOutput(ostream &os,int indent=0)const;
106  virtual void XMLInput(istream &is,const XMLCrystTag &tag);
110  void SetIsInRing(const bool r)const;
111  bool IsInRing()const;
112  private:
114  string mName;
115  /* Get the atom at the other end of bond #i
116  MolAtom & GetBondedAtom(unsigned int i);
117  */
123  mutable REAL mX,mY,mZ;
131  mutable bool mIsInRing;
132  #ifdef __WX__CRYST__
133  public:
134  WXCrystObjBasic *mpWXCrystObj;
135  virtual WXCrystObjBasic* WXCreate(wxWindow*);
136  WXCrystObjBasic* WXGet();
137  void WXDelete();
138  void WXNotifyDelete();
139  #endif
140 };
141 
143 REAL GetBondLength(const MolAtom&,const MolAtom&);
145 REAL GetBondAngle(const MolAtom&,const MolAtom&,const MolAtom&);
147 REAL GetDihedralAngle(const MolAtom&,const MolAtom&,const MolAtom&,const MolAtom&);
148 
152 class MolBond:public Restraint
153 {
154  public:
173  MolBond(MolAtom &atom1, MolAtom &atom2,
174  const REAL length, const REAL sigma, const REAL delta,
175  Molecule &parent,const REAL bondOrder=1.);
180  virtual ~MolBond();
181  const Molecule& GetMolecule()const;
182  Molecule& GetMolecule();
184  string GetName()const;
185  virtual void XMLOutput(ostream &os,int indent=0)const;
186  virtual void XMLInput(istream &is,const XMLCrystTag &tag);
187  virtual REAL GetLogLikelihood()const;
188  REAL GetLogLikelihood(const bool calcDeriv, const bool recalc)const;
192  REAL GetDeriv(const std::map<const MolAtom*,XYZ> &m, const bool llk=false)const;
200  void CalcGradient(std::map<MolAtom*,XYZ> &m)const;
201  const MolAtom& GetAtom1()const;
202  const MolAtom& GetAtom2()const;
203  MolAtom& GetAtom1();
204  MolAtom& GetAtom2();
205  void SetAtom1(MolAtom &at1);
206  void SetAtom2(MolAtom &at2);
207  REAL GetLength()const;
208  REAL GetLength0()const;
209  REAL GetLengthDelta()const;
210  REAL GetLengthSigma()const;
211  REAL GetBondOrder()const;
212  REAL& Length0();
213  REAL& LengthDelta();
214  REAL& LengthSigma();
215  REAL& BondOrder();
216  void SetLength0(const REAL length);
217  void SetLengthDelta(const REAL length);
218  void SetLengthSigma(const REAL length);
219  void SetBondOrder(const REAL length);
220  bool IsFreeTorsion()const;
221  void SetFreeTorsion(const bool isInRing);
222  private:
223  pair<MolAtom*,MolAtom*> mAtomPair;
224  REAL mLength0,mDelta,mSigma;
225  REAL mBondOrder;
226  bool mIsFreeTorsion;
230  mutable REAL mLLK;
235  mutable XYZ mDerivAtom1,mDerivAtom2;
239  mutable REAL mDerivLLKCoeff;
240  #ifdef __WX__CRYST__
241  public:
242  WXCrystObjBasic *mpWXCrystObj;
243  virtual WXCrystObjBasic* WXCreate(wxWindow*);
244  WXCrystObjBasic* WXGet();
245  void WXDelete();
246  void WXNotifyDelete();
247  #endif
248 };
249 
257 {
258  public:
262  MolBondAngle(MolAtom &atom1,MolAtom &atom2,MolAtom &atom3,
263  const REAL angle, const REAL sigma, const REAL delta,
264  Molecule &parent);
268  virtual ~MolBondAngle();
269  const Molecule& GetMolecule()const;
270  Molecule& GetMolecule();
271  string GetName()const;
272  virtual void XMLOutput(ostream &os,int indent=0)const;
273  virtual void XMLInput(istream &is,const XMLCrystTag &tag);
274  virtual REAL GetLogLikelihood()const;
275  REAL GetLogLikelihood(const bool calcDeriv, const bool recalc)const;
279  REAL GetDeriv(const std::map<const MolAtom*,XYZ> &m, const bool llk=false)const;
287  void CalcGradient(std::map<MolAtom*,XYZ> &m)const;
288  REAL GetAngle()const;
289  REAL& Angle0();
290  REAL& AngleDelta();
291  REAL& AngleSigma();
292  REAL GetAngle0()const;
293  REAL GetAngleDelta()const;
294  REAL GetAngleSigma()const;
295  void SetAngle0(const REAL angle);
296  void SetAngleDelta(const REAL delta);
297  void SetAngleSigma(const REAL sigma);
298  const MolAtom& GetAtom1()const;
299  const MolAtom& GetAtom2()const;
300  const MolAtom& GetAtom3()const;
301  void SetAtom1(MolAtom &at);
302  void SetAtom2(MolAtom &at);
303  void SetAtom3(MolAtom &at);
304  MolAtom& GetAtom1();
305  MolAtom& GetAtom2();
306  MolAtom& GetAtom3();
307  bool IsFlexible()const;
308  void SetFlexible(const bool isInRing);
309  private:
311  vector<MolAtom*> mvpAtom;
312  REAL mAngle0,mDelta,mSigma;
320  mutable REAL mLLK;
325  mutable XYZ mDerivAtom1,mDerivAtom2,mDerivAtom3;
329  mutable REAL mDerivLLKCoeff;
330  #ifdef __WX__CRYST__
331  public:
332  WXCrystObjBasic *mpWXCrystObj;
333  virtual WXCrystObjBasic* WXCreate(wxWindow*);
334  WXCrystObjBasic* WXGet();
335  void WXDelete();
336  void WXNotifyDelete();
337  #endif
338 };
339 
347 {
348  public:
352  MolDihedralAngle(MolAtom &atom1, MolAtom &atom2,
353  MolAtom &atom3, MolAtom &atom4,
354  const REAL angle, const REAL sigma, const REAL delta,
355  Molecule &parent);
359  virtual ~MolDihedralAngle();
360  const Molecule& GetMolecule()const;
361  Molecule& GetMolecule();
362  string GetName()const;
363  virtual void XMLOutput(ostream &os,int indent=0)const;
364  virtual void XMLInput(istream &is,const XMLCrystTag &tag);
365  virtual REAL GetLogLikelihood()const;
366  REAL GetLogLikelihood(const bool calcDeriv, const bool recalc)const;
370  REAL GetDeriv(const std::map<const MolAtom*,XYZ> &m, const bool llk=false)const;
378  void CalcGradient(std::map<MolAtom*,XYZ> &m)const;
379  REAL GetAngle()const;
380  REAL& Angle0();
381  REAL& AngleDelta();
382  REAL& AngleSigma();
383  REAL GetAngle0()const;
384  REAL GetAngleDelta()const;
385  REAL GetAngleSigma()const;
386  void SetAngle0(const REAL angle);
387  void SetAngleDelta(const REAL delta);
388  void SetAngleSigma(const REAL sigma);
389  const MolAtom& GetAtom1()const;
390  const MolAtom& GetAtom2()const;
391  const MolAtom& GetAtom3()const;
392  const MolAtom& GetAtom4()const;
393  void SetAtom1(MolAtom& at);
394  void SetAtom2(MolAtom& at);
395  void SetAtom3(MolAtom& at);
396  void SetAtom4(MolAtom& at);
397  MolAtom& GetAtom1();
398  MolAtom& GetAtom2();
399  MolAtom& GetAtom3();
400  MolAtom& GetAtom4();
401  private:
403  vector<MolAtom*> mvpAtom;
404  REAL mAngle0, mDelta, mSigma;
408  mutable REAL mLLK;
413  mutable XYZ mDerivAtom1,mDerivAtom2,mDerivAtom3,mDerivAtom4;
417  mutable REAL mDerivLLKCoeff;
418  #ifdef __WX__CRYST__
419  public:
420  WXCrystObjBasic *mpWXCrystObj;
421  virtual WXCrystObjBasic* WXCreate(wxWindow*);
422  WXCrystObjBasic* WXGet();
423  void WXDelete();
424  void WXNotifyDelete();
425  #endif
426 };
427 
434 class MolRing
435 {
436  public:
437  MolRing();
438  const std::list<MolAtom*>& GetAtomList()const;
439  std::list<MolAtom*>& GetAtomList();
440  private:
441  std::list<MolAtom*> mvpAtom;
442 };
443 
449 {
450  public:
452  Quaternion();
454  Quaternion(const REAL q0,const REAL q1,const REAL q2,const REAL q3,bool unit=true);
455  ~Quaternion();
457  static Quaternion RotationQuaternion(const REAL ang,const REAL v1,const REAL v2,const REAL v3);
459  Quaternion GetConjugate()const;
461  Quaternion operator*(const Quaternion &q)const;
462  void operator*=(const Quaternion &q);
463  void XMLOutput(ostream &os,int indent=0)const;
464  void XMLInput(istream &is,const XMLCrystTag &tag);
466  void RotateVector(REAL &v1,REAL &v2, REAL &v3)const;
472  void Normalize()const ;
473  REAL GetNorm()const;
474  const REAL& Q0()const;
475  const REAL& Q1()const;
476  const REAL& Q2()const;
477  const REAL& Q3()const;
478  REAL& Q0();
479  REAL& Q1();
480  REAL& Q2();
481  REAL& Q3();
482  private:
486  mutable REAL mQ0,mQ1,mQ2,mQ3;
487  bool mIsUniQuaternion;
488 };
489 
500 class RigidGroup:public std::set<MolAtom *>
501 {
502  public:
503  std::string GetName()const;
508  mutable Quaternion mQuat;
511  mutable REAL mX,mY,mZ;
514  mutable std::set<unsigned int> mvIdx;
515 };
516 
521 {
522  virtual ~StretchMode();
531  virtual void CalcDeriv(const bool derivllk=true)const=0;
533  virtual void Print(ostream &os,bool full=true)const=0;
535  virtual void Stretch(const REAL change, const bool keepCenter=true)=0;
537  virtual void RandomStretch(const REAL amplitude, const bool keepCenter=true)=0;
540  std::map<const MolBond*,REAL> mvpBrokenBond;
543  std::map<const MolBondAngle*,REAL> mvpBrokenBondAngle;
546  std::map<const MolDihedralAngle*,REAL> mvpBrokenDihedralAngle;
548  mutable REAL mLLKDeriv;
550  mutable std::map<const MolAtom*,XYZ> mDerivXYZ;
561 };
562 
568 {
572  StretchModeBondLength(MolAtom &at0,MolAtom &at1,const MolBond *pBond);
573  virtual ~StretchModeBondLength();
574  virtual void CalcDeriv(const bool derivllk=true)const;
576  virtual void Print(ostream &os,bool full=true)const;
578  virtual void Stretch(const REAL change, const bool keepCenter=true);
580  virtual void RandomStretch(const REAL amplitude, const bool keepCenter=true);
586  const MolBond *mpBond;
588  set<MolAtom *> mvTranslatedAtomList;
589 };
590 
596 {
601  const MolBondAngle *pBondAngle);
602  virtual ~StretchModeBondAngle();
603  virtual void CalcDeriv(const bool derivllk=true)const;
605  virtual void Print(ostream &os,bool full=true)const;
607  virtual void Stretch(const REAL change, const bool keepCenter=true);
609  virtual void RandomStretch(const REAL amplitude, const bool keepCenter=true);
620  set<MolAtom *> mvRotatedAtomList;
621 };
627 {
632  const MolDihedralAngle *pDihedralAngle);
633  virtual ~StretchModeTorsion();
634  virtual void CalcDeriv(const bool derivllk=true)const;
636  virtual void Print(ostream &os,bool full=true)const;
638  virtual void Stretch(const REAL change, const bool keepCenter=true);
640  virtual void RandomStretch(const REAL amplitude, const bool keepCenter=true);
649  set<MolAtom *> mvRotatedAtomList;
650 };
651 
659 {
663  StretchModeTwist(MolAtom &at1,MolAtom &at2);
664  virtual ~StretchModeTwist();
665  virtual void CalcDeriv(const bool derivllk=true)const;
667  virtual void Print(ostream &os,bool full=true)const;
669  virtual void Stretch(const REAL change, const bool keepCenter=true);
671  virtual void RandomStretch(const REAL amplitude, const bool keepCenter=true);
677  set<MolAtom *> mvRotatedAtomList;
678 };
679 
686 {
688  MDAtomGroup();
693  MDAtomGroup(std::set<MolAtom*> &vat,
694  std::set<MolBond*> &vb,
695  std::set<MolBondAngle*> &va,
696  std::set<MolDihedralAngle*> &vd);
698  void Print(ostream &os,bool full=true)const;
699  std::set<MolAtom*> mvpAtom;
700  std::vector<MolBond*> mvpBond;
701  std::vector<MolBondAngle*> mvpBondAngle;
702  std::vector<MolDihedralAngle*> mvpDihedralAngle;
703 };
704 
710 struct MolZAtom
711 {
712  const ScatteringPower *mpPow;
713  unsigned long mBondAtom,mBondAngleAtom,mDihedralAtom;
714  REAL mBondLength,mBondAngle,mDihedralAngle;
715 };
716 
731 class Molecule: public Scatterer
732 {
733  public:
737  Molecule(Crystal &cryst, const string &name="");
741  Molecule(const Molecule &old);
745  ~Molecule();
746  virtual Molecule* CreateCopy() const;
747  virtual const string& GetClassName() const;
748  virtual void SetName(const string &name);
750  std::string GetFormula() const;
751  virtual void Print()const;
752  virtual void XMLOutput(ostream &os,int indent=0)const;
753  virtual void XMLInput(istream &is,const XMLCrystTag &tag);
754  virtual void UpdateDisplay()const;
755  virtual void BeginOptimization(const bool allowApproximations=false,const bool enableRestraints=false);
756  virtual void EndOptimization();
757  virtual void RandomizeConfiguration();
758  virtual void GlobalOptRandomMove(const REAL mutationAmplitude,
759  const RefParType *type);
760  virtual REAL GetLogLikelihood()const;
761 
762  virtual unsigned int GetNbLSQFunction()const;
763  virtual const CrystVector_REAL& GetLSQCalc(const unsigned int) const;
764  virtual const CrystVector_REAL& GetLSQObs(const unsigned int) const;
765  virtual const CrystVector_REAL& GetLSQWeight(const unsigned int) const;
766  virtual const CrystVector_REAL& GetLSQDeriv(const unsigned int n, RefinablePar&par);
767 
768  virtual void TagNewBestConfig()const;
769  virtual int GetNbComponent() const;
771  virtual string GetComponentName(const int i) const;
772  virtual ostream& POVRayDescription(ostream &os,
773  const CrystalPOVRayOptions &options)const;
774  virtual void GLInitDisplayList(const bool onlyIndependentAtoms=false,
775  const REAL xMin=-.1,const REAL xMax=1.1,
776  const REAL yMin=-.1,const REAL yMax=1.1,
777  const REAL zMin=-.1,const REAL zMax=1.1,
778  const bool displayEnantiomer=false,
779  const bool displayNames=false,
780  const bool hideHydrogens=false)const;
785  void AddAtom(const REAL x, const REAL y, const REAL z,
786  const ScatteringPower *pPow,const string &name,
787  const bool updateDisplay=true);
795  vector<MolAtom*>::iterator RemoveAtom(MolAtom&, const bool del = true);
796 
797  void AddNonFlipAtom(MolAtom &atom);
798  void removeNonFlipAtom(MolAtom &atom);
799  vector<MolAtom*> getNonFlipAtomList();
800 
805  void AddBond(MolAtom &atom1, MolAtom &atom2,
806  const REAL length, const REAL sigma, const REAL delta,
807  const REAL bondOrder=1.,
808  const bool updateDisplay=true);
814  vector<MolBond*>::iterator RemoveBond(const MolBond&, const bool del = true);
819  vector<MolBond*>::const_iterator FindBond(const MolAtom&,const MolAtom&)const;
824  vector<MolBond*>::iterator FindBond(const MolAtom&,const MolAtom&);
829  void AddBondAngle(MolAtom &atom1, MolAtom &atom2, MolAtom &atom3,
830  const REAL angle, const REAL sigma, const REAL delta,
831  const bool updateDisplay=true);
836  vector<MolBondAngle*>::iterator RemoveBondAngle(const MolBondAngle&, const bool del = true);
842  vector<MolBondAngle*>::const_iterator FindBondAngle(const MolAtom& at1,const MolAtom&at0,const MolAtom&at2)const;
847  void AddDihedralAngle(MolAtom &atom1, MolAtom &atom2,
848  MolAtom &atom3, MolAtom &atom4,
849  const REAL angle, const REAL sigma, const REAL delta,
850  const bool updateDisplay=true);
855  vector<MolDihedralAngle*>::iterator RemoveDihedralAngle(const MolDihedralAngle&, const bool del = true);
861  vector<MolDihedralAngle*>::const_iterator FindDihedralAngle(const MolAtom &at1,
862  const MolAtom &at2,
863  const MolAtom &at3,
864  const MolAtom &at4)const;
867  void AddRigidGroup(const RigidGroup&,const bool updateDisplay=true);
872  std::vector<RigidGroup*>::iterator RemoveRigidGroup(const RigidGroup &group,const bool updateDisplay=true, const bool del = true);
873 
874  MolAtom &GetAtom(unsigned int i);
875  const MolAtom &GetAtom(unsigned int i)const;
876  MolAtom &GetAtom(const string &name);
877  const MolAtom &GetAtom(const string &name)const;
878 
881  vector<MolAtom*>::reverse_iterator FindAtom(const string &name);
884  vector<MolAtom*>::const_reverse_iterator FindAtom(const string &name)const;
885 
890  void OptimizeConformation(const long nbTrial=10000,const REAL stopCost=0.);
897  void OptimizeConformationSteepestDescent(const REAL maxStep=0.1,const unsigned nbStep=1);
921  void MolecularDynamicsEvolve(std::map<MolAtom*,XYZ> &v0,const unsigned nbStep,const REAL dt,
922  const std::vector<MolBond*> &vb,const std::vector<MolBondAngle*> &va,
923  const std::vector<MolDihedralAngle*> &vd,
924  std::map<RigidGroup*,std::pair<XYZ,XYZ> > &vr, REAL nrj0=0);
925  const std::vector<MolAtom*>& GetAtomList()const;
926  const std::vector<MolBond*>& GetBondList()const;
927  const std::vector<MolBondAngle*>& GetBondAngleList()const;
928  const std::vector<MolDihedralAngle*>& GetDihedralAngleList()const;
929  std::vector<MolAtom*>& GetAtomList();
930  std::vector<MolBond*>& GetBondList();
931  std::vector<MolBondAngle*>& GetBondAngleList();
932  std::vector<MolDihedralAngle*>& GetDihedralAngleList();
933 
934  std::list<StretchModeBondLength>& GetStretchModeBondLengthList();
935  std::list<StretchModeBondAngle>& GetStretchModeBondAngleList();
936  std::list<StretchModeTorsion>& GetStretchModeTorsionList();
937 
938  const std::list<StretchModeBondLength>& GetStretchModeBondLengthList()const;
939  const std::list<StretchModeBondAngle>& GetStretchModeBondAngleList()const;
940  const std::list<StretchModeTorsion>& GetStretchModeTorsionList()const;
941 
944  const std::vector<RigidGroup *>& GetRigidGroupList()const;
947  std::vector<RigidGroup *>& GetRigidGroupList();
948 
954  void RotateAtomGroup(const MolAtom &at1,const MolAtom &at2,
955  const set<MolAtom *> &atoms, const REAL angle,
956  const bool keepCenter=true);
962  void RotateAtomGroup(const MolAtom &at,const REAL vx,const REAL vy,const REAL vz,
963  const set<MolAtom *> &atoms, const REAL angle,
964  const bool keepCenter=true);
970  void TranslateAtomGroup(const set<MolAtom *> &atoms,
971  const REAL dx,const REAL dy,const REAL dz,
972  const bool keepCenter=true);
974  void RestraintStatus(ostream &os)const;
976  void RestraintExport(ostream &os)const;
978  const map<MolAtom *,set<MolAtom *> > & GetConnectivityTable();
982  const RefinableObjClock& GetBondListClock()const;
1007  REAL BondLengthRandomChange(const StretchModeBondLength& mode, const REAL amplitude,
1008  const bool respectRestraint=true);
1015  REAL BondAngleRandomChange(const StretchModeBondAngle& mode, const REAL amplitude,
1016  const bool respectRestraint=true);
1023  REAL DihedralAngleRandomChange(const StretchModeTorsion& mode, const REAL amplitude,
1024  const bool respectRestraint=true);
1027  const MolAtom* GetCenterAtom()const;
1030  void SetCenterAtom(const MolAtom &at);
1036  const std::vector<MolZAtom>& AsZMatrix(const bool keeporder)const;
1041  void SetDeleteSubObjInDestructor(const bool b);
1042  public:
1043  virtual void InitRefParList();
1053  void BuildRingList();
1057  void BuildConnectivityTable()const;
1063  void BuildRotorGroup();
1075  void BuildFlipGroup();
1087  void BuildStretchModeTorsion();
1091  void BuildStretchModeTwist();
1095  void BuildStretchModeGroups();
1106  void BuildMDAtomGroups();
1110  void UpdateScattCompList()const;
1112  void InitOptions();
1118  void ResetRigidGroupsPar()const;
1124 
1125  vector<MolAtom*> mvNonFlipAtom;
1129  vector<MolAtom*> mvpAtom;
1133  vector<MolBond*> mvpBond;
1137  vector<MolBondAngle*> mvpBondAngle;
1141  vector<MolDihedralAngle*> mvpDihedralAngle;
1146  map<MolAtom* , std::vector<MolBond*> > mvAtomBond;
1151  std::vector<RigidGroup*> mvRigidGroup;
1156  mutable list<MolRing> mvRing;
1166  // Flag indicating whether to destroy MolAtoms, MolBonds, MolBondAngles,
1167  // and MolDihedralAngles in the destructor (default true). Mofified by
1168  // SetDeleteSubObjInDestructor.
1170  REAL mBaseRotationAmplitude;
1171  // Clocks
1172  RefinableObjClock mClockAtomList;
1173  RefinableObjClock mClockBondList;
1174  RefinableObjClock mClockBondAngleList;
1175  RefinableObjClock mClockDihedralAngleList;
1176  RefinableObjClock mClockRigidGroup;
1177  RefinableObjClock mClockAtomPosition;
1178  RefinableObjClock mClockAtomScattPow;
1179  RefinableObjClock mClockOrientation;
1180  mutable RefinableObjClock mClockLogLikelihood;
1181  mutable RefinableObjClock mClockConnectivityTable;
1182  mutable RefinableObjClock mClockRingList;
1183  mutable RefinableObjClock mClockRotorGroup;
1184  mutable RefinableObjClock mClockFlipGroup;
1185  mutable RefinableObjClock mClockStretchModeBondLength;
1186  mutable RefinableObjClock mClockStretchModeBondAngle;
1187  mutable RefinableObjClock mClockStretchModeTorsion;
1188  mutable RefinableObjClock mClockStretchModeTwist;
1189  mutable RefinableObjClock mClockMDAtomGroup;
1190 
1191  // For local minimization (EXPERIMENTAL)
1192  unsigned long mLocalParamSet;
1193  mutable unsigned long mRandomConformChangeNbTest;
1194  mutable unsigned long mRandomConformChangeNbAccept;
1195  mutable REAL mRandomConformChangeTemp;
1196  REAL mLastLogLike;
1197  bool mIsSelfOptimizing;
1202 
1203  RefObjOpt mFlipModel;
1204 
1212 
1217 
1222 
1227 
1230  mutable map<MolAtom *,set<MolAtom *> > mConnectivityTable;
1234  struct RotorGroup
1235  {
1239  RotorGroup(const MolAtom &at1,const MolAtom &at2);
1241  const MolAtom * mpAtom1;
1243  const MolAtom * mpAtom2;
1245  set<MolAtom *> mvRotatedAtomList;
1254  };
1261  mutable list<RotorGroup> mvRotorGroupTorsion;
1270  mutable list<RotorGroup> mvRotorGroupTorsionSingleChain;
1276  mutable list<RotorGroup> mvRotorGroupInternal;
1287  struct FlipGroup
1288  {
1291  FlipGroup(const MolAtom &at0,const MolAtom &at1,const MolAtom &at2);
1293  const MolAtom * mpAtom0;
1295  const MolAtom * mpAtom1;
1297  const MolAtom * mpAtom2;
1304  list<pair<const MolAtom *,set<MolAtom *> > > mvRotatedChainList;
1309  mutable unsigned long mNbTest,mNbAccept;
1310  };
1312  void FlipAtomGroup(const FlipGroup&, const bool keepCenter=true);
1316  mutable list<FlipGroup> mvFlipGroup;
1317 
1318  // Group of atoms for random moves naturally respecting restraints
1320  mutable list<StretchModeBondLength> mvStretchModeBondLength;
1322  mutable list<StretchModeBondAngle> mvStretchModeBondAngle;
1324  mutable list<StretchModeTorsion> mvStretchModeTorsion;
1326  mutable list<StretchModeTwist> mvStretchModeTwist;
1327 
1329  mutable std::list<StretchMode*> mvpStretchModeFree;
1331  mutable std::list<StretchMode*> mvpStretchModeNotFree;
1335  {
1336  std::set<StretchMode*> mvpStretchMode;
1337  std::set<const MolBond*> mvpBrokenBond;
1338  std::set<const MolBondAngle*> mvpBrokenBondAngle;
1339  std::set<const MolDihedralAngle*> mvpBrokenDihedralAngle;
1340  };
1344  mutable list<MDAtomGroup> mvMDAtomGroup;
1347  mutable std::set<MolAtom*> mvMDFullAtomGroup;
1348 
1354 
1356  mutable std::vector<MolZAtom> mAsZMatrix;
1357 
1359  mutable REAL mLogLikelihood;
1368  mutable CrystVector_REAL mLSQCalc;
1370  mutable CrystVector_REAL mLSQObs;
1372  mutable CrystVector_REAL mLSQWeight;
1373 
1374  #ifdef __WX__CRYST__
1375  public:
1376  virtual WXCrystObjBasic* WXCreate(wxWindow*);
1377  #endif
1378 };
1379 
1392  const map<MolAtom*,set<MolAtom*> > &connect,
1393  set<MolAtom*> &atomlist,const MolAtom* finalAtom=0);
1394 
1407  const map<MolAtom*,set<MolAtom*> > &connect,
1408  map<MolAtom*,unsigned long> &atomlist,const unsigned long maxdepth, unsigned long depth=0);
1409 
1410 
1411 }//namespace
1412 #endif
MolAtom(const REAL x, const REAL y, const REAL z, const ScatteringPower *pPow, const string &name, Molecule &parent)
Constructor for a MolAtom.
Definition: Molecule.cpp:188
RotorGroup(const MolAtom &at1, const MolAtom &at2)
Constructor, with the two atoms around which the rotation shall be made.
Definition: Molecule.cpp:5333
list< MDAtomGroup > mvMDAtomGroup
Groups of atoms that should be moved according to molecular dynamics principles.
Definition: Molecule.h:1344
REAL mOccupancy
Occupancy.
Definition: Molecule.h:125
void RestraintExport(ostream &os) const
Print the restraints (bond length, angles...) as whole labels and number in column text format which ...
Definition: Molecule.cpp:4526
map< MolAtom *, set< MolAtom * > > mConnectivityTable
Connectivity table: for each atom, keep the list of atoms bonded to it.
Definition: Molecule.h:1230
MolAtom * mpAtom1
The second atom (first atom moved)
Definition: Molecule.h:584
StretchModeTwist(MolAtom &at1, MolAtom &at2)
Constructor If pDihedralAngle!=0, the dihedral angle length restraint is respected.
Definition: Molecule.cpp:1766
XYZ mDerivAtom1
Partial derivatives of the angle with respect to the coordinates of the atoms.
Definition: Molecule.h:325
vector< MolDihedralAngle * >::iterator RemoveDihedralAngle(const MolDihedralAngle &, const bool del=true)
Remove a dihedral angle.
Definition: Molecule.cpp:4036
vector< MolBond * > mvpBond
The list of bonds.
Definition: Molecule.h:1133
void BuildRotorGroup()
Build the groups of atoms that will be rotated during global optimization.
Definition: Molecule.cpp:5337
REAL mLLK
Stored log(likelihood)
Definition: Molecule.h:320
REAL mX
The translation of all the atoms as a group The values will be resetted whenever entering or leaving ...
Definition: Molecule.h:511
Bond angle restraint between 3 atoms.
Definition: Molecule.h:256
unsigned long mNbTest
Number of times this flip has been tried, and the number of times it has been accepted.
Definition: Molecule.h:1309
void TuneGlobalOptimRotationAmplitude()
Tune the rotation amplitude for free torsions and for the overall Molecule Rotation.
Definition: Molecule.cpp:6861
virtual void Print(ostream &os, bool full=true) const
Print one-line list of atoms moved.
Definition: Molecule.cpp:1735
vector< MolDihedralAngle * >::const_iterator FindDihedralAngle(const MolAtom &at1, const MolAtom &at2, const MolAtom &at3, const MolAtom &at4) const
Searches whether a dihedral between four atoms already exists, searching for either (at1...
Definition: Molecule.cpp:4056
Molecule * mpMol
Parent Molecule.
Definition: Molecule.h:314
virtual void Stretch(const REAL change, const bool keepCenter=true)
Move the atoms according to this mode.
Definition: Molecule.cpp:1562
virtual REAL GetLogLikelihood() const
Get -ln(likelihood) for this restraint.
Definition: Molecule.cpp:1066
bool mIsInRing
Is the atom in a ring ?
Definition: Molecule.h:131
Atoms moved when changing a bond angle.
Definition: Molecule.h:595
REAL GetBondLength(const MolAtom &at1, const MolAtom &at2)
Get The Bond Length between two atoms.
Definition: Molecule.cpp:59
MolBondAngle(MolAtom &atom1, MolAtom &atom2, MolAtom &atom3, const REAL angle, const REAL sigma, const REAL delta, Molecule &parent)
Constructor.
Definition: Molecule.cpp:626
virtual void CalcDeriv(const bool derivllk=true) const
Calculate the derivative of the Molecule's Log(likelihood) and atomic positions versus a change of th...
Definition: Molecule.cpp:1693
virtual const string & GetClassName() const
Name for this class ("RefinableObj", "Crystal",...).
Definition: Molecule.cpp:2106
set< MolAtom * > mvRotatedAtomList
The set of atoms that are to be rotated around the direction going through at1 and perpendicular to t...
Definition: Molecule.h:620
We need to record exactly when refinable objects have been modified for the last time (to avoid re-co...
Definition: RefinableObj.h:138
std::map< const MolAtom *, XYZ > mDerivXYZ
Derivative of the atomic positions versus a change of the bond length.
Definition: Molecule.h:550
virtual ~MolAtom()
Destructor.
Definition: Molecule.cpp:198
void BuildFlipGroup()
Build the groups of atoms that can be flipped.
Definition: Molecule.cpp:7040
Ring class.
Definition: Molecule.h:434
string GetName() const
Name of the bond, e.g. "C3-O4".
Definition: Molecule.cpp:368
vector< MolBond * >::const_iterator FindBond(const MolAtom &, const MolAtom &) const
Searches whether a bond between two atoms already exists.
Definition: Molecule.cpp:3955
CrystVector_REAL mLSQObs
Current LSQ Calc - one value for each restraint (bond distance, angle or dihedral angle ideal values)...
Definition: Molecule.h:1370
MolAtom * mpAtom2
The third atom.
Definition: Molecule.h:615
std::vector< RigidGroup * >::iterator RemoveRigidGroup(const RigidGroup &group, const bool updateDisplay=true, const bool del=true)
Remove a rigid group of atoms.
Definition: Molecule.cpp:4153
REAL mLLK
Stored log(likelihood)
Definition: Molecule.h:408
virtual void Stretch(const REAL change, const bool keepCenter=true)
Move the atoms according to this mode.
Definition: Molecule.cpp:1830
void BuildStretchModeTorsion()
Build the groups of atoms moved when changing a dihedral angle, while respecting the Molecule restrai...
Definition: Molecule.cpp:6181
REAL mDerivLLKCoeff
The factor used to change the derivative of the length/angle, to the derivative of the log(likelihood...
Definition: Molecule.h:239
const MolAtom * mpCenterAtom
Atom chosen as center of rotation, if mRotationCenter is set to use an atom rather than the geometric...
Definition: Molecule.h:1226
StretchModeBondLength(MolAtom &at0, MolAtom &at1, const MolBond *pBond)
Constructor If pBond!=0, the bond length restraint is respected.
Definition: Molecule.cpp:1504
list< StretchModeBondLength > mvStretchModeBondLength
List of StretchModeBondLength.
Definition: Molecule.h:1320
virtual void GlobalOptRandomMove(const REAL mutationAmplitude, const RefParType *type)
Make a random move of the current configuration.
Definition: Molecule.cpp:2652
vector< MolAtom * > mvpAtom
The vector of the 3 atoms involved in the bond angle.
Definition: Molecule.h:311
Molecule * mpMol
The Molecule corresponding to this stretch mode.
Definition: Molecule.h:552
virtual void TagNewBestConfig() const
During a global optimization, tells the object that the current config is the latest "best" config...
Definition: Molecule.cpp:3124
MolAtom * mpAtom1
The first atom.
Definition: Molecule.h:673
const MolAtom * mpAtom1
The first atom defining the rotation axis.
Definition: Molecule.h:1295
virtual void Print(ostream &os, bool full=true) const
Print one-line list of atoms moved.
Definition: Molecule.cpp:1647
void AddBondAngle(MolAtom &atom1, MolAtom &atom2, MolAtom &atom3, const REAL angle, const REAL sigma, const REAL delta, const bool updateDisplay=true)
Add a bond angle restraint.
Definition: Molecule.cpp:3976
virtual REAL GetLogLikelihood() const
Get -ln(likelihood) for this restraint.
Definition: Molecule.cpp:454
FlipGroup(const MolAtom &at0, const MolAtom &at1, const MolAtom &at2)
Constructor, with the central atom.
Definition: Molecule.cpp:7717
bool mDeleteSubObjInDestructor
Base Rotation amplitude (in radians) for the Molecule, so that the average atomic displacement is equ...
Definition: Molecule.h:1169
virtual const CrystVector_REAL & GetLSQDeriv(const unsigned int n, RefinablePar &par)
Get the first derivative values for the LSQ function, for a given parameter.
Definition: Molecule.cpp:3118
Quaternion mQuat
The unit quaternion defining the orientation - this is used during optimizations to rotate all atoms ...
Definition: Molecule.h:508
void ResetRigidGroupsPar() const
Set the orientation & translation parameters of all rigid groups to 0, after correcting the atomic po...
Definition: Molecule.cpp:7806
virtual const CrystVector_REAL & GetLSQObs(const unsigned int) const
Get the observed values for the LSQ function.
Definition: Molecule.cpp:3090
REAL DihedralAngleRandomChange(const StretchModeTorsion &mode, const REAL amplitude, const bool respectRestraint=true)
Change a dihedral angle, while respecting the Restraint (if any).
Definition: Molecule.cpp:4988
vector< MolAtom * > mvpAtom
The list of atoms.
Definition: Molecule.h:1129
std::vector< RigidGroup * > mvRigidGroup
Rigid groups of atoms.
Definition: Molecule.h:1151
StretchModeBondAngle(MolAtom &at0, MolAtom &at1, MolAtom &at2, const MolBondAngle *pBondAngle)
Constructor If pBondAngle!=0, the bond angle length restraint is respected.
Definition: Molecule.cpp:1583
A quaternion class, used to represent the orientation of the molecule.
Definition: Molecule.h:448
const MolAtom * mpAtom0
The atom which is an asymmetric center.
Definition: Molecule.h:1293
Bond between two atoms, also a restraint on the associated bond length.
Definition: Molecule.h:152
REAL mLLK
Stored log(likelihood)
Definition: Molecule.h:230
virtual ostream & POVRayDescription(ostream &os, const CrystalPOVRayOptions &options) const
Definition: Molecule.cpp:3189
ScatteringComponentList mScattCompList
The list of scattering components.
Definition: Molecule.h:1123
MDAtomGroup()
Default constructor.
Definition: Molecule.cpp:1851
void Print(ostream &os, bool full=true) const
Print one-line list of atoms moved.
Definition: Molecule.cpp:1869
std::list< StretchMode * > mvpStretchModeNotFree
Groups of StretchMode breaking restraints (beyond the one they are associated to) ...
Definition: Molecule.h:1331
virtual void BeginOptimization(const bool allowApproximations=false, const bool enableRestraints=false)
This should be called by any optimization class at the begining of an optimization.
Definition: Molecule.cpp:2385
void RotateAtomGroup(const MolAtom &at1, const MolAtom &at2, const set< MolAtom * > &atoms, const REAL angle, const bool keepCenter=true)
Rotate a group of atoms around an axis defined by two atoms.
Definition: Molecule.cpp:4397
MolDihedralAngle(MolAtom &atom1, MolAtom &atom2, MolAtom &atom3, MolAtom &atom4, const REAL angle, const REAL sigma, const REAL delta, Molecule &parent)
Constructor.
Definition: Molecule.cpp:930
list< MolRing > mvRing
The list of rings.
Definition: Molecule.h:1156
Structure holding 3 coordinates, or deriviatives with respect to each of these coordinates.
Definition: Molecule.h:43
map< MolAtom *, std::vector< MolBond * > > mvAtomBond
List of Bonds for each atom.
Definition: Molecule.h:1146
XYZ mDerivAtom1
Derivatives of the bond length with respect to the coordinates of the atoms.
Definition: Molecule.h:235
Atoms moved when rotated around a bond at0-at1-at2-at3.
Definition: Molecule.h:626
set< MolAtom * > mvRotatedAtomList
The set of atoms that are to be rotated.
Definition: Molecule.h:1245
MolAtom * mpAtom2
The second atom.
Definition: Molecule.h:644
list< StretchModeTwist > mvStretchModeTwist
List of StretchModeTwist.
Definition: Molecule.h:1326
void AddDihedralAngle(MolAtom &atom1, MolAtom &atom2, MolAtom &atom3, MolAtom &atom4, const REAL angle, const REAL sigma, const REAL delta, const bool updateDisplay=true)
Add a dihedral angle restraint.
Definition: Molecule.cpp:4022
Rigid groups of atoms inside a molecule.
Definition: Molecule.h:500
virtual int GetNbComponent() const
Number of components in the scatterer (eg number of point scatterers)
Definition: Molecule.cpp:3173
RefinableObjClock & GetBondListClock()
get the clock associated to the list of bonds
Definition: Molecule.cpp:4580
void AddAtom(const REAL x, const REAL y, const REAL z, const ScatteringPower *pPow, const string &name, const bool updateDisplay=true)
Add an atom.
Definition: Molecule.cpp:3786
std::vector< MolZAtom > mAsZMatrix
The Molecule, as a lightweight ZMatrix, for export purposes.
Definition: Molecule.h:1356
void CalcGradient(std::map< MolAtom *, XYZ > &m) const
Calc log(likelihood) gradient - versus all atomic coordinates.
Definition: Molecule.cpp:1213
list< StretchModeTorsion > mvStretchModeTorsion
List of StretchModeBondLength.
Definition: Molecule.h:1324
REAL mQ0
The components of the quaternion z=(q0,v) with v=(q1,q2,q3)
Definition: Molecule.h:486
list< RotorGroup > mvRotorGroupTorsion
List of RotorGroups corresponding to free torsion bonds.
Definition: Molecule.h:1261
CrystVector_REAL mLSQCalc
Current LSQ Calc - one value for each restraint (bond distance, angle or dihedral angle) ...
Definition: Molecule.h:1368
MolBond(MolAtom &atom1, MolAtom &atom2, const REAL length, const REAL sigma, const REAL delta, Molecule &parent, const REAL bondOrder=1.)
Constructor.
Definition: Molecule.cpp:347
~Molecule()
Destructor.
Definition: Molecule.cpp:2075
void BuildStretchModeTwist()
Build the groups of atoms used to twist internally the Molecule, e.g.
Definition: Molecule.cpp:6595
virtual void Print(ostream &os, bool full=true) const
Print one-line list of atoms moved.
Definition: Molecule.cpp:1548
void MolecularDynamicsEvolve(std::map< MolAtom *, XYZ > &v0, const unsigned nbStep, const REAL dt, const std::vector< MolBond * > &vb, const std::vector< MolBondAngle * > &va, const std::vector< MolDihedralAngle * > &vd, std::map< RigidGroup *, std::pair< XYZ, XYZ > > &vr, REAL nrj0=0)
Change the conformation of the molecule using molecular dynamics principles.
Definition: Molecule.cpp:4278
std::map< const MolDihedralAngle *, REAL > mvpBrokenDihedralAngle
List of dihedral angle restraints modified by this mode The key is the restraint, the value is the de...
Definition: Molecule.h:546
void BuildStretchModeBondAngle()
Build the groups of atoms moved when changing a bond angle, while respecting the Molecule restraints...
Definition: Molecule.cpp:5844
const MolAtom * GetCenterAtom() const
Get the atom defining the origin of the Molecule Equal to 0 if no atom as been set.
Definition: Molecule.cpp:5029
Abstract base class for all objects in wxCryst.
Definition: wxCryst.h:127
virtual const CrystVector_REAL & GetLSQWeight(const unsigned int) const
Get the weight values for the LSQ function.
Definition: Molecule.cpp:3103
Quaternion operator*(const Quaternion &q) const
Quaternion multiplication.
Definition: Molecule.cpp:1349
const ScatteringPower * mpScattPow
ScatteringPower.
Definition: Molecule.h:127
virtual void RandomStretch(const REAL amplitude, const bool keepCenter=true)
Move the atoms according to this mode, randomly.
Definition: Molecule.cpp:1835
void BuildStretchModeGroups()
Separate StretchMode that break more than their assigned restraint from others.
Definition: Molecule.cpp:7213
const std::vector< MolZAtom > & AsZMatrix(const bool keeporder) const
Molecule as Z-matrix.
Definition: Molecule.cpp:5116
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: Molecule.cpp:3398
Abstract base Stretch Mode for Molecule objects.
Definition: Molecule.h:520
void BuildMDAtomGroups()
Find groups of atoms that cannot be moved relatively to each other using the free or non-free stretch...
Definition: Molecule.cpp:7368
virtual Molecule * CreateCopy() const
Definition: Molecule.cpp:2100
static Quaternion RotationQuaternion(const REAL ang, const REAL v1, const REAL v2, const REAL v3)
Create a rotation quaternion around a given vector for a given angle.
Definition: Molecule.cpp:1334
Quaternion GetConjugate() const
Get the conjugate of this quaternion (== the inverse if unit quaternion)
Definition: Molecule.cpp:1345
void SetIsInRing(const bool r) const
Flag this atom as being in a ring (or not).
Definition: Molecule.cpp:327
virtual REAL GetLogLikelihood() const
Get -ln(likelihood) for this restraint.
Definition: Molecule.cpp:745
Base class for options.
Definition: RefinableObj.h:550
virtual void RandomStretch(const REAL amplitude, const bool keepCenter=true)
Move the atoms according to this mode, randomly.
Definition: Molecule.cpp:1677
virtual ~MolBondAngle()
Destructor.
Definition: Molecule.cpp:639
REAL mX
Cartesian oordinates in the Molecule reference frame.
Definition: Molecule.h:123
REAL mDerivLLKCoeff
The factor used to change the derivative of the length/angle, to the derivative of the log(likelihood...
Definition: Molecule.h:417
REAL mLogLikelihood
The current log(likelihood)
Definition: Molecule.h:1359
REAL GetBondAngle(const MolAtom &at1, const MolAtom &at2, const MolAtom &at3)
Get The Bond Angle of 3 atoms.
Definition: Molecule.cpp:95
virtual void Stretch(const REAL change, const bool keepCenter=true)
Move the atoms according to this mode.
Definition: Molecule.cpp:1749
Defines a group of atoms which can be rotated around an axis defined by two other atoms...
Definition: Molecule.h:1234
Molecule : class for complex scatterer descriptions using cartesian coordinates with bond length/angl...
Definition: Molecule.h:731
vector< MolAtom * >::reverse_iterator FindAtom(const string &name)
Search a MolAtom from its name.
Definition: Molecule.cpp:7630
Class to store POV-Ray output options.
Definition: General.h:175
Molecule(Crystal &cryst, const string &name="")
Constructor.
Definition: Molecule.cpp:1894
Molecule * mpMol
Parent Molecule.
Definition: Molecule.h:129
const MolDihedralAngle * mpDihedralAngle
The (optional) bond angle restraint which this stretch mode should respect.
Definition: Molecule.h:647
void BuildStretchModeBondLength()
Build the groups of atoms moved when stretching a bond length, while respecting the Molecule restrain...
Definition: Molecule.cpp:5572
vector< MolBondAngle * >::iterator RemoveBondAngle(const MolBondAngle &, const bool del=true)
Remove a BondAngle.
Definition: Molecule.cpp:3988
set< MolAtom * > mvTranslatedAtomList
The set of atoms that are to be translated, including at1.
Definition: Molecule.h:588
const MolAtom * mpAtom1
The first atom defining the rotation axis.
Definition: Molecule.h:1241
void FlipAtomGroup(const FlipGroup &, const bool keepCenter=true)
Flip a group of atom. See Molecule::FlipGroup.
Definition: Molecule.cpp:7722
Group of concurrent StretchModes (affecting common restraints) A given stretch mode can only belong t...
Definition: Molecule.h:1334
virtual string GetComponentName(const int i) const
Name for the i-th component of this scatterer.
Definition: Molecule.cpp:3183
const MolAtom * mpAtom2
The second atom defining the rotation axis.
Definition: Molecule.h:1243
void UpdateScattCompList() const
Update the Molecule::mScattCompList from the cartesian coordinates of all atoms, and the orientation ...
Definition: Molecule.cpp:7527
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
Definition: Molecule.cpp:2267
virtual unsigned int GetNbLSQFunction() const
Number of LSQ functions.
Definition: Molecule.cpp:3072
REAL mDerivLLKCoeff
The factor used to change the derivative of the length/angle, to the derivative of the log(likelihood...
Definition: Molecule.h:329
Molecule * mpMol
Parent Molecule.
Definition: Molecule.h:406
MolAtom * mpAtom2
The second atom.
Definition: Molecule.h:675
void Normalize() const
Re-normalize the quaternion to unity.
Definition: Molecule.cpp:1472
XYZ mDerivAtom1
Partial derivatives of the angle with respect to the coordinates of the atoms.
Definition: Molecule.h:413
void CalcGradient(std::map< MolAtom *, XYZ > &m) const
Calc log(likelihood) gradient - versus all atomic coordinates.
Definition: Molecule.cpp:545
void RotateVector(REAL &v1, REAL &v2, REAL &v3) const
Rotate vector v=(v1,v2,v3). The rotated components are directly written.
Definition: Molecule.cpp:1449
MolAtom : atom inside a Molecule.
Definition: Molecule.h:58
void SetCenterAtom(const MolAtom &at)
Get the atom defining the origin of the Molecule Equal to 0 if no atom as been set.
Definition: Molecule.cpp:5034
REAL mLLKDeriv
Derivative of the Molecule's Log(likelihood) versus a change of the bond length.
Definition: Molecule.h:548
REAL GetDihedralAngle(const MolAtom &at1, const MolAtom &at2, const MolAtom &at3, const MolAtom &at4)
Get The dihedral angle defined by 4 atoms.
Definition: Molecule.cpp:111
REAL GetDeriv(const std::map< const MolAtom *, XYZ > &m, const bool llk=false) const
Get the derivative of the bond length, given the derivatives of the atom positions This requires that...
Definition: Molecule.cpp:526
REAL mBaseAmplitude
The recommended change amplitude, for a base global optimization displacement, to obtain an average 0...
Definition: Molecule.h:560
const map< MolAtom *, set< MolAtom * > > & GetConnectivityTable()
Get the connectivity table.
Definition: Molecule.cpp:4574
RefObjOpt mFlexModel
OPtion for the different types of flexibility possible for this molecule: rigid body, free atoms + restraints, torsion angles...
Definition: Molecule.h:1201
void InitOptions()
Build options for this object.
Definition: Molecule.cpp:7651
vector< MolAtom * >::iterator RemoveAtom(MolAtom &, const bool del=true)
Remove an atom.
Definition: Molecule.cpp:3842
virtual ~MolDihedralAngle()
Destructor.
Definition: Molecule.cpp:951
REAL mLogLikelihoodScale
Scale (multiplier) for the log(likelihood)
Definition: Molecule.h:1366
virtual void InitRefParList()
Definition: Molecule.cpp:5208
Quaternion mQuat
The unit quaternion defining the orientation.
Definition: Molecule.h:1160
void AddRigidGroup(const RigidGroup &, const bool updateDisplay=true)
Add a rigid group of atoms.
Definition: Molecule.cpp:4073
MolAtom * mpAtom0
The first atom.
Definition: Molecule.h:611
const MolBond * mpBond
The (optional) bond length which this stretch mode should respect.
Definition: Molecule.h:586
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
Definition: Molecule.cpp:2167
REAL GetDeriv(const std::map< const MolAtom *, XYZ > &m, const bool llk=false) const
Get the derivative of the angle, given the derivatives of the atom positions This requires that GetLo...
Definition: Molecule.cpp:839
RefinableObjClock & GetRigidGroupClock()
Get the clock associated to the list of rigid groups (clicked also whenever a rigid group is modified...
Definition: Molecule.cpp:4586
list< RotorGroup > mvRotorGroupInternal
List of RotorGroups for internal rotations.
Definition: Molecule.h:1276
const MolBondAngle * mpBondAngle
The (optional) bond angle restraint which this stretch mode should respect.
Definition: Molecule.h:617
Restraint: generic class for a restraint of a given model.
Definition: RefinableObj.h:199
std::set< unsigned int > mvIdx
Temporary list of the atoms indices in the molecule, used during optimization This is created in Mole...
Definition: Molecule.h:514
Molecule * mpMol
Parent Molecule.
Definition: Molecule.h:228
string mName
Name for this atom.
Definition: Molecule.h:114
void SetDeleteSubObjInDestructor(const bool b)
Set whether to delete the MolAtoms, MolBonds, MolBondAngles and MolDihedralAngles in the destructor...
Definition: Molecule.cpp:7802
void CalcGradient(std::map< MolAtom *, XYZ > &m) const
Calc log(likelihood) gradient - versus all atomic coordinates.
Definition: Molecule.cpp:863
std::map< const MolBond *, REAL > mvpBrokenBond
List of bond restraints affected by this mode The key is the restraint, the value is the derivative o...
Definition: Molecule.h:540
list< RotorGroup > mvRotorGroupTorsionSingleChain
List of RotorGroups corresponding to free torsion bonds, but with only one chain of atoms listed...
Definition: Molecule.h:1270
Dihedral angle restraint between 4 atoms.
Definition: Molecule.h:346
virtual void RandomizeConfiguration()
Randomize Configuration (before a global optimization).
Definition: Molecule.cpp:2539
vector< MolBondAngle * > mvpBondAngle
The list of bond angles.
Definition: Molecule.h:1137
virtual void SetName(const string &name)
Name of the object.
Definition: Molecule.cpp:2112
std::list< StretchMode * > mvpStretchModeFree
Groups of StretchMode not breaking any restraint (unless the one they are associated to) ...
Definition: Molecule.h:1329
virtual void CalcDeriv(const bool derivllk=true) const =0
Calculate the derivative of the Molecule's Log(likelihood) and atomic positions versus a change of th...
list< FlipGroup > mvFlipGroup
The list of FlipGroups.
Definition: Molecule.h:1316
virtual void CalcDeriv(const bool derivllk=true) const
Calculate the derivative of the Molecule's Log(likelihood) and atomic positions versus a change of th...
Definition: Molecule.cpp:1775
virtual REAL GetLogLikelihood() const
Get -log(likelihood) of the current configuration for the object.
Definition: Molecule.cpp:3058
virtual void RandomStretch(const REAL amplitude, const bool keepCenter=true)
Move the atoms according to this mode, randomly.
Definition: Molecule.cpp:1754
vector< MolBondAngle * >::const_iterator FindBondAngle(const MolAtom &at1, const MolAtom &at0, const MolAtom &at2) const
Searches whether a bond between three atoms already exists, searching for either (at1,at2,at3) and (at3,at2,at1), as these are equivalent.
Definition: Molecule.cpp:4007
virtual const CrystVector_REAL & GetLSQCalc(const unsigned int) const
Get the current calculated value for the LSQ function.
Definition: Molecule.cpp:3077
RefObjOpt mAutoOptimizeConformation
Option to automatically optimize the starting conformation, if the total restraint cost is too high...
Definition: Molecule.h:1211
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
Definition: Atom.cpp:47
REAL mMDMoveFreq
Frequency of using molecular dynamics move during GlobalOptRandomMove()
Definition: Molecule.h:1350
Light-weight representation of an atom in the molecule, as a part of a Z-matrix.
Definition: Molecule.h:710
virtual void EndOptimization()
This should be called by any optimization class at the end of an optimization.
Definition: Molecule.cpp:2512
StretchModeTorsion(MolAtom &at1, MolAtom &at2, const MolDihedralAngle *pDihedralAngle)
Constructor If pDihedralAngle!=0, the dihedral angle length restraint is respected.
Definition: Molecule.cpp:1683
std::map< const MolBondAngle *, REAL > mvpBrokenBondAngle
List of bond angle restraints modified by this mode The key is the restraint, the value is the deriva...
Definition: Molecule.h:543
void BuildConnectivityTable() const
Build the Connectivity table.
Definition: Molecule.cpp:5299
std::string GetFormula() const
Formula with atoms in alphabetic order.
Definition: Molecule.cpp:2134
REAL mBaseRotationAmplitude
The recommended rotation amplitude, for a base global optimization displacement, to obtain an average...
Definition: Molecule.h:1253
Generic class for parameters of refinable objects.
Definition: RefinableObj.h:223
bool mIsFlexible
When using the user-chosen flexibility model, this allows some flexibility for this bond angle...
Definition: Molecule.h:318
virtual const ScatteringComponentList & GetScatteringComponentList() const
Get the list of all scattering components for this scatterer.
Definition: Molecule.cpp:3175
virtual void Stretch(const REAL change, const bool keepCenter=true)=0
Move the atoms according to this mode.
REAL BondLengthRandomChange(const StretchModeBondLength &mode, const REAL amplitude, const bool respectRestraint=true)
Stretch a bond, while respecting the Restraint (if any).
Definition: Molecule.cpp:4887
virtual void Stretch(const REAL change, const bool keepCenter=true)
Move the atoms according to this mode.
Definition: Molecule.cpp:1661
const std::vector< RigidGroup * > & GetRigidGroupList() const
List of rigid group of atoms.
Definition: Molecule.cpp:4394
virtual void RandomStretch(const REAL amplitude, const bool keepCenter=true)
Move the atoms according to this mode, randomly.
Definition: Molecule.cpp:1577
set< MolAtom * > mvRotatedAtomList
The set of atoms that are to be rotated around at1-at2.
Definition: Molecule.h:649
void ExpandAtomGroupRecursive(MolAtom *atom, const map< MolAtom *, set< MolAtom * > > &connect, set< MolAtom * > &atomlist, const MolAtom *finalAtom)
Build recursively a list of atoms, starting from a one atom, and given a connectivity table...
Definition: Molecule.cpp:151
void BuildRingList()
Build the list of rings in the molecule.
Definition: Molecule.cpp:5259
virtual void Print(ostream &os, bool full=true) const
Print one-line list of atoms moved.
Definition: Molecule.cpp:1816
void RestraintStatus(ostream &os) const
Print the status of all restraints (bond length, angles...)
Definition: Molecule.cpp:4551
set< MolAtom * > mvRotatedAtomList
The set of atoms that are to be rotated around at1-at2.
Definition: Molecule.h:677
virtual ~MolBond()
Destructor.
Definition: Molecule.cpp:358
MolAtom * mpAtom1
The second atom.
Definition: Molecule.h:613
void SetX(const REAL) const
Set the X,Y,Z coordinate - this is const because sometimes their coordinate must be changed even thou...
Definition: Molecule.cpp:244
virtual void UpdateDisplay() const
If there is an interface, this should be automatically be called each time there is a 'new...
Definition: Molecule.cpp:2379
RefinableObjClock & GetAtomPositionClock()
Get the clock associated to the atomic positions.
Definition: Molecule.cpp:4583
Groups of atoms that can be moved using molecular dynamics principles, taking a list of restraints as...
Definition: Molecule.h:685
RefObjOpt mMoleculeCenter
Option to choose the center of rotation of the Molecule for the global orientation either as the geom...
Definition: Molecule.h:1221
Crystal class: Unit cell, spacegroup, scatterers.
Definition: Crystal.h:97
vector< MolBond * >::iterator RemoveBond(const MolBond &, const bool del=true)
Remove a bond.
Definition: Molecule.cpp:3936
vector< MolDihedralAngle * > mvpDihedralAngle
The list of dihedral angles.
Definition: Molecule.h:1141
const MolAtom * mpAtom2
The second atom defining the rotation axis.
Definition: Molecule.h:1297
virtual void CalcDeriv(const bool derivllk=true) const
Calculate the derivative of the Molecule's Log(likelihood) and atomic positions versus a change of th...
Definition: Molecule.cpp:1593
class to input or output a well-formatted xml beginning or ending tag.
Group of atoms for random moves changing a bond length.
Definition: Molecule.h:567
CrystVector_REAL mLSQWeight
Current LSQ Calc - one value for each restraint(bond distance, angle or dihedral angle sigmas) ...
Definition: Molecule.h:1372
virtual void Print(ostream &os, bool full=true) const =0
Print one-line list of atoms moved.
MolAtom * mpAtom1
The first atom.
Definition: Molecule.h:642
list< pair< const MolAtom *, set< MolAtom * > > > mvRotatedChainList
The set of atoms that are to be rotated during the flip.
Definition: Molecule.h:1304
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 GetDeriv(const std::map< const MolAtom *, XYZ > &m, const bool llk=false) const
Get the derivative of the Angle, given the derivatives of the atom positions This requires that GetLo...
Definition: Molecule.cpp:1184
virtual void Print() const
Print some info about the scatterer (ideally this should be one line...).
Definition: Molecule.cpp:2161
REAL mMDMoveEnergy
Relative energy of molecule during molecular dynamics move Default: 40, 10 (slow conformation change)...
Definition: Molecule.h:1353
Generic type of scatterer: can be an atom, or a more complex assembly of atoms.
Definition: Scatterer.h:130
virtual void CalcDeriv(const bool derivllk=true) const
Calculate the derivative of the Molecule's Log(likelihood) and atomic positions versus a change of th...
Definition: Molecule.cpp:1514
MolAtom * mpAtom0
The first atom (fixed).
Definition: Molecule.h:582
std::set< MolAtom * > mvMDFullAtomGroup
Full list of atoms that can be moved using molecular dynamics This excludes any atom part of a rigid ...
Definition: Molecule.h:1347
void RigidifyWithDihedralAngles()
Add dihedral angles so as to rigidify the Molecule.
Definition: Molecule.cpp:4589
Quaternion()
Default constructor, yields q=(1,0,0,0)
Definition: Molecule.cpp:1312
REAL BondAngleRandomChange(const StretchModeBondAngle &mode, const REAL amplitude, const bool respectRestraint=true)
change a bond angle, while respecting the Restraint (if any).
Definition: Molecule.cpp:4931
list< StretchModeBondAngle > mvStretchModeBondAngle
List of StretchModeBondLength.
Definition: Molecule.h:1322
void TranslateAtomGroup(const set< MolAtom * > &atoms, const REAL dx, const REAL dy, const REAL dz, const bool keepCenter=true)
Translate a group of atoms in a given direction.
Definition: Molecule.cpp:4499
void AddBond(MolAtom &atom1, MolAtom &atom2, const REAL length, const REAL sigma, const REAL delta, const REAL bondOrder=1., const bool updateDisplay=true)
Add a bond.
Definition: Molecule.cpp:3923
bool IsDummy() const
Returns true if this is a dummy atom, i.e.
Definition: Molecule.cpp:249
Atoms moved between two other atoms, using a "twist" of their positions - only small twists of their ...
Definition: Molecule.h:658
virtual void RandomStretch(const REAL amplitude, const bool keepCenter=true)=0
Move the atoms according to this mode, randomly.
When 3(A1..1n) or more atoms are connected to a same atom A, it defines a 'flip' group, where it is possible to rotate bonds to their symmetric with respect to one plane defined by atoms Ai-A-Aj.
Definition: Molecule.h:1287
RefObjOpt mOptimizeOrientation
Option to optimize the Molecule's orientation.
Definition: Molecule.h:1216
vector< MolAtom * > mvpAtom
The vector of the 4 atoms involved in the bond angle.
Definition: Molecule.h:403
void OptimizeConformationSteepestDescent(const REAL maxStep=0.1, const unsigned nbStep=1)
Optimize the conformation from internal restraints (bond lengths, angles and dihedral angles)...
Definition: Molecule.cpp:4202
void OptimizeConformation(const long nbTrial=10000, const REAL stopCost=0.)
Minimize configuration from internal restraints (bond lengths, angles and dihedral angles)...
Definition: Molecule.cpp:4184
Abstract Base Class to describe the scattering power of any Scatterer component in a crystal...