pyvibdmc.analysis
Submodules
Classes
Object that takes in a .hdf5 file (one of the outputs of the simulation) and provides tools for analysis. |
|
A very basic plotting class that will use matplotlib to generate various plots using results from PyVibDMC/AnalyzeWfn/SimInfo. |
|
A helper class that will rotate a stack of molecules and generate 3D rotation matrices using vectorized |
Package Contents
- class pyvibdmc.analysis.AnalyzeWfn(coordinates)[source]
- xx
- static exp_val(operator, dw)[source]
Calculation of an expectation value using Monte Carlo Integration
- Parameters:
operator (np.ndarray) – array of bond lengths, bond angles, potentials, dipole moments, etc.
dw (np.ndarray) – Descendant Weights
- Returns:
Expectation value (single float)
- bond_length(atm1, atm2)[source]
Computes the norm of the vector between two atoms.
- Parameters:
atm1 (int) – desired atom number 1 (python index starts at 0)
atm2 (int) – desired atom number 2
- Returns:
norm of x[atm1]-x[atm2]
- bond_angle(atm1, atm_vert, atm3)[source]
Calculate atm1 - atm_vert - atm3 angle
- Parameters:
atm1 (int) – Index of the first external atom (python index starts at 0)
atm_vert (int) – Index of the atom at the vertex (python index starts at 0)
atm3 (int) – Index of the second external atom (python index starts at 0)
- Returns:
Angle in radians
- bisecting_vector(atm1, atm_vert, atm3)[source]
Get normalized bisecting vector of two vectors (two bond lengths). It is assumed that the two flanking atoms have the same central atom. |b|*a + |a|*b
- Parameters:
atm1 (int) – Index of the first external atom (python index starts at 0)
atm_vert (int) – Index of the atom at the vertex (python index starts at 0)
atm3 (int) – Index of the second external atom (python index starts at 0)
- Returns:
normalized bisecting vector
- dihedral(atm_1, atm_2, atm_3, atm_4)[source]
Defines the dihedral coordinate using 3 vectors. vec_1 and vec_2 form a plane, and vec_2 and vec_3 form a plane. The dihedral angle is the calculated angle betwen these two planes. The sign is dependent on the direction of the vectors, as the cross product is taken between the two pairs of two vectors https://stackoverflow.com/questions/20305272/dihedral-torsion-angle-from-four-points-in-cartesian-coordinates-in-python https://en.wikipedia.org/w/index.php?title=Dihedral_angle&oldid=689165217#Angle_between_three_vectors
- get_component(atm, xyz)[source]
Get x, y, or z component of a vector that corresponds to a particular atom in some predetermined cooridnate system.
- Parameters:
atm – atom’s index in numpy array
xyz (int) – Either 0 (x), 1 (y), or 2 (z)
- Type:
int
- Returns:
vector of x, y, or z components of a stack of vectors
- static cart_to_spherical(vecc)[source]
Takes stack of cartesian vectors (nx3) and translates them to stack of r theta phi coordinates, with the assumption that you are already in the coordinate frame you desire.
- static projection_1d(attr, desc_weights, bins=25, range=None, normalize=True)[source]
Project the probability amplitude onto a particular coordinate, 1D Histogram.
- Parameters:
attr (bool) – the coordinate to be projected onto (bond length, bond angle, etc.)
desc_weights (np.ndarray) – the descendant weights for psi**2
bins – Number of bins in histogram (higher number, more number of walkers needed)
range (tuple) – Range over which attr is histogrammed
normalize – Normalizes the wave function along coordinate
- Returns:
np.ndarray of shape (bin_num-1 x 2), bin centers, amplitude at bin centers
- static projection_2d(attr1, attr2, desc_weights, bins=[25, 25], range=None, normalize=True)[source]
Project the probability amplitude onto a 2 coordinates, 2D Histogram.
- Parameters:
attr1 – coordinate 1 to be projected onto (bond length, bond angle, etc.)
attr2 – coordinate 2 to be projected onto (bond length, bond angle, etc.)
desc_weights (np.ndarray) – the descendant weights for psi**2
bins – Number of bins for histogram in both directions (higher number, more number of walkers needed)
range (list of two tuples) – Range over which attr is histogrammed
normalize – Normalizes the wave function along both coordinates (integrated area under 2D surface is 1)
- Returns:
np.ndarray of shape (bin_num-1 x 2), bin centers x, bin centers y, and then the 2D array with amplitude.
- class pyvibdmc.analysis.SimInfo(h5_name)[source]
Object that takes in a .hdf5 file (one of the outputs of the simulation) and provides tools for analysis.
- Parameters:
h5Name – hdf5 file
:type str
- fname
- static get_wfn(wfn_fl, ret_ang=False, get_parent_wts=False)[source]
Given a .hdf5 file, return wave function and descendant weights associated with that wave function.
- Parameters:
wfn_fl – A resultant .hdf5 file from a PyVibDMC simulation
ret_ang – boolean indicating returning the coordinates in angtstroms. Bohr is the default.
- Returns:
Coordinates array in angstroms (nxmx3), descendant weights array (n).
- get_wfns(time_step_list, ret_ang=False, get_parent_wts=False)[source]
Extract the wave function (walker set) and descendant weights given a time step number or numbers :param time_step_list: a list of ints that correspond to the time steps you want the wfn from given the simulation you are working with :type time_step_list: int or list :param ret_ang: boolean indicating returning the coordinates in angtstroms. Bohr is the default. :param get_parent_wts: Return the continuous weights associated with the walkers at the beginning of descendant weighting.
- get_zpe(onwards=1000, ret_cm=False)[source]
onwards is an int that tells us where to start averaging (python indexing starts at 0)
- class pyvibdmc.analysis.Plotter[source]
A very basic plotting class that will use matplotlib to generate various plots using results from PyVibDMC/AnalyzeWfn/SimInfo.
- params
- static plt_vref_vs_tau(vref_vs_tau, save_name='vref_vs_tau.png')[source]
Takes in the vref vs tau array from a DMC sim and plots it. Can also take in many vref_vs_tau arrays and plot them successively
- Parameters:
vref_vs_tau (str or list) – The vref_vs_tau array from the *sim_info.hdf5 file. Can be a list of these as well.
save_name (str) – The name of the plot that will save as a .png
- Returns:
- static plt_pop_vs_tau(pop_vs_tau, save_name='pop_vs_tau.png')[source]
Takes in the pop_vs_tau array from a DMC sim and plots it. Can also take in many pop_vs_tau arrays and plot them successively
- Parameters:
pop_vs_tau (str or list) – The vref_vs_tau array from the *sim_info.hdf5 file. Can be a list of these as well.
save_name (str) – The name of the plot that will save as a .png
- Returns:
- static plt_hist1d(hist, xlabel, ylabel='Probability Amplitude ($\\mathrm{\\Psi^{2}}$)', title='', save_name='histogram.png')[source]
Plots the histogram generated from AnalyzeWfn.projection_1d.
- Parameters:
hist (np.ndarray) – Output from AnalyzeWfn.projection_1d ; array of shape (bin_num-1 x 2)
xlabel (str) – What to label the x-axis
ylabel (str) – What to label the y-axis (units in Parenthesis is always good)
title (str) – Title of the plot
save_name (str) – name of the .png file that this plot will be saved to
- static plt_hist2d(binsx, binsy, hist_2d, xlabel, ylabel, title='', save_name='histogram.png')[source]
Plots the 2D-histogram generated from AnalyzeWfn.projection_2d.
- Parameters:
bins (np.ndarray) – First output from AnalyzeWfn.projection_2d; the array containing the x and y bins
hist_2d (np.ndarray) – Second output from AnalyzeWfn.projection_2d; The matrix that contains the amplitude at each of the bins in the 2d histogram.
xlabel (str) – What to label the x-axis
ylabel (str) – What to label the y-axis (units in Parenthesis is always good)
title (str) – Title of the plot
save_name (str) – name of the .png file that this plot will be saved to
- class pyvibdmc.analysis.MolRotator[source]
A helper class that will rotate a stack of molecules and generate 3D rotation matrices using vectorized numpy operations.
- static rotate_geoms(rot_mats, geoms)[source]
Takes in a stack of rotation matrices and applies it to a stack of geometries.
- static rotate_vec(rot_mats, vecc)[source]
Takes in a stack of rotation matrices and applies it to a stack of vector
- static gen_rot_mats(theta, xyz_int)[source]
Generates the 3D rotation matrix about X, Y, or Z by theta radians
- static rotate_to_xy_plane(geoms, orig, xax, xyp, return_mat=False)[source]
Rotate geometries to XY plane, placing one atom at the origin, one on the xaxis, and one on the xyplane. Done through successive rotations about the X-axis, Z-axis then X-axis again.