Electron-phonon examples and generator: reorganisation plan#
Status (October 27 2026): implemented as alternative A (the thin drivers over
PAOFLOW.elphon.workflows), with the generator upgraded. What exists now:
src/PAOFLOW/elphon/workflows/:ElphonSystem(system.py),superconductivity.py,optics.py,transport.py,arpes.py,phonons.py,coupling.py;load_systemfinds the nearestsystem.pyabove a driver.src/PAOFLOW/gen/elphon_templates/: the drivers of every workflow folder (phonons/,coupling/,superconductivity/,optics/,transport/,arpes/,qe/kmesh.py);src/PAOFLOW/gen/elphon_system.py:paoflow-gen elphon(prompts,render_system_py,qe_inputs,render_run_qe,write_system_folder). The old string templates ofpaoflow_driver.py(2.7k lines) are gone, as are theahc/elphmatmenu entries.examples/elphon/{Si,Pb,MgB2,SiC}:system.py(rendered by the generator),qe/(phonon, nscf, optics inputs,run_qe.sh,kmesh.py), the workflow folders with copies of the templates, READMEs with references, the SiC report.examples/elphon_example/is gone.Tests:
tests/unit/elphon/test_workflows.py,tests/unit/gen/test_elphon_system.py(the examples must equal the templates; every driver parses--help; the ME, resistivity and k-mesh templates run on synthetic data),tests/integration/elphon/test_example_workflows.py(each workflow on the Si asset).Numerics: the old drivers and the new ones were run on the same data with identical outputs (max relative difference ≤ 7e-15): Pb 12³/12³ Eliashberg and ARPES and MgB₂ anisotropic ME on the Workspace EPW data, SiC coupling path and 12³ mobility on the SiC run, Si 12³/6³ phonon-assisted absorption and 12³ mobility on the 6³/3³ integration asset.
The original proposal follows.
What we have#
examples/elphon_example/{Si,Pb,MgB2,SiC} grew one script per property on top of a flat
layout: each system has phonon/ (scf, ph.x) and nscf/ (nscf, EPW inputs) and, next to
them, main.py, me.py, me_aniso.py, transport.py, mobility.py, arpes.py,
optics_eps.py, emissivity_from_absorption.py, quadrupoles.py, coupling.py,
phonons.py, plot*.py, 3.5k lines in all. Three problems came up during the last weeks of
work:
The configuration is duplicated.
SAVEDIR,PHONON_DIR,COARSE_GRID,QGRID,MASSES_AMU,NELEC, the basis path and the long-range choices live at the top of every script (Si/mobility.pyrepeatsSi/main.py; only thearpes.pydrivers import them). Copies in the users’ run directories drift: today a Si run failed twice because the copiedmobility.pycarried a 3³ q-grid while the data were 6³.main.pyis a multiplexer.Si/main.py(611 lines) is phonon-assisted absorption, emissivity, eACBN0 electrons and scissor handling in one file;Pb/main.pyis Eliashberg plus a transport flag. A user who wants one property has to read the others.The expensive part is recomputed. Every script rebuilds the coarse vertex \(g(R_e, R_p)\) from the DFPT files (minutes to tens of minutes) although
coupling_cacheexists; nothing shares a cache directory across properties.The generator lags the examples.
paoflow-gen elphon(gen/paoflow_driver.py, a 6.2k-line script of string templates) emits an EPW-sourcemain.elphon.py/me.elphon.py/transport.elphon.py/plot.elphon.pyin the layout ofexamples/elphon_epw_example, which no longer exists. It knows nothing of the native DFPT source, the irreducible-wedge nscf, the long-range and quadrupole terms, adaptive smearing or ARPES. Two template sets (examples and generator) cannot be kept in step by hand.
The generator#
paoflow-gen elphon should produce the system folder, not a script:
prompts (as today) for the
pw.xinput, prefix, pseudopotentials, grids, masses; new prompts: coupling source (dfptdefault,epwoptional), nscf on the irreducible wedge (default) or the explicit full list (EPW), long-range term (automatic fromepsil), quadrupoles (quadrupoles.pyworkflow), and a multi-select of workflows (phonons, coupling, superconductivity, optics, transport, arpes);writes
qe/(scf, ph.x withepsilandfildvscf, nscf,run_qe.sh; EPW inputs only for the EPW source),system.pyfrom the prompts, and copies the selected workflow folders fromexamples/elphon/_template/(the same files the examples use, parameters only insystem.py);drops the string templates of
paoflow_driver.pyfor the electron-phonon workflow (the ~1.5k lines that buildmain.elphon.pyand friends) and the reference toexamples/elphon_epw_example.
With alternative A the templates are the thin drivers; with the pure reorganisation they are
the example scripts themselves. Either way, paoflow-gen elphon and
examples/elphon/<system> cannot drift again.
Tests and CI#
The elphon integration asset (
si/,sic/) is reshaped to theqe/layout, so every workflow driver runs on it unchanged with small grids; a smoke testtests/integration/elphon/test_example_workflows.pyruns each workflow with--nk 6 --nq 6(seconds to a minute each) and checks the output files. Today the examples are not exercised by CI at all.The asset builder in
.github/assets_generation/elphon/reusesqe/run_qe.shof the example instead of its own copies.
Migration#
Create
examples/elphon/with the layout above;examples/elphon_examplebecomes a one-line README pointing to it (removed one release later).Write
system.pyfor Si, Pb, MgB₂ and SiC from the current constants; splitSi/main.pyintooptics/absorption.pyandoptics/emissivity.py; move the rest unchanged.(Alternative A) add
elphon/workflows/and cut the drivers down; keep the numerical output bit-identical (the drivers call the same backends with the same arguments; the existing REPORT numbers are the regression reference).Shared
cache/wired into every driver.Docs:
Electron-Phonon-Coupling.md(module map, CLI section, example references),cli-generators.md,arpes.md, the four READMEs and REPORTs,CLAUDE.mdtree.Generator: system-folder output, workflow multi-select, DFPT default, template copy.
CI smoke test on the asset; Workspace run directories re-created as
system.py+ symlinks to the data.
Effort: 1.5 days for the layout, system.py, the splits and the docs; 1 day for the workflow
layer and the caches (alternative A); 1 day for the generator; half a day for the CI smoke
test. Numerical outputs do not change.