visualize_3d
- _eval_density(coords: ndarray, mol: Mole, dm: ndarray) ndarray[source]
Evaluate the electron density at the given coordinates.
- Parameters:
coords – The coordinates to evaluate the density at, shape (n, 3).
mol – The molecule.
dm – The density matrix.
- Returns:
The electron density at the given coordinates, shape (n).
- _eval_orbital(coords: ndarray, mol: Mole, coeff: ndarray) ndarray[source]
Evaluate an orbital at the given coordinates.
- Parameters:
coords – The coordinates to evaluate the orbital at, shape (n, 3).
mol – The molecule.
- Returns:
The orbital at the given coordinates, shape (n).
- _fix_cube_data(cube_data: str) str[source]
Fix a cube file string produced by pyscf. Undoes a pyscf bug by adding spaces where needed: e.g. replace incorrect lines like “-2.52899E-114-1.81539E-116-9.75640E-119-3.92559E-121-1.18255E-123-2.66702E-126” with “-2.52899E-114 -1.81539E-116 -9.75640E-119 -3.92559E-121 -1.18255E-123 -2.66702E-126”.
- Parameters:
cube_data – The cube data to fix.
- Returns:
The fixed cube data.
- find_isosurface_value(cube_array: ndarray, quantile: float | ndarray = 0.9, p: int = 2) float | ndarray[source]
Find an isosurface value for a cube array, such that the isosurface contains a given fraction of the total mass. The mass is computed as the sum of the absolute values of the cube array raised to the power p.
- Parameters:
cube_array – The cube array.
quantile – The fraction (or array of fractions) of the total mass to be contained in the isosurface.
p – The power to raise the cube array to. Use p=1 for electron density and p=2 for orbitals.
- Returns:
The isosurface value.
- get_local_frames_mesh_dict(origins: ndarray, bases: ndarray, scale: float = 1, axes_radius_scale: float = 0.03, cone_scale: float = 2.0, cone_aspect_ratio: float = 2, resolution: int = 20) dict[source]
Create a mesh dict for a set of local frames, given by their origin and basis vectors.
- Parameters:
origins – The origins of the local frames, shape (n, 3).
bases – The basis vectors of the local frames, shape (n, 3=n_vectors, 3=n_axes).
scale – The scale of the local frames.
axes_radius_scale – The radius of the cylinders representing the axes.
cone_scale – The scale of the cones representing the axes.
cone_aspect_ratio – The aspect ratio of the cones representing the axes.
resolution – The resolution of the cylinders and cones.
- Returns:
A dictionary with keyword arguments to pass to
pyvista.Plotter.add_mesh().
- get_sticks_mesh_dict(mol: Mole, bond_radius: float = 0.2, atom_radius: float = None, resolution=20) dict[source]
Create a ‘sticks’ representation for a pyscf molecule. By choosing a larger atom_radius, one can make this look like balls-and-sticks.
- Parameters:
mol – The molecule.
bond_radius – The radius of the cylinders representing the bonds.
atom_radius – The radius of the spheres representing the atoms. If None, use bond_radius.
resolution – The resolution of the cylinders and spheres.
- Returns:
A dictionary with keyword arguments to pass to pyvista.Plotter.add_mesh.
- plot_density(cube: DataCube = None, mode: str = 'auto', plot_molecule: bool = True, isosurface_quantile: float = None, isosurface_opacity: float = 0.4, plotter: Plotter = None, figsize: tuple[int, int] = None, title: str = None, cmap: str = None)[source]
Plot an electron density using pyvista. By default, the orbital is plotted as a volume.
- Parameters:
cube – The DataCube.
mode – The mode to use for plotting. Must be one of ‘volume’, ‘isosurface’, ‘nested_isosurfaces’.
plot_molecule – Whether to plot the molecule.
isosurface_quantile – For mode ‘isosurface’, the quantile of the total mass to be contained in the isosurface. Defaults to 0.9.
isosurface_opacity – For mode ‘isosurface’, the opacity of the isosurface.
plotter – A pyvista plotter to use. If None, a new plotter is created.
figsize – The figure size in inches.
title – The title of the plot.
cmap – The colormap to use.
- Returns:
The pyvista plotter.
- plot_molecule(mol: Mole, plotter: Plotter = None, figsize: tuple[int, int] = None, title: str = None) Plotter[source]
Plot molecule.
- Parameters:
mol – The pyscf molecule.
plotter – A pyvista plotter to use. If None, a new plotter is created.
figsize – The figure size in inches.
title – The title of the plot.
- Returns:
The pyvista plotter.
- plot_orbital(cube: DataCube, mode: str = 'auto', plot_molecule: bool = True, isosurface_quantile: float = None, plotter: Plotter = None, figsize: tuple[int, int] = None, title: str = None) Plotter[source]
Plot an electron orbital using pyvista. By default, the orbital is plotted as a volume.
- Parameters:
cube – The DataCube.
mode – The mode to use for plotting. Must be one of ‘volume’, ‘isosurface’, ‘nested_isosurfaces’.
plot_molecule – Whether to plot the molecule.
isosurface_quantile – The quantile of the total mass to be contained in the isosurface, for mode ‘isosurface’. Defaults to 0.9.
plotter – A pyvista plotter to use. If None, a new plotter is created.
figsize – The figure size in inches.
title – The title of the plot.
- Returns:
The pyvista plotter.
- visualize_density(mol: Mole, density_matrix: ndarray, resolution: float = 0.3, margin: float = 3.0, **plot_density_kwargs)[source]
Visualize the electron density with the corresponding molecule.
- Parameters:
mol – The molecule.
density_matrix – The density matrix in the atomic orbital basis.
resolution – The resolution of the cube file.
margin – The margin of the cube file.
plot_density_kwargs – Keyword arguments to pass to plot_density.
- Returns:
The pyvista plotter.
- visualize_orbital(mol: Mole, coeff: ndarray, resolution: float = 0.3, margin: float = 3.0, **plot_orbital_kwargs)[source]
Visualize an orbital together with the molecule it belongs to.
- Parameters:
mol – The molecule.
coeff – The orbital coefficients.
resolution – The resolution of the cube file.
margin – The margin of the cube file.
plot_orbital_kwargs – Keyword arguments to pass to plot_orbital.
- Returns:
The pyvista plotter.