# Unfold the phonons of R-3c AlF3 (the child: the 8-atom rhombohedral primitive
# cell, child/FORCE_SETS of a 2x2x2 supercell) onto the Brillouin zone of cubic
# Pm-3m AlF3 (the parent: 4 atoms with Al at the origin, parent/FORCE_SETS of a
# 2x2x2 supercell). Only the antiphase tilt R4+ condenses, so only GM and R
# fold onto the child Gamma point; every arm of X and of M goes to the F star
# of the child, and the arms of each star are equivalent (one class, a). The
# pseudo-parent cell is strongly compressed (volume -9.66 %): the tilt pulls
# the lattice in while the Al-F bonds keep their length.
crystod-phonon --unfold --child-poscar child/167_PPOSCAR_AlF3 --child-dim 2 2 2 --parent-poscar parent/221_PPOSCAR_AlF3 --parent-dim 2 2 2

* Unfolding setup *
child          child/167_PPOSCAR_AlF3: R-3c (No. 167), 8 atoms, cell used as given
child forces   child/FORCE_SETS, supercell 2 2 2
parent         parent/221_PPOSCAR_AlF3: Pm-3m (No. 221), 4 atoms, cell used as given
parent forces  parent/FORCE_SETS, supercell 2 2 2
setting        crystod-group --supergroup-cif parent/221_PPOSCAR_AlF3
               --subgroup-cif child/167_PPOSCAR_AlF3 (1 of 24 equivalent settings)
transformation parent -> child as crystod-group prints it (columns of P: the child basis in
               parent units, (a', b', c') = (a, b, c) P; last column: the origin shift p,
               x_parent = P x_child + p):
  [    -1    -1     0 ] [     0 ]
  [    -1     0    -1 ] [     0 ]
  [     0    -1    -1 ] [     0 ]
M (rows)       -1 -1 0  -1 0 -1  0 -1 -1
               (A_child = M A_parent, k_child = M k_parent; the form --trans-mat takes)
origin shift   p = (0, 0, 0) (parent fractional)
cells          N = 2 parent cells in the child cell; n_child = 8, n_parent = 4 atoms (Al F F F)
pseudo-parent  A_pp = inv(M) A_child: a = 3.4839 3.4839 3.4839 A, angles 88.012 88.012 88.012 deg
strain         lengths -3.27 -3.27 -3.27 %, volume -9.66 % against the parent cell (a = 3.6018 A);
               rotation 125.8 deg
displacement   max 0.4602 A (F), rms 0.3986 A in the child lattice;
               0.4843 A in the strain-free parent lattice
               (crystod-group: 0.4843 A)
condensed      R4+ 1.1862 A (crystod-group mode amplitudes)
folding        parent k folding onto the child Gamma point: GM (0, 0, 0), R (1/2, 1/2, 1/2)

* Unfolding path *
path           GM-X-M-GM-R-X|R-M (seekpath, parent primitive basis), 51 points per leg, 306 k
distances      1/A without 2 pi, reciprocal metric of the pseudo-parent cell A_pp
vertex  k (parent)           K = M k (child)       child point
GM      (0, 0, 0)            (0, 0, 0)             GM
X       (0, 1/2, 0)          (-1/2, 0, -1/2)       F
M       (1/2, 1/2, 0)        (-1, -1/2, -1/2)      F
GM      (0, 0, 0)            (0, 0, 0)             GM
R       (1/2, 1/2, 1/2)      (-1, -1, -1)          GM
X       (0, 1/2, 0)          (-1/2, 0, -1/2)       F
R       (1/2, 1/2, 1/2)      (-1, -1, -1)          GM
M       (1/2, 1/2, 0)        (-1, -1/2, -1/2)      F

* Star arms of the path vertices *
point groups   child 12 operations (R-3c), parent 48 (Pm-3m): 4 orientation domains
star  arm k (parent)         K = M k mod 1        child point  to child GM  path  class
GM    (0, 0, 0)              (0, 0, 0)            GM           yes          path  a
X     (0, 1/2, 0)            (1/2, 0, 1/2)        F            -            path  a
X     (1/2, 0, 0)            (1/2, 1/2, 0)        F            -            -     a
X     (0, 0, 1/2)            (0, 1/2, 1/2)        F            -            -     a
M     (1/2, 1/2, 0)          (0, 1/2, 1/2)        F            -            path  a
M     (1/2, 0, 1/2)          (1/2, 0, 1/2)        F            -            -     a
M     (0, 1/2, 1/2)          (1/2, 1/2, 0)        F            -            -     a
R     (1/2, 1/2, 1/2)        (0, 0, 0)            GM           yes          path  a
  (arms with the same class letter are related by a child operation or by time reversal and give the
   same unfolded spectrum; 'to child GM' = the arm folds onto the child Gamma point, where a
   condensed distortion lives)

* Unfolded irreps at special points *
GM (0, 0, 0) -> child GM
  parent levels: GM4- [T1u] 0.0000 x3, GM5- [T2u] 6.7446 x3, GM4- [T1u] 9.7679 x3,
                 GM4- [T1u] 19.9718 x3
  not separated by the child symmetry: {GM4-, GM5-}
  freq(THz)   n    P_g  label              fractions
     0.0000   3  3.000  GM4- [T1u]         GM4- 1.000
     7.0155   2  1.996  GM5- [T2u]         GM5- 0.982, GM4- 0.018
     8.2426   1  0.972  GM5- [T2u]         GM5- 1.000
     9.6745   1  1.000  GM4- [T1u]         GM4- 1.000
    10.1483   2  1.748  GM4- [T1u]         GM4- 0.986, GM5- 0.014
    16.1107   2  0.297  GM4- [T1u]         GM4- 0.944, GM5- 0.056
    19.2963   1  1.000  GM4- [T1u]         GM4- 1.000
    19.4371   2  1.959  GM4- [T1u]         GM4- 1.000
X (0, 1/2, 0) -> child F
  parent levels: X5- 3.7885 x2, X4- 6.8515, X5+ 7.6422 x2, X3- 7.8903, X5- 9.1109 x2, X3- 17.9117,
                 X1+ 18.8463, X5- 19.7201 x2
  not separated by the child symmetry: {X1+, X5+}, {X3-, X4-, X5-}
  freq(THz)   n    P_g  label              fractions
     3.8830   1  0.996  X5-                X5- 1.000
     3.8955   1  0.975  X5-                X5- 0.999
     6.8787   1  0.221  X4-                X4- 0.792, X5- 0.208
     7.0509   1  0.470  X3-                X3- 0.832, X5- 0.168
     7.0679   1  0.651  X5+                X5+ 0.990
     7.1094   1  0.278  X4-                X4- 0.979, X5- 0.021
     7.5798   1  0.290  X5+                X5+ 1.000
     8.3210   1  0.730  X4-                X4- 0.600, X5- 0.400
     8.5203   1  0.309  X5+                X5+ 0.968, X1+ 0.032
     8.6461   1  0.713  X3-                X3- 0.810, X5- 0.190
     8.9198   1  0.671  X5+                X5+ 1.000
     9.6655   1  0.800  X5-                X5- 0.954, X3- 0.046
     9.8757   1  0.750  X5-                X5- 0.876, X4- 0.124
    18.0733   1  0.983  X1+                X1+ 1.000
    18.6955   1  0.977  X3-                X3- 0.963, X5- 0.037
    19.1093   1  0.991  X5-                X5- 0.973, X3- 0.027
    19.1934   1  0.966  X5-                X5- 1.000
M (1/2, 1/2, 0) -> child F
  parent levels: M3+ -1.6312, M3- 7.2417, M5- 7.4019 x2, M5+ 7.6429 x2, M4+ 10.7752, M2+ 14.6449,
                 M5- 16.7530 x2, M3- 19.6287, M1+ 20.0935
  not separated by the child symmetry: {M1+, M2+, M3+, M4+, M5+}, {M3-, M5-}
  freq(THz)   n    P_g  label              fractions
     4.4322   1  0.950  M3+                M3+ 0.985, M5+ 0.015
     6.8787   1  0.779  M3-                M3- 0.639, M5- 0.361
     7.0509   1  0.530  M5-                M5- 1.000
     7.0679   1  0.349  M5+                M5+ 0.947, M3+ 0.040, M2+ 0.013
     7.1094   1  0.722  M3-                M3- 0.649, M5- 0.351
     7.5798   1  0.710  M5+                M5+ 0.950, M4+ 0.044
     8.3210   1  0.270  M5-                M5- 0.956, M3- 0.044
     8.5203   1  0.691  M5+                M5+ 0.925, M3+ 0.071
     8.6461   1  0.287  M5-                M5- 1.000
     8.9198   1  0.329  M5+                M5+ 0.960, M4+ 0.027, M1+ 0.013
     9.6655   1  0.200  M5-                M5- 1.000
     9.8757   1  0.250  M5-                M5- 0.987, M3- 0.013
    11.4617   1  0.968  M4+                M4+ 0.991
    14.3986   1  0.992  M2+                M2+ 1.000
    17.0414   1  0.948  M5-                M5- 0.999
    17.1128   1  0.947  M5-                M5- 1.000
    19.0483   1  0.972  M3-                M3- 0.999
    19.1415   1  0.992  M1+                M1+ 0.999
R (1/2, 1/2, 1/2) -> child GM
  parent levels: R4+ -1.9107 x3, R5+ 10.7086 x3, R3+ 14.7069 x2, R4- 16.1103 x3, R1+ 21.1196
  not separated by the child symmetry: {R1+, R3+, R4+, R5+}
  freq(THz)   n    P_g  label              fractions
     4.0303   2  2.000  R4+                R4+ 0.999
     6.1149   1  1.000  R4+                R4+ 1.000
    10.1483   2  0.252  R4-                R4- 1.000
    10.9599   1  1.000  R5+                R5+ 0.999
    11.3591   2  2.000  R5+                R5+ 0.999
    14.3513   2  2.000  R3+                R3+ 1.000
    16.1107   2  1.703  R4-                R4- 1.000
    16.3832   1  0.972  R4-                R4- 1.000
    19.9557   1  1.000  R1+                R1+ 0.999
  (rows: the degenerate groups of child modes (|df| <= 1e-4 THz) with P_g >= 0.10; the .dat file has
   all groups. The label is the irrep holding at least 50 % of P_g, else the smallest set of irreps
   that the child symmetry cannot separate and that together hold at least 50 % (written A/B), else
   mixed; two irreps that time reversal joins count as one (written S1+S2).)

* Child GM mode origin *
child GM (K = 0), 24 modes, from the parent k folding onto it: GM (0, 0, 0), R (1/2, 1/2, 1/2)
modes     freq(THz)  n  child irrep                  origin
1,2,3        0.0000  3  GM2-+GM3- [A2u+Eu] acoustic  GM GM4- [T1u] 3.00
4,5          4.0303  2  GM3+ [Eg] Raman              R R4+ 2.00
6            6.1149  1  GM1+ [A1g] Raman             R R4+ 1.00
7,8          7.0155  2  GM3- [Eu] IR                 GM GM5- [T2u] 2.00
9            8.2426  1  GM1- [A1u] silent            GM GM5- [T2u] 0.97
10           9.6745  1  GM2- [A2u] IR                GM GM4- [T1u] 1.00
11,12       10.1483  2  GM3- [Eu] IR                 GM GM4- [T1u] 1.75
13          10.9599  1  GM2+ [A2g] silent            R R5+ 1.00
14,15       11.3591  2  GM3+ [Eg] Raman              R R5+ 2.00
16,17       14.3513  2  GM3+ [Eg] Raman              R R3+ 2.00
18,19       16.1107  2  GM3- [Eu] IR                 R R4- 1.70
20          16.3832  1  GM1- [A1u] silent            R R4- 0.97
21          19.2963  1  GM2- [A2u] IR                GM GM4- [T1u] 1.00
22,23       19.4371  2  GM3- [Eu] IR                 GM GM4- [T1u] 1.96
24          19.9557  1  GM2+ [A2g] silent            R R1+ 1.00
  (origin: the folding k with the largest P_g(k) of the level, its label there and that P_g(k))
modes     freq(THz)  n  GM                R
1,2,3        0.0000  3  3.000 GM4- [T1u]  0.000 -
4,5          4.0303  2  0.000 -           2.000 R4+
6            6.1149  1  0.000 -           1.000 R4+
7,8          7.0155  2  1.996 GM5- [T2u]  0.004 -
9            8.2426  1  0.972 GM5- [T2u]  0.028 R4-
10           9.6745  1  1.000 GM4- [T1u]  0.000 -
11,12       10.1483  2  1.748 GM4- [T1u]  0.252 R4-
13          10.9599  1  0.000 -           1.000 R5+
14,15       11.3591  2  0.000 -           2.000 R5+
16,17       14.3513  2  0.000 -           2.000 R3+
18,19       16.1107  2  0.297 GM4- [T1u]  1.703 R4-
20          16.3832  1  0.028 GM5- [T2u]  0.972 R4-
21          19.2963  1  1.000 GM4- [T1u]  0.000 -
22,23       19.4371  2  1.959 GM4- [T1u]  0.041 R4-
24          19.9557  1  0.000 -           1.000 R1+
  (columns: weight P_g(k) of the child level at each folding k and its label there ('-' below 0.02);
   the weights of a level add up to its number of modes)
soft parent levels and the child GM levels they go into (content c_g >= 0.02):
  R (1/2, 1/2, 1/2) R4+ -1.9107 x3: 4.030 Eg 2.00, 6.115 A1g 1.00; mean 4.73 THz

* Unfolding summary *
k points       306 on the path; 2768 arms of their stars unfolded for the domain average
               (4 orientation domains)
modes          24 child modes at every k; 7344 (k, mode) pairs, 6491 with weight >= 0.02
sum rule       max |sum_J P_J(k) - 12| = 1.8e-14 on the path, 1.2e-14 for the domain average
arm classes    arms of one class agree to 5.1e-13 THz and 2.0e-12 in weight
               (child operations and time reversal)
irreps         projectors 7.7e-16 (completeness, idempotency, hermiticity);
               per-irrep sum rule 1.4e-14; parent levels pure to 5.3e-15;
               weight forbidden by the child symmetry 3.7e-23
labels         ISO-IR labels computed at 16 k and copied along 6 straight runs (0 mismatches);
               groups with P_g >= 0.02: 5938 one irrep, 158 sets (A/B), 0 mixed
timings (CPU)  mapping 2.4 s, phonopy 0.9 s, unfolding 0.03 s, star arms and domain average 0.3 s,
               irreps 2.6 s, child GM origin 0.07 s, figures 3.2 s, total 9.8 s

* Output files *
  Unfolded bands (2 pages) written to: phonon_unfold.pdf
  Weights and labels written to: phonon_unfold.dat
  Report written to: phonon_unfold.txt (this output)



# The setting with the rhombohedral axes a+b, b+c, c+a of the parent. It
# differs from crystod-group's setting -1 -1 0  -1 0 -1  0 -1 -1 above by the
# two-fold rotation W = 0 -1 0  -1 0 0  0 0 -1 of the parent, which is also an
# operation of the R-3c child: both settings describe the same domain, and
# the frequencies, weights, labels and the child GM origin are the same; only
# K = M k differs (the setup block is shown).
crystod-phonon --unfold --child-poscar child/167_PPOSCAR_AlF3 --child-dim 2 2 2 --parent-poscar parent/221_PPOSCAR_AlF3 --parent-dim 2 2 2 --trans-mat 1 1 0  0 1 1  1 0 1 -o phonon_unfold_abc

* Unfolding setup *
child          child/167_PPOSCAR_AlF3: R-3c (No. 167), 8 atoms, cell used as given
child forces   child/FORCE_SETS, supercell 2 2 2
parent         parent/221_PPOSCAR_AlF3: Pm-3m (No. 221), 4 atoms, cell used as given
parent forces  parent/FORCE_SETS, supercell 2 2 2
setting        --trans-mat 1 1 0  0 1 1  1 0 1: the crystod-group setting -1 -1 0  -1 0 -1  0 -1 -1
               transformed by the parent operation W = 0 -1 0  -1 0 0  0 0 -1, w = (0, 0, 0)
               (24 equivalent settings)
transformation parent -> child of this setting in crystod-group's convention (columns of P:
               the child basis in parent units, (a', b', c') = (a, b, c) P; last column:
               the origin shift p, x_parent = P x_child + p):
  [     1     0     1 ] [     0 ]
  [     1     1     0 ] [     0 ]
  [     0     1     1 ] [     0 ]
M (rows)       1 1 0  0 1 1  1 0 1
               (A_child = M A_parent, k_child = M k_parent; the form --trans-mat takes)
origin shift   p = (0, 0, 0) (parent fractional)
cells          N = 2 parent cells in the child cell; n_child = 8, n_parent = 4 atoms (Al F F F)
pseudo-parent  A_pp = inv(M) A_child: a = 3.4839 3.4839 3.4839 A, angles 88.012 88.012 88.012 deg
strain         lengths -3.27 -3.27 -3.27 %, volume -9.66 % against the parent cell (a = 3.6018 A);
               rotation 56.6 deg
displacement   max 0.4602 A (F), rms 0.3986 A in the child lattice;
               0.4843 A in the strain-free parent lattice
               (crystod-group: 0.4843 A)
condensed      R4+ 1.1862 A (crystod-group mode amplitudes)
folding        parent k folding onto the child Gamma point: GM (0, 0, 0), R (1/2, 1/2, 1/2)

...
