epsproc.vol.orbPlot module¶
ePSproc orbPlot
Functions for calculating and plotting orbitals from quantum chemistry results.
Makes use of pyvista/itkwidgets, cclib and chemview/pyquante on the backend (see notes below).
13/05/20 v1, adapting from test notebook, cclib_chemlab_ITK_pyVista_dev_150420.ipynb
-
epsproc.vol.orbPlot.
importChemLabQC
(chemPath=None)[source]¶ Import chemlab. This is set as optional, and a local path can be defiend, since it is deprecated and may not install.
The chemlab.qc.wavefunction() method essentially repackages pyQuante functionality, for 3D volume calculation for orbitals defined by Gaussian basis sets.
Code: https://github.com/chemlab/chemlab/blob/master/chemlab/qc/wavefunction.py
To do: add more error parsing and logging, see, e.g., https://airbrake.io/blog/python-exception-handling/importerror-and-modulenotfounderror
-
class
epsproc.vol.orbPlot.
molOrbPlotter
(chemPath=None, fileIn=None, localPath=None, fileType=None, geomInd=-1)[source]¶ Bases:
object
Class to define & calculate electronic structure properties & orbitals.
Parameters: - chemPath (str, optional) – Set import path for chemlib. If not set, only standard python dir tree will be used.
- fileIn (str, Path or jobInfo dict) – Set file to use, either directly via str/Path, or use file from jobInfo dictionary (as returned by
epsproc.headerFileParse()
) - localPath (str, optional) – Set local path to use for electronic structure file, instead of original path from jobInfo.
- fileType (str, optional) – Set to override electronic structure file type by suffix. Usually this will be a .molden file for ePS, with a corresponding original file (e.g. Gamess .log). CClib supports most formats, although doesn’t read Molden. See https://cclib.github.io/data.html
Returns: Return type: molOrbPlotter class object, with molecular data + plotting methods.
Notes
- File serach logic? Set default case to call
epsproc.headerFileParse()
? Other locations?
Read files and process with cclib. https://cclib.github.io/how_to_parse.html
Method from chemview.viewer.MoleculeViewer.add_isosurfaces The chemlab.qc.wavefunction() method essentially repackages pyQuante functionality, for 3D volume calculation for orbitals defined by Gaussian basis sets.
-
calcOrb
(orbN=None)[source]¶ Calculate orbital volume.
Parameters: orbN (int, optional, default = None) – Set orbital number to plot. This will default to the homo (as defined by cclib data.homos[-1]) if not set. Note there is a -1 indexing offset for zero-indexed python arrays, which is applied in the function.
-
plotOrb
(orbN=None, isoLevels=6, isoValsAbs=None, isoValsPC=None, interactive=True, opacity=0.5)[source]¶ Plot orbital(s) with pyVista/ITK
- orbN : str or list of strs, optional, default = None
- Orbital(s) to plot, by name in self.vol PV object. By default these are set to orbital numbers, and exist for all calculated orbitals. If not supplied, plot all available surfaces, i.e. items in self.vol.array_names
- isoLevels : int, optional, default = 6
- Number of isosurfs to compute & render.
- isoValsAbs : list or array, default = None
- Isovals to use (absolute values). If both isoValsAbs and isoValsPC are passed, only PC values will be used.
- isoValsPC : list or array, default = None
- Isovals to use, percentage values. Plot values are set by +/-isoValsPC * np.abs(self.vol[item]).mean(). If both isoValsAbs and isoValsPC are passed, only PC values will be used.
- interactive : bool, optional, default = True
- Plot inteactively using itkwidgets if true. Otherwise use pyVista.Plotter(), which produces static output.
- opacity : float, optional, default = 0.5
- Set isosurface opacity.
- Fix naming & colourmapping for multiple objects in ITK plotter.
- Consolidate atoms > molecular geometry pyVista object.
- orbN as list of ints or np.array? Integrate with calcOrb()?
- Opacity mapping for isosurfs? For pv.Plotter() can do this via transfer fns, e.g. ‘linear’, https://docs.pyvista.org/examples/02-plot/opacity.html#sphx-glr-examples-02-plot-opacity-py
-
setGrid
(extent=None, resolution=50, padGrid=1.0, sqGrid=True, geomInd=None)[source]¶ Setup grids for orbital calculations.
Basic 3D grid setup, based on passed or atomic coords. Currently limited to square grid for compatibility with ITK/VTK plotting - but should be able to make this more flexible. Final grid set as PyVista object, self.vol
Parameters: - extent (list or np.array, [min, max], optional) – Define limits of grid (in working units, Angs or Bohr). If not specified will be defined from atomic coords (min and max values in any dimension).
- resolution (int, optional, default = 50) – Number of points per dimension, final grid size will be resolution^3
- padGrid (float, optional, default = 1.0) – Padding to add when using atomic coords to define grid (in working units angs/bohr). Currently single valued, same for all dims.
- sqGrid (bool, optional, default = True) – Force square gridding? Currently only True is supported.
- geomInd (int, optional, default = -1) – Set to select a specific geometry from the electronic structure file (if present). Defaults to the final geometry listed. Overrides self.geomInd if set.
Notes
- Method originally adapted from chemview.viewer.MoleculeViewer.add_isosurfaces
- Q: do units matter here…?