Skip to content

Commit

Permalink
Convert supercell CLI option to tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
ElliottKasoar committed Oct 2, 2024
1 parent e7d8222 commit 1266fe5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
6 changes: 3 additions & 3 deletions docs/source/user_guide/command_line.rst
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ Calculate phonons with a 2x2x2 supercell, after geometry optimization (using the

.. code-block:: bash
janus phonons --struct tests/data/NaCl.cif --supercell 2x2x2 --minimize --arch mace_mp --model-path small
janus phonons --struct tests/data/NaCl.cif --supercell 2 2 2 --minimize --arch mace_mp --model-path small
This will save the Phonopy parameters, including displacements and force constants, to ``NaCl-phonopy.yml`` and ``NaCl-force_constants.hdf5``,
Expand All @@ -324,7 +324,7 @@ Additionally, the ``--bands`` option can be added to calculate the band structur

.. code-block:: bash
janus phonons --struct tests/data/NaCl.cif --supercell 2x2x2 --minimize --arch mace_mp --model-path small --bands
janus phonons --struct tests/data/NaCl.cif --supercell 2 2 2 --minimize --arch mace_mp --model-path small --bands
If you need eigenvectors and group velocities written, add the ``--write-full`` option. This will generate a much larger file, but can be used to visualise phonon modes.
Expand All @@ -333,7 +333,7 @@ Further calculations, including thermal properties, DOS, and PDOS, can also be c

.. code-block:: bash
janus phonons --struct tests/data/NaCl.cif --supercell 2x3x4 --dos --pdos --thermal --temp-start 0 --temp-end 300 --temp-step 50
janus phonons --struct tests/data/NaCl.cif --supercell 2 3 4 --dos --pdos --thermal --temp-start 0 --temp-end 300 --temp-step 50
This will create additional output files: ``NaCl-thermal.dat`` for the thermal properties (heat capacity, entropy, and free energy)
Expand Down
20 changes: 4 additions & 16 deletions janus_core/cli/phonons.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def phonons(
ctx: Context,
struct: StructPath,
supercell: Annotated[
str, Option(help="Supercell lattice vectors in the form '1x2x3'.")
] = "2x2x2",
tuple[int, int, int], Option(help="Supercell lattice vectors.")
] = (2, 2, 2),
displacement: Annotated[
float, Option(help="Displacement for force constants calculation, in A.")
] = 0.01,
Expand Down Expand Up @@ -122,9 +122,8 @@ def phonons(
Typer (Click) Context. Automatically set.
struct : Path
Path of structure to simulate.
supercell : str
Supercell lattice vectors. Must be passed in the form '1x2x3'. Default is
2x2x2.
supercell : tuple[int, int, int]
Supercell lattice vectors. Default is (2, 2, 2).
displacement : float
Displacement for force constants calculation, in A. Default is 0.01.
mesh : tuple[int, int, int]
Expand Down Expand Up @@ -200,17 +199,6 @@ def phonons(
raise ValueError("'fmax' must be passed through the --fmax option")
minimize_kwargs["fmax"] = fmax

try:
supercell = [int(x) for x in supercell.split("x")]
except ValueError as exc:
raise ValueError(
"Please pass lattice vectors as integers in the form 1x2x3"
) from exc

# Validate supercell list
if len(supercell) != 3:
raise ValueError("Please pass three lattice vectors in the form 1x2x3")

calcs = []
if bands:
calcs.append("bands")
Expand Down

0 comments on commit 1266fe5

Please sign in to comment.