FOX/ObjCryst++  2022
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;
169  void ChangeSpaceGroup(const string &spgId);
170 
171  // :TODO: ?
172  //virtual void XMLOutput(ostream &os,int indent=0)const;
173  //virtual void XMLInput(istream &is,const XMLCrystTag &tag);
174 
176  REAL GetVolume()const;
177  protected:
184  virtual void Init(const REAL a, const REAL b, const REAL c, const REAL alpha,
185  const REAL beta, const REAL gamma,const string &SpaceGroupId,
186  const string& name);
191  void InitRefParList();
192  private:
197  virtual void InitOptions();
200  void InitMatrices() const;
206  void UpdateLatticePar();
207 
212  CrystVector_REAL mCellDim;
215 
225  mutable CrystMatrix_REAL mBMatrix;
227  mutable CrystMatrix_REAL mBMatrixInvert;
238  mutable CrystMatrix_REAL mOrthMatrix;
240  mutable CrystMatrix_REAL mOrthMatrixInvert;
241 
248 
264 
265 };
266 
267 
268 }// namespace
269 
270 
271 #endif //_OBJCRYST_UNITCELL_H_
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
Definition: doc-main.h:25
const RefParType * gpRefParTypeObjCryst
Top RefParType for the ObjCryst++ library.
The crystallographic space group, and the cell choice.
Definition: SpaceGroup.h:105
Unit Cell class: Unit cell with spacegroup information.
Definition: UnitCell.h:72
CrystMatrix_REAL mBMatrix
B Matrix (Orthogonalization matrix for reciprocal space)
Definition: UnitCell.h:225
CrystVector_REAL mCellDim
a,b and c in Angstroems, angles (stored) in radians For cubic, rhomboedric UnitCells,...
Definition: UnitCell.h:212
CrystMatrix_REAL mOrthMatrixInvert
inverse of Eucl Matrix (i.e. inverse of de-orthogonalization matrix for direct space)
Definition: UnitCell.h:240
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:251
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
virtual void Print(ostream &os) const
Prints some info about the UnitCell.
Definition: UnitCell.cpp:306
void ChangeSpaceGroup(const string &spgId)
Change the spacegroup.
Definition: UnitCell.cpp:325
void MillerToOrthonormalCoords(REAL &x, REAL &y, REAL &z) const
Get Miller H,K, L indices from orthonormal coordinates in reciprocal space.
Definition: UnitCell.cpp:286
CrystMatrix_REAL mOrthMatrix
Eucl Matrix (Orthogonalization matrix for direct space)
Definition: UnitCell.h:238
const RefinableObjClock & GetClockMetricMatrix() const
last time the metric matrices were changed
Definition: UnitCell.cpp:334
REAL GetVolume() const
Volume of Unit Cell (in Angstroems)
Definition: UnitCell.cpp:336
void InitRefParList()
Prepare the refinable parameters list.
Definition: UnitCell.cpp:536
UnitCell()
Default Constructor.
Definition: UnitCell.cpp:33
RefinableObjClock mClockMetricMatrix
Definition: UnitCell.h:245
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:349
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:273
SpaceGroup mSpaceGroup
The space group of the UnitCell.
Definition: UnitCell.h:214
RefinableObjClock mClockLatticePar
Last time lattice parameters were changed.
Definition: UnitCell.h:243
void UpdateLatticePar()
Definition: UnitCell.cpp:458
virtual const string & GetClassName() const
Name for this class ("RefinableObj", "Crystal",...).
Definition: UnitCell.cpp:86
RefinableObjClock mClockLatticeParUpdate
Definition: UnitCell.h:247
void InitMatrices() const
Definition: UnitCell.cpp:402
const SpaceGroup & GetSpaceGroup() const
Access to the SpaceGroup object.
Definition: UnitCell.cpp:322
~UnitCell()
Destructor.
Definition: UnitCell.cpp:80
const CrystMatrix_REAL & GetOrthMatrix() const
Get the orthogonalization matrix (UnitCell::mOrthMatrix)for the UnitCell in real space.
Definition: UnitCell.cpp:244
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:296
RefObjOpt mConstrainLatticeToSpaceGroup
Option to override lattice parameters constraints from spacegroup choice.
Definition: UnitCell.h:263
CrystMatrix_REAL mBMatrixInvert
inverse of B Matrix (i.e. inverse of orthogonalization matrix for direct space)
Definition: UnitCell.h:227
const CrystMatrix_REAL & GetBMatrix() const
Get the 'B' matrix (UnitCell::mBMatrix)for the UnitCell (orthogonalization matrix for the given latti...
Definition: UnitCell.cpp:237
const RefinableObjClock & GetClockLatticePar() const
last time the Lattice parameters were changed
Definition: UnitCell.cpp:333
virtual void InitOptions()
Init options.
Definition: UnitCell.cpp:379
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:263
class of refinable parameter types.
Definition: RefinableObj.h:80
We need to record exactly when refinable objects have been modified for the last time (to avoid re-co...
Definition: RefinableObj.h:140
Base class for options.
Definition: RefinableObj.h:552
Generic Refinable Object.
Definition: RefinableObj.h:784