|
| 1 | +module solveur_yee |
| 2 | + use commun, only: dp, ilp, mesh_fields, dx, dy, csq, c, dt |
| 3 | + implicit none(external) |
| 4 | + private |
| 5 | + |
| 6 | + interface |
| 7 | + pure module subroutine faraday(tm, ix, jx, iy, jy) |
| 8 | + implicit none(external) |
| 9 | + type(mesh_fields), intent(inout) :: tm |
| 10 | + integer(ilp), intent(in) :: ix, jx, iy, jy |
| 11 | + end subroutine faraday |
| 12 | + pure module subroutine ampere_maxwell(tm, ix, jx, iy, jy) |
| 13 | + implicit none(external) |
| 14 | + type(mesh_fields), intent(inout) :: tm |
| 15 | + integer(ilp), intent(in) :: ix, jx, iy, jy |
| 16 | + end subroutine ampere_maxwell |
| 17 | + pure module subroutine cl_periodiques(tm, ix, jx, iy, jy) |
| 18 | + implicit none(external) |
| 19 | + type(mesh_fields), intent(inout) :: tm |
| 20 | + integer(ilp), intent(in) :: ix, jx, iy, jy |
| 21 | + end subroutine cl_periodiques |
| 22 | + end interface |
| 23 | + public :: faraday, ampere_maxwell, cl_periodiques |
| 24 | + |
| 25 | +contains |
| 26 | + |
| 27 | + module procedure faraday |
| 28 | + integer(ilp) :: i, j |
| 29 | + real(dp) :: dex_dy, dey_dx |
| 30 | + !*** On utilise l'equation de Faraday sur un demi pas |
| 31 | + !*** de temps pour le calcul du champ magnetique Bz |
| 32 | + !*** a l'instant n puis n+1/2 |
| 33 | + !Ex[1:nx,1:ny+1,]*Ey[1:nx+1,1:ny] -> Bz[1:nx,1:ny] |
| 34 | + do concurrent(i=ix:jx, j=iy:jy) local(dex_dy, dey_dx) |
| 35 | + dex_dy = (tm%ex(i, j + 1) - tm%ex(i, j))/dy |
| 36 | + dey_dx = (tm%ey(i + 1, j) - tm%ey(i, j))/dx |
| 37 | + tm%bz(i, j) = tm%bz(i, j) + dt*(dex_dy - dey_dx) |
| 38 | + end do |
| 39 | + end procedure faraday |
| 40 | + |
| 41 | +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 42 | + |
| 43 | + module procedure ampere_maxwell |
| 44 | + integer(ilp) :: i, j |
| 45 | + real(dp) :: dbz_dy, dbz_dx |
| 46 | + !*** Calcul du champ electrique E au temps n+1 |
| 47 | + !*** sur les points internes du maillage |
| 48 | + !*** Ex aux points (i+1/2,j) |
| 49 | + !*** Ey aux points (i,j+1/2) |
| 50 | + do concurrent(i=ix:jx, j=iy + 1:jy) local(dbz_dy) |
| 51 | + dbz_dy = (tm%bz(i, j) - tm%bz(i, j - 1))/dy |
| 52 | + tm%ex(i, j) = tm%ex(i, j) + dt*csq*dbz_dy |
| 53 | + end do |
| 54 | + do concurrent(i=ix + 1:jx, j=iy:jy) local(dbz_dx) |
| 55 | + dbz_dx = (tm%bz(i, j) - tm%bz(i - 1, j))/dx |
| 56 | + tm%ey(i, j) = tm%ey(i, j) - dt*csq*dbz_dx |
| 57 | + end do |
| 58 | + end procedure ampere_maxwell |
| 59 | + |
| 60 | +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 61 | + |
| 62 | + module procedure cl_periodiques |
| 63 | + integer(ilp) :: i, j |
| 64 | + real(dp) :: dbz_dy, dbz_dx |
| 65 | + do concurrent(i=ix:jx) local(dbz_dy) |
| 66 | + dbz_dy = (tm%bz(i, iy) - tm%bz(i, jy))/dy |
| 67 | + tm%ex(i, iy) = tm%ex(i, iy) + dt*csq*dbz_dy |
| 68 | + tm%ex(i, jy + 1) = tm%ex(i, iy) |
| 69 | + end do |
| 70 | + do concurrent(j=iy:jy) local(dbz_dx) |
| 71 | + dbz_dx = (tm%bz(ix, j) - tm%bz(jx, j))/dx |
| 72 | + tm%ey(ix, j) = tm%ey(ix, j) - dt*csq*dbz_dx |
| 73 | + tm%ey(jx + 1, j) = tm%ey(ix, j) |
| 74 | + end do |
| 75 | + end procedure cl_periodiques |
| 76 | + |
| 77 | +end module solveur_yee |
0 commit comments