diff --git a/CHANGELOG.md b/CHANGELOG.md index 446e83fb..666423ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ and this project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.ht ## [Unreleased] +## [0.12.0] - 2026-11-12 + +This release also includes the fixes from a full codebase audit +(2026-11-10; PRs #169, #170, #172). The most important ones change +computed numbers: NMR ¹³C shifts, wB97X-D energies, and the entropy of +high-symmetry molecules. Results from earlier versions in those areas +should be recomputed. + ### Added - **ECD (electronic circular dichroism) spectra** (M-SPECTRA2 SPC2.3). UV-Vis @@ -42,7 +50,76 @@ and this project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.ht - The full 3Dmol.js BSD-3-Clause license now ships with the vendored copy (`quantui/data/js/3Dmol-LICENSE.txt`). +### Security + +- **Every Voilà launch now needs a per-run token and listens on 127.0.0.1 + only** (`quantui run app`, the native launchers and the Apptainer app + runscript), as `quantui view` already did; the JupyterLab launcher no + longer disables Jupyter's token. Another user on a shared machine could + otherwise drive your session. +- **A results folder is treated as data, not page code.** Opening someone + else's results (Viewer zip, shared folder) could inject HTML/JavaScript + through cached vibrational animations, saved orbital cubes or symmetry + labels, and two index files allowed reading files outside the folder. + Cached animations are now signed per user; file names, script-embedded + JSON and all result text shown in History, Results and error cards are + checked or escaped. +- **Batch job folders are created owner-only (0700)**, and the SLURM + partition name is validated like account/QOS before it reaches the batch + script. + ### Fixed +- **NMR chemical shifts were offset by up to 52 ppm (¹³C).** The TMS + reference table did not match QuantUI's own GIAO shieldings (TMS itself + came out at δ(¹³C) = −7.7 ppm at B3LYP/6-31G*, −52 ppm at RHF/STO-3G). The + table is now computed by QuantUI on TMS optimized at each level, so TMS + gives δ ≈ 0. NMR also refuses open-shell, post-HF and meta-GGA cases up + front instead of failing with a cryptic error. +- **wB97X-D now includes its dispersion term.** LibXC's functional is only + the exchange-correlation part; QuantUI now adds the Chai–Head-Gordon + atom-pair dispersion to energies, forces, frequencies and exported + scripts (parameters for H–Xe). +- **Thermochemistry uses the right symmetry number for slightly distorted + geometries** (e.g. benzene σ = 12, was 4; G was 2.7 kJ/mol too low). The + point group is shown in the thermo panel. +- **Open-shell HOMO–LUMO gap and orbital diagram** use both spins + (min LUMO − max HOMO) and draw α and β levels; the gap was α-only. +- **Structure search keeps charge and multiplicity**: ions and radicals + (sulfate, ammonium, OH⁻, CH₃·, O₂ triplet) no longer load as neutral + singlets or fail as "Not found". Search answers from the bundled library + first, offline. +- **Calculation runs:** one run at a time (a double-click started two); + settings are read once at Run and frozen while it runs, so changing the + basis mid-run no longer mixes levels of theory; a seed geometry keeps the + current charge and multiplicity; a resumed Frequency run never reuses IR + or Raman displacements from a different geometry; a failed save, a late + Cancel and a failed pre-optimization are reported instead of looking + like success. +- **IRC** reports the true end minimum when Sella's inner loop gives up (the + stored end point could be the previous path point, giving wrong + barriers), and mirror-image ends (NH₃ inversion) count as two minima. +- **PES scans:** angle scans stay between 0° and 180° and start from linear + geometries; angle/dihedral scans rotate the whole moving group instead of + one atom. +- **Frequencies:** an unconverged displaced SCF no longer corrupts IR or + Raman intensities (they are dropped with a message); the mode-following + restart from a saddle point moves the stated 0.3 Å. +- **Batch/SLURM:** cancelled ("CANCELLED by …"), preempted and lost jobs are + recognised instead of holding a job slot forever; a reused request id no + longer overwrites a running job; requeued jobs follow the new attempt; + ingested results keep their structure; `quantui-batch submit --from` + keeps the source's solvent and refuses an unconverged source; the job + monitor can no longer leave Run disabled. +- **Uploads and parsing:** planar 3-D MOL/SDF files keep their geometry; + charge/multiplicity are taken from a file only when it sets them; + non-finite coordinates, impossible spin states and truncated XYZ are + rejected; UTF-8 BOM, UTF-16, Fortran `D` exponents, D/T isotope labels + and PDB alternate locations are handled. +- Many smaller fixes from the same audit: History cards, exports following + the run instead of the last-viewed History folder, theme CSS and Dark + contrast, 1-based MO numbers everywhere, open-shell TD states no longer + labelled S1…Sn, GFN-FF pre-optimization charge, C3v orbital labels, + calibration and estimator fixes, launcher robustness. - **MO symmetry labels no longer depend on the LAPACK build.** On a geometry symmetric only to within the detection tolerance, a split @@ -131,6 +208,17 @@ and this project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.ht Frequency cannot be resumed, and now lists Reorganization Energy. ### Changed +- **Plotly figures load plotly.js once per page** from the installed + package (still offline) instead of embedding ~4.8 MB in every figure and + slider redraw; in-app figures are now under 200 kB. +- **Batch jobs match the app:** a geometry optimization or pre-optimization + is followed by the same required single point (one more SCF per job); + PySCF's memory follows the SLURM allocation; failures write a full + traceback to `live.log`; `result.json` records elapsed time and warnings. +- NMR stick spectra run high → low in δ, as in the literature. +- Packaging: `py3Dmol` capped below 2.6 (matches the vendored 3Dmol.js); + `rdkit` and `psutil` declared directly; SPDX licence metadata; provenance + files shipped in the wheel. - Documentation brought in line with the code: CLI reference (`quantui view`, `gpu check --engine`, `submit` requirements and flags, @@ -1523,7 +1611,8 @@ Initial public scaffolding of the QuantUI package: `quantui` package with `calculator.py`, basic notebook launcher, Apptainer container definition, MIT license, and project metadata. -[Unreleased]: https://github.com/The-Schultz-Lab/QuantUI/compare/v0.11.1...HEAD +[Unreleased]: https://github.com/The-Schultz-Lab/QuantUI/compare/v0.12.0...HEAD +[0.12.0]: https://github.com/The-Schultz-Lab/QuantUI/compare/v0.11.1...v0.12.0 [0.11.1]: https://github.com/The-Schultz-Lab/QuantUI/compare/v0.11.0...v0.11.1 [0.11.0]: https://github.com/The-Schultz-Lab/QuantUI/compare/v0.10.0...v0.11.0 [0.10.0]: https://github.com/The-Schultz-Lab/QuantUI/compare/v0.9.0...v0.10.0 diff --git a/CLAUDE.md b/CLAUDE.md index f1f449d9..07417041 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -63,7 +63,7 @@ pytest tests/test_foo.py -n0 # one test, serial (breakpoints work; -n=auto is o pre-commit run --all-files # file hygiene + nbstripout + black (26.5.1) + ruff (v0.16.0); mypy runs on pre-push and in CI ``` -Test baseline (see STATUS): **~4680 passed / 11 skipped** for +Test baseline (see STATUS): **~4930 passed / 11 skipped** for `pytest -m "not network"` (cloud, Python 3.11, 2026-11). `network`-marked tests need internet (live PubChem) — skip them in the cloud. diff --git a/README.md b/README.md index 4d74740b..33a7eb86 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,8 @@ Real output from QuantUI, straight from the app: - **In-session calculations** — RHF, UHF, 9 DFT functionals, MP2, CCSD, CCSD(T), NMR shielding, TD-DFT UV-Vis, 1D PES scans, Marcus reorganization energies, **transition-state searches** (Sella, with an automatic - frequency check that says whether it found a TS) and **IRC reaction paths** + frequency check that says whether it found a TS; the starting guess can be + built from a reactant and a product along an IDPP path) and **IRC reaction paths** via PySCF, running in your Python kernel. Optional PyFock (≥0.1.7) adds native-Windows PBE single points and geometry optimizations for neutral, closed-shell molecules with def2-SVP/def2-TZVP, including orbital and population analysis; @@ -88,11 +89,12 @@ Real output from QuantUI, straight from the app: Hessian + IR; Raman is not computed in solvent), TD-DFT (non-equilibrium excitations) and reorganization energies (gas-phase optimizations, solvated single points). NMR and PES scans are gas-phase only -- **Rich results** — total energy, HOMO-LUMO gap, Mulliken charges, dipole +- **Rich results** — total energy, HOMO-LUMO gap, Mulliken and NPA charges, + Mayer and Wiberg bond orders, dipole moment, point group, ⟨S²⟩ with a spin-contamination flag for open-shell results, thermochemistry (U, H, S, G, Cv, Cp at any temperature and pressure), IR and Raman spectrum charts (stick and Lorentzian-broadened; - Raman in the gas phase), ¹H/¹³C NMR + Raman in the gas phase), UV-Vis and ECD spectra, ¹H/¹³C NMR chemical shifts, an orbital energy-level diagram with symmetry labels (1a₁, 1b₂ …), and a side-by-side comparison table for multiple calculations - **Surfaces** — any molecular orbital (α and β for unrestricted results), an @@ -532,13 +534,13 @@ The notebooks are not in the PyPI package; clone the repository to run them. | Type | Output | | --- | --- | -| Single Point | Energy, HOMO-LUMO gap, Mulliken charges, dipole moment | +| Single Point | Energy, HOMO-LUMO gap, Mulliken and NPA charges, Mayer/Wiberg bond orders, dipole moment | | Geometry Opt | Optimised structure, trajectory animation; optional frozen atoms | -| Transition State | Saddle point near the input geometry (Sella, optional `[ts]` extra), then a frequency check: transition state, minimum, or higher-order saddle point; animated imaginary mode | +| Transition State | Saddle point near the input geometry, or from a reactant + product guess path (Sella, optional `[ts]` extra), then a frequency check: transition state, minimum, or higher-order saddle point; animated imaginary mode | | IRC | Reaction path from a Transition State result, downhill both ways to the minima it connects (Sella); barrier from each side, energy profile and animated path | | Frequency | Vibrational frequencies, ZPVE, IR intensities, thermochemistry at any temperature and pressure, animated normal modes, IR spectrum chart (stick / Lorentzian broadened) | -| UV-Vis (TD-DFT) | Excitation energies, oscillator strengths, UV-Vis spectrum plot | -| NMR Shielding | ¹H and ¹³C chemical shifts relative to TMS via GIAO; tabulated by element | +| UV-Vis (TD-DFT) | Excitation energies, oscillator strengths, UV-Vis spectrum plot; rotatory strengths and ECD spectrum | +| NMR Shielding | ¹H and ¹³C chemical shifts relative to TMS via GIAO (TMS reference shieldings computed by QuantUI at common levels; other levels fall back to B3LYP/6-31G\* and say so); closed-shell HF/DFT only, not meta-GGAs (M06-2X, M06-L); tabulated by element | | PES Scan | 1D potential energy surface along a bond, angle, or dihedral; energy profile chart; geometry animation at each scan point | | Reorganization Energy | Marcus four-point internal reorganization energy λ = λ₁ + λ₂ for hole (cation) and/or electron (anion) transfer | @@ -629,7 +631,7 @@ quantui/ Main package notebooks/ molecule_computations.ipynb Main user-facing interface (3-cell launcher) tutorials/ Step-by-step guided notebooks (01–05) -tests/ pytest test suite (~4,700 tests; run in parallel via pytest-xdist) +tests/ pytest test suite (~4,900 tests; run in parallel via pytest-xdist) apptainer/ Container definition for reproducible deployment local-setup/ Conda environment definition pyproject.toml Package metadata and tool config diff --git a/SECURITY.md b/SECURITY.md index 8f611513..52214eba 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -11,8 +11,8 @@ writes job folders under your own cluster home and submits them with your own | Version | Supported | |---------|-----------| -| 0.11.x | Yes | -| < 0.11 | No | +| 0.12.x | Yes | +| < 0.12 | No | ## Reporting a Vulnerability diff --git a/docs/features.md b/docs/features.md index 04cf093c..88a6ff24 100644 --- a/docs/features.md +++ b/docs/features.md @@ -43,7 +43,8 @@ Everything runs in your local Python kernel.
📊
Spectra & Analysis

- IR, Raman, UV-Vis and NMR spectra, point groups, orbital diagrams, + IR, Raman, UV-Vis, ECD and NMR spectra, NPA charges and bond orders, + point groups, orbital diagrams, density and ESP surfaces, thermochemistry, side-by-side comparisons.

diff --git a/docs/index.md b/docs/index.md index bb97afe6..2c1c5198 100644 --- a/docs/index.md +++ b/docs/index.md @@ -30,7 +30,7 @@ hide:
Python 3.9–3.11 · - 4,100+ tests + 4,900+ tests · MIT License · diff --git a/docs/methods.md b/docs/methods.md index 72c16a67..cc3e015d 100644 --- a/docs/methods.md +++ b/docs/methods.md @@ -6,13 +6,13 @@ Nine calculation types, fourteen methods, fourteen basis sets. | Calculation type | Output | | --- | --- | -| **Single Point** | Energy, HOMO–LUMO gap, charges, dipole | +| **Single Point** | Energy, HOMO–LUMO gap, Mulliken and NPA charges, bond orders, dipole | | **Geometry Opt** | Optimized structure and trajectory; optional frozen atoms | -| **Transition State** | Saddle point (Sella, `quantui[ts]`) plus a frequency check | +| **Transition State** | Saddle point (Sella, `quantui[ts]`) plus a frequency check; optional guess from a reactant + product | | **IRC** | Path from a transition state to the two minima it connects; barriers and energy profile | | **Frequency** | Frequencies, IR intensities, Raman activities (gas phase), ZPVE, thermochemistry, animated modes | -| **UV-Vis (TD-DFT)** | Excitation energies, oscillator strengths, spectrum | -| **NMR Shielding** | ¹H and ¹³C shifts vs TMS (GIAO) | +| **UV-Vis (TD-DFT)** | Excitation energies, oscillator strengths, UV-Vis and ECD spectra | +| **NMR Shielding** | ¹H and ¹³C shifts vs TMS (GIAO); closed-shell HF/DFT, not M06-2X/M06-L. TMS reference computed by QuantUI at common levels, flagged otherwise | | **PES Scan** | 1D bond, angle or dihedral scan | | **Reorganization Energy** | Marcus four-point λ for hole and/or electron transfer | diff --git a/docs/platforms.md b/docs/platforms.md index 8beae8e9..025649c2 100644 --- a/docs/platforms.md +++ b/docs/platforms.md @@ -2,7 +2,8 @@ | Platform | Status | Notes | | --- | --- | --- | -| **Linux / macOS** | :material-check-circle:{ .green } Full | PySCF via conda or pip | +| **Linux** | :material-check-circle:{ .green } Full | PySCF via conda or pip; tested in CI | +| **macOS** | :material-check-circle:{ .green } Full | PySCF via conda or pip; not covered by CI | | **WSL (Windows)** | :material-check-circle:{ .green } Full | Same as Linux | | **Windows native** | :material-alert-circle:{ .yellow } Partial | PyFock: neutral closed-shell PBE single points and optimizations | diff --git a/pyproject.toml b/pyproject.toml index 96e55f34..140fe273 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ build-backend = "setuptools.build_meta" [project] name = "quantui" -version = "0.11.1" +version = "0.12.0" description = "An open-source frontend for DFT and post-HF quantum chemistry with PySCF" readme = "README.md" requires-python = ">=3.9" diff --git a/quantui/__init__.py b/quantui/__init__.py index c22aecc7..d2483a8c 100644 --- a/quantui/__init__.py +++ b/quantui/__init__.py @@ -7,7 +7,7 @@ PySCF requires Linux/macOS/WSL. Windows users should use the Apptainer container. """ -__version__ = "0.11.1" +__version__ = "0.12.0" import logging from typing import Any diff --git a/tests/test_audit_low_data.py b/tests/test_audit_low_data.py index 699ef63a..e1baaa26 100644 --- a/tests/test_audit_low_data.py +++ b/tests/test_audit_low_data.py @@ -82,48 +82,79 @@ def test_calibration_worker_is_not_daemonic(monkeypatch, tmp_path): assert proc.daemon is False -def _group_leader_with_child(pids): # pragma: no cover - runs in a fork child - os.setpgrp() - child = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(60)"]) - pids.put(child.pid) - time.sleep(60) +class _PopenWorker: + """The slice of ``multiprocessing.Process`` that ``_terminate_worker_tree`` uses. + + The worker is a fresh interpreter in its own session (so it leads its + process group, as the calibration worker does after ``os.setpgrp()``). + Forking the pytest process instead can hang the child before it reaches + ``setpgrp`` when xdist/coverage threads hold a lock at fork time. + """ + + def __init__(self, popen): + self._p = popen + self.pid = popen.pid + + def is_alive(self): + return self._p.poll() is None + + def terminate(self): + self._p.terminate() + + def join(self, timeout=None): + try: + self._p.wait(timeout) + except subprocess.TimeoutExpired: + pass def _running(pid): - """True while *pid* exists and is not a zombie. The process can vanish - between any two /proc reads (ENOENT, or ESRCH from a stat file whose - process was just reaped); either way it is gone.""" + """True while ``pid`` exists and is not a zombie (tolerates it vanishing).""" try: with open(f"/proc/{pid}/stat") as fh: - return "Z" not in fh.read().split()[2] - except OSError: + return fh.read().rsplit(")", 1)[1].split()[0] != "Z" + except (OSError, IndexError): return False -@pytest.mark.skipif(not hasattr(os, "killpg"), reason="POSIX process groups") -def test_terminate_worker_tree_kills_grandchildren(): +@pytest.mark.skipif( + not hasattr(os, "killpg") or not os.path.isdir("/proc"), + reason="POSIX process groups + /proc", +) +def test_terminate_worker_tree_kills_grandchildren(tmp_path): """Stop/Skip/timeout must not orphan the worker's pool processes.""" - import multiprocessing - - ctx = multiprocessing.get_context("fork") - pids = ctx.Queue() - worker = ctx.Process(target=_group_leader_with_child, args=(pids,)) - worker.start() + pid_file = tmp_path / "grandchild.pid" + script = ( + "import subprocess, sys, time\n" + "c = subprocess.Popen([sys.executable, '-c', 'import time; time.sleep(60)'])\n" + f"open({str(pid_file)!r}, 'w').write(str(c.pid))\n" + "time.sleep(60)\n" + ) + worker = _PopenWorker( + subprocess.Popen([sys.executable, "-c", script], start_new_session=True) + ) try: - kids = [pids.get(timeout=20)] + deadline = time.time() + 30 + while not (pid_file.exists() and pid_file.read_text().strip()): + assert time.time() < deadline, "worker never started its child" + assert worker.is_alive(), "worker exited before starting its child" + time.sleep(0.05) + kid = int(pid_file.read_text()) + assert os.getpgid(worker.pid) == worker.pid + benchmarks._terminate_worker_tree(worker) worker.join(10) assert not worker.is_alive() deadline = time.time() + 10 - while time.time() < deadline: - alive = [k for k in kids if _running(k)] - if not alive: - break + while _running(kid) and time.time() < deadline: time.sleep(0.1) - assert not alive + assert not _running(kid) finally: - if worker.is_alive(): + try: os.killpg(worker.pid, 9) + except ProcessLookupError: + pass + worker.join(5) # ---------------------------------------------------------------------------