Open In Colab

Phonons

janus-core contains an interface to phonopy to compute phonons and ready made workflows these calculations.

Set up environment (optional)

These steps are required for Google Colab, but may work on other systems too:

[1]:
# import locale
# locale.getpreferredencoding = lambda: "UTF-8"

# ! pip uninstall torch torchaudio torchvision transformers numpy -y
# ! uv pip install janus-core[all] data-tutorials torch==2.5.1 --system
# get_ipython().kernel.do_shutdown(restart=True)

Use data_tutorials to get the data required for this tutorial:

[2]:
from data_tutorials.data import get_data

get_data(
    url="https://raw.githubusercontent.com/stfc/janus-core/main/docs/source/tutorials/data/",
    filename=["NaCl.cif"],
    folder="../data",
)
try to download NaCl.cif from https://raw.githubusercontent.com/stfc/janus-core/main/docs/source/tutorials/data/ and save it in ../data/NaCl.cif
saved in ../data/NaCl.cif

view the data

[3]:
from ase.io import read
from weas_widget import WeasWidget

NaCl = read("../data/NaCl.cif")
print(NaCl.cell)
v=WeasWidget()
v.from_ase(NaCl)
v.avr.model_style = 1
v
Cell([5.63, 5.63, 5.63])
[3]:

Command-line help and options

Once janus-core is installed, the janus phonons command should be available. You may want to execute it in a real terminal to see all the options.

[4]:
! janus phonons --help
                                                                                
 Usage: janus phonons [OPTIONS]                                                 
                                                                                
 Calculate phonons and save results.


╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --config        TEXT  Path to configuration file.                            │
│ --help                Show this message and exit.                            │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ MLIP calculator ────────────────────────────────────────────────────────────╮
│ *  --arch               [mace|mace_mp|mace_off|m  MLIP architecture to use   │
│                         3gnet|chgnet|alignn|seve  for calculations.          │
│                         nnet|nequip|dpa3|orb|mat  [required]                 │
│                         tersim|grace|esen|equifo                             │
│                         rmer]                                                │
│    --device             [cpu|cuda|mps|xpu]        Device to run calculations │
│                                                   on.                        │
│                                                   [default: cpu]             │
│    --model              TEXT                      MLIP model name, or path   │
│                                                   to model.                  │
│                                                   [default: None]            │
│    --model-path         TEXT                      Deprecated. Please use     │
│                                                   --model                    │
│                                                   [default: None]            │
│    --calc-kwargs        DICT                      Keyword arguments to pass  │
│                                                   to selected calculator.    │
│                                                   Must be passed as a        │
│                                                   dictionary wrapped in      │
│                                                   quotes, e.g. "{'key':      │
│                                                   value}".                   │
│                                                   [default: None]            │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Calculation ────────────────────────────────────────────────────────────────╮
│ *  --struct                               PATH             Path of structure │
│                                                            to simulate.      │
│                                                            [required]        │
│    --supercell                            TEXT             Supercell matrix, │
│                                                            in the Phonopy    │
│                                                            style. Must be    │
│                                                            passed as a       │
│                                                            string in one of  │
│                                                            three forms:      │
│                                                            single integer    │
│                                                            ('2'), which      │
│                                                            specifies all     │
│                                                            diagonal          │
│                                                            elements; three   │
│                                                            integers ('1 2    │
│                                                            3'), which        │
│                                                            specifies each    │
│                                                            individual        │
│                                                            diagonal element; │
│                                                            or nine values    │
│                                                            ('1 2 3 4 5 6 7 8 │
│                                                            9'), which        │
│                                                            specifies all     │
│                                                            elements, filling │
│                                                            the matrix        │
│                                                            row-wise.         │
│                                                            [default: 2 2 2]  │
│    --displacement                         FLOAT            Displacement for  │
│                                                            force constants   │
│                                                            calculation, in   │
│                                                            A.                │
│                                                            [default: 0.01]   │
│    --displacement                        DICT             Keyword arguments │
│                                                            to pass to        │
│                                                            generate_displac… │
│                                                            Must be passed as │
│                                                            a dictionary      │
│                                                            wrapped in        │
│                                                            quotes, e.g.      │
│                                                            "{'key' :         │
│                                                            value}".          │
│                                                            [default: None]   │
│    --mesh                                 <INTEGER         Mesh numbers      │
│                                           INTEGER          along a, b, c     │
│                                           INTEGER>...      axes.             │
│                                                            [default: 10, 10, │
│                                                            10]               │
│    --bands            --no-bands                           Whether to        │
│                                                            compute band      │
│                                                            structure.        │
│                                                            [default:         │
│                                                            no-bands]         │
│    --n-qpoints                            INTEGER          Number of         │
│                                                            q-points to       │
│                                                            sample along      │
│                                                            generated path,   │
│                                                            including end     │
│                                                            points. Unused if │
│                                                            `qpoint_file` is  │
│                                                            specified         │
│                                                            [default: 51]     │
│    --qpoint-file                          PATH             Path to yaml file │
│                                                            with info to      │
│                                                            generate a path   │
│                                                            of q-points for   │
│                                                            band structure.   │
│                                                            [default: None]   │
│    --symmetrize       --no-symmetrize                      Whether to        │
│                                                            symmetrize force  │
│                                                            constants.        │
│                                                            [default:         │
│                                                            no-symmetrize]    │
│    --minimize         --no-minimize                        Whether to        │
│                                                            minimize          │
│                                                            structure before  │
│                                                            calculations.     │
│                                                            [default:         │
│                                                            no-minimize]      │
│    --fmax                                 FLOAT            Maximum force for │
│                                                            optimization      │
│                                                            convergence.      │
│                                                            [default: 0.1]    │
│    --minimize-kwa…                        DICT             Keyword arguments │
│                                                            to pass to        │
│                                                            optimizer. Must   │
│                                                            be passed as a    │
│                                                            dictionary        │
│                                                            wrapped in        │
│                                                            quotes, e.g.      │
│                                                            "{'key': value}". │
│                                                            [default: None]   │
│    --hdf5             --no-hdf5                            Whether to save   │
│                                                            force constants   │
│                                                            in hdf5.          │
│                                                            [default: hdf5]   │
│    --plot-to-file     --no-plot-to-fi…                     Whether to plot   │
│                                                            band structure    │
│                                                            and/or dos/pdos   │
│                                                            when calculated.  │
│                                                            [default:         │
│                                                            no-plot-to-file]  │
│    --write-full       --no-write-full                      Whether to write  │
│                                                            eigenvectors,     │
│                                                            group velocities, │
│                                                            etc. to bands     │
│                                                            file.             │
│                                                            [default:         │
│                                                            write-full]       │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ DOS ────────────────────────────────────────────────────────────────────────╮
│ --dos           --no-dos          Whether to calculate the DOS.              │
│                                   [default: no-dos]                          │
│ --dos-kwargs                DICT  Keyword arguments to pass to               │
│                                   `run_total_dos`. Must be passed as a       │
│                                   dictionary wrapped in quotes, e.g. "{'key' │
│                                   : value}".                                 │
│                                   [default: None]                            │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ PDOS ───────────────────────────────────────────────────────────────────────╮
│ --pdos           --no-pdos          Whether to calculate the PDOS.           │
│                                     [default: no-pdos]                       │
│ --pdos-kwargs                 DICT  Keyword arguments to pass to             │
│                                     `run_projected_dos`. Must be passed as a │
│                                     dictionary wrapped in quotes, e.g.       │
│                                     "{'key' : value}".                       │
│                                     [default: None]                          │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Thermal properties ─────────────────────────────────────────────────────────╮
│ --thermal      --no-thermal           Whether to calculate thermal           │
│                                       properties.                            │
│                                       [default: no-thermal]                  │
│ --temp-min                     FLOAT  Start temperature for thermal          │
│                                       properties calculations, in K.         │
│                                       [default: 0.0]                         │
│ --temp-max                     FLOAT  End temperature for thermal properties │
│                                       calculations, in K.                    │
│                                       [default: 1000.0]                      │
│ --temp-step                    FLOAT  Temperature step for thermal           │
│                                       properties calculations, in K.         │
│                                       [default: 50]                          │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Structure I/O ──────────────────────────────────────────────────────────────╮
│ --file-prefix        PATH  Prefix for output files, including directories.   │
│                            Default directory is ./janus_results, and default │
│                            filename prefix is inferred from the input        │
│                            stucture filename.                                │
│                            [default: None]                                   │
│ --read-kwargs        DICT  Keyword arguments to pass to ase.io.read. Must be │
│                            passed as a dictionary wrapped in quotes, e.g.    │
│                            "{'key': value}". By default,                     │
│                            read_kwargs['index'] = -1, so only the last       │
│                            structure is read.                                │
│                            [default: None]                                   │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Logging/summary ────────────────────────────────────────────────────────────╮
│ --log                                  PATH  Path to save logs to. Default   │
│                                              is inferred from `file_prefix`  │
│                                              [default: None]                 │
│ --tracker         --no-tracker               Whether to save carbon          │
│                                              emissions of calculation        │
│                                              [default: tracker]              │
│ --summary                              PATH  Path to save summary of inputs, │
│                                              start/end time, and carbon      │
│                                              emissions. Default is inferred  │
│                                              from `file_prefix`.             │
│                                              [default: None]                 │
│ --progress-bar    --no-progress-bar          Whether to show progress bar.   │
│                                              [default: progress-bar]         │
╰──────────────────────────────────────────────────────────────────────────────╯

simple calculation

start by creating a config for the calculations. In this we performs

  • geometry optimisation

  • force constants calculations

  • band structure (on a path determined by seekpath)

  • density of states calculation

[5]:
%%writefile phonons.yml

supercell: 2 2 2
displacement: 0.001
fmax: 1.0e-6
bands: True
dos: True
minimize: True
minimize-kwargs:
  write_results: True
arch: mace_mp
write-full: False
plot-to-file: True
calc-kwargs:
    model:  medium-mpa-0
device: cpu
tracker: False
Writing phonons.yml

now run the calculation itself

[6]:
! janus phonons --config phonons.yml --struct ../data/NaCl.cif
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/e3nn/o3/_wigner.py:10: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  _Jd, _W3j_flat, _W3j_indices = torch.load(os.path.join(os.path.dirname(__file__), 'constants.pt'))
cuequivariance or cuequivariance_torch is not available. Cuequivariance acceleration will be disabled.
Using medium MPA-0 model as default MACE-MP model, to use previous (before 3.10) default model please specify 'medium' as model argument
Downloading MACE model from 'https://github.com/ACEsuit/mace-mp/releases/download/mace_mpa_0/mace-mpa-0-medium.model'
Cached MACE model to /home/runner/.cache/mace/macempa0mediummodel
Using Materials Project MACE for MACECalculator with /home/runner/.cache/mace/macempa0mediummodel
Using float64 for MACECalculator, which is slower but more accurate. Recommended for geometry optimization.
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/mace/calculators/mace.py:143: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  torch.load(f=model_path, map_location=device)
Using head default out of ['default']
       Step     Time          Energy          fmax
LBFGS:    0 14:33:41      -27.068017        0.139945
LBFGS:    1 14:33:42      -27.068849        0.137428
LBFGS:    2 14:33:42      -27.092226        0.007598
LBFGS:    3 14:33:42      -27.092302        0.000368
LBFGS:    4 14:33:43      -27.092303        0.000001
Computing displacements... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2/2 0:00:00

explore the results

[7]:
!ls janus_results/
NaCl-1040-npt-T1040.0-T1080.0-p0.0-final.extxyz
NaCl-1040-npt-T1040.0-T1080.0-p0.0-md-log.yml
NaCl-1040-npt-T1040.0-T1080.0-p0.0-md-summary.yml
NaCl-1040-npt-T1040.0-T1080.0-p0.0-stats.dat
NaCl-1040-npt-T1040.0-T1080.0-p0.0-traj.extxyz
NaCl-auto_bands.yml.xz
NaCl-bands.svg
NaCl-bs-dos.svg
NaCl-deformed-geomopt-log.yml
NaCl-deformed-geomopt-summary.yml
NaCl-deformed-opt.extxyz
NaCl-deformed-traj.extxyz
NaCl-dos.dat
NaCl-dos.svg
NaCl-force_constants.hdf5
NaCl-mace-geomopt-log.yml
NaCl-mace-geomopt-summary.yml
NaCl-mace-opt.extxyz
NaCl-nvt-T100.0-cor.dat
NaCl-nvt-T100.0-final.extxyz
NaCl-nvt-T100.0-md-log.yml
NaCl-nvt-T100.0-md-summary.yml
NaCl-nvt-T100.0-res-100.extxyz
NaCl-nvt-T100.0-res-150.extxyz
NaCl-nvt-T100.0-res-200.extxyz
NaCl-nvt-T100.0-res-250.extxyz
NaCl-nvt-T100.0-res-300.extxyz
NaCl-nvt-T100.0-res-50.extxyz
NaCl-nvt-T100.0-stats.dat
NaCl-nvt-T100.0-traj.extxyz
NaCl-opt.extxyz
NaCl-phonons-log.yml
NaCl-phonons-summary.yml
NaCl-phonopy.yml
NaCl-sevennet-geomopt-log.yml
NaCl-sevennet-geomopt-summary.yml
NaCl-sevennet-opt.extxyz
ethanol_products-final-opt.extxyz
ethanol_products_1water-final-opt.extxyz
ethanol_products_2water-final-opt.extxyz
ethanol_reactants-init-opt.extxyz
ethanol_reactants-neb-band.extxyz
ethanol_reactants-neb-log.yml
ethanol_reactants-neb-plot.svg
ethanol_reactants-neb-results.dat
ethanol_reactants-neb-summary.yml
ethanol_reactants_1water-init-opt.extxyz
ethanol_reactants_1water-neb-band.extxyz
ethanol_reactants_1water-neb-log.yml
ethanol_reactants_1water-neb-plot.svg
ethanol_reactants_1water-neb-results.dat
ethanol_reactants_1water-neb-summary.yml
ethanol_reactants_2water-init-opt.extxyz
ethanol_reactants_2water-neb-band.extxyz
ethanol_reactants_2water-neb-log.yml
ethanol_reactants_2water-neb-plot.svg
ethanol_reactants_2water-neb-results.dat
ethanol_reactants_2water-neb-summary.yml
[8]:
from IPython.display import SVG, display

NaCl_opt = read("janus_results/NaCl-opt.extxyz")
print(NaCl_opt.cell)
display(SVG("janus_results/NaCl-bands.svg"))
display(SVG("janus_results/NaCl-dos.svg"))
Cell([[5.713563543365227, -1.5749646114348606e-13, -1.6437741235132155e-13], [-8.842538875526146e-14, 5.713563543365362, 1.1281619483733187e-13], [-8.496298352540394e-14, 1.261053187634596e-13, 5.713563543365368]])
../../_images/tutorials_cli_phonons_18_1.svg
../../_images/tutorials_cli_phonons_18_2.svg

advanced options

we compute thermal properties and also we specify the granularity of the DOS

[9]:
%%writefile phonons-adv.yml

supercell: 2 2 2
displacement: 0.001
fmax: 1.0e-6
thermal: True
temp-min: 0
temp-max: 1000
temp-step: 10
bands: True
dos: True
pdos: False
dos-kwargs:
  freq_pitch: 0.05
mesh: [11,11,11]
minimize: True
minimize-kwargs:
  write_results: True
arch: mace_mp
write-full: False
plot-to-file: True
calc-kwargs:
    dispersion: False
    skin: 0
    model:  medium-mpa-0
device: cpu
tracker: False
Writing phonons-adv.yml
[10]:
! janus phonons --config phonons-adv.yml --struct ../data/NaCl.cif
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/e3nn/o3/_wigner.py:10: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  _Jd, _W3j_flat, _W3j_indices = torch.load(os.path.join(os.path.dirname(__file__), 'constants.pt'))
cuequivariance or cuequivariance_torch is not available. Cuequivariance acceleration will be disabled.
Using medium MPA-0 model as default MACE-MP model, to use previous (before 3.10) default model please specify 'medium' as model argument
Using Materials Project MACE for MACECalculator with /home/runner/.cache/mace/macempa0mediummodel
Using float64 for MACECalculator, which is slower but more accurate. Recommended for geometry optimization.
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/mace/calculators/mace.py:143: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  torch.load(f=model_path, map_location=device)
Using head default out of ['default']
       Step     Time          Energy          fmax
LBFGS:    0 14:33:52      -27.068017        0.139945
LBFGS:    1 14:33:52      -27.068849        0.137428
LBFGS:    2 14:33:53      -27.092226        0.007598
LBFGS:    3 14:33:53      -27.092302        0.000368
LBFGS:    4 14:33:53      -27.092303        0.000001
Computing displacements... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2/2 0:00:00

[11]:
!ls janus_results/
NaCl-1040-npt-T1040.0-T1080.0-p0.0-final.extxyz
NaCl-1040-npt-T1040.0-T1080.0-p0.0-md-log.yml
NaCl-1040-npt-T1040.0-T1080.0-p0.0-md-summary.yml
NaCl-1040-npt-T1040.0-T1080.0-p0.0-stats.dat
NaCl-1040-npt-T1040.0-T1080.0-p0.0-traj.extxyz
NaCl-auto_bands.yml.xz
NaCl-bands.svg
NaCl-bs-dos.svg
NaCl-deformed-geomopt-log.yml
NaCl-deformed-geomopt-summary.yml
NaCl-deformed-opt.extxyz
NaCl-deformed-traj.extxyz
NaCl-dos.dat
NaCl-dos.svg
NaCl-force_constants.hdf5
NaCl-mace-geomopt-log.yml
NaCl-mace-geomopt-summary.yml
NaCl-mace-opt.extxyz
NaCl-nvt-T100.0-cor.dat
NaCl-nvt-T100.0-final.extxyz
NaCl-nvt-T100.0-md-log.yml
NaCl-nvt-T100.0-md-summary.yml
NaCl-nvt-T100.0-res-100.extxyz
NaCl-nvt-T100.0-res-150.extxyz
NaCl-nvt-T100.0-res-200.extxyz
NaCl-nvt-T100.0-res-250.extxyz
NaCl-nvt-T100.0-res-300.extxyz
NaCl-nvt-T100.0-res-50.extxyz
NaCl-nvt-T100.0-stats.dat
NaCl-nvt-T100.0-traj.extxyz
NaCl-opt.extxyz
NaCl-phonons-log.yml
NaCl-phonons-summary.yml
NaCl-phonopy.yml
NaCl-sevennet-geomopt-log.yml
NaCl-sevennet-geomopt-summary.yml
NaCl-sevennet-opt.extxyz
NaCl-thermal.yml
ethanol_products-final-opt.extxyz
ethanol_products_1water-final-opt.extxyz
ethanol_products_2water-final-opt.extxyz
ethanol_reactants-init-opt.extxyz
ethanol_reactants-neb-band.extxyz
ethanol_reactants-neb-log.yml
ethanol_reactants-neb-plot.svg
ethanol_reactants-neb-results.dat
ethanol_reactants-neb-summary.yml
ethanol_reactants_1water-init-opt.extxyz
ethanol_reactants_1water-neb-band.extxyz
ethanol_reactants_1water-neb-log.yml
ethanol_reactants_1water-neb-plot.svg
ethanol_reactants_1water-neb-results.dat
ethanol_reactants_1water-neb-summary.yml
ethanol_reactants_2water-init-opt.extxyz
ethanol_reactants_2water-neb-band.extxyz
ethanol_reactants_2water-neb-log.yml
ethanol_reactants_2water-neb-plot.svg
ethanol_reactants_2water-neb-results.dat
ethanol_reactants_2water-neb-summary.yml
[12]:
from IPython.display import SVG, display
display(SVG("janus_results/NaCl-bands.svg"))
display(SVG("janus_results/NaCl-dos.svg"))
../../_images/tutorials_cli_phonons_23_0.svg
../../_images/tutorials_cli_phonons_23_1.svg

phonons under pressure

[13]:
%%writefile phonons-pressure.yml

supercell: 2 2 2
displacement: 0.001
fmax: 1.0e-6
thermal: True
temp-min: 0
temp-max: 1000
temp-step: 10
bands: True
dos: True
pdos: False
dos-kwargs:
  freq_pitch: 0.05
mesh: [11,11,11]
minimize: True
minimize-kwargs:
  write_results: True
  filter_kwargs:
      scalar_pressure: 1.0
arch: mace_mp
write-full: False
plot-to-file: True
calc-kwargs:
    dispersion: False
    skin: 0
    model:  medium-mpa-0
device: cpu
tracker: False
Writing phonons-pressure.yml
[14]:
! janus phonons --config phonons-pressure.yml --struct ../data/NaCl.cif
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/e3nn/o3/_wigner.py:10: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  _Jd, _W3j_flat, _W3j_indices = torch.load(os.path.join(os.path.dirname(__file__), 'constants.pt'))
cuequivariance or cuequivariance_torch is not available. Cuequivariance acceleration will be disabled.
Using medium MPA-0 model as default MACE-MP model, to use previous (before 3.10) default model please specify 'medium' as model argument
Using Materials Project MACE for MACECalculator with /home/runner/.cache/mace/macempa0mediummodel
Using float64 for MACECalculator, which is slower but more accurate. Recommended for geometry optimization.
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/mace/calculators/mace.py:143: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  torch.load(f=model_path, map_location=device)
Using head default out of ['default']
       Step     Time          Energy          fmax
LBFGS:    0 14:34:02      -25.954198        0.000718
LBFGS:    1 14:34:03      -25.954198        0.000704
LBFGS:    2 14:34:03      -25.954198        0.000000
Computing displacements... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2/2 0:00:00

[15]:
from IPython.display import SVG, display
display(SVG("janus_results/NaCl-bands.svg"))
display(SVG("janus_results/NaCl-dos.svg"))
../../_images/tutorials_cli_phonons_27_0.svg
../../_images/tutorials_cli_phonons_27_1.svg

isotropic optimisation of the cell

[16]:
%%writefile phonons-iso.yml

supercell: 2 2 2
displacement: 0.001
fmax: 1.0e-6
thermal: True
temp-min: 0
temp-max: 1000
temp-step: 10
bands: True
dos: True
pdos: False
dos-kwargs:
  freq_pitch: 0.05
mesh: [11,11,11]
minimize: True
minimize-kwargs:
  write_results: True
  filter_kwargs:
    hydrostatic_strain: True
arch: mace_mp
write-full: False
plot-to-file: True
calc-kwargs:
    dispersion: False
    skin: 0
    model:  medium-mpa-0
device: cpu
tracker: False
Writing phonons-iso.yml
[17]:
!janus phonons --config phonons-iso.yml --struct ../data/NaCl.cif
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/e3nn/o3/_wigner.py:10: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  _Jd, _W3j_flat, _W3j_indices = torch.load(os.path.join(os.path.dirname(__file__), 'constants.pt'))
cuequivariance or cuequivariance_torch is not available. Cuequivariance acceleration will be disabled.
Using medium MPA-0 model as default MACE-MP model, to use previous (before 3.10) default model please specify 'medium' as model argument
Using Materials Project MACE for MACECalculator with /home/runner/.cache/mace/macempa0mediummodel
Using float64 for MACECalculator, which is slower but more accurate. Recommended for geometry optimization.
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/mace/calculators/mace.py:143: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  torch.load(f=model_path, map_location=device)
Using head default out of ['default']
       Step     Time          Energy          fmax
LBFGS:    0 14:34:12      -27.068017        0.139945
LBFGS:    1 14:34:13      -27.068849        0.137428
LBFGS:    2 14:34:13      -27.092226        0.007598
LBFGS:    3 14:34:13      -27.092302        0.000368
LBFGS:    4 14:34:14      -27.092303        0.000001
Computing displacements... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2/2 0:00:00

[18]:
from IPython.display import SVG, display
display(SVG("janus_results/NaCl-bands.svg"))
display(SVG("janus_results/NaCl-dos.svg"))
../../_images/tutorials_cli_phonons_31_0.svg
../../_images/tutorials_cli_phonons_31_1.svg

using a path for band structure

download mof-5.cif and paths.yaml from examples folder

[19]:
get_data(
    url="https://raw.githubusercontent.com/stfc/janus-core/main/docs/source/tutorials/data/",
    filename=["mof-5.cif", "paths.yaml"],
    folder="../data",
)
try to download mof-5.cif from https://raw.githubusercontent.com/stfc/janus-core/main/docs/source/tutorials/data/ and save it in ../data/mof-5.cif
saved in ../data/mof-5.cif
try to download paths.yaml from https://raw.githubusercontent.com/stfc/janus-core/main/docs/source/tutorials/data/ and save it in ../data/paths.yaml
saved in ../data/paths.yaml
[20]:
mof5 = read("../data/mof-5.cif")
v=WeasWidget()
v.from_ase(mof5)
v.avr.model_style = 1
v
[20]:
[21]:
%%writefile phonons-mof5.yml

supercell: 1 1 1
displacement: 0.001
fmax: 1.0e-6
thermal: True
temp-min: 0
temp-max: 1000
temp-step: 10
bands: True
dos: True
pdos: False
dos-kwargs:
  freq_pitch: 0.05
mesh: [11,11,11]
minimize: True
minimize-kwargs:
  write_results: True
arch: mace_mp
write-full: False
plot-to-file: True
calc-kwargs:
    dispersion: False
    skin: 0
    model:  medium-mpa-0
device: cpu
tracker: False
Writing phonons-mof5.yml

please note parameters here are chosen for speed rather than correctness

[22]:
! janus phonons --config phonons-mof5.yml --struct ../data/mof-5.cif
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/e3nn/o3/_wigner.py:10: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  _Jd, _W3j_flat, _W3j_indices = torch.load(os.path.join(os.path.dirname(__file__), 'constants.pt'))
cuequivariance or cuequivariance_torch is not available. Cuequivariance acceleration will be disabled.
Using medium MPA-0 model as default MACE-MP model, to use previous (before 3.10) default model please specify 'medium' as model argument
Using Materials Project MACE for MACECalculator with /home/runner/.cache/mace/macempa0mediummodel
Using float64 for MACECalculator, which is slower but more accurate. Recommended for geometry optimization.
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/mace/calculators/mace.py:143: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  torch.load(f=model_path, map_location=device)
Using head default out of ['default']
       Step     Time          Energy          fmax
LBFGS:    0 14:34:24     -717.990651        0.453342
LBFGS:    1 14:34:26     -718.036579        0.118547
LBFGS:    2 14:34:27     -718.042364        0.051292
LBFGS:    3 14:34:28     -718.043794        0.031008
LBFGS:    4 14:34:30     -718.044806        0.023343
LBFGS:    5 14:34:31     -718.045403        0.025471
LBFGS:    6 14:34:32     -718.045801        0.016009
LBFGS:    7 14:34:33     -718.046041        0.014984
LBFGS:    8 14:34:35     -718.046126        0.014026
LBFGS:    9 14:34:36     -718.046161        0.013629
LBFGS:   10 14:34:37     -718.046202        0.013497
LBFGS:   11 14:34:38     -718.046262        0.013703
LBFGS:   12 14:34:40     -718.046327        0.014230
LBFGS:   13 14:34:41     -718.046388        0.014738
LBFGS:   14 14:34:42     -718.046459        0.014931
LBFGS:   15 14:34:44     -718.046571        0.014507
LBFGS:   16 14:34:45     -718.046746        0.017375
LBFGS:   17 14:34:46     -718.046972        0.016781
LBFGS:   18 14:34:48     -718.047220        0.014905
LBFGS:   19 14:34:49     -718.047515        0.014402
LBFGS:   20 14:34:50     -718.047938        0.020799
LBFGS:   21 14:34:51     -718.048500        0.028931
LBFGS:   22 14:34:52     -718.048972        0.022752
LBFGS:   23 14:34:54     -718.049151        0.008560
LBFGS:   24 14:34:55     -718.049179        0.003982
LBFGS:   25 14:34:56     -718.049182        0.002267
LBFGS:   26 14:34:57     -718.049184        0.001018
LBFGS:   27 14:34:59     -718.049184        0.000499
LBFGS:   28 14:35:00     -718.049184        0.000184
LBFGS:   29 14:35:01     -718.049184        0.000024
LBFGS:   30 14:35:03     -718.049184        0.000004
LBFGS:   31 14:35:04     -718.049184        0.000004
LBFGS:   32 14:35:05     -718.049184        0.000005
LBFGS:   33 14:35:07     -718.049184        0.000004
LBFGS:   34 14:35:08     -718.049184        0.000003
LBFGS:   35 14:35:09     -718.049184        0.000001
LBFGS:   36 14:35:10     -718.049184        0.000001
Computing displacements... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 19/19 0:00:00

[23]:
!ls janus_results/
NaCl-1040-npt-T1040.0-T1080.0-p0.0-final.extxyz
NaCl-1040-npt-T1040.0-T1080.0-p0.0-md-log.yml
NaCl-1040-npt-T1040.0-T1080.0-p0.0-md-summary.yml
NaCl-1040-npt-T1040.0-T1080.0-p0.0-stats.dat
NaCl-1040-npt-T1040.0-T1080.0-p0.0-traj.extxyz
NaCl-auto_bands.yml.xz
NaCl-bands.svg
NaCl-bs-dos.svg
NaCl-deformed-geomopt-log.yml
NaCl-deformed-geomopt-summary.yml
NaCl-deformed-opt.extxyz
NaCl-deformed-traj.extxyz
NaCl-dos.dat
NaCl-dos.svg
NaCl-force_constants.hdf5
NaCl-mace-geomopt-log.yml
NaCl-mace-geomopt-summary.yml
NaCl-mace-opt.extxyz
NaCl-nvt-T100.0-cor.dat
NaCl-nvt-T100.0-final.extxyz
NaCl-nvt-T100.0-md-log.yml
NaCl-nvt-T100.0-md-summary.yml
NaCl-nvt-T100.0-res-100.extxyz
NaCl-nvt-T100.0-res-150.extxyz
NaCl-nvt-T100.0-res-200.extxyz
NaCl-nvt-T100.0-res-250.extxyz
NaCl-nvt-T100.0-res-300.extxyz
NaCl-nvt-T100.0-res-50.extxyz
NaCl-nvt-T100.0-stats.dat
NaCl-nvt-T100.0-traj.extxyz
NaCl-opt.extxyz
NaCl-phonons-log.yml
NaCl-phonons-summary.yml
NaCl-phonopy.yml
NaCl-sevennet-geomopt-log.yml
NaCl-sevennet-geomopt-summary.yml
NaCl-sevennet-opt.extxyz
NaCl-thermal.yml
ethanol_products-final-opt.extxyz
ethanol_products_1water-final-opt.extxyz
ethanol_products_2water-final-opt.extxyz
ethanol_reactants-init-opt.extxyz
ethanol_reactants-neb-band.extxyz
ethanol_reactants-neb-log.yml
ethanol_reactants-neb-plot.svg
ethanol_reactants-neb-results.dat
ethanol_reactants-neb-summary.yml
ethanol_reactants_1water-init-opt.extxyz
ethanol_reactants_1water-neb-band.extxyz
ethanol_reactants_1water-neb-log.yml
ethanol_reactants_1water-neb-plot.svg
ethanol_reactants_1water-neb-results.dat
ethanol_reactants_1water-neb-summary.yml
ethanol_reactants_2water-init-opt.extxyz
ethanol_reactants_2water-neb-band.extxyz
ethanol_reactants_2water-neb-log.yml
ethanol_reactants_2water-neb-plot.svg
ethanol_reactants_2water-neb-results.dat
ethanol_reactants_2water-neb-summary.yml
mof-5-auto_bands.yml.xz
mof-5-bands.svg
mof-5-bs-dos.svg
mof-5-dos.dat
mof-5-dos.svg
mof-5-force_constants.hdf5
mof-5-opt.extxyz
mof-5-phonons-log.yml
mof-5-phonons-summary.yml
mof-5-phonopy.yml
mof-5-thermal.yml
[24]:
from IPython.display import SVG, display
display(SVG("janus_results/mof-5-bs-dos.svg"))
../../_images/tutorials_cli_phonons_39_0.svg
[25]:
%%writefile phonons-mof5-path.yml

supercell: 1 1 1
displacement: 0.001
fmax: 1.0e-6
thermal: True
temp-min: 0
temp-max: 1000
temp-step: 10
bands: True
dos: True
pdos: False
dos-kwargs:
  freq_pitch: 0.05
mesh: [11,11,11]
qpoint-file: ../data/paths.yaml
minimize: True
minimize-kwargs:
  write_results: True
arch: mace_mp
write-full: False
plot-to-file: True
calc-kwargs:
    dispersion: False
    skin: 0
    model:  medium-mpa-0
device: cpu
tracker: False
Writing phonons-mof5-path.yml
[26]:
! janus phonons --config phonons-mof5-path.yml --struct ../data/mof-5.cif
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/e3nn/o3/_wigner.py:10: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  _Jd, _W3j_flat, _W3j_indices = torch.load(os.path.join(os.path.dirname(__file__), 'constants.pt'))
cuequivariance or cuequivariance_torch is not available. Cuequivariance acceleration will be disabled.
Using medium MPA-0 model as default MACE-MP model, to use previous (before 3.10) default model please specify 'medium' as model argument
Using Materials Project MACE for MACECalculator with /home/runner/.cache/mace/macempa0mediummodel
Using float64 for MACECalculator, which is slower but more accurate. Recommended for geometry optimization.
/home/runner/work/janus-core/janus-core/.venv/lib/python3.12/site-packages/mace/calculators/mace.py:143: UserWarning: Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed to `torch.load`, forcing weights_only=False.
  torch.load(f=model_path, map_location=device)
Using head default out of ['default']
       Step     Time          Energy          fmax
LBFGS:    0 14:35:57     -717.990651        0.453342
LBFGS:    1 14:35:58     -718.036579        0.118547
LBFGS:    2 14:36:00     -718.042364        0.051292
LBFGS:    3 14:36:01     -718.043794        0.031008
LBFGS:    4 14:36:02     -718.044806        0.023343
LBFGS:    5 14:36:04     -718.045403        0.025471
LBFGS:    6 14:36:05     -718.045801        0.016009
LBFGS:    7 14:36:06     -718.046041        0.014984
LBFGS:    8 14:36:07     -718.046126        0.014026
LBFGS:    9 14:36:08     -718.046161        0.013629
LBFGS:   10 14:36:10     -718.046202        0.013497
LBFGS:   11 14:36:11     -718.046262        0.013703
LBFGS:   12 14:36:12     -718.046327        0.014230
LBFGS:   13 14:36:14     -718.046388        0.014738
LBFGS:   14 14:36:15     -718.046459        0.014931
LBFGS:   15 14:36:16     -718.046571        0.014507
LBFGS:   16 14:36:17     -718.046746        0.017375
LBFGS:   17 14:36:19     -718.046972        0.016781
LBFGS:   18 14:36:20     -718.047220        0.014905
LBFGS:   19 14:36:21     -718.047515        0.014402
LBFGS:   20 14:36:22     -718.047938        0.020799
LBFGS:   21 14:36:23     -718.048500        0.028931
LBFGS:   22 14:36:25     -718.048972        0.022752
LBFGS:   23 14:36:26     -718.049151        0.008560
LBFGS:   24 14:36:27     -718.049179        0.003982
LBFGS:   25 14:36:28     -718.049182        0.002267
LBFGS:   26 14:36:30     -718.049184        0.001018
LBFGS:   27 14:36:31     -718.049184        0.000499
LBFGS:   28 14:36:32     -718.049184        0.000184
LBFGS:   29 14:36:33     -718.049184        0.000024
LBFGS:   30 14:36:35     -718.049184        0.000004
LBFGS:   31 14:36:36     -718.049184        0.000004
LBFGS:   32 14:36:37     -718.049184        0.000005
LBFGS:   33 14:36:38     -718.049184        0.000004
LBFGS:   34 14:36:39     -718.049184        0.000003
LBFGS:   35 14:36:41     -718.049184        0.000001
LBFGS:   36 14:36:42     -718.049184        0.000001
Computing displacements... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 19/19 0:00:00

[27]:
! ls janus_results/
NaCl-1040-npt-T1040.0-T1080.0-p0.0-final.extxyz
NaCl-1040-npt-T1040.0-T1080.0-p0.0-md-log.yml
NaCl-1040-npt-T1040.0-T1080.0-p0.0-md-summary.yml
NaCl-1040-npt-T1040.0-T1080.0-p0.0-stats.dat
NaCl-1040-npt-T1040.0-T1080.0-p0.0-traj.extxyz
NaCl-auto_bands.yml.xz
NaCl-bands.svg
NaCl-bs-dos.svg
NaCl-deformed-geomopt-log.yml
NaCl-deformed-geomopt-summary.yml
NaCl-deformed-opt.extxyz
NaCl-deformed-traj.extxyz
NaCl-dos.dat
NaCl-dos.svg
NaCl-force_constants.hdf5
NaCl-mace-geomopt-log.yml
NaCl-mace-geomopt-summary.yml
NaCl-mace-opt.extxyz
NaCl-nvt-T100.0-cor.dat
NaCl-nvt-T100.0-final.extxyz
NaCl-nvt-T100.0-md-log.yml
NaCl-nvt-T100.0-md-summary.yml
NaCl-nvt-T100.0-res-100.extxyz
NaCl-nvt-T100.0-res-150.extxyz
NaCl-nvt-T100.0-res-200.extxyz
NaCl-nvt-T100.0-res-250.extxyz
NaCl-nvt-T100.0-res-300.extxyz
NaCl-nvt-T100.0-res-50.extxyz
NaCl-nvt-T100.0-stats.dat
NaCl-nvt-T100.0-traj.extxyz
NaCl-opt.extxyz
NaCl-phonons-log.yml
NaCl-phonons-summary.yml
NaCl-phonopy.yml
NaCl-sevennet-geomopt-log.yml
NaCl-sevennet-geomopt-summary.yml
NaCl-sevennet-opt.extxyz
NaCl-thermal.yml
ethanol_products-final-opt.extxyz
ethanol_products_1water-final-opt.extxyz
ethanol_products_2water-final-opt.extxyz
ethanol_reactants-init-opt.extxyz
ethanol_reactants-neb-band.extxyz
ethanol_reactants-neb-log.yml
ethanol_reactants-neb-plot.svg
ethanol_reactants-neb-results.dat
ethanol_reactants-neb-summary.yml
ethanol_reactants_1water-init-opt.extxyz
ethanol_reactants_1water-neb-band.extxyz
ethanol_reactants_1water-neb-log.yml
ethanol_reactants_1water-neb-plot.svg
ethanol_reactants_1water-neb-results.dat
ethanol_reactants_1water-neb-summary.yml
ethanol_reactants_2water-init-opt.extxyz
ethanol_reactants_2water-neb-band.extxyz
ethanol_reactants_2water-neb-log.yml
ethanol_reactants_2water-neb-plot.svg
ethanol_reactants_2water-neb-results.dat
ethanol_reactants_2water-neb-summary.yml
mof-5-auto_bands.yml.xz
mof-5-bands.svg
mof-5-bands.yml.xz
mof-5-bs-dos.svg
mof-5-dos.dat
mof-5-dos.svg
mof-5-force_constants.hdf5
mof-5-opt.extxyz
mof-5-phonons-log.yml
mof-5-phonons-summary.yml
mof-5-phonopy.yml
mof-5-thermal.yml
[28]:
display(SVG("janus_results/mof-5-bs-dos.svg"))
../../_images/tutorials_cli_phonons_43_0.svg

extra bits

now as a challenge you can do a more realistic example, change the above example to

this is part of this paper if you want to know more: https://arxiv.org/abs/2412.02877