FOX/ObjCryst++  1.10.X (development)
CIF.h
1 #ifndef _OBJCRYST_CIF_H
2 #define _OBJCRYST_CIF_H
3 
4 #include <iostream>
5 #include <fstream>
6 #include <sstream>
7 #include <vector>
8 #include <list>
9 #include <map>
10 #include <set>
11 
12 #include "ObjCryst/Quirks/ci_string.h"
13 namespace ObjCryst
14 {// Forward declaration
15  class CIF;
16 }
17 #include "ObjCryst/ObjCryst/PowderPattern.h" // For CreatePowderPatternFromCIF only.
18 #include "ObjCryst/ObjCryst/DiffractionDataSingleCrystal.h" // For CreateSingleCrystalDataFromCIF only.
19 #include "ObjCryst/ObjCryst/Crystal.h" // For CreateCrystalFromCIF only.
20 #include "ObjCryst/ObjCryst/General.h" // TO identify wavelength type in CIFData::ExtractPowderPattern.
21 
22 namespace ObjCryst
23 {
26 REAL CIFNumeric2REAL(const std::string &s);
29 int CIFNumeric2Int(const std::string &s);
30 
62 class CIFData
63 {
64  public:
65  CIFData();
66 
70  void ExtractAll(const bool verbose=false);
72  void ExtractName(const bool verbose=false);
74  void ExtractUnitCell(const bool verbose=false);
76  void ExtractSpacegroup(const bool verbose=false);
79  void ExtractAtomicPositions(const bool verbose=false);
81  // may be extracted in ExtractAtomicPositions. This takes prescedent.
82  void ExtractAnisotropicADPs(const bool verbose=false);
85  void ExtractPowderPattern(const bool verbose=false);
87  void ExtractSingleCrystalData(const bool verbose=false);
96  void f2c(REAL &x,REAL &y, REAL &z);
99  void c2f(REAL &x,REAL &y, REAL &z);
102  void CalcMatrices(const bool verbose=false);
104  std::list<std::string> mvComment;
106  std::map<ci_string,std::string> mvItem;
108  std::map<std::set<ci_string>,std::map<ci_string,std::vector<std::string> > > mvLoop;
111  std::vector<REAL> mvLatticePar;
113  std::string mSpacegroupNumberIT;
119  std::set<string> mvSymmetry_equiv_pos_as_xyz;
121  std::string mName;
123  std::string mFormula;
125  struct CIFAtom
126  {
127  CIFAtom();
129  std::string mLabel;
131  std::string mSymbol;
133  std::vector<REAL> mCoordFrac;
137  std::vector<REAL> mCoordCart;
140 
142  std::vector<REAL> mBeta;
143 
145  REAL mBiso;
146  };
148  std::vector<CIFAtom> mvAtom;
150  REAL mOrthMatrix[3][3];
152  REAL mOrthMatrixInvert[3][3];
154  std::vector<REAL> mPowderPatternObs,mPowderPatternX,mPowderPatternSigma;
156  CrystVector_long mH,mK,mL;
158  CrystVector_REAL mIobs,mSigma;
163 };
164 
169 class CIF
170 {
171  public:
175  CIF(std::istream &in, const bool interpret=true,const bool verbose=false);
176  //private:
179  void Parse(std::stringstream &in);
181  std::map<std::string,CIFData> mvData;
183  std::list<std::string> mvComment;
184 };
185 
186 // Forward declarations
187 class Crystal;
188 class PowderPattern;
189 
198 Crystal* CreateCrystalFromCIF(CIF &cif,const bool verbose=true,const bool checkSymAsXYZ=true);
199 
214 Crystal* CreateCrystalFromCIF(CIF &cif,const bool verbose,const bool checkSymAsXYZ, const bool oneScatteringPowerPerElement, const bool connectAtoms);
215 
220 
226 
227 }
228 
229 #endif
std::map< std::set< ci_string >, std::map< ci_string, std::vector< std::string > > > mvLoop
CIF Loop data.
Definition: CIF.h:108
void ExtractAtomicPositions(const bool verbose=false)
Extract all atomic positions.
Definition: CIF.cpp:233
The CIFData class holds all the information from a single data_ block from a cif file.
Definition: CIF.h:62
REAL mBiso
Biso.
Definition: CIF.h:145
Crystal * CreateCrystalFromCIF(CIF &cif, bool verbose, bool checkSymAsXYZ)
Extract Crystal object(s) from a CIF, if possible.
Definition: CIF.cpp:991
std::vector< REAL > mBeta
ADP tensor.
Definition: CIF.h:142
void ExtractAll(const bool verbose=false)
Extract lattice parameters, spacegroup (symbol or number), atomic positions, chemical name and formul...
Definition: CIF.cpp:26
void Cartesian2FractionalCoord()
Generate fractional coordinates from cartesian ones for all atoms CIFData::CalcMatrices() must be cal...
Definition: CIF.cpp:727
std::string mFormula
Formula. Or empty string if none is available.
Definition: CIF.h:123
REAL mOrthMatrixInvert[3][3]
Cartesian2Fractionnal matrix.
Definition: CIF.h:152
CrystVector_REAL mIobs
Single crystal data.
Definition: CIF.h:158
std::map< ci_string, std::string > mvItem
Individual CIF items.
Definition: CIF.h:106
CIF(std::istream &in, const bool interpret=true, const bool verbose=false)
Creates the CIF object from a stream.
Definition: CIF.cpp:754
std::string mSymbol
Symbol of the atom, or empty string (_atom_type_symbol or _atom_site_type_symbol).
Definition: CIF.h:131
PowderPattern * CreatePowderPatternFromCIF(CIF &cif)
Create PowderPattern object(s) from a CIF, if possible.
Definition: CIF.cpp:1252
std::vector< REAL > mCoordFrac
Fractionnal coordinates (atom_site_fract{x,y,z}) or empty vector.
Definition: CIF.h:133
void ExtractSpacegroup(const bool verbose=false)
Extract spacegroup number or symbol.
Definition: CIF.cpp:74
std::string mSpacegroupSymbolHall
Spacegroup Hall symbol (or empty string) (_space_group_name_Hall)
Definition: CIF.h:115
REAL mOccupancy
Site occupancy, or -1.
Definition: CIF.h:139
Atom record.
Definition: CIF.h:125
WavelengthType mDataType
Is this X-Ray 2theta, time-of-flight ?
Definition: CIF.h:160
std::vector< CIFAtom > mvAtom
Atoms, if any are found.
Definition: CIF.h:148
void ExtractSingleCrystalData(const bool verbose=false)
Extract single crystal data, with Iobs, sigma(Iobs) and h,k,l.
Definition: CIF.cpp:570
std::vector< REAL > mPowderPatternObs
Powder pattern data.
Definition: CIF.h:154
void CalcMatrices(const bool verbose=false)
Calculate real space transformation matrices requires unit cell parameters.
Definition: CIF.cpp:627
std::string mSpacegroupHermannMauguin
Spacegroup Hermann-Mauguin symbol (or empty string) (_space_group_name_H-M_alt)
Definition: CIF.h:117
void f2c(REAL &x, REAL &y, REAL &z)
Convert from fractional to cartesian coordinates CIFData::CalcMatrices() must be called first...
Definition: CIF.cpp:711
DiffractionData object for Single Crystal analysis.
std::list< std::string > mvComment
Global comments, outside and data block.
Definition: CIF.h:183
WavelengthType
Incident beam characteristics : monochromatic, X-Ray tube with Alpha1 and alpha2, MAD (a few waveleng...
Definition: General.h:100
Powder pattern class, with an observed pattern and several calculated components to modelize the patt...
void ExtractPowderPattern(const bool verbose=false)
Extract Powder Diffraction data, with Iobs, sigma(Iobs) and either 2theta or time-of-flight position...
Definition: CIF.cpp:468
REAL mOrthMatrix[3][3]
Fractionnal2Cartesian matrix.
Definition: CIF.h:150
void Parse(std::stringstream &in)
Separate the file in data blocks and parse them to sort tags, loops and comments. ...
Definition: CIF.cpp:840
Main CIF class - parses the stream and separates data blocks, comments, items, loops.
Definition: CIF.h:169
void Fractional2CartesianCoord()
Generate cartesian coordinates from fractional ones for all atoms CIFData::CalcMatrices() must be cal...
Definition: CIF.cpp:739
std::string mName
Crystal name. Or empty string if none is available.
Definition: CIF.h:121
void ExtractName(const bool verbose=false)
Extract name & formula for the crystal.
Definition: CIF.cpp:143
DiffractionDataSingleCrystal * CreateSingleCrystalDataFromCIF(CIF &cif, Crystal *pcryst)
Create DiffractionDataSingleCrystal object(s) from a CIF, if possible.
Definition: CIF.cpp:1266
std::map< std::string, CIFData > mvData
The data blocks, after parsing. The key is the name of the data block.
Definition: CIF.h:181
void ExtractAnisotropicADPs(const bool verbose=false)
Extract anisotropic atomic displacement parameters. Isotropic ADPs.
Definition: CIF.cpp:346
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
Definition: Atom.cpp:47
std::vector< REAL > mvLatticePar
Lattice parameters, in ansgtroem and degrees - vector size is 0 if no parameters have been obtained y...
Definition: CIF.h:111
std::string mLabel
Label of the atom, or empty string (_atom_site_label).
Definition: CIF.h:129
REAL mWavelength
Wavelength.
Definition: CIF.h:162
Crystal class: Unit cell, spacegroup, scatterers.
Definition: Crystal.h:97
void ExtractUnitCell(const bool verbose=false)
Extract unit cell.
Definition: CIF.cpp:41
void c2f(REAL &x, REAL &y, REAL &z)
Convert from cartesia to fractional coordinates CIFData::CalcMatrices() must be called first...
Definition: CIF.cpp:719
std::set< string > mvSymmetry_equiv_pos_as_xyz
Map of _symmetry_equiv_pos_as_xyz strings.
Definition: CIF.h:119
CrystVector_long mH
Single crystal data.
Definition: CIF.h:156
std::vector< REAL > mCoordCart
Cartesian coordinates in Angstroem (atom_site_Cartn{x,y,z}) or empty vector.
Definition: CIF.h:137
std::string mSpacegroupNumberIT
Spacegroup number from International Tables (_space_group_IT_number), or -1.
Definition: CIF.h:113
std::list< std::string > mvComment
Comments from CIF file, in the order they were read.
Definition: CIF.h:104