FOX/ObjCryst++  2022
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;
117  void SetNonFlipAtom(const bool nonflip);
119  bool IsNonFlipAtom() const;
121  size_t int_ptr() const;
122  private:
124  string mName;
125  /* Get the atom at the other end of bond #i
126  MolAtom & GetBondedAtom(unsigned int i);
127  */
133  mutable REAL mX,mY,mZ;
141  mutable bool mIsInRing;
144  #ifdef __WX__CRYST__
145  public:
146  WXCrystObjBasic *mpWXCrystObj;
147  virtual WXCrystObjBasic* WXCreate(wxWindow*);
148  WXCrystObjBasic* WXGet();
149  void WXDelete();
150  void WXNotifyDelete();
151  #endif
152 };
153 
155 REAL GetBondLength(const MolAtom&,const MolAtom&);
157 REAL GetBondAngle(const MolAtom&,const MolAtom&,const MolAtom&);
159 REAL GetDihedralAngle(const MolAtom&,const MolAtom&,const MolAtom&,const MolAtom&);
160 
164 class MolBond:public Restraint
165 {
166  public:
185  MolBond(MolAtom &atom1, MolAtom &atom2,
186  const REAL length, const REAL sigma, const REAL delta,
187  Molecule &parent,const REAL bondOrder=1.);
192  virtual ~MolBond();
193  const Molecule& GetMolecule()const;
194  Molecule& GetMolecule();
196  string GetName()const;
197  virtual void XMLOutput(ostream &os,int indent=0)const;
198  virtual void XMLInput(istream &is,const XMLCrystTag &tag);
199  virtual REAL GetLogLikelihood()const;
200  REAL GetLogLikelihood(const bool calcDeriv, const bool recalc)const;
204  REAL GetDeriv(const std::map<const MolAtom*,XYZ> &m, const bool llk=false)const;
212  void CalcGradient(std::map<MolAtom*,XYZ> &m)const;
213  const MolAtom& GetAtom1()const;
214  const MolAtom& GetAtom2()const;
215  MolAtom& GetAtom1();
216  MolAtom& GetAtom2();
217  void SetAtom1(MolAtom &at1);
218  void SetAtom2(MolAtom &at2);
219  REAL GetLength()const;
220  REAL GetLength0()const;
221  REAL GetLengthDelta()const;
222  REAL GetLengthSigma()const;
223  REAL GetBondOrder()const;
224  REAL& Length0();
225  REAL& LengthDelta();
226  REAL& LengthSigma();
227  REAL& BondOrder();
228  void SetLength0(const REAL length);
229  void SetLengthDelta(const REAL length);
230  void SetLengthSigma(const REAL length);
231  void SetBondOrder(const REAL length);
232  bool IsFreeTorsion()const;
233  void SetFreeTorsion(const bool isInRing);
235  size_t int_ptr() const;
236  private:
237  pair<MolAtom*,MolAtom*> mAtomPair;
238  REAL mLength0,mDelta,mSigma;
239  REAL mBondOrder;
240  bool mIsFreeTorsion;
244  mutable REAL mLLK;
249  mutable XYZ mDerivAtom1,mDerivAtom2;
253  mutable REAL mDerivLLKCoeff;
254  #ifdef __WX__CRYST__
255  public:
256  WXCrystObjBasic *mpWXCrystObj;
257  virtual WXCrystObjBasic* WXCreate(wxWindow*);
258  WXCrystObjBasic* WXGet();
259  void WXDelete();
260  void WXNotifyDelete();
261  #endif
262 };
263 
271 {
272  public:
276  MolBondAngle(MolAtom &atom1,MolAtom &atom2,MolAtom &atom3,
277  const REAL angle, const REAL sigma, const REAL delta,
278  Molecule &parent);
282  virtual ~MolBondAngle();
283  const Molecule& GetMolecule()const;
284  Molecule& GetMolecule();
285  string GetName()const;
286  virtual void XMLOutput(ostream &os,int indent=0)const;
287  virtual void XMLInput(istream &is,const XMLCrystTag &tag);
288  virtual REAL GetLogLikelihood()const;
289  REAL GetLogLikelihood(const bool calcDeriv, const bool recalc)const;
293  REAL GetDeriv(const std::map<const MolAtom*,XYZ> &m, const bool llk=false)const;
301  void CalcGradient(std::map<MolAtom*,XYZ> &m)const;
302  REAL GetAngle()const;
303  REAL& Angle0();
304  REAL& AngleDelta();
305  REAL& AngleSigma();
306  REAL GetAngle0()const;
307  REAL GetAngleDelta()const;
308  REAL GetAngleSigma()const;
309  void SetAngle0(const REAL angle);
310  void SetAngleDelta(const REAL delta);
311  void SetAngleSigma(const REAL sigma);
312  const MolAtom& GetAtom1()const;
313  const MolAtom& GetAtom2()const;
314  const MolAtom& GetAtom3()const;
315  void SetAtom1(MolAtom &at);
316  void SetAtom2(MolAtom &at);
317  void SetAtom3(MolAtom &at);
318  MolAtom& GetAtom1();
319  MolAtom& GetAtom2();
320  MolAtom& GetAtom3();
321  bool IsFlexible()const;
322  void SetFlexible(const bool isInRing);
323  std::size_t size() const;
324  vector<MolAtom*>::const_iterator begin() const;
325  vector<MolAtom*>::const_iterator end() const;
327  size_t int_ptr() const;
328  private:
330  vector<MolAtom*> mvpAtom;
331  REAL mAngle0,mDelta,mSigma;
339  mutable REAL mLLK;
344  mutable XYZ mDerivAtom1,mDerivAtom2,mDerivAtom3;
348  mutable REAL mDerivLLKCoeff;
349  #ifdef __WX__CRYST__
350  public:
351  WXCrystObjBasic *mpWXCrystObj;
352  virtual WXCrystObjBasic* WXCreate(wxWindow*);
353  WXCrystObjBasic* WXGet();
354  void WXDelete();
355  void WXNotifyDelete();
356  #endif
357 };
358 
366 {
367  public:
371  MolDihedralAngle(MolAtom &atom1, MolAtom &atom2,
372  MolAtom &atom3, MolAtom &atom4,
373  const REAL angle, const REAL sigma, const REAL delta,
374  Molecule &parent);
378  virtual ~MolDihedralAngle();
379  const Molecule& GetMolecule()const;
380  Molecule& GetMolecule();
381  string GetName()const;
382  virtual void XMLOutput(ostream &os,int indent=0)const;
383  virtual void XMLInput(istream &is,const XMLCrystTag &tag);
384  virtual REAL GetLogLikelihood()const;
385  REAL GetLogLikelihood(const bool calcDeriv, const bool recalc)const;
389  REAL GetDeriv(const std::map<const MolAtom*,XYZ> &m, const bool llk=false)const;
397  void CalcGradient(std::map<MolAtom*,XYZ> &m)const;
398  REAL GetAngle()const;
399  REAL& Angle0();
400  REAL& AngleDelta();
401  REAL& AngleSigma();
402  REAL GetAngle0()const;
403  REAL GetAngleDelta()const;
404  REAL GetAngleSigma()const;
405  void SetAngle0(const REAL angle);
406  void SetAngleDelta(const REAL delta);
407  void SetAngleSigma(const REAL sigma);
408  const MolAtom& GetAtom1()const;
409  const MolAtom& GetAtom2()const;
410  const MolAtom& GetAtom3()const;
411  const MolAtom& GetAtom4()const;
412  void SetAtom1(MolAtom& at);
413  void SetAtom2(MolAtom& at);
414  void SetAtom3(MolAtom& at);
415  void SetAtom4(MolAtom& at);
416  MolAtom& GetAtom1();
417  MolAtom& GetAtom2();
418  MolAtom& GetAtom3();
419  MolAtom& GetAtom4();
420  std::size_t size() const;
421  vector<MolAtom*>::const_iterator begin() const;
422  vector<MolAtom*>::const_iterator end() const;
424  size_t int_ptr() const;
425  private:
427  vector<MolAtom*> mvpAtom;
428  REAL mAngle0, mDelta, mSigma;
432  mutable REAL mLLK;
437  mutable XYZ mDerivAtom1,mDerivAtom2,mDerivAtom3,mDerivAtom4;
441  mutable REAL mDerivLLKCoeff;
442  #ifdef __WX__CRYST__
443  public:
444  WXCrystObjBasic *mpWXCrystObj;
445  virtual WXCrystObjBasic* WXCreate(wxWindow*);
446  WXCrystObjBasic* WXGet();
447  void WXDelete();
448  void WXNotifyDelete();
449  #endif
450 };
451 
458 class MolRing
459 {
460  public:
461  MolRing();
462  const std::list<MolAtom*>& GetAtomList()const;
463  std::list<MolAtom*>& GetAtomList();
465  size_t int_ptr() const;
466  private:
467  std::list<MolAtom*> mvpAtom;
468 };
469 
475 {
476  public:
478  Quaternion();
480  Quaternion(const REAL q0,const REAL q1,const REAL q2,const REAL q3,bool unit=true);
481  ~Quaternion();
483  static Quaternion RotationQuaternion(const REAL ang,const REAL v1,const REAL v2,const REAL v3);
485  Quaternion GetConjugate()const;
487  Quaternion operator*(const Quaternion &q)const;
488  void operator*=(const Quaternion &q);
489  void XMLOutput(ostream &os,int indent=0)const;
490  void XMLInput(istream &is,const XMLCrystTag &tag);
492  void RotateVector(REAL &v1,REAL &v2, REAL &v3)const;
498  void Normalize()const ;
499  REAL GetNorm()const;
500  const REAL& Q0()const;
501  const REAL& Q1()const;
502  const REAL& Q2()const;
503  const REAL& Q3()const;
504  REAL& Q0();
505  REAL& Q1();
506  REAL& Q2();
507  REAL& Q3();
508  private:
512  mutable REAL mQ0,mQ1,mQ2,mQ3;
513  bool mIsUniQuaternion;
514 };
515 
526 class RigidGroup:public std::set<MolAtom *>
527 {
528  public:
529  std::string GetName()const;
534  mutable Quaternion mQuat;
537  mutable REAL mX,mY,mZ;
540  mutable std::set<unsigned int> mvIdx;
542  size_t int_ptr() const;
543 };
544 
549 {
550  virtual ~StretchMode();
559  virtual void CalcDeriv(const bool derivllk=true)const=0;
561  virtual void Print(ostream &os,bool full=true)const=0;
563  virtual void Stretch(const REAL change, const bool keepCenter=true)=0;
565  virtual void RandomStretch(const REAL amplitude, const bool keepCenter=true)=0;
568  std::map<const MolBond*,REAL> mvpBrokenBond;
571  std::map<const MolBondAngle*,REAL> mvpBrokenBondAngle;
574  std::map<const MolDihedralAngle*,REAL> mvpBrokenDihedralAngle;
576  mutable REAL mLLKDeriv;
578  mutable std::map<const MolAtom*,XYZ> mDerivXYZ;
589 };
590 
596 {
600  StretchModeBondLength(MolAtom &at0,MolAtom &at1,const MolBond *pBond);
601  virtual ~StretchModeBondLength();
602  virtual void CalcDeriv(const bool derivllk=true)const;
604  virtual void Print(ostream &os,bool full=true)const;
606  virtual void Stretch(const REAL change, const bool keepCenter=true);
608  virtual void RandomStretch(const REAL amplitude, const bool keepCenter=true);
614  const MolBond *mpBond;
616  set<MolAtom *> mvTranslatedAtomList;
617 };
618 
624 {
629  const MolBondAngle *pBondAngle);
630  virtual ~StretchModeBondAngle();
631  virtual void CalcDeriv(const bool derivllk=true)const;
633  virtual void Print(ostream &os,bool full=true)const;
635  virtual void Stretch(const REAL change, const bool keepCenter=true);
637  virtual void RandomStretch(const REAL amplitude, const bool keepCenter=true);
648  set<MolAtom *> mvRotatedAtomList;
649 };
655 {
660  const MolDihedralAngle *pDihedralAngle);
661  virtual ~StretchModeTorsion();
662  virtual void CalcDeriv(const bool derivllk=true)const;
664  virtual void Print(ostream &os,bool full=true)const;
666  virtual void Stretch(const REAL change, const bool keepCenter=true);
668  virtual void RandomStretch(const REAL amplitude, const bool keepCenter=true);
677  set<MolAtom *> mvRotatedAtomList;
678 };
679 
687 {
691  StretchModeTwist(MolAtom &at1,MolAtom &at2);
692  virtual ~StretchModeTwist();
693  virtual void CalcDeriv(const bool derivllk=true)const;
695  virtual void Print(ostream &os,bool full=true)const;
697  virtual void Stretch(const REAL change, const bool keepCenter=true);
699  virtual void RandomStretch(const REAL amplitude, const bool keepCenter=true);
705  set<MolAtom *> mvRotatedAtomList;
706 };
707 
714 {
716  MDAtomGroup();
721  MDAtomGroup(std::set<MolAtom*> &vat,
722  std::set<MolBond*> &vb,
723  std::set<MolBondAngle*> &va,
724  std::set<MolDihedralAngle*> &vd);
726  void Print(ostream &os,bool full=true)const;
727  std::set<MolAtom*> mvpAtom;
728  std::vector<MolBond*> mvpBond;
729  std::vector<MolBondAngle*> mvpBondAngle;
730  std::vector<MolDihedralAngle*> mvpDihedralAngle;
731 };
732 
738 struct MolZAtom
739 {
740  const ScatteringPower *mpPow;
741  unsigned long mBondAtom,mBondAngleAtom,mDihedralAtom;
742  REAL mBondLength,mBondAngle,mDihedralAngle;
743 };
744 
759 class Molecule: public Scatterer
760 {
761  public:
765  Molecule(Crystal &cryst, const string &name="");
769  Molecule(const Molecule &old);
773  ~Molecule();
774  virtual Molecule* CreateCopy() const;
775  virtual const string& GetClassName() const;
776  virtual void SetName(const string &name);
778  std::string GetFormula() const;
779  virtual void Print()const;
780  virtual void XMLOutput(ostream &os,int indent=0)const;
781  virtual void XMLInput(istream &is,const XMLCrystTag &tag);
782  virtual void UpdateDisplay()const;
783  virtual void BeginOptimization(const bool allowApproximations=false,const bool enableRestraints=false);
784  virtual void EndOptimization();
785  virtual void RandomizeConfiguration();
786  virtual void GlobalOptRandomMove(const REAL mutationAmplitude,
787  const RefParType *type);
788  virtual REAL GetLogLikelihood()const;
789 
790  virtual unsigned int GetNbLSQFunction()const;
791  virtual const CrystVector_REAL& GetLSQCalc(const unsigned int) const;
792  virtual const CrystVector_REAL& GetLSQObs(const unsigned int) const;
793  virtual const CrystVector_REAL& GetLSQWeight(const unsigned int) const;
794  virtual const CrystVector_REAL& GetLSQDeriv(const unsigned int n, RefinablePar&par);
795 
796  virtual void TagNewBestConfig()const;
797  virtual int GetNbComponent() const;
799  virtual string GetComponentName(const int i) const;
800  virtual ostream& POVRayDescription(ostream &os,
801  const CrystalPOVRayOptions &options)const;
802 
803 #ifdef OBJCRYST_GL
804  virtual void GLInitDisplayList(const bool onlyIndependentAtoms=false,
805  const REAL xMin=-.1,const REAL xMax=1.1,
806  const REAL yMin=-.1,const REAL yMax=1.1,
807  const REAL zMin=-.1,const REAL zMax=1.1,
808  const bool displayEnantiomer=false,
809  const bool displayNames=false,
810  const bool hideHydrogens=false,
811  const REAL fadeDistance=0,
812  const bool fullMoleculeInLimits=false)const;
813 #endif // OBJCRYST_GL
814 
819  void AddAtom(const REAL x, const REAL y, const REAL z,
820  const ScatteringPower *pPow,const string &name,
821  const bool updateDisplay=true);
829  vector<MolAtom*>::iterator RemoveAtom(MolAtom&, const bool del = true);
830 
835  void AddBond(MolAtom &atom1, MolAtom &atom2,
836  const REAL length, const REAL sigma, const REAL delta,
837  const REAL bondOrder=1.,
838  const bool updateDisplay=true);
844  vector<MolBond*>::iterator RemoveBond(const MolBond&, const bool del = true);
849  vector<MolBond*>::const_iterator FindBond(const MolAtom&,const MolAtom&)const;
854  vector<MolBond*>::iterator FindBond(const MolAtom&,const MolAtom&);
859  void AddBondAngle(MolAtom &atom1, MolAtom &atom2, MolAtom &atom3,
860  const REAL angle, const REAL sigma, const REAL delta,
861  const bool updateDisplay=true);
866  vector<MolBondAngle*>::iterator RemoveBondAngle(const MolBondAngle&, const bool del = true);
872  vector<MolBondAngle*>::const_iterator FindBondAngle(const MolAtom& at1,const MolAtom&at0,const MolAtom&at2)const;
877  void AddDihedralAngle(MolAtom &atom1, MolAtom &atom2,
878  MolAtom &atom3, MolAtom &atom4,
879  const REAL angle, const REAL sigma, const REAL delta,
880  const bool updateDisplay=true);
885  vector<MolDihedralAngle*>::iterator RemoveDihedralAngle(const MolDihedralAngle&, const bool del = true);
891  vector<MolDihedralAngle*>::const_iterator FindDihedralAngle(const MolAtom &at1,
892  const MolAtom &at2,
893  const MolAtom &at3,
894  const MolAtom &at4)const;
897  void AddRigidGroup(const RigidGroup&,const bool updateDisplay=true);
902  std::vector<RigidGroup*>::iterator RemoveRigidGroup(const RigidGroup &group,const bool updateDisplay=true, const bool del = true);
903 
904  MolAtom &GetAtom(unsigned int i);
905  const MolAtom &GetAtom(unsigned int i)const;
906  MolAtom &GetAtom(const string &name);
907  const MolAtom &GetAtom(const string &name)const;
908 
911  vector<MolAtom*>::reverse_iterator FindAtom(const string &name);
914  vector<MolAtom*>::const_reverse_iterator FindAtom(const string &name)const;
915 
920  void OptimizeConformation(const long nbTrial=10000,const REAL stopCost=0.);
927  void OptimizeConformationSteepestDescent(const REAL maxStep=0.1,const unsigned nbStep=1);
951  void MolecularDynamicsEvolve(std::map<MolAtom*,XYZ> &v0,const unsigned nbStep,const REAL dt,
952  const std::vector<MolBond*> &vb,const std::vector<MolBondAngle*> &va,
953  const std::vector<MolDihedralAngle*> &vd,
954  std::map<RigidGroup*,std::pair<XYZ,XYZ> > &vr, REAL nrj0=0);
955  const std::vector<MolAtom*>& GetAtomList()const;
956  const std::vector<MolBond*>& GetBondList()const;
957  const std::vector<MolBondAngle*>& GetBondAngleList()const;
958  const std::vector<MolDihedralAngle*>& GetDihedralAngleList()const;
959  std::vector<MolAtom*>& GetAtomList();
960  std::vector<MolBond*>& GetBondList();
961  std::vector<MolBondAngle*>& GetBondAngleList();
962  std::vector<MolDihedralAngle*>& GetDihedralAngleList();
963 
964  std::list<StretchModeBondLength>& GetStretchModeBondLengthList();
965  std::list<StretchModeBondAngle>& GetStretchModeBondAngleList();
966  std::list<StretchModeTorsion>& GetStretchModeTorsionList();
967 
968  const std::list<StretchModeBondLength>& GetStretchModeBondLengthList()const;
969  const std::list<StretchModeBondAngle>& GetStretchModeBondAngleList()const;
970  const std::list<StretchModeTorsion>& GetStretchModeTorsionList()const;
971 
974  const std::vector<RigidGroup *>& GetRigidGroupList()const;
977  std::vector<RigidGroup *>& GetRigidGroupList();
978 
984  void RotateAtomGroup(const MolAtom &at1,const MolAtom &at2,
985  const set<MolAtom *> &atoms, const REAL angle,
986  const bool keepCenter=true);
992  void RotateAtomGroup(const MolAtom &at,const REAL vx,const REAL vy,const REAL vz,
993  const set<MolAtom *> &atoms, const REAL angle,
994  const bool keepCenter=true);
1000  void TranslateAtomGroup(const set<MolAtom *> &atoms,
1001  const REAL dx,const REAL dy,const REAL dz,
1002  const bool keepCenter=true);
1004  void RestraintStatus(ostream &os)const;
1006  void RestraintExport(ostream &os)const;
1008  const map<MolAtom *,set<MolAtom *> > & GetConnectivityTable();
1012  const RefinableObjClock& GetBondListClock()const;
1026  const RefinableObjClock& GetRigidGroupClock()const;
1041  REAL BondLengthRandomChange(const StretchModeBondLength& mode, const REAL amplitude,
1042  const bool respectRestraint=true);
1049  REAL BondAngleRandomChange(const StretchModeBondAngle& mode, const REAL amplitude,
1050  const bool respectRestraint=true);
1057  REAL DihedralAngleRandomChange(const StretchModeTorsion& mode, const REAL amplitude,
1058  const bool respectRestraint=true);
1061  const MolAtom* GetCenterAtom()const;
1064  void SetCenterAtom(const MolAtom &at);
1070  const std::vector<MolZAtom>& AsZMatrix(const bool keeporder)const;
1075  void SetDeleteSubObjInDestructor(const bool b);
1076  public:
1077  virtual void InitRefParList();
1087  void BuildRingList();
1091  void BuildConnectivityTable()const;
1097  void BuildRotorGroup();
1109  void BuildFlipGroup();
1121  void BuildStretchModeTorsion();
1125  void BuildStretchModeTwist();
1129  void BuildStretchModeGroups();
1140  void BuildMDAtomGroups();
1144  void UpdateScattCompList()const;
1146  void InitOptions();
1152  void ResetRigidGroupsPar()const;
1161  vector<MolAtom*> mvpAtom;
1165  vector<MolBond*> mvpBond;
1169  vector<MolBondAngle*> mvpBondAngle;
1173  vector<MolDihedralAngle*> mvpDihedralAngle;
1178  map<MolAtom* , std::vector<MolBond*> > mvAtomBond;
1183  std::vector<RigidGroup*> mvRigidGroup;
1188  mutable list<MolRing> mvRing;
1198  // Flag indicating whether to destroy MolAtoms, MolBonds, MolBondAngles,
1199  // and MolDihedralAngles in the destructor (default true). Mofified by
1200  // SetDeleteSubObjInDestructor.
1202  REAL mBaseRotationAmplitude;
1203  // Clocks
1204  RefinableObjClock mClockAtomList;
1205  RefinableObjClock mClockBondList;
1206  RefinableObjClock mClockBondAngleList;
1207  RefinableObjClock mClockDihedralAngleList;
1208  RefinableObjClock mClockRigidGroup;
1213  RefinableObjClock mClockAtomPosition;
1214  RefinableObjClock mClockAtomScattPow;
1215  RefinableObjClock mClockOrientation;
1216  mutable RefinableObjClock mClockLogLikelihood;
1217  mutable RefinableObjClock mClockConnectivityTable;
1218  mutable RefinableObjClock mClockRingList;
1219  mutable RefinableObjClock mClockRotorGroup;
1220  mutable RefinableObjClock mClockFlipGroup;
1221  mutable RefinableObjClock mClockStretchModeBondLength;
1222  mutable RefinableObjClock mClockStretchModeBondAngle;
1223  mutable RefinableObjClock mClockStretchModeTorsion;
1224  mutable RefinableObjClock mClockStretchModeTwist;
1225  mutable RefinableObjClock mClockMDAtomGroup;
1226 
1227  // For local minimization (EXPERIMENTAL)
1228  unsigned long mLocalParamSet;
1229  mutable unsigned long mRandomConformChangeNbTest;
1230  mutable unsigned long mRandomConformChangeNbAccept;
1231  mutable REAL mRandomConformChangeTemp;
1232  REAL mLastLogLike;
1233  bool mIsSelfOptimizing;
1238 
1239  RefObjOpt mFlipModel;
1240 
1248 
1253 
1258 
1263 
1266  mutable map<MolAtom *,set<MolAtom *> > mConnectivityTable;
1270  struct RotorGroup
1271  {
1275  RotorGroup(const MolAtom &at1,const MolAtom &at2);
1277  const MolAtom * mpAtom1;
1279  const MolAtom * mpAtom2;
1281  set<MolAtom *> mvRotatedAtomList;
1290  };
1297  mutable list<RotorGroup> mvRotorGroupTorsion;
1306  mutable list<RotorGroup> mvRotorGroupTorsionSingleChain;
1312  mutable list<RotorGroup> mvRotorGroupInternal;
1323  struct FlipGroup
1324  {
1327  FlipGroup(const MolAtom &at0,const MolAtom &at1,const MolAtom &at2);
1329  const MolAtom * mpAtom0;
1331  const MolAtom * mpAtom1;
1333  const MolAtom * mpAtom2;
1340  list<pair<const MolAtom *,set<MolAtom *> > > mvRotatedChainList;
1345  mutable unsigned long mNbTest,mNbAccept;
1346  };
1348  void FlipAtomGroup(const FlipGroup&, const bool keepCenter=true);
1352  mutable list<FlipGroup> mvFlipGroup;
1353 
1354  // Group of atoms for random moves naturally respecting restraints
1356  mutable list<StretchModeBondLength> mvStretchModeBondLength;
1358  mutable list<StretchModeBondAngle> mvStretchModeBondAngle;
1360  mutable list<StretchModeTorsion> mvStretchModeTorsion;
1362  mutable list<StretchModeTwist> mvStretchModeTwist;
1363 
1365  mutable std::list<StretchMode*> mvpStretchModeFree;
1367  mutable std::list<StretchMode*> mvpStretchModeNotFree;
1371  {
1372  std::set<StretchMode*> mvpStretchMode;
1373  std::set<const MolBond*> mvpBrokenBond;
1374  std::set<const MolBondAngle*> mvpBrokenBondAngle;
1375  std::set<const MolDihedralAngle*> mvpBrokenDihedralAngle;
1376  };
1380  mutable list<MDAtomGroup> mvMDAtomGroup;
1383  mutable std::set<MolAtom*> mvMDFullAtomGroup;
1384 
1390 
1392  mutable std::vector<MolZAtom> mAsZMatrix;
1393 
1395  mutable REAL mLogLikelihood;
1404  mutable CrystVector_REAL mLSQCalc;
1406  mutable CrystVector_REAL mLSQObs;
1408  mutable CrystVector_REAL mLSQWeight;
1409 
1410  #ifdef __WX__CRYST__
1411  public:
1412  virtual WXCrystObjBasic* WXCreate(wxWindow*);
1413  #endif
1414 };
1415 
1428  const map<MolAtom*,set<MolAtom*> > &connect,
1429  set<MolAtom*> &atomlist,const MolAtom* finalAtom=0);
1430 
1443  const map<MolAtom*,set<MolAtom*> > &connect,
1444  map<MolAtom*,unsigned long> &atomlist,const unsigned long maxdepth, unsigned long depth=0);
1445 
1446 // Forward declaration
1447 class ZScatterer;
1448 
1451 
1452 }//namespace
1453 #endif
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
Definition: doc-main.h:25
REAL GetBondLength(const MolAtom &at1, const MolAtom &at2)
Get The Bond Length between two atoms.
Definition: Molecule.cpp:62
Molecule * ZScatterer2Molecule(ZScatterer *scatt)
Converter from ZScatterer to a Molecule object.
Definition: Molecule.cpp:7949
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:154
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:114
REAL GetBondAngle(const MolAtom &at1, const MolAtom &at2, const MolAtom &at3)
Get The Bond Angle of 3 atoms.
Definition: Molecule.cpp:98
Crystal class: Unit cell, spacegroup, scatterers.
Definition: Crystal.h:98
Class to store POV-Ray output options.
Definition: General.h:178
Structure holding 3 coordinates, or deriviatives with respect to each of these coordinates.
Definition: Molecule.h:44
MolAtom : atom inside a Molecule.
Definition: Molecule.h:59
virtual ~MolAtom()
Destructor.
Definition: Molecule.cpp:201
const ScatteringPower * mpScattPow
ScatteringPower.
Definition: Molecule.h:137
REAL mX
Cartesian oordinates in the Molecule reference frame.
Definition: Molecule.h:133
size_t int_ptr() const
Access to the integer address of this object, for unique identification from python.
Definition: Molecule.cpp:359
bool mIsInRing
Is the atom in a ring ?
Definition: Molecule.h:141
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:191
Molecule * mpMol
Parent Molecule.
Definition: Molecule.h:139
bool IsDummy() const
Returns true if this is a dummy atom, i.e.
Definition: Molecule.cpp:252
bool mIsNonFlipAtom
Can the atom be flipped (this is used for optically active atom which should keep their absolute conf...
Definition: Molecule.h:143
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:247
string mName
Name for this atom.
Definition: Molecule.h:124
bool IsNonFlipAtom() const
Can this atom be flipped (return=false) or should its absolute configuration be kept (return=true)
Definition: Molecule.cpp:354
REAL mOccupancy
Occupancy.
Definition: Molecule.h:135
void SetNonFlipAtom(const bool nonflip)
Set a flag to prevent the atom's absolute configuration to be changed.
Definition: Molecule.cpp:347
void SetIsInRing(const bool r) const
Flag this atom as being in a ring (or not).
Definition: Molecule.cpp:344
Bond between two atoms, also a restraint on the associated bond length.
Definition: Molecule.h:165
size_t int_ptr() const
Access to the integer address of this object, for unique identification from python.
Definition: Molecule.cpp:641
virtual ~MolBond()
Destructor.
Definition: Molecule.cpp:389
REAL mLLK
Stored log(likelihood)
Definition: Molecule.h:244
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:557
virtual REAL GetLogLikelihood() const
Get -ln(likelihood) for this restraint.
Definition: Molecule.cpp:485
string GetName() const
Name of the bond, e.g. "C3-O4".
Definition: Molecule.cpp:399
MolBond(MolAtom &atom1, MolAtom &atom2, const REAL length, const REAL sigma, const REAL delta, Molecule &parent, const REAL bondOrder=1.)
Constructor.
Definition: Molecule.cpp:378
void CalcGradient(std::map< MolAtom *, XYZ > &m) const
Calc log(likelihood) gradient - versus all atomic coordinates.
Definition: Molecule.cpp:576
Molecule * mpMol
Parent Molecule.
Definition: Molecule.h:242
REAL mDerivLLKCoeff
The factor used to change the derivative of the length/angle, to the derivative of the log(likelihood...
Definition: Molecule.h:253
XYZ mDerivAtom1
Derivatives of the bond length with respect to the coordinates of the atoms.
Definition: Molecule.h:249
Bond angle restraint between 3 atoms.
Definition: Molecule.h:271
virtual REAL GetLogLikelihood() const
Get -ln(likelihood) for this restraint.
Definition: Molecule.cpp:779
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:873
bool mIsFlexible
When using the user-chosen flexibility model, this allows some flexibility for this bond angle,...
Definition: Molecule.h:337
XYZ mDerivAtom1
Partial derivatives of the angle with respect to the coordinates of the atoms.
Definition: Molecule.h:344
void CalcGradient(std::map< MolAtom *, XYZ > &m) const
Calc log(likelihood) gradient - versus all atomic coordinates.
Definition: Molecule.cpp:897
MolBondAngle(MolAtom &atom1, MolAtom &atom2, MolAtom &atom3, const REAL angle, const REAL sigma, const REAL delta, Molecule &parent)
Constructor.
Definition: Molecule.cpp:660
size_t int_ptr() const
Access to the integer address of this object, for unique identification from python.
Definition: Molecule.cpp:951
REAL mLLK
Stored log(likelihood)
Definition: Molecule.h:339
Molecule * mpMol
Parent Molecule.
Definition: Molecule.h:333
vector< MolAtom * > mvpAtom
The vector of the 3 atoms involved in the bond angle.
Definition: Molecule.h:330
REAL mDerivLLKCoeff
The factor used to change the derivative of the length/angle, to the derivative of the log(likelihood...
Definition: Molecule.h:348
virtual ~MolBondAngle()
Destructor.
Definition: Molecule.cpp:673
Dihedral angle restraint between 4 atoms.
Definition: Molecule.h:366
XYZ mDerivAtom1
Partial derivatives of the angle with respect to the coordinates of the atoms.
Definition: Molecule.h:437
size_t int_ptr() const
Access to the integer address of this object, for unique identification from python.
Definition: Molecule.cpp:1314
vector< MolAtom * > mvpAtom
The vector of the 4 atoms involved in the bond angle.
Definition: Molecule.h:427
REAL mDerivLLKCoeff
The factor used to change the derivative of the length/angle, to the derivative of the log(likelihood...
Definition: Molecule.h:441
virtual ~MolDihedralAngle()
Destructor.
Definition: Molecule.cpp:991
void CalcGradient(std::map< MolAtom *, XYZ > &m) const
Calc log(likelihood) gradient - versus all atomic coordinates.
Definition: Molecule.cpp:1253
REAL mLLK
Stored log(likelihood)
Definition: Molecule.h:432
MolDihedralAngle(MolAtom &atom1, MolAtom &atom2, MolAtom &atom3, MolAtom &atom4, const REAL angle, const REAL sigma, const REAL delta, Molecule &parent)
Constructor.
Definition: Molecule.cpp:970
Molecule * mpMol
Parent Molecule.
Definition: Molecule.h:430
virtual REAL GetLogLikelihood() const
Get -ln(likelihood) for this restraint.
Definition: Molecule.cpp:1106
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:1224
Ring class.
Definition: Molecule.h:459
size_t int_ptr() const
Access to the integer address of this object, for unique identification from python.
Definition: Molecule.cpp:1357
A quaternion class, used to represent the orientation of the molecule.
Definition: Molecule.h:475
Quaternion GetConjugate() const
Get the conjugate of this quaternion (== the inverse if unit quaternion)
Definition: Molecule.cpp:1397
Quaternion operator*(const Quaternion &q) const
Quaternion multiplication.
Definition: Molecule.cpp:1401
REAL mQ0
The components of the quaternion z=(q0,v) with v=(q1,q2,q3)
Definition: Molecule.h:512
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:1386
void Normalize() const
Re-normalize the quaternion to unity.
Definition: Molecule.cpp:1524
Quaternion()
Default constructor, yields q=(1,0,0,0)
Definition: Molecule.cpp:1364
void RotateVector(REAL &v1, REAL &v2, REAL &v3) const
Rotate vector v=(v1,v2,v3). The rotated components are directly written.
Definition: Molecule.cpp:1501
Rigid groups of atoms inside a molecule.
Definition: Molecule.h:527
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:540
Quaternion mQuat
The unit quaternion defining the orientation - this is used during optimizations to rotate all atoms ...
Definition: Molecule.h:534
size_t int_ptr() const
Access to the integer address of this object, for unique identification from python.
Definition: Molecule.cpp:1341
REAL mX
The translation of all the atoms as a group The values will be resetted whenever entering or leaving ...
Definition: Molecule.h:537
Abstract base Stretch Mode for Molecule objects.
Definition: Molecule.h:549
virtual void RandomStretch(const REAL amplitude, const bool keepCenter=true)=0
Move the atoms according to this mode, randomly.
virtual void Stretch(const REAL change, const bool keepCenter=true)=0
Move the atoms according to this mode.
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:571
Molecule * mpMol
The Molecule corresponding to this stretch mode.
Definition: Molecule.h:580
std::map< const MolAtom *, XYZ > mDerivXYZ
Derivative of the atomic positions versus a change of the bond length.
Definition: Molecule.h:578
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...
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:568
virtual void Print(ostream &os, bool full=true) const =0
Print one-line list of atoms moved.
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:574
REAL mBaseAmplitude
The recommended change amplitude, for a base global optimization displacement, to obtain an average 0...
Definition: Molecule.h:588
REAL mLLKDeriv
Derivative of the Molecule's Log(likelihood) versus a change of the bond length.
Definition: Molecule.h:576
Group of atoms for random moves changing a bond length.
Definition: Molecule.h:596
virtual void RandomStretch(const REAL amplitude, const bool keepCenter=true)
Move the atoms according to this mode, randomly.
Definition: Molecule.cpp:1629
MolAtom * mpAtom0
The first atom (fixed).
Definition: Molecule.h:610
const MolBond * mpBond
The (optional) bond length which this stretch mode should respect.
Definition: Molecule.h:614
StretchModeBondLength(MolAtom &at0, MolAtom &at1, const MolBond *pBond)
Constructor If pBond!=0, the bond length restraint is respected.
Definition: Molecule.cpp:1556
virtual void Print(ostream &os, bool full=true) const
Print one-line list of atoms moved.
Definition: Molecule.cpp:1600
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:1566
set< MolAtom * > mvTranslatedAtomList
The set of atoms that are to be translated, including at1.
Definition: Molecule.h:616
MolAtom * mpAtom1
The second atom (first atom moved)
Definition: Molecule.h:612
virtual void Stretch(const REAL change, const bool keepCenter=true)
Move the atoms according to this mode.
Definition: Molecule.cpp:1614
Atoms moved when changing a bond angle.
Definition: Molecule.h:624
MolAtom * mpAtom2
The third atom.
Definition: Molecule.h:643
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:648
virtual void Print(ostream &os, bool full=true) const
Print one-line list of atoms moved.
Definition: Molecule.cpp:1699
virtual void RandomStretch(const REAL amplitude, const bool keepCenter=true)
Move the atoms according to this mode, randomly.
Definition: Molecule.cpp:1729
MolAtom * mpAtom0
The first atom.
Definition: Molecule.h:639
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:1645
virtual void Stretch(const REAL change, const bool keepCenter=true)
Move the atoms according to this mode.
Definition: Molecule.cpp:1713
StretchModeBondAngle(MolAtom &at0, MolAtom &at1, MolAtom &at2, const MolBondAngle *pBondAngle)
Constructor If pBondAngle!=0, the bond angle length restraint is respected.
Definition: Molecule.cpp:1635
MolAtom * mpAtom1
The second atom.
Definition: Molecule.h:641
const MolBondAngle * mpBondAngle
The (optional) bond angle restraint which this stretch mode should respect.
Definition: Molecule.h:645
Atoms moved when rotated around a bond at0-at1-at2-at3.
Definition: Molecule.h:655
MolAtom * mpAtom1
The first atom.
Definition: Molecule.h:670
MolAtom * mpAtom2
The second atom.
Definition: Molecule.h:672
StretchModeTorsion(MolAtom &at1, MolAtom &at2, const MolDihedralAngle *pDihedralAngle)
Constructor If pDihedralAngle!=0, the dihedral angle length restraint is respected.
Definition: Molecule.cpp:1735
virtual void Print(ostream &os, bool full=true) const
Print one-line list of atoms moved.
Definition: Molecule.cpp:1787
const MolDihedralAngle * mpDihedralAngle
The (optional) bond angle restraint which this stretch mode should respect.
Definition: Molecule.h:675
virtual void RandomStretch(const REAL amplitude, const bool keepCenter=true)
Move the atoms according to this mode, randomly.
Definition: Molecule.cpp:1806
set< MolAtom * > mvRotatedAtomList
The set of atoms that are to be rotated around at1-at2.
Definition: Molecule.h:677
virtual void Stretch(const REAL change, const bool keepCenter=true)
Move the atoms according to this mode.
Definition: Molecule.cpp:1801
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:1745
Atoms moved between two other atoms, using a "twist" of their positions - only small twists of their ...
Definition: Molecule.h:687
MolAtom * mpAtom2
The second atom.
Definition: Molecule.h:703
virtual void Print(ostream &os, bool full=true) const
Print one-line list of atoms moved.
Definition: Molecule.cpp:1868
set< MolAtom * > mvRotatedAtomList
The set of atoms that are to be rotated around at1-at2.
Definition: Molecule.h:705
StretchModeTwist(MolAtom &at1, MolAtom &at2)
Constructor If pDihedralAngle!=0, the dihedral angle length restraint is respected.
Definition: Molecule.cpp:1818
virtual void Stretch(const REAL change, const bool keepCenter=true)
Move the atoms according to this mode.
Definition: Molecule.cpp:1882
MolAtom * mpAtom1
The first atom.
Definition: Molecule.h:701
virtual void RandomStretch(const REAL amplitude, const bool keepCenter=true)
Move the atoms according to this mode, randomly.
Definition: Molecule.cpp:1887
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:1827
Groups of atoms that can be moved using molecular dynamics principles, taking a list of restraints as...
Definition: Molecule.h:714
MDAtomGroup()
Default constructor.
Definition: Molecule.cpp:1903
void Print(ostream &os, bool full=true) const
Print one-line list of atoms moved.
Definition: Molecule.cpp:1921
Light-weight representation of an atom in the molecule, as a part of a Z-matrix.
Definition: Molecule.h:739
Molecule : class for complex scatterer descriptions using cartesian coordinates with bond length/angl...
Definition: Molecule.h:760
virtual const ScatteringComponentList & GetScatteringComponentList() const
Get the list of all scattering components for this scatterer.
Definition: Molecule.cpp:3242
vector< MolBondAngle * >::iterator RemoveBondAngle(const MolBondAngle &, const bool del=true)
Remove a BondAngle.
Definition: Molecule.cpp:4053
void BuildMDAtomGroups()
Find groups of atoms that cannot be moved relatively to each other using the free or non-free stretch...
Definition: Molecule.cpp:7458
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:4564
map< MolAtom *, set< MolAtom * > > mConnectivityTable
Connectivity table: for each atom, keep the list of atoms bonded to it.
Definition: Molecule.h:1266
void InitOptions()
Build options for this object.
Definition: Molecule.cpp:7741
void BuildStretchModeTorsion()
Build the groups of atoms moved when changing a dihedral angle, while respecting the Molecule restrai...
Definition: Molecule.cpp:6265
void SetDeleteSubObjInDestructor(const bool b)
Set whether to delete the MolAtoms, MolBonds, MolBondAngles and MolDihedralAngles in the destructor.
Definition: Molecule.cpp:7892
vector< MolDihedralAngle * > mvpDihedralAngle
The list of dihedral angles.
Definition: Molecule.h:1173
std::list< StretchMode * > mvpStretchModeFree
Groups of StretchMode not breaking any restraint (unless the one they are associated to)
Definition: Molecule.h:1365
list< RotorGroup > mvRotorGroupTorsionSingleChain
List of RotorGroups corresponding to free torsion bonds, but with only one chain of atoms listed.
Definition: Molecule.h:1306
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:5101
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:4041
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:5096
virtual ostream & POVRayDescription(ostream &os, const CrystalPOVRayOptions &options) const
Definition: Molecule.cpp:3256
virtual void EndOptimization()
This should be called by any optimization class at the end of an optimization.
Definition: Molecule.cpp:2576
RefObjOpt mFlexModel
OPtion for the different types of flexibility possible for this molecule: rigid body,...
Definition: Molecule.h:1237
list< MolRing > mvRing
The list of rings.
Definition: Molecule.h:1188
virtual void SetName(const string &name)
Name of the object.
Definition: Molecule.cpp:2171
void BuildRotorGroup()
Build the groups of atoms that will be rotated during global optimization.
Definition: Molecule.cpp:5421
void BuildStretchModeBondAngle()
Build the groups of atoms moved when changing a bond angle, while respecting the Molecule restraints.
Definition: Molecule.cpp:5928
virtual unsigned int GetNbLSQFunction() const
Number of LSQ functions.
Definition: Molecule.cpp:3139
std::vector< RigidGroup * > mvRigidGroup
Rigid groups of atoms.
Definition: Molecule.h:1183
std::vector< MolZAtom > mAsZMatrix
The Molecule, as a lightweight ZMatrix, for export purposes.
Definition: Molecule.h:1392
void BuildConnectivityTable() const
Build the Connectivity table.
Definition: Molecule.cpp:5369
list< MDAtomGroup > mvMDAtomGroup
Groups of atoms that should be moved according to molecular dynamics principles.
Definition: Molecule.h:1380
RefObjOpt mMoleculeCenter
Option to choose the center of rotation of the Molecule for the global orientation either as the geom...
Definition: Molecule.h:1257
void FlipAtomGroup(const FlipGroup &, const bool keepCenter=true)
Flip a group of atom. See Molecule::FlipGroup.
Definition: Molecule.cpp:7812
list< StretchModeTwist > mvStretchModeTwist
List of StretchModeTwist.
Definition: Molecule.h:1362
void UpdateScattCompList() const
Update the Molecule::mScattCompList from the cartesian coordinates of all atoms, and the orientation ...
Definition: Molecule.cpp:7617
vector< MolDihedralAngle * >::iterator RemoveDihedralAngle(const MolDihedralAngle &, const bool del=true)
Remove a dihedral angle.
Definition: Molecule.cpp:4101
void RigidifyWithDihedralAngles()
Add dihedral angles so as to rigidify the Molecule.
Definition: Molecule.cpp:4657
list< StretchModeBondAngle > mvStretchModeBondAngle
List of StretchModeBondLength.
Definition: Molecule.h:1358
const std::vector< RigidGroup * > & GetRigidGroupList() const
List of rigid group of atoms.
Definition: Molecule.cpp:4459
virtual void InitRefParList()
Definition: Molecule.cpp:5275
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,...
Definition: Molecule.cpp:4072
bool mDeleteSubObjInDestructor
Base Rotation amplitude (in radians) for the Molecule, so that the average atomic displacement is equ...
Definition: Molecule.h:1201
REAL mMDMoveEnergy
Relative energy of molecule during molecular dynamics move Default: 40, 10 (slow conformation change)...
Definition: Molecule.h:1389
Quaternion mQuat
The unit quaternion defining the orientation.
Definition: Molecule.h:1192
CrystVector_REAL mLSQObs
Current LSQ Calc - one value for each restraint (bond distance, angle or dihedral angle ideal values)
Definition: Molecule.h:1406
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
Definition: Molecule.cpp:2331
vector< MolAtom * >::iterator RemoveAtom(MolAtom &, const bool del=true)
Remove an atom.
Definition: Molecule.cpp:3932
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:2449
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:4121
RefinableObjClock & GetRigidGroupClock()
Get the clock associated to the list of rigid groups (clicked also whenever a rigid group is modified...
Definition: Molecule.cpp:4654
virtual void TagNewBestConfig() const
During a global optimization, tells the object that the current config is the latest "best" config.
Definition: Molecule.cpp:3191
CrystVector_REAL mLSQWeight
Current LSQ Calc - one value for each restraint(bond distance, angle or dihedral angle sigmas)
Definition: Molecule.h:1408
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
Definition: Molecule.cpp:2227
vector< MolBond * >::const_iterator FindBond(const MolAtom &, const MolAtom &) const
Searches whether a bond between two atoms already exists.
Definition: Molecule.cpp:4020
list< FlipGroup > mvFlipGroup
The list of FlipGroups.
Definition: Molecule.h:1352
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:3876
virtual Molecule * CreateCopy() const
Definition: Molecule.cpp:2159
vector< MolAtom * >::reverse_iterator FindAtom(const string &name)
Search a MolAtom from its name.
Definition: Molecule.cpp:7720
REAL mLogLikelihoodScale
Scale (multiplier) for the log(likelihood)
Definition: Molecule.h:1402
void BuildStretchModeTwist()
Build the groups of atoms used to twist internally the Molecule, e.g.
Definition: Molecule.cpp:6679
virtual const CrystVector_REAL & GetLSQObs(const unsigned int) const
Get the observed values for the LSQ function.
Definition: Molecule.cpp:3157
virtual int GetNbComponent() const
Number of components in the scatterer (eg number of point scatterers)
Definition: Molecule.cpp:3240
void BuildStretchModeGroups()
Separate StretchMode that break more than their assigned restraint from others.
Definition: Molecule.cpp:7303
const RefinableObjClock & GetAtomScattPowClock() const
Get the clock associated to the scattering powers.
Definition: Molecule.cpp:4651
const std::vector< MolZAtom > & AsZMatrix(const bool keeporder) const
Molecule as Z-matrix.
Definition: Molecule.cpp:5183
list< StretchModeTorsion > mvStretchModeTorsion
List of StretchModeBondLength.
Definition: Molecule.h:1360
RefinableObjClock mClockRestraint
This clock is the parent of mClockAtomList, mClockBondList, mClockBondAngleList, mClockDihedralAngleL...
Definition: Molecule.h:1212
void AddRigidGroup(const RigidGroup &, const bool updateDisplay=true)
Add a rigid group of atoms.
Definition: Molecule.cpp:4138
RefObjOpt mOptimizeOrientation
Option to optimize the Molecule's orientation.
Definition: Molecule.h:1252
void OptimizeConformation(const long nbTrial=10000, const REAL stopCost=0.)
Minimize configuration from internal restraints (bond lengths, angles and dihedral angles).
Definition: Molecule.cpp:4249
const MolAtom * mpCenterAtom
Atom chosen as center of rotation, if mRotationCenter is set to use an atom rather than the geometric...
Definition: Molecule.h:1262
virtual void RandomizeConfiguration()
Randomize Configuration (before a global optimization).
Definition: Molecule.cpp:2603
void BuildRingList()
Build the list of rings in the molecule.
Definition: Molecule.cpp:5329
virtual REAL GetLogLikelihood() const
Get -log(likelihood) of the current configuration for the object.
Definition: Molecule.cpp:3125
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:4343
std::string GetFormula() const
Formula with atoms in alphabetic order.
Definition: Molecule.cpp:2193
void RestraintStatus(ostream &os) const
Print the status of all restraints (bond length, angles...)
Definition: Molecule.cpp:4616
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:4462
vector< MolBondAngle * > mvpBondAngle
The list of bond angles.
Definition: Molecule.h:1169
void RestraintExport(ostream &os) const
Print the restraints (bond length, angles...) as whole labels and number in column text format which ...
Definition: Molecule.cpp:4591
void TuneGlobalOptimRotationAmplitude()
Tune the rotation amplitude for free torsions and for the overall Molecule Rotation.
Definition: Molecule.cpp:6945
CrystVector_REAL mLSQCalc
Current LSQ Calc - one value for each restraint (bond distance, angle or dihedral angle)
Definition: Molecule.h:1404
vector< MolBond * >::iterator RemoveBond(const MolBond &, const bool del=true)
Remove a bond.
Definition: Molecule.cpp:4001
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:3988
list< StretchModeBondLength > mvStretchModeBondLength
List of StretchModeBondLength.
Definition: Molecule.h:1356
virtual string GetComponentName(const int i) const
Name for the i-th component of this scatterer.
Definition: Molecule.cpp:3250
virtual void UpdateDisplay() const
If there is an interface, this should be automatically be called each time there is a 'new,...
Definition: Molecule.cpp:2443
vector< MolBond * > mvpBond
The list of bonds.
Definition: Molecule.h:1165
void ResetRigidGroupsPar() const
Set the orientation & translation parameters of all rigid groups to 0, after correcting the atomic po...
Definition: Molecule.cpp:7896
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:4087
virtual void Print() const
Print some info about the scatterer (ideally this should be one line...).
Definition: Molecule.cpp:2221
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:4218
const map< MolAtom *, set< MolAtom * > > & GetConnectivityTable()
Get the connectivity table.
Definition: Molecule.cpp:4639
void BuildStretchModeBondLength()
Build the groups of atoms moved when stretching a bond length, while respecting the Molecule restrain...
Definition: Molecule.cpp:5656
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:4267
list< RotorGroup > mvRotorGroupInternal
List of RotorGroups for internal rotations.
Definition: Molecule.h:1312
void BuildFlipGroup()
Build the groups of atoms that can be flipped.
Definition: Molecule.cpp:7124
REAL mLogLikelihood
The current log(likelihood)
Definition: Molecule.h:1395
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:3185
Molecule(Crystal &cryst, const string &name="")
Constructor.
Definition: Molecule.cpp:1946
vector< MolAtom * > mvpAtom
The list of atoms.
Definition: Molecule.h:1161
map< MolAtom *, std::vector< MolBond * > > mvAtomBond
List of Bonds for each atom.
Definition: Molecule.h:1178
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:4998
REAL BondLengthRandomChange(const StretchModeBondLength &mode, const REAL amplitude, const bool respectRestraint=true)
Stretch a bond, while respecting the Restraint (if any).
Definition: Molecule.cpp:4954
RefinableObjClock & GetBondListClock()
get the clock associated to the list of bonds
Definition: Molecule.cpp:4645
virtual void GlobalOptRandomMove(const REAL mutationAmplitude, const RefParType *type)
Make a random move of the current configuration.
Definition: Molecule.cpp:2719
RefinableObjClock & GetAtomPositionClock()
Get the clock associated to the atomic positions.
Definition: Molecule.cpp:4648
~Molecule()
Destructor.
Definition: Molecule.cpp:2134
ScatteringComponentList mScattCompList
The list of scattering components.
Definition: Molecule.h:1157
RefObjOpt mAutoOptimizeConformation
Option to automatically optimize the starting conformation, if the total restraint cost is too high.
Definition: Molecule.h:1247
std::list< StretchMode * > mvpStretchModeNotFree
Groups of StretchMode breaking restraints (beyond the one they are associated to)
Definition: Molecule.h:1367
REAL mMDMoveFreq
Frequency of using molecular dynamics move during GlobalOptRandomMove()
Definition: Molecule.h:1386
virtual const CrystVector_REAL & GetLSQCalc(const unsigned int) const
Get the current calculated value for the LSQ function.
Definition: Molecule.cpp:3144
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:1383
virtual const CrystVector_REAL & GetLSQWeight(const unsigned int) const
Get the weight values for the LSQ function.
Definition: Molecule.cpp:3170
virtual const string & GetClassName() const
Name for this class ("RefinableObj", "Crystal",...).
Definition: Molecule.cpp:2165
list< RotorGroup > mvRotorGroupTorsion
List of RotorGroups corresponding to free torsion bonds.
Definition: Molecule.h:1297
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:5055
Defines a group of atoms which can be rotated around an axis defined by two other atoms.
Definition: Molecule.h:1271
RotorGroup(const MolAtom &at1, const MolAtom &at2)
Constructor, with the two atoms around which the rotation shall be made.
Definition: Molecule.cpp:5417
set< MolAtom * > mvRotatedAtomList
The set of atoms that are to be rotated.
Definition: Molecule.h:1281
const MolAtom * mpAtom1
The first atom defining the rotation axis.
Definition: Molecule.h:1277
REAL mBaseRotationAmplitude
The recommended rotation amplitude, for a base global optimization displacement, to obtain an average...
Definition: Molecule.h:1289
const MolAtom * mpAtom2
The second atom defining the rotation axis.
Definition: Molecule.h:1279
When 3(A1..1n) or more atoms are connected to a same atom A, it defines a 'flip' group,...
Definition: Molecule.h:1324
list< pair< const MolAtom *, set< MolAtom * > > > mvRotatedChainList
The set of atoms that are to be rotated during the flip.
Definition: Molecule.h:1340
const MolAtom * mpAtom2
The second atom defining the rotation axis.
Definition: Molecule.h:1333
const MolAtom * mpAtom0
The atom which is an asymmetric center.
Definition: Molecule.h:1329
FlipGroup(const MolAtom &at0, const MolAtom &at1, const MolAtom &at2)
Constructor, with the central atom.
Definition: Molecule.cpp:7807
unsigned long mNbTest
Number of times this flip has been tried, and the number of times it has been accepted.
Definition: Molecule.h:1345
const MolAtom * mpAtom1
The first atom defining the rotation axis.
Definition: Molecule.h:1331
Group of concurrent StretchModes (affecting common restraints) A given stretch mode can only belong t...
Definition: Molecule.h:1371
Generic type of scatterer: can be an atom, or a more complex assembly of atoms.
Definition: Scatterer.h:131
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 ...
ZScatterer: the basic type of complex scatterers, where atom positions are defined using a standard "...
Definition: ZScatterer.h:191
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
Restraint: generic class for a restraint of a given model.
Definition: RefinableObj.h:201
Generic class for parameters of refinable objects.
Definition: RefinableObj.h:225
Base class for options.
Definition: RefinableObj.h:552
Abstract base class for all objects in wxCryst.
Definition: wxCryst.h:128