FOX/ObjCryst++  1.10.X (development)
ObjCryst::Crystal Class Reference

Crystal class: Unit cell, spacegroup, scatterers. More...

+ Inheritance diagram for ObjCryst::Crystal:
+ Collaboration diagram for ObjCryst::Crystal:

Classes

struct  BumpMergePar
 Storage for anti-bump/merge parameters. More...
 
struct  Neighbour
 Interatomic distance for a given neighbour. More...
 
struct  NeighbourHood
 Table of neighbours for a given unique atom. More...
 

Public Types

typedef std::map< pair< const
ScatteringPower *, const
ScatteringPower * >
, Crystal::BumpMergePar
VBumpMergePar
 Anti-bump parameters. More...
 

Public Member Functions

 Crystal ()
 Default Constructor.
 
 Crystal (const REAL a, const REAL b, const REAL c, const string &SpaceGroupId)
 Crystal Constructor (orthorombic) More...
 
 Crystal (const REAL a, const REAL b, const REAL c, const REAL alpha, const REAL beta, const REAL gamma, const string &SpaceGroupId)
 Crystal Constructor (triclinic) More...
 
 Crystal (const Crystal &oldCryst)
 Crystal copy constructor.
 
 ~Crystal ()
 Crystal destructor.
 
virtual const string & GetClassName () const
 Name for this class ("RefinableObj", "Crystal",...). More...
 
void AddScatterer (Scatterer *scatt)
 Add a scatterer to the crystal. More...
 
void RemoveScatterer (Scatterer *scatt, const bool del=true)
 Remove a Scatterer. This also deletes the scatterer unless del=false.
 
long GetNbScatterer () const
 Number of scatterers in the crystal.
 
ScattererGetScatt (const string &scattName)
 Provides an access to the scatterers. More...
 
const ScattererGetScatt (const string &scattName) const
 Provides a const access to the scatterers. More...
 
ScattererGetScatt (const long scattIndex)
 Provides an access to the scatterers. More...
 
const ScattererGetScatt (const long scattIndex) const
 Provides a const access to the scatterers. More...
 
ObjRegistry< Scatterer > & GetScattererRegistry ()
 Get the registry of scatterers.
 
const ObjRegistry< Scatterer > & GetScattererRegistry () const
 Get the registry of scatterers.
 
ObjRegistry< ScatteringPower > & GetScatteringPowerRegistry ()
 Get the registry of ScatteringPower included in this Crystal.
 
const ObjRegistry
< ScatteringPower > & 
GetScatteringPowerRegistry () const
 Get the registry of ScatteringPower included in this Crystal.
 
void AddScatteringPower (ScatteringPower *scattPow)
 Add a ScatteringPower for this Crystal. More...
 
void RemoveScatteringPower (ScatteringPower *scattPow, const bool del=true)
 Remove a ScatteringPower for this Crystal. More...
 
ScatteringPowerGetScatteringPower (const string &name)
 Find a ScatteringPower from its name. Names must be unique in a given Crystal.
 
const ScatteringPowerGetScatteringPower (const string &name) const
 Find a ScatteringPower from its name. Names must be unique in a given Crystal.
 
const RefinableObjClockGetMasterClockScatteringPower () const
 Get the clock which reports all changes in ScatteringPowers.
 
virtual const
ScatteringComponentList
GetScatteringComponentList () const
 Get the list of all scattering components.
 
const RefinableObjClockGetClockScattCompList () const
 Get the list of all scattering components.
 
void Print (ostream &os=cout) const
 Prints some info about the crystal. More...
 
CrystMatrix_REAL GetMinDistanceTable (const REAL minDistance=0.1) const
 Minimum interatomic distance between all scattering components (atoms) in the crystal. More...
 
void PrintMinDistanceTable (const REAL minDistance=0.1, ostream &os=cout) const
 Print the minimum distance table between all scattering centers (atoms) in the crystal. More...
 
ostream & POVRayDescription (ostream &os, const CrystalPOVRayOptions &options) const
 XMLOutput POV-Ray Description for this Crystal. More...
 
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 displayNames=false, const bool hideHydrogens=false) const
 Create an OpenGL DisplayList of the crystal. More...
 
void CalcDynPopCorr (const REAL overlapDist=1., const REAL mergeDist=.0) const
 Compute the 'Dynamical population correction for all atoms. Atoms which are considered "equivalent" (ie currently with the same Z number) and which are overlapping see their Dynamical occupancy changed so that when they fully overlap, they are equivalent to 1 atom. More...
 
void ResetDynPopCorr () const
 Reset Dynamical Population Correction factors (ie set it to 1)
 
REAL GetDynPopCorr (const Scatterer *pscatt, unsigned int component) const
 Access the Dynamical Occupancy Correction for a given component (atom) in a given Scatterer.
 
void SetUseDynPopCorr (const int use)
 Set the use of dynamical population correction (Crystal::mUseDynPopCorr). More...
 
int GetUseDynPopCorr () const
 Get dynamical population correction setting. More...
 
REAL GetBumpMergeCost () const
 Get the Anti-bumping/pro-Merging cost function. More...
 
void SetBumpMergeDistance (const ScatteringPower &scatt1, const ScatteringPower &scatt2, const REAL dist=1.5)
 Set the Anti-bumping distance between two scattering types. More...
 
void SetBumpMergeDistance (const ScatteringPower &scatt1, const ScatteringPower &scatt2, const REAL dist, const bool allowMerge)
 Set the Anti-bumping distance between two scattering types.
 
void RemoveBumpMergeDistance (const ScatteringPower &scatt1, const ScatteringPower &scatt2)
 Remove an Anti-bumping distance between two scattering types.
 
const VBumpMergeParGetBumpMergeParList () const
 
VBumpMergeParGetBumpMergeParList ()
 
const RefinableObjClockGetClockScattererList () const
 When was the list of scatterers last changed ?
 
virtual void XMLOutput (ostream &os, int indent=0) const
 Output to stream in well-formed XML. More...
 
virtual void XMLInput (istream &is, const XMLCrystTag &tag)
 Input From stream. More...
 
virtual void GlobalOptRandomMove (const REAL mutationAmplitude, const RefParType *type=gpRefParTypeObjCryst)
 Make a random move of the current configuration. More...
 
virtual REAL GetLogLikelihood () const
 Get -log(likelihood) of the current configuration for the object. More...
 
virtual void CIFOutput (ostream &os, double mindist=0.5) const
 output Crystal structure as a cif file (EXPERIMENTAL !) More...
 
virtual void GetGeneGroup (const RefinableObj &obj, CrystVector_uint &groupIndex, unsigned int &firstGroup) const
 Get the gene group assigned to each parameter. More...
 
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. More...
 
void AddBondValenceRo (const ScatteringPower &, const ScatteringPower &, const REAL ro)
 
void RemoveBondValenceRo (const ScatteringPower &, const ScatteringPower &)
 
REAL GetBondValenceCost () const
 Get the Bond-Valence cost function, which compares the expected valence to the one computed from Bond-Valence Ro parameters.
 
std::map< pair< const
ScatteringPower *, const
ScatteringPower * >, REAL > & 
GetBondValenceRoList ()
 
const std::map< pair< const
ScatteringPower *, const
ScatteringPower * >, REAL > & 
GetBondValenceRoList () const
 
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. More...
 
void SetDeleteSubObjInDestructor (const bool b)
 Set whether to delete the Scatterers and ScatteringPowers in the destructor. More...
 
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). More...
 
- Public Member Functions inherited from ObjCryst::UnitCell
 UnitCell ()
 Default Constructor.
 
 UnitCell (const REAL a, const REAL b, const REAL c, const string &SpaceGroupId)
 UnitCell Constructor (orthorombic) More...
 
 UnitCell (const REAL a, const REAL b, const REAL c, const REAL alpha, const REAL beta, const REAL gamma, const string &SpaceGroupId)
 UnitCell Constructor (triclinic) More...
 
 UnitCell (const UnitCell &oldCryst)
 UnitCell copy constructor.
 
 ~UnitCell ()
 Destructor.
 
CrystVector_REAL GetLatticePar () const
 Lattice parameters (a,b,c,alpha,beta,gamma) as a 6-element vector in Angstroems and radians. More...
 
REAL GetLatticePar (const int whichPar) const
 Return one of the 6 Lattice parameters, 0<= whichPar <6 (a,b,c,alpha,beta,gamma), returned in Angstroems and radians. More...
 
const RefinableObjClockGetClockLatticePar () const
 last time the Lattice parameters were changed
 
const CrystMatrix_REAL & GetBMatrix () const
 Get the 'B' matrix (UnitCell::mBMatrix)for the UnitCell (orthogonalization matrix for the given lattice, in the reciprocal space) More...
 
const CrystMatrix_REAL & GetOrthMatrix () const
 Get the orthogonalization matrix (UnitCell::mOrthMatrix)for the UnitCell in real space. More...
 
const RefinableObjClockGetClockMetricMatrix () const
 last time the metric matrices were changed
 
CrystVector_REAL GetOrthonormalCoords (const REAL x, const REAL y, const REAL z) const
 Get orthonormal cartesian coordinates for a set of (x,y,z) fractional coordinates. More...
 
void FractionalToOrthonormalCoords (REAL &x, REAL &y, REAL &z) const
 Get orthonormal cartesian coordinates for a set of (x,y,z) fractional coordinates. More...
 
void OrthonormalToFractionalCoords (REAL &x, REAL &y, REAL &z) const
 Get fractional cartesian coordinates for a set of (x,y,z) orthonormal coordinates. More...
 
void MillerToOrthonormalCoords (REAL &x, REAL &y, REAL &z) const
 Get Miller H,K, L indices from orthonormal coordinates in reciprocal space. More...
 
void OrthonormalToMillerCoords (REAL &x, REAL &y, REAL &z) const
 Get orthonormal coordinates given a set of H,K, L indices in reciprocal space. More...
 
virtual void Print () const
 
const SpaceGroupGetSpaceGroup () const
 Access to the SpaceGroup object.
 
SpaceGroupGetSpaceGroup ()
 Access to the SpaceGroup object.
 
REAL GetVolume () const
 Volume of Unit Cell (in Angstroems)
 
- Public Member Functions inherited from ObjCryst::RefinableObj
 RefinableObj ()
 Constructor.
 
 RefinableObj (const bool internalUseOnly)
 Constructor. More...
 
 RefinableObj (const RefinableObj &old)
 Defined not implemented... More...
 
virtual ~RefinableObj ()
 Destructor.
 
virtual const string & GetName () const
 Name of the object.
 
virtual void SetName (const string &name)
 Name of the object.
 
void operator= (const RefinableObj &old)
 Defined not implemented... More...
 
void PrepareForRefinement () const
 Find which parameters are used and not fixed, for a refinement /optimization. More...
 
void FixAllPar ()
 Fix All parameters.
 
void UnFixAllPar ()
 UnFix All parameters.
 
void SetParIsFixed (const long parIndex, const bool fix)
 Fix/un-fix one parameter from its #.
 
void SetParIsFixed (const string &parName, const bool fix)
 Fix/un-fix one parameter from its name.
 
void SetParIsFixed (const RefParType *type, const bool fix)
 Fix/un-fix one family of parameters.
 
void SetParIsUsed (const string &parName, const bool use)
 Set whether a parameter is used.
 
void SetParIsUsed (const RefParType *type, const bool use)
 Set whether a family of parameters is used.
 
long GetNbPar () const
 Total number of refinable parameter in the object. More...
 
long GetNbParNotFixed () const
 Total number of non-fixed parameters. Is initialized by PrepareForRefinement()
 
RefinableParGetPar (const long i)
 Access all parameters in the order they were inputted.
 
const RefinableParGetPar (const long i) const
 Access all parameters in the order they were inputted.
 
RefinableParGetPar (const string &name)
 Access all parameters from their name.
 
const RefinableParGetPar (const string &name) const
 Access all parameters from their name.
 
RefinableParGetPar (const REAL *)
 Access parameter from its adress.
 
const RefinableParGetPar (const REAL *) const
 Access parameter from its adress.
 
RefinableParGetParNotFixed (const long i)
 Access all parameters in the order they were inputted, skipping fixed parameters. More...
 
const RefinableParGetParNotFixed (const long i) const
 Access all parameters in the order they were inputed, skipping fixed parameters. More...
 
void AddPar (const RefinablePar &newRefPar)
 Add a refinable parameter. More...
 
void AddPar (RefinablePar *newRefPar)
 Add a refinable parameter. More...
 
void AddPar (RefinableObj &newRefParList, const bool copyParam=false)
 Add all the parameters in another RefinableObj. More...
 
vector< RefinablePar * >::iterator RemovePar (RefinablePar *refPar)
 Remove a refinable parameter. More...
 
unsigned long CreateParamSet (const string name="") const
 Save the current set of refined values in a new set. More...
 
void ClearParamSet (const unsigned long id) const
 Erase the param set with the given id, releasing memory.
 
void SaveParamSet (const unsigned long id) const
 Save the current set of refined values over a previously-created set of saved values. More...
 
void RestoreParamSet (const unsigned long id)
 Restore a saved set of values. More...
 
const CrystVector_REAL & GetParamSet (const unsigned long setId) const
 Access one save refpar set. More...
 
CrystVector_REAL & GetParamSet (const unsigned long setId)
 Access one save refpar set. More...
 
REAL GetParamSet_ParNotFixedHumanValue (const unsigned long setId, const long parNumber) const
 Access the (human) value of one refined parameter in a saved set of parameters. More...
 
const void EraseAllParamSet ()
 Erase all saved refpar sets. More...
 
const string & GetParamSetName (const unsigned long setId) const
 Get the name associated to a refpar set. More...
 
void SetLimitsAbsolute (const string &parName, const REAL min, const REAL max)
 Change the limits for a given parameter, giving absolute new limits.
 
void SetLimitsAbsolute (const RefParType *type, const REAL min, const REAL max)
 Change the limits for a category of parameters, giving absolute new limits.
 
void SetLimitsRelative (const string &parName, const REAL min, const REAL max)
 Change the limits for a given parameter, giving relative new limits (eg giving -.1 and +.1 will set new limits at the current value + min and current value + max) Thus min should logically be <0 and max >0. More...
 
void SetLimitsRelative (const RefParType *type, const REAL min, const REAL max)
 Change the limits for a category of parameters, giving relative new limits (eg giving -.1 and +.1 will set new limits at the current value + min and current value + max). More...
 
void SetLimitsProportional (const string &parName, const REAL min, const REAL max)
 Change the limits for a given parameter, proportionnaly to the current value. More...
 
void SetLimitsProportional (const RefParType *type, const REAL min, const REAL max)
 Change the limits for a category of parameters, proportionnaly to their current value. More...
 
void SetGlobalOptimStep (const RefParType *type, const REAL step)
 Change the maximum step to use during Global Optimization algorithms.
 
ObjRegistry< RefinableObj > & GetSubObjRegistry ()
 Access to the registry of RefinableObj used by this object.
 
const ObjRegistry< RefinableObj > & GetSubObjRegistry () const
 Access to the registry of RefinableObj used by this object.
 
virtual void RegisterClient (RefinableObj &) const
 Register a new object using this object. More...
 
virtual void DeRegisterClient (RefinableObj &) const
 Deregister an object (which not any more) using this object.
 
virtual const ObjRegistry
< RefinableObj > & 
GetClientRegistry () const
 Get the list of clients.
 
virtual ObjRegistry
< RefinableObj > & 
GetClientRegistry ()
 Get the list of clients.
 
bool IsBeingRefined () const
 Is the object being refined ? (Can be refined by one algorithm at a time only.)
 
virtual void EndOptimization ()
 This should be called by any optimization class at the end of an optimization. More...
 
virtual void SetApproximationFlag (const bool allow)
 Enable or disable numerical approximations. More...
 
virtual void RandomizeConfiguration ()
 Randomize Configuration (before a global optimization). More...
 
void BeginGlobalOptRandomMove ()
 Raise a flag, to be sure not to make a random change more than once in each RefinableObj. More...
 
virtual unsigned int GetNbLSQFunction () const
 Number of LSQ functions.
 
virtual const CrystVector_REAL & GetLSQCalc (const unsigned int) const
 Get the current calculated value for the LSQ function.
 
virtual const CrystVector_REAL & GetLSQObs (const unsigned int) const
 Get the observed values for the LSQ function.
 
virtual const CrystVector_REAL & GetLSQWeight (const unsigned int) const
 Get the weight values for the LSQ function.
 
virtual const CrystVector_REAL & GetLSQDeriv (const unsigned int, RefinablePar &)
 Get the first derivative values for the LSQ function, for a given parameter. More...
 
virtual std::map< RefinablePar
*, CrystVector_REAL > & 
GetLSQ_FullDeriv (const unsigned int, std::set< RefinablePar * > &vPar)
 Get the first derivative for the LSQ function for each parameter supplied in a list. More...
 
void ResetParList ()
 Re-init the list of refinable parameters, removing all parameters. More...
 
virtual void UpdateDisplay () const
 If there is an interface, this should be automatically be called each time there is a 'new, significant' configuration to report. More...
 
unsigned int GetNbOption () const
 Number of Options for this object.
 
RefObjOptGetOption (const unsigned int i)
 Access to the options.
 
const RefObjOptGetOption (const unsigned int i) const
 const access to the options
 
void SetDeleteRefParInDestructor (const bool b)
 Set this object not to delete its list of parameters when destroyed. More...
 
const RefinableObjClockGetRefParListClock () const
 What was the last time a RefinablePar was added/removed ? More...
 
virtual REAL GetRestraintCost () const
 Get the restraint cost (overall penalty of all restraints) More...
 
void AddRestraint (Restraint *pNewRestraint)
 Add a new restraint. More...
 
vector< Restraint * >::iterator RemoveRestraint (Restraint *pRestraint)
 Remove a restraint from the list of known restraints. More...
 
virtual void TagNewBestConfig () const
 During a global optimization, tells the object that the current config is the latest "best" config. More...
 
const RefinableObjClockGetClockMaster () const
 This clocks records any change in the object. See refinableObj::mClockMaster.
 

Private Member Functions

void InitOptions ()
 Init options. More...
 
int FindScatterer (const string &scattName) const
 Find a scatterer (its index # in mpScatterrer[]) with a given name. More...
 
void CalcDistTable (const bool fast) const
 Compute the distance Table (mDistTable) for all scattering components. More...
 
void CalcBondValenceSum () const
 Calculate all Bond Valences.
 

Private Attributes

ObjRegistry< ScatterermScattererRegistry
 The registry of scatterers for this UnitCell.
 
VBumpMergePar mvBumpMergePar
 Anti-bump parameters map.
 
RefinableObjClock mBumpMergeParClock
 Last Time Anti-bump parameters were changed.
 
RefinableObjClock mBumpMergeCostClock
 Last Time Anti-bump parameters were changed.
 
REAL mBumpMergeCost
 Current bump-merge cost.
 
REAL mBumpMergeScale
 Bump-merge scale factor.
 
std::vector< NeighbourHoodmvDistTableSq
 Interatomic distance table for all unique atoms. More...
 
RefinableObjClock mDistTableClock
 The time when the distance table was last calculated.
 
REAL mDistTableMaxDistance
 The distance up to which the distance table & neighbours needs to be calculated.
 
ScatteringComponentList mScattCompList
 The list of all scattering components in the crystal.
 
RefinableObjClock mLatticeClock
 Clock for lattice paramaters.
 
RefObjOpt mUseDynPopCorr
 Use Dynamical population correction (ScatteringComponent::mDynPopCorr) during Structure factor calculation ?
 
ObjRegistry< ScatteringPowermScatteringPowerRegistry
 The registry of ScatteringPower for this Crystal.
 
RefinableObjClock mClockScattererList
 Last time the list of Scatterers was changed.
 
RefinableObjClock mClockScattCompList
 
RefinableObjClock mClockNeighborTable
 
RefinableObjClock mClockDynPopCorr
 
RefinableObjClock mMasterClockScatteringPower
 master clock recording every change in Scattering Powers
 
RefObjOpt mDisplayEnantiomer
 Display the enantiomeric (mirror along x) structure in 3D? This can be helpful for non-centrosymmetric structure which have been solved using powder diffraction (which only gives the relative configuration). More...
 
map< pair< const
ScatteringPower *, const
ScatteringPower * >, REAL > 
mvBondValenceRo
 Map of Bond Valence "Ro" parameters for each couple of ScatteringPower.
 
RefinableObjClock mBondValenceParClock
 Last Time Bond Valence parameters were changed.
 
RefinableObjClock mBondValenceCalcClock
 Last time Bond Valences were calculated.
 
RefinableObjClock mBondValenceCostClock
 Last time the Bond Valence cost was calculated.
 
REAL mBondValenceCost
 Current Bond Valence cost.
 
REAL mBondValenceCostScale
 Bond Valence cost scale factor.
 
std::map< long, REAL > mvBondValenceCalc
 List of calculated bond valences, as a map, the key being the index of the atom in Crystal::mScattCompList. More...
 
bool mDeleteSubObjInDestructor
 

Additional Inherited Members

- Protected Member Functions inherited from ObjCryst::UnitCell
void InitRefParList ()
 Prepare the refinable parameters list. More...
 
- Protected Member Functions inherited from ObjCryst::RefinableObj
long FindPar (const string &name) const
 Find a refinable parameter with a given name.
 
long FindPar (const REAL *) const
 Find a refinable parameter from the adress of its value.
 
void AddSubRefObj (RefinableObj &)
 
void RemoveSubRefObj (RefinableObj &)
 
void AddOption (RefObjOpt *opt)
 
virtual void Prepare ()
 
map< unsigned long, pair
< CrystVector_REAL, string >
>::iterator 
FindParamSet (unsigned long id) const
 Find a parameter set with a given id (and check if it is there)
 
- Protected Attributes inherited from ObjCryst::RefinableObj
string mName
 Name for this RefinableObject. Should be unique, at least in the same scope.+.
 
vector< RefinablePar * > mvpRefPar
 Vector of pointers to the refinable parameters.
 
vector< Restraint * > mvpRestraint
 Vector of pointers to the restraints for this object. More...
 
map< unsigned long, pair
< CrystVector_REAL, string > > 
mvpSavedValuesSet
 Map of (index,pointers to arrays) used to save sets of values for all parameters. More...
 
long mNbRefParNotFixed
 Total of not-fixed parameters.
 
CrystVector_long mRefparNotFixedIndex
 Index of not-fixed parameters.
 
int mOptimizationDepth
 Is the object being refined or optimized ? if mOptimizationDepth=0, no optimization is taking place. More...
 
ObjRegistry< RefinableObjmSubObjRegistry
 Registry of RefinableObject needed for this object (owned by this object or not)
 
ObjRegistry< RefinableObjmClientObjRegistry
 Registry of RefinableObject using this object. More...
 
ObjRegistry< RefObjOptmOptionRegistry
 List of options for this object. More...
 
bool mDeleteRefParInDestructor
 If true (the default), then all RefinablePar will be deleted when the the object is deleted. More...
 
RefinableObjClock mRefParListClock
 Last time the RefinableParList was modified (a parameter added or removed).
 
bool mRandomMoveIsDone
 
CrystVector_REAL mLSQDeriv
 Temporary array used to return derivative values of the LSQ function for given parameters. More...
 
std::map< unsigned int,
std::map< RefinablePar
*, CrystVector_REAL > > 
mLSQ_FullDeriv
 Temporary map to return the derivative of the LSQ function versus a list of parameters. More...
 
RefinableObjClock mClockMaster
 Master clock, which is changed whenever the object has been altered. More...
 

Detailed Description

Crystal class: Unit cell, spacegroup, scatterers.

A Crystal object has several main characteristics : (1) a unit cell, (2) a Spacegroup and (3) a list of Scatterer. Also stored in the Crystal is a list of the ScttaringPower used by all the scatterers of this crystal.

The crystal is capable of giving a list of all scattering components (ie the list of all unique scattering 'points' (ScatteringComponent, ie atoms) in the unit cell, each associated to a ScatteringPower).

When those scattering components are on a special position or overlapping with another component of the same type, it is possible to correct dynamically the occupancy of this/these components to effectively have only one component instead of several due to the overlapping. This method is interesting for global optimization where atoms must not be "locked" on a special position. If this "Dynamical Occupancy Correction" is used then no occupancy should be corrected for special positions, since this will be done dynamically.

A crystal structure can be viewed in 3D using OpenGL.

Todo:
exporting (and importing) crystal structures to/from other files format than ObjCryst's XML (eg CIF, and format used by refinement software)

Currently only 3D crystal structures can be handled, with no magnetic structure (that may be done later) and no incommensurate structure.

Definition at line 97 of file Crystal.h.

Member Typedef Documentation

Anti-bump parameters.

Each atom type (ScatteringPower is referenced using a reference number)

Definition at line 325 of file Crystal.h.

Constructor & Destructor Documentation

ObjCryst::Crystal::Crystal ( const REAL  a,
const REAL  b,
const REAL  c,
const string &  SpaceGroupId 
)

Crystal Constructor (orthorombic)

Parameters
a,b,c: unit cell dimension, in angstroems
SpaceGroupIdspace group symbol or number

Definition at line 73 of file Crystal.cpp.

ObjCryst::Crystal::Crystal ( const REAL  a,
const REAL  b,
const REAL  c,
const REAL  alpha,
const REAL  beta,
const REAL  gamma,
const string &  SpaceGroupId 
)

Crystal Constructor (triclinic)

Parameters
a,b,c: unit cell dimension, in angstroems
alpha,beta,gamma: unit cell angles, in radians.
SpaceGroupIdspace group symbol or number

Definition at line 90 of file Crystal.cpp.

Member Function Documentation

void ObjCryst::Crystal::AddScatterer ( Scatterer scatt)

Add a scatterer to the crystal.

Warning
the scatterer must be allocated in the heap, since the scatterer will not be copied but used directly. A Scatterer can only belong to one Crystal. It will be detroyed when removed or when the Crystal is destroyed.
Parameters
scatt: the address of the scatterer to be included in the crystal scatterer names must be unique in a given crystal.
Note
that the ScatteringPower used in the Scatterer should be one of the Crystal (see Crystal::AddScatteringPower())

Definition at line 174 of file Crystal.cpp.

void ObjCryst::Crystal::AddScatteringPower ( ScatteringPower scattPow)

Add a ScatteringPower for this Crystal.

It must be allocated in the heap, and not used by any other Crystal.

Definition at line 227 of file Crystal.cpp.

void ObjCryst::Crystal::BeginOptimization ( const bool  allowApproximations = false,
const bool  enableRestraints = false 
)
virtual

This should be called by any optimization class at the begining of an optimization.

This will also check that everything is ready, eg call the RefinableObj::Prepare() function. This also affects all sub-objects.

Note
this may be called several time for some objects which are used by several other objects, or for nested optimizations (e.g. least-squares optimizations inside a global one).
EndOptimization() must be called at the end of the optimization, the same number of time BeginOptimization() was called !
Parameters
allowApproximationsif true, then the object can use faster but less precise functions during the optimization. This is useful for global optimization not using derivatives.
enableRestraintsxrefitem deprecated 28.

Reimplemented from ObjCryst::RefinableObj.

Definition at line 1160 of file Crystal.cpp.

void ObjCryst::Crystal::CalcDistTable ( const bool  fast) const
private

Compute the distance Table (mDistTable) for all scattering components.

Parameters
fast: if true, the distance calculations will be made using integers, thus with a lower precision but faster. Less atoms will also be involved (using the AsymmetricUnit and mDistTableMaxDistance2) to make it even faster.
Warning
Crystal::GetScatteringComponentList() must be called beforehand, since this will not be done here.
Returns
see Crystal::mDistTableSq and Crystal::mDistTableIndex
Todo:
sanitize the result distance table in a more usable structure than the currently used Crystal::mDistTableSq and Crystal::mDistTableIndex.
Warning
not using the fast option has not been very much tested...
optimize again. Test if recomputation is needed using Clocks. Use a global option instead of asymUnitMargin.

Definition at line 1628 of file Crystal.cpp.

void ObjCryst::Crystal::CalcDynPopCorr ( const REAL  overlapDist = 1.,
const REAL  mergeDist = .0 
) const

Compute the 'Dynamical population correction for all atoms. Atoms which are considered "equivalent" (ie currently with the same Z number) and which are overlapping see their Dynamical occupancy changed so that when they fully overlap, they are equivalent to 1 atom.

Parameters
overlapDist: distance below which atoms (ScatteringComponents, to be more precise) are considered overlapping and should be corrected. The correction changes the dynamical occupancy from 1 to 1/nbAtomOverlapping, progressively as the distance falls from overlapDist to mergeDist.
mergeDist: distance below which atoms are considered fully overlapping. If 3 atoms are 'fully' overlapping, then all have a dynamical population correction equal to 1/3

This is const since ScatteringComponent::mDynPopCorr is mutable.

Warning
. Do not call this function, which will turn private. This is called by only Crystal::GetScatteringComponentList()

Definition at line 708 of file Crystal.cpp.

void ObjCryst::Crystal::CIFOutput ( ostream &  os,
double  mindist = 0.5 
) const
virtual

output Crystal structure as a cif file (EXPERIMENTAL !)

Parameters
mindist: minimum distance between atoms to consider them overlapping. Overlapping atoms are only included as comments in the CIF file.
Warning
This is very crude and EXPERIMENTAL so far: there is not much information beside atom positions...

Definition at line 930 of file Crystal.cpp.

void ObjCryst::Crystal::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).

Parameters
min_relat_dist,max_relat_distthis compares all interatomic distances with the sum of atomic covalent radii d_cov, if d_cov*min_relat_dist < d < d_cov*max_relat_dist, the atoms are assumed to be connected by a bond. This function only works if the Crystal contains only atoms.
warnuser_failif true, will pass a message to the end user that auto-creating at least one Molecule failed.
Warning
: experimental, unstable

Definition at line 1295 of file Crystal.cpp.

int ObjCryst::Crystal::FindScatterer ( const string &  scattName) const
private

Find a scatterer (its index # in mpScatterrer[]) with a given name.

Warning
There should be no duplicate names !!! :TODO: test in AddScatterer()

Definition at line 803 of file Crystal.cpp.

REAL ObjCryst::Crystal::GetBumpMergeCost ( ) const

Get the Anti-bumping/pro-Merging cost function.

Only works (ie returnes a non-null value) if you have added antibump distances using Crystal::SetBumpMergeDistance().

Definition at line 820 of file Crystal.cpp.

const string & ObjCryst::Crystal::GetClassName ( ) const
virtual

Name for this class ("RefinableObj", "Crystal",...).

This is only useful to distinguish different classes when picking up objects from the RefinableObj Global Registry

Reimplemented from ObjCryst::UnitCell.

Definition at line 168 of file Crystal.cpp.

void ObjCryst::Crystal::GetGeneGroup ( const RefinableObj obj,
CrystVector_uint &  groupIndex,
unsigned int &  firstGroup 
) const
virtual

Get the gene group assigned to each parameter.

Each parameter (a gene in terms of genetic algorithms) can be assigned to a gene group. Thus when mating two configurations, genes will be exchanged by groups. By default (in the base RefinabeObj class), each parameter is alone in its group. Derived classes can group genes for a better s** life.

The number identifying a gene group only has a meaning in a given object. It can also change on subsequent calls, and thus is not unique.

Parameters
objthe , supplied by an algorithm class (OptimizationObj,..), which contains a list of parameters, some of which (but possibly all or none) are parameters belonging to this object.
groupIndexa vector of unsigned integers, one for each parameter in the input object, giving an unsigned integer value as gene group index. At the beginning this vector should contain only zeros (no group assigned).
firstGroupthis is the number of groups which have already been assigned, plus one. The gene groups returned by this object will start from this value, and increment firstGroup for each gene group used, so that different RefinableObj cannot share a gene group.
Note
this function is not optimized, and should only be called at the beginning of a refinement.

Reimplemented from ObjCryst::RefinableObj.

Definition at line 1141 of file Crystal.cpp.

REAL ObjCryst::Crystal::GetLogLikelihood ( ) const
virtual

Get -log(likelihood) of the current configuration for the object.

By default (no likelihood evaluation available), this is equal to 0.

This call should not be recursive, it is the task of the algorithm to get the sum of likelihoods for all objects invlolved.

Note
contrary to the old "Cost Function" approach, with log(Likelihood) there is no 'choice' of cost function, so that it is the task of the object to give the optimized likelihood (possibly with user options).

Reimplemented from ObjCryst::RefinableObj.

Definition at line 925 of file Crystal.cpp.

CrystMatrix_REAL ObjCryst::Crystal::GetMinDistanceTable ( const REAL  minDistance = 0.1) const

Minimum interatomic distance between all scattering components (atoms) in the crystal.

This will return a symmetrical matrix with NbComp rows and cols, where NbComp is the number of independent scattering components in the unit cell. All distances are given in Angstroems.

Note that the distance of a given atom with 'itself' is not generally equal to 0 (except full special position), but equal to the min distance with its symmetrics.

Parameters
minDistance: atoms who are less distant than (minDistance,in Angstroems) are considered equivalent. So the smallest distance between any atoms will be at least minDistance.

Definition at line 387 of file Crystal.cpp.

Scatterer & ObjCryst::Crystal::GetScatt ( const string &  scattName)

Provides an access to the scatterers.

Parameters
scattNamethe name of the scatterer to access

Definition at line 198 of file Crystal.cpp.

const Scatterer & ObjCryst::Crystal::GetScatt ( const string &  scattName) const

Provides a const access to the scatterers.

Parameters
scattNamethe name of the scatterer to access

Definition at line 203 of file Crystal.cpp.

Scatterer & ObjCryst::Crystal::GetScatt ( const long  scattIndex)

Provides an access to the scatterers.

Parameters
scattIndexthe number of the scatterer to access

Definition at line 208 of file Crystal.cpp.

const Scatterer & ObjCryst::Crystal::GetScatt ( const long  scattIndex) const

Provides a const access to the scatterers.

Parameters
scattIndexthe number of the scatterer to access

Definition at line 213 of file Crystal.cpp.

int ObjCryst::Crystal::GetUseDynPopCorr ( ) const

Get dynamical population correction setting.

See SetUseDynPopCorr.

Definition at line 798 of file Crystal.cpp.

void ObjCryst::Crystal::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  displayNames = false,
const bool  hideHydrogens = false 
) const
virtual

Create an OpenGL DisplayList of the crystal.

Parameters
onlyIndependentAtomsif false (the default), then all symmetrics are displayed within the given limits \ param xMin,xMax,yMin,yMax,zMin,zMax: in fractionnal coordinates, the region in which we want scaterrers to be displayed. The test is made on the center of the scatterer (eg a ZScatterer (molecule) will not be 'cut' on the border).
displayNamesif true, only the names of the scatterers will be displayed, at the position of the scatterers (to actually see them, they will have to be translated with respect to the drawing of the scatterers).
hideHydrogensif true, do not display hydrogens/deuterium and their bonds

Definition at line 545 of file Crystal.cpp.

void ObjCryst::Crystal::GlobalOptRandomMove ( const REAL  mutationAmplitude,
const RefParType type = gpRefParTypeObjCryst 
)
virtual

Make a random move of the current configuration.

This is for global optimization algorithms. the moves for each parameter are less than their global optimization step, multiplied by the mutation amplitude.

Warning
: this makes a random move for the parameter declared for this object, and it is the duty of the object to decide whether the included objects should be moved and how. (eg an algorithm should only call for a move with the top object, and this object decides how he and his sub-objects moves). By default (RefinableObj implementation) all included objects are moved recursively.

RefinableObj::

Parameters
mutationAmplitudemultiplier for the maximum move amplitude, for all parameters
typerestrain the change exclusively to parameters of a given type (same type or descendant from this RefParType).

Reimplemented from ObjCryst::RefinableObj.

Definition at line 894 of file Crystal.cpp.

void ObjCryst::Crystal::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 
)
virtual

Init all Crystal parameters.

Parameters
a,b,c: unit cell dimension, in angstroems
alpha,beta,gamma: unit cell angles
SpcGroupspace group number (1..230)
namename for the crystal, : '(TaSe4)2I'

Reimplemented from ObjCryst::UnitCell.

Definition at line 1277 of file Crystal.cpp.

void ObjCryst::Crystal::InitOptions ( )
privatevirtual

Init options.

Need only be done once per Crystal.

Reimplemented from ObjCryst::UnitCell.

Definition at line 1576 of file Crystal.cpp.

ostream & ObjCryst::Crystal::POVRayDescription ( ostream &  os,
const CrystalPOVRayOptions options 
) const

XMLOutput POV-Ray Description for this Crystal.

Parameters
onlyIndependentAtomsif false, all symmetrics are showed in the drawing.
Warning
This currently needs some fixing (ZScatterer does not work ?) Use rather the OpenGL 3D display which is more useful.
Parameters
osthe stream to which the information is outputed (default=cout)

Definition at line 461 of file Crystal.cpp.

void ObjCryst::Crystal::Print ( ostream &  os = cout) const
virtual

Prints some info about the crystal.

Todo:
one function to print on one line and a PrintLong() function
Parameters
osthe stream to which the information is outputed (default=cout)

Reimplemented from ObjCryst::UnitCell.

Definition at line 324 of file Crystal.cpp.

void ObjCryst::Crystal::PrintMinDistanceTable ( const REAL  minDistance = 0.1,
ostream &  os = cout 
) const

Print the minimum distance table between all scattering centers (atoms) in the crystal.

Parameters
osthe stream to which the information is outputed (default=cout)

Definition at line 428 of file Crystal.cpp.

void ObjCryst::Crystal::RemoveScatteringPower ( ScatteringPower scattPow,
const bool  del = true 
)

Remove a ScatteringPower for this Crystal.

(the Scattering power is deleted unless del=false). This function should check that it is not used any more before removing it.

Definition at line 237 of file Crystal.cpp.

void ObjCryst::Crystal::SetBumpMergeDistance ( const ScatteringPower scatt1,
const ScatteringPower scatt2,
const REAL  dist = 1.5 
)

Set the Anti-bumping distance between two scattering types.

Definition at line 860 of file Crystal.cpp.

void ObjCryst::Crystal::SetDeleteSubObjInDestructor ( const bool  b)

Set whether to delete the Scatterers and ScatteringPowers in the destructor.

By default these sub-objects are deleted.

Definition at line 1848 of file Crystal.cpp.

void ObjCryst::Crystal::SetUseDynPopCorr ( const int  use)

Set the use of dynamical population correction (Crystal::mUseDynPopCorr).

Atoms which are considered "equivalent" (ie currently with the same Z number) and which are overlapping see their Dynamical occupancy changed so that when they fully overlap, they are equivalent to 1 atom.

The Dynamical Occupancy correction will be performed in Crystal::GetScatteringComponentList() automatically.

This seriously affects the speed of the calculation, since computing interatomic distances is lenghty.

Parameters
useset to 1 to use, 0 not to use it.

Definition at line 791 of file Crystal.cpp.

void ObjCryst::Crystal::XMLInput ( istream &  is,
const XMLCrystTag tag 
)
virtual

Input From stream.

Todo:
Add an bool XMLInputTag(is,tag) function to recognize all the tags from the stream. So that each inherited class can use the XMLInputTag function from its parent (ie take advantage of inheritance). The children class would first try to interpret the tag, then if unsuccessful would pass it to its parent (thus allowing overloading), etc...

Reimplemented from ObjCryst::RefinableObj.

Definition at line 885 of file ObjCryst/IO.cpp.

void ObjCryst::Crystal::XMLOutput ( ostream &  os,
int  indent = 0 
) const
virtual

Output to stream in well-formed XML.

Todo:
Use inheritance.. as for XMLInputTag()...

Reimplemented from ObjCryst::RefinableObj.

Definition at line 791 of file ObjCryst/IO.cpp.

Member Data Documentation

RefinableObjClock ObjCryst::Crystal::mClockDynPopCorr
mutableprivate

Last time the dynamical population correction was computed

Definition at line 486 of file Crystal.h.

RefinableObjClock ObjCryst::Crystal::mClockNeighborTable
mutableprivate

Last time the Neighbor Table was generated

Definition at line 484 of file Crystal.h.

RefinableObjClock ObjCryst::Crystal::mClockScattCompList
mutableprivate

Last time the ScatteringComponentList was generated

Definition at line 482 of file Crystal.h.

RefObjOpt ObjCryst::Crystal::mDisplayEnantiomer
private

Display the enantiomeric (mirror along x) structure in 3D? This can be helpful for non-centrosymmetric structure which have been solved using powder diffraction (which only gives the relative configuration).

Definition at line 493 of file Crystal.h.

std::map<long, REAL> ObjCryst::Crystal::mvBondValenceCalc
mutableprivate

List of calculated bond valences, as a map, the key being the index of the atom in Crystal::mScattCompList.

Definition at line 511 of file Crystal.h.

std::vector<NeighbourHood> ObjCryst::Crystal::mvDistTableSq
mutableprivate

Interatomic distance table for all unique atoms.

Definition at line 460 of file Crystal.h.


The documentation for this class was generated from the following files: