Build a training set, fit 1-RDM and 2-RDM models, then drive AIMD with the ASE calculator. Click a notebook to read it in the browser, or download the .ipynb from that page and run it locally after you install QMLearn. Talks from the QMLearn YouTube playlist are at the bottom of this page.
HDF5 databases used in the papers are not shipped with the notebooks. Generate them with the training-set notebook, or point the AIMD scripts at your own .hdf5 files.
The first notebook builds a QMLearn database: displaced geometries, a PySCF engine, and stored potentials plus RDMs. The second notebook is the unified training workflow used for the 2-RDM paper: it fits γ, δγ, Γ, Γc, and Δ models, scans KRR hyperparameters, and plots potential-energy curves against CASCI/FCI references.
| Beginners | Notebook | Description |
|---|---|---|
| 👉 | create_training |
Sample geometries, run PySCF, and write an HDF5 training database. |
| 👉 | rdm_training |
Unified 1-RDM and 2-RDM fitting (γ, δγ, Γ, Γc, Δ), hyperparameter search, and PEC plots. |
The unified trainer lives as Unify_Training_Webpage.ipynb in the examples bundle; the copy above is the website tutorial.
These notebooks attach QMLCalculator to ASE and run NVE velocity-Verlet dynamics for water at 300 K (0.5 fs timestep). Production runs in the examples used 20 000 steps; the notebooks default to a short trajectory so they are interactive. Swap in your trained HDF5 path before running.
| Beginners | Notebook | Description |
|---|---|---|
| 👉 | aimd_1rdm |
1-RDM AIMD: learn δγ, then energy and forces from the predicted γ (method='gamma'). |
aimd_2rdm_gamma2c |
2-RDM AIMD from the correlated 2-RDM Γc (method='gamma2'). |
|
aimd_2rdm_cumulant |
2-RDM AIMD from δγ plus the cumulant Δ (method='gamma2cum'). |
Load a trained Γc model and attach it as an ASE calculator. The same pattern works for gamma and gamma2cum by changing the target, method, and kernel-ridge key.
from sklearn.kernel_ridge import KernelRidge
from qmlearn.io.model import db2qmmodel
from qmlearn.api.api4ase import QMLCalculator
from ase.build import molecule
models = {'gamma2c': KernelRidge(alpha=0.0, kernel='rbf')}
qmmodel = db2qmmodel('train.hdf5', mmodels=models,
target='gamma2c', method='gamma2c',
purify_gamma=True)
atoms = molecule('H2O')
atoms.calc = QMLCalculator(qmmodel=qmmodel, method='gamma2',
properties=('energy',))
print(atoms.get_potential_energy())
The notebooks above are the tutorial versions. The original water AIMD scripts (20 000 steps) and SLURM jobfiles are in notebooks/examples/.
4_gamma_300 — 1-RDM AIMD1_Gamma_C_300 — Γc 2-RDM AIMD2_Cum_300 — cumulant 2-RDM AIMD3_Exact_FCI — FCI-trained 1-RDM AIMD (reference-style)On HPC, wrap the AIMD Python with your site’s job script. Keep OMP_NUM_THREADS=1 unless you have measured a benefit from threaded BLAS inside PySCF.