Unwanted sine modes appearing in convolution using FFT
まだ誰も着手していません。
評価
調査の方向性
まず issue の Julia MWE を実行し、fft の周波数構成、weight_hat の計算、および real(ifft(I_hat)) の結果に注目してください。FFT 畳み込みを手動で評価した積分と比較し、残っている振動が畳み込みの設定によるものか FastTransforms.jl によるものかを判断してください。原因と、再現可能な修正または制限事項を文書化してください。
索引モデルが issue の本文から書いたものです。
説明
Hi All, I don't know if this is an issue with FastTransforms.jl specifically or something that I've done, but any guidance that could be provide will be appreciated.
To give a little bit of background, I'm trying to perform the following convolution (nV, r and r' are vectors):
n_\mathbf{V}(r) = \int d\mathbf{r}' \rho (r') \delta(|r-r'|-R) \frac{r-r'}{|r-r'|}
Where rho(r) is a profile which looks like (I've made sure it's periodic):
I have obtained an analytical expression for the fourier transform of the last two terms in the integral as:
\hat{w} = 4\pi i \frac{k}{|k|^3} (\sin(|k|R)-|k|R\cos(|k|R))
If I use just regular Float64, the resulting nV profile looks fine:
Except when I zoom in:
While these values are small, in a later part of my code, I need to divide this profile by a small number which makes this 'noise' blow up and affects calculations downstream.
I tried using FastTransforms.jl since it would let me go to higher precision. However, even when I use BigFloat, although it removes the noise, some unphysical oscillations remain:
Im no longer certain that these remaining oscillations are due to floating point errors. I also call these oscillations unphysical as, aside from the nature of this convolution integral, if I perform this convolution integral manually, the oscillations disappear completely (and I'm able to obtain the integral to higher precision).
Am I doing something wrong in the way I'm performing the convolution integral? Thanks!
I've attached an MWE below:
using FFTW, FastTransforms
# Generating the density profile
tanh_prof(x,start,stop,shift,coef) = 1/2*(start-stop)*tanh((x-shift)*coef)+1/2*(start+stop)
ub = 10
lb = -10
z = LinRange(lb,ub,4000)
rho1 = 1e3
rho2 = 1e-12
rho = @. tanh_prof(z,rho1,rho2,(ub/4+3*lb/4),20)*(z<=0) +
tanh_prof(z,rho2,rho1,(3*ub/4+lb/4),20)*(z>0)
# Obtaining the fourier transform of w_hat
freq = fftfreq(4000,4000/20)
R = 1/2*2pi
weight_hat = @. 0.0 - 4π*im*freq/abs(freq)^3*(sin(abs(freq)*R)-R*abs(freq)*cos(abs(freq)*R)) *(freq != 0.0)
# Performing the convolution integral
rho_hat = fft(rho)
I_hat = @. rho_hat*weight_hat
nV = real(ifft(I_hat))
- 主要言語
- Julia
- スター
- 282
- フォーク
- 27
- 平均マージ
- 53分
- マージ済み PR(30日)
- 1
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
JuliaApproximation/FastTransforms.jl のほかの issue
-
Loading FastTransforms.jl can make FFTs via FFTW.jl 100x slower due to threading conflicts対応中かも @dlfivefifty が 96 日前に担当しました。 オープン
JuliaApproximation/FastTransforms.jl#267 · リアクション 2 件 · 担当者 2 名 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 38/100
JuliaApproximation/FastTransforms.jl#266 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
JuliaApproximation/FastTransforms.jl#263 · コメント 2 件 ·
-
Allocating lmul!オープン
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
JuliaApproximation/FastTransforms.jl#253 · コメント 7 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
JuliaApproximation/FastTransforms.jl の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
SciML/OrdinaryDiffEq.jl#4875 ·
メンテナーはふだん 3 日以内に返信
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
SciML/NonlinearSolve.jl#1372 ·
メンテナーはふだん 1 日以内に返信
-
Truncated discrete ccdf and logccdf return incorrect values at the lower atom対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
JuliaStats/Distributions.jl#2095 ·
-
documentation 📜 microphysics💧 ❄️
難易度 2/5 1〜3時間 初心者へのやさしさ 63/100
NumericalEarth/Breeze.jl#1073 ·
メンテナーはふだん 1 日以内に返信