tsh_stat

libra_py.tsh_stat.amplitudes2denmat(coeffs)[source]
Converts the wavefunction amplitudes for all trajectories to the corresponding

density matrices

Parameters

coeffs (list of CMATRIX(nstates, 1)) – wavefunction amplitudes for all trajectories

Returns

density matrices for all trajectory

Return type

( list of CMATRIX(nstates, nstate) )

libra_py.tsh_stat.avarage_populations(el)[source]

This function computes the SH statistics for an ensemble of trajectories

Parameters

el (list of Electronic) – The list containing electronic DOF variables for all trajectories in ensemble. The length of the list determines the number of trajectories in ensemble

Returns

( sh_pops, se_pops, rho ):

  • sh_pops ( list of N float ): The list containing the average population

    of each quantum state based on the statistics of the discrete states in which each trajectory resides. Here, N is the number of states

  • se_pops ( list of N float ): The list containing the average population

    of each quantum state based on the amplitudes of all quantum states as obtained from the TD-SE solution. Here, N is the number of states

  • rho ( CMATRIX(N,N) ): The matrix containing the trajectory-averaged

    SE populations and coherences. Here, N is the number of states

Return type

tuple

libra_py.tsh_stat.ave_en(denmat_sh, denmat_se, Hvib)[source]

Computes ensemble averaged SH and SE energies

Parameters
  • denmat_sh (list of CMATRIX(nst_in, nst_in)) – SE density matrices (diagonal) for each trajectory

  • denmat_se (list of CMATRIX(nst_in,nst_in)) – SE density matrices for each trajectory

  • Hvib (list of CMATRIX(nst_in,nst_in)) – Hvib for each trajectory [units: arbitrary]

Returns

ave_en_sh, ave_en_se, where:

  • ave_en_sh ( double ): SH-averaged energy [ units: same as Hvib ]

  • ave_en_se ( double ): SE-averaged energy [ units: same as Hvib ]

Return type

(double, double)

libra_py.tsh_stat.ave_pop(denmat_sh, denmat_se)[source]

Compute the ensemble-averaged SH and SE density matrices

Parameters
  • denmat_sh (list of CMATRIX(N, N)) – SH density matrix (diagonal) for each trajectory. Such that `denmat_sh[itraj]` corresponds to the trajectory `itraj`

  • denmat_se (list of CMATRIX(N, N)) – SE density matrix for each trajectory. Such that `denmat_se[itraj]` corresponds to the trajectory `itraj`

Returns

( ave_pop_sh, ave_pop_se ):

  • ave_pop_sh ( CMATRIX(N, N) ): the ensemble-averaged SH density matrix

  • ave_pop_se ( CMATRIX(N, N) ): the ensemble-averaged SE density matrix

Return type

tuple

libra_py.tsh_stat.compute_dm(ham, Cdia, Cadi, projectors, rep, lvl)[source]

Compute the trajectory-averaged density matrices in diabatic or adiabatic representations

Parameters
  • ham (nHamiltonian) – object that handles Hamiltonian-related calculations with many trajectories

  • Cdia (CMATRIX(ndia, ntraj)) – amplitudes of diabatic states in the TD wavefunction expansion

  • Cadi (CMATRIX(ndia, ntraj)) – amplitudes of adiabatic states in the TD wavefunction expansion

  • projectors (list of CMATRIX(nst, nst)) – dynamically-consistent corrections

  • rep (int) –

    a selector of which representation is considered main (being propagated) E.g. if rep = 0 - that means we propagate the diabatic coefficients, that is the calculation of the diabatic density matrix is straightforward, but we need to involve some transformations to compute the adiabatic density matrix and vice versa, if rep = 1, the propagation is done according to the adiabatic properties and we’d need to convert to the diabatic representation in the end

    • 0: diabatic

    • 1: adiabatic

  • lvl (int) – The level of the Hamiltonian that treats the transformations: - 0: ham is the actual Hamiltonian to use (use with single trajectory), - 1: ham is the parent of the Hamiltonians to use (use with multiple trajectories)

Returns

( dm_dia, dm_adi ):

  • dm_dia ( CMATRIX(ndia, ndia) ): the trajectory-averaged density matrix in

    the diabatic representation. Here, ndia - is the number of diabatic basis states

  • dm_adi ( CMATRIX(nadi, nadi) ): the trajectory-averaged density matrix in

    the adiabatic representation. Here, nadi - is the number of adiabatic basis states

Return type

tuple

libra_py.tsh_stat.compute_etot(ham, p, Cdia, Cadi, projectors, iM, rep)[source]

Computes the Ehrenfest potential energy

This function computes the average kinetic, potential, and total energies for an ensemble of trajectories - according to the Ehrenfest recipe

Parameters
  • ham (nHamiltonian) – object that handles Hamiltonian-related calculations with many trajectories

  • p (MATRIX(ndof, ntraj)) – nuclear momenta of multiple trajectories

  • Cdia (CMATRIX(ndia, ntraj)) – amplitudes of diabatic states in the TD wavefunction expansion

  • Cadi (CMATRIX(ndia, ntraj)) – amplitudes of adiabatic states in the TD wavefunction expansion

  • projectors (list of CMATRIX(nst, nst)) – dynamically-consistent corrections

  • iM (MATRIX(ndof, 1)) – inverse masses for all nuclear DOFs

  • rep (int) –

    The selector of the representation that is of current interest.

    • 0: diabatic

    • 1: adiabatic

Returns

( Ekin, Epot, Etot, dEkin, dEpot, dEtot ): here

  • Ekin ( double ): average kinetic energy of the ensemble

  • Epot ( double ): average potential energy of the ensemble

  • Etot ( double ): average total energy of the ensemble

  • dEkin ( double ): standard deviation of the kinetic energy in the ensemble

  • dEpot ( double ): standard deviation of the potential energy in the ensemble

  • dEtot ( double ): standard deviation of the total energy in the ensemble

Return type

tuple

libra_py.tsh_stat.compute_etot_tsh(ham, p, Cdia, Cadi, projectors, act_states, iM, rep)[source]

Compute the adiabatic potential energy

This function computes the average kinetic, potential, and total energies for an ensemble of trajectories - according to the TSH recipe

Parameters
  • ham (nHamiltonian) – object that handles Hamiltonian-related calculations with many trajectories

  • p (MATRIX(ndof, ntraj)) – nuclear momenta of multiple trajectories

  • Cdia (CMATRIX(ndia, ntraj)) – amplitudes of diabatic states in the TD wavefunction expansion

  • Cadi (CMATRIX(nadi, ntraj)) – amplitudes of adiabatic states in the TD wavefunction expansion

  • projectors (list of CMATRIX(nst, nst)) – dynamically-consistent corrections

  • iM (MATRIX(ndof, 1)) – inverse masses for all nuclear DOFs

  • rep (int) –

    The selector of the representation that is of current interest.

    • 0: diabatic

    • 1: adiabatic

Returns

( Ekin, Epot, Etot, dEkin, dEpot, dEtot ): here

  • Ekin ( double ): average kinetic energy of the ensemble

  • Epot ( double ): average potential energy of the ensemble

  • Etot ( double ): average total energy of the ensemble

  • dEkin ( double ): standard deviation of the kinetic energy in the ensemble

  • dEpot ( double ): standard deviation of the potential energy in the ensemble

  • dEtot ( double ): standard deviation of the total energy in the ensemble

Return type

tuple

libra_py.tsh_stat.compute_sh_statistics(nstates, istate, projectors)[source]

This function computes the SH statistics for an ensemble of trajectories

Parameters
  • nstates (int) – The number of considered quantum states

  • istate (list of integers) – The list containing the info about the index of a quantum state in which each trajectory is found. The length of the list is equal to the number of trajectories. Each element of the list is the state index for that trajectory. In other words, istate[0] is the quantum state for a trajectory 0, istate[1] is the quantum state for a trajectory 1, etc.

Returns

coeff_sh: The list containing the average

population of each quantum state. The length of the list is equal to the total number of quantum states considered, `nstates`

Return type

MATRIX(nstates, 1)

libra_py.tsh_stat.denmat2prob(P)[source]

Convert the density matrix to the populations

Parameters

P (CMATRIX(N, N)) – Density matrix

Returns

populations of all states

Return type

( list of doubles )

libra_py.tsh_stat.pops2denmat(pops)[source]
Converts the populations (vector) of all states for all trajectories to the corresponding

density matrices (matrix). This is just a convenience function

Parameters

pops (list of CMATRIX(nstates, 1)) – state populations for all trajectories

Returns

density matrices for all trajectories

Return type

( list of CMATRIX(nstates, nstate) )

libra_py.tsh_stat.probabilities_1D_scattering(q, states, nst, params)[source]

Computes the scattering probabilities in 1D

Parameters
  • _q (MATRIX(nnucl, ntraj)) – coordinates of the “classical” particles [units: Bohr]

  • states (intList, or list of ntraj ints) – the quantum state of each trajectory

  • nst (int) – the number of possible quantum states in the problem

  • params (dictionary) –

    parameters of the simulation, should contain

    • params[“act_dof”] ( int ): index of the nuclear DOF that is considered active (scattering coord)

    • **params[“left_boundary”] ( double ): the beginning of the reflected particles counter [units: Bohr]

    • **params[“right_boundary”] ( double ): the beginning of the transmitted particles counter [units: Bohr]

Returns

( pop_refl, pop_transm ): where

  • pop_refl ( MATRIX(nst, 1) ): probabilities of reflection on each state

  • pop_transm ( MATRIX(nst, 1) ): probabilities of transmission on each state

Return type

tuple

libra_py.tsh_stat.update_sh_pop(istate, nstates)[source]
Parameters
  • istate (list of integers) – The list containing the info about the index of a quantum state in which each trajectory is found. The length of the list is equal to the number of trajectories. Each element of the list is the state index for that trajectory. In other words, istate[0] is the quantum state for a trajectory 0, istate[1] is the quantum state for a trajectory 1, etc.

  • nstates (int) – The number of considered quantum states

Returns

pops: The list containing the average

SH-based population of each quantum state. The length of the list is equal to the total number of quantum states considered, `nstates`

Return type

( list of `nstates` ints )

Note

The functionality is the same as of `compute_sh_statistics`, just a different format of the output