-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandomCells.cpp
More file actions
78 lines (67 loc) · 2.52 KB
/
RandomCells.cpp
File metadata and controls
78 lines (67 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <iostream>
#include <string>
#include <vector>
#include "G6.h"
#include "LRL_Cell.h"
#include "Niggli.h"
#include "GenerateLatticeTypeExamples.h"
// how many examples of each type to generate
static const int ngen = 1;
/*
The "name" variable is the designator for the Bravais type(s)
you want to generate. Because the code below works in Niggli
space, the name should be one of the following types:
1) The number of a single type from the International Tables (1-44)
2) Bravais type, such as cI for body-centered cubic or oI for
body centered orthorhombic. Because there are multiple oI
cases, all will be used. (case sensitive) Hexagonal is hP,
and rhombohedral is hR.
3) Crystal system such as: c, t, h, o, m, a for cubic,
tetragonal, rhombohedral, hexagonal, orthorhombic, monoclinic,
anorthic (=triclinic). (case sensitive)
4) Empty string (or unrecognised) delivers all!!
For centered types, the output will be the centered, not the
primitive, cell.
Obviously, these two parameters could be made into input command
parameters. Values 5 cI would be obvious, but what is 10 15
supposed to mean?
*/
static std::string name = "cI"; // blank or unrecognized gives all types
G6 TryToGetAGoodProjection(const std::shared_ptr<GenerateNiggliBase>& pt,
const MatG6& projector, const int trials = 500) {
G6 probe;
probe.SetValid(false);
int count = 0;
while ((!LRL_Cell(probe).IsValid()) || (count > trials) || (!pt->IsMember(probe))) {
const G6 start = G6::randDeloneReduced();
Niggli::Reduce(start, probe);
probe = projector * probe;
Niggli::Reduce(probe, probe);
++count;
}
return probe;
}
G6 Generate(const std::shared_ptr<GenerateNiggliBase>& pt) {
const G6 probe = TryToGetAGoodProjection(pt, pt->GetPrj(), 50);
const G6 test = pt->GetToCenter() * probe;
return probe;;
}
int main()
{
std::cout << "; generate examples ngen = " << ngen << " lattice type selection = """ << name << std::endl;
const std::vector<std::shared_ptr<GenerateNiggliBase> >
vglb = GenerateNiggliBase().Select(name);
for (size_t lat = 0; lat < vglb.size(); ++lat) {
const std::shared_ptr<GenerateNiggliBase> pt = vglb[lat];
std::cout << "; lattice type = " << pt->GetITNumber() << std::endl;
for (size_t i = 0; i < ngen; ++i) {
const G6 g = Generate(vglb[lat]);
std::cout << "G6 "
<< g << " "
<< " IT# = " << pt->GetITNumber() << " "
<< pt->GetBravaisType()
<< std::endl;
}
std::cout << ";" << std::endl;
}
}