quantui 0.13.0__tar.gz → 0.13.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. {quantui-0.13.0 → quantui-0.13.1}/CHANGELOG.md +19 -1
  2. {quantui-0.13.0/quantui.egg-info → quantui-0.13.1}/PKG-INFO +1 -1
  3. {quantui-0.13.0 → quantui-0.13.1}/pyproject.toml +1 -1
  4. {quantui-0.13.0 → quantui-0.13.1}/quantui/__init__.py +1 -1
  5. {quantui-0.13.0 → quantui-0.13.1}/quantui/tddft_calc.py +51 -1
  6. {quantui-0.13.0 → quantui-0.13.1}/quantui/xcheck/cases.py +16 -0
  7. {quantui-0.13.0 → quantui-0.13.1}/quantui/xcheck/reference.py +20 -12
  8. {quantui-0.13.0 → quantui-0.13.1}/quantui/xcheck/runner.py +4 -0
  9. {quantui-0.13.0 → quantui-0.13.1/quantui.egg-info}/PKG-INFO +1 -1
  10. {quantui-0.13.0 → quantui-0.13.1}/LICENSE +0 -0
  11. {quantui-0.13.0 → quantui-0.13.1}/MANIFEST.in +0 -0
  12. {quantui-0.13.0 → quantui-0.13.1}/README.md +0 -0
  13. {quantui-0.13.0 → quantui-0.13.1}/SECURITY.md +0 -0
  14. {quantui-0.13.0 → quantui-0.13.1}/quantui/analytics.py +0 -0
  15. {quantui-0.13.0 → quantui-0.13.1}/quantui/app.py +0 -0
  16. {quantui-0.13.0 → quantui-0.13.1}/quantui/app_analysis.py +0 -0
  17. {quantui-0.13.0 → quantui-0.13.1}/quantui/app_builders.py +0 -0
  18. {quantui-0.13.0 → quantui-0.13.1}/quantui/app_compare_tools.py +0 -0
  19. {quantui-0.13.0 → quantui-0.13.1}/quantui/app_exports.py +0 -0
  20. {quantui-0.13.0 → quantui-0.13.1}/quantui/app_formatters.py +0 -0
  21. {quantui-0.13.0 → quantui-0.13.1}/quantui/app_history.py +0 -0
  22. {quantui-0.13.0 → quantui-0.13.1}/quantui/app_launcher.py +0 -0
  23. {quantui-0.13.0 → quantui-0.13.1}/quantui/app_measurement.py +0 -0
  24. {quantui-0.13.0 → quantui-0.13.1}/quantui/app_menubar.py +0 -0
  25. {quantui-0.13.0 → quantui-0.13.1}/quantui/app_pes2d.py +0 -0
  26. {quantui-0.13.0 → quantui-0.13.1}/quantui/app_pes_pick.py +0 -0
  27. {quantui-0.13.0 → quantui-0.13.1}/quantui/app_runflow.py +0 -0
  28. {quantui-0.13.0 → quantui-0.13.1}/quantui/app_scf_options.py +0 -0
  29. {quantui-0.13.0 → quantui-0.13.1}/quantui/app_setup_dialog.py +0 -0
  30. {quantui-0.13.0 → quantui-0.13.1}/quantui/app_slurm.py +0 -0
  31. {quantui-0.13.0 → quantui-0.13.1}/quantui/app_structure_edit.py +0 -0
  32. {quantui-0.13.0 → quantui-0.13.1}/quantui/app_viewer.py +0 -0
  33. {quantui-0.13.0 → quantui-0.13.1}/quantui/app_visualization.py +0 -0
  34. {quantui-0.13.0 → quantui-0.13.1}/quantui/app_workspace.py +0 -0
  35. {quantui-0.13.0 → quantui-0.13.1}/quantui/app_xyz_input.py +0 -0
  36. {quantui-0.13.0 → quantui-0.13.1}/quantui/ase_bridge.py +0 -0
  37. {quantui-0.13.0 → quantui-0.13.1}/quantui/backends/__init__.py +0 -0
  38. {quantui-0.13.0 → quantui-0.13.1}/quantui/backends/base.py +0 -0
  39. {quantui-0.13.0 → quantui-0.13.1}/quantui/backends/batch_chain.py +0 -0
  40. {quantui-0.13.0 → quantui-0.13.1}/quantui/backends/batch_input.py +0 -0
  41. {quantui-0.13.0 → quantui-0.13.1}/quantui/backends/batch_status.py +0 -0
  42. {quantui-0.13.0 → quantui-0.13.1}/quantui/backends/cluster_config.py +0 -0
  43. {quantui-0.13.0 → quantui-0.13.1}/quantui/backends/cluster_security.py +0 -0
  44. {quantui-0.13.0 → quantui-0.13.1}/quantui/backends/dispatch.py +0 -0
  45. {quantui-0.13.0 → quantui-0.13.1}/quantui/backends/local.py +0 -0
  46. {quantui-0.13.0 → quantui-0.13.1}/quantui/backends/registry.py +0 -0
  47. {quantui-0.13.0 → quantui-0.13.1}/quantui/backends/result_summary.py +0 -0
  48. {quantui-0.13.0 → quantui-0.13.1}/quantui/backends/slurm.py +0 -0
  49. {quantui-0.13.0 → quantui-0.13.1}/quantui/backends/slurm_errors.py +0 -0
  50. {quantui-0.13.0 → quantui-0.13.1}/quantui/backends/slurm_ingest.py +0 -0
  51. {quantui-0.13.0 → quantui-0.13.1}/quantui/backends/slurm_utils.py +0 -0
  52. {quantui-0.13.0 → quantui-0.13.1}/quantui/backends/worker.py +0 -0
  53. {quantui-0.13.0 → quantui-0.13.1}/quantui/backends/worker_payload.py +0 -0
  54. {quantui-0.13.0 → quantui-0.13.1}/quantui/batch_launcher.py +0 -0
  55. {quantui-0.13.0 → quantui-0.13.1}/quantui/benchmarks.py +0 -0
  56. {quantui-0.13.0 → quantui-0.13.1}/quantui/c_stderr.py +0 -0
  57. {quantui-0.13.0 → quantui-0.13.1}/quantui/cactus.py +0 -0
  58. {quantui-0.13.0 → quantui-0.13.1}/quantui/calc_log.py +0 -0
  59. {quantui-0.13.0 → quantui-0.13.1}/quantui/calculator.py +0 -0
  60. {quantui-0.13.0 → quantui-0.13.1}/quantui/cancellation.py +0 -0
  61. {quantui-0.13.0 → quantui-0.13.1}/quantui/checklist_widget.py +0 -0
  62. {quantui-0.13.0 → quantui-0.13.1}/quantui/checkpoint.py +0 -0
  63. {quantui-0.13.0 → quantui-0.13.1}/quantui/chg_dispersion.py +0 -0
  64. {quantui-0.13.0 → quantui-0.13.1}/quantui/cli.py +0 -0
  65. {quantui-0.13.0 → quantui-0.13.1}/quantui/comparison.py +0 -0
  66. {quantui-0.13.0 → quantui-0.13.1}/quantui/config.py +0 -0
  67. {quantui-0.13.0 → quantui-0.13.1}/quantui/connectivity.py +0 -0
  68. {quantui-0.13.0 → quantui-0.13.1}/quantui/data/js/3Dmol-LICENSE.txt +0 -0
  69. {quantui-0.13.0 → quantui-0.13.1}/quantui/data/js/3Dmol-min.js +0 -0
  70. {quantui-0.13.0 → quantui-0.13.1}/quantui/data/js/3Dmol-min.js.LICENSE.txt +0 -0
  71. {quantui-0.13.0 → quantui-0.13.1}/quantui/data/js/PROVENANCE.md +0 -0
  72. {quantui-0.13.0 → quantui-0.13.1}/quantui/data/launcher/quantui_batch.py +0 -0
  73. {quantui-0.13.0 → quantui-0.13.1}/quantui/data/library/QM9-PROVENANCE.md +0 -0
  74. {quantui-0.13.0 → quantui-0.13.1}/quantui/data/library/library.sqlite +0 -0
  75. {quantui-0.13.0 → quantui-0.13.1}/quantui/data/manifests/bulk_qm9.json +0 -0
  76. {quantui-0.13.0 → quantui-0.13.1}/quantui/data/manifests/curated.json +0 -0
  77. {quantui-0.13.0 → quantui-0.13.1}/quantui/data/manifests/inorganic.json +0 -0
  78. {quantui-0.13.0 → quantui-0.13.1}/quantui/data/manifests/presets.json +0 -0
  79. {quantui-0.13.0 → quantui-0.13.1}/quantui/density_fitting.py +0 -0
  80. {quantui-0.13.0 → quantui-0.13.1}/quantui/descriptor_cards.py +0 -0
  81. {quantui-0.13.0 → quantui-0.13.1}/quantui/downloads.py +0 -0
  82. {quantui-0.13.0 → quantui-0.13.1}/quantui/ecd_plot.py +0 -0
  83. {quantui-0.13.0 → quantui-0.13.1}/quantui/engines/__init__.py +0 -0
  84. {quantui-0.13.0 → quantui-0.13.1}/quantui/engines/base.py +0 -0
  85. {quantui-0.13.0 → quantui-0.13.1}/quantui/engines/pyfock_engine.py +0 -0
  86. {quantui-0.13.0 → quantui-0.13.1}/quantui/engines/pyscf_engine.py +0 -0
  87. {quantui-0.13.0 → quantui-0.13.1}/quantui/estimator_eval.py +0 -0
  88. {quantui-0.13.0 → quantui-0.13.1}/quantui/freq_calc.py +0 -0
  89. {quantui-0.13.0 → quantui-0.13.1}/quantui/freq_displacement_ids.py +0 -0
  90. {quantui-0.13.0 → quantui-0.13.1}/quantui/freq_ir_workers.py +0 -0
  91. {quantui-0.13.0 → quantui-0.13.1}/quantui/freq_raman_workers.py +0 -0
  92. {quantui-0.13.0 → quantui-0.13.1}/quantui/gaussian_input.py +0 -0
  93. {quantui-0.13.0 → quantui-0.13.1}/quantui/gpu_offload.py +0 -0
  94. {quantui-0.13.0 → quantui-0.13.1}/quantui/help_content.py +0 -0
  95. {quantui-0.13.0 → quantui-0.13.1}/quantui/inorganic_guards.py +0 -0
  96. {quantui-0.13.0 → quantui-0.13.1}/quantui/ir_plot.py +0 -0
  97. {quantui-0.13.0 → quantui-0.13.1}/quantui/irc.py +0 -0
  98. {quantui-0.13.0 → quantui-0.13.1}/quantui/issue_tracker.py +0 -0
  99. {quantui-0.13.0 → quantui-0.13.1}/quantui/live_log.py +0 -0
  100. {quantui-0.13.0 → quantui-0.13.1}/quantui/log_utils.py +0 -0
  101. {quantui-0.13.0 → quantui-0.13.1}/quantui/measurement.py +0 -0
  102. {quantui-0.13.0 → quantui-0.13.1}/quantui/molecule.py +0 -0
  103. {quantui-0.13.0 → quantui-0.13.1}/quantui/molecule_library.py +0 -0
  104. {quantui-0.13.0 → quantui-0.13.1}/quantui/mulliken_plot.py +0 -0
  105. {quantui-0.13.0 → quantui-0.13.1}/quantui/nmr_calc.py +0 -0
  106. {quantui-0.13.0 → quantui-0.13.1}/quantui/nmr_plot.py +0 -0
  107. {quantui-0.13.0 → quantui-0.13.1}/quantui/nmr_ssc.py +0 -0
  108. {quantui-0.13.0 → quantui-0.13.1}/quantui/optimizer.py +0 -0
  109. {quantui-0.13.0 → quantui-0.13.1}/quantui/orbital_visualization.py +0 -0
  110. {quantui-0.13.0 → quantui-0.13.1}/quantui/pes_scan.py +0 -0
  111. {quantui-0.13.0 → quantui-0.13.1}/quantui/pes_scan_2d.py +0 -0
  112. {quantui-0.13.0 → quantui-0.13.1}/quantui/pes_scan_2d_plot.py +0 -0
  113. {quantui-0.13.0 → quantui-0.13.1}/quantui/pes_scan_ui.py +0 -0
  114. {quantui-0.13.0 → quantui-0.13.1}/quantui/plotly_embed.py +0 -0
  115. {quantui-0.13.0 → quantui-0.13.1}/quantui/population_analysis.py +0 -0
  116. {quantui-0.13.0 → quantui-0.13.1}/quantui/populations_overlay.py +0 -0
  117. {quantui-0.13.0 → quantui-0.13.1}/quantui/preopt.py +0 -0
  118. {quantui-0.13.0 → quantui-0.13.1}/quantui/progress.py +0 -0
  119. {quantui-0.13.0 → quantui-0.13.1}/quantui/pubchem.py +0 -0
  120. {quantui-0.13.0 → quantui-0.13.1}/quantui/pyfock_gpu.py +0 -0
  121. {quantui-0.13.0 → quantui-0.13.1}/quantui/raman_calc.py +0 -0
  122. {quantui-0.13.0 → quantui-0.13.1}/quantui/raman_plot.py +0 -0
  123. {quantui-0.13.0 → quantui-0.13.1}/quantui/reaction_energy.py +0 -0
  124. {quantui-0.13.0 → quantui-0.13.1}/quantui/reorganization_energy.py +0 -0
  125. {quantui-0.13.0 → quantui-0.13.1}/quantui/results_storage.py +0 -0
  126. {quantui-0.13.0 → quantui-0.13.1}/quantui/scf_robust.py +0 -0
  127. {quantui-0.13.0 → quantui-0.13.1}/quantui/scf_stability.py +0 -0
  128. {quantui-0.13.0 → quantui-0.13.1}/quantui/security.py +0 -0
  129. {quantui-0.13.0 → quantui-0.13.1}/quantui/session_calc.py +0 -0
  130. {quantui-0.13.0 → quantui-0.13.1}/quantui/spectrum_overlay.py +0 -0
  131. {quantui-0.13.0 → quantui-0.13.1}/quantui/spin_presets.py +0 -0
  132. {quantui-0.13.0 → quantui-0.13.1}/quantui/structure_edit.py +0 -0
  133. {quantui-0.13.0 → quantui-0.13.1}/quantui/structure_overlay.py +0 -0
  134. {quantui-0.13.0 → quantui-0.13.1}/quantui/structure_providers.py +0 -0
  135. {quantui-0.13.0 → quantui-0.13.1}/quantui/structure_upload.py +0 -0
  136. {quantui-0.13.0 → quantui-0.13.1}/quantui/symmetry.py +0 -0
  137. {quantui-0.13.0 → quantui-0.13.1}/quantui/symmetry_constraint.py +0 -0
  138. {quantui-0.13.0 → quantui-0.13.1}/quantui/theme.py +0 -0
  139. {quantui-0.13.0 → quantui-0.13.1}/quantui/ts_guess.py +0 -0
  140. {quantui-0.13.0 → quantui-0.13.1}/quantui/ts_search.py +0 -0
  141. {quantui-0.13.0 → quantui-0.13.1}/quantui/user_settings.py +0 -0
  142. {quantui-0.13.0 → quantui-0.13.1}/quantui/utils.py +0 -0
  143. {quantui-0.13.0 → quantui-0.13.1}/quantui/vib_cache.py +0 -0
  144. {quantui-0.13.0 → quantui-0.13.1}/quantui/visualization_py3dmol.py +0 -0
  145. {quantui-0.13.0 → quantui-0.13.1}/quantui/viz_assets.py +0 -0
  146. {quantui-0.13.0 → quantui-0.13.1}/quantui/viz_backend_router.py +0 -0
  147. {quantui-0.13.0 → quantui-0.13.1}/quantui/xcheck/__init__.py +0 -0
  148. {quantui-0.13.0 → quantui-0.13.1}/quantui/xyz_input.py +0 -0
  149. {quantui-0.13.0 → quantui-0.13.1}/quantui.egg-info/SOURCES.txt +0 -0
  150. {quantui-0.13.0 → quantui-0.13.1}/quantui.egg-info/dependency_links.txt +0 -0
  151. {quantui-0.13.0 → quantui-0.13.1}/quantui.egg-info/entry_points.txt +0 -0
  152. {quantui-0.13.0 → quantui-0.13.1}/quantui.egg-info/requires.txt +0 -0
  153. {quantui-0.13.0 → quantui-0.13.1}/quantui.egg-info/top_level.txt +0 -0
  154. {quantui-0.13.0 → quantui-0.13.1}/setup.cfg +0 -0
@@ -7,6 +7,23 @@ and this project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.ht
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.13.1] - 2026-12-05
11
+
12
+ ### Fixed
13
+
14
+ - **UV-Vis (TD-DFT) could miss low-lying excited states**, mostly for
15
+ open-shell molecules: the iterative solver, asked for exactly the number
16
+ of states wanted, sometimes converged to higher roots and skipped lower
17
+ ones (for example the 4.5 eV state of the OH radical). QuantUI now solves
18
+ for a few extra states and reports the lowest ones requested, so spectra
19
+ include every low-energy band. Open-shell UV-Vis results from earlier
20
+ versions should be recomputed.
21
+
22
+ ### Changed
23
+
24
+ - The backend cross-check's TD-DFT reference solves for extra states too and
25
+ now includes an open-shell case.
26
+
10
27
  ## [0.13.0] - 2026-12-05
11
28
 
12
29
  This release adds a built-in cross-check of QuantUI's numbers against its
@@ -1706,7 +1723,8 @@ Initial public scaffolding of the QuantUI package: `quantui` package with
1706
1723
  `calculator.py`, basic notebook launcher, Apptainer container definition,
1707
1724
  MIT license, and project metadata.
1708
1725
 
1709
- [Unreleased]: https://github.com/The-Schultz-Lab/QuantUI/compare/v0.13.0...HEAD
1726
+ [Unreleased]: https://github.com/The-Schultz-Lab/QuantUI/compare/v0.13.1...HEAD
1727
+ [0.13.1]: https://github.com/The-Schultz-Lab/QuantUI/compare/v0.13.0...v0.13.1
1710
1728
  [0.13.0]: https://github.com/The-Schultz-Lab/QuantUI/compare/v0.12.0...v0.13.0
1711
1729
  [0.12.0]: https://github.com/The-Schultz-Lab/QuantUI/compare/v0.11.1...v0.12.0
1712
1730
  [0.11.1]: https://github.com/The-Schultz-Lab/QuantUI/compare/v0.11.0...v0.11.1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: quantui
3
- Version: 0.13.0
3
+ Version: 0.13.1
4
4
  Summary: An open-source frontend for DFT and post-HF quantum chemistry with PySCF
5
5
  Author-email: Jonathan Schultz <nccu-schultz-lab@users.noreply.github.com>
6
6
  License-Expression: MIT
@@ -11,7 +11,7 @@ build-backend = "setuptools.build_meta"
11
11
 
12
12
  [project]
13
13
  name = "quantui"
14
- version = "0.13.0"
14
+ version = "0.13.1"
15
15
  description = "An open-source frontend for DFT and post-HF quantum chemistry with PySCF"
16
16
  readme = "README.md"
17
17
  requires-python = ">=3.9"
@@ -7,7 +7,7 @@ Calculations run locally in the Jupyter session — no cluster or SLURM required
7
7
  PySCF requires Linux/macOS/WSL. Windows users should use the Apptainer container.
8
8
  """
9
9
 
10
- __version__ = "0.13.0"
10
+ __version__ = "0.13.1"
11
11
 
12
12
  import logging
13
13
  from typing import Any
@@ -116,6 +116,46 @@ def rotatory_strengths(td: Any) -> tuple[List[float], List[float]]:
116
116
  # ============================================================================
117
117
 
118
118
 
119
+ # The iterative (Davidson) excited-state solver converges to the roots its
120
+ # start vectors overlap with, so asking it for exactly n states can return n
121
+ # roots that are not the lowest n: UHF OH/6-31G with 2 states misses its
122
+ # 4.5 eV state, and NH2 its 7.5 eV state with 2 or 3. Solving for a few
123
+ # extra states and keeping the lowest n fixed every case checked (UHF, UKS,
124
+ # RKS; 2, 5 and 10 states needed at most +3).
125
+ def solver_nstates(nstates: int, mo_occ: Any) -> int:
126
+ """States to ask the solver for so the lowest *nstates* are found.
127
+
128
+ ``nstates + max(3, ceil(0.3 * nstates))``, capped at the number of
129
+ single excitations (occupied x virtual, per spin channel).
130
+ """
131
+ import math
132
+
133
+ import numpy as np
134
+
135
+ occ = np.asarray(mo_occ)
136
+ dim: int
137
+ if occ.ndim == 1:
138
+ n_occ = int((occ > 0).sum())
139
+ dim = n_occ * (int(occ.size) - n_occ)
140
+ else:
141
+ dim = int(sum(int((o > 0).sum()) * int((o == 0).sum()) for o in occ))
142
+ want = int(nstates) + max(3, math.ceil(0.3 * int(nstates)))
143
+ return max(int(nstates), min(want, dim)) if dim > 0 else int(nstates)
144
+
145
+
146
+ def _keep_lowest(td: Any, nstates: int) -> None:
147
+ """Trim a solved TD object to its lowest *nstates* roots, in place."""
148
+ import numpy as np
149
+
150
+ e = np.asarray(td.e)
151
+ order = np.argsort(e)[: int(nstates)]
152
+ td.e = e[order]
153
+ td.xy = [td.xy[i] for i in order]
154
+ conv = getattr(td, "converged", None)
155
+ if conv is not None and np.ndim(conv) > 0 and len(conv) == len(e):
156
+ td.converged = np.asarray(conv)[order]
157
+
158
+
119
159
  @dataclass
120
160
  class TDDFTResult:
121
161
  """Structured output from a TD-DFT excited-state calculation.
@@ -497,7 +537,7 @@ def _run_tddft_calc_body(
497
537
  td = mf.TDHF() if using_hf else mf.TDDFT()
498
538
  if pcm_solvent:
499
539
  _use_optical_dielectric(td, pcm_solvent, stream)
500
- td.nstates = nstates
540
+ td.nstates = solver_nstates(nstates, mf.mo_occ)
501
541
  # verbose=5 (DEBUG) is what surfaces PySCF's per-root "root %d
502
542
  # converged" lines during the Davidson solve — the only progress
503
543
  # signal available while it runs. _LogCapture.write in app.py greps
@@ -505,6 +545,16 @@ def _run_tddft_calc_body(
505
545
  td.verbose = 5
506
546
  td.stdout = stream
507
547
  td.kernel()
548
+ if td.nstates > nstates:
549
+ _keep_lowest(td, nstates)
550
+ try:
551
+ stream.write(
552
+ f"\nSolved for {td.nstates} states and kept the lowest "
553
+ f"{nstates} (the solver can skip low roots when asked for "
554
+ "exactly the number wanted).\n"
555
+ )
556
+ except Exception: # noqa: BLE001 — cleanup (stream may be closed)
557
+ pass
508
558
 
509
559
  excitation_energies_ev = [float(e) * HARTREE_TO_EV for e in td.e]
510
560
  osc = td.oscillator_strength()
@@ -203,6 +203,22 @@ CASES: Tuple[XCase, ...] = (
203
203
  options={"nstates": 4},
204
204
  description="TD-DFT excitation energies and oscillator strengths.",
205
205
  ),
206
+ XCase(
207
+ "td-nh2-uhf-631g",
208
+ "tddft",
209
+ ("N", "H", "H"),
210
+ (
211
+ (0.0, 0.0, 0.1478),
212
+ (0.0, 0.7958, -0.5174),
213
+ (0.0, -0.7958, -0.5174),
214
+ ),
215
+ "UHF",
216
+ "6-31G",
217
+ multiplicity=2,
218
+ options={"nstates": 3},
219
+ description="Open-shell excitations: the lowest roots, not just the "
220
+ "ones the solver reaches when asked for exactly nstates.",
221
+ ),
206
222
  XCase(
207
223
  "opt-h2o-rhf-sto3g",
208
224
  "geometry_opt",
@@ -599,16 +599,28 @@ def tddft(
599
599
  mol = build_mol(atoms, coords, basis, charge, multiplicity)
600
600
  mf = build_scf(mol, method)
601
601
  mf.kernel()
602
- if method.upper() in ("RHF",):
602
+ if method.upper() in ("RHF", "UHF"):
603
603
  td = mf.TDHF()
604
604
  else:
605
605
  td = mf.TDDFT()
606
- td.nstates = int(nstates)
606
+ # The Davidson solver converges to the roots its start vectors reach, so
607
+ # asking for exactly n states can skip low ones. Solve for plenty more
608
+ # and keep the lowest n: this is the reference for "the lowest n".
609
+ td.nstates = int(nstates) + 10
607
610
  td.conv_tol = 1e-9
608
611
  td.verbose = 0
609
612
  td.kernel()
610
- omega = np.asarray(td.e, dtype=float)
613
+ keep = np.argsort(np.asarray(td.e, dtype=float))[: int(nstates)]
614
+ omega = np.asarray(td.e, dtype=float)[keep]
611
615
  hartree_ev = _nist().HARTREE2EV
616
+ f_all = np.asarray(td.oscillator_strength(gauge="length"), dtype=float)
617
+ out: Dict[str, Any] = {
618
+ "energy_hartree": float(mf.e_tot),
619
+ "excitation_energies_ev": [float(w * hartree_ev) for w in omega],
620
+ "oscillator_strengths": [float(v) for v in f_all[keep]],
621
+ }
622
+ if np.asarray(mf.mo_occ).ndim != 1:
623
+ return out # open shell: the closed-shell moment formulas below do not apply
612
624
  occ = mf.mo_occ > 0
613
625
  orbo = mf.mo_coeff[:, occ]
614
626
  orbv = mf.mo_coeff[:, ~occ]
@@ -623,21 +635,17 @@ def tddft(
623
635
 
624
636
  r_ia, p_ia, l_ia = mo_block(r_ao), mo_block(nabla_ao), mo_block(rxnabla_ao)
625
637
  f_own, r_vel = [], []
626
- for k, (x, y) in enumerate(td.xy):
638
+ for k, idx in enumerate(keep):
639
+ x, y = td.xy[idx]
627
640
  d = 2.0 * np.einsum("xia,ia->x", r_ia, x + y)
628
641
  p = 2.0 * np.einsum("xia,ia->x", p_ia, x - y)
629
642
  g = 2.0 * np.einsum("xia,ia->x", l_ia, x - y)
630
643
  f_own.append(2.0 / 3.0 * omega[k] * float(d @ d))
631
644
  r_vel.append(float(p @ g) / (2.0 * omega[k]))
632
- f_pyscf = [float(v) for v in td.oscillator_strength(gauge="length")]
633
645
  conv = rotatory_strength_au_to_cgs40()
634
- return {
635
- "energy_hartree": float(mf.e_tot),
636
- "excitation_energies_ev": [float(w * hartree_ev) for w in omega],
637
- "oscillator_strengths": f_pyscf,
638
- "_oscillator_strengths_own": f_own,
639
- "rotatory_strengths_velocity": [r * conv for r in r_vel],
640
- }
646
+ out["_oscillator_strengths_own"] = f_own
647
+ out["rotatory_strengths_velocity"] = [r * conv for r in r_vel]
648
+ return out
641
649
 
642
650
 
643
651
  # ---------------------------------------------------------------------------
@@ -670,6 +670,8 @@ def _check_tddft(case: XCase, path: str, data: Dict[str, Any]) -> List[CheckRow]
670
670
  # Degenerate states may come back in either order: compare per
671
671
  # degenerate group (sums), which is what a spectrum shows anyway.
672
672
  for q in ("oscillator_strengths", "rotatory_strengths_velocity"):
673
+ if q not in r:
674
+ continue # open shell: no closed-shell rotatory-strength reference
673
675
  qv = uv.get(q)
674
676
  rv = r[q]
675
677
  if qv is not None and len(qv) == len(rv):
@@ -681,6 +683,8 @@ def _check_tddft(case: XCase, path: str, data: Dict[str, Any]) -> List[CheckRow]
681
683
  if not qv and not any(abs(x) > 1e-6 for x in rv):
682
684
  continue # achiral: both empty/zero, nothing to compare
683
685
  rows.append(compare(case.case_id, path, q, qv, rv, note=note))
686
+ if "_oscillator_strengths_own" not in r:
687
+ return rows
684
688
  own = r["_oscillator_strengths_own"]
685
689
  worst = max(
686
690
  (abs(a - b) for a, b in zip(own, r["oscillator_strengths"])), default=0.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: quantui
3
- Version: 0.13.0
3
+ Version: 0.13.1
4
4
  Summary: An open-source frontend for DFT and post-HF quantum chemistry with PySCF
5
5
  Author-email: Jonathan Schultz <nccu-schultz-lab@users.noreply.github.com>
6
6
  License-Expression: MIT
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes