forte2.system.geom_utils#
Module Contents#
- forte2.system.geom_utils.parse_geometry(geom, unit)#
Parse a geometry string (XYZ or Z-matrix) into a list of atoms.
- Parameters:
- geomstr
Geometry string in XYZ or Z-matrix format.
- unitstr
Coordinate unit, “bohr” or “angstrom”.
- Returns:
- atomslist[tuple(int, NDArray)]
List of (Z, coords) tuples in Bohr.
- forte2.system.geom_utils.parse_xyz(lines, unit)#
Parse an XYZ string into a list of atoms.
- Parameters:
- lineslist[str]
The lines containing the XYZ atom symbols and coordinates.
- unitstr
The unit of the coordinates, either “bohr” or “angstrom”.
- Returns:
- atomslist[tuple(int, NDArray)]
A list of tuples, each containing the atomic number and a numpy array of coordinates.
- Raises:
- ValueError
If a line in the XYZ string does not match the expected format or has an incorrect number of coordinates.
Examples
>>> xyz = "Li 0.0 0.0 0.0\nN -10 0 0\n" >>> parse_xyz(xyz, "bohr") [(3, array([0., 0., 0.])), (7, array([-10., 0., 0.]))]
>>> xyz = "Li 0.0 0.0\nN -10 0\n" >>> parse_xyz(xyz, "angstrom") Traceback (most recent call last): ... ValueError: Invalid line in XYZ file: Li 0.0 0.0. Expected 3 coordinates, found 2.
- forte2.system.geom_utils.parse_zmatrix(lines, unit)#
Parse a Z-matrix string into a list of atoms.
- Parameters:
- lineslist[str]
The lines containing the Z-matrix atom symbols and coordinates.
- unitstr
The unit of the coordinates, either “bohr” or “angstrom”.
- Returns:
- atomslist[tuple(int, NDArray)]
A list of tuples, each containing the atomic number and a numpy array of coordinates.
- Raises:
- ValueError
If a line in the Z-matrix string does not match the expected format.
Examples
Unit bohr: H O 1 0.9 O 2 1.4 1 105.0 H 3 0.9 2 105.0 1 120.0
Should return: [[ 0. 0. 0. ] [ 1.70075351 0. 0. ] [ 2.38548947 0. -2.55546938] [ 3.29283067 1.42270804 -2.76806356]]