pyvibdmc ======== .. py:module:: pyvibdmc .. autoapi-nested-parse:: PyVibDMC A general purpose diffusion monte carlo code for studying vibrational problems Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/pyvibdmc/analysis/index /autoapi/pyvibdmc/pyvibdmc/index /autoapi/pyvibdmc/simulation_utilities/index Attributes ---------- .. autoapisummary:: pyvibdmc.versions Classes ------- .. autoapisummary:: pyvibdmc.DMC_Sim pyvibdmc.Constants pyvibdmc.XYZNPY pyvibdmc.Potential pyvibdmc.Potential_NoMP pyvibdmc.NN_Potential pyvibdmc.Potential_Direct pyvibdmc.MolFiniteDifference pyvibdmc.HarmonicAnalysis pyvibdmc.InitialConditioner pyvibdmc.DistIt pyvibdmc.ImpSampManager pyvibdmc.ImpSampManager_NoMP pyvibdmc.ImpSamp pyvibdmc.AnalyzeWfn pyvibdmc.ChainRuleHelper pyvibdmc.AnalyzeWfn pyvibdmc.SimInfo pyvibdmc.Plotter pyvibdmc.MolRotator Functions --------- .. autoapisummary:: pyvibdmc.dmc_restart pyvibdmc.get_atomic_num pyvibdmc.get_atomic_string Package Contents ---------------- .. py:class:: DMC_Sim(sim_name='DMC_Sim', output_folder='exSimResults', weighting='discrete', num_walkers=10000, num_timesteps=20000, equil_steps=2000, chkpt_every=1000, wfn_every=1000, desc_wt_steps=100, atoms=[], delta_t=1, potential=None, masses=None, start_structures=None, start_cont_wts=None, branch_every=1, log_every=1, cur_timestep=0, cont_wt_thresh=None, imp_samp=None, imp_samp_oned=False, second_impsamp_displacement=False, excited_state_imp_samp=False, adiabatic_dmc=None, fixed_node=None, DEBUG_alpha=None, DEBUG_save_desc_wt_tracker=None, DEBUG_save_training_every=None, DEBUG_save_before_bod=False, DEBUG_mass_change=None) The main object that you will use to run the DMC simulation. You will instantiate an object DMC_SIM(...) and then use object.run() to begin the simulation. :param sim_name: Simulation name for saving wave functions and checkpointing :type sim_name: str :param output_folder: The folder where the results will be stored, including wave functions and energies. Abs. or rel. path. :type output_folder: str :param weighting: Discrete or Continuous weighting DMC. Continuous means that there are fixed number of walkers :type weighting: str :param num_walkers: Number of walkers we will start the simulation with :type num_walkers: int :param num_timesteps: Total time steps we will be propagating the walkers. num_timesteps*delta_t = total time in A.U. :type num_timesteps: int :param equil_steps: Time steps before we start collecting wave function :type equil_steps: int :param chkpt_every: How many time steps in between checkpoints (only checkpoints once we reached equil_steps. :type chkpt_every: int :param desc_wt_steps: Number of time steps monitoring the wave function's desc_wt_timeendants. :type desc_wt_steps: int :param atoms: List of atoms for the simulation :type atoms: list :param delta_t: The length of the time step; how many atomic units of time are you going in one time step. :type delta_t: int :param potential: Takes in coordinates, gives back energies :type potential: function :param masses: For feeding in artificial masses in atomic units. If not, then the atoms param will designate masses :type masses: list :param start_structures: An initial structure to initialize all your walkers :type start_structures: np.ndarray :param branch_every: Branch the walkers every x time steps, also known as birth/death :type branch_every: int :param log_every: Gather simulation information every n time steps. This includes timing of potential call, max/min of weight and energy of ensemble, and number of births/deaths or branching :type log_every: int :param cur_timestep: The current time step, should be zero unless you are restarting :type cur_timestep: int :param cont_wt_thresh: If a weight goes past this bound, branch it. If only supplied one number, it will use that for the lower bound. :type cont_wt_thresh: list of floats :param DEBUG_alpha: The number that will be used instead of 1/(2*delta_t) for alpha. :type DEBUG_alpha: float :param DEBUG_save_desc_wt_tracker: If true, will save the array that keeps track of births/deaths during desc_wt_time weighting. Will save as a binary .npy file (see numpy documentation) :type DEBUG_save_desc_wt_tracker: bool :param DEBUG_save_training_every: If true, will collect coordinates and energies every n time steps :type DEBUG_save_training_every: int :param DEBUG_mass_change: Dictionary that will scale the mass every change_every steps. The scaling factor_per_change can be an array or an int/float "type DEBUG_mass_change: dict .. py:attribute:: atoms :value: [] .. py:attribute:: sim_name :value: 'DMC_Sim' .. py:attribute:: output_folder :value: 'exSimResults' .. py:attribute:: num_walkers :value: 10000 .. py:attribute:: num_timesteps :value: 20000 .. py:attribute:: potential_info .. py:attribute:: potential .. py:attribute:: weighting :value: '' .. py:attribute:: desc_wt_time_steps :value: 100 .. py:attribute:: branch_every :value: 1 .. py:attribute:: delta_t :value: 1 .. py:attribute:: start_structures :value: None .. py:attribute:: start_cont_wts :value: None .. py:attribute:: masses :value: None .. py:attribute:: equil_steps :value: 2000 .. py:attribute:: chkpt_every :value: 1000 .. py:attribute:: wfn_every :value: 1000 .. py:attribute:: log_every :value: 1 .. py:attribute:: cur_timestep :value: 0 .. py:attribute:: cont_wt_thresh :value: None .. py:attribute:: impsamp_manager :value: None .. py:attribute:: imp1d :value: False .. py:attribute:: second_impsamp_displacement :value: False .. py:attribute:: adiabatic_dmc :value: None .. py:attribute:: fixed_node :value: None .. py:attribute:: excited_state_imp_samp :value: False .. py:property:: vref_vs_tau Returns the vref array, including zeros from initialization .. py:property:: walkers .. py:method:: update_effetive_timestep() .. py:method:: birth_or_death() Chooses whether or not the walker made a bad enough random walk to be removed from the simulation. For discrete weighting, this leads to removal or duplication of the walkers. For continuous, this leads to an update of the weights and a potential branching of a large weight walker to the smallest one :return: Updated Continus Weights , the "who from" array for desc_wt_timeendent weighting, walker coords, and pot vals. .. py:method:: birth_or_death_old() Chooses whether or not the walker made a bad enough random walk to be removed from the simulation. For discrete weighting, this leads to removal or duplication of the walkers. For continuous, this leads to an update of the weights and a potential branching of a large weight walker to the smallest one :return: Updated Continus Weights , the "who from" array for desc_wt_timeendent weighting, walker coords, and pot vals. .. py:method:: move_randomly() The random displacement of each of the coordinates of each of the walkers, done in a vectorized fashion. Displaces self._walker_coords .. py:method:: imp_move_randomly() The random displacement of each of the coordinates of each of the walkers, done in a vectorized fashion. Displaces self._walker_coords .. py:method:: imp_move_randomly_second_type() The random displacement of each of the coordinates of each of the walkers, done in a vectorized fashion. Displaces self._walker_coords .. py:method:: calc_vref() Use the energy of all walkers to calculate self._vref with a correction for the fluctuation in the population or weight. Updates Vref .. py:method:: calc_desc_wts() At the end of desc_wt_timeendent weighting, count up which walkers came from other walkers (desc_wt_timeendants) .. py:method:: update_sim_arrays(prop_step) :param prop_step: the time step that we are currently on .. py:method:: recrossing(q_1, q_2, cds) .. py:method:: propagate() The main DMC loop. 1. Move Randomly 2. Calculate the Potential Energy 3. Birth/Death 4. Update Vref Additionally, checks when the wavefunction has hit a point where it should save / do desc_wt_timeendent weighting. .. py:method:: run() This function calls propagate and saves simulation results .. py:function:: dmc_restart(potential, chkpt_folder, sim_name, additional_timesteps=0, impsamp=None, imp_samp_oned=False, fixed_node=None) TODO: Need to add in impsamp infrastructure here for restarting... .. py:class:: Constants Thanks, Mark Boyer, for this silly little class. Converter that handles energy, distance, and mass conversions for DMC. Can be expanded upon. .. py:attribute:: atomic_units .. py:method:: convert(val, unit, to_AU=True) :classmethod: :param val: The value or values that will be converted :type val: np.ndarray :param unit: The units (not atomic units) that we will be converting to or from :type unit: str :param to_AU: If true, converting from non-a.u. to a.u. If false, converting to a.u. from non-a.u. :type to_AU:boolean :return: converted values .. py:method:: mass(atom, to_AU=True) :classmethod: Given a string that corresponds to an atomic element, output the atomic mass of that element :param atom: The string of an atomic element :type atom:str :param to_AU: If true, converting from non-a.u. to a.u. If false, converting to a.u. from non-a.u. :type to_AU:boolean :return: mass in atomic units unless user changes to_AU to False, then AMU .. py:method:: reduced_mass(atoms, to_AU=True) :classmethod: Given a string like 'O-H' or 'N-N' , output the reduced mass of that diatomic :param atoms: A string that is composed of two atoms :type atom:str :param to_AU: If true, converting from non-a.u. to a.u. If false, converting to a.u. from non-a.u. :type to_AU:boolean :return: mass in atomic units unless user changes to_AU to False, then AMU .. py:function:: get_atomic_num(atms) :param atms: A list (or single string) of atomic element symbols :return: The atomic numbers of each of the atom strings you provide .. py:function:: get_atomic_string(atomic_num) :param atomic_num: The atomic numbers of each of the atom strings you provide :return: A list of atomic element symbols .. py:class:: XYZNPY Handler of xyz <-> npy conversion, like a personal version of openBabel. .. py:method:: extract_xyz(file_name, num_atoms) :staticmethod: Extracts the coordinates from an xyz file and returns it as an np array of dimension nxmx3, where n = number of geometries, m = number of atoms, and 3 = cartesian coordinates :param file_name: Name of the .xyz file, including extension :type file_name: str :param num_atoms: Number of atoms in molecule. :type num_atoms: int :return: nxmx3 numpy array of coordinates .. py:method:: write_xyz(coords, fname, atm_strings, cmt=None) :staticmethod: Writes a numpy array of x,y,z coordinates to a .xyz file :param fname: name of xyz file :param coords: numpy array, either mx3 or nxmx3, where n = number of geometries and m = number of atoms :param atm_strings: list of strings that correspond to the atom type e.g. ["H","H","O"] :return: np.ndarray .. py:class:: Potential(potential_function, potential_directory, python_file, num_cores=1, pass_timestep=False, pot_kwargs=None) A potential handler that is able to call python functions that call .so files, either generated by f2py or loaded in by ctypes. :param potential_function: The name of a python function (user specified) that will take in a n x m x 3 stack of geometries and return a 1D numpy array filled with potential values in hartrees. :type potential_function: str :param potential_dir: The *absolute path* to the directory that contains the .so file and .py file. If it"s a python function, then just the absolute path to your .py file. :type: str :param num_cores: Will create a pool of processes using Python"s multiprocessing module. This should never be larger than the number of processors on the machine this code is run. :type: int .. py:attribute:: potential_function .. py:attribute:: python_file .. py:attribute:: potential_directory .. py:attribute:: num_cores :value: 1 .. py:attribute:: pass_timestep :value: False .. py:attribute:: pot_kwargs :value: None .. py:property:: pool Returns the potential manager's pool so that it can be used internally with Imp Samp or with the user elsewhere .. py:method:: getpot(cds, timeit=False) Uses the potential function we got to call potential :param cds: A stack of geometries (nxmx3, n=num_geoms;m=num_atoms;3=x,y,z) whose energies we need :type cds: np.ndarray :param timeit: The logger telling the potential manager whether or not to time the potential call :type timeit: bool .. py:method:: mp_close() .. py:class:: Potential_NoMP(potential_function, potential_directory, python_file, pass_timestep=False, ch_dir=False, pot_kwargs=None) Version of Potential where no multiprocessing is included. As such, it does not leave a worker in the potential directory of interest. If you need to cd into the directory to call a potential (for example, the potential loads in a file using a relative path or something), then use ch_dir=True. Not the default since it is computationally inefficient to cd during each potential call when not necessary. .. py:attribute:: potential_function .. py:attribute:: python_file .. py:attribute:: pass_timestep :value: False .. py:attribute:: potential_directory .. py:attribute:: pot_kwargs :value: None .. py:attribute:: ch_dir :value: False .. py:method:: getpot(cds, timeit=False) Uses the potential function we got to call potential :param cds: A stack of geometries (nxmx3, n=num_geoms;m=num_atoms;3=x,y,z) whose energies we need :type cds: np.ndarray :param timeit: The logger telling the potential manager whether or not to time the potential call :type timeit: bool .. py:class:: NN_Potential(potential_function, potential_directory, python_file, model, ch_dir=False, pot_kwargs=None, pass_timestep=False) Bases: :py:obj:`Potential_NoMP` Subclass of Potential_NoMP, where a model argument is provided for convenience .. py:attribute:: model .. py:attribute:: ch_dir :value: False .. py:attribute:: pot_kwargs :value: None .. py:method:: getpot(cds, timeit=False) Subclass of Potential_NoMP, but with an explicit argument passed for the NN model for convenience. .. py:class:: Potential_Direct(potential_function, pot_kwargs=None, pass_timestep=False) Version of Potential where the actual Python function is passed rather than being imported from an external file. At the request of Mark. .. py:attribute:: potential_function .. py:attribute:: pot_kwargs :value: None .. py:attribute:: pass_timestep :value: False .. py:method:: getpot(cds, timeit=False) .. py:class:: MolFiniteDifference Helper to calculate derivatives of some value as a function of Cartesian displacements in a molecule. .. py:attribute:: weights_der1 .. py:attribute:: weights_der2 .. py:method:: displace_molecule(eq_geom, atm_cd, dx, num_disps) :staticmethod: Displace atm along cd :param eq_geom: Geometry from which you will be displaced :param atm_cd: a tuple that has a paricular atom of interest to displace in a particular dimension (x,y,or,z) :param dx: The amount each geometry will be replaced :param num_disps: int of how many displacements to do, will take the form of 3 or 5 for harmonic analysis. :return: Displaced coordinates in a 3D array (n,m,3). If displaced in two directions, then still (n,m,3) .. py:method:: differentiate(values, dx, num_points, der) :classmethod: .. py:class:: HarmonicAnalysis(eq_geom, atoms, potential, masses=None, dx=0.001, points_diag=5, points_off_diag=3, dipole=None) .. py:attribute:: eq_geom .. py:attribute:: atoms .. py:attribute:: potential .. py:attribute:: masses :value: None .. py:attribute:: dx :value: 0.001 .. py:attribute:: points_diag :value: 5 .. py:attribute:: points_off_diag :value: 3 .. py:attribute:: num_elems .. py:attribute:: dipole :value: None .. py:method:: generate_hessian() .. py:method:: dipole_derivs() .. py:method:: diagonalize(hessian) .. py:method:: run() .. py:class:: InitialConditioner(coord, atoms, num_walkers, technique, technique_kwargs, masses=None) If given a minimum energy geometry of the system you are trying to run, it will generate a preliminary ensemble. In one instance, you can calculate the harmonic frequencies and normal modes, and then sample the harmonic 3N-6 ground state wave function along those normal modes. Will, in the future, handle other initial conditions. .. py:attribute:: coord .. py:attribute:: atoms .. py:attribute:: masses :value: None .. py:attribute:: num_walkers .. py:attribute:: technique .. py:attribute:: technique_kwargs .. py:method:: gen_disps(sigmas) .. py:method:: displace_along_nms(freqz, nmz, massez, ensemble) .. py:method:: run_harm() .. py:method:: run_permute() Must pass in a list of lists. .. py:method:: run() .. py:class:: DistIt(zs, method, eq_xyz=None, sorted_groups=None, sorted_atoms=None, full_mat=False, force_numpy=False) Calculates the Distance matrix, coulomb matrix, or SPF matrix (delta_r / r) for a given molecule. Returns a cupy or numpy multidimensional array. If cupy is installed, this will default to using it. This means in the run(cds) function, you must pass cds as a cupy array .. py:attribute:: zs .. py:attribute:: method .. py:attribute:: eq_xyz :value: None .. py:attribute:: sorted_groups :value: None .. py:attribute:: sorted_atoms :value: None .. py:attribute:: full_mat :value: False .. py:attribute:: force_numpy :value: False .. py:method:: check_cupy() .. py:method:: dist_matrix(atm_vec) If full matrix required, calculate it here. .. py:method:: atm_atm_dists(cds) Takes in coordinates, will return a vector of the atm-atm dists. .. py:method:: sort_atoms(d_mat) .. py:method:: sort_groups(d_mat) Swap 2 or more groups of atoms according to the sum of the norm of the group's columns. Only one type of group can swapped. .. py:method:: get_prepped_vec(atm_atm_vec) .. py:method:: run(cds) Takes in cartesian coordinates, outputs the descriptor matrix in either vector form (upper triangle) or matrix form. .. py:class:: ImpSampManager(trial_function, trial_directory, python_file, pot_manager, pass_timestep=False, new_pool_num_cores=None, deriv_function=None, trial_kwargs=None, deriv_kwargs=None) Imports and Wraps around the user-provided trial wfn and (optionally) the first and second derivatives. Parallelized using multiprocessing, which is considered the default for pyvibdmc. .. py:attribute:: trial_func .. py:attribute:: trial_dir .. py:attribute:: python_file .. py:attribute:: deriv_func :value: None .. py:attribute:: trial_kwargs :value: None .. py:attribute:: deriv_kwargs :value: None .. py:attribute:: pot_manager .. py:attribute:: pass_timestep :value: False .. py:attribute:: nomp_pool_cores :value: None .. py:method:: call_trial(cds) Get trial wave function using multiprocessing .. py:method:: call_trial_no_mp(cds) For call_derivs (finite diff), get trial wave function. Still used in the mp.pool context, just doesn't call pool itself .. py:method:: call_derivs(cds) For when derivatives are not supplied, call finite difference function. This is still parallelized. .. py:class:: ImpSampManager_NoMP(trial_function, trial_directory, python_file, chdir=False, pass_timestep=False, deriv_function=None, trial_kwargs=None, deriv_kwargs=None) Version of the manager that does not use any multiprocessing. If we ever evaluate the trial wfns with GPUs this could be useful. Could also be useful if multiprocessing is incompatible with your workflow. .. py:attribute:: trial_fuc .. py:attribute:: trial_dir .. py:attribute:: python_file .. py:attribute:: pass_timestep :value: False .. py:attribute:: deriv_func :value: None .. py:attribute:: trial_kwargs :value: None .. py:attribute:: deriv_kwargs :value: None .. py:attribute:: chdir :value: False .. py:method:: call_imp_func(func, cds, func_kwargs=None) Convenience function for trial, deriv, and sderiv so I don't have to have triplicates of code .. py:method:: call_trial(cds) Call trial wave function. .. py:method:: call_derivs(cds) For when derivatives are not supplied, call finite difference function. Returns derivatives divided by psi already .. py:class:: ImpSamp(imp_samp_manager) Internal class that: 1. Calculates local energy 2. Calculates drift terms 3. Calls trial wave function Directly interfaces with the simulation. Also a good place to put finite difference derivatives. .. py:attribute:: imp_manager .. py:method:: trial(cds) Internally returns the direct product wfn .. py:method:: drift(cds) Internally returns (dpsi/psi), since it's more convenient in the workflow. Also returns second derivatives divided by psi .. py:method:: metropolis(sigma_trip, trial_x, trial_y, disp_x, disp_y, D_x, D_y, dt) :staticmethod: .. py:method:: local_kin(inv_masses_trip, sec_deriv) :staticmethod: .. py:method:: finite_diff(cds, trial_func) :staticmethod: Internal finite diff of needed derivatives for imp samp DMC, dpsi/dx and d2spi/dx2 .. 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:: ChainRuleHelper(coords, module) .. py:attribute:: cds .. py:attribute:: xp .. py:attribute:: analyzer .. py:method:: dpsidx(dpsi_dr, dr_dx) Generic function that takes in a series of dpsi/dr matrices and dr/dx matrices and generates the dpsi/dx matrix. Assumes direct product wave function fed in appropriately. .. py:method:: d2psidx2(d2psi_dr2, d2r_dx2, dpsi_dr, dr_dx) Generic function that takes in a series of d2psi_dr2 and d2r/dx matrices and generates the second derivative of psi wrt x, doing out the chain rule explicitly. .. py:method:: dr_dx(atm_pair) calculates the dr/dx first derivatives for bond lengths :param self.cds: num_walkers x num_atms x 3 array :param atm_bonds: list of bond lengths that are relevant to the trial wave function. like [0,1] :return: num_walkers x num_atoms x 3 array of dr/dx .. py:method:: d2r_dx2(atm_pair, dr_dx=None) Calculates d2r/dx2 second derivatives for bond lengths .. py:method:: dcth_dx(atm_pair, cos_theta=None, dr_da=None, dr_dc=None) calculates the dcos(theta)/dx first derivatives for bond lengths :param self.cds: num_walkers x num_atms x 3 array :param atm_pair: list of bond lengths that are relevant to the trial wave function. like [0,2,1]. ALWAYS put vertex of angle in middle index atm_bonds[x][1]. :param dr_das: The derivative of the bond length corresponding to atm_bonds[i][0] and atm_bonds[i][1]. i is the index of the atm_bonds list of lists :param dr_dcs: The derivative of the bond length corresponding to atm_bonds[i][1] and atm_bonds[i][2]. i is the index of the atm_bonds list of lists :return: len(atm_bonds) x num_walkers x num_atoms x 3 array of dr/dx .. py:method:: d2cth_dx2(atm_pair, cos_theta=None, dr_da=None, dr_dc=None, d2r_da2=None, d2r_dc2=None) :param self.cds: num_walkers x num_atms x 3 array :param atm_bonds: list of lists of bond lengths that are relevant to the trial wave function. like [[0,2,1]]. ALWAYS put vertex of angle in middle index atm_bonds[x][1]. :param dr_das: The derivative of the bond length corresponding to atm_bonds[i][0] and atm_bonds[i][1]. i is the index of the atm_bonds list of lists :param dr_dcs: The derivative of the bond length corresponding to atm_bonds[i][1] and atm_bonds[i][2]. i is the index of the atm_bonds list of lists :param d2r_da2s: The second derivative of the bond length corresponding to atm_bonds[i][0] and atm_bonds[i][1]. i is the index of the atm_bonds list of lists :param d2r_dc2s: The second derivative of the bond length corresponding to atm_bonds[i][1] and atm_bonds[i][2]. i is the index of the atm_bonds list of lists .. py:method:: dth_dx(atm_pair, cos_theta=None, dcth_dx=None, dr_da=None, dr_dc=None) :param self.cds: num_walkers x num_atoms x 3 array :param atm_pair: list that corresponds to indices of the ABC angle, where B is the vertex :param dcth_dxs: Derivative of cosine theta wrt x. This is needed for this derivative and the second derivative. .. py:method:: d2th_dx2(atm_pair, cos_theta=None, dcth_dx=None, dr_da=None, dr_dc=None, d2r_da2=None, d2r_dc2=None) :param self.cds: num_walkers x num_atoms x 3 array :param atm_pair: list that corresponds to indices of the ABC angle, where B is the vertex :param dcth_dxs: Derivative of cosine theta wrt x. This is needed for this derivative and the second derivative. .. 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 .. py:data:: versions