normal_modes

libra_py.normal_modes.compute_cov(R, V, A, M, E, params)[source]

Computes and visualizes (as the trajectories) normal modes following the methods described in:

(1) Strachan, A. Normal Modes and Frequencies from Covariances in Molecular Dynamics or Monte Carlo Simulation. J. Chem. Phys. 2003, 120, 1-4.

Parameters
  • R (MATRIX(ndof x nsteps-1)) – coordinates of all DOFs for all mid-timesteps

  • V (MATRIX(ndof x nsteps-1)) – velocities of all DOFs for all mid-timesteps

  • A (MATRIX(ndof x nsteps-1)) – accelerations of all DOFs for all mid-timesteps

  • M (MATRIX(ndof x 1)) – masses of all DOFs

  • E (list of ndof/3 strings) – atom names (elements) of all atoms

  • params (dictionary) –

    parameters controlling the computations, including the visualization (see the visualize_modes(E, R, U, w, params) description). Contains keyword-value pairs:

    • params[“verbosity”] (int): level to control verbosity

    • params[“visualize”] (int): flag to control whether we want to produce additional files (with normal modes)
      • 0 - not to

      • 1 - do it

Returns

(w, w_inv_cm, U_v, w2, w2_inv_cm, U_a), where:
  • w ( MATRIX(ndof,1) ): frequencies from the velocity covariance matrix

  • w_inv_cm ( MATRIX(ndof,1) ): frequencies from the velocity covariance matrix, in cm^-1 units

  • U_v ( MATRIX(ndof,ndof) ): eigenvectors of the velocity covariance matrix

  • w2 ( MATRIX(ndof,1) ): frequencies from the acceleration covariance matrix

  • w2_inv_cm ( MATRIX(ndof,1) ): frequencies from the acceleration covariance matrix, in cm^-1 units

  • U_a ( MATRIX(ndof,ndof) ): eigenvectors of the acceleration covariance matrix

Return type

tuple

Note

All quantities are in atomic units

libra_py.normal_modes.compute_cov1(R, V, M, E, params)[source]

Same as compute_cov, except that we don’t use the acceleration data

Computes and visualizes (as the trajectories) normal modes following the methods described in:

(1) Strachan, A. Normal Modes and Frequencies from Covariances in Molecular Dynamics or Monte Carlo Simulation. J. Chem. Phys. 2003, 120, 1-4.

Parameters
  • R (MATRIX(ndof x nsteps-1)) – coordinates of all DOFs for all mid-timesteps [Bohr]

  • V (MATRIX(ndof x nsteps-1)) – velocities of all DOFs for all mid-timesteps [a.u. of velocity]

  • M (MATRIX(ndof x 1)) – masses of all DOFs [a.u. of mass]

  • E (list of ndof/3 strings) – atom names (elements) of all atoms

  • params (dictionary) –

    parameters controlling the computations, including the visualization (see the visualize_modes(E, R, U, w, params) description). Contains keyword-value pairs:

    • params[“verbosity”] (int): level to control verbosity

    • params[“visualize”] (int): flag to control whether we want to produce additional files (with normal modes)
      • 0 - not to

      • 1 - do it

Returns

(w, w_inv_cm, U_v), where:
  • w ( MATRIX(ndof,1) ): frequencies from the velocity covariance matrix

  • w_inv_cm ( MATRIX(ndof,1) ): frequencies from the velocity covariance matrix, in cm^-1 units

  • U_v ( MATRIX(ndof,ndof) ): eigenvectors of the velocity covariance matrix

Return type

tuple

Note

All quantities are in atomic units

libra_py.normal_modes.compute_cov2(R, A, M, E, T, params)[source]

Computes and visualizes (as the trajectories) normal modes following the methods described in:

(1) Pereverzev, A.; Sewell, T. D. Obtaining the Hessian from the Force Covariance Matrix: Application to Crystalline Explosives PETN and RDX. J. Chem. Phys. 2015, 142, 134110.

Parameters
  • R (MATRIX(ndof x nsteps-1)) – coordinates of all DOFs for all mid-timesteps

  • A (MATRIX(ndof x nsteps-1)) – accelerations of all DOFs for all mid-timesteps

  • M (MATRIX(ndof x 1)) – masses of all DOFs

  • E (list of ndof/3 strings) – atom names (elements) of all atoms

  • T (double) – temperature of simulation (in K)

  • params (dictionary) –

    parameters controlling the computations, including the visualization (see the visualize_modes(E, R, U, w, params) description). Contains keyword-value pairs:

    • params[“verbosity”] ( int ): level to control verbosity

    • params[“visualize”] ( int ): flag to control whether we want to produce additional files (with normal modes)
      • 0 - not to

      • 1 - do it

Returns

(w_a, w_inv_cm, U_a), where:

  • w_a ( MATRIX(ndof,1) ): frequencies - Hessian eigenvalues

  • w_inv_cm ( MATRIX(ndof,1) ): frequencies from - Hessian eigenvalues, in cm^-1 units

  • U_a ( MATRIX(ndof,ndof) ): Hessian eigenvectors

Return type

tuple

Note

All quantities are in atomic units

libra_py.normal_modes.compute_dynmat(R, D, M, E, params)[source]

Computes and visualizes (as the trajectories) normal modes using the dynamic matrix: D_ij = [1/sqrt(m_i * m_j)] d^2E/dR_i dR_j

Here, H_ij = d^2E/dR_i dR_j is the Hessian

Parameters
  • R (MATRIX(ndof x nsteps-1)) – coordinates of all DOFs for all mid-timesteps

  • D (MATRIX(ndof x nsteps-1)) – the dynamic matrix

  • M (MATRIX(ndof x 1)) – masses of all DOFs

  • E (list of ndof/3 strings) – atom names (elements) of all atoms

  • params (dictionary) –

    parameters controlling the computations, including the visualization (see the visualize_modes(E, R, U, w, params) description). Contains keyword-value pairs:

    • params[“verbosity”] ( int ): level to control verbosity

    • params[“visualize”] ( int ): flag to control whether we want to produce additional files (with normal modes)
      • 0 - not to

      • 1 - do it

Returns

(w_a, w_inv_cm, U_a), where:

  • w_a ( MATRIX(ndof,1) ): frequencies - Hessian eigenvalues

  • w_inv_cm ( MATRIX(ndof,1) ): frequencies from - Hessian eigenvalues, in cm^-1 units

  • U_a ( MATRIX(ndof,ndof) ): Hessian eigenvectors

Return type

tuple

Note

All quantities are in atomic units

libra_py.normal_modes.covariance_matrix(X, M, flag)[source]

Computes the covariance matrix

Computes the covariance matrix $$K^x = <sqrt(m_i * m_j) * x_i * x_j }>$$

Parameters
  • X (MATRIX(ndof, nsteps)) – data collected along a trajectory: can be R, V, or A

  • M (MATRIX(ndof, 1)) – masses of all DOFs

  • flag (int) –

    controls how to compute variance

    • 0 - using the data as they are (no centering)

    • 1 - using the fluctuations of the data around the mean (do centering)

Returns

the matrix of covariance of all DOFs averaged over the trajectory

Return type

MATRIX(ndof, ndof)

libra_py.normal_modes.get_xyz(E, R, M, U, mode)[source]

This function returns a string in the xyz format with X, Y, Z and UX, UY, UZ where X,Y,Z are the coordinates, UX, UY, UZ - vectors coming from those coordinates - e.g. normal modes

Parameters
  • E (list of ndof/3 strings) – atom names (elements) of all atoms

  • R (MATRIX(ndof x nsteps-1)) – coordinates of all DOFs for all mid-timesteps

  • M (MATRIX(ndof x 1)) – masses of all DOFs

  • U (MATRIX(ndof x ndof)) – a matrix containing normal mode vectors

  • mode (int) – index of the normal mode that we want to visualize

Returns

A string representing an xyz file

Return type

string

libra_py.normal_modes.get_xyz2(E, R, U, mode)[source]

This function returns a string in the xyz format with X, Y, Z and UX, UY, UZ where X,Y,Z are the coordinates, UX, UY, UZ - vectors coming from those coordinates - e.g. normal modes

Parameters
  • E (list of ndof/3 string) – atom names (elements) of all atoms

  • R (MATRIX(ndof x nsteps-1)) – coordinates of all DOFs for all mid-timesteps

  • U (MATRIX(ndof x ndof)) – a matrix containing normal mode vectors

  • mode (int) – index of the normal mode that we want to visualize

Returns

A string representing an xyz file

Return type

string

libra_py.normal_modes.visualize_modes(E, R, U, M, w, params)[source]

This function “visualizes” a particular collective modes for a particular set of data. The visualization means we generate an “xyz” file, showing the trajectory with defined number of repetitions of the mode.

Parameters
  • E (list of ndof/3) – atom names (elements) of all atoms

  • R (MATRIX(ndof x nsteps-1)) – coordinates of all DOFs for all mid-timesteps

  • U (MATRIX(ndof, ndof)) – eigenvectors defining the collective modes in terms of the original DOFs, see the theory

  • M (MATRIX(ndof x 1)) – masses of all DOFs

  • w (list of ndof doubles) – frequencies of all modes

  • params (dictionary) –

    parameters controlling how to do the visualization. Contains keyword-value pairs:

    • params[“scale”] ( double ): mode amplification factor (for better visualization)

    • params[“print_modes”] ( list of integers ): indices of the modes to handle. Indexing starts with 0 and should be consistent with other data arrays provided - e.g. “w”

    • params[“prefix”] ( string ): the name of the prefix of the files, to where the modes are printed out

    • params[“nperiods”] ( integer ): the number of periods of motion to repeat

    • params[“nsteps”] ( integer ): how many steps should be in the “visualization” trajectory. Controls the resolution of the modes

Returns

Simply prints out a number of files with the trajectories (using Angstrom units) showing the

periodic motion along the modes of interest

Return type

None

Note

All quantities are in atomic units