averages module

torch_tdscha.averages.V_classic(R, phi, chi, psi)

Evaluate the potential energy at configuration R using the classical Taylor expansion up to fourth order.

Parameters:
  • R (ndarray)

  • phi (ndarray)

  • chi (ndarray)

  • psi (ndarray)

Returns:

Classical potential energy value.

Return type:

float

torch_tdscha.averages.av_V(R, A, phi, chi, psi)

Compute the average potential energy for a Gaussian distribution centered at R with covariance A, up to fourth order in displacements.

Parameters:
  • R (ndarray) – Displacement, covariance, and force-constant tensors.

  • A (ndarray) – Displacement, covariance, and force-constant tensors.

  • phi (ndarray) – Displacement, covariance, and force-constant tensors.

  • chi (ndarray) – Displacement, covariance, and force-constant tensors.

  • psi (ndarray) – Displacement, covariance, and force-constant tensors.

Returns:

Expectation value of the quatnum potential energy.

Return type:

float

torch_tdscha.averages.av_V_t(R, A, phi, chi, psi)

Compute the time-dependent average potential energy ⟨V(t)⟩ for trajectories of displacements R(t) and covariances A(t).

Parameters:
  • R (ndarray (nt, n))

  • A (ndarray (nt, n, n))

  • phi (ndarray)

  • chi (ndarray)

  • psi (ndarray)

Returns:

Average potential energy at each time step.

Return type:

ndarray (nt,)

torch_tdscha.averages.av_d3(R, chi, psi)

Compute the third-order derivative tensor averaged over displacements R.

Parameters:
  • R (ndarray (n,)) – Displacement vector.

  • chi (ndarray (n, n, n)) – Third-order force constants.

  • psi (ndarray (n, n, n, n)) – Fourth-order force constants.

Returns:

Averaged third-order tensor.

Return type:

ndarray (n, n, n)

torch_tdscha.averages.d2V(R, phi, chi, psi)

Compute the instantaneous second derivative of the potential energy (Hessian) at configuration R.

Parameters:
  • R (ndarray (n,))

  • phi (ndarray)

  • chi (ndarray)

  • psi (ndarray)

Returns:

Second-derivative (Hessian) matrix.

Return type:

ndarray (n, n)

torch_tdscha.averages.ext_for(t, field)

Compute the external driving force as a function of time.

Parameters:
  • t (float) – Time (in atomic units or fs converted accordingly).

  • field (dict) – Dictionary describing the external field: - ‘amp’ : field amplitude (kV/cm) - ‘freq’ : field frequency (THz) - ‘edir’ : polarization direction (3-vector, normalized) - ‘t0’ : pulse center (fs) - ‘sig’ : pulse width (fs) - ‘type’ : waveform (‘sine’, ‘pulse’, ‘gaussian1’, ‘gaussian2’, ‘sinc’) - ‘Zeff’ : effective charge tensor - ‘eps’ : dielectric constant

Returns:

External force vector acting on all vibrational coordinates.

Return type:

ndarray

torch_tdscha.averages.f_classic(R, phi, chi, psi)

Compute the classical force from the Taylor-expanded potential up to quartic order.

Parameters:
  • R (ndarray)

  • phi (ndarray)

  • chi (ndarray)

  • psi (ndarray)

Returns:

Classical force vector.

Return type:

ndarray

torch_tdscha.averages.force(R, A, phi, chi, psi)

Compute the total force acting on the nuclei from a 4th-order expansion of the potential energy surface.

Parameters:
  • R (ndarray (n,)) – Displacement vector from equilibrium positions.

  • A (ndarray (n, n)) – Covariance (or quantum fluctuation) matrix.

  • phi (ndarray (n, n)) – Harmonic (second-order) force-constant matrix.

  • chi (ndarray (n, n, n)) – Third-order force-constant tensor.

  • psi (ndarray (n, n, n, n)) – Fourth-order force-constant tensor.

Returns:

Total force vector including harmonic, cubic, quartic, and quantum-correction terms.

Return type:

ndarray (n,)

torch_tdscha.averages.force_t(R, A, phi, chi, psi)

Compute the time-dependent force for trajectories R(t), A(t).

Parameters:
  • R (ndarray (nt, n)) – Time series of displacements.

  • A (ndarray (nt, n, n)) – Time series of covariance matrices.

  • phi (ndarray) – Harmonic, cubic, and quartic force-constant tensors.

  • chi (ndarray) – Harmonic, cubic, and quartic force-constant tensors.

  • psi (ndarray) – Harmonic, cubic, and quartic force-constant tensors.

Returns:

Force vectors at each time step.

Return type:

ndarray (nt, n)

torch_tdscha.averages.kappa(R, A, phi, chi, psi)

Compute the effective force-constant matrix (curvature tensor).

Parameters:
  • R (ndarray) – Same quantities as in force.

  • A (ndarray) – Same quantities as in force.

  • phi (ndarray) – Same quantities as in force.

  • chi (ndarray) – Same quantities as in force.

  • psi (ndarray) – Same quantities as in force.

Returns:

Effective force constants tensor including third- and fourth-order corrections and quantum effects.

Return type:

ndarray

torch_tdscha.averages.kappa_t(R, A, phi, chi, psi)

Time-dependent effective force-constants tensor kappa(t), computed for time series of displacements and covariances.

Parameters:
  • R (ndarray (nt, n))

  • A (ndarray (nt, n, n))

  • phi (ndarray)

  • chi (ndarray)

  • psi (ndarray)

Returns:

Effective force-constants tensors at each time.

Return type:

ndarray (nt, n, n)

torch_tdscha.averages.torch_av_V(R, A, phi, chi, psi)

PyTorch implementation of av_V, computing the average potential energy using tensor operations.

Parameters:
Returns:

Scalar potential energy.

Return type:

torch.Tensor

torch_tdscha.averages.torch_ext_for(t, field)

PyTorch implementation of ext_for, supporting tensor operations.

Parameters:
  • t (float or torch.Tensor) – Time value(s).

  • field (dict) – Same field dictionary as in ext_for, with torch.Tensor values for Zeff and edir.

Returns:

External force vector as a function of time.

Return type:

torch.Tensor

torch_tdscha.averages.torch_force(R, A, phi, chi, psi)

PyTorch implementation of force, enabling GPU execution.

Parameters:
  • R (torch.Tensor) – Same physical quantities as in force, represented as tensors.

  • A (torch.Tensor) – Same physical quantities as in force, represented as tensors.

  • phi (torch.Tensor) – Same physical quantities as in force, represented as tensors.

  • chi (torch.Tensor) – Same physical quantities as in force, represented as tensors.

  • psi (torch.Tensor) – Same physical quantities as in force, represented as tensors.

Returns:

Total force vector.

Return type:

torch.Tensor

torch_tdscha.averages.torch_kappa(R, A, phi, chi, psi)

PyTorch implementation of kappa, enabling GPU.

Parameters:
  • R (torch.Tensor) – Same physical quantities as in kappa.

  • A (torch.Tensor) – Same physical quantities as in kappa.

  • phi (torch.Tensor) – Same physical quantities as in kappa.

  • chi (torch.Tensor) – Same physical quantities as in kappa.

  • psi (torch.Tensor) – Same physical quantities as in kappa.

Returns:

Effective force-constants tensor.

Return type:

torch.Tensor