Quantum Chemistry Algorithms
Overview
unitarylab_algorithms.quantum_chemistry provides MolecularDMRGAlgorithm, which always runs this pipeline:
PySCF/OpenFermion electronic structure
-> physics-tenpy DMRG ground state
-> SciPy L-BFGS-B CVD circuit conversion
-> UnitaryLab QWC measurement and OpenQASM exportThe algorithm inherits the shared unitarylab_algorithms.algo_base.BaseAlgorithm, returning the standard result dictionary plus energy, active-space, circuit-quality, and measurement fields.
Installation and Platforms
pip install "unitarylab[chemistry]" unitarylab-algorithmsMolecular DMRG and its Chemistry dependencies support Linux and macOS only and do not support Windows. This does not affect the other algorithm categories on Windows. The implementation currently reaches the independent Chemistry package through the compatibility path unitarylab.library.chemistry; Chemistry is not bundled in the main simulator.
Import and Run
MolecularDMRGAlgorithm is included in the root __all__:
from unitarylab_algorithms import MolecularDMRGAlgorithm
algorithm = MolecularDMRGAlgorithm(text_mode="plain")
result = algorithm.run(
xyz_file="H2",
basis="sto-3g",
active_occupied_orbitals=1,
active_virtual_orbitals=1,
max_iterations=100,
chi0=20,
nsweeps=100,
maxdim=100,
cutoff=1e-8,
shots=10_000,
seed=2077,
backend="torch",
device="cpu",
dtype="complex128",
)
print(result["status"])
print(result["DMRG energy"])
print(result["Sampled energy"])The module-level test() accepts an optional xyz_file and always runs the complete workflow:
from unitarylab_algorithms.quantum_chemistry.molecular_dmrg.algorithm import test
test(xyz_file="H2")The algorithm does not expose the lower-level workflow’s target argument; every run completes electronic structure, DMRG, CVD, and QWC measurement.
Parameters
| Parameter | Default | Description |
|---|---|---|
xyz_file | Python API: None | Bundled molecule name, .xyz filename, or path; None selects CH4.xyz, while the Web schema defaults to H2 |
basis | "sto-3g" | PySCF basis |
charge, multiplicity | 0, 1 | Molecular charge and spin multiplicity |
active_occupied_orbitals | 3 | Maximum number of active occupied orbitals |
active_virtual_orbitals | 3 | Maximum number of active virtual orbitals |
max_iterations | 100 | Maximum L-BFGS-B iterations for each local CVD gate |
cvd_restarts, cvd_init_scale | 3, 0.5 | Number of CVD restarts and initialization scale |
chi0, maxdim | 20, 100 | Initial and maximum DMRG bond dimensions |
nsweeps, cutoff | 100, 1e-8 | Maximum DMRG sweeps and truncation threshold |
shots, seed | 10000, 2077 | Samples per QWC group and seed; shots=0 skips sampling but still computes exact energy and exports QASM |
backend, device, dtype | torch, cpu, complex128 | UnitaryLab execution settings |
Bundled molecules are H2, LiH, H2O, CH4, CO, CO2, C6H6, HF, N2, NH3, and O2. Names without extensions resolve under molecules/; external XYZ paths are accepted.
Results and Files
Results include the standard fields status, circuit_path, plot, and circuit, plus these algorithm-specific fields:
HF energy,Active-space FCI energy,Active spaceDMRG energy,CVD layers,CVD infidelityUnitaryLab exact energy,Exact energy difference,Sampled energyMeasurement groups,Circuit depth,Circuit gates,QASM directory
The default directory is results/quantum_chemistry/molecular_dmrg/ under the current working directory. It contains the BaseAlgorithm result TXT, circuit SVG, and output/ with PySCF data and OpenQASM 2.0 files for each QWC group. The returned plot list contains the TXT and QASM artifacts; QASM entries have their format explicitly corrected to "qasm".
Notes
- Active-space size, DMRG bond dimension, CVD restarts, and optimizer iterations can greatly increase memory and runtime. Start with H2/sto-3g to validate the environment.
- The algorithm retains an active-space FCI reference but does not provide the MP2, CISD, CCSD, full post-SCF FCI switches, or Julia DMRG output from the old implementation.
MolecularDMRGResultis the result type of the lower-level Chemistry workflow. The algorithm documented here returns a BaseAlgorithm dictionary; do not confuse the two.