22 #ifndef _OBJCRYST_CRYSTAL_H_
23 #define _OBJCRYST_CRYSTAL_H_
25 #include "ObjCryst/CrystVector/CrystVector.h"
27 #include "ObjCryst/ObjCryst/General.h"
28 #include "ObjCryst/RefinableObj/RefinableObj.h"
29 #include "ObjCryst/ObjCryst/UnitCell.h"
30 #include "ObjCryst/ObjCryst/ScatteringPower.h"
31 #include "ObjCryst/ObjCryst/Scatterer.h"
44 extern const RefParType *gpRefParTypeCrystal;
52 gpRefParTypeCrystal=
new RefParType (gpRefParTypeUnitCell,
"Crystal");
59 delete gpRefParTypeCrystal;
60 gpRefParTypeCrystal=0;
106 Crystal(
const REAL a,
const REAL b,
const REAL c,
107 const string &SpaceGroupId);
113 Crystal(
const REAL a,
const REAL b,
const REAL c,
const REAL alpha,
114 const REAL beta,
const REAL gamma,
const string &SpaceGroupId);
191 void Print(ostream &os=cout)
const;
247 virtual void GLInitDisplayList(
const bool onlyIndependentAtoms=
false,
248 const REAL xMin=-.1,
const REAL xMax=1.1,
249 const REAL yMin=-.1,
const REAL yMax=1.1,
250 const REAL zMin=-.1,
const REAL zMax=1.1,
251 const bool displayNames=
false,
252 const bool hideHydrogens=
false,
253 const REAL fadeDistance=0,
254 const bool fullMoleculeInLimits=
false)
const;
277 void CalcDynPopCorr(
const REAL overlapDist=1.,
const REAL mergeDist=.0)
const ;
314 const bool allowMerge);
328 BumpMergePar(
const REAL dist,
const bool canOverlap=
false);
345 const REAL x,
const REAL y,
const REAL z);
357 Neighbour(
const unsigned long neighbourIndex,
const int sym,
384 InterMolDistPar(
const vector<string> At1,
const vector<string> At2,
const REAL actualDist,
const REAL dist,
const REAL sigma,
const REAL delta);
387 string get_list_At1();
388 string get_list_At2();
389 void set_At2(
string atom_names);
393 vector<int> mAt1Indexes;
394 vector<DistTableInternalPosition> vUniqueIndexAt1;
398 vector<int> mAt2Indexes;
399 vector<DistTableInternalPosition> vPosAt2;
403 vector<NeighbourHood> mNbh;
417 mutable vector<NamedScatteringComponent> mNamedScattCompList;
419 const vector<NamedScatteringComponent>& GetNamedScatteringComponentList()
const;
421 void SetNewInterMolDist(
const vector<string> At1,
const vector<string> At2,
const REAL dist,
const REAL sigma,
const REAL delta)
const;
423 void RemoveIntermolDistPar(
int Index)
const;
425 int GetIntermolDistNb()
const;
429 void InitializeInterMolDistList()
const;
431 mutable bool mInterMolDistListNeedsInit;
433 REAL GetInterMolDistCost()
const;
439 virtual void XMLOutput(ostream &os,
int indent=0)
const;
461 virtual void CIFOutput(ostream &os,
double mindist = 0.5)
const;
464 CrystVector_uint & groupIndex,
465 unsigned int &firstGroup)
const;
467 const bool enableRestraints=
false);
474 std::map<pair<const ScatteringPower*,const ScatteringPower*>, REAL>& GetBondValenceRoList();
475 const std::map<pair<const ScatteringPower*,const ScatteringPower*>, REAL>& GetBondValenceRoList()
const;
482 void Init(
const REAL a,
const REAL b,
const REAL c,
const REAL alpha,
483 const REAL beta,
const REAL gamma,
const string &SpaceGroupId,
498 void ConnectAtoms(
const REAL min_relat_dist=0.4,
const REAL max_relat_dist=1.3,
const bool warnuser_fail=
false);
521 vector<int> FindScatterersInComponentList(
const string &scattName)
const;
525 bool isScattererInInterMolDistList(
string &scattName)
const;
526 bool isScattererInInterMolDistListAt1(
string &scattName)
const;
527 bool isScattererInInterMolDistListAt2(
string &scattName)
const;
548 void CalcDistTableForInterMolDistCost()
const;
551 void printInterMolDistList()
const;
576 mutable std::vector<InterMolDistPar> mInterMolDistList;
580 mutable vector<vector<int> > mInterMolDistListIndexes;
582 mutable REAL mInterMolDistCost;
584 REAL mInterMolDistCostScale;
600 mutable std::vector<NeighbourHood> mvDistTableSq;
606 mutable REAL mDistTableForInterMolMaxDistance;
608 mutable REAL mDistMaxMultiplier;
659 bool mDeleteSubObjInDestructor;
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
const RefParType * gpRefParTypeObjCryst
Top RefParType for the ObjCryst++ library.
ObjRegistry< Crystal > gCrystalRegistry("List of all Crystals")
Global registry for all Crystal objects.
Crystal class: Unit cell, spacegroup, scatterers.
void ResetDynPopCorr() const
Reset Dynamical Population Correction factors (ie set it to 1)
void Print(ostream &os=cout) const
Prints some info about the crystal.
RefinableObjClock mMasterClockScatteringPower
master clock recording every change in Scattering Powers
virtual void CIFOutput(ostream &os, double mindist=0.5) const
output Crystal structure as a cif file
~Crystal()
Crystal destructor.
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
REAL GetBondValenceCost() const
Get the Bond-Valence cost function, which compares the expected valence to the one computed from Bond...
ostream & POVRayDescription(ostream &os, const CrystalPOVRayOptions &options) const
XMLOutput POV-Ray Description for this Crystal.
RefinableObjClock mClockDynPopCorr
CrystMatrix_REAL GetMinDistanceTable(const REAL minDistance=0.1) const
Minimum interatomic distance between all scattering components (atoms) in the crystal.
ScatteringComponentList mScattCompList
The list of all scattering components in the crystal.
RefinableObjClock mBondValenceParClock
Last Time Bond Valence parameters were changed.
REAL mBondValenceCostScale
Bond Valence cost scale factor.
RefinableObjClock mBondValenceCalcClock
Last time Bond Valences were calculated.
void CalcDistTable(const bool fast) const
Compute the distance Table (mDistTable) for all scattering components.
ScatteringPower & GetScatteringPower(const string &name)
Find a ScatteringPower from its name. Names must be unique in a given Crystal.
void PrintMinDistanceTable(const REAL minDistance=0.1, ostream &os=cout) const
Print the minimum distance table between all scattering centers (atoms) in the crystal.
std::map< long, REAL > mvBondValenceCalc
List of calculated bond valences, as a map, the key being the index of the atom in Crystal::mScattCom...
Crystal()
Default Constructor.
ObjRegistry< Scatterer > & GetScattererRegistry()
Get the registry of scatterers.
void SetUseDynPopCorr(const int use)
Set the use of dynamical population correction (Crystal::mUseDynPopCorr).
RefinableObjClock mBumpMergeCostClock
Last Time Anti-bump parameters were changed.
virtual const ScatteringComponentList & GetScatteringComponentList() const
Get the list of all scattering components.
virtual void GlobalOptRandomMove(const REAL mutationAmplitude, const RefParType *type=gpRefParTypeObjCryst)
Make a random move of the current configuration.
void ConnectAtoms(const REAL min_relat_dist=0.4, const REAL max_relat_dist=1.3, const bool warnuser_fail=false)
Convert as much as possible the crystal's atoms to molecule(s).
void InitOptions()
Init options.
RefinableObjClock mDistTableForInterMolDistClock
The time when the distance table was last calculated.
int GetUseDynPopCorr() const
Get dynamical population correction setting.
void AddScatteringPower(ScatteringPower *scattPow)
Add a ScatteringPower for this Crystal.
int FindScatterer(const string &scattName) const
Find a scatterer (its index # in mpScatterrer[]) with a given name.
const RefinableObjClock & GetClockScattererList() const
When was the list of scatterers last changed ?
RefinableObjClock mClockScattererList
Last time the list of Scatterers was changed.
ObjRegistry< ScatteringPower > mScatteringPowerRegistry
The registry of ScatteringPower for this Crystal.
map< pair< const ScatteringPower *, const ScatteringPower * >, REAL > mvBondValenceRo
Map of Bond Valence "Ro" parameters for each couple of ScatteringPower.
void CalcBondValenceSum() const
Calculate all Bond Valences.
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.
RefinableObjClock mClockNeighborTable
void MergeEqualScatteringPowers(const bool oneScatteringPowerPerElement)
Merge all equal scattering powers.
REAL GetWeight() const
Weight for the crystal formula, in atomic units (g/mol).
REAL mDistTableMaxDistance
The distance up to which the distance table & neighbours needs to be calculated.
REAL GetDynPopCorr(const Scatterer *pscatt, unsigned int component) const
Access the Dynamical Occupancy Correction for a given component (atom) in a given Scatterer.
ObjRegistry< Scatterer > mScattererRegistry
The registry of scatterers for this UnitCell.
VBumpMergePar mvBumpMergePar
Anti-bump parameters map.
ObjRegistry< ScatteringPower > & GetScatteringPowerRegistry()
Get the registry of ScatteringPower included in this Crystal.
const RefinableObjClock & GetClockScattCompList() const
Get the list of all scattering components.
REAL GetBumpMergeCost() const
Get the Anti-bumping/pro-Merging cost function.
RefinableObjClock mBumpMergeParClock
Last Time Anti-bump parameters were changed.
RefObjOpt mUseDynPopCorr
Use Dynamical population correction (ScatteringComponent::mDynPopCorr) during Structure factor calcul...
RefObjOpt mDisplayEnantiomer
Display the enantiomeric (mirror along x) structure in 3D? This can be helpful for non-centrosymmetri...
virtual const string & GetClassName() const
Name for this class ("RefinableObj", "Crystal",...).
Scatterer & GetScatt(const string &scattName)
Provides an access to the scatterers.
void RemoveScatteringPower(ScatteringPower *scattPow, const bool del=true)
Remove a ScatteringPower for this Crystal.
void RemoveBumpMergeDistance(const ScatteringPower &scatt1, const ScatteringPower &scatt2)
Remove an Anti-bumping distance between two scattering types.
void RemoveScatterer(Scatterer *scatt, const bool del=true)
Remove a Scatterer. This also deletes the scatterer unless del=false.
RefinableObjClock mClockScattCompList
std::string GetFormula() const
Formula with atoms in alphabetic order.
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input the crystal structure from a stream.
long GetNbScatterer() const
Number of scatterers in the crystal.
void AddScatterer(Scatterer *scatt)
Add a scatterer to the crystal.
REAL mBumpMergeCost
Current bump-merge cost.
RefinableObjClock mDistTableClock
The time when the distance table was last calculated.
void SetBumpMergeDistance(const ScatteringPower &scatt1, const ScatteringPower &scatt2, const REAL dist=1.5)
Set the Anti-bumping distance between two scattering types.
virtual REAL GetLogLikelihood() const
Get -log(likelihood) of the current configuration for the object.
RefinableObjClock mLatticeClock
Clock for lattice paramaters.
void CalcDynPopCorr(const REAL overlapDist=1., const REAL mergeDist=.0) const
Compute the 'Dynamical population correction for all atoms. Atoms which are considered "equivalent" (...
RefinableObjClock mBondValenceCostClock
Last time the Bond Valence cost was calculated.
void SetDeleteSubObjInDestructor(const bool b)
Set whether to delete the Scatterers and ScatteringPowers in the destructor.
REAL mBumpMergeScale
Bump-merge scale factor.
virtual void GetGeneGroup(const RefinableObj &obj, CrystVector_uint &groupIndex, unsigned int &firstGroup) const
Get the gene group assigned to each parameter.
void Init(const REAL a, const REAL b, const REAL c, const REAL alpha, const REAL beta, const REAL gamma, const string &SpaceGroupId, const string &name)
Init all Crystal parameters.
std::map< pair< const ScatteringPower *, const ScatteringPower * >, Crystal::BumpMergePar > VBumpMergePar
Anti-bump parameters.
REAL mBondValenceCost
Current Bond Valence cost.
const RefinableObjClock & GetMasterClockScatteringPower() const
Get the clock which reports all changes in ScatteringPowers.
Storage for anti-bump/merge parameters.
bool mCanOverlap
Can the two atoms completely overlap ?
REAL mDist2
The squared antibump interatomic distance.
int mSymmetryIndex
Which symmetry operation does this symmetric correspond to ?
long mAtomIndex
Index of the atom (order) in the component list.
REAL mX
Fractionnal coordinates.
unsigned long mNeighbourIndex
The number associated to the neighbour (its index in the Crystal's scattering component list)
unsigned int mNeighbourSymmetryIndex
The symmetry position associated to the neighbour (its index in the Crystal's scattering component li...
REAL mDist2
The squared distance, in square Angstroems.
Table of neighbours for a given unique atom.
unsigned long mIndex
Index of the atom in the scattering component list.
unsigned int mUniquePosSymmetryIndex
Index of the symmetry operation for the chosen unique position in the (pseudo) asymmetric unit.
std::vector< Crystal::Neighbour > mvNeighbour
List of neighbours.
Class to store POV-Ray output options.
Generic type of scatterer: can be an atom, or a more complex assembly of atoms.
Abstract Base Class to describe the scattering power of any Scatterer component in a crystal.
A scattering position in a crystal, associated with the corresponding occupancy and a pointer to the ...
list of scattering positions in a crystal, associated with the corresponding occupancy and a pointer ...
Unit Cell class: Unit cell with spacegroup information.
class to input or output a well-formatted xml beginning or ending tag.
class of refinable parameter types.
We need to record exactly when refinable objects have been modified for the last time (to avoid re-co...
Generic Refinable Object.
Abstract base class for all objects in wxCryst.
wxCryst class for Crystals