.. _label_strain_tools: Tools for the cell-relaxation inputs (strainifc.py, elastic.py, strainfile.py) ================================================================================ The structural optimization with cell relaxation (``RELAX_STR = 2, 3, 4`` in the SCPH/QHA modes) needs a few quantities that anphon cannot compute from the force constants alone: the reference stress and the second- and third-order elastic constants, the strain–force coupling, and the strain–harmonic-IFC coupling. They are prepared from DFT calculations of strained cells by the Python scripts described below, and handed to anphon in one of two ways: * **the strain-coupling container** (recommended): one HDF5 file given as ``STRAINFILE`` in the ``&relax`` field, see :ref:`label_strain_container`; * **the legacy text files** in the directory given by ``STRAIN_IFC_DIR`` (plus ``C1_array.in`` in the working directory of anphon), see :ref:`label_strain_legacy_files`. anphon prints a note when this route is used; it will be removed in a later release. .. _label_strain_container: One file for all inputs: the strain-coupling container (``STRAINFILE``) ----------------------------------------------------------------------- The container is an HDF5 file with the schema ``alamode:strain_coupling``. Every ingredient lives in its own group, the units are stored as attributes, and the reference structure is stored once, so that anphon can verify that the pieces belong together and to the cell of the run: .. list-table:: :header-rows: 1 :widths: 22 18 60 * - Group - Needed by - Content * - ``/ReferenceCell`` - always - The reference structure (lattice, fractional coordinates, elements) in anphon's primitive-cell atom order. anphon checks that its own primitive cell (the ``&cell`` field) describes the same crystal; a nested super- or sub-cell is accepted. * - ``/Elastic`` - ``STRAIN_COUPLING`` bit 1 (``soec``, ``toec``); the reference stress is used with bit 1 clear as well - ``stress`` (3×3), ``soec`` (9×9) and ``toec`` (9×9×9) in GPa, the layout of the text files (:math:`i = 3\mu + \nu`). The stress may be absent (zero is used, with a note); ``soec`` and ``toec`` come together. * - ``/StrainForce`` - ``STRAIN_COUPLING`` bit 2 - The strain-mode table (``modes``, ``smag``, ``weight``), the forces ``[n_modes, n_atoms, 3]`` in eV/Å, and ``Cell``, the cell the rows belong to (the role of the ``&reference_cell`` header of the text file). * - ``/StrainHarmonic`` - ``STRAIN_COUPLING`` bit 4 - The strain-mode table and one sub-group ``entry_NNN`` per strained supercell holding its harmonic force constants in the layout of the alm ``.h5`` files (``SuperCell``, ``ForceConstants/Order2``). anphon checks every entry against the supercell of ``FC2FILE``/``FCSFILE`` deformed by the entry's own strain, atom by atom. The producing commands write into the container directly; the same file can be updated by each, replacing only its own groups and refusing a reference structure that is not the crystal already stored:: elastic.py fit ... --fcs FC2FILE --anphon-cell anphon.in --strain-file ZnO.strain.h5 strainifc.py collect --coupling harmonic ... --fcs FC2FILE --anphon-cell anphon.in --fcs-format h5 --strain-file ZnO.strain.h5 ``elastic.py fit`` writes ``/Elastic`` **and** ``/StrainForce``: its single-mode runs at :math:`\pm s` are exactly the strained primitive cells of the strain–force coupling, so no separate ``strainifc.py --coupling force`` calculations are needed. That route remains for runs that compute the elastic constants from the IFCs (``STRAIN_COUPLING = 6``, no ``elastic.py``):: strainifc.py collect --coupling force ... --fcs FC2FILE --anphon-cell anphon.in --strain-file ZnO.strain.h5 and the anphon input needs a single line:: &relax ... STRAINFILE = ZnO.strain.h5 / ``strainfile.py`` inspects, checks, and converts containers:: strainfile.py show ZnO.strain.h5 strainfile.py check ZnO.strain.h5 --anphon-cell anphon.in --fcs FC2FILE strainfile.py pack --strain-ifc-dir strain_IFC [--c1 C1_array.in] --fcs FC2FILE --anphon-cell anphon.in [--legacy-cell anphon.in] -o ZnO.strain.h5 ``show`` prints the contents (cells, units, the elastic constants in GPa, the strain modes and their weight sums) and which anphon settings the file supports; ``check`` repeats anphon's consistency checks against a planned run before it is submitted; ``pack`` converts an existing ``STRAIN_IFC_DIR`` (any subset of the text files; legacy ``Ry`` files are converted to GPa with the volume of ``--legacy-cell``, the ``&cell`` of the run they were made for, and that assumption is recorded in the file). Every write records its command line in the ``provenance`` attribute. The container is read on every MPI rank and must not be modified while anphon runs. Non-magnetic reference structures only. .. The /Piezoelectric group (EFIELD) is unpublished in 2.0 (planned for 2.1); kept hidden. **The clamped-ion piezoelectric tensor** (``/Piezoelectric/clamped_ion``). ``strainfile.py piezo`` writes it into an existing container and replaces only that dataset (``--overwrite`` when it exists; the other groups and the sibling datasets ``second_order`` and ``born_charge_strain_derivative`` are kept byte for byte). * ``--outcar``: a VASP ``LEPSILON = .TRUE.`` OUTCAR (not recommended for non-centrosymmetric structures; see *Which route for which term* below). The **last** complete block ``PIEZOELECTRIC TENSOR (including local field effects) for field in x, y, z (C/m^2)`` is used. Its rows are the field direction, its columns ``XX YY ZZ XY YZ ZX``, and a shear column is the tensor component itself (:math:`e_{x,ZX} = e_{xxz} = e_{xzx}`: no factor 2, no sign change). The block of the same name in ``e Angst`` is the derivative of the dipole of the simulation cell (extensive) and is not used; the ``IONIC CONTR`` blocks (``IBRION = 7, 8``) hold the relaxed-ion part, which anphon already obtains from the Born charges, and are ignored. An OUTCAR with only those blocks is refused. * ``--voigt``: a 3×6 text table in C/m² (rows :math:`x, y, z`, columns ``xx yy zz yz xz xy``, shear columns equal to the tensor component) from any code, e.g. ABINIT's proper clamped-ion tensor. It requires ``--structure``. The lattice, species and fractional coordinates of the calculation (read from the OUTCAR, or from ``--structure``, a POSCAR or ``vasprun.xml``) must describe the crystal of ``/ReferenceCell`` in the same Cartesian frame (a nested cell is accepted), because the tensor is Cartesian. The file records the method, the VASP version and the source path. The tensor must be the clamped-ion one: a relaxed-ion total counts the ionic response twice. (VASP 5.4.4 and older have a sign bug in ``LCALCEPS``.) **Nonlinear terms: piezo.py** (``second_order`` :math:`B` and ``born_charge_strain_derivative`` :math:`\Lambda`). ``piezo.py`` generates the clamped-ion VASP calculations from a reference calculation directory (``POSCAR``, ``INCAR``, ``KPOINTS``, ``POTCAR``; only these inputs are copied) and collects the results:: piezo.py generate --route berry REFDIR berry [--h 0.01] piezo.py generate --route dfpt REFDIR dfpt [--h 0.01] piezo.py generate --route berry-lambda REFDIR lam_Zn_z_zz --atom 1 --dir z --strain zz [--h 0.01 --delta 0.02] (run VASP in every directory, e.g. with the generated run_all.sh) piezo.py collect berry --strain-file ZnO.strain.h5 [--overwrite] [--no-clamped-ion] [--no-symmetrize] piezo.py collect dfpt --strain-file ZnO.strain.h5 [--born-ref borninfo/OUTCAR] [--overwrite] [--print] piezo.py collect lam_Zn_z_zz --strain-file ZnO.strain.h5 Every cell is clamped-ion: the fractional coordinates are those of the reference, the lattice rows are :math:`\bm a(I+u)` with :math:`u` symmetric, and a shear step sets :math:`u_{mn} = u_{nm} = \pm h` (engineering strain :math:`2h`). The ``INCAR`` of ``REFDIR`` is copied with the route's tags set (``IBRION = -1``, ``NSW = 0`` and the tags below); ``piezo_manifest.json`` records the strains, and ``collect`` checks every ``POSCAR`` and the structure recorded in every ``OUTCAR`` (last lattice, fractional coordinates, species and atom order from the ``TITEL`` lines and ``ions per type``) against it, so a stale or swapped ``OUTCAR`` is rejected. Selective-dynamics flags of the reference ``POSCAR`` are dropped for the displaced atom of ``berry-lambda``. * ``--route berry`` (73 SCF runs with ``LCALCPOL = .TRUE.``, ``ISYM = 0``; ``LEPSILON`` removed): the reference, :math:`\pm h` along each Voigt direction and :math:`(\pm h, \pm h)` for the 15 pairs. ``collect`` forms the reduced dipole :math:`\psi(u) = F^{-1}(p_\mathrm{elc} + p_\mathrm{ion})` from the last ``p[elc]=(`` and ``p[ion]=(`` lines of each OUTCAR, with :math:`F` from the ``POSCAR`` (the ionic part is constant for clamped ions; its grid mean is used). The Berry-phase branch is unwrapped on the connected grid (one quantum = one lattice vector) and every edge, including the loop-closing ones, must change :math:`\psi` by less than a quarter quantum; the largest changes are printed. Then :math:`e^{(0)} = \Omega_0^{-1}\partial\psi/\partial u` and :math:`B = \Omega_0^{-1}\partial^2\psi/\partial u^2` by central first, second and mixed differences. Both are averaged over the point group of the reference (the removed noise is printed and stored as ``e0_symmetry_noise``, ``B_symmetry_noise``; ``--no-symmetrize`` keeps the raw values). ``collect`` writes ``clamped_ion`` and ``second_order`` (``--no-clamped-ion`` keeps a stored :math:`e^{(0)}`, e.g. a DFPT one). * ``--route dfpt`` (12 runs with ``LEPSILON = .TRUE.``, :math:`\pm h` per Voigt direction): the Born charges of the last ``BORN EFFECTIVE CHARGES (including local field effects)`` block. VASP writes row :math:`i` = field (polarization) direction and column :math:`b` = displacement direction (``linear_response.F``: the force on ion :math:`N` along :math:`b` is ``BORN_CHARGES(i, b, N) * E(i)``). Then .. math:: \Lambda_{k,ib,mn} = \partial^\mathrm{sym}_{u_{mn}}Z^*_{k,ib} - \tfrac12\big(\delta_{im}Z^*_{k,nb} + \delta_{in}Z^*_{k,mb}\big), where the second term is the reduction :math:`F^{-1}`. :math:`Z^*` of the reference comes from ``--born-ref`` (the ``LEPSILON`` OUTCAR of the unstrained cell; its atoms are mapped onto the generated order, and another crystal or lattice is refused), otherwise from the mean of the 12 cells (:math:`O(h^2)`). The residual of the acoustic sum rule :math:`\sum_k\Lambda_k = 0` is printed, the atomic mean is subtracted, and the residual is stored in the attribute ``asr_residual_removed``. ``collect`` writes ``born_charge_strain_derivative``. * ``--route berry-lambda`` (4 SCF runs, ``LCALCPOL``): the independent check of one :math:`\Lambda` column. Atom ``--atom`` (1-based, POSCAR order) is displaced by :math:`\pm\delta` (Cartesian, added after straining) at strain :math:`\pm h` along ``--strain``; the mixed difference of :math:`\psi` gives :math:`\Lambda_{k,ib,mn}` for all :math:`i`. ``collect`` prints it next to the stored :math:`\Lambda` of ``--strain-file``. Check one diagonal and one shear component before trusting a DFPT :math:`\Lambda`. The 5-decimal dipole output limits the precision to roughly :math:`10^{-5}/(4\delta h)` e (0.01 e for the defaults :math:`\delta = 0.02` Å, :math:`h = 0.01`). Which route for which term: * :math:`B` **only from the Berry grid.** Differentiating the ``LEPSILON`` piezoelectric tensors of strained cells gives a :math:`B` that violates the :math:`(jk)\leftrightarrow(lm)` symmetry by up to 1.3 C/m² for ZnO; the reason is not understood. ``piezo.py`` never derives :math:`B` from the DFPT route (``collect --route dfpt --second-order`` is refused). * :math:`\Lambda` from the strained-cell DFPT Born charges. For BaTiO\ :sub:`3` it agrees with the ``berry-lambda`` mixed differences to about 1 % (e.g. :math:`\Lambda_{\mathrm{Ti},zz,zz} = -17.17` vs. :math:`-17.04`), and it reproduces the Berry-phase clamped-ion tensor of displaced structures through the exact identity (better than 1 %). Cross-check one component with ``berry-lambda`` for a new material. * :math:`e^{(0)}` **from the Berry grid for non-centrosymmetric structures.** The ``LEPSILON`` piezoelectric tensor of a structure with a polar distortion is unreliable: for BaTiO\ :sub:`3` with a displaced Ti it gets even the sign of :math:`\partial e_{33}/\partial u_0` wrong, while the Berry phase and the DFPT Born charges agree with each other. For polar ZnO the ``LEPSILON`` :math:`e^{(0)}` is about 1.1 × the Berry value. ``strainfile.py piezo --outcar`` is therefore meant for checks only; ``piezo.py collect --route berry`` writes :math:`e^{(0)}` together with :math:`B`. Cost: a few-atom primitive cell suffices. :math:`B` needs 73 small SCF runs (ZnO, 12³ k-points: about 20 min on one 32-core node); :math:`\Lambda` needs 12 DFPT runs (plus 4 SCF runs per checked component). A centrosymmetric reference (e.g. cubic BaTiO\ :sub:`3`) has :math:`e^{(0)} = B = 0` and needs only the DFPT route. ``collect`` maps the atoms onto the ``/ReferenceCell`` of ``--strain-file`` (a permutation, or a nested cell: copies for a larger reference cell, the average over translation-equivalent images for a smaller one) and replaces only the datasets it computes; an existing dataset needs ``--overwrite``. .. _label_strain_legacy_files: Legacy text layout (``STRAIN_IFC_DIR``) --------------------------------------- The text files are read from the directory given by ``STRAIN_IFC_DIR`` (except ``C1_array.in``, which is read from the working directory of anphon): .. list-table:: :header-rows: 1 :widths: 24 16 60 * - File - Tag - Content * - ``elastic_constants.in`` - ``STRAIN_COUPLING`` bit 1 - Second- and third-order elastic constants in GPa: a label with the unit token (``SOEC GPa``), 81 values :math:`C_{\mu_1\nu_1,\mu_2\nu_2}` in the full-index layout (:math:`i = 3\mu + \nu`, row-major), a label (``TOEC GPa``) and 729 values. anphon multiplies them by the volume of its primitive cell, so the file does not depend on the cell size (any nested ``&cell`` of the same reference crystal, in the same Cartesian frame and strain convention). Files without the unit token (the legacy layout) or with an explicit ``Ry`` token hold :math:`V C^{(2)}`, :math:`V C^{(3)}` in Ry for one specific cell; anphon cannot check that cell and warns when such a file is used together with a user-defined ``&cell``. * - ``C1_array.in`` (working directory) - always - Reference stress :math:`\sigma_{\mu\nu}` in GPa: ``C1 GPa`` followed by 9 values (row-major); files without the unit token (or with ``Ry``) hold :math:`V\sigma` in Ry for one specific cell. Zero when the file is absent. * - ``strain_force.in`` - ``STRAIN_COUPLING`` bit 2 - Forces (eV/Å) in strained cells, one block per strain mode: a header ``mode smag weight`` followed by one line ``fx fy fz`` per atom. An optional ``&reference_cell ... /`` header (see below) records the cell the rows belong to; without it the rows must follow the atom order of the anphon primitive cell. * - ``strain_harmonic.in`` + force-constant files - ``STRAIN_COUPLING`` bit 4 - One line ``mode smag weight filename`` per strained supercell; ``filename`` (relative to ``STRAIN_IFC_DIR``, ``.xml`` or ``.h5``) holds the harmonic force constants of the strained supercell in Ry/bohr\ :sup:`2`. The elastic constants are the Brugger constants, i.e. derivatives of the static energy with respect to the Green–Lagrange strain :math:`\eta = \mathrm{sym}(u) + \frac{1}{2} u u^{T}` of the deformation gradient :math:`F = I + u` (:math:`u` symmetric), and they must be the **clamped-ion** constants because anphon relaxes the internal coordinates explicitly. Strain modes are named ``xx, yy, zz, yz, zx, xy``; a mode ``yz`` with magnitude ``smag`` means :math:`u_{yz} = u_{zy} = \mathrm{smag}/2`. Weights of a mode must sum to 1 (one-sided differences: one line with weight 1; central differences: ``+smag`` and ``-smag`` with weight 0.5 each). Two Python scripts in the ``tools/`` directory prepare these files from DFT calculations (they need ``numpy``, ``ase`` and ``spglib``, and ``h5py`` for the strain-coupling container; ``strainifc.py --coupling harmonic`` additionally needs the ``alm`` Python package built from the ``python/`` directory): * ``elastic.py`` — finite-strain workflow for :math:`\sigma`, :math:`C^{(2)}` and :math:`C^{(3)}` (``elastic_constants.in``, ``C1_array.in``); the same runs also give the strain–force coupling (``strain_force.in``). * ``strainifc.py`` — strain–harmonic-IFC coupling (``strain_harmonic.in``) and, for runs without ``elastic.py``, the strain–force coupling (``strain_force.in``). This is a port of the `strainIFCcoupling `_ scripts by Ryota Masuki [Masuki2022]_ [Masuki2023]_ onto the in-tree ``alm`` package. Both follow the same pattern: ``generate`` writes the strained input structures (VASP ``POSCAR`` or Quantum-ESPRESSO ``pw.in``, taken from a template directory whose other files are copied), the user runs the DFT code in every directory (single-point calculations: fixed cell **and** fixed ions), and ``fit`` / ``collect`` read the outputs (``vasprun.xml`` / ``pw.out``) and write the anphon files into ``results/``. A JSON manifest written by ``generate`` carries all parameters, so nothing has to be re-typed. Every DFT output is checked against the generated structure (cell, species and fractional coordinates at the same index); relaxed geometries are rejected. Atom ordering ------------- The generated inputs and the force-constant files keep the order of the template structure. For ``--coupling harmonic`` the template must be the supercell of the force-constant file given to anphon: ``collect`` checks it index-wise against ``--fcs`` and checks every generated force-constant file for identical translation tables. The rows of ``strain_force.in``, on the other hand, refer to the atoms of anphon's primitive cell, i.e. the order obtained by folding the supercell of the force-constant file into the ``&cell`` lattice, keeping the first occurrence of every site (for ``.h5`` files without ``&cell``, the stored primitive cell). Give the reference force-constant file (``--fcs``, the ``FC2FILE``/``FCSFILE`` of the anphon run) and the anphon input (``--anphon-cell``) to ``collect``: the atoms of the DFT cell are matched by position to that cell, and the rows are written in anphon's order and preceded by an ``&reference_cell`` header that records that cell (a permuted template is reported as an error unless ``--reorder`` is given; for a conventional anphon cell the rows of the translation-equivalent atoms are duplicated, which requires the DFT setup to have the full translational symmetry — e.g. no magnetic order enlarging the cell; for a DFT supercell of the anphon cell one translation image per atom is used). ``strainifc.py check`` prints the full picture before any DFT calculation is run. The ``&reference_cell`` header of strain_force.in ------------------------------------------------- ``strain_force.in`` holds one force row per atom, so by itself it is tied to the atom list of the cell the strained calculations were done for. ``strainifc.py collect --fcs ...`` therefore records that cell at the top of the file:: &reference_cell 1.889726124625770 3.235859326375770 0.000000000000000 0.000000000000000 -1.617929663187880 2.802336379714220 0.000000000000000 0.000000000000000 0.000000000000000 5.224712025937350 4 Zn 0.333333333333333 0.666666666666667 0.000000000000000 Zn 0.666666666666667 0.333333333333333 0.500000000000000 O 0.333333333333333 0.666666666666667 0.381500000000000 O 0.666666666666667 0.333333333333333 0.881500000000000 / xx 0.005 1.0 ... i.e. a scale factor and three lattice vectors (one per line) as in the ``&cell`` field (here Å converted to bohr), the number of atoms, one line ``symbol x y z`` per atom in fractional coordinates, and a closing ``/``. No comments are allowed anywhere in the file: anphon reads it as a plain stream of tokens. With the header, anphon compares this cell with its own primitive cell (the ``&cell`` field) and matches the atoms by position, so the row order in the file does not matter. If the anphon cell is an integer supercell of the reference cell — for instance an enlarged ``&cell`` chosen to condense a zone-boundary instability — every row is copied onto the translation images of its atom; if it is a sub-cell, the images are averaged (a warning reports their spread when it exceeds 1e-8 eV/Å). The two cells must describe the same crystal in the same Cartesian frame, and one must be an integer supercell of the other: rotated settings and commensurate but non-nested cells, inconsistent atom counts and atoms without a counterpart are rejected with an explicit message. anphon logs the atom counts and the volume ratio of the mapping it applied. Without the header the rows must follow the atom order of the anphon primitive cell. ``elastic_constants.in`` and ``C1_array.in`` need no such header: written in GPa they do not depend on the cell size (the reference structure and the Cartesian frame must of course be the same), and anphon multiplies them by the volume of its own primitive cell. elastic.py ---------- :: elastic.py generate --code {VASP,QE} --template DIR [--smag 0.01] [--nmag 2] [--dirset {minimal,full}] [--outdir DIR] [--job-template job.sh] [--dft-command DFT_command.sh] [--force] elastic.py fit [--outdir DIR] [--fit {stress,energy,both}] [--fcs REF] [--anphon-cell FILE] [--no-symmetrize] [--symprec 1e-5] [--compare anphon.log] [--exclude strain_NNN,...] [--strain-file FILE.h5 [--force]] elastic.py show elastic_constants.in [--structure FILE | --volume V_A3] [--c1 C1_array.in] ``generate`` creates the unstrained reference ``strain_000`` and strained cells :math:`u = k\,s\,d` for :math:`k = \pm 1, \ldots, \pm n_\mathrm{mag}` along a set of directions :math:`d` in the six-dimensional strain space: ``minimal`` (6 single + 15 pair directions, 85 calculations with the defaults) determines all constants from the stresses; ``full`` (56 directions, 225 calculations) is required when only energies are fitted. ``fit`` builds the second Piola–Kirchhoff stress :math:`S = \det(F) F^{-1}\sigma F^{-T}` from the DFT (Cauchy) stress and solves the linear least-squares problem :math:`S(\eta) = \sigma_0 + C^{(2)}\eta + \frac{1}{2}C^{(3)}\eta\eta` (and/or the energy expansion) for the 83 independent Voigt components, symmetrizes the tensors over the point group of the reference structure, prints the constants in GPa and writes the files in GPa (unit token ``GPa`` after each label), which makes them independent of the size of the cell anphon uses (they still refer to the DFT reference structure and its Cartesian frame). ``--fcs``/``--anphon-cell`` are optional and only report how the anphon cell relates to the DFT cell; when given, the two cells must be commensurate in the same Cartesian frame: one must be an integer combination of the lattice vectors of the other (a conventional anphon cell and a primitive DFT cell, or the reverse); rotated settings are rejected. ``--compare`` prints the difference to the clamped-ion constants that anphon prints when it computes them from the IFCs (``STRAIN_COUPLING`` bit 1 clear). The forces of the reference and of the single-mode runs at :math:`k = \pm 1` are the central-difference strain–force coupling (weights 1/2), written as ``strain_force.in`` next to the elastic files (rows in anphon's order with the ``&reference_cell`` header when ``--fcs`` is given, as ``strainifc.py collect --coupling force`` does). ``--strain-file`` additionally writes the reference stress and the constants (``/Elastic``) and the strain–force coupling (``/StrainForce``) into the strain-coupling container; with ``--fcs``/``--anphon-cell`` the container is labeled with the anphon primitive cell after the DFT reference structure has been verified to be that crystal. ``show`` prints any ``elastic_constants.in`` in GPa; ``--structure``/``--volume`` are needed only for legacy files holding :math:`V C` in Ry. strainifc.py ------------ :: strainifc.py generate --coupling {harmonic,force} --code {VASP,QE} --template DIR [--smag 0.005] [--dmag 0.01] [--central] [--no-offset] [--with-reference] [--modes strain_modes.json | --modes xx,yy,...] [--outdir DIR] [--nbody 2] [--cutoff R] [--job-template job.sh] [--dft-command FILE] strainifc.py collect [--outdir DIR] [--fcs REF [--anphon-cell FILE]] [--fcs-format {xml,h5}] [--prefix strain] [--reorder] [--write-dfset] [--unchecked] [--strain-file FILE.h5 [--force]] strainifc.py check [--outdir DIR] --fcs REF [--anphon-cell FILE] ``--fcs`` is mandatory for ``--coupling harmonic`` (unless ``--unchecked``); for ``--coupling force`` it is optional but recommended: without it the rows are written in the order of the template, which must then be anphon's order. ``--anphon-cell`` is required with an XML ``--fcs`` (anphon needs ``&cell`` for XML force-constant files). * ``--coupling force`` (only needed when ``elastic.py fit`` is not run, e.g. with ``STRAIN_COUPLING = 6``): the template is the primitive cell. ``strain_000/primitive`` (reference) and ``strain_NNN/primitive`` (strained cells) are generated; ``collect`` subtracts the reference forces and writes ``strain_force.in`` in anphon's atom order, with the ``&reference_cell`` header when ``--fcs`` is given (and ``/StrainForce`` of the container with ``--strain-file``). All six strain modes are required (anphon demands that the weights of every component sum to 1); ``--modes`` subsets are only meaningful for ``--coupling harmonic`` (anphon completes the missing components by symmetry). Use ``--central``: the one-sided difference can bias the thermal expansion noticeably (by about 10 percent for the c axis of ZnO at 1000 K). * ``--coupling harmonic``: the template is the **same supercell** as the one used to fit the harmonic force constants given to anphon. For every strained supercell the ALM displacement patterns are generated (``strain_NNN/disp_MM``), plus the undisplaced strained cell (``strain_NNN/nodisp``) whose residual forces are subtracted unless ``--no-offset`` is given. ``collect`` fits the harmonic force constants of every strained supercell with the ``alm`` package (translational invariance imposed), writes them as ``results/strain_NNN.xml`` (or ``.h5``) and ``results/strain_harmonic.in``; with ``--strain-file`` (which requires ``--fcs-format h5``) the fitted force constants are embedded in ``/StrainHarmonic`` of the container. With ``--with-reference`` the undeformed supercell is generated as well (``strain_000``); ``collect`` fits it to ``results/strain_000.*`` (not listed in ``strain_harmonic.in``) and prints its difference to ``--fcs`` — a direct check that the DFT setup reproduces the harmonic force constants given to anphon. A job-script template containing the line ``RUN_DFT_CALCULATION`` (``--job-template``) and a file with the shell lines that run the DFT code in one directory (``--dft-command``) produce ``job.sh`` files in the same way as the original strainIFCcoupling scripts; without them a plain ``run_all.sh`` loop is written. Template inputs for wurtzite ZnO are provided in ``example/ZnO/strain_IFC_workflow``.