Native Molecular Geometry Optimizer¶
vibe-qc ships a standalone molecular geometry optimizer that needs no
ASE. It wraps analytic SCF nuclear gradients under scipy’s L-BFGS-B
minimiser and is available both as a library function and through
run_job.
Quick start¶
from vibeqc import Molecule, Atom
from vibeqc.molecular_optimize import optimize_molecule
mol = Molecule([
Atom(8, [ 0.00, 0.00, 0.00]),
Atom(1, [ 0.00, 1.43, -0.98]),
Atom(1, [ 0.00, -1.43, -0.98]),
])
result = optimize_molecule(
mol,
basis_name="def2-svp",
method="rks",
functional="PBE",
)
print(result.system) # optimised Molecule (bohr)
print(result.energy) # final energy (Ha)
print(result.n_iter) # number of BFGS steps
print(result.converged) # True / False
Through run_job¶
Pass optimizer_backend="native" to bypass ASE:
from vibeqc import run_job
run_job(
mol,
basis="def2-svp",
method="rks",
functional="PBE",
optimize=True,
optimizer_backend="native", # ← no ASE needed
output="h2o_opt",
)
The default optimizer_backend="auto" prefers ASE when installed
and falls back to the native path otherwise, so existing workflows
are unchanged.
Supported methods¶
Method |
Gradient |
Notes |
|---|---|---|
|
Analytic |
All-electron, closed- and open-shell |
|
Analytic |
All DFT functionals with analytic gradients |
|
Central FD |
2-point finite difference on energy ( |
Dispersion corrections (D3-BJ) and implicit solvation (CPCM/COSMO) are folded into the energy and gradient automatically when passed.
Trajectory collection¶
Set record_trajectory=True (the default) to collect per-step
geometries and energies:
result = optimize_molecule(mol, basis_name="sto-3g", method="rhf")
for i, (frame, e) in enumerate(
zip(result.trajectory_frames, result.trajectory_energies)
):
print(f" step {i}: E = {e:.8f} Ha")
When used through run_job(optimize=True, output_qvf=True), the
trajectory is embedded in the QVF archive for vibe-view’s animation
player — identical behaviour to the ASE backend.
Convergence control¶
Parameter |
Default |
Meaning |
|---|---|---|
|
|
Gradient norm convergence (Ha/bohr) |
|
|
Energy change tolerance (Ha) |
|
|
Maximum L-BFGS-B steps |
For DFT jobs where the SCF may struggle at intermediate geometries
(common with PBE + minimal basis sets), pass the appropriate
rks_options / uks_options with increased max_iter:
from vibeqc import RKSOptions
rks_opts = RKSOptions()
rks_opts.max_iter = 80
rks_opts.use_diis = True
result = optimize_molecule(
mol, basis_name="sto-3g", method="rks", functional="PBE",
rks_options=rks_opts,
)
API reference¶
- class vibeqc.molecular_optimize.MolecularOptimizeResult(system, energy, gradient, n_iter, converged, trajectory_frames=None, trajectory_energies=None)[source]¶
Bases:
objectContainer for molecular geometry optimization results.
- vibeqc.molecular_optimize.optimize_molecule(molecule, basis_name, *, method='rhf', functional=None, rhf_options=None, uhf_options=None, rks_options=None, uks_options=None, max_iter=100, conv_tol_grad=0.00045, conv_tol_energy=1e-06, gradient_options=None, grid_options=None, dispersion_params=None, solvent=None, record_trajectory=True, progress=False, fd_step_bohr=0.005)[source]¶
Relax molecular geometry using analytic gradients + L-BFGS-B.
- Parameters:
molecule (vibeqc._vibeqc_core.Molecule) – Starting geometry (Cartesian coordinates in bohr).
basis_name (str) – Basis-set name (rebuilt at each geometry step).
method (str) –
"rhf","uhf","rks","uks", or a wavefunction method ("selected_ci","dmrg","v2rdm","transcorrelated_ci"). Wavefunction methods fall back to central finite differences on the energy.functional (str | None) – XC functional string for
"rks"/"uks"(e.g."PBE").uks_options (vibeqc._vibeqc_core.UKSOptions | None) – Per-method SCF options. If
None, defaults are used.max_iter (int) – Maximum L-BFGS-B iterations.
conv_tol_grad (float) – Gradient convergence tolerance (Ha/bohr). Default 4.5e-4 corresponds to ~0.01 eV/Å — tight enough for routine use.
conv_tol_energy (float) – Energy convergence tolerance (Ha). Controls the scipy
ftolparameter.gradient_options (vibeqc._vibeqc_core.GradientOptions | None) – Options for the analytic gradient kernels (density fitting, COSX, etc.).
grid_options (vibeqc._vibeqc_core.GridOptions | None) – DFT integration grid options (RKS / UKS only).
dispersion_params (Any) – A
D3BJParamsinstance — if provided, the D3-BJ energy and gradient are folded into the objective.solvent (Any) – A
SolventModelor preset string / dict for CPCM implicit solvation (v0.9.0).record_trajectory (bool) – If True (default), collect per-step geometries and energies for downstream visualisation (QVF animation player).
progress (bool) – If True, print per-step energy and gradient norms to stdout.
fd_step_bohr (float) – Finite-difference step size for wavefunction-method gradients (bohr). Default 0.005 (≈ 0.0026 Å).
rhf_options (vibeqc._vibeqc_core.RHFOptions | None)
uhf_options (vibeqc._vibeqc_core.UHFOptions | None)
rks_options (vibeqc._vibeqc_core.RKSOptions | None)
uks_options
- Return type: