22 #ifndef _OBJCRYST_MOLECULE_H_
23 #define _OBJCRYST_MOLECULE_H_
31 #include "ObjCryst/ObjCryst/General.h"
32 #include "ObjCryst/ObjCryst/ScatteringPower.h"
33 #include "ObjCryst/ObjCryst/Scatterer.h"
45 XYZ(REAL x=0,REAL y=0,REAL z=0);
64 MolAtom(
const REAL x,
const REAL y,
const REAL z,
72 void SetName(
const string &name);
73 const string& GetName()
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);
105 virtual void XMLOutput(ostream &os,
int indent=0)
const;
106 virtual void XMLInput(istream &is,
const XMLCrystTag &tag);
111 bool IsInRing()
const;
123 mutable REAL
mX,mY,mZ;
138 void WXNotifyDelete();
174 const REAL length,
const REAL sigma,
const REAL delta,
175 Molecule &parent,
const REAL bondOrder=1.);
185 virtual void XMLOutput(ostream &os,
int indent=0)
const;
186 virtual void XMLInput(istream &is,
const XMLCrystTag &tag);
192 REAL
GetDeriv(
const std::map<const MolAtom*,XYZ> &m,
const bool llk=
false)
const;
201 const MolAtom& GetAtom1()
const;
202 const MolAtom& GetAtom2()
const;
207 REAL GetLength()
const;
208 REAL GetLength0()
const;
209 REAL GetLengthDelta()
const;
210 REAL GetLengthSigma()
const;
211 REAL GetBondOrder()
const;
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);
223 pair<MolAtom*,MolAtom*> mAtomPair;
224 REAL mLength0,mDelta,mSigma;
246 void WXNotifyDelete();
263 const REAL angle,
const REAL sigma,
const REAL delta,
271 string GetName()
const;
272 virtual void XMLOutput(ostream &os,
int indent=0)
const;
273 virtual void XMLInput(istream &is,
const XMLCrystTag &tag);
279 REAL
GetDeriv(
const std::map<const MolAtom*,XYZ> &m,
const bool llk=
false)
const;
288 REAL GetAngle()
const;
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;
307 bool IsFlexible()
const;
308 void SetFlexible(
const bool isInRing);
312 REAL mAngle0,mDelta,mSigma;
336 void WXNotifyDelete();
354 const REAL angle,
const REAL sigma,
const REAL delta,
362 string GetName()
const;
363 virtual void XMLOutput(ostream &os,
int indent=0)
const;
364 virtual void XMLInput(istream &is,
const XMLCrystTag &tag);
370 REAL
GetDeriv(
const std::map<const MolAtom*,XYZ> &m,
const bool llk=
false)
const;
379 REAL GetAngle()
const;
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;
404 REAL mAngle0, mDelta, mSigma;
424 void WXNotifyDelete();
438 const std::list<MolAtom*>& GetAtomList()
const;
439 std::list<MolAtom*>& GetAtomList();
441 std::list<MolAtom*> mvpAtom;
454 Quaternion(
const REAL q0,
const REAL q1,
const REAL q2,
const REAL q3,
bool unit=
true);
463 void XMLOutput(ostream &os,
int indent=0)
const;
474 const REAL& Q0()
const;
475 const REAL& Q1()
const;
476 const REAL& Q2()
const;
477 const REAL& Q3()
const;
486 mutable REAL
mQ0,mQ1,mQ2,mQ3;
487 bool mIsUniQuaternion;
503 std::string GetName()
const;
511 mutable REAL
mX,mY,mZ;
514 mutable std::set<unsigned int>
mvIdx;
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;
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);
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);
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);
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);
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;
713 unsigned long mBondAtom,mBondAngleAtom,mDihedralAtom;
714 REAL mBondLength,mBondAngle,mDihedralAngle;
748 virtual void SetName(
const string &name);
751 virtual void Print()
const;
752 virtual void XMLOutput(ostream &os,
int indent=0)
const;
755 virtual void BeginOptimization(
const bool allowApproximations=
false,
const bool enableRestraints=
false);
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;
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,
787 const bool updateDisplay=
true);
797 void AddNonFlipAtom(
MolAtom &atom);
798 void removeNonFlipAtom(
MolAtom &atom);
799 vector<MolAtom*> getNonFlipAtomList();
806 const REAL length,
const REAL sigma,
const REAL delta,
807 const REAL bondOrder=1.,
808 const bool updateDisplay=
true);
830 const REAL angle,
const REAL sigma,
const REAL delta,
831 const bool updateDisplay=
true);
849 const REAL angle,
const REAL sigma,
const REAL delta,
850 const bool updateDisplay=
true);
872 std::vector<RigidGroup*>::iterator
RemoveRigidGroup(
const RigidGroup &group,
const bool updateDisplay=
true,
const bool del =
true);
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;
881 vector<MolAtom*>::reverse_iterator
FindAtom(
const string &name);
884 vector<MolAtom*>::const_reverse_iterator
FindAtom(
const string &name)
const;
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();
934 std::list<StretchModeBondLength>& GetStretchModeBondLengthList();
935 std::list<StretchModeBondAngle>& GetStretchModeBondAngleList();
936 std::list<StretchModeTorsion>& GetStretchModeTorsionList();
938 const std::list<StretchModeBondLength>& GetStretchModeBondLengthList()
const;
939 const std::list<StretchModeBondAngle>& GetStretchModeBondAngleList()
const;
940 const std::list<StretchModeTorsion>& GetStretchModeTorsionList()
const;
955 const set<MolAtom *> &atoms,
const REAL angle,
956 const bool keepCenter=
true);
963 const set<MolAtom *> &atoms,
const REAL angle,
964 const bool keepCenter=
true);
971 const REAL dx,
const REAL dy,
const REAL dz,
972 const bool keepCenter=
true);
1008 const bool respectRestraint=
true);
1016 const bool respectRestraint=
true);
1024 const bool respectRestraint=
true);
1036 const std::vector<MolZAtom>&
AsZMatrix(
const bool keeporder)
const;
1125 vector<MolAtom*> mvNonFlipAtom;
1170 REAL mBaseRotationAmplitude;
1192 unsigned long mLocalParamSet;
1193 mutable unsigned long mRandomConformChangeNbTest;
1194 mutable unsigned long mRandomConformChangeNbAccept;
1195 mutable REAL mRandomConformChangeTemp;
1197 bool mIsSelfOptimizing;
1336 std::set<StretchMode*> mvpStretchMode;
1337 std::set<const MolBond*> mvpBrokenBond;
1338 std::set<const MolBondAngle*> mvpBrokenBondAngle;
1339 std::set<const MolDihedralAngle*> mvpBrokenDihedralAngle;
1374 #ifdef __WX__CRYST__
1392 const map<
MolAtom*,set<MolAtom*> > &connect,
1393 set<MolAtom*> &atomlist,
const MolAtom* finalAtom=0);
1407 const map<
MolAtom*,set<MolAtom*> > &connect,
1408 map<MolAtom*,unsigned long> &atomlist,
const unsigned long maxdepth,
unsigned long depth=0);
MolAtom(const REAL x, const REAL y, const REAL z, const ScatteringPower *pPow, const string &name, Molecule &parent)
Constructor for a MolAtom.
RotorGroup(const MolAtom &at1, const MolAtom &at2)
Constructor, with the two atoms around which the rotation shall be made.
list< MDAtomGroup > mvMDAtomGroup
Groups of atoms that should be moved according to molecular dynamics principles.
REAL mOccupancy
Occupancy.
void RestraintExport(ostream &os) const
Print the restraints (bond length, angles...) as whole labels and number in column text format which ...
map< MolAtom *, set< MolAtom * > > mConnectivityTable
Connectivity table: for each atom, keep the list of atoms bonded to it.
MolAtom * mpAtom1
The second atom (first atom moved)
StretchModeTwist(MolAtom &at1, MolAtom &at2)
Constructor If pDihedralAngle!=0, the dihedral angle length restraint is respected.
XYZ mDerivAtom1
Partial derivatives of the angle with respect to the coordinates of the atoms.
vector< MolDihedralAngle * >::iterator RemoveDihedralAngle(const MolDihedralAngle &, const bool del=true)
Remove a dihedral angle.
vector< MolBond * > mvpBond
The list of bonds.
void BuildRotorGroup()
Build the groups of atoms that will be rotated during global optimization.
REAL mLLK
Stored log(likelihood)
REAL mX
The translation of all the atoms as a group The values will be resetted whenever entering or leaving ...
Bond angle restraint between 3 atoms.
unsigned long mNbTest
Number of times this flip has been tried, and the number of times it has been accepted.
void TuneGlobalOptimRotationAmplitude()
Tune the rotation amplitude for free torsions and for the overall Molecule Rotation.
virtual void Print(ostream &os, bool full=true) const
Print one-line list of atoms moved.
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...
Molecule * mpMol
Parent Molecule.
virtual void Stretch(const REAL change, const bool keepCenter=true)
Move the atoms according to this mode.
virtual REAL GetLogLikelihood() const
Get -ln(likelihood) for this restraint.
bool mIsInRing
Is the atom in a ring ?
Atoms moved when changing a bond angle.
REAL GetBondLength(const MolAtom &at1, const MolAtom &at2)
Get The Bond Length between two atoms.
MolBondAngle(MolAtom &atom1, MolAtom &atom2, MolAtom &atom3, const REAL angle, const REAL sigma, const REAL delta, Molecule &parent)
Constructor.
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...
virtual const string & GetClassName() const
Name for this class ("RefinableObj", "Crystal",...).
set< MolAtom * > mvRotatedAtomList
The set of atoms that are to be rotated around the direction going through at1 and perpendicular to t...
We need to record exactly when refinable objects have been modified for the last time (to avoid re-co...
std::map< const MolAtom *, XYZ > mDerivXYZ
Derivative of the atomic positions versus a change of the bond length.
virtual ~MolAtom()
Destructor.
void BuildFlipGroup()
Build the groups of atoms that can be flipped.
string GetName() const
Name of the bond, e.g. "C3-O4".
vector< MolBond * >::const_iterator FindBond(const MolAtom &, const MolAtom &) const
Searches whether a bond between two atoms already exists.
CrystVector_REAL mLSQObs
Current LSQ Calc - one value for each restraint (bond distance, angle or dihedral angle ideal values)...
MolAtom * mpAtom2
The third atom.
std::vector< RigidGroup * >::iterator RemoveRigidGroup(const RigidGroup &group, const bool updateDisplay=true, const bool del=true)
Remove a rigid group of atoms.
REAL mLLK
Stored log(likelihood)
virtual void Stretch(const REAL change, const bool keepCenter=true)
Move the atoms according to this mode.
void BuildStretchModeTorsion()
Build the groups of atoms moved when changing a dihedral angle, while respecting the Molecule restrai...
REAL mDerivLLKCoeff
The factor used to change the derivative of the length/angle, to the derivative of the log(likelihood...
const MolAtom * mpCenterAtom
Atom chosen as center of rotation, if mRotationCenter is set to use an atom rather than the geometric...
StretchModeBondLength(MolAtom &at0, MolAtom &at1, const MolBond *pBond)
Constructor If pBond!=0, the bond length restraint is respected.
list< StretchModeBondLength > mvStretchModeBondLength
List of StretchModeBondLength.
virtual void GlobalOptRandomMove(const REAL mutationAmplitude, const RefParType *type)
Make a random move of the current configuration.
vector< MolAtom * > mvpAtom
The vector of the 3 atoms involved in the bond angle.
Molecule * mpMol
The Molecule corresponding to this stretch mode.
virtual void TagNewBestConfig() const
During a global optimization, tells the object that the current config is the latest "best" config...
MolAtom * mpAtom1
The first atom.
const MolAtom * mpAtom1
The first atom defining the rotation axis.
virtual void Print(ostream &os, bool full=true) const
Print one-line list of atoms moved.
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.
virtual REAL GetLogLikelihood() const
Get -ln(likelihood) for this restraint.
FlipGroup(const MolAtom &at0, const MolAtom &at1, const MolAtom &at2)
Constructor, with the central atom.
bool mDeleteSubObjInDestructor
Base Rotation amplitude (in radians) for the Molecule, so that the average atomic displacement is equ...
virtual const CrystVector_REAL & GetLSQDeriv(const unsigned int n, RefinablePar &par)
Get the first derivative values for the LSQ function, for a given parameter.
Quaternion mQuat
The unit quaternion defining the orientation - this is used during optimizations to rotate all atoms ...
void ResetRigidGroupsPar() const
Set the orientation & translation parameters of all rigid groups to 0, after correcting the atomic po...
virtual const CrystVector_REAL & GetLSQObs(const unsigned int) const
Get the observed values for the LSQ function.
REAL DihedralAngleRandomChange(const StretchModeTorsion &mode, const REAL amplitude, const bool respectRestraint=true)
Change a dihedral angle, while respecting the Restraint (if any).
vector< MolAtom * > mvpAtom
The list of atoms.
std::vector< RigidGroup * > mvRigidGroup
Rigid groups of atoms.
StretchModeBondAngle(MolAtom &at0, MolAtom &at1, MolAtom &at2, const MolBondAngle *pBondAngle)
Constructor If pBondAngle!=0, the bond angle length restraint is respected.
A quaternion class, used to represent the orientation of the molecule.
const MolAtom * mpAtom0
The atom which is an asymmetric center.
Bond between two atoms, also a restraint on the associated bond length.
REAL mLLK
Stored log(likelihood)
virtual ostream & POVRayDescription(ostream &os, const CrystalPOVRayOptions &options) const
ScatteringComponentList mScattCompList
The list of scattering components.
MDAtomGroup()
Default constructor.
void Print(ostream &os, bool full=true) const
Print one-line list of atoms moved.
std::list< StretchMode * > mvpStretchModeNotFree
Groups of StretchMode breaking restraints (beyond the one they are associated to) ...
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.
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.
MolDihedralAngle(MolAtom &atom1, MolAtom &atom2, MolAtom &atom3, MolAtom &atom4, const REAL angle, const REAL sigma, const REAL delta, Molecule &parent)
Constructor.
list< MolRing > mvRing
The list of rings.
Structure holding 3 coordinates, or deriviatives with respect to each of these coordinates.
map< MolAtom *, std::vector< MolBond * > > mvAtomBond
List of Bonds for each atom.
XYZ mDerivAtom1
Derivatives of the bond length with respect to the coordinates of the atoms.
Atoms moved when rotated around a bond at0-at1-at2-at3.
set< MolAtom * > mvRotatedAtomList
The set of atoms that are to be rotated.
MolAtom * mpAtom2
The second atom.
list< StretchModeTwist > mvStretchModeTwist
List of StretchModeTwist.
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.
Rigid groups of atoms inside a molecule.
virtual int GetNbComponent() const
Number of components in the scatterer (eg number of point scatterers)
RefinableObjClock & GetBondListClock()
get the clock associated to the list of bonds
void AddAtom(const REAL x, const REAL y, const REAL z, const ScatteringPower *pPow, const string &name, const bool updateDisplay=true)
Add an atom.
std::vector< MolZAtom > mAsZMatrix
The Molecule, as a lightweight ZMatrix, for export purposes.
void CalcGradient(std::map< MolAtom *, XYZ > &m) const
Calc log(likelihood) gradient - versus all atomic coordinates.
list< StretchModeTorsion > mvStretchModeTorsion
List of StretchModeBondLength.
REAL mQ0
The components of the quaternion z=(q0,v) with v=(q1,q2,q3)
list< RotorGroup > mvRotorGroupTorsion
List of RotorGroups corresponding to free torsion bonds.
CrystVector_REAL mLSQCalc
Current LSQ Calc - one value for each restraint (bond distance, angle or dihedral angle) ...
MolBond(MolAtom &atom1, MolAtom &atom2, const REAL length, const REAL sigma, const REAL delta, Molecule &parent, const REAL bondOrder=1.)
Constructor.
void BuildStretchModeTwist()
Build the groups of atoms used to twist internally the Molecule, e.g.
virtual void Print(ostream &os, bool full=true) const
Print one-line list of atoms moved.
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.
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...
void BuildStretchModeBondAngle()
Build the groups of atoms moved when changing a bond angle, while respecting the Molecule restraints...
const MolAtom * GetCenterAtom() const
Get the atom defining the origin of the Molecule Equal to 0 if no atom as been set.
Abstract base class for all objects in wxCryst.
virtual const CrystVector_REAL & GetLSQWeight(const unsigned int) const
Get the weight values for the LSQ function.
Quaternion operator*(const Quaternion &q) const
Quaternion multiplication.
const ScatteringPower * mpScattPow
ScatteringPower.
virtual void RandomStretch(const REAL amplitude, const bool keepCenter=true)
Move the atoms according to this mode, randomly.
void BuildStretchModeGroups()
Separate StretchMode that break more than their assigned restraint from others.
const std::vector< MolZAtom > & AsZMatrix(const bool keeporder) const
Molecule as Z-matrix.
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
Abstract base Stretch Mode for Molecule objects.
void BuildMDAtomGroups()
Find groups of atoms that cannot be moved relatively to each other using the free or non-free stretch...
virtual Molecule * CreateCopy() const
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.
Quaternion GetConjugate() const
Get the conjugate of this quaternion (== the inverse if unit quaternion)
void SetIsInRing(const bool r) const
Flag this atom as being in a ring (or not).
virtual REAL GetLogLikelihood() const
Get -ln(likelihood) for this restraint.
virtual void RandomStretch(const REAL amplitude, const bool keepCenter=true)
Move the atoms according to this mode, randomly.
virtual ~MolBondAngle()
Destructor.
REAL mX
Cartesian oordinates in the Molecule reference frame.
REAL mDerivLLKCoeff
The factor used to change the derivative of the length/angle, to the derivative of the log(likelihood...
REAL mLogLikelihood
The current log(likelihood)
REAL GetBondAngle(const MolAtom &at1, const MolAtom &at2, const MolAtom &at3)
Get The Bond Angle of 3 atoms.
virtual void Stretch(const REAL change, const bool keepCenter=true)
Move the atoms according to this mode.
Defines a group of atoms which can be rotated around an axis defined by two other atoms...
Molecule : class for complex scatterer descriptions using cartesian coordinates with bond length/angl...
vector< MolAtom * >::reverse_iterator FindAtom(const string &name)
Search a MolAtom from its name.
Class to store POV-Ray output options.
Molecule(Crystal &cryst, const string &name="")
Constructor.
Molecule * mpMol
Parent Molecule.
const MolDihedralAngle * mpDihedralAngle
The (optional) bond angle restraint which this stretch mode should respect.
void BuildStretchModeBondLength()
Build the groups of atoms moved when stretching a bond length, while respecting the Molecule restrain...
vector< MolBondAngle * >::iterator RemoveBondAngle(const MolBondAngle &, const bool del=true)
Remove a BondAngle.
set< MolAtom * > mvTranslatedAtomList
The set of atoms that are to be translated, including at1.
const MolAtom * mpAtom1
The first atom defining the rotation axis.
void FlipAtomGroup(const FlipGroup &, const bool keepCenter=true)
Flip a group of atom. See Molecule::FlipGroup.
Group of concurrent StretchModes (affecting common restraints) A given stretch mode can only belong t...
virtual string GetComponentName(const int i) const
Name for the i-th component of this scatterer.
const MolAtom * mpAtom2
The second atom defining the rotation axis.
void UpdateScattCompList() const
Update the Molecule::mScattCompList from the cartesian coordinates of all atoms, and the orientation ...
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
virtual unsigned int GetNbLSQFunction() const
Number of LSQ functions.
REAL mDerivLLKCoeff
The factor used to change the derivative of the length/angle, to the derivative of the log(likelihood...
Molecule * mpMol
Parent Molecule.
MolAtom * mpAtom2
The second atom.
void Normalize() const
Re-normalize the quaternion to unity.
XYZ mDerivAtom1
Partial derivatives of the angle with respect to the coordinates of the atoms.
void CalcGradient(std::map< MolAtom *, XYZ > &m) const
Calc log(likelihood) gradient - versus all atomic coordinates.
void RotateVector(REAL &v1, REAL &v2, REAL &v3) const
Rotate vector v=(v1,v2,v3). The rotated components are directly written.
MolAtom : atom inside a Molecule.
void SetCenterAtom(const MolAtom &at)
Get the atom defining the origin of the Molecule Equal to 0 if no atom as been set.
REAL mLLKDeriv
Derivative of the Molecule's Log(likelihood) versus a change of the bond length.
REAL GetDihedralAngle(const MolAtom &at1, const MolAtom &at2, const MolAtom &at3, const MolAtom &at4)
Get The dihedral angle defined by 4 atoms.
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...
REAL mBaseAmplitude
The recommended change amplitude, for a base global optimization displacement, to obtain an average 0...
const map< MolAtom *, set< MolAtom * > > & GetConnectivityTable()
Get the connectivity table.
RefObjOpt mFlexModel
OPtion for the different types of flexibility possible for this molecule: rigid body, free atoms + restraints, torsion angles...
void InitOptions()
Build options for this object.
vector< MolAtom * >::iterator RemoveAtom(MolAtom &, const bool del=true)
Remove an atom.
virtual ~MolDihedralAngle()
Destructor.
REAL mLogLikelihoodScale
Scale (multiplier) for the log(likelihood)
virtual void InitRefParList()
Quaternion mQuat
The unit quaternion defining the orientation.
void AddRigidGroup(const RigidGroup &, const bool updateDisplay=true)
Add a rigid group of atoms.
MolAtom * mpAtom0
The first atom.
const MolBond * mpBond
The (optional) bond length which this stretch mode should respect.
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
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...
RefinableObjClock & GetRigidGroupClock()
Get the clock associated to the list of rigid groups (clicked also whenever a rigid group is modified...
list< RotorGroup > mvRotorGroupInternal
List of RotorGroups for internal rotations.
const MolBondAngle * mpBondAngle
The (optional) bond angle restraint which this stretch mode should respect.
Restraint: generic class for a restraint of a given model.
std::set< unsigned int > mvIdx
Temporary list of the atoms indices in the molecule, used during optimization This is created in Mole...
Molecule * mpMol
Parent Molecule.
string mName
Name for this atom.
void SetDeleteSubObjInDestructor(const bool b)
Set whether to delete the MolAtoms, MolBonds, MolBondAngles and MolDihedralAngles in the destructor...
void CalcGradient(std::map< MolAtom *, XYZ > &m) const
Calc log(likelihood) gradient - versus all atomic coordinates.
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...
list< RotorGroup > mvRotorGroupTorsionSingleChain
List of RotorGroups corresponding to free torsion bonds, but with only one chain of atoms listed...
Dihedral angle restraint between 4 atoms.
virtual void RandomizeConfiguration()
Randomize Configuration (before a global optimization).
vector< MolBondAngle * > mvpBondAngle
The list of bond angles.
virtual void SetName(const string &name)
Name of the object.
std::list< StretchMode * > mvpStretchModeFree
Groups of StretchMode not breaking any restraint (unless the one they are associated to) ...
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.
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...
virtual REAL GetLogLikelihood() const
Get -log(likelihood) of the current configuration for the object.
virtual void RandomStretch(const REAL amplitude, const bool keepCenter=true)
Move the atoms according to this mode, randomly.
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.
virtual const CrystVector_REAL & GetLSQCalc(const unsigned int) const
Get the current calculated value for the LSQ function.
RefObjOpt mAutoOptimizeConformation
Option to automatically optimize the starting conformation, if the total restraint cost is too high...
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
REAL mMDMoveFreq
Frequency of using molecular dynamics move during GlobalOptRandomMove()
Light-weight representation of an atom in the molecule, as a part of a Z-matrix.
virtual void EndOptimization()
This should be called by any optimization class at the end of an optimization.
StretchModeTorsion(MolAtom &at1, MolAtom &at2, const MolDihedralAngle *pDihedralAngle)
Constructor If pDihedralAngle!=0, the dihedral angle length restraint is respected.
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...
void BuildConnectivityTable() const
Build the Connectivity table.
std::string GetFormula() const
Formula with atoms in alphabetic order.
REAL mBaseRotationAmplitude
The recommended rotation amplitude, for a base global optimization displacement, to obtain an average...
Generic class for parameters of refinable objects.
bool mIsFlexible
When using the user-chosen flexibility model, this allows some flexibility for this bond angle...
virtual const ScatteringComponentList & GetScatteringComponentList() const
Get the list of all scattering components for this scatterer.
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).
virtual void Stretch(const REAL change, const bool keepCenter=true)
Move the atoms according to this mode.
const std::vector< RigidGroup * > & GetRigidGroupList() const
List of rigid group of atoms.
virtual void RandomStretch(const REAL amplitude, const bool keepCenter=true)
Move the atoms according to this mode, randomly.
set< MolAtom * > mvRotatedAtomList
The set of atoms that are to be rotated around at1-at2.
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...
void BuildRingList()
Build the list of rings in the molecule.
virtual void Print(ostream &os, bool full=true) const
Print one-line list of atoms moved.
void RestraintStatus(ostream &os) const
Print the status of all restraints (bond length, angles...)
set< MolAtom * > mvRotatedAtomList
The set of atoms that are to be rotated around at1-at2.
virtual ~MolBond()
Destructor.
MolAtom * mpAtom1
The second atom.
void SetX(const REAL) const
Set the X,Y,Z coordinate - this is const because sometimes their coordinate must be changed even thou...
virtual void UpdateDisplay() const
If there is an interface, this should be automatically be called each time there is a 'new...
RefinableObjClock & GetAtomPositionClock()
Get the clock associated to the atomic positions.
Groups of atoms that can be moved using molecular dynamics principles, taking a list of restraints as...
RefObjOpt mMoleculeCenter
Option to choose the center of rotation of the Molecule for the global orientation either as the geom...
Crystal class: Unit cell, spacegroup, scatterers.
vector< MolBond * >::iterator RemoveBond(const MolBond &, const bool del=true)
Remove a bond.
vector< MolDihedralAngle * > mvpDihedralAngle
The list of dihedral angles.
const MolAtom * mpAtom2
The second atom defining the rotation axis.
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...
class to input or output a well-formatted xml beginning or ending tag.
Group of atoms for random moves changing a bond length.
CrystVector_REAL mLSQWeight
Current LSQ Calc - one value for each restraint(bond distance, angle or dihedral angle sigmas) ...
virtual void Print(ostream &os, bool full=true) const =0
Print one-line list of atoms moved.
MolAtom * mpAtom1
The first atom.
list< pair< const MolAtom *, set< MolAtom * > > > mvRotatedChainList
The set of atoms that are to be rotated during the flip.
class of refinable parameter types.
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...
virtual void Print() const
Print some info about the scatterer (ideally this should be one line...).
REAL mMDMoveEnergy
Relative energy of molecule during molecular dynamics move Default: 40, 10 (slow conformation change)...
Generic type of scatterer: can be an atom, or a more complex assembly of atoms.
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...
MolAtom * mpAtom0
The first atom (fixed).
std::set< MolAtom * > mvMDFullAtomGroup
Full list of atoms that can be moved using molecular dynamics This excludes any atom part of a rigid ...
void RigidifyWithDihedralAngles()
Add dihedral angles so as to rigidify the Molecule.
Quaternion()
Default constructor, yields q=(1,0,0,0)
REAL BondAngleRandomChange(const StretchModeBondAngle &mode, const REAL amplitude, const bool respectRestraint=true)
change a bond angle, while respecting the Restraint (if any).
list< StretchModeBondAngle > mvStretchModeBondAngle
List of StretchModeBondLength.
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.
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.
bool IsDummy() const
Returns true if this is a dummy atom, i.e.
Atoms moved between two other atoms, using a "twist" of their positions - only small twists of their ...
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.
RefObjOpt mOptimizeOrientation
Option to optimize the Molecule's orientation.
vector< MolAtom * > mvpAtom
The vector of the 4 atoms involved in the bond angle.
void OptimizeConformationSteepestDescent(const REAL maxStep=0.1, const unsigned nbStep=1)
Optimize the conformation from internal restraints (bond lengths, angles and dihedral angles)...
void OptimizeConformation(const long nbTrial=10000, const REAL stopCost=0.)
Minimize configuration from internal restraints (bond lengths, angles and dihedral angles)...
Abstract Base Class to describe the scattering power of any Scatterer component in a crystal...