This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org

Engines · hf-energy

Hartree-Fock energy of a molecule, from an XYZ file and a basis name

Give it a molecule as an XYZ file and name a basis. It builds the Gaussian basis the way PySCF does, runs Hartree–Fock through lib/hf in your browser, and prints the energy and the orbital energies. Water in 6-31G takes about three seconds.

Examples
Drop a file here, or paste one below

What it takes and gives

The engine is engines/hf-energy.viv, 114 lines of Viv that run lib/hf/scf. Its header says what it takes and gives:

#! engine hf-energy
#! title Hartree-Fock energy of a molecule, from an XYZ file and a basis name
#! program lib/hf/scf
#! input molecule: xyz
#! input settings: basis (sto-3g | 6-31g | 6-31g* | cc-pvdz | def2-svp), charge, spin, method (rhf | uhf | rohf), spherical or cartesian
#! output total-energy, orbital-energies
#! limit tab: elements H to Ar, up to an estimated 60 s in the interpreter; larger runs natively with viv run
#! validated water 6-31g: lib/hfref/water_631g.viv
#! validated water cc-pvdz: lib/hfref/water_ccpvdz.viv
input
molecule: xyz
input
settings: basis (sto-3g | 6-31g | 6-31g* | cc-pvdz | def2-svp), charge, spin, method (rhf | uhf | rohf), spherical or cartesian
output
total-energy, orbital-energies
limit
tab: elements H to Ar, up to an estimated 60 s in the interpreter; larger runs natively with viv run
validated
water 6-31g: lib/hfref/water_631g.viv
validated
water cc-pvdz: lib/hfref/water_ccpvdz.viv

What happens to your file

  1. The XYZ file is read: symbols (or atomic numbers) and positions in ångström. The comment line may carry basis=, charge= and multiplicity= (or spin=, as Nα − Nβ), which fill in the form above.
  2. The basis is built as PySCF builds it: its library’s shells, every general contraction split into one shell per column, zero coefficients dropped, ångström converted with PySCF’s own bohr. For water, hydroxyl and ammonia the basis-set data it builds matches lib/hfref’s, number for number.
  3. lib/hf runs: overlap, kinetic and nuclear-attraction integrals, the two-electron integrals, the optional transform to spherical functions, and RHF, UHF or ROHF, each stage using the implementation lib/hf uses by default. Then the converged Fock matrix is diagonalized once more for the orbital energies.

The cost estimate is c · P^a · n^b, where P counts primitive Cartesian functions and n basis functions, fitted to 9 runs from water in 6-31G (2.3 s) to ethanol in 6-31G* (374.1 s). It is within 29% of every one of them. A molecule estimated above 60 s, or with more than 60 basis functions, is not offered here.

How it is checked

When lib/hfref holds the same molecule, basis, charge, spin and method, its PySCF energy is handed to the program, which prints the difference; the tests of lib/hf require it to match PySCF to 10−9 hartree. The orbital energies of water and hydroxyl are compared with PySCF’s in the tests. These are the last recorded runs:

inputreferenceenergy, Haerror, Haseconds
water.xyz, 6-31gWATER631G_E_RHF-75.98394849812.0e-132.5
oh.xyz, 6-31gOH_631G_E_UHF-75.36316991971.3e-132.4
ammonia.xyz, 6-31g*NH3_631GS_E_RHF-56.18324204851.4e-148.3

Seconds are timings under Node.js on the machine that ran the tests; a browser tab is usually a little slower. The XYZ reader and basis builder have their own tests: the basis arrays for every example, and inputs that must be refused, each with its reason.

The basis sets come from the Basis Set Exchange. PySCF 2.5.0 (Apache-2.0) is the reference the energies are compared with; no PySCF code is copied.

What it does not do