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

Notebooks · lib/hf/mole

A molecule from text and a basis name, as PySCF takes them

import basis.pople631g
from hf.mole import molecule
from hf.scf import rhf

mol = molecule("O 0 0 0; H 0 -0.757 0.587; H 0 0.757 0.587", "6-31g")
r = rhf(mol)
show r.energy

molecule(atoms, basis) is PySCF's gto.M(atom=atoms, basis=basis): the atoms as text, each an element symbol and three coordinates in angstrom, separated by ; or by newlines, or a whole XYZ file (a count line, a comment line, then the atoms), read by lib/xyz's parse_xyz; the basis by the name PySCF uses, in any case, with or without the hyphens (lib/basis/named: "sto-3g", "6-31g", "6-31g", "6-31g*", "cc-pvdz", "cc-pvtz", "def2-svp", "def2-tzvp"). It gives the Molecule of lib/hf/molecule, the one molecule_from builds from atomic numbers, an array of coordinates and a Basis record: the same atoms, shells and primitives, bit for bit (scf/molecule_text.viv checks every molecule of the lock ladder).

molecule_in(atoms, basis, unit) reads the coordinates in unit: "bohr" (or "b", "au", any case, PySCF's unit="B") or "angstrom" ("a", "ang"). Charge, spin and Cartesian functions are record updates, as for every Molecule:

cation = Molecule { charge: 1, spin: 1, ..mol }

An element symbol lib/xyz does not know, a basis name that is not one of the eight, or an element the chosen basis set has no functions for stops the run and says what is available.

The name is looked up among the tables of lib/basis (lib/basis/named). A program that uses none of them gets all eight; one that uses the table it names (import basis.pople631g) links that table alone, and a name whose table such a program does not use stops the run and says which import line to add.

Used with import hf.mole.

Look inside this program

  • Atlas

    The program’s map: every function and which calls which.

  • There’s no recorded run of this program yet.

Shift+Enter in a cell runs it and moves to the next. Running a cell runs every cell above it too, as one program.

[1]lines 44–111