#!/usr/bin/env python # coding: utf-8 # ## Volume Rendering Demonstration in JupyterLab # In[1]: import openchemistry as oc import json # Once you have imported the basic Python modules we load a file # In[2]: with open('caffeine.cjson') as f: cjson = json.load(f) mol = oc.load(cjson) # Set up the transfer function used to render the orbital volume, by setting the color and opacity nodes # In[3]: transfer_function = { 'colormap': { 'colors': [ [1, 0, 0], [0.5, 0.5, 0], [1, 0, 1], [0, 0.5, 0.5], [0,0,1] ], 'points': [ -0.1, -0.03, 0, 0.03, 0.1 ] }, 'opacitymap': { 'opacities': [ 1, 0.75, 0, 0, 0.75, 1 ], 'points': [ -0.3, -0.2, -0.0001, 0.0001, 0.2, 0.3 ] } } # NOTE: Only the `vtkjs` viewer is capable of volume rendering. # In[4]: mol.orbitals.show( mo='homo', viewer='vtkjs', isosurface=False, volume=True, transfer_function=transfer_function )