# Read a molecule written as XYZ text into atoms: symbol, atomic number, # position (the parser is lib/xyz.viv). from xyz import parse_xyz text = "3\nwater\nO 0.000000 0.000000 0.117300\nH 0.000000 0.757200 -0.469200\nH 0.000000 -0.757200 -0.469200\n" m = parse_xyz(text) for i, sym in enumerate(m.symbols) { print(f"{sym:<2} Z = {m.z[i]:2d} {m.xyz[i, 0]:9.6f} {m.xyz[i, 1]:9.6f} {m.xyz[i, 2]:9.6f}") } # the O-H distance, in angstroms d = m.xyz[1, 0:3] - m.xyz[0, 0:3] print("r(OH) =", fmt(sqrt(sum(d * d)), ".4f"), "A") # SPDX-License-Identifier: MIT OR Apache-2.0 # SPDX-FileCopyrightText: 2026 The Viv authors