# Displacement patterns of the O atoms of SrTiO3 (Pm-3m, Ti at the origin,
# Sr at 1/2 1/2 1/2); crystod-phonon -c POSCAR --element EL [--irrep IR ...],
# testsuite section 04-01
#
# With Ti at the origin the O displacements at R are R1+ + R3+ + R4+ + R5+,
# and R4+ and M3+ are the out-of-phase and in-phase rotations of the TiO6
# octahedra, as in ScF3 (../ScF3). --irrep R4+ gives the 6 rows of
# crystod-group --parent Pm-3m --irrep R4+, --irrep R4+ M3+ the 14 rows of the
# coupled table (127 P4/mbm, 62 Pnma, ...), every one found again on the
# displaced structure.
#
# The labels depend on the origin. In example/test_POSCARs/221_PPOSCAR_SrTiO3
# (Sr at the origin) the O displacements at R are R2- + R3- + R4- + R5-, and
# --element O --irrep R4+ stops with "ERROR: R4+ is not contained in the
# displacement representation of O at R". There the same distortions carry
# R5- and M2+: --irrep R5- gives the table of R4+ here, --irrep R5- M2+ the 14
# coupled rows of R4+ M3+ here, row by row (the same groups, sizes and
# indices, and displaced structures that match those of this cell), while
# --irrep R5- M3+ gives a different coupled table (135 P4_2/mbc, 62 Pnma, ...).
#
# Files of a run of --element O --irrep R4+ M3+ (not kept here; not in the pip
# package): MPPOSCAR_SrTiO3_Pm-3m_R4+_M3+_NN_SG (the displaced structure of
# row NN), POSCAR_SrTiO3_disp_R4+_M3+_NN_SG.vesta (the supercell with arrows),
# SPPOSCAR_SrTiO3_Pm-3m_R4+_M3+ (the undistorted supercell) and the report
# saad_SrTiO3_O_R4+_M3+ (the whole output). crystod -c PPOSCAR_SrTiO3_Pm-3m
# --element O --orbital p (report salc_SrTiO3_O_p) gives the same
# decomposition at R and M as the survey.
#
# Below: the survey in full, then the beginning of each other output, up to
# the end of its first block.

$ crystod-phonon -c PPOSCAR_SrTiO3_Pm-3m --element O

* Structure *
  Space group: Pm-3m (#221)
  Displaced atoms: O x 3
    O1: [0.5, 0.0, 0.0]
    O2: [0.0, 0.5, 0.0]
    O3: [0.0, 0.0, 0.5]

* Displacement (polar-vector) Irreducible Representations of O sites *
  k point (primitive): GM [0.0, 0.0, 0.0]
    2.0 [GM4-(3)] + 1.0 [GM5-(3)]
  k point (primitive): R [0.5, 0.5, 0.5]
    1.0 [R1+(1)] + 1.0 [R3+(2)] + 1.0 [R4+(3)] + 1.0 [R5+(3)]
  k point (primitive): X [0.0, 0.5, 0.0]
    1.0 [X1+(1)] + 1.0 [X3-(1)] + 1.0 [X5+(2)] + 2.0 [X5-(2)] + 1.0 [X4-(1)]
  k point (primitive): M [0.5, 0.5, 0.0]
    1.0 [M1+(1)] + 1.0 [M3+(1)] + 1.0 [M3-(1)] + 1.0 [M5+(2)] + 1.0 [M5-(2)] + 1.0 [M2+(1)] + 1.0 [M4+(1)]

Use --qpoint K for the displacement patterns of every irrep at one k point, --irrep IR [IR2 ...] for those of given irreps (VESTA files with arrows and displaced POSCARs).

* Output files *
  Report written to: saad_SrTiO3_O_survey (this output)

$ crystod-phonon -c PPOSCAR_SrTiO3_Pm-3m --element O --irrep R4+

* Structure *
  Space group: Pm-3m (#221)
  Displaced atoms: O x 3
    O1: [0.5, 0.0, 0.0]
    O2: [0.0, 0.5, 0.0]
    O3: [0.0, 0.0, 0.5]

* Displacement (polar-vector) representation of O atoms at the k points of the irreps *
  k point (primitive): R [0.5, 0.5, 0.5]
    1.0 [R1+(1)] + 1.0 [R3+(2)] + 1.0 [R4+(3)] + 1.0 [R5+(3)]

* Irrep *
R4+: order parameter dimension 3

* Copies in the displacement representation *
  R4+: 1 copy: O
  These are symmetry-adapted displacement patterns, not eigenvectors of a
  dynamical matrix: a real distortion of a row's symmetry combines the copies of
  its irreps with amplitudes that only a force calculation fixes.

* Supercell *
  Commensurate supercell: 2x2x2 (8 primitive cells, 40 atoms), common to every arm of R4+
  displacement modes: |O(g) Psi - Psi D(g)| <= 5.3e-16 over the elements of G/T_S, Psi^T Psi = c 1 within 4.8e-16
  amplitude: largest displacement 0.1 A in every displaced structure (--amplitude); VESTA arrows scaled to a largest length of 1.5 A

* Order parameter directions and isotropy subgroups *
No.  irrep                subgroup           size  index structure
1    R4+(0,0,a)           140 I4/mcm         2     6     140 I4/mcm same
2    R4+(a,a,a)           167 R-3c           2     8     167 R-3c same
3    R4+(0,a,a)           74 Imma            2     12    74 Imma same
4    R4+(0,a,b)           12 C2/m            2     24    12 C2/m same
5    R4+(a,a,b)           15 C2/c            2     24    15 C2/c same
6    R4+(a,b,c)           2 P-1              2     48    2 P-1 same

The components of a direction refer to the irrep basis of the table (as with
crystod-group --parent), not to the axes of the POSCAR; the displacement
listings give the Cartesian displacements.

structure = the space group spglib finds on the displaced structure exported for
the row (supercell as written, all atoms, tolerance 1e-05 A),
compared with the table (number, size, index): same, enantiomorph (the partner
type), different; (xN) for N choices of copies.

* 1: R4+(0,0,a) -> 140 I4/mcm *
  order parameter: a = 1
  reproduce: --order-parameter "0 0 0.816497"
  displacements: |u| = 0.1000 on 16 of 24 O atoms; zero on 8 atoms (no displacement in R4+)
  space group (displaced structure): 140 I4/mcm, point group 4/mmm, size 2, index 6
  check (on the displaced structure as written): table 140 I4/mcm (size 2, index 6), structure 140 I4/mcm same; 64 elements of G/T_S fix the displacements, 64 the order parameter
  allowed by symmetry: no electric polarization (non-polar point group 4/mmm); inversion kept
  displacements in Angstrom (Cartesian, POSCAR axes; atoms numbered as in the supercell POSCAR) ([2, 2, 2] supercell): 16 O atoms move, 8 stay
    O17: [0.0000, 0.0000, -0.1000]
    O18: [0.0000, 0.0000, 0.1000]
    O19: [0.0000, 0.0000, 0.1000]
    O20: [0.0000, 0.0000, -0.1000]
    O21: [0.0000, 0.0000, 0.1000]
    O22: [0.0000, 0.0000, -0.1000]
    O23: [0.0000, 0.0000, -0.1000]
    O24: [0.0000, 0.0000, 0.1000]
    O33: [0.1000, 0.0000, 0.0000]
    O34: [-0.1000, 0.0000, 0.0000]
    O35: [-0.1000, 0.0000, 0.0000]
    O36: [0.1000, 0.0000, 0.0000]
    O37: [-0.1000, 0.0000, 0.0000]
    O38: [0.1000, 0.0000, 0.0000]
    O39: [0.1000, 0.0000, 0.0000]
    O40: [-0.1000, 0.0000, 0.0000]

...

$ crystod-phonon -c PPOSCAR_SrTiO3_Pm-3m --element O --irrep R4+ M3+

* Structure *
  Space group: Pm-3m (#221)
  Displaced atoms: O x 3
    O1: [0.5, 0.0, 0.0]
    O2: [0.0, 0.5, 0.0]
    O3: [0.0, 0.0, 0.5]

* Displacement (polar-vector) representation of O atoms at the k points of the irreps *
  k point (primitive): R [0.5, 0.5, 0.5]
    1.0 [R1+(1)] + 1.0 [R3+(2)] + 1.0 [R4+(3)] + 1.0 [R5+(3)]
  k point (primitive): M [0.5, 0.5, 0.0]
    1.0 [M1+(1)] + 1.0 [M3+(1)] + 1.0 [M3-(1)] + 1.0 [M5+(2)] + 1.0 [M5-(2)] + 1.0 [M2+(1)] + 1.0 [M4+(1)]

* Coupled irreps *
R4+: order parameter dimension 3
M3+: order parameter dimension 3 (star of 3 arm(s) x small dim 1)
coupled order parameter dimension 6 (3 + 3)

* Copies in the displacement representation *
  R4+: 1 copy: O
  M3+: 1 copy: O
  These are symmetry-adapted displacement patterns, not eigenvectors of a
  dynamical matrix: a real distortion of a row's symmetry combines the copies of
  its irreps with amplitudes that only a force calculation fixes.

* Supercell *
  Commensurate supercell: 2x2x2 (8 primitive cells, 40 atoms), common to every arm of R4+, M3+
  displacement modes: |O(g) Psi - Psi D(g)| <= 2.5e-15 over the elements of G/T_S, Psi^T Psi = c 1 within 4.8e-16
  amplitude: largest displacement 0.1 A in every displaced structure (--amplitude); VESTA arrows scaled to a largest length of 1.5 A

* Order parameter directions and isotropy subgroups (R4+ alone) *
irrep                subgroup           size  index
R4+(0,0,a)           140 I4/mcm         2     6    
R4+(a,a,a)           167 R-3c           2     8    
R4+(0,a,a)           74 Imma            2     12   
R4+(0,a,b)           12 C2/m            2     24   
R4+(a,a,b)           15 C2/c            2     24   
R4+(a,b,c)           2 P-1              2     48   

* Order parameter directions and isotropy subgroups (M3+ alone) *
irrep                subgroup           size  index
M3+(0;0;d)           127 P4/mbm         2     6    
M3+(d;d;d)           204 Im-3           4     8    
M3+(0;d;d)           139 I4/mmm         4     12   
M3+(d;e;f)           71 Immm            4     24   

* Order parameter directions and isotropy subgroups (coupled) *
No.  irrep                  subgroup           size  index structure
1    R4+(0,0,a) M3+(0;0;d)  127 P4/mbm         4     12    127 P4/mbm same
2    R4+(0,a,a) M3+(d;0;0)  62 Pnma            4     24    62 Pnma same
3    R4+(0,0,a) M3+(0;d;0)  63 Cmcm            4     24    63 Cmcm same
4    R4+(0,0,a) M3+(d;d;0)  137 P4_2/nmc       8     24    137 P4_2/nmc same
5    R4+(0,a,a) M3+(0;d;d)  63 Cmcm            8     48    63 Cmcm same
6    R4+(a,a,a) M3+(d;d;d)  148 R-3            8     64    148 R-3 same
7    R4+(0,a,b) M3+(d;0;0)  11 P2_1/m          4     48    11 P2_1/m same
8    R4+(0,a,b) M3+(0;0;d)  12 C2/m            4     48    12 C2/m same
9    R4+(a,a,b) M3+(0;0;d)  14 P2_1/c          4     48    14 P2_1/c same
10   R4+(a,a,b) M3+(d;d;0)  15 C2/c            8     96    15 C2/c same
11   R4+(0,0,a) M3+(d;e;f)  59 Pmmn            8     48    59 Pmmn same
12   R4+(a,b,c) M3+(0;0;d)  2 P-1              4     96    2 P-1 same
13   R4+(0,a,b) M3+(d;e;f)  11 P2_1/m          8     96    11 P2_1/m same
14   R4+(a,b,c) M3+(d;e;f)  2 P-1              8     192   2 P-1 same

Every irrep of the coupled table condenses with a nonzero
amplitude; every irrep keeps its own independent free
parameters (R4+: a, b, c; M3+: d, e, f).

The components of a direction refer to the irrep basis of the table (as with
crystod-group --parent), not to the axes of the POSCAR; the displacement
listings give the Cartesian displacements.

structure = the space group spglib finds on the displaced structure exported for
the row (supercell as written, all atoms, tolerance 1e-05 A),
compared with the table (number, size, index): same, enantiomorph (the partner
type), different; (xN) for N choices of copies.

Displacement patterns are exported for the coupled rows; crystod-phonon --irrep R4+ alone exports those of one irrep.

* 1: R4+(0,0,a) M3+(0;0;d) -> 127 P4/mbm *
  copies: R4+ O; M3+ O
  order parameter: R4+: a = 1; M3+: d = 1
  parts: R4+ : M3+ = 1 : 0.5 (each part scaled to largest displacement 1, then weighted)
  weights: 1 : 1 would cancel the displacements on 8 sites
  the relative amplitudes are not fixed by symmetry: other nonzero values that
  keep the pattern of the label (no new zero or equal components) give the
  same group
  reproduce: --order-parameter "0 0 0.544331 0 0 0.272166"
  displacements: 2 distinct magnitudes on 24 O atoms: 0.1000 (x8), 0.0333 (x8); zero on 8 atoms (no displacement in R4+, M3+)
  space group (displaced structure): 127 P4/mbm, point group 4/mmm, size 4, index 12
  check (on the displaced structure as written): table 127 P4/mbm (size 4, index 12), structure 127 P4/mbm same; 32 elements of G/T_S fix the displacements, 32 the order parameter
  allowed by symmetry: no electric polarization (non-polar point group 4/mmm); inversion kept
  displacements in Angstrom (Cartesian, POSCAR axes; atoms numbered as in the supercell POSCAR) ([2, 2, 2] supercell): 16 O atoms move, 8 stay
    O17: [0.0000, 0.0000, -0.1000]
    O18: [0.0000, 0.0000, 0.1000]
    O19: [0.0000, 0.0000, 0.0333]
    O20: [0.0000, 0.0000, -0.0333]
    O21: [0.0000, 0.0000, 0.1000]
    O22: [0.0000, 0.0000, -0.1000]
    O23: [0.0000, 0.0000, -0.0333]
    O24: [0.0000, 0.0000, 0.0333]
    O33: [0.1000, 0.0000, 0.0000]
    O34: [-0.1000, 0.0000, 0.0000]
    O35: [-0.0333, 0.0000, 0.0000]
    O36: [0.0333, 0.0000, 0.0000]
    O37: [-0.1000, 0.0000, 0.0000]
    O38: [0.1000, 0.0000, 0.0000]
    O39: [0.0333, 0.0000, 0.0000]
    O40: [-0.0333, 0.0000, 0.0000]

...
