maxwelllink.tools.ir module

Utilities for spectral post-processing of MD simulations.

maxwelllink.tools.ir.auto_correlation_function(x)[source]

Compute the autocorrelation of a 1D array via FFT-based convolution.

Parameters:

x (numpy.ndarray) – 1D input array for which to compute the autocorrelation function.

Returns:

Autocorrelation of the input signal, truncated to half-length.

Return type:

numpy.ndarray

maxwelllink.tools.ir.fft(x, dtfs, N=None, field_description='square')[source]

Compute a DCT-based spectrum for a 1D signal.

Parameters:
  • x (numpy.ndarray) – 1D time-domain signal.

  • dtfs (float) – Time step in femtoseconds.

  • N (int or None, optional) – Number of points for the discrete cosine transform. None (default) uses x.size. Values greater than x.size result in zero-padding.

  • field_description ({'square', 'none'}, default: 'square') – Field prefactor applied to the DCT output. Use 'square' for dipole autocorrelation functions and 'none' for velocity autocorrelations.

Returns:

  • numpy.ndarray – Frequencies in \(\text{cm}^{-1}\).

  • numpy.ndarray – Spectral intensities.

Raises:

ValueError – If field_description is not 'square' or 'none'.

maxwelllink.tools.ir.ir_spectrum(x, dtfs, N=None, field_description='square', smooth_window_len=11)[source]

Compute an infrared spectrum from a dipole trajectory.

Parameters:
  • x (numpy.ndarray) – Dipole moment trajectory.

  • dtfs (float) – Time step in femtoseconds.

  • N (int or None, optional) – Number of DCT points. None (default) uses x.size. Values greater than x.size result in zero-padding.

  • field_description ({'square', 'none'}, default: 'square') – Field prefactor passed to fft(). Use 'square' for dipole autocorrelation functions and 'none' for velocity autocorrelations.

  • smooth_window_len (int or None, optional) – Window length applied to smooth the spectrum. None disables smoothing. Default is 11.

Returns:

  • numpy.ndarray – Frequencies in \(\text{cm}^{-1}\).

  • numpy.ndarray – Smoothed IR spectral intensities.

Raises:

ValueError – If field_description is not 'square' or 'none'.

maxwelllink.tools.ir.smooth(x, window_len=11, window='hamming')[source]

Smooth 1D data using a windowed moving-average convolution.

Parameters:
  • x (numpy.ndarray) – 1D input signal to smooth.

  • window_len (int, default: 11) – Size of the smoothing window. Must be an odd integer greater than or equal to 3.

  • window ({'flat', 'hanning', 'hamming', 'bartlett', 'blackman'}, default: 'hamming') – Window function used for smoothing. 'flat' corresponds to a moving average.

Returns:

Smoothed signal.

Return type:

numpy.ndarray