Skip to content

Commit

Permalink
run fprettify and JuliaFormatter
Browse files Browse the repository at this point in the history
  • Loading branch information
pnavaro committed Mar 25, 2024
1 parent 294d26a commit a38db33
Show file tree
Hide file tree
Showing 13 changed files with 695 additions and 727 deletions.
79 changes: 39 additions & 40 deletions commun.F90
Original file line number Diff line number Diff line change
@@ -1,60 +1,59 @@
module commun

type mesh_fields
real(8), dimension(:,:), pointer :: ex, ey
real(8), dimension(:,:), pointer :: bz
end type mesh_fields
type mesh_fields
real(8), dimension(:, :), pointer :: ex, ey
real(8), dimension(:, :), pointer :: bz
end type mesh_fields

real(8) :: c, csq
real(8) :: pi
real(8) :: c, csq
real(8) :: pi

integer :: md, nd
integer :: nx, ny
integer :: nstep, nstepmax
integer :: idiag
integer :: md, nd
integer :: nx, ny
integer :: nstep, nstepmax
integer :: idiag

integer, private :: i, j
integer, private :: i, j

real(8) :: dt, dx, dy
real(8) :: dimx, dimy
real(8) :: cfl
real(8) :: tfinal
real(8) :: omega
real(8) :: dt, dx, dy
real(8) :: dimx, dimy
real(8) :: cfl
real(8) :: tfinal
real(8) :: omega

contains

subroutine readin( )
subroutine readin()

implicit none
implicit none

namelist/donnees/ cfl, & !nbre de Courant
tfinal, & !duree maxi
nstepmax, & !nbre d'iterations maxi
idiag, & !frequence des diagnostics
md,nd, & !nombre d'onde de la solution initiale
nx, ny, & !nombre de points dans les deux directions
dimx, dimy !dimensions du domaine
namelist /donnees/ cfl, & !nbre de Courant
tfinal, & !duree maxi
nstepmax, & !nbre d'iterations maxi
idiag, & !frequence des diagnostics
md, nd, & !nombre d'onde de la solution initiale
nx, ny, & !nombre de points dans les deux directions
dimx, dimy !dimensions du domaine

!***Initialisation des valeurs pas default

pi = 4.*atan(1.)
pi = 4.*atan(1.)

c = 1d0 !celerite de la lumiere
csq = c * c
c = 1d0 !celerite de la lumiere
csq = c*c

open(10,file="input_data",status='old')
read(10,donnees)
close(10)
open (10, file="input_data", status='old')
read (10, donnees)
close (10)

write(*,"(a,g12.3)")" largeur dimx = ", dimx
write(*,"(a,g12.3)")" longueur dimy = ", dimy
write(*,"(a,g12.3)")" temps = ", tfinal
write(*,"(a,g12.3)")" nombre nx = ", nx
write(*,"(a,g12.3)")" nombre ny = ", ny
write(*,"(a,g12.3)")" nombre de Courant = ", cfl
write(*,"(a,g12.3)")" frequence des diagnostics = ", idiag
write (*, "(a,g12.3)") " largeur dimx = ", dimx
write (*, "(a,g12.3)") " longueur dimy = ", dimy
write (*, "(a,g12.3)") " temps = ", tfinal
write (*, "(a,g12.3)") " nombre nx = ", nx
write (*, "(a,g12.3)") " nombre ny = ", ny
write (*, "(a,g12.3)") " nombre de Courant = ", cfl
write (*, "(a,g12.3)") " frequence des diagnostics = ", idiag


end subroutine readin
end subroutine readin

end module commun
48 changes: 24 additions & 24 deletions fdtd.jl
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
function faraday!( fields, ix, jx, iy, jy, dt )
function faraday!(fields, ix, jx, iy, jy, dt)

dx, dy = fields.mesh.dx, fields.mesh.dy

for j=iy:jy, i=ix:jx
dex_dy = (fields.ex[i,j+1]-fields.ex[i,j]) / dy
dey_dx = (fields.ey[i+1,j]-fields.ey[i,j]) / dx
fields.bz[i,j] = fields.bz[i,j] + dt * (dex_dy - dey_dx)
for j = iy:jy, i = ix:jx
dex_dy = (fields.ex[i, j+1] - fields.ex[i, j]) / dy
dey_dx = (fields.ey[i+1, j] - fields.ey[i, j]) / dx
fields.bz[i, j] = fields.bz[i, j] + dt * (dex_dy - dey_dx)
end

end

function ampere_maxwell!( fields, ix, jx, iy, jy, dt )
function ampere_maxwell!(fields, ix, jx, iy, jy, dt)

dx, dy = fields.mesh.dx, fields.mesh.dy

for j=iy+1:jy, i=ix:jx
dbz_dy = (fields.bz[i,j]-fields.bz[i,j-1]) / dy
fields.ex[i,j] = fields.ex[i,j] + dt*csq*dbz_dy
for j = iy+1:jy, i = ix:jx
dbz_dy = (fields.bz[i, j] - fields.bz[i, j-1]) / dy
fields.ex[i, j] = fields.ex[i, j] + dt * csq * dbz_dy
end

for j=iy:jy, i=ix+1:jx
dbz_dx = (fields.bz[i,j]-fields.bz[i-1,j]) / dx
fields.ey[i,j] = fields.ey[i,j] - dt*csq*dbz_dx
for j = iy:jy, i = ix+1:jx
dbz_dx = (fields.bz[i, j] - fields.bz[i-1, j]) / dx
fields.ey[i, j] = fields.ey[i, j] - dt * csq * dbz_dx
end

end
end

function periodic_bc!(fields, ix, jx, iy, jy, dt)

for i = ix:jx
dbz_dy = (fields.bz[i,iy]-fields.bz[i,jy]) / fields.mesh.dy
fields.ex[i,iy] = fields.ex[i,iy] + dt*csq*dbz_dy
fields.ex[i,jy+1] = fields.ex[i,iy]
end
dbz_dy = (fields.bz[i, iy] - fields.bz[i, jy]) / fields.mesh.dy
fields.ex[i, iy] = fields.ex[i, iy] + dt * csq * dbz_dy
fields.ex[i, jy+1] = fields.ex[i, iy]
end

for j = iy:jy
dbz_dx = (fields.bz[ix,j]-fields.bz[jx,j]) / fields.mesh.dx
fields.ey[ix,j] = fields.ey[ix,j] - dt*csq*dbz_dx
fields.ey[jx+1,j] = fields.ey[ix,j]
dbz_dx = (fields.bz[ix, j] - fields.bz[jx, j]) / fields.mesh.dx
fields.ey[ix, j] = fields.ey[ix, j] - dt * csq * dbz_dx
fields.ey[jx+1, j] = fields.ey[ix, j]
end

fields.bz[:,jy+1] .= fields.bz[:,iy]
fields.bz[jx+1,:] .= fields.bz[ix,:]
fields.bz[:, jy+1] .= fields.bz[:, iy]
fields.bz[jx+1, :] .= fields.bz[ix, :]

end
Loading

0 comments on commit a38db33

Please sign in to comment.