FOX/ObjCryst++  1.10.X (development)
UnitCell.h
1 /* ObjCryst++ Object-Oriented Crystallographic Library
2  (c) 2000-2002 Vincent Favre-Nicolin vincefn@users.sourceforge.net
3  2000-2001 University of Geneva (Switzerland)
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 /* UnitCell.h header file for the UnitCell object
20 *
21 */
22 #ifndef _OBJCRYST_UNITCELL_H_
23 #define _OBJCRYST_UNITCELL_H_
24 
25 #include "ObjCryst/CrystVector/CrystVector.h"
26 
27 #include "ObjCryst/ObjCryst/General.h"
28 #include "ObjCryst/RefinableObj/RefinableObj.h"
29 #include "ObjCryst/ObjCryst/SpaceGroup.h"
30 
31 
32 namespace ObjCryst
33 {
34 extern const RefParType *gpRefParTypeUnitCell;
35 extern const RefParType *gpRefParTypeUnitCellLength;
36 extern const RefParType *gpRefParTypeUnitCellAngle;
38 {
39  public:
41  {
42  if (mCount++ == 0)
43  {
44  gpRefParTypeUnitCell=new RefParType (gpRefParTypeObjCryst,"Unit Cell");
45  gpRefParTypeUnitCellLength=new RefParType (gpRefParTypeUnitCell,"Unit Cell Length");
46  gpRefParTypeUnitCellAngle=new RefParType (gpRefParTypeUnitCell,"Unit Cell Angle");
47  }
48  }
50  {
51  if (--mCount == 0)
52  {
53  delete gpRefParTypeUnitCell;
54  delete gpRefParTypeUnitCellLength;
55  delete gpRefParTypeUnitCellAngle;
56  gpRefParTypeUnitCell=0;
57  gpRefParTypeUnitCellLength=0;
58  gpRefParTypeUnitCellAngle=0;
59  }
60  }
61  private:
62  static long mCount;
63 };
64 static NiftyStaticGlobalObjectsInitializer_UnitCell NiftyStaticGlobalObjectsInitializer_UnitCell_counter;
65 
66 //######################################################################
70 //######################################################################
71 class UnitCell:public RefinableObj
72 {
73  public:
75  UnitCell();
80  UnitCell(const REAL a, const REAL b, const REAL c,
81  const string &SpaceGroupId);
87  UnitCell(const REAL a, const REAL b, const REAL c, const REAL alpha,
88  const REAL beta, const REAL gamma,const string &SpaceGroupId);
89 
91  UnitCell(const UnitCell &oldCryst);
93  ~UnitCell();
94  virtual const string& GetClassName() const;
97  CrystVector_REAL GetLatticePar() const;
100  REAL GetLatticePar(const int whichPar)const;
109  const CrystMatrix_REAL& GetBMatrix() const;
114  const CrystMatrix_REAL& GetOrthMatrix() const;
124  CrystVector_REAL GetOrthonormalCoords(const REAL x,const REAL y,const REAL z) const;
132  void FractionalToOrthonormalCoords(REAL &x,REAL &y,REAL &z) const;
140  void OrthonormalToFractionalCoords(REAL &x,REAL &y,REAL &z) const;
146  void MillerToOrthonormalCoords(REAL &x,REAL &y,REAL &z) const;
152  void OrthonormalToMillerCoords(REAL &x,REAL &y,REAL &z) const;
157  virtual void Print(ostream &os) const;
158  // Avoid compiler warnings about hidden base class method.
159  virtual void Print() const { this->Print(cout); }
161  const SpaceGroup & GetSpaceGroup()const;
164 
165  // :TODO: ?
166  //virtual void XMLOutput(ostream &os,int indent=0)const;
167  //virtual void XMLInput(istream &is,const XMLCrystTag &tag);
168 
170  REAL GetVolume()const;
171  protected:
178  virtual void Init(const REAL a, const REAL b, const REAL c, const REAL alpha,
179  const REAL beta, const REAL gamma,const string &SpaceGroupId,
180  const string& name);
185  void InitRefParList();
186  private:
191  virtual void InitOptions();
194  void InitMatrices() const;
200  void UpdateLatticePar();
201 
206  CrystVector_REAL mCellDim;
209 
219  mutable CrystMatrix_REAL mBMatrix;
221  mutable CrystMatrix_REAL mBMatrixInvert;
232  mutable CrystMatrix_REAL mOrthMatrix;
234  mutable CrystMatrix_REAL mOrthMatrixInvert;
235 
242 
258 
259 };
260 
261 
262 }// namespace
263 
264 
265 #endif //_OBJCRYST_UNITCELL_H_
CrystVector_REAL GetLatticePar() const
Lattice parameters (a,b,c,alpha,beta,gamma) as a 6-element vector in Angstroems and radians...
Definition: UnitCell.cpp:92
void UpdateLatticePar()
Definition: UnitCell.cpp:443
virtual 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 UnitCell parameters.
Definition: UnitCell.cpp:339
CrystMatrix_REAL mBMatrixInvert
inverse of B Matrix (i.e. inverse of orthogonalization matrix for direct space)
Definition: UnitCell.h:221
const CrystMatrix_REAL & GetBMatrix() const
Get the 'B' matrix (UnitCell::mBMatrix)for the UnitCell (orthogonalization matrix for the given latti...
Definition: UnitCell.cpp:235
const RefinableObjClock & GetClockLatticePar() const
last time the Lattice parameters were changed
Definition: UnitCell.cpp:323
void OrthonormalToFractionalCoords(REAL &x, REAL &y, REAL &z) const
Get fractional cartesian coordinates for a set of (x,y,z) orthonormal coordinates.
Definition: UnitCell.cpp:271
UnitCell()
Default Constructor.
Definition: UnitCell.cpp:33
We need to record exactly when refinable objects have been modified for the last time (to avoid re-co...
Definition: RefinableObj.h:138
void FractionalToOrthonormalCoords(REAL &x, REAL &y, REAL &z) const
Get orthonormal cartesian coordinates for a set of (x,y,z) fractional coordinates.
Definition: UnitCell.cpp:261
RefinableObjClock mClockLatticePar
Last time lattice parameters were changed.
Definition: UnitCell.h:237
RefObjOpt mConstrainLatticeToSpaceGroup
Option to override lattice parameters constraints from spacegroup choice.
Definition: UnitCell.h:257
void MillerToOrthonormalCoords(REAL &x, REAL &y, REAL &z) const
Get Miller H,K, L indices from orthonormal coordinates in reciprocal space.
Definition: UnitCell.cpp:284
virtual const string & GetClassName() const
Name for this class ("RefinableObj", "Crystal",...).
Definition: UnitCell.cpp:86
Generic Refinable Object.
Definition: RefinableObj.h:752
SpaceGroup mSpaceGroup
The space group of the UnitCell.
Definition: UnitCell.h:208
const SpaceGroup & GetSpaceGroup() const
Access to the SpaceGroup object.
Definition: UnitCell.cpp:320
const RefinableObjClock & GetClockMetricMatrix() const
last time the metric matrices were changed
Definition: UnitCell.cpp:324
void OrthonormalToMillerCoords(REAL &x, REAL &y, REAL &z) const
Get orthonormal coordinates given a set of H,K, L indices in reciprocal space.
Definition: UnitCell.cpp:294
void InitMatrices() const
Definition: UnitCell.cpp:388
Base class for options.
Definition: RefinableObj.h:550
The crystallographic space group, and the cell choice.
Definition: SpaceGroup.h:104
RefinableObjClock mClockMetricMatrix
Definition: UnitCell.h:239
REAL GetVolume() const
Volume of Unit Cell (in Angstroems)
Definition: UnitCell.cpp:326
CrystVector_REAL mCellDim
a,b and c in Angstroems, angles (stored) in radians For cubic, rhomboedric UnitCells, only the 'a' parameter is relevant.
Definition: UnitCell.h:206
RefinableObjClock mClockLatticeParUpdate
Definition: UnitCell.h:241
CrystMatrix_REAL mOrthMatrixInvert
inverse of Eucl Matrix (i.e. inverse of de-orthogonalization matrix for direct space) ...
Definition: UnitCell.h:234
virtual void Print(ostream &os) const
Prints some info about the UnitCell.
Definition: UnitCell.cpp:304
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
Definition: Atom.cpp:47
Unit Cell class: Unit cell with spacegroup information.
Definition: UnitCell.h:71
const CrystMatrix_REAL & GetOrthMatrix() const
Get the orthogonalization matrix (UnitCell::mOrthMatrix)for the UnitCell in real space.
Definition: UnitCell.cpp:242
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.
Definition: UnitCell.cpp:249
CrystMatrix_REAL mOrthMatrix
Eucl Matrix (Orthogonalization matrix for direct space) .
Definition: UnitCell.h:232
~UnitCell()
Destructor.
Definition: UnitCell.cpp:80
CrystMatrix_REAL mBMatrix
B Matrix (Orthogonalization matrix for reciprocal space) .
Definition: UnitCell.h:219
class of refinable parameter types.
Definition: RefinableObj.h:78
virtual void InitOptions()
Init options.
Definition: UnitCell.cpp:365
const RefParType * gpRefParTypeObjCryst
Top RefParType for the ObjCryst++ library.
void InitRefParList()
Prepare the refinable parameters list.
Definition: UnitCell.cpp:521