Repository navigation
Add NVT post-processing for TDEP input generation - #698
Conversation
|
Addressed Jacob's review comments and pushed an update. Verified with |
oerc0122
left a comment
There was a problem hiding this comment.
Just some minor recommendations, otherwise looks ok.
|
be sure we add tdep in CI and we actually test it |
ElliottKasoar
left a comment
There was a problem hiding this comment.
Thanks for this, @junwen94!
Would you be able to add a (very brief) CLI tutorial for this too?
Related to that, it would be great to include these kwargs in the example configs found in docs/source/examples/full/, similarly to how we already show rdf_compute etc. This provides another example for how you can specify these.
Co-authored-by: Jacob Wilkins <46597752+oerc0122@users.noreply.github.com>
|
@junwen94 can you go through the comments please? and also we will need to install tdep in the ci to have a proper test, in the sense tdep runs and we get to test the real data. |
janus_core/processing/tdep.py (oerc0122 round 2):
- Fix syntax error in positions writer and define out_fmt = '{:.12f}'.format
- Collapse meta_path.write_text into a single triple-quoted f-string
- Refactor stat_path block to iterate data tuple through out_fmt
docs/source/tutorials/python/anharmonic_phonons.ipynb (ElliottKasoar):
- Clear all cell outputs and execution counts
- Drop the static dispersion PNG; notebook now runs TDEP via !-shell calls
and embeds the gnuplot-generated PDF (converted via pdftoppm)
- Add nbsphinx execute=always + timeout metadata so this notebook is the
only one executed at docs build time (global default remains 'never')
docs/source/examples/full/nvt.yml (ElliottKasoar):
- Add tdep_compute / tdep_unit_cell_file / tdep_supercell_file /
tdep_output_dir under post_process_kwargs, mirroring rdf_compute
.gitignore (ElliottKasoar):
- Remove ! exceptions for the tutorial notebook and dispersion PNG
.github/workflows/ci.yml (alinelena):
- Install TDEP via conda-forge per upstream INSTALL.md and build with
build_things.sh; cache the build under ~/tdep
- Add poppler-utils for pdftoppm
- Bump docs job timeout to 30 min and switch shell to bash -el
The previous run produced no PDF because gnuplot was not on the CI runner. Use gnuplot-nox to avoid pulling in X11/Qt. Also print produced TDEP outputs at the end of the !-shell pipeline to aid future debugging.
Previous run still failed at Image cell, meaning a silent failure earlier in the TDEP pipeline. Bash with set -ex aborts on first error and echoes each command, so the next CI run will show exactly which step is failing.
TDEP libolle/lo_phonon_bandstructure_on_path.f90 appends a _pdf suffix when pdfplot is true (the -p / --pdf flag), so the script TDEP actually writes is outfile.dispersion_relations.gnuplot_pdf, not .gnuplot. Also drop -x from set -ex now that the failure is identified; keep -e for fail-fast on future regressions.
- Build TDEP 6ccdf13 before make all, as in ci.yml, so the TDEP tutorials run TDEP when the docs are published - Continue on error: if TDEP does not build, a warning is shown and the tutorials skip their TDEP steps, so the release is never blocked
- List other TDEP calculations that the generated inputs can be used for, such as higher-order force constants, free energies and the thermal conductivity, linking to the TDEP tutorials - Note what MLIPs do not usually provide (Born effective charges for --polar, dielectric tensors for infrared and Raman spectra), that classical MD has no nuclear quantum effects, and that higher-order properties are more sensitive to MLIP errors
|
@alinelena @ElliottKasoar @oerc0122 Sorry for the long silence. I've pushed changes for all the review comments and replied in each thread. Here's a summary. CI (docs workflow, two package managers, gnuplot/poppler)
CI details
Tests that run TDEP (Elliott; Alin 1, 2)
Test details
Tutorials and docs (saved outputs, CLI tutorial)
Fixes found by running TDEP and the example configsRunning TDEP exposed several bugs; Full list
Example configs (Elliott's review)
No
|
The YAML log formatter only replaces backslashes in str arguments, so passing the Path itself wrote Windows paths with backslashes inside a double-quoted YAML string, making the log file invalid on Windows.
|
@junwen94 @oerc0122 @ElliottKasoar can we get this in a shape to be merged? if needed have a meeting to have it done... I want to go on AL with it done. |
|
Pending a fix from @junwen94 |
|
While making the TDEP figure for the paper, I found that TDEP fails when the structure files are extxyz and the lattice parameter comes from an MLIP relaxation. |
ElliottKasoar
left a comment
There was a problem hiding this comment.
Thanks again, @junwen94!
Summary
This PR lets
janus-corewrite TDEP input files after NVT molecular dynamics, throughpost_process_kwargs, so TDEP can fit temperature-dependent force constants to the sampled structures without a separate conversion step.janus md --ensemble nvt --struct tests/data/NaCl.cif --arch mace_mp --steps 2000 --traj-start 1000 --traj-every 100 --stats-every 100 --post-process-kwargs "{'tdep_compute': True, 'tdep_unit_cell_file': 'tests/data/NaCl-primitive.extxyz', 'tdep_supercell_file': 'tests/data/NaCl.cif'}"This writes
infile.ucposcar,infile.ssposcar,infile.positions,infile.forces,infile.statandinfile.metatojanus_results/NaCl-nvt-T300.0-tdep-inputs.Changes
janus_core/processing/tdep.py:build_tdep_inputs_from_nvtwrites the TDEP input files from the MD trajectory and statistics. It pairs frames with statistics by step, falls back to<arch>_forces, and writes the stress columns in the order TDEP reads them.janus_core/calculations/md.py: thetdep_*options inpost_process_kwargs. The settings are checked when the MD is created (_config_tdep), so an invalid setup fails before the MD runs. The output directory is reported inoutput_filesand the log.janus_core/helpers/janus_types.py: the TDEP keys inPostProcessKwargs.tests/test_tdep.py): input generation, error paths and the CLI always run. When TDEP is onPATH, TDEP is also run on committed NVT output, with the phonon frequencies checked against reference values, and on a short seeded MD.testsjob and the releasebuild-docsjob, pinned to6ccdf13, withcontinue-on-errorlike PLUMED.command_line.rst, a TDEP section ininstallation.rst, the README, and thetdep_*options in thenvt,nvt-nhandnvt-csvrexample configs.Why there is no
janus-core[tdep]extra orTDEP_KERNELUnlike PLUMED, TDEP support needs no optional extra and no environment variable.
The
plumedextra installs the PyPI packageplumed("Python wrappers for plumed"). janus-core uses it during MD through ASE'sPlumedcalculator. At run time the wrapper loads the PLUMED library from the path inPLUMED_KERNEL, and otherwise raises "PLUMED not available, check your PLUMED_KERNEL environment variable". That is why PLUMED needs both.TDEP is a set of Fortran command-line programs, built on a Fortran library (libolle). Neither has Python bindings, and TDEP is not packaged on PyPI or conda-forge. janus-core never calls TDEP. With
tdep_compute: True, it only writes TDEP'sinfile.*text files after the MD, using ASE and NumPy, which are already core dependencies. So there is nothing for an extra to install and nothing for janus-core to locate, and noTDEP_KERNELequivalent is needed.To run TDEP on the generated files, and for the optional TDEP tests, the TDEP executables only need to be on
PATH. That is what TDEP's installation instructions set up. The TDEP tests are skipped when the executables are not found, and the TDEP section ofinstallation.rstexplains this.Testing
The two tests that run TDEP are skipped unless
extract_forceconstantsandphonon_dispersion_relationsare onPATH.