J'ai écrit poisson eq. solveur avec la méthode spectrale. Cependant, le résultat obtenu ne coïncide pas avec le résultat de la méthode des différences avec condition aux limites périodiques. Je pense que je me trompe dans l'utilisation de FFTW. Pourriez-vous me dire quelle partie du code suivant contient des erreurs? Merci.poisson éq. avec méthode spectrale
program main
implicit none
include 'fftw3.f'
integer(8) :: plan
integer, parameter :: j_max = 100, k_max = 100, m_max = j_max/2 + 1, n_max = k_max
integer :: j, k, m, n, mm, nn
real(8) :: v(1:j_max, 1:k_max), f(1:j_max, 1:k_max)
real(8) :: x_max, y_max, dx, dy, x, y, t_max, pi
complex(8), parameter :: im = (0.d0, 1.d0)
complex(8) :: vk(1:m_max, 1:n_max), fk(1:m_max, 1:n_max)
pi = 4.d0*atan(1.d0)
x_max = 2.d0*pi
y_max = 2.d0*pi
dx = x_max/j_max
dy = y_max/k_max
!*-- Initial Condition ---
do j = 1, j_max
x = dx*j
do k = 1, k_max
y = dy*k
f(j, k) = dexp(-(x - x_max/2)**2 -(y - y_max/2)**2)
enddo
enddo
!*-- FFT forward ---
call dfftw_plan_dft_r2c_2d(plan, j_max, k_max, v, vk, FFTW_ESTIMATE)
call dfftw_execute(plan)
call dfftw_plan_dft_r2c_2d(plan, j_max, k_max, f, fk, FFTW_ESTIMATE)
call dfftw_execute(plan)
do m = 1, m_max
do n = 1, n_max
if(m <= m_max/2 + 1) then
mm = m - 1
else
mm = m - 1 - m_max
endif
if(n <= n_max/2 + 1) then
nn = n - 1
else
nn = n - 1 - n_max
endif
if(mm == 0 .and. nn == 0) then
else
vk(m, n) = fk(m, n)/(mm**2 + nn**2)
endif
enddo
enddo
!*-- FFT backward ---
call dfftw_plan_dft_c2r_2d(plan, j_max, k_max, vk, v, FFTW_ESTIMATE)
call dfftw_execute(plan)
!*-- normalization ---
v = v/j_max/k_max
call dfftw_destroy_plan(plan)
end program main
Quelle langue cela pourrait-il être? Fortran? –