Tools
A number of utility functions, for example for dealing with autocorrelation functions, Fourier transforms, and smoothing.
- dynasor.tools.acfs.compute_acf(Z, delta_t=1.0, method='scipy')[source]
Computes the autocorrelation function (ACF) for a one-dimensional signal \(Z\) in time as
\[ACF(\tau) = \frac{\left < Z(t) Z^*(t+\tau) \right >}{\left < Z(t) Z^*(t) \right >}\]Here, only the real part of the ACF is returned since if \(Z\) is complex the imaginary part should average out to zero for any stationary signal.
- Parameters
Z (
ndarray
[Any
,dtype
[float
]]) – complex time signaldelta_t (
float
) – spacing in time between two consecutive values in \(Z\)method – implementation to use; possible values: numpy and scipy (default and usually faster)
- dynasor.tools.acfs.fermi_dirac(t, t_0, t_width)[source]
Evaluates a Fermi-Dirac-like function in time \(f(t)\), which can be applied to an ACF in time to artificially damp it, i.e., forcing it to go to zero for long times without affecting the short-time correlations too much.
\[f(t) = \frac{1}{\exp{[(t-t_0)/t_\mathrm{width}}] + 1}\]- Parameters
t (
ndarray
[Any
,dtype
[float
]]) – time arrayt_0 (
float
) – starting time for decayt_width (
float
) – width of the decay
- dynasor.tools.acfs.gaussian_decay(t, t_sigma)[source]
Evaluates a gaussian distribution in time \(f(t)\), which can be applied to an ACF in time to artificially damp it, i.e., forcing it to go to zero for long times.
\[f(t) = \exp{\left [-\frac{1}{2} \left (\frac{t}{t_\mathrm{sigma}}\right )^2 \right ] }\]- Parameters
t (
ndarray
[Any
,dtype
[float
]]) – time arrayt_sigma (
float
) – width (standard deviation of the gaussian) of the decay
- dynasor.tools.acfs.smoothing_function(data, window_size, window_type='hamming')[source]
Smoothing function for 1D arrays. This functions employs pandas rolling window average
- Parameters
data (
ndarray
[Any
,dtype
[float
]]) – 1D data arraywindow_size (
int
) – The size of smoothing/smearing windowwindow_type (
str
) – What type of window-shape to use, e.g.'blackman'
,'hamming'
,'boxcar'
(see pandas and scipy documentaiton for more details)
- dynasor.tools.damped_harmonic_oscillator.acf_position_dho(t, w0, gamma, A=1.0)[source]
The damped damped harmonic oscillator (DHO) autocorrelation function for the position. The definition of this function can be found in the dynasor documentation <dynasor.materialsmodeling.org/theory.html#damped-harmonic-oscillator-model>_.
- Parameters
t (
ndarray
[Any
,dtype
[float
]]) – Time, usually as an array.w0 (
float
) – Natural angular frequency of the DHO.gamma (
float
) – Damping of DHO.A (
float
) – Amplitude of the DHO.
- dynasor.tools.damped_harmonic_oscillator.acf_velocity_dho(t, w0, gamma, A=1.0)[source]
The damped damped harmonic oscillator (DHO) autocorrelation function for the velocity. The definition of this function can be found in the dynasor documentation <dynasor.materialsmodeling.org/theory.html#damped-harmonic-oscillator-model>_.
- Parameters
t (
ndarray
[Any
,dtype
[float
]]) – Time, usually as an array.w0 (
float
) – Natural angular frequency of the DHO.gamma (
float
) – Damping of DHO.A (
float
) – Amplitude of the DHO.
- dynasor.tools.damped_harmonic_oscillator.psd_position_dho(w, w0, gamma, A=1.0)[source]
The power spectral density (PSD) function for the damped harmonic oscillator (DHO) (i.e., the Fourier transform of the autocorrelation function) for the position.
The definition of this function can be found in the dynasor documentation <dynasor.materialsmodeling.org/theory.html#damped-harmonic-oscillator-model>_.
- Parameters
w (
ndarray
[Any
,dtype
[float
]]) – Angular frequency, usually as an array.w0 (
float
) – Natural angular frequency of the DHO.gamma (
float
) – Damping of DHO.A (
float
) – Amplitude of the DHO.
- dynasor.tools.damped_harmonic_oscillator.psd_velocity_dho(w, w0, gamma, A=1.0)[source]
The power spectral density (PSD) function for the damped harmonic oscillator (DHO) (i.e., the Fourier transform of the autocorrelation function) for the position.
The definition of this function can be found in the dynasor documentation <dynasor.materialsmodeling.org/theory.html#damped-harmonic-oscillator-model>_.
- Parameters
w (
ndarray
[Any
,dtype
[float
]]) – Angular frequency, usually as an array.w0 (
float
) – Natural angular frequency of the DHO.gamma (
float
) – Damping of DHO.A (
float
) – Amplitude of the DHO.