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/xyz

Atoms from XYZ text

parse_xyz(text) reads a molecule's atoms into a Geometry: each atom's symbol, its atomic number, and the positions as an n x 3 array, in the text's unit (angstroms, in an XYZ file). lib/hf/mole builds a Hartree-Fock Molecule from the same text.

It takes the XYZ format (a line with the number of atoms, a comment line, then one symbol x y z line per atom) and the same atoms with no header, one per line or separated by semicolons, as PySCF's atom= string writes them: "O 0 0 0; H 0 0.757 0.587; H 0 -0.757 0.587". A symbol may be written in either case (o, O). A count that does not match the atoms, a line that is not a symbol and three numbers, or a symbol that is not an element stops the run and says which.

Used with import xyz.

Look inside this program

  • Atlas

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

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

This program declares a record type (Geometry), and records run only in compiled C for now, so the Run buttons here are off. Open it in the workbench and use its C tab to compile it.

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 21–96