Skip to content

Commit

Permalink
update transverse read-in wakefield computing so that x and y
Browse files Browse the repository at this point in the history
wakefunction can be different
  • Loading branch information
qianglbl committed Oct 24, 2024
1 parent b6f5d3c commit 09ec276
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 15 deletions.
35 changes: 31 additions & 4 deletions src/Appl/Field.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1572,14 +1572,15 @@ end subroutine wakefield_FieldQuant
!> readin longitudinal and transverse wake functions
!--------------------------------------------------------------------------------------
subroutine wakereadin_FieldQuant(Nz,xwakez,ywakez,recvdensz,exwake,eywake,ezwake,&
hz,leng,ndatawk,wklong,wktran)
hz,leng,ndatawk,wklong,wktranx,wktrany)
implicit none
include 'mpif.h'
integer, intent(in) :: Nz,ndatawk
double precision, intent(in) :: hz, leng
double precision, dimension(Nz,2), intent(in) :: recvdensz
double precision, dimension(Nz), intent(in) :: xwakez,ywakez
double precision, dimension(ndatawk), intent(in) :: wklong,wktran
double precision, dimension(ndatawk), intent(in) :: wklong,wktranx,&
wktrany
double precision, dimension(Nz), intent(out) :: exwake,ezwake,eywake
double precision, dimension(2*Nz,1) :: densz2n,densz2nout,&
greenwake,greenwakeout
Expand Down Expand Up @@ -1666,7 +1667,7 @@ subroutine wakereadin_FieldQuant(Nz,xwakez,ywakez,recvdensz,exwake,eywake,ezwake
scale = 1.
call fftrclocal2_FFT(ksign,scale,densz2n,twonz,one,densz2nout)

!tranverse wakefield
!tranverse wakefield x
do kz = 1, Nz+1
zz = (kz-1)*hz*Scxlt
iz = zz/hzwake + 1
Expand All @@ -1676,7 +1677,7 @@ subroutine wakereadin_FieldQuant(Nz,xwakez,ywakez,recvdensz,exwake,eywake,ezwake
iz1 = ndatawk
endif
zziz = (iz-1)*hzwake
greenwake(kz,1) = wktran(iz)+(wktran(iz1)-wktran(iz))*(zz-zziz)/hzwake
greenwake(kz,1) = wktranx(iz)+(wktranx(iz1)-wktranx(iz))*(zz-zziz)/hzwake
enddo
do kz = Nz+2, 2*Nz
greenwake(kz,1) = greenwake(twonz-kz+2,1)
Expand Down Expand Up @@ -1721,6 +1722,32 @@ subroutine wakereadin_FieldQuant(Nz,xwakez,ywakez,recvdensz,exwake,eywake,ezwake
ksign = 1
scale = 1.
call fftrclocal2_FFT(ksign,scale,densz2n,twonz,one,densz2nout)


!tranverse wakefield y
do kz = 1, Nz+1
zz = (kz-1)*hz*Scxlt
iz = zz/hzwake + 1
iz1 = iz + 1
if(iz1.gt.ndatawk) then
iz = ndatawk - 1
iz1 = ndatawk
endif
zziz = (iz-1)*hzwake
greenwake(kz,1) = wktrany(iz)+(wktrany(iz1)-wktrany(iz))*(zz-zziz)/hzwake
enddo
do kz = Nz+2, 2*Nz
greenwake(kz,1) = greenwake(twonz-kz+2,1)
enddo
do kz = 1, Nz
greenwake(kz,1) = 0.0
enddo

ksign = 1
scale = 1.
call fftrclocal2_FFT(ksign,scale,greenwake,twonz,one,&
greenwakeout)


do kz = 1, 2
greenwake(kz,1) = densz2nout(kz,1)*greenwakeout(kz,1)
Expand Down
30 changes: 19 additions & 11 deletions src/Contrl/AccSimulator.f90
Original file line number Diff line number Diff line change
Expand Up @@ -704,8 +704,8 @@ subroutine run_AccSimulator()
integer :: ldsg,nlsg,nrsg,npsg,msg,ncoefreal,iz
!//for readin wake function
integer :: ndatawk,ndatawkmax,itmp
real*8, allocatable, dimension(:,:) :: wklong2d,wktran2d
real*8, allocatable, dimension(:) :: wklong,wktran
real*8, allocatable, dimension(:,:) :: wklong2d,wktran2dx,wktran2dy
real*8, allocatable, dimension(:) :: wklong,wktranx,wktrany
integer :: flagstep,flagspc,itspc
double precision, dimension(101) :: tspcstart,vspc
real*8, dimension(3) :: tmpfld
Expand Down Expand Up @@ -838,13 +838,17 @@ subroutine run_AccSimulator()
allocate(eywake(Nz))
allocate(ezwake(Nz))
allocate(wklong2d(ndatawkmax,100))
allocate(wktran2d(ndatawkmax,100))
allocate(wktran(ndatawkmax))
allocate(wktran2dx(ndatawkmax,100))
allocate(wktran2dy(ndatawkmax,100))
allocate(wktranx(ndatawkmax))
allocate(wktrany(ndatawkmax))
allocate(wklong(ndatawkmax))
wklong2d = 0.0
wklong = 0.0
wktran2d = 0.0
wktran = 0.0
wktran2dx = 0.0
wktran2dy = 0.0
wktranx = 0.0
wktrany = 0.0
exwake = 0.0
eywake = 0.0
ezwake = 0.0
Expand Down Expand Up @@ -980,7 +984,8 @@ subroutine run_AccSimulator()
!count the number of data points in wake function
aawk(nwk) = 0.0
do itmp = 1, ndatawkmax
read(bmpstp,*,end=111)wklong2d(itmp,nwk),wktran2d(itmp,nwk)
read(bmpstp,*,end=111)wklong2d(itmp,nwk),wktran2dx(itmp,nwk),&
wktran2dy(itmp,nwk)
aawk(nwk) = aawk(nwk) + 1
enddo
111 continue
Expand Down Expand Up @@ -1340,7 +1345,8 @@ subroutine run_AccSimulator()
if(ggwk1.le.0.0) then
ndatawk = aawk(iwk) + 0.1
wklong(:) = wklong2d(:,iwk)
wktran(:) = wktran2d(:,iwk)
wktranx(:) = wktran2dx(:,iwk)
wktrany(:) = wktran2dy(:,iwk)
endif
exit
else
Expand Down Expand Up @@ -1975,7 +1981,7 @@ subroutine run_AccSimulator()
hzwake,aawk1,ggwk1,lengwk1,flagbtw)
else
call wakereadin_FieldQuant(Nz,xwakez,ywakez,recvdensz,exwake,eywake,ezwake,&
hzwake,lengwk1,ndatawk,wklong,wktran)
hzwake,lengwk1,ndatawk,wklong,wktranx,wktrany)
endif

endif
Expand Down Expand Up @@ -2666,8 +2672,10 @@ subroutine run_AccSimulator()
deallocate(ywakelc)
deallocate(ywakez)
deallocate(wklong2d)
deallocate(wktran2d)
deallocate(wktran)
deallocate(wktran2dx)
deallocate(wktran2dy)
deallocate(wktranx)
deallocate(wktrany)
deallocate(wklong)

!!! DWA
Expand Down

0 comments on commit 09ec276

Please sign in to comment.