1 #ifndef CASM_cluterography_io_OrbitPrinter_impl
2 #define CASM_cluterography_io_OrbitPrinter_impl
14 template <
typename OrbitPr
inter,
typename Element>
17 out << out.
indent_str() <<
"Coordinates:" << std::endl;
18 printer.increase_indent(out);
19 printer.print(element, out);
20 printer.decrease_indent(out);
23 template <
typename OrbitType>
26 out << out.
indent_str() <<
"Equivalence map: " << std::endl;
30 for (
const auto &op : orbit.equivalence_map()[equiv_index]) {
31 out << out.
indent_str() << j <<
": (" << op.index() <<
") "
39 template <
typename OrbitType>
45 std::vector<Index> master_group_indices;
46 for (
const auto &op : orbit.equivalence_map()[equiv_index]) {
47 master_group_indices.push_back(op.index());
49 json[
"equivalence_map"] = master_group_indices;
51 std::vector<std::string>
desc;
52 for (
const auto &op : orbit.equivalence_map()[equiv_index]) {
56 json[
"equivalence_map_descriptions"] =
desc;
57 json[
"equivalence_map_descriptions"].set_force_column();
60 template <
typename OrbitType>
63 out << out.
indent_str() <<
"Orbit equivalence map: " << std::endl;
66 for (
int i = 0; i < orbit.size(); ++i) {
67 out << out.
indent_str() <<
"Element: " << i << std::endl;
70 for (
const auto &op : orbit.equivalence_map()[i]) {
71 out << out.
indent_str() << j <<
": (" << op.index() <<
") "
81 template <
typename OrbitType,
typename Element>
83 const Element &element,
85 out << out.
indent_str() <<
"Invariant group:" << std::endl;
87 element, orbit.generating_group(), orbit.sym_compare());
95 template <
typename OrbitType,
typename Element>
97 const Element &element,
101 element, orbit.generating_group(), orbit.sym_compare());
103 std::vector<Index> master_group_indices;
104 for (
const auto &op : invariant_group) {
105 master_group_indices.push_back(op.index());
107 json[
"invariant_group"] = master_group_indices;
109 std::vector<std::string>
desc;
110 for (
const auto &op : invariant_group) {
114 json[
"invariant_group_descriptions"] =
desc;
115 json[
"invariant_group_descriptions"].set_force_column();
120 template <
typename _Element>
121 template <
typename OrbitType>
123 const OrbitType &orbit,
Log &out,
Index orbit_index,
Index Norbits)
const {
125 <<
" of " << orbit.size() <<
" Equivalent " << element_name
126 <<
" in Orbit " << orbit_index << std::endl;
127 this->increase_indent(out);
129 if (this->opt.print_coordinates) {
132 if (this->opt.print_invariant_group) {
133 this->print_invariant_group(orbit, orbit.prototype(), out);
135 this->decrease_indent(out);
141 template <
typename _Element>
142 template <
typename OrbitType>
145 Index Norbits)
const {
147 json[
"prototype"] = orbit.prototype();
148 json[
"linear_orbit_index"] = orbit_index;
149 json[
"mult"] = orbit.
size();
150 if (this->opt.print_invariant_group) {
151 this->print_invariant_group(orbit, orbit.prototype(), json[
"prototype"]);
157 template <
typename _Element>
158 template <
typename OrbitType>
160 const OrbitType &orbit,
Log &out,
Index orbit_index,
Index Norbits)
const {
161 for (
Index equiv_index = 0; equiv_index != orbit.size(); ++equiv_index) {
162 out << out.
indent_str() << equiv_index <<
" of " << orbit.size()
163 <<
" Equivalent " << element_name <<
" in Orbit " << orbit_index
165 this->increase_indent(out);
167 if (this->opt.print_coordinates) {
170 if (this->opt.print_invariant_group) {
171 this->print_invariant_group(orbit, orbit[equiv_index], out);
173 if (this->opt.print_equivalence_map) {
174 this->print_equivalence_map(orbit, equiv_index, out);
176 this->decrease_indent(out);
183 template <
typename _Element>
184 template <
typename OrbitType>
187 Index Norbits)
const {
189 json[
"linear_orbit_index"] = orbit_index;
190 json[
"prototype"] = orbit.prototype();
191 if (this->opt.print_invariant_group) {
192 this->print_invariant_group(orbit, orbit.prototype(), json[
"prototype"]);
194 json[
"elements"].
put_array(orbit.begin(), orbit.end());
195 for (
Index equiv_index = 0; equiv_index != orbit.size(); ++equiv_index) {
196 if (this->opt.print_invariant_group) {
197 this->print_invariant_group(orbit, orbit[equiv_index],
198 json[
"elements"][equiv_index]);
200 if (this->opt.print_equivalence_map) {
201 this->print_equivalence_map(orbit, equiv_index,
202 json[
"elements"][equiv_index]);
221 template <
typename ClusterOrbitIterator,
typename OrbitPr
inter>
224 if (!printer.opt.itemize_orbits) {
225 printer.coord_type(out);
228 out.
ostream().flags(std::ios::showpoint | std::ios::fixed | std::ios::left);
232 Index orbit_index = 0;
233 Index Norbits = std::distance(begin, end);
235 for (
auto it = begin; it != end; ++it) {
236 if (printer.opt.itemize_orbits) {
238 out <<
"\\begin{itemize}\n";
240 out <<
"\\item Orbit " << orbit_index + 1 <<
"\n\n";
241 double min_length = 0.0;
242 double max_length = 0.0;
243 if (it->invariants().displacement().size()) {
244 min_length = it->invariants().displacement().front();
245 max_length = it->invariants().displacement().back();
247 out <<
"\\begin{itemize}\n";
248 out <<
"\\item Number of cluster sites: " << it->prototype().size()
250 out <<
"\\item Multiplicity: " << it->size() <<
"\n";
251 out <<
"\\item Minimum length: " << min_length <<
"\n";
252 out <<
"\\item Maximum length: " << max_length <<
"\n";
253 out <<
"\\end{itemize}\n\n";
255 printer(*it, out, orbit_index, Norbits);
259 out <<
"\\end{itemize}\n\n";
262 if (it->prototype().size() != branch) {
263 branch = it->prototype().size();
264 out << out.
indent_str() <<
"** Branch " << branch <<
" ** "
267 printer.increase_indent(out);
268 double min_length = 0.0;
269 double max_length = 0.0;
270 if (it->invariants().displacement().size()) {
271 min_length = it->invariants().displacement().front();
272 max_length = it->invariants().displacement().back();
274 out << out.
indent_str() <<
"** " << orbit_index <<
" of " << Norbits
276 <<
" Points: " << it->prototype().size() <<
" Mult: " << it->size()
277 <<
" MinLength: " << min_length <<
" MaxLength: " << max_length
279 printer.increase_indent(out);
280 printer(*it, out, orbit_index, Norbits);
282 printer.decrease_indent(out);
283 printer.decrease_indent(out);
290 template <
typename ClusterOrbitIterator>
295 typedef typename std::iterator_traits<ClusterOrbitIterator>::value_type
297 typedef typename orbit_type::Element Element;
317 template <
typename ClusterOutputIterator,
typename SymCompareType>
318 ClusterOutputIterator
read_clust(ClusterOutputIterator result,
321 const SymCompareType &sym_compare) {
324 for (
const auto &j : json[
"orbits"]) {
325 *result++ = orbit_type(j[
"prototype"].get<IntegralCluster>(prim),
326 generating_grp, sym_compare);
337 template <
typename ClusterOutputIterator>
338 ClusterOutputIterator
read_clust(ClusterOutputIterator result,
341 for (
const auto &j : json[
"orbits"]) {
366 template <
typename ClusterOrbitIterator,
typename Pr
inter>
369 Index Norbits = std::distance(begin, end);
371 Index orbit_index = 0;
372 for (
auto it = begin; it != end; ++it, ++orbit_index) {
373 printer.to_json(*it, json[
"orbits"][orbit_index], orbit_index, Norbits);
380 template <
typename ClusterOrbitIterator>
385 typedef typename std::iterator_traits<ClusterOrbitIterator>::value_type
387 typedef typename orbit_type::Element Element;
419 template <
typename ClusterOrbitIterator,
typename Pr
inter>
424 json[
"bspecs"] = bspecs;
std::string indent_str() const
Structure specifies the lattice and atomic basis of a crystal.
SymGroup is a collection of symmetry operations that satisfy the group property The symmetry operatio...
const Lattice & lattice() const
Lattice used for periodic comparisons (for instance, to generate multiplcation table)
static jsonParser object()
Returns an empty json object.
static jsonParser array()
Returns an empty json array.
jsonParser & put_obj()
Puts new empty JSON object.
jsonParser & put_array()
Puts new empty JSON array.
std::vector< PermuteIterator > make_invariant_subgroup(ConfigEnumInput const &config_enum_input)
jsonParser & write_clust(ClusterOrbitIterator begin, ClusterOrbitIterator end, jsonParser &json, Printer printer)
Write Orbit<SymCompareType> to JSON.
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
void print_clust(ClusterOrbitIterator begin, ClusterOrbitIterator end, Log &out, OrbitPrinter printer)
Print IntegralCluster orbits.
void write_prim(const xtal::BasicStructure &prim, fs::path filename, COORD_TYPE mode, bool include_va=false)
Write prim.json to file.
std::string brief_description(const SymOp &op, const xtal::Lattice &lat, SymInfoOptions opt=SymInfoOptions())
Print SymInfo to brief string.
void print_coordinates(OrbitPrinter &printer, const Element &element, Log &out)
INDEX_TYPE Index
For long integer indexing:
ClusterOutputIterator read_clust(ClusterOutputIterator result, const jsonParser &json, const Structure &prim, const SymGroup &generating_grp, const SymCompareType &sym_compare)
Read JSON containing Orbit<SymCompareType> prototypes.
SymInfoOptions sym_info_opt
ORBIT_PRINT_MODE orbit_print_mode
void decrease_indent(Log &out) const
void print_invariant_group(const OrbitType &orbit, const Element &element, Log &out) const
void increase_indent(Log &out) const
void print_equivalence_map(const OrbitType &orbit, Index equiv_index, Log &out) const
Options for printing SymInfo.