CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
SupercellEnumerator_test.cpp
Go to the documentation of this file.
1 #define BOOST_TEST_DYN_LINK
2 #include <boost/test/unit_test.hpp>
3 #include<boost/filesystem.hpp>
4 
9 
13 #include "casm/external/Eigen/Dense"
15 
16 using namespace CASM;
17 boost::filesystem::path testdir("tests/unit/crystallography");
18 
19 void autofail() {
20  BOOST_CHECK_EQUAL(1, 0);
21  return;
22 }
23 
24 void hermite_init() {
25  int dims = 5;
26  int det = 30;
27 
28  HermiteCounter hermit_test(det, dims);
29 
30  Eigen::VectorXi init_diagonal(Eigen::VectorXi::Ones(dims));
31  init_diagonal(0) = det;
32 
33  BOOST_CHECK_EQUAL(init_diagonal, hermit_test.diagonal());
34  BOOST_CHECK_EQUAL(0, hermit_test.position());
35 
36  auto tricounter = HermiteCounter_impl::_upper_tri_counter(hermit_test.diagonal());
37  Eigen::VectorXi startcount(Eigen::VectorXi::Zero(HermiteCounter_impl::upper_size(dims)));
38  BOOST_CHECK_EQUAL(tricounter.current(), startcount);
39 
40 
41  Eigen::VectorXi endcount(Eigen::VectorXi::Zero(HermiteCounter_impl::upper_size(dims)));
42  endcount(0) = (det - 1);
43  endcount(1) = (det - 1);
44  endcount(2) = (det - 1);
45  endcount(3) = (det - 1);
46 
47  auto finalcounterstate = tricounter;
48 
49  for(; tricounter.valid(); ++tricounter) {
50  finalcounterstate = tricounter;
51  }
52 
53  BOOST_CHECK_EQUAL(finalcounterstate.current(), endcount);
54 
55 
56  return;
57 }
58 
59 void spill_test() {
60  Eigen::VectorXi diagonal0(Eigen::VectorXi::Ones(5));
61  Eigen::VectorXi diagonal1(Eigen::VectorXi::Ones(5));
62  Eigen::VectorXi diagonal2(Eigen::VectorXi::Ones(5));
63  Eigen::VectorXi diagonal3(Eigen::VectorXi::Ones(5));
64 
65 
66  int p = 0;
67  diagonal0(p) = 2;
68  int p0 = HermiteCounter_impl::_spill_factor(diagonal0, p, 2);
69  BOOST_CHECK_EQUAL(p0, p + 1);
70  BOOST_CHECK_EQUAL(diagonal0(p), 1);
71  BOOST_CHECK_EQUAL(diagonal0(p + 1), 2);
72 
73  p = 3;
74  diagonal1(p) = 6;
75  int p1 = HermiteCounter_impl::_spill_factor(diagonal1, p, 2);
76  BOOST_CHECK_EQUAL(p1, p + 1);
77  BOOST_CHECK_EQUAL(diagonal1(p), 3);
78  BOOST_CHECK_EQUAL(diagonal1(p + 1), 2);
79 
80  p = 3;
81  diagonal2(p) = 6;
82  int p2 = HermiteCounter_impl::_spill_factor(diagonal2, p, 4);
83  BOOST_CHECK_EQUAL(p2, p + 1);
84  BOOST_CHECK_EQUAL(diagonal2(p), 1);
85  BOOST_CHECK_EQUAL(diagonal2(p + 1), 6);
86 
87  p = 2;
88  diagonal3(p) = 8;
89  int p3 = HermiteCounter_impl::_spill_factor(diagonal3, p, 4);
90  BOOST_CHECK_EQUAL(p3, p + 1);
91  BOOST_CHECK_EQUAL(diagonal3(p), 2);
92  BOOST_CHECK_EQUAL(diagonal3(p + 1), 4);
93 
94  return;
95 }
96 
98  //Example increment from one possible diagonal to the next
99  Eigen::VectorXi diagonal(Eigen::VectorXi::Ones(5));
100  Eigen::VectorXi next_diagonal(Eigen::VectorXi::Ones(5));
101  diagonal(0) = 6;
102  next_diagonal(0) = 3;
103  next_diagonal(1) = 2;
104  int p = 0;
105 
107 
108  BOOST_CHECK_EQUAL(diagonal, next_diagonal);
109  BOOST_CHECK_EQUAL(p, 1);
110 
111 
112  diagonal = Eigen::VectorXi::Ones(5);
113  next_diagonal = Eigen::VectorXi::Ones(5);
114  //[1 2 1 1 3]
115  diagonal(1) = 2;
116  diagonal(4) = 3;
117  //[1 1 6 1 1]
118  next_diagonal(2) = 6;
119 
120  p = 4;
122 
123  BOOST_CHECK_EQUAL(diagonal, next_diagonal);
124  BOOST_CHECK_EQUAL(p, 2);
125 
126  //*************/
127  //Make sure every enumerated diagonal has the right determinant
128 
129  int det = 2 * 3 * 5 * 7;
130  int dims = 5;
131 
132  Eigen::VectorXi diag = Eigen::VectorXi::Ones(dims);
133  diag(0) = det;
134 
135  p = 0;
136  while(p != diag.size()) {
137  int testdet = 1;
138  for(int i = 0; i < diag.size(); i++) {
139  testdet = testdet * diag(i);
140  }
141  BOOST_CHECK_EQUAL(det, testdet);
143  }
144 
145  return;
146 }
147 
150  BOOST_CHECK_EQUAL(totals, -7 + 7 + 6 + 5 + 4 + 3 + 2 + 1);
151 
152  int dims = 5;
153  // int det = 30;
154 
155  Eigen::VectorXi mid_diagonal(Eigen::VectorXi::Ones(dims));
156  mid_diagonal(0) = 5;
157  mid_diagonal(1) = 3;
158  mid_diagonal(4) = 2;
159 
160  auto countertest = HermiteCounter_impl::_upper_tri_counter(mid_diagonal);
161  auto finalcount = countertest;
162 
163  for(; countertest.valid(); countertest++) {
164  finalcount = countertest;
165  }
166 
167  //The initial matrix is 5x5 with diagonal [ 5 3 1 1 2 ], so it has determinant=30
168  //The Hermite matrix with highest ranking for this determinant will therefore be:
169  // 5 4 4 4 4
170  // 0 3 2 2 2
171  // 0 0 1 0 0
172  // 0 0 0 1 0
173  // 0 0 0 0 2
174  //Which gives the upper triangular vector [ 4 4 4 4 2 2 2 0 0 0 ]
175 
176  Eigen::VectorXi end_count_value(Eigen::VectorXi::Zero(HermiteCounter_impl::upper_size(5)));
177  end_count_value(0) = 4;
178  end_count_value(1) = 4;
179  end_count_value(2) = 4;
180  end_count_value(3) = 4;
181  end_count_value(4) = 2;
182  end_count_value(5) = 2;
183  end_count_value(6) = 2;
184  //Rest of the values are zero
185 
186  BOOST_CHECK_EQUAL(finalcount.current(), end_count_value);
187 
188  return;
189 }
190 
192  Eigen::VectorXi diag;
193  diag.resize(4);
194  diag << 2, 4, 6, 8;
195  Eigen::VectorXi upper;
196  upper.resize(3 + 2 + 1);
197  upper << 11, 12, 13,
198  21, 22,
199  33;
200 
201  Eigen::MatrixXi diagmat;
202  diagmat.resize(4, 4);
203  diagmat << 2, 11, 12, 13,
204  0, 4, 21, 22,
205  0, 0, 6, 33,
206  0, 0, 0, 8;
207 
208  BOOST_CHECK_EQUAL(diagmat, HermiteCounter_impl::_zip_matrix(diag, upper));
209 
210  return;
211 }
212 
214  HermiteCounter hermit_test(6, 4);
215 
216  Eigen::MatrixXi hermmat;
217  hermmat.resize(4, 4);
218 
219  //Test starting status
220  hermmat << 6, 0, 0, 0,
221  0, 1, 0, 0,
222  0, 0, 1, 0,
223  0, 0, 0, 1;
224 
225  BOOST_CHECK_EQUAL(hermmat, hermit_test());
226 
227  //Test next status
228  ++hermit_test;
229  hermmat << 6, 1, 0, 0,
230  0, 1, 0, 0,
231  0, 0, 1, 0,
232  0, 0, 0, 1;
233 
234  BOOST_CHECK_EQUAL(hermmat, hermit_test());
235 
236  //Jump to just before you need a new diagonal
237  hermmat << 6, 5, 5, 5,
238  0, 1, 0, 0,
239  0, 0, 1, 0,
240  0, 0, 0, 1;
241 
242  while(hermit_test() != hermmat) {
243  ++hermit_test;
244  }
245 
246  //Check diagonal jump
247  ++hermit_test;
248  hermmat << 3, 0, 0, 0,
249  0, 2, 0, 0,
250  0, 0, 1, 0,
251  0, 0, 0, 1;
252 
253  BOOST_CHECK_EQUAL(hermmat, hermit_test());
254 
255  //Check invalidation and last status
256  auto lastherm = hermmat;
257  while(hermit_test.determinant() != 7) {
258  lastherm = hermit_test();
259  ++hermit_test;
260  }
261 
262  hermmat << 1, 0, 0, 0,
263  0, 1, 0, 0,
264  0, 0, 1, 0,
265  0, 0, 0, 6;
266 
267  BOOST_CHECK_EQUAL(hermmat, lastherm);
268 
269  //Check determinant jump
270  hermit_test = HermiteCounter(3, 4);
271 
272  //Jump to just before you need a new determinant
273 
274  hermmat << 1, 0, 0, 0,
275  0, 1, 0, 0,
276  0, 0, 1, 0,
277  0, 0, 0, 3;
278 
279  while(hermit_test() != hermmat) {
280  ++hermit_test;
281  }
282 
283  //Check determinant jump
284  ++hermit_test;
285 
286  hermmat << 4, 0, 0, 0,
287  0, 1, 0, 0,
288  0, 0, 1, 0,
289  0, 0, 0, 1;
290 
291  BOOST_CHECK_EQUAL(hermmat, hermit_test());
292  return;
293 }
294 
295 void reset_test() {
296  HermiteCounter hermit_test(1, 3);
297 
298  Eigen::MatrixXi hermmat;
299  hermmat.resize(3, 3);
300 
301 
302  Eigen::MatrixXi startmat = hermit_test();
303 
304  //Skip to one of the bigger determinants
305  hermmat << 2, 1, 1,
306  0, 2, 1,
307  0, 0, 1;
308 
309  while(hermit_test() != hermmat) {
310  ++hermit_test;
311  }
312 
313  hermmat << 4, 0, 0,
314  0, 1, 0,
315  0, 0, 1;
316 
317  hermit_test.reset_current();
318 
319  BOOST_CHECK_EQUAL(hermmat, hermit_test());
320 
321  hermit_test.jump_to_determinant(1);
322 
323  BOOST_CHECK_EQUAL(startmat, hermit_test());
324 
325  return;
326 }
327 
329  Eigen::MatrixXi expandmat(Eigen::MatrixXi::Ones(5, 5));
330  expandmat = expandmat * 3;
331 
332  Eigen::VectorXi expanddims(8);
333  expanddims << 1, 1, 1, 0, 1, 0, 0, 1;
334 
335  Eigen::MatrixXi expandedmat(8, 8);
336  expandmat << 3, 3, 3, 0, 3, 0, 0, 3,
337  3, 3, 3, 0, 3, 0, 0, 3,
338  3, 3, 3, 0, 3, 0, 0, 3,
339  0, 0, 0, 1, 0, 0, 0, 0,
340  3, 3, 3, 0, 3, 0, 0, 3,
341  0, 0, 0, 0, 0, 1, 0, 0,
342  0, 0, 0, 0, 0, 0, 1, 0,
343  3, 3, 3, 0, 3, 0, 0, 1;
344 
345  BOOST_CHECK_EQUAL(expandmat, HermiteCounter_impl::_expand_dims_old(expandmat, expanddims));
346 
347  HermiteCounter minicount(1, 4);
348  for(int i = 0; i < 12; i++) {
349  ++minicount;
350  }
351 
352  Eigen::MatrixXi endcount(4, 4);
353  endcount << 1, 0, 0, 0,
354  0, 2, 1, 1,
355  0, 0, 1, 0,
356  0, 0, 0, 1;
357 
358  BOOST_CHECK_EQUAL(endcount, minicount());
359 
360  Eigen::MatrixXi transmat(Eigen::MatrixXi::Identity(6, 6));
361 
362  Eigen::MatrixXi expanded = HermiteCounter_impl::_expand_dims(minicount(), transmat);
363  Eigen::MatrixXi blockmat(6, 6);
364  blockmat << 1, 0, 0, 0, 0, 0,
365  0, 2, 1, 1, 0, 0,
366  0, 0, 1, 0, 0, 0,
367  0, 0, 0, 1, 0, 0,
368  0, 0, 0, 0, 1, 0,
369  0, 0, 0, 0, 0, 1;
370 
371  BOOST_CHECK_EQUAL(blockmat, expanded);
372 
373  Eigen::Matrix2Xi miniherm;
374  miniherm << 2, 1,
375  0, 3;
376 
377  Eigen::Matrix3i minitrans;
378  minitrans << 1, 0, 0,
379  0, 0, 1,
380  0, 1, 0;
381 
382  Eigen::Matrix3i miniexpand;
383  miniexpand << 2, 1, 0,
384  0, 0, 1,
385  0, 3, 0;
386 
387  BOOST_CHECK_EQUAL(HermiteCounter_impl::_expand_dims(miniherm, minitrans), miniexpand);
388 
389 
390  return;
391 }
392 
393 jsonParser mat_test_case(const std::string &pos_filename, int minvol, int maxvol) {
394 
395  const Structure test_struc(testdir / pos_filename);
396  const Lattice test_lat = test_struc.lattice();
397  const SymGroup effective_pg = test_struc.factor_group();
398 
399  Array<Eigen::Matrix3i> enumerated_mats;
400 
401  ScelEnumProps enum_props(minvol, maxvol + 1);
402  SupercellEnumerator<Lattice> test_enumerator(test_lat, effective_pg, enum_props);
403 
404  double tol = TOL;
405  for(auto it = test_enumerator.begin(); it != test_enumerator.end(); ++it) {
406  enumerated_mats.push_back(it.matrix());
407 
408  // -- check niggli generation
409 
410  Lattice niggli1 = niggli(*it, tol);
411  Lattice niggli2 = niggli(niggli1, tol);
412  bool check_niggli = almost_equal(
413  niggli1.lat_column_mat(),
414  niggli2.lat_column_mat(),
415  tol);
416 
417  BOOST_CHECK_EQUAL(check_niggli, true);
418 
419  // -- check canonical generation
420 
421  Lattice canon = canonical_equivalent_lattice(*it, effective_pg, tol);
422  Lattice canon2 = canonical_equivalent_lattice(canon, effective_pg, tol);
423  bool check = almost_equal(
424  canon.lat_column_mat(),
425  canon2.lat_column_mat(),
426  tol);
427 
428  BOOST_CHECK_EQUAL(check, true);
429 
430  }
431 
432  jsonParser mat_dump;
433  mat_dump["input"]["min_vol"] = minvol;
434  mat_dump["input"]["max_vol"] = maxvol;
435  mat_dump["input"]["source"] = pos_filename;
436  mat_dump["output"]["mats"] = enumerated_mats;
437 
438  return mat_dump;
439 }
440 
441 jsonParser lat_test_case(const std::string &pos_filename, int minvol, int maxvol) {
442  const Structure test_struc(testdir / pos_filename);
443  const Lattice test_lat = test_struc.lattice();
444  const SymGroup effective_pg = test_struc.factor_group();
445 
446  Array<Lattice> enumerated_lats;
447  ScelEnumProps enum_props(minvol, maxvol + 1);
448  test_lat.generate_supercells(enumerated_lats, effective_pg, enum_props);
449 
450  jsonParser lat_dump;
451  lat_dump["input"]["min_vol"] = minvol;
452  lat_dump["input"]["max_vol"] = maxvol;
453  lat_dump["input"]["source"] = pos_filename;
454  lat_dump["output"]["lats"] = enumerated_lats;
455 
456  return lat_dump;
457 }
458 
460  jsonParser all_test_cases;
461 
462  //********************************************************************//
463 
464  std::vector<jsonParser> all_mat_tests;
465  all_mat_tests.push_back(mat_test_case("POS1", 1, 6));
466  all_mat_tests.push_back(mat_test_case("PRIM1", 2, 9));
467  all_mat_tests.push_back(mat_test_case("PRIM2", 4, 7));
468  all_mat_tests.push_back(mat_test_case("PRIM4", 1, 8));
469 
470  all_test_cases["mat_test_cases"] = all_mat_tests;
471 
472  //********************************************************************//
473 
474  std::vector<jsonParser> all_lat_tests;
475  all_lat_tests.push_back(lat_test_case("POS1", 2, 6));
476  all_lat_tests.push_back(lat_test_case("PRIM1", 2, 9));
477  all_lat_tests.push_back(lat_test_case("PRIM2", 3, 7));
478  all_lat_tests.push_back(lat_test_case("PRIM4", 1, 8));
479  all_lat_tests.push_back(lat_test_case("PRIM5", 1, 8));
480 
481  all_test_cases["lat_test_cases"] = all_lat_tests;
482 
483  //********************************************************************//
484 
485  jsonParser test1 = all_test_cases;
486  jsonParser test2 = all_test_cases;
487 
488  return all_test_cases;
489 }
490 
491 void unroll_test() {
492  Eigen::MatrixXi mat5(5, 5);
493  mat5 << 1, 12, 11, 10, 9,
494  0, 2, 13, 15, 8,
495  0, 0, 3, 14, 7,
496  0, 0, 0, 4, 6,
497  0, 0, 0, 0, 5;
498 
499  Eigen::VectorXi vec5(5 + 4 + 3 + 2 + 1);
500  vec5 << 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15;
501 
502  BOOST_CHECK_EQUAL(vec5, HermiteCounter_impl::_canonical_unroll(mat5));
503 
504  return;
505 
506  Eigen::Matrix3i mat3;
507  mat3 << 1, 6, 5,
508  0, 2, 4,
509  0, 0, 3;
510 
511  Eigen::Vector3i vec3(3 + 2 + 1);
512  vec3 << 1, 2, 3, 4, 5, 6;
513 
514  BOOST_CHECK_EQUAL(vec3, HermiteCounter_impl::_canonical_unroll(mat3));
515 
516  return;
517 }
518 
519 void compare_test() {
520  Eigen::Matrix3i low, high;
521 
522  low << 1, 9, 9,
523  0, 9, 9,
524  0, 9, 9;
525 
526  high << 2, 0, 0,
527  0, 1, 0,
528  0, 0, 1;
529 
530  BOOST_CHECK(HermiteCounter_impl::_canonical_compare(low, high));
531 
532  low << 1, 9, 9,
533  0, 9, 9,
534  0, 9, 9;
535 
536  high << 1, 10, 9,
537  0, 9, 9,
538  0, 9, 9;
539 
540  BOOST_CHECK(HermiteCounter_impl::_canonical_compare(low, high));
541 
542  return;
543 }
544 
546  Lattice testlat(Lattice::fcc());
547  SymGroup pg;
548  testlat.generate_point_group(pg);
549  // int dims = 3;
550  Eigen::Matrix3i transmat;
551 
552  transmat << -1, 1, 1,
553  1, -1, 1,
554  1, 1, -1;
555 
556  Lattice bigunit = make_supercell(testlat, transmat);
557 
558  ScelEnumProps enum_props(1, 5 + 1, "abc", transmat);
559  SupercellEnumerator<Lattice> enumerator(testlat, pg, enum_props);
560 
561  std::vector<Lattice> enumerated_lat(enumerator.begin(), enumerator.end());
562 
563  for(Index i = 0; i > enumerated_lat.size(); i++) {
564  BOOST_CHECK(enumerated_lat[i].is_supercell_of(bigunit));
565  }
566 
567  return;
568 }
569 
571  std::vector<Lattice> all_test_lats;
572  all_test_lats.push_back(Lattice::fcc());
573  all_test_lats.push_back(Lattice::bcc());
574  all_test_lats.push_back(Lattice::cubic());
575  all_test_lats.push_back(Lattice::hexagonal());
576 
577  for(Index t = 0; t < all_test_lats.size(); t++) {
578  Lattice testlat = all_test_lats[t];
579  SymGroup pg;
580  testlat.generate_point_group(pg);
581  // int dims = 1;
582 
583  ScelEnumProps enum_props(1, 15 + 1, "a");
584  SupercellEnumerator<Lattice> enumerator(testlat, pg, enum_props);
585 
586  int l = 1;
587  for(auto it = enumerator.begin(); it != enumerator.end(); ++it) {
588  Eigen::Matrix3i comp_transmat;
589  comp_transmat << (l), 0, 0,
590  0, 1, 0,
591  0, 0, 1;
592 
593  BOOST_CHECK(it.matrix() == canonical_hnf(comp_transmat, pg, testlat));
594  l++;
595  }
596  }
597 
598  return;
599 }
600 
601 
602 BOOST_AUTO_TEST_SUITE(SupercellEnumeratorTest)
603 
604 BOOST_AUTO_TEST_CASE(HermiteConstruction) {
605  hermite_init();
606 }
607 
608 BOOST_AUTO_TEST_CASE(HermiteImpl) {
609  spill_test();
613  reset_test();
614  unroll_test();
615  compare_test();
616 }
617 
618 BOOST_AUTO_TEST_CASE(HermiteCounting) {
619  increment_test();
620 }
621 
622 //Tests in here were created by first getting results from
623 //before HermiteCounter existed and then making sure the results
624 //didn't change after it was introduced
625 
626 //Unfortunately, the old niggli routines weren't working as
627 //they should have been, so these hard coded examples to check
628 //had to be regenerated...
629 
630 BOOST_AUTO_TEST_CASE(EnumeratorConsistency) {
631 
632  boost::filesystem::path old_test_path = testdir / "test_cases.json";
633  boost::filesystem::path current_test_path = testdir / "current_test_results.json";
634 
635  jsonParser current_test_results = generate_all_test_cases();
636  current_test_results.write(current_test_path);
637 
638  //Find out where things fail
639  //Comparison will fail if you don't compare from pre-written files.
640  jsonParser curr(current_test_path);
641  jsonParser existing(old_test_path);
642 
643  boost::filesystem::path failure_point = find_diff(curr, existing, TOL);
644 
645  if(!failure_point.empty()) {
646  std::cout << "Difference at: " << failure_point << "\n" << std::endl;
647 
648  auto &_existing = existing.at(failure_point);
649  auto &_curr = curr.at(failure_point);
650  if(_existing.type() != _curr.type()) {
651  std::cout << "Different types\n" << std::endl;
652  }
653  else if(_existing.is_array() && (_existing.size() != _curr.type())) {
654  std::cout << "Different array sizes" << std::endl;
655  std::cout << " Expected: " << _existing.size() << std::endl;
656  std::cout << " Found: " << _curr.size() << std::endl;
657 
658  }
659  else if(_existing.is_obj() && (_existing.size() != _curr.type())) {
660  std::cout << "Different object sizes\n" << std::endl;
661  std::cout << " Expected: " << _existing.size() << std::endl;
662  std::cout << " Found: " << _curr.size() << std::endl;
663 
664  }
665  else {
666  std::cout << "Different values\n" << std::endl;
667  }
668 
669  std::cout << "Expected: \n" << existing.at(failure_point) << "\n"
670  << "Found: \n" << curr.at(failure_point) << std::endl;
671  }
672 
673 
674  BOOST_CHECK(failure_point.empty());
675 
676  current_test_results["WARNING"] = "This has been added as an inconvenience to anyone who is thinking of replacing the \
677 current test_results.json file. Do not replace anything unless you're certain the old \
678 results were incorrect, and these are an improvement. If you are sure you want to proceed, eliminate this key.";
679 
680  current_test_results.write(current_test_path);
681 
682 }
683 
684 BOOST_AUTO_TEST_CASE(RestrictedEnumeration) {
685  trans_enum_test();
686  restricted_test();
687 }
688 
689 BOOST_AUTO_TEST_SUITE_END()
HermiteCounter::Index _spill_factor(Eigen::VectorXi &diag, HermiteCounter::Index position, HermiteCounter::value_type attempt)
Find the next factor of the specified position and share with next element. Use attempt as starting p...
size_type size() const
Returns array size if *this is a JSON array, object size if *this is a JSON object, 1 otherwise.
Definition: jsonParser.cc:430
value_type determinant() const
Get the current determinant.
void compare_test()
Eigen::MatrixXi _expand_dims(const Eigen::MatrixXi &H, const Eigen::MatrixXi &G)
Expand a n x n Hermite normal matrix (H) into a m x m one through a m x m generating matrix (G) (e...
void matrix_construction_test()
boost::filesystem::path find_diff(const jsonParser &A, const jsonParser &B, boost::filesystem::path diff=boost::filesystem::path())
Return the location at which jsonParser 'A' != 'B' as a boost::filesystem::path.
Definition: jsonParser.cc:380
Eigen::VectorXi diagonal() const
void generate_point_group(SymGroup &point_group, double pg_tol=TOL) const
Populate.
Definition: Lattice.cc:304
void write(const std::string &file_name, unsigned int indent=2, unsigned int prec=12) const
Write json to file.
Definition: jsonParser.cc:191
void push_back(const T &toPush)
Definition: Array.hh:513
static Lattice hexagonal()
Construct cubic primitive cell of unit volume.
Definition: Lattice.cc:75
Structure specifies the lattice and atomic basis of a crystal.
Definition: Structure.hh:29
Data structure for holding supercell enumeration properties.
Eigen::Matrix3i canonical_hnf(const Eigen::Matrix3i &T, const SymGroup &effective_pg, const Lattice &ref_lattice)
Return canonical hermite normal form of the supercell matrix, and op used to find it...
bool _canonical_compare(const Eigen::MatrixXi &H0, const Eigen::MatrixXi &H1)
Compare two integer matrices and see which one is lexicographically greatest. Returns true if H0
void reset_test()
boost::filesystem::path testdir("tests/unit/crystallography")
Eigen::MatrixXi _zip_matrix(const Eigen::VectorXi &current_diag, const Eigen::VectorXi &current_upper_tri)
Assemble a matrix diagonal and unrolled upper triangle values into a matrix.
void trans_enum_test()
const_iterator end() const
A const iterator to the past-the-last volume.
Lattice make_supercell(const Lattice &lat, const Eigen::Matrix3i &transf_mat)
Returns a super Lattice.
Definition: Lattice.hh:377
jsonParser & at(const fs::path &path)
Definition: jsonParser.cc:321
jsonParser generate_all_test_cases()
Eigen::MatrixXi _expand_dims_old(const Eigen::MatrixXi &hermit_mat, const Eigen::VectorXi &active_dims)
Expand a n x n Hermite normal matrix into a m x m one (e.g. for 2D supercells)
A fake container of supercell matrices.
Definition: Enumerator.hh:407
void jump_to_determinant(value_type new_det)
Reset the diagonal to the specified determinant and set the other elements to zero.
void next_position_test()
Main CASM namespace.
Definition: complete.cpp:8
const Lattice & lattice() const
void restricted_test()
static Lattice bcc()
Construct BCC primitive cell of unit volume.
Definition: Lattice.cc:57
const double TOL
const Eigen::Matrix3d & lat_column_mat() const
3x3 matrix with lattice vectors as its columne
Definition: Lattice.hh:104
void expand_dims_test()
SymGroup is a collection of symmetry operations that satisfy the group property The symmetry operatio...
Definition: SymGroup.hh:33
BOOST_AUTO_TEST_CASE(HermiteConstruction)
double tol
void increment_test()
const_iterator begin() const
A const iterator to the beginning volume, specify here how the iterator should jump through the enume...
static Lattice cubic()
Construct simple cubic primitive cell of unit volume.
Definition: Lattice.cc:69
const MasterSymGroup & factor_group() const
Definition: Structure.cc:94
Eigen::VectorXi _canonical_unroll(const Eigen::MatrixXi &hermit_mat)
Unroll a Hermit normal form square matrix into a vector such that it's canonical form is easy to comp...
void hermite_init()
EigenIndex Index
For long integer indexing:
Lattice canonical_equivalent_lattice(const Lattice &in_lat, const SymGroup &point_grp, double compare_tol)
Find the niggli, most standard oriented version of the given orbit (defined by the given SymGroup) of...
Definition: Niggli.cc:276
jsonParser lat_test_case(const std::string &pos_filename, int minvol, int maxvol)
void autofail()
void reset_current()
reset the counter to the first iteration of the current determinant
bool check(std::string test, const jsonParser &expected, const jsonParser &calculated, fs::path test_cases_path, bool quiet, double tol=0.0)
Check expected JSON vs calculated JSON using BOOST_CHECK_EQUAL.
jsonParser & push_back(const T &value)
Puts new valued element at end of array of any type T for which 'jsonParser& to_json( const T &value...
Definition: jsonParser.hh:696
jsonParser mat_test_case(const std::string &pos_filename, int minvol, int maxvol)
HermiteCounter::Index upper_size(HermiteCounter::Index init_dim)
Determine the number of elements in the upper triangular matrix (excluding diagonal) ...
void triangle_count_test()
void spill_test()
HermiteCounter::Index next_spill_position(Eigen::VectorXi &diag, HermiteCounter::Index position)
Spill the next factor of the specified element with its neighbor, and return new position.
EigenVectorXiCounter _upper_tri_counter(const Eigen::VectorXi &current_diag)
Create a counter for the elements above the diagonal based on the current diagonal value...
void unroll_test()
Lattice niggli(const Lattice &in_lat, double compare_tol, bool keep_handedness=false)
Convert the given lattice into it's niggli reduced form, with the most standard orientation possilbe...
Definition: Niggli.cc:240
Basic std::vector like container (deprecated)
static Lattice fcc()
Construct FCC primitive cell of unit volume.
Definition: Lattice.cc:45
bool almost_equal(const GenericCluster< CoordType > &LHS, const GenericCluster< CoordType > &RHS, double tol)
void generate_supercells(Array< Lattice > &supercell, const SymGroup &effective_pg, const ScelEnumProps &enum_props) const
Populate.
Definition: Lattice.cc:410