Clipper
spacegroup.h
1 
4 //C Copyright (C) 2000-2006 Kevin Cowtan and University of York
5 //L
6 //L This library is free software and is distributed under the terms
7 //L and conditions of version 2.1 of the GNU Lesser General Public
8 //L Licence (LGPL) with the following additional clause:
9 //L
10 //L `You may also combine or link a "work that uses the Library" to
11 //L produce a work containing portions of the Library, and distribute
12 //L that work under terms of your choice, provided that you give
13 //L prominent notice with each copy of the work that the specified
14 //L version of the Library is used in it, and that you include or
15 //L provide public access to the complete corresponding
16 //L machine-readable source code for the Library including whatever
17 //L changes were used in the work. (i.e. If you make changes to the
18 //L Library you must distribute those, but you do not need to
19 //L distribute source or object code to those portions of the work
20 //L not covered by this licence.)'
21 //L
22 //L Note that this clause grants an additional right and does not impose
23 //L any additional restriction, and so does not affect compatibility
24 //L with the GNU General Public Licence (GPL). If you wish to negotiate
25 //L other terms, please contact the maintainer.
26 //L
27 //L You can redistribute it and/or modify the library under the terms of
28 //L the GNU Lesser General Public License as published by the Free Software
29 //L Foundation; either version 2.1 of the License, or (at your option) any
30 //L later version.
31 //L
32 //L This library is distributed in the hope that it will be useful, but
33 //L WITHOUT ANY WARRANTY; without even the implied warranty of
34 //L MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
35 //L Lesser General Public License for more details.
36 //L
37 //L You should have received a copy of the CCP4 licence and/or GNU
38 //L Lesser General Public License along with this library; if not, write
39 //L to the CCP4 Secretary, Daresbury Laboratory, Warrington WA4 4AD, UK.
40 //L The GNU Lesser General Public can also be obtained by writing to the
41 //L Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
42 //L MA 02111-1307 USA
43 /* some code & data converted from CCP4 library symlib.f (various authors) */
44 
45 
46 #ifndef CLIPPER_SPACEGROUP
47 #define CLIPPER_SPACEGROUP
48 
49 
50 #include "symop.h"
51 #include "spacegroup_data.h"
52 
53 
54 namespace clipper {
55 
56  // forward definitions
57  class HKL;
58  class HKL_class;
59  class Coord_frac;
60 
61 
63 
73  class Spgr_descr
74  {
75  public:
76  enum TYPE { Hall, HM, XHM, Symops, Number, Unknown };
78  Spgr_descr();
80  explicit Spgr_descr( const String& symb, TYPE type = Unknown );
82  explicit Spgr_descr( const int& num );
84  int spacegroup_number() const;
86  String symbol_hall() const;
88  String symbol_hm() const;
90  String symbol_xhm() const;
92  String symbol_hm_ext() const;
94  static void set_preferred( const char& c );
95 
97  class Symop_codes : public std::vector<Symop_code>
98  {
99  public:
101  void init_hall( const String& symb );
103  void init_symops( const String& symb );
105  Symop_codes expand() const;
109  Symop_codes inversion_ops() const;
111  Symop_codes primitive_ops() const;
113  Symop_codes centering_ops() const;
115  Symop_codes laue_ops() const;
117  Symop_codes pgrp_ops() const;
119  Symop_codes patterson_ops() const;
121  Symop_codes generator_ops() const;
123  Symop_codes product( const Symop_codes& ops2 ) const;
125  unsigned int hash() const;
126  };
127 
129  explicit Spgr_descr( const Symop_codes& ops );
131  const Symop_codes& generator_ops() const { return generators_; }
133  const unsigned int& hash() const { return hash_; }
134 
135  protected:
136  unsigned int hash_;
138 
139  static char pref_12, pref_hr;
140  };
141 
142 
143  // ObjectCache data type
145  {
146  public:
147  typedef Spgr_descr Key;
148  Spgr_cacheobj( const Key& spgr_cachekey );
149  bool matches( const Key& spgr_cachekey ) const;
150  String format() const;
151  // data
153  int nsym, nsymn, nsymi, nsymc, nsymp;
154  int lgrp;
155  std::vector<Symop> symops;
156  std::vector<Isymop> isymops;
157  Vec3<> asu_min_, asu_max_;
158  static Mutex mutex;
159  };
160 
161 
163 
172  class Spacegroup : public Spgr_descr
173  {
174  public:
176  enum TYPE { Null, P1 };
178  enum AXIS { A=0, B=1, C=2 };
182  explicit Spacegroup( TYPE type );
184  explicit Spacegroup( const Spgr_descr& spgr_descr );
186  void init( const Spgr_descr& spgr_descr );
187 
189  bool is_null() const;
190 
191  // methods
193  inline const Spgr_descr& descr() const { return (*this); }
195  inline const int& num_symops() const { return nsym; }
197  inline const int& num_primops() const { return num_primitive_symops(); }
199  inline const int& num_primitive_symops() const { return nsymp; }
201  inline const int& num_centering_symops() const { return nsymc; }
203  inline const int& num_inversion_symops() const { return nsymi; }
205  inline const int& num_primitive_noninversion_symops() const { return nsymn;}
207  inline const Symop& symop( const int& sym_no ) const
208  { return symops[sym_no]; }
210  inline const Symop& primitive_symop( const int& sym_no ) const
211  { return symops[sym_no]; }
213  inline const Symop& inversion_symop( const int& sym_no ) const
214  { return symops[nsymn*sym_no]; }
216  inline const Symop& centering_symop( const int& sym_no ) const
217  { return symops[nsymp*sym_no]; }
219  int order_of_symmetry_about_axis( const AXIS axis ) const;
220 
222  HKL_class hkl_class( const HKL& hkl ) const;
224  bool recip_asu( const HKL& hkl ) const;
225 
227  int product_op( const int& s1, int& s2 ) const;
229  int inverse_op( const int& s ) const;
230 
232  Coord_frac asu_max() const;
234  Coord_frac asu_min() const;
235 
237  bool invariant_under_change_of_hand() const;
238 
239  // inherited functions listed for documentation purposes
240  //-- int spacegroup_number() const;
241  //-- String symbol_hall() const;
242  //-- String symbol_hm() const;
244  String symbol_laue() const;
245 
247  static Spacegroup p1() { return Spacegroup( P1 ); }
249  static Spacegroup null() { return Spacegroup( Null ); }
250 
251  void debug() const;
252 
253  private:
255  const Symop* symops;
256  const Isymop* isymops;
257  data::ASUfn asufn;
258  int nsym, nsymn, nsymi, nsymc, nsymp;
259  };
260 
261 
262 } // namespace clipper
263 
264 #endif
clipper::Spgr_descr::Symop_codes::generator_ops
Symop_codes generator_ops() const
return minimal list of generator ops
Definition: spacegroup.cpp:374
clipper
clipper::Spgr_descr::spacegroup_number
int spacegroup_number() const
return the spacegroup number
Definition: spacegroup.cpp:591
clipper::Spgr_cacheobj::symops
std::vector< Symop > symops
symmetry operators
Definition: spacegroup.h:155
clipper::Spgr_descr::Symop_codes
Vector of symop codes and associated methods.
Definition: spacegroup.h:97
clipper::Spgr_descr::Symop_codes::inversion_ops
Symop_codes inversion_ops() const
return inversion ops (by computation)
Definition: spacegroup.cpp:306
clipper::Spacegroup::num_symops
const int & num_symops() const
get number of symops
Definition: spacegroup.h:195
clipper::Spacegroup::is_null
bool is_null() const
test if object has been initialised
Definition: spacegroup.cpp:874
clipper::Spacegroup::num_centering_symops
const int & num_centering_symops() const
get number of centering symops (inc identity)
Definition: spacegroup.h:201
clipper::Spgr_cacheobj::nsymp
int nsymp
number of syms: total, primitive
Definition: spacegroup.h:153
clipper::Spgr_cacheobj::isymops
std::vector< Isymop > isymops
symmetry operators
Definition: spacegroup.h:156
clipper::Spacegroup::recip_asu
bool recip_asu(const HKL &hkl) const
test if hkl is in default reciprocal ASU
Definition: spacegroup.cpp:908
clipper::Isymop
Integerised symmetry matrix.
Definition: symop.h:108
clipper::Coord_frac
fractional (cell) coordinates
Definition: coords.h:342
clipper::Spgr_descr::Symop_codes::init_hall
void init_hall(const String &symb)
initialise from Hall symbol
Definition: spacegroup.cpp:93
clipper::Spacegroup::init
void init(const Spgr_descr &spgr_descr)
initialiser: from spacegroup description
Definition: spacegroup.cpp:856
clipper::Spacegroup
Spacegroup object.
Definition: spacegroup.h:172
clipper::Spacegroup::hkl_class
HKL_class hkl_class(const HKL &hkl) const
get 'class' of reflection: multiplicity, allowed phase, absence
Definition: spacegroup.cpp:902
clipper::HKL_class
reflection class
Definition: coords.h:86
clipper::Spacegroup::num_primitive_noninversion_symops
const int & num_primitive_noninversion_symops() const
get number of primitive non-inversion symops (inc identity)
Definition: spacegroup.h:205
clipper::Spgr_descr::Symop_codes::laue_ops
Symop_codes laue_ops() const
return Laue ops
Definition: spacegroup.cpp:342
clipper::Spacegroup::centering_symop
const Symop & centering_symop(const int &sym_no) const
get n'th centering symop (0...3 max)
Definition: spacegroup.h:216
clipper::Spgr_descr::Symop_codes::pgrp_ops
Symop_codes pgrp_ops() const
return point group ops
Definition: spacegroup.cpp:352
clipper::Spgr_descr::pref_hr
static char pref_hr
preferred origin and hex/romb symbols
Definition: spacegroup.h:139
clipper::Spgr_descr::symbol_hall
String symbol_hall() const
return the Hall symbol
Definition: spacegroup.cpp:601
clipper::Spgr_descr::Symop_codes::product
Symop_codes product(const Symop_codes &ops2) const
return product of this (expanded) list by another (expanded) list
Definition: spacegroup.cpp:417
clipper::Spgr_cacheobj::Spgr_cacheobj
Spgr_cacheobj(const Key &spgr_cachekey)
construct entry
Definition: spacegroup.cpp:778
clipper::HKL
reflection 'Miller' index
Definition: coords.h:145
clipper::Spgr_descr::set_preferred
static void set_preferred(const char &c)
set preferred default spacegroup choice
Definition: spacegroup.cpp:658
clipper::Spgr_descr::hash
const unsigned int & hash() const
return the hash code for the spacegroup
Definition: spacegroup.h:133
clipper::Spacegroup::asu_min
Coord_frac asu_min() const
get map ASU, lower bound
Definition: spacegroup.cpp:937
clipper::Spacegroup::Spacegroup
Spacegroup()
null constructor
Definition: spacegroup.h:180
clipper::Spgr_cacheobj::asu_max_
Vec3 asu_max_
real space ASU
Definition: spacegroup.h:157
clipper::Spgr_cacheobj::lgrp
int lgrp
Laue group number.
Definition: spacegroup.h:154
clipper::Spgr_descr::Symop_codes::init_symops
void init_symops(const String &symb)
initialise from symops
Definition: spacegroup.cpp:260
clipper::Spacegroup::inverse_op
int inverse_op(const int &s) const
get symop number corresponding to the inverse of a symop
Definition: spacegroup.cpp:919
clipper::Spgr_cacheobj::mutex
static Mutex mutex
thread safety
Definition: spacegroup.h:158
clipper::Spgr_descr
spacegroup description
Definition: spacegroup.h:73
clipper::String
String extension with simple parsing methods.
Definition: clipper_types.h:64
clipper::Spgr_descr::symbol_xhm
String symbol_xhm() const
return the extended H-M symbol
Definition: spacegroup.cpp:621
clipper::ObjectCache::Reference
ObjectCache reference class.
Definition: clipper_memory.h:154
clipper::Spgr_descr::Symop_codes::hash
unsigned int hash() const
return hash code of symop list
Definition: spacegroup.cpp:430
clipper::Spgr_cacheobj::format
String format() const
string description
Definition: spacegroup.cpp:836
clipper::Spacegroup::inversion_symop
const Symop & inversion_symop(const int &sym_no) const
get n'th inversion symop (0...1 max)
Definition: spacegroup.h:213
clipper::Spacegroup::num_inversion_symops
const int & num_inversion_symops() const
get number of inversion symops (inc identity)
Definition: spacegroup.h:203
clipper::Mutex
Mutex class: used for locking and unlocking shared resources.
Definition: clipper_thread.h:64
clipper::Spgr_cacheobj::spgr_cachekey_
Key spgr_cachekey_
spacegroup cachekey
Definition: spacegroup.h:152
clipper::Spgr_descr::hash_
unsigned int hash_
hash code of spacegroup
Definition: spacegroup.h:136
clipper::Spgr_cacheobj
Definition: spacegroup.h:144
clipper::Spgr_descr::generator_ops
const Symop_codes & generator_ops() const
return the generators for the spacegroup
Definition: spacegroup.h:131
clipper::Spgr_descr::symbol_hm_ext
String symbol_hm_ext() const
return the extension H-M symbol
Definition: spacegroup.cpp:636
clipper::Vec3<>
clipper::Spacegroup::product_op
int product_op(const int &s1, int &s2) const
get symop number corresponding to the product of two symops
Definition: spacegroup.cpp:911
clipper::Spacegroup::p1
static Spacegroup p1()
Return P1 spacegroup.
Definition: spacegroup.h:247
clipper::Spgr_descr::Symop_codes::centering_ops
Symop_codes centering_ops() const
return lattice centering ops (by computation)
Definition: spacegroup.cpp:332
clipper::Spacegroup::symop
const Symop & symop(const int &sym_no) const
get n'th symop
Definition: spacegroup.h:207
clipper::Spgr_descr::generators_
Symop_codes generators_
codes for symop generators
Definition: spacegroup.h:137
clipper::Spacegroup::symbol_laue
String symbol_laue() const
return the Laue group symbol
Definition: spacegroup.cpp:954
clipper::Spgr_descr::Symop_codes::primitive_noninversion_ops
Symop_codes primitive_noninversion_ops() const
return primitive non-inversion ops (by computation)
Definition: spacegroup.cpp:293
clipper::Spacegroup::primitive_symop
const Symop & primitive_symop(const int &sym_no) const
get n'th primitive symop (identical to symop(sym_no))
Definition: spacegroup.h:210
clipper::Spgr_descr::Symop_codes::patterson_ops
Symop_codes patterson_ops() const
return Patterson ops
Definition: spacegroup.cpp:361
clipper::Symop
Crystallographic symmetry operator.
Definition: symop.h:92
clipper::Spgr_descr::Symop_codes::expand
Symop_codes expand() const
expand (incomplete) list of symops
Definition: spacegroup.cpp:268
clipper::Spgr_descr::Symop_codes::primitive_ops
Symop_codes primitive_ops() const
return primitive incl inversion ops (by computation)
Definition: spacegroup.cpp:318
clipper::Spacegroup::AXIS
AXIS
enumeration for cell axes
Definition: spacegroup.h:178
clipper::Spgr_descr::Spgr_descr
Spgr_descr()
null constructor
Definition: spacegroup.cpp:459
clipper::Spacegroup::num_primitive_symops
const int & num_primitive_symops() const
get number of primitive symops (inc identity and inversion)
Definition: spacegroup.h:199
clipper::Spacegroup::invariant_under_change_of_hand
bool invariant_under_change_of_hand() const
test if change of hand preserves spacegroup
Definition: spacegroup.cpp:942
clipper::Spgr_cacheobj::matches
bool matches(const Key &spgr_cachekey) const
compare entry
Definition: spacegroup.cpp:833
clipper::Spacegroup::num_primops
const int & num_primops() const
get number of primitive symops (identical to num_primitive_symops())
Definition: spacegroup.h:197
clipper::Spacegroup::TYPE
TYPE
enumeration for fast construction of Null or P1 spacegroup
Definition: spacegroup.h:176
clipper::Spacegroup::asu_max
Coord_frac asu_max() const
get map ASU, upper bound
Definition: spacegroup.cpp:930
clipper::Spgr_descr::symbol_hm
String symbol_hm() const
return the H-M symbol
Definition: spacegroup.cpp:611
clipper::Spacegroup::order_of_symmetry_about_axis
int order_of_symmetry_about_axis(const AXIS axis) const
get the order of rotational symmetry about a given axis
Definition: spacegroup.cpp:881
clipper::Spacegroup::descr
const Spgr_descr & descr() const
get spacegroup description
Definition: spacegroup.h:193