Skip to content

Add thermo-output-to-file notebook; map wasm /work to the kernel cwd#88

Merged
andeplane merged 1 commit into
masterfrom
add-thermo-file-notebook
Jul 8, 2026
Merged

Add thermo-output-to-file notebook; map wasm /work to the kernel cwd#88
andeplane merged 1 commit into
masterfrom
add-thermo-file-notebook

Conversation

@andeplane

Copy link
Copy Markdown
Collaborator

Summary

New tutorial basics/05-thermo-output-to-file.ipynb — the classic file-based LAMMPS workflow: the input script writes time, temperature and energy to thermo.txt with fix ave/time during the run; a separate cell — with the simulation already closed — reads the file back with numpy.loadtxt and plots temperature relaxation and NVE energy conservation. Linked from the index table and NOTEBOOK_TUTORIALS.md.

Bindings fix (required for the above): the DriveFS mount from #86 mapped the wasm /work directory to the drive root, so files LAMMPS wrote landed at the site root while the notebook's kernel runs in its own subdirectory (e.g. /drive/basics) — np.loadtxt("thermo.txt") couldn't find the file. /work paths are now prefixed with the kernel's current directory, so files land next to the running notebook — the same place native LAMMPS would put them (the process cwd). Notebooks at the site root are unaffected (empty prefix).

Test plan

  • Headless browser run (playwright + freshly built wasm) of the new notebook: both cells execute, thermo.txt lands next to the notebook, plot renders.
  • Regression: index.ipynb, basics/02 (file I/O), basics/03 (live plotting), basics/04, materials/01 all pass headlessly with the bindings change. The remaining materials notebooks do no file I/O.

🤖 Generated with Claude Code

New basics/05 tutorial: the classic file-based LAMMPS workflow — the
input script writes time/temperature/energy to thermo.txt with
fix ave/time during the run, and a separate cell (with the simulation
already closed) reads the file with numpy.loadtxt and plots it.

Doing this surfaced a wart in the DriveFS mount from #86: /work was
mapped to the drive root, so files written by LAMMPS landed at the site
root instead of next to the notebook (whose kernel runs in its own
directory, e.g. /drive/basics). Map /work through the kernel's current
directory instead — files now land where native LAMMPS would put them
(the process cwd), and np.loadtxt("thermo.txt") just works. Notebooks
at the site root are unaffected (empty prefix).

Verified headlessly (playwright + freshly built wasm): the new notebook
runs end-to-end and renders the plot; index, basics/02 (file I/O),
basics/03 (plots), basics/04 and materials/01 all still pass. The
remaining materials notebooks do no file I/O.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@andeplane andeplane merged commit 5a399c8 into master Jul 8, 2026
3 checks passed
@andeplane andeplane deleted the add-thermo-file-notebook branch July 8, 2026 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant