{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# POV-Ray rendered crystal structure\n\nHere, we show POV-Ray rendered images as shown in :mod:`ase.spacegroup`.\nAs an example, we start from a skutterudite structure.\nThis structure is visualised with the Cobalt atoms on the\ncorners. This can easily be accomplished with ASE using\n:func:`ase.build.cut`. Below is the *origo* argument used to\nput the Cobalt atom on the corners and *extend* to include all corner\nand edge atoms, even those belonging to neighbouring unit cells.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import ase.io as io\nfrom ase.build import cut\nfrom ase.spacegroup import crystal\n\na = 9.04\nskutterudite = crystal(\n ('Co', 'Sb'),\n basis=[(0.25, 0.25, 0.25), (0.0, 0.335, 0.158)],\n spacegroup=204,\n cellpar=[a, a, a, 90, 90, 90],\n)\n\n# Create a new atoms instance with Co at origo including all atoms on the\n# surface of the unit cell\ncosb3 = cut(skutterudite, origo=(0.25, 0.25, 0.25), extend=1.01)\n\n# Define the atomic bonds to show\nbondatoms = []\nsymbols = cosb3.get_chemical_symbols()\nfor i in range(len(cosb3)):\n for j in range(i):\n if symbols[i] == symbols[j] == 'Co' and cosb3.get_distance(i, j) < 4.53:\n bondatoms.append((i, j))\n elif (\n symbols[i] == symbols[j] == 'Sb' and cosb3.get_distance(i, j) < 2.99\n ):\n bondatoms.append((i, j))\n\n# Create nice-looking image using povray\nrenderer = io.write(\n 'spacegroup-cosb3.pov',\n cosb3,\n rotation='90y',\n radii=0.4,\n povray_settings=dict(\n transparent=False,\n camera_type='perspective',\n canvas_width=320,\n bondlinewidth=0.07,\n bondatoms=bondatoms,\n ),\n)\n\nrenderer.render()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.7" } }, "nbformat": 4, "nbformat_minor": 0 }