pyvibdmc.analysis ================= .. py:module:: pyvibdmc.analysis Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/pyvibdmc/analysis/analyze_wfn/index /autoapi/pyvibdmc/analysis/extract_sim_info/index /autoapi/pyvibdmc/analysis/plotter/index /autoapi/pyvibdmc/analysis/rotator/index Classes ------- .. autoapisummary:: pyvibdmc.analysis.AnalyzeWfn pyvibdmc.analysis.SimInfo pyvibdmc.analysis.Plotter pyvibdmc.analysis.MolRotator Package Contents ---------------- .. py:class:: AnalyzeWfn(coordinates) .. py:attribute:: xx .. py:method:: dot_pdt(v1, v2) :staticmethod: Takes two stacks of vectors and dots the pairs of vectors together .. py:method:: exp_val(operator, dw) :staticmethod: Calculation of an expectation value using Monte Carlo Integration :param operator: array of bond lengths, bond angles, potentials, dipole moments, etc. :type operator: np.ndarray :param dw: Descendant Weights :type dw: np.ndarray :return: Expectation value (single float) .. py:method:: bond_length(atm1, atm2) Computes the norm of the vector between two atoms. :param atm1: desired atom number 1 (python index starts at 0) :type atm1: int :param atm2: desired atom number 2 :type atm2: int :return: norm of x[atm1]-x[atm2] .. py:method:: bond_angle(atm1, atm_vert, atm3) Calculate atm1 - atm_vert - atm3 angle :param atm1: Index of the first external atom (python index starts at 0) :type atm1: int :param atm_vert: Index of the atom at the vertex (python index starts at 0) :type atm_vert: int :param atm3: Index of the second external atom (python index starts at 0) :type atm3: int :return: Angle in radians .. py:method:: bisecting_vector(atm1, atm_vert, atm3) 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 :param atm1: Index of the first external atom (python index starts at 0) :type atm1: int :param atm_vert: Index of the atom at the vertex (python index starts at 0) :type atm_vert: int :param atm3: Index of the second external atom (python index starts at 0) :type atm3: int :return: normalized bisecting vector .. py:method:: dihedral(atm_1, atm_2, atm_3, atm_4) 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 .. py:method:: get_component(atm, xyz) Get x, y, or z component of a vector that corresponds to a particular atom in some predetermined cooridnate system. :param atm: atom's index in numpy array :type: int :param xyz: Either 0 (x), 1 (y), or 2 (z) :type xyz: int :return: vector of x, y, or z components of a stack of vectors .. py:method:: cart_to_spherical(vecc) :staticmethod: 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. .. py:method:: projection_1d(attr, desc_weights, bins=25, range=None, normalize=True) :staticmethod: Project the probability amplitude onto a particular coordinate, 1D Histogram. :param attr: the coordinate to be projected onto (bond length, bond angle, etc.) :type attr: np.ndarray :param desc_weights: the descendant weights for \psi**2 :type desc_weights: np.ndarray :param bins: Number of bins in histogram (higher number, more number of walkers needed) :type attr: int :param range: Range over which attr is histogrammed :type range: tuple :param normalize: Normalizes the wave function along coordinate :type attr: bool :return: np.ndarray of shape (bin_num-1 x 2), bin centers, amplitude at bin centers .. py:method:: projection_2d(attr1, attr2, desc_weights, bins=[25, 25], range=None, normalize=True) :staticmethod: Project the probability amplitude onto a 2 coordinates, 2D Histogram. :param attr1: coordinate 1 to be projected onto (bond length, bond angle, etc.) :type attr: np.ndarray :param attr2: coordinate 2 to be projected onto (bond length, bond angle, etc.) :type attr: np.ndarray :param desc_weights: the descendant weights for \psi**2 :type desc_weights: np.ndarray :param bins: Number of bins for histogram in both directions (higher number, more number of walkers needed) :type attr: tuple :param range: Range over which attr is histogrammed :type range: list of two tuples :param normalize: Normalizes the wave function along both coordinates (integrated area under 2D surface is 1) :type attr: bool :return: np.ndarray of shape (bin_num-1 x 2), bin centers x, bin centers y, and then the 2D array with amplitude. .. py:class:: SimInfo(h5_name) Object that takes in a .hdf5 file (one of the outputs of the simulation) and provides tools for analysis. :param h5Name: hdf5 file :type str .. py:attribute:: fname .. py:method:: get_wfn(wfn_fl, ret_ang=False, get_parent_wts=False) :staticmethod: Given a .hdf5 file, return wave function and descendant weights associated with that wave function. :param wfn_fl: A resultant .hdf5 file from a PyVibDMC simulation :param ret_ang: boolean indicating returning the coordinates in angtstroms. Bohr is the default. :return: Coordinates array in angstroms (nxmx3), descendant weights array (n). .. py:method:: get_wfns(time_step_list, ret_ang=False, get_parent_wts=False) 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. .. py:method:: get_vref(ret_cm=False) Returns vref_vs_tau array .. py:method:: get_pop() Returns population array, either ensemble size or sum of weights .. py:method:: get_atomic_nums() Returns list of atoms used in the simulation (by atomic number) .. py:method:: get_atom_masses() Returns masses used in the simulation in atomic units (mass electron) .. py:method:: get_zpe(onwards=1000, ret_cm=False) onwards is an int that tells us where to start averaging (python indexing starts at 0) .. py:method:: window_avg(blocks=5, ret_cm=False) Splits vref into blocks, calculates zpe in each of those blocks .. py:method:: get_training(training_file, ret_ang=False, ret_cm=False) :staticmethod: If using deb_training_every argument, read the files with this. Returns walkers in angstr and engs in cm-1 .. py:class:: Plotter A very basic plotting class that will use matplotlib to generate various plots using results from PyVibDMC/AnalyzeWfn/SimInfo. .. py:attribute:: params .. py:method:: plt_vref_vs_tau(vref_vs_tau, save_name='vref_vs_tau.png') :staticmethod: 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 :param vref_vs_tau: The vref_vs_tau array from the *sim_info.hdf5 file. Can be a list of these as well. :type vref_vs_tau: str or list :param save_name: The name of the plot that will save as a .png :type save_name: str :return: .. py:method:: plt_pop_vs_tau(pop_vs_tau, save_name='pop_vs_tau.png') :staticmethod: 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 :param pop_vs_tau: The vref_vs_tau array from the *sim_info.hdf5 file. Can be a list of these as well. :type pop_vs_tau: str or list :param save_name: The name of the plot that will save as a .png :type save_name: str :return: .. py:method:: plt_hist1d(hist, xlabel, ylabel='Probability Amplitude ($\\mathrm{\\Psi^{2}}$)', title='', save_name='histogram.png') :staticmethod: Plots the histogram generated from AnalyzeWfn.projection_1d. :param hist: Output from AnalyzeWfn.projection_1d ; array of shape (bin_num-1 x 2) :type hist: np.ndarray :param xlabel: What to label the x-axis :type xlabel: str :param ylabel: What to label the y-axis (units in Parenthesis is always good) :type ylabel: str :param title: Title of the plot :type title: str :param save_name: name of the .png file that this plot will be saved to :type save_name: str .. py:method:: plt_hist2d(binsx, binsy, hist_2d, xlabel, ylabel, title='', save_name='histogram.png') :staticmethod: Plots the 2D-histogram generated from AnalyzeWfn.projection_2d. :param bins: First output from AnalyzeWfn.projection_2d; the array containing the x and y bins :type bins: np.ndarray :param hist_2d: Second output from AnalyzeWfn.projection_2d; The matrix that contains the amplitude at each of the bins in the 2d histogram. :type hist_2d: np.ndarray :param xlabel: What to label the x-axis :type xlabel: str :param ylabel: What to label the y-axis (units in Parenthesis is always good) :type ylabel: str :param title: Title of the plot :type title: str :param save_name: name of the .png file that this plot will be saved to :type save_name: str .. py:class:: MolRotator A helper class that will rotate a stack of molecules and generate 3D rotation matrices using vectorized numpy operations. .. py:method:: rotate_geoms(rot_mats, geoms) :staticmethod: Takes in a stack of rotation matrices and applies it to a stack of geometries. .. py:method:: rotate_vec(rot_mats, vecc) :staticmethod: Takes in a stack of rotation matrices and applies it to a stack of vector .. py:method:: gen_rot_mats(theta, xyz_int) :staticmethod: Generates the 3D rotation matrix about X, Y, or Z by theta radians .. py:method:: rotate_to_xy_plane(geoms, orig, xax, xyp, return_mat=False) :staticmethod: 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. .. py:method:: gen_eulers(xyz, XYZ) :staticmethod: Takes in cartesian vectors and gives you the 3 euler angles that bring xyz to XYZ based on a 'ZYZ' rotation .. py:method:: extract_eulers(rot_mats) :staticmethod: From a rotation matrix, calculate the three euler angles theta,phi and Chi. This is based on a 'ZYZ' euler rotation