{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Isosurface with povray\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Render an isosurface and atoms with povray\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import numpy as np\n\nfrom ase.build import bulk\nfrom ase.io import write\n\ndensity_cut_off = 0.15\n\nrotation = '24x, 34y, 14z'\n\natoms = bulk('Au', cubic=True) * (2, 2, 2)\n\naxis = np.linspace(-1, 1, 100)\nX, Y, Z = np.meshgrid(axis, axis, axis)\nisodata = np.exp(-0.5 * (X**2 + 2 * Y**2 + 3 * Z**2))\n\npovray_settings = {\n 'pause': False, # Pause when done rendering (only if display)\n 'transparent': False, # Transparent background\n 'canvas_width': None, # Width of canvas in pixels\n 'canvas_height': 1024, # Height of canvas in pixels\n 'camera_dist': 25.0, # Distance from camera to front atom\n 'camera_type': 'orthographic angle 35', # 'perspective angle 20'\n 'textures': len(atoms) * ['ase3'],\n}\n\ngeneric_projection_settings = {\n 'rotation': rotation,\n 'radii': atoms.positions.shape[0] * [0.3],\n 'show_unit_cell': 1,\n}\n\nwrite(\n 'isosurface.pov',\n atoms,\n **generic_projection_settings,\n povray_settings=povray_settings,\n isosurface_data=dict(density_grid=isodata, cut_off=density_cut_off),\n).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 }