Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ghislainp committed May 4, 2020
1 parent 36ec835 commit 8d32fb0
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions smrt/microstructure_model/autocorrelation.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,8 @@ def ft_autocorrelation_function_fft(self, k):

# fft for auxiliary wave vector array
ft_resampled = np.empty_like(C)
ft_resampled[1:] = dst(4 * np.pi * C[1:] * r[1:], type=1)
ft_resampled[1:] /= 2 / dr * k_resampled[1:]
ft_resampled[0] = dr * 4 * np.pi * np.sum(C*r**2)
ft_resampled[1:] = dst(4 * np.pi * C[1:] * r[1:], type=1) / (2 / dr * k_resampled[1:])
ft_resampled[0] = dr * 4 * np.pi * np.sum(C * r**2)

# get ft values for input k-values by linear interpolation
ft = np.interp(k_abs, k_resampled, ft_resampled)
Expand All @@ -136,16 +135,15 @@ def autocorrelation_function_invfft(self, r):

no_points = (np.max(r) - np.min(r)) / r_spacing
points = np.arange(no_points)
r_resampled = r_spacing*points
r_resampled = r_spacing * points

dk = np.pi / (no_points * r_spacing)
k = dk*points
k = dk * points
ft = self.ft_autocorrelation_function(k)

C_resampled = np.empty_like(ft)
C_resampled[1:] = dst(4 * np.pi * ft[1:] * k[1:], type=1)
C_resampled[1:] /= 2 / (dk / (2*np.pi)**3) * r_resampled[1:]
C_resampled[0] = (dk / (2*np.pi)**3) * 4 * np.pi*sum(ft*k**2)
C_resampled[1:] = dst(4 * np.pi * ft[1:] * k[1:], type=1) / (2 / (dk / (2 * np.pi)**3) * r_resampled[1:])
C_resampled[0] = (dk / (2 * np.pi)**3) * 4 * np.pi * np.sum(ft * k**2)

# get invft values corresponding to input r-values by linear interpolation
C = np.interp(r, r_resampled, C_resampled)
Expand Down

0 comments on commit 8d32fb0

Please sign in to comment.