This implementation in Python and numpy
converts a structure described by an
xyz coordinate file into POV-Ray scenes by
python ./xyz2povray.py input.xyz
with files input.pov
and input.ini
. Subsequently, either
- run
povray ./input.pov
to write a single bitmapinput.png
(800 × 600 px), or - run
povray ./input.ini
to generate a sequence of 36 frames (640 × 420 px) to rotate the structure around POV-Ray's x-axis. This can be used to generate an animated gif (for instance on ezgif) as shown below for a cyclic form of glucose.
All atoms starting from atomic number 1 (hydrogen, H) up to 96 (curium, Cm) are supported by a color scheme close to the one used by Jmol. If the interatomic distance is less or equal the sum of the corresponding covalent radii compiled by Wikipedia, two atoms are considered to be bound together; the model depicts them as connected by a tube. An atom "too far out" to bind with an other atom is going to be displayed as a sphere.
The camera is automatically directed to the molecule's center of mass and placed at an appropriate distance. Two lights are placed relative to the camera automatically.
Alternative programs to describe a structure in the PovRay format include Jmol (see instructions), and Avogadro (see instructions), or CCDC's Mercury (see instructions) with a GUI. Equally, openbabel allows the generation from the CLI (see instructions).
At time of writing, reserve about 93MB permanent memory for a virtual Python
environment to support the script xyz2mol.py
. Consider about 2MB in addition
for the script and its documentation.
For February 1st, 2024, numpy2
is scheduled to be published as replacement for
numpy
(see for instance here).
Though ruff (version 0.1.13) does not
identify an issue in xyz2pov.py
related to this transition, for now,
requirements.txt
constrains the installation of numpy
to be any version
greater or equal to 1.24.0, but less than version 2.0.