# The copy made by crystod-example has no phonopy_params.yaml (the package
# leaves it out; the CrystOD development tree keeps one here). Make it from the
# unit cell and FORCE_SETS with phonopy 4 (with phonopy 4.3.0 it is that file
# byte for byte; phonopy-init also writes phonopy_disp.yaml, SPOSCAR and
# POSCAR-001 ... POSCAR-010):
phonopy-init -d -c 139_PPOSCAR_Sr3Ti2O7 --dim 4 4 4
phonopy phonopy_disp.yaml --sp
# (phonopy before version 4, where -c moved to phonopy-init, makes it in one
# command:  phonopy --sp -c 139_PPOSCAR_Sr3Ti2O7 --dim="4 4 4")

crystod-phonon --modulation --yaml phonopy_params.yaml --qpoint 0 0 0.5

* Selected Q point *
  Loading 'phonopy_params.yaml' at q = [0.0, 0.0, 0.5]...

* Phonon modes at q = [0.  0.  0.5] *
 Mode    Freq (THz)         Irrep   Degeneracy
--------------------------------------------------
    1        2.2105        X3-(1)            1
    2        2.6519        X4-(1)            1
    3        3.1120        X1-(1)            1
    4        3.2560        X3+(1)            1
    5        3.4220        X2+(1)            1
    6        3.4749        X4+(1)            1
    7        3.4768        X3-(1)            1
    8        3.5443        X2-(1)            1
    9        3.6427        X4-(1)            1
   10        4.1211        X3-(1)            1
   11        4.3933        X2-(1)            1
   12        4.5038        X1+(1)            1
   13        4.8212        X4-(1)            1
   14        4.8338        X3+(1)            1
   15        6.2962        X2-(1)            1
   16        6.4490        X4+(1)            1
   17        6.8091        X3-(1)            1
   18        7.6292        X4-(1)            1
   19        9.6887        X1+(1)            1
   20       10.7529        X3+(1)            1
   21       10.9176        X4+(1)            1
   22       11.8463        X2-(1)            1
   23       12.1322        X3-(1)            1
   24       12.2640        X4-(1)            1
   25       12.5004        X3+(1)            1
   26       12.5356        X4+(1)            1
   27       12.9325        X1+(1)            1
   28       13.0778        X4-(1)            1
   29       13.1042        X3-(1)            1
   30       13.2236        X2-(1)            1
   31       13.7427        X1+(1)            1
   32       14.0144        X2-(1)            1
   33       15.3257        X1-(1)            1
   34       15.3933        X2+(1)            1
   35       22.8936        X1+(1)            1
   36       23.1297        X2-(1)            1

* Star of q (arms related by the space-group rotations) *
  |G| = 16, |G_k| = 8, |star of k| = 2
  arm 1: k = [+0, +0, +0.5]
  arm 2: k = [+0.5, +0.5, +0]

No --mode given. Choose mode number(s) from the table above and rerun with
--mode (and optionally --amplitude) to generate a modulated structure.




# Generate the modulated structure according to the X3- mode (mode 1):
# X3-(0;a), Cmcm
crystod-phonon --modulation --yaml phonopy_params.yaml --qpoint 0 0 0.5 --mode 1 --amplitude 0.3
# -> MPOSCAR_X_mode1_X3-_Cmcm


# The star of X has two arms, (0,0,1/2) and (1/2,1/2,0) (the star printed
# above). Mode 1 frozen into both arms with equal amplitudes is X3-(a;a),
# P4_2/mnm; unequal amplitudes give X3-(a;b), Pnnm -- the rows of
# crystod-group --parent I4/mmm --irrep X3-. An arm may be written as any
# equivalent q: --qpoint2 -0.5 0.5 0 (the same point shifted by a reciprocal
# lattice vector) writes the same structure.
crystod-phonon --modulation --yaml phonopy_params.yaml --qpoint1 0 0 0.5 --mode1 1 --amplitude1 0.3 --qpoint2 0.5 0.5 0 --mode2 1 --amplitude2 0.3

* Selected Q point *
  Loading 'phonopy_params.yaml' at q = [0.0, 0.0, 0.5]...

* Phonon modes at q = [0.  0.  0.5] *
 Mode    Freq (THz)         Irrep   Degeneracy
--------------------------------------------------
    1        2.2105        X3-(1)            1
    2        2.6519        X4-(1)            1
    3        3.1120        X1-(1)            1
    4        3.2560        X3+(1)            1
    5        3.4220        X2+(1)            1
    6        3.4749        X4+(1)            1
    7        3.4768        X3-(1)            1
    8        3.5443        X2-(1)            1
    9        3.6427        X4-(1)            1
   10        4.1211        X3-(1)            1
   11        4.3933        X2-(1)            1
   12        4.5038        X1+(1)            1
   13        4.8212        X4-(1)            1
   14        4.8338        X3+(1)            1
   15        6.2962        X2-(1)            1
   16        6.4490        X4+(1)            1
   17        6.8091        X3-(1)            1
   18        7.6292        X4-(1)            1
   19        9.6887        X1+(1)            1
   20       10.7529        X3+(1)            1
   21       10.9176        X4+(1)            1
   22       11.8463        X2-(1)            1
   23       12.1322        X3-(1)            1
   24       12.2640        X4-(1)            1
   25       12.5004        X3+(1)            1
   26       12.5356        X4+(1)            1
   27       12.9325        X1+(1)            1
   28       13.0778        X4-(1)            1
   29       13.1042        X3-(1)            1
   30       13.2236        X2-(1)            1
   31       13.7427        X1+(1)            1
   32       14.0144        X2-(1)            1
   33       15.3257        X1-(1)            1
   34       15.3933        X2+(1)            1
   35       22.8936        X1+(1)            1
   36       23.1297        X2-(1)            1

* Star of q (arms related by the space-group rotations) *
  |G| = 16, |G_k| = 8, |star of k| = 2
  arm 1: k = [+0, +0, +0.5]
  arm 2: k = [+0.5, +0.5, +0]

* Selected Q point *
  Loading 'phonopy_params.yaml' at q = [0.5, 0.5, 0.0]...

* Phonon modes at q = [0.5 0.5 0. ] *
 Mode    Freq (THz)         Irrep   Degeneracy
--------------------------------------------------
    1        2.2105        X3-(1)            1
    2        2.6519        X4-(1)            1
    3        3.1120        X1-(1)            1
    4        3.2560        X3+(1)            1
    5        3.4220        X2+(1)            1
    6        3.4749        X4+(1)            1
    7        3.4768        X3-(1)            1
    8        3.5443        X2-(1)            1
    9        3.6427        X4-(1)            1
   10        4.1211        X3-(1)            1
   11        4.3933        X2-(1)            1
   12        4.5038        X1+(1)            1
   13        4.8212        X4-(1)            1
   14        4.8338        X3+(1)            1
   15        6.2962        X2-(1)            1
   16        6.4490        X4+(1)            1
   17        6.8091        X3-(1)            1
   18        7.6292        X4-(1)            1
   19        9.6887        X1+(1)            1
   20       10.7529        X3+(1)            1
   21       10.9176        X4+(1)            1
   22       11.8463        X2-(1)            1
   23       12.1322        X3-(1)            1
   24       12.2640        X4-(1)            1
   25       12.5004        X3+(1)            1
   26       12.5356        X4+(1)            1
   27       12.9325        X1+(1)            1
   28       13.0778        X4-(1)            1
   29       13.1042        X3-(1)            1
   30       13.2236        X2-(1)            1
   31       13.7427        X1+(1)            1
   32       14.0144        X2-(1)            1
   33       15.3257        X1-(1)            1
   34       15.3933        X2+(1)            1
   35       22.8936        X1+(1)            1
   36       23.1297        X2-(1)            1

* Star of q (arms related by the space-group rotations) *
  |G| = 16, |G_k| = 8, |star of k| = 2
  arm 1: k = [+0.5, +0.5, +0]
  arm 2: k = [+0, +0, +0.5]

* Modulation *
  Term 1: q = [0.0, 0.0, 0.5], modes = [1], amplitudes (A) = [0.3]
  Term 2: q = [0.5, 0.5, 0.0], modes = [1], amplitudes (A) = [0.3]

* Symmetry of the generated structure *
  Space group: P4_2/mnm (#136)
  Hall symbol: -P 4n 2n

* Output files *
  Modulated structure written to: MPOSCAR_X_mode1_X3-_X_mode1_X3-_P4_2mnm


# Every order-parameter direction of the two lowest X levels (X3-, X4-) at
# once, each written with the --modulation command that reproduces it:
# MPOSCAR_X_X3-_0_a_Cmcm, MPOSCAR_X_X3-_a_a_P4_2mnm, MPOSCAR_X_X3-_a_b_Pnnm,
# MPOSCAR_X_X4-_0_a_Cmme, MPOSCAR_X_X4-_a_a_P4_2mcm, MPOSCAR_X_X4-_a_b_Pccm.
# The levels are stable, so --threshold raises the cut above them.
crystod-phonon --subgroup -c 139_PPOSCAR_Sr3Ti2O7 --dim "4 4 4" --qpoint X --threshold 3.0 --modulate

# --modulation reports the space group at 0.1 A by default; add
# --tolerance 1e-5 to check it strictly. The two (a;b) structures, whose
# second arm has the amplitude 0.16434, read as their (a;a) groups at 0.1
# (P4_2/mnm and P4_2/mcm) and as Pnnm and Pccm at 1e-5.

