diff --git a/src/Appl/Quadrupole.f90 b/src/Appl/Quadrupole.f90 index de5780f..9c8effc 100644 --- a/src/Appl/Quadrupole.f90 +++ b/src/Appl/Quadrupole.f90 @@ -2,13 +2,10 @@ ! (c) Copyright, 2017 by the Regents of the University of California. ! Quadrupoleclass: Quadrupole beam line element class ! in Lattice module of APPLICATION layer. -! MODULE : ... Quadrupoleclass -! VERSION : ... 1.0 -!> @author -!> Ji Qiang -! DESCRIPTION: -!> This class defines the linear transfer map and field -!> for the quadrupole beam line elment. +! Version: 1.0 +! Author: Ji Qiang +! Description: This class defines the linear transfer map and field +! for the quadrupole beam line elment. ! Comments: !---------------------------------------------------------------- module Quadrupoleclass @@ -122,10 +119,8 @@ subroutine getparam3_Quadrupole(this,blength,bnseg,bmapstp,& end subroutine getparam3_Quadrupole - !-------------------------------------------------------------------------------------- - !> @brief - !> get external field with displacement and rotation errors. - !-------------------------------------------------------------------------------------- + + !get external field with displacement and rotation errors. subroutine getflderr_Quadrupole(pos,extfld,this,dx,dy,anglex,& angley,anglez) implicit none @@ -176,8 +171,10 @@ subroutine getflderr_Quadrupole(pos,extfld,this,dx,dy,anglex,& ! extfld(5) = bgrad*tmp(1) ! extfld(6) = 0.0 if(this%Param(3).gt.0.0) then - extfld(4) = bgrad*tmp(2) - bgradpp*tmp(2)**3/6 - extfld(5) = bgrad*tmp(1) - bgradpp*tmp(1)*tmp(2)**2/2 + extfld(4) = bgrad*tmp(2) - & + bgradpp*(tmp(2)**3+3*tmp(1)**2*tmp(2))/12 + extfld(5) = bgrad*tmp(1) - & + bgradpp*(tmp(1)**3+3*tmp(1)*tmp(2)**2)/12 extfld(6) = bgradp*tmp(1)*tmp(2) else extfld(4) = bgrad*tmp(2) @@ -205,12 +202,9 @@ subroutine getflderr_Quadrupole(pos,extfld,this,dx,dy,anglex,& endif end subroutine getflderr_Quadrupole - - !-------------------------------------------------------------------------------------- - !> @brief - !> get external field without displacement and rotation errors. - !> here, the skew quad can can be modeled with nonzero anglez - !-------------------------------------------------------------------------------------- + + !get external field without displacement and rotation errors. + !here, the skew quad can can be modeled with nonzero anglez subroutine getfld_Quadrupole(pos,extfld,this) implicit none include 'mpif.h' @@ -243,11 +237,11 @@ subroutine getfld_Quadrupole(pos,extfld,this) extfld(2) = 0.0 extfld(3) = 0.0 if(this%Param(3).gt.0.0) then - !extfld(4) = bgrad*pos(2) - bgradpp*pos(2)**3/6 - !extfld(5) = bgrad*pos(1) - bgradpp*pos(1)*pos(2)**2/2 - !extfld(6) = bgradp*pos(1)*pos(2) - temp(1) = bgrad*tmp(2) - bgradpp*tmp(2)**3/6 - temp(2) = bgrad*tmp(1) - bgradpp*tmp(1)*tmp(2)**2/2 + temp(1) = bgrad*tmp(2) - & + bgradpp*(tmp(2)**3+3*tmp(1)**2*tmp(2))/12 + temp(2) = bgrad*tmp(1) - & + bgradpp*(tmp(1)**3+3*tmp(1)*tmp(2)**2)/12 + temp(3) = bgradp*tmp(1)*tmp(2) else !extfld(4) = bgrad*pos(2) @@ -273,10 +267,7 @@ subroutine getfld_Quadrupole(pos,extfld,this) end subroutine getfld_Quadrupole - !-------------------------------------------------------------------------------------- - !> @brief - !> interpolate the field from the SC rf cavity onto bunch location. - !-------------------------------------------------------------------------------------- + !interpolate the field from the SC rf cavity onto bunch location. subroutine getfldfrg_Quadrupole(zz,this,bgrad) implicit none include 'mpif.h' @@ -380,10 +371,7 @@ subroutine getfldfrgAna2_Quadrupole(zz,this,bgrad,bgradp,bgradpp) end subroutine getfldfrgAna2_Quadrupole - !-------------------------------------------------------------------------------------- - !> @brief - !> get external field with displacement and rotation errors. - !-------------------------------------------------------------------------------------- + !get external field with displacement and rotation errors. subroutine getflderrt_Quadrupole(pos,extfld,this) implicit none include 'mpif.h' @@ -430,8 +418,11 @@ subroutine getflderrt_Quadrupole(pos,extfld,this) ! extfld(5) = bgrad*tmp(1) ! extfld(6) = 0.0 if(this%Param(3).gt.0.0) then - extfld(4) = bgrad*tmp(2) - bgradpp*tmp(2)**3/6 - extfld(5) = bgrad*tmp(1) - bgradpp*tmp(1)*tmp(2)**2/2 + extfld(4) = bgrad*tmp(2) - & + bgradpp*(tmp(2)**3+3*tmp(1)**2*tmp(2))/12 + extfld(5) = bgrad*tmp(1) - & + bgradpp*(tmp(1)**3+3*tmp(1)*tmp(2)**2)/12 + extfld(6) = bgradp*tmp(1)*tmp(2) else extfld(4) = bgrad*tmp(2) diff --git a/src/Contrl/AccSimulator.f90 b/src/Contrl/AccSimulator.f90 index 29b5beb..b2e6b1b 100644 --- a/src/Contrl/AccSimulator.f90 +++ b/src/Contrl/AccSimulator.f90 @@ -18,17 +18,12 @@ !**************************** ! ! AccSimulatorclass: Linear accelerator simulator class in CONTROL layer. -! -! MODULE : ... AccSimulatorclass -! VERSION : ... 2.0 -!> @author -!> Ji Qiang -! -! DESCRIPTION: -!> This class defines functions to set up the initial beam -!> particle distribution, field information, computational -!> domain, beam line element lattice and run the dynamics -!> simulation through the system. +! Version: 2.0 +! Author: Ji Qiang +! Description: This class defines functions to set up the initial beam +! particle distribution, field information, computational +! domain, beam line element lattice and run the dynamics +! simulation through the system. ! Comments: !---------------------------------------------------------------- module AccSimulatorclass @@ -48,83 +43,62 @@ module AccSimulatorclass use Rangerclass use Depositorclass implicit none - !> @name - !! \# of phase dim., num. total and local particles, int. dist. - !! and restart switch, error study switch, substep for space-charge - !! switch, \# of time step - !> @{ + !# of phase dim., num. total and local particles, int. dist. + !and restart switch, error study switch, substep for space-charge + !switch,# of time step integer :: Dim, Flagdist,Rstartflg,Flagerr,& Flagsubstep,ntstep integer, dimension(Nbunchmax) :: Np, Nplocal - !> @} - - !> @name - !! \# of num. total x, total and local y mesh pts., type of BC, - !! \# of beam elems, type of integrator. - !! FlagImage: switch flag for image space-charge force calculation: "1" for yes, - !! otherwise for no. - !> @{ + !# of num. total x, total and local y mesh pts., type of BC, + !# of beam elems, type of integrator. + !FlagImage: switch flag for image space-charge force calculation: "1" for yes, + !otherwise for no. integer :: Nx,Ny,Nz,Nxlocal,Nylocal,Nzlocal,Flagbc,& Nblem,Flagmap,Flagdiag,FlagImage - !> @} - !> @name - !! \# of processors in column and row direction. - !> @{ + !# of processors in column and row direction. integer :: npcol, nprow - !> @} - !> initial \# of bunches/bins - integer :: Nbunch + !initial # of bunches/bins + integer :: Nbunch - !> @name - !! beam current, kin. energy, part. mass, charge, ref. freq., period length, - !! time step size - !> @{ + !beam current, kin. energy, part. mass, charge, ref. freq., period length, + !time step size double precision :: Bcurr,Bkenergy,Bmass,Bcharge,Bfreq,& Perdlen,dt,xrad,yrad - !> @} - !> @name - !! conts. in init. dist. - !> @{ + !conts. in init. dist. integer, parameter :: Ndistparam = 21 double precision, dimension(Ndistparam) :: distparam - !> @} - !> 2d logical processor array - type (Pgrid2d) :: grid2d + !2d logical processor array. + type (Pgrid2d) :: grid2d - !> beam particle object and array. + !beam particle object and array. type (BeamBunch), dimension(Nbunchmax) :: Ebunch - !> beam charge density and field potential arrays. + !beam charge density and field potential arrays. type (FieldQuant) :: Potential - !> geometry object. + !geometry object. type (CompDom) :: Ageom - !> overlaped external field data array + !overlaped external field data array type (fielddata), dimension(Maxoverlap) :: fldmp - !> maximum e- emission time + !maximum e- emission time double precision :: temission - !> number of steps for emission + !number of steps for emission integer :: Nemission - !> distance after that to turn off image space-charge + !distance after that to turn off image space-charge double precision :: zimage - !> @name - !! restart time and step - !> @{ + !restart time and step double precision :: tend,dtlessend integer :: iend,ibchend,nfileout,ioutend,itszend,isteerend,isloutend - !> @} - !> @name - !! beam line element array. - !> @{ + !beam line element array. type (BPM),target,dimension(Nbpmmax) :: beamln0 type (DriftTube),target,dimension(Ndriftmax) :: beamln1 type (Quadrupole),target,dimension(Nquadmax) :: beamln2 @@ -142,16 +116,14 @@ module AccSimulatorclass type (EMfldAna),target,dimension(Ncclmax) :: beamln14 type (Multipole),target,dimension(Nquadmax) :: beamln15 type (BeamLineElem),dimension(Nblemtmax)::Blnelem - !> @} - - !> longitudinal position of each element (min and max). + !longitudinal position of each element (min and max). double precision, dimension(2,Nblemtmax)::zBlnelem - !> beam line element period. + !beam line element period. interface construct_AccSimulator module procedure init_AccSimulator end interface contains - !> set up objects and parameters. + !set up objects and parameters. subroutine init_AccSimulator(time) implicit none include 'mpif.h' @@ -179,7 +151,7 @@ subroutine init_AccSimulator(time) real*8 rancheck integer :: seedsize - ! start up MPI. + !start up MPI. call init_Input(time) ! initialize Timer. @@ -642,7 +614,7 @@ subroutine init_AccSimulator(time) end subroutine init_AccSimulator - !> Run beam dynamics simulation through accelerator. + !Run beam dynamics simulation through accelerator. subroutine run_AccSimulator() implicit none include 'mpif.h' @@ -1082,8 +1054,8 @@ subroutine run_AccSimulator() read(11,*) enddo do ii = 1, 6 - read(11,*)rmt(i,1,imap),rmt(i,2,imap),rmt(i,3,imap),& - rmt(i,4,imap),rmt(i,5,imap),rmt(i,6,imap) + read(11,*)rmt(ii,1,imap),rmt(ii,2,imap),rmt(ii,3,imap),& + rmt(ii,4,imap),rmt(ii,5,imap),rmt(ii,6,imap) enddo close(11) endif @@ -1237,32 +1209,36 @@ subroutine run_AccSimulator() if(distance.le.tmap(imap+1) .and. (distance+dzz).ge.tmap(imap+1)) then imap = imap + 1 do ib = 1, Nbunch - !//find the range and center information of each bunch/bin + + !//find the range and center information of each bunch/bin + call singlerange(Ebunch(ib)%Pts1,Nplocal(ib),Np(ib),& + ptrange,sgcenter) + do ipt = 1, Nplocal(ib) - tmpx = Ebunch(ib)%Pts1(1,ipt) - tmppx = Ebunch(ib)%Pts1(2,ipt) - tmpy = Ebunch(ib)%Pts1(3,ipt) - tmppy = Ebunch(ib)%Pts1(4,ipt) - tmpz = Ebunch(ib)%Pts1(5,ipt) - tmppz = Ebunch(ib)%Pts1(6,ipt) + tmpx = Ebunch(ib)%Pts1(1,ipt) - sgcenter(1) + tmppx = Ebunch(ib)%Pts1(2,ipt) - sgcenter(2) + tmpy = Ebunch(ib)%Pts1(3,ipt) - sgcenter(3) + tmppy = Ebunch(ib)%Pts1(4,ipt) - sgcenter(4) + tmpz = Ebunch(ib)%Pts1(5,ipt) - sgcenter(5) + tmppz = Ebunch(ib)%Pts1(6,ipt) - sgcenter(6) Ebunch(ib)%Pts1(1,ipt)=tmpx*rmt(1,1,imap)+tmppx*rmt(1,2,imap)+& tmpy*rmt(1,3,imap)+tmppy*rmt(1,4,imap)+& - tmpz*rmt(1,5,imap)+tmppz*rmt(1,6,imap) + tmpz*rmt(1,5,imap)+tmppz*rmt(1,6,imap)+ sgcenter(1) Ebunch(ib)%Pts1(2,ipt)=tmpx*rmt(2,1,imap)+tmppx*rmt(2,2,imap)+& tmpy*rmt(2,3,imap)+tmppy*rmt(2,4,imap)+& - tmpz*rmt(2,5,imap)+tmppz*rmt(2,6,imap) + tmpz*rmt(2,5,imap)+tmppz*rmt(2,6,imap)+ sgcenter(2) Ebunch(ib)%Pts1(3,ipt)=tmpx*rmt(3,1,imap)+tmppx*rmt(3,2,imap)+& tmpy*rmt(3,3,imap)+tmppy*rmt(3,4,imap)+& - tmpz*rmt(3,5,imap)+tmppz*rmt(3,6,imap) + tmpz*rmt(3,5,imap)+tmppz*rmt(3,6,imap)+ sgcenter(3) Ebunch(ib)%Pts1(4,ipt)=tmpx*rmt(4,1,imap)+tmppx*rmt(4,2,imap)+& tmpy*rmt(4,3,imap)+tmppy*rmt(4,4,imap)+& - tmpz*rmt(4,5,imap)+tmppz*rmt(4,6,imap) + tmpz*rmt(4,5,imap)+tmppz*rmt(4,6,imap)+ sgcenter(4) Ebunch(ib)%Pts1(5,ipt)=tmpx*rmt(5,1,imap)+tmppx*rmt(5,2,imap)+& tmpy*rmt(5,3,imap)+tmppy*rmt(5,4,imap)+& - tmpz*rmt(5,5,imap)+tmppz*rmt(5,6,imap) + tmpz*rmt(5,5,imap)+tmppz*rmt(5,6,imap)+ sgcenter(5) Ebunch(ib)%Pts1(6,ipt)=tmpx*rmt(6,1,imap)+tmppx*rmt(6,2,imap)+& tmpy*rmt(6,3,imap)+tmppy*rmt(6,4,imap)+& - tmpz*rmt(6,5,imap)+tmppz*rmt(6,6,imap) + tmpz*rmt(6,5,imap)+tmppz*rmt(6,6,imap)+ sgcenter(6) enddo enddo endif diff --git a/src/DataStruct/Data.f90 b/src/DataStruct/Data.f90 index b561e20..74e83bc 100644 --- a/src/DataStruct/Data.f90 +++ b/src/DataStruct/Data.f90 @@ -1,18 +1,13 @@ !---------------------------------------------------------------- ! (c) Copyright, 2017 by the Regents of the University of California. ! Dataclass: Field data class in DATA STRUCTURE layer. -! -! MODULE : ... Dataclass -! VERSION : ... 1.0 -!> @author -!> Ji Qiang -! -! DESCRIPTION: -!> This class stores the rf cavity data Ez, Ez', Ez'' on the -!> axis; Fourier coefficients of Ez on the axis; Ez(r,z), -!> Er(r,z), Htheta(r,z) on the r-z grid plane; and Ex(x,y,z), -!> Ey(x,y,z), Ez(x,y,z), Bx(x,y,z), By(x,y,z), Bz(x,y,z) on -!> uniform x, y, z grid, and Br(r,z) and Bz(r,z) on the r-z grid. +! Version: 1.0 +! Author: Ji Qiang +! Description: This class stores the rf cavity data Ez, Ez', Ez'' on the +! axis; Fourier coefficients of Ez on the axis; Ez(r,z), +! Er(r,z), Htheta(r,z) on the r-z grid plane; and Ex(x,y,z), +! Ey(x,y,z), Ez(x,y,z), Bx(x,y,z), By(x,y,z), Bz(x,y,z) on +! uniform x, y, z grid, and Br(r,z) and Bz(r,z) on the r-z grid. ! Comments: !---------------------------------------------------------------- module Dataclass @@ -20,95 +15,45 @@ module Dataclass use mpistub ! save !----------------------------------------------------------------------- -!> @name - -!> @{ -!> using the x-y-z field data (Ex,Ey,Ez,Bx,By,Bz) directly. - !> @name - - !> @{ - !> number of grid points along x, y, and z direction. +! using the x-y-z field data (Ex,Ey,Ez,Bx,By,Bz) directly. + !number of grid points along x, y, and z direction. integer :: NxIntvRfg = 1 integer :: NyIntvRfg = 1 integer :: NzIntvRfg = 1 - !> @} - !> @name - - !> @{ - !> range in x, y, and zdirections. + !range in x, y, and zdirections. double precision :: XmaxRfg,XminRfg,YmaxRfg,YminRfg,ZmaxRfg,ZminRfg - !> @} - !> @name - - !> @{ - !> discrete Ex(x,y,z), Ey(x,y,z), Ez(x,y,z) and Bx(x,y,z), By(x,y,z), and - !> Bz(x,y,z) rf data. Here, the grid is uniform in x, y and z. + ! discrete Ex(x,y,z), Ey(x,y,z), Ez(x,y,z) and Bx(x,y,z), By(x,y,z), and + ! Bz(x,y,z) rf data. Here, the grid is uniform in x, y and z. double precision,allocatable,dimension(:,:,:) :: & Exgrid,Eygrid,Ezgrid,Bxgrid,Bygrid,Bzgrid - !> @} -!> @} !----------------------------------------------------------------------- -!> @name -!> @{ -!> using the r-z field data (Er,Ez,Htheta) directly. - !> @name - - !> @{ - !> number of grid points along r direction. +! using the r-z field data (Er,Ez,Htheta) directly. + !number of grid points along r direction. integer :: NrIntvRf = 1 - !> number of grid points along z direction. + !number of grid points along z direction. integer :: NzIntvRf = 1 - !> @} - !> @name - - !> @{ - !> range in r and z directions. + !range in r and z directions. double precision :: RmaxRf,RminRf,ZmaxRf,ZminRf - !> @} - !> @name - - !> @{ - !> discrete Ez(r,z), Er(r,z) and Htheta(r,z) rf data. Here, the grid - !> is uniform in r and z. + ! discrete Ez(r,z), Er(r,z) and Htheta(r,z) rf data. Here, the grid + ! is uniform in r and z. double precision,allocatable,dimension(:,:) :: & ezdata,erdata,btdata - !> @} -!> @} !----------------------------------------------------------------------- -!> @name -!> @{ -!> using only on-axis field data and its derivities. - !> @name - - !> @{ - !> initial number of grid points on the axis. +! using only on-axis field data and its derivities. + !initial number of grid points on the axis. integer, parameter :: Ndataini = 5000 - !> @} - !> @name - - !> @{ - !> discrete Ez(0,z), Ez'(0,z), Ez''(0,z) rf data. + ! discrete Ez(0,z), Ez'(0,z), Ez''(0,z) rf data. double precision,dimension(Ndataini) :: zdat,edat,epdat,eppdat - !> @} -!> @} !---------------------------------------------------------------------- -!> @name -!> @{ -!> using the Fourier coefficients +! using the Fourier coefficients + !number of Fourier expansion coefficients. integer, parameter :: NcoefF = 401 - double precision,dimension(NcoefF) :: Fcoef - !> @name - - !> @{ - !> number of Fourier expansion coefficients. - !> @} - + double precision,dimension(NcoefF) :: Fcoef !Fcoef(1): constant !Fcoef(2k): cosine term !Fcoef(2k+1): sine term -!> @} !---------------------------------------------------------------------- - !> practical number of grid data on the axis or Fourier coefficients. + ! practical number of grid data on the axis or Fourier coefficients. integer :: Ndata !------------------------------------------------------------------------ ! @@ -116,78 +61,54 @@ module Dataclass type fielddata ! using the x-y-z field data (Ex,Ey,Ez,Bx,By,Bz) !directly for beam line element i. - !> @name - - !> @{ - !> number of grid points along x, y, and z direction. + !number of grid points along x, y, and z direction. integer :: NxIntvRfgt integer :: NyIntvRfgt integer :: NzIntvRfgt - !> @} - !> @name - - !> @{ - !> range in x, y, and zdirections. + !range in x, y, and zdirections. double precision :: XmaxRfgt,XminRfgt,& YmaxRfgt,YminRfgt,ZmaxRfgt,ZminRfgt - !> @} - !> @name - - !> @{ - !> discrete Ex(x,y,z,i), Ey(x,y,z,i), Ez(x,y,z,i) and Bx(x,y,z,i), - !> By(x,y,z,i), and - !> Bz(x,y,z,i) rf data. Here, the grid is uniform in x, y and z. + ! discrete Ex(x,y,z,i), Ey(x,y,z,i), Ez(x,y,z,i) and Bx(x,y,z,i), + ! By(x,y,z,i), and + ! Bz(x,y,z,i) rf data. Here, the grid is uniform in x, y and z. double complex,pointer,dimension(:,:,:) :: & Exgridt,Eygridt,Ezgridt,Bxgridt,Bygridt,Bzgridt - !> @} ! using the r-z field data (Er,Ez,Htheta) directly. - !> number of grid points along r direction. + !number of grid points along r direction. integer :: NrIntvRft - !> number of grid points along z direction. + !number of grid points along z direction. integer :: NzIntvRft - !> @name - - !> @{ - !> range in r and z directions. + !range in r and z directions. double precision :: RmaxRft,RminRft,& ZmaxRft,ZminRft - !> @} - !> @name - - !> @{ - !> discrete Ezt(r,z,i), Ert(r,z,i) and - !> Btheta(r,z,i) rf data. Here, the grid - !> is uniform in r and z. + ! discrete Ezt(r,z,i), Ert(r,z,i) and + ! Btheta(r,z,i) rf data. Here, the grid + ! is uniform in r and z. double precision,pointer,dimension(:,:) :: & ezdatat,erdatat,btdatat,brdatat,bzdatat - !> @} ! using the analytical function for field data ! (Ex,Ey,Ez,Bx,By,Bz) for beam line element i directly. - !> number of coefficients in Ex. + !number of coefficients in Ex. integer :: Ncex - !> number of coefficients in Ey. + !number of coefficients in Ey. integer :: Ncey - !> number of coefficients in Ez. + !number of coefficients in Ez. integer :: Ncez - !> number of coefficients in Bx. + !number of coefficients in Bx. integer :: Ncbx - !> number of coefficients in By. + !number of coefficients in By. integer :: Ncby - !> number of coefficients in Bz. + !number of coefficients in Bz. integer :: Ncbz - !> @name - - !> @{ - !> coefficients for analytical function description of the rf data. + !coefficients for analytical function description of the rf data. double precision,pointer,dimension(:) :: & coefex,coefey,coefez,coefbx,coefby,coefbz - !> @} ! using the Fourier coefficients !integer, parameter :: NcoefFt = 401 - !> practical number of grid data on the axis or Fourier coefficients. + ! practical number of grid data on the axis or Fourier coefficients. double precision,dimension(401) :: Fcoeft !store the discrete data of ez,ez',ez'',ez''' on axis. - !> here, maximum data point is 5000 for E field or B field. + !here, maximum data point is 5000 for E field or B field. double precision,dimension(4,10002) :: Fcoeftdata integer :: Ndatat end type fielddata @@ -196,7 +117,7 @@ module Dataclass !------------------------------------------------------------------------- ! the following are used to store the field data in position z domain, i.e. ! used by Impact-Z code. - !> Initialize the data storage arrays. + !Initialize the data storage arrays. subroutine init_Data() implicit none include 'mpif.h' @@ -270,9 +191,9 @@ subroutine destruct_Data() end subroutine destruct_Data - !> read in the discrete field data Ez(0,z), Ez'(0,z), Ez''(0,z) - !> distribution along axis zdat from files "rfdatax or rfdataxx - !> or rfdataxxx". + !read in the discrete field data Ez(0,z), Ez'(0,z), Ez''(0,z) + !distribution along axis zdat from files "rfdatax or rfdataxx + !or rfdataxxx". subroutine read1_Data(ifile) implicit none include 'mpif.h' @@ -351,9 +272,9 @@ subroutine read1_Data(ifile) !print*,"Ndata: ",Ndata end subroutine read1_Data - !> read in discrete Ez(r,z), Er(r,z) and Btheta(r,z) rf data from - !> files "1Tx.T7 or 1Txx.T7 or 1Txxx.T7. Here, the grid - !> is uniform in r and z. + ! read in discrete Ez(r,z), Er(r,z) and Btheta(r,z) rf data from + ! files "1Tx.T7 or 1Txx.T7 or 1Txxx.T7. Here, the grid + ! is uniform in r and z. subroutine read2_Data(ifile) implicit none include 'mpif.h' @@ -480,8 +401,8 @@ subroutine read2_Data(ifile) !print*,"Ndata: ",Ndatalc end subroutine read2_Data - !> readin the Fourier coefficients of the RF field from files - !> "rfdatax or rfdataxx or rfdataxxx". + !readin the Fourier coefficients of the RF field from files + !"rfdatax or rfdataxx or rfdataxxx". subroutine read3_Data(ifile) implicit none include 'mpif.h' @@ -545,10 +466,10 @@ subroutine read3_Data(ifile) !print*,"Ndata: ",Ndata end subroutine read3_Data - !> read in discrete Ex(x,y,z), Ey(x,y,z), Ez(x,y,z), Bx(x,y,z), By(x,y,z), - !> Bz(x,y,z) rf data from - !> files "1Tx.T7 or 1Txx.T7 or 1Txxx.T7. Here, the grid - !> is uniform in x, y and z. + ! read in discrete Ex(x,y,z), Ey(x,y,z), Ez(x,y,z), Bx(x,y,z), By(x,y,z), + ! Bz(x,y,z) rf data from + ! files "1Tx.T7 or 1Txx.T7 or 1Txxx.T7. Here, the grid + ! is uniform in x, y and z. subroutine read4_Data(ifile) implicit none include 'mpif.h' @@ -797,8 +718,8 @@ subroutine destructt_Data(this) end subroutine destructt_Data - !> readin the Fourier coefficients of the RF field from files - !> "rfdatax or rfdataxx or rfdataxxx". + !readin the Fourier coefficients of the RF field from files + !"rfdatax or rfdataxx or rfdataxxx". subroutine read1t_Data(this,ifile) implicit none include 'mpif.h' @@ -864,8 +785,8 @@ subroutine read1t_Data(this,ifile) print*,"Ndata: ",this%Ndatat end subroutine read1t_Data - !> readin the Fourier coefficients of the RF field from files - !> "rfdatax or rfdataxx or rfdataxxx". + !readin the Fourier coefficients of the RF field from files + !"rfdatax or rfdataxx or rfdataxxx". subroutine read1tdata_Data(this,ifile) implicit none include 'mpif.h' @@ -952,9 +873,11 @@ subroutine read1tdata_Data(this,ifile) print*,"Ndata: ",this%Ndatat end subroutine read1tdata_Data - !> read in discrete Ez(r,z), Er(r,z) and Btheta(r,z) rf data from - !> files "1Tx.T7 or 1Txx.T7 or 1Txxx.T7. Here, the grid - !> is uniform in r and z. + !J.Q. changed the format of inputs (7/28/2020) to the new + !Superfilsh RF cavity output. + ! read in discrete Ez(r,z), Er(r,z) and Btheta(r,z) rf data from + ! files "1Tx.T7 or 1Txx.T7 or 1Txxx.T7. Here, the grid + ! is uniform in r and z. subroutine read2t_Data(this,ifile) implicit none include 'mpif.h' @@ -971,6 +894,140 @@ subroutine read2t_Data(this,ifile) name2 = '1Txx.T7' name3 = '1Txxx.T7' + mu0 = 4*2*asin(1.0d0)*1.0d-7 + + !call MPI_BARRIER(MPI_COMM_WORLD,ierr) + call MPI_COMM_RANK(MPI_COMM_WORLD,myrank,ierr) + + !print*,"into read: " + if(myrank.eq.0) then + if((ifile.ge.1).and.(ifile.le.9)) then + name1(3:3) = char(ifile+48) + open(14,file=name1,status='old') + open(15,file=name1//"out",status='unknown') + else if((ifile.ge.10).and.(ifile.le.99)) then + ii = ifile/10 + jj = ifile - ii*10 + name2(3:3) = char(ii+48) + name2(4:4) = char(jj+48) + open(14,file=name2,status='old') +! open(15,file=name2//"out",status='unknown') + else if((ifile.ge.100).and.(ifile.le.999)) then + ii = ifile/100 + jj = ifile - 100*ii + kk = jj/10 + ll = jj - 10*kk + name3(3:3) = char(ii+48) + name3(4:4) = char(kk+48) + name3(5:5) = char(ll+48) + open(14,file=name3,status='old') +! open(15,file=name3//"out",status='unknown') + else + print*,"out of the range of maximum 999 files!!!!" + endif + + ! the input range units are cm + read(14,*,end=33)tmp1,tmp2,tmpint + this%ZminRft = tmp1/100.0 + this%ZmaxRft = tmp2/100.0 + this%NzIntvRft = tmpint + if(tmpint.ne.this%NzIntvRft) then + print*,"input data wrong in Z: ",this%NzIntvRft,tmpint + stop + endif + ! the input range units are cm + read(14,*,end=33)tmp1 + read(14,*,end=33)tmp1,tmp2,tmpint + this%RminRft = tmp1/100.0 + this%RmaxRft = tmp2/100.0 + this%NrIntvRft = tmpint + if(tmpint.ne.this%NrIntvRft) then + print*,"input data wrong in R: ",this%NrIntvRft,tmpint + stop + endif + !print*,"Nz: ",NzIntvRft(ib),ZminRft(ib),ZmaxRft(ib) + !print*,"Nr: ",NrIntvRft(ib),RminRft(ib),RmaxRft(ib) + endif +33 continue + call MPI_BCAST(this%NrIntvRft,1,MPI_INTEGER,0,MPI_COMM_WORLD,ierr) + call MPI_BCAST(this%NzIntvRft,1,MPI_INTEGER,0,MPI_COMM_WORLD,ierr) + + deallocate(this%ezdatat) + deallocate(this%erdatat) + deallocate(this%btdatat) + allocate(this%ezdatat(this%NzIntvRft+1,this%NrIntvRft+1)) + allocate(this%erdatat(this%NzIntvRft+1,this%NrIntvRft+1)) + allocate(this%btdatat(this%NzIntvRft+1,this%NrIntvRft+1)) + + if(myrank.eq.0) then + tmpmax = -1.0e10 + n = 1 +50 continue + read(14,*,end=77)tmp1,tmp2,tmp3,tmp4 + j = (n-1)/(this%NzIntvRft+1) + 1 + i = mod((n-1),this%NzIntvRft+1) + 1 + this%ezdatat(i,j) = tmp1*1.0e6 + this%erdatat(i,j) = tmp2*1.0e6 + !convert from H (A/m) to Tesla + this%btdatat(i,j) = tmp4*mu0 + n = n + 1 + write(15,100)float(i-1),this%ezdatat(i,j),this%erdatat(i,j) + goto 50 +77 continue + close(14) + close(15) + Ndatalc = n - 1 + !print*,"Ndata in 0: ",Ndatalc + do i = 1, this%NzIntvRft+1 + !find the max. of e field on axis + tmp3 = sqrt(this%ezdatat(i,1)**2+this%erdatat(i,1)**2) + if(tmpmax.lt.abs(tmp3)) tmpmax = abs(tmp3) + enddo + print*,"maximum E field on axis: ",tmpmax + endif +100 format(3(1x,1pe15.8)) + + call MPI_BCAST(Ndatalc,1,MPI_INTEGER,0,& + MPI_COMM_WORLD,ierr) + call MPI_BCAST(this%ZminRft,1,MPI_DOUBLE_PRECISION,0,& + MPI_COMM_WORLD,ierr) + call MPI_BCAST(this%ZmaxRft,1,MPI_DOUBLE_PRECISION,0,& + MPI_COMM_WORLD,ierr) + call MPI_BCAST(this%RminRft,1,MPI_DOUBLE_PRECISION,0,& + MPI_COMM_WORLD,ierr) + call MPI_BCAST(this%RmaxRft,1,MPI_DOUBLE_PRECISION,0,& + MPI_COMM_WORLD,ierr) + call MPI_BCAST(this%ezdatat(1,1),Ndatalc,MPI_DOUBLE_PRECISION,0,& + MPI_COMM_WORLD,ierr) + call MPI_BCAST(this%erdatat(1,1),Ndatalc,MPI_DOUBLE_PRECISION,0,& + MPI_COMM_WORLD,ierr) + call MPI_BCAST(this%btdatat(1,1),Ndatalc,MPI_DOUBLE_PRECISION,0,& + MPI_COMM_WORLD,ierr) + + call MPI_BARRIER(MPI_COMM_WORLD,ierr) + + !print*,"Ndata: ",Ndatalc + end subroutine read2t_Data + + ! read in discrete Ez(r,z), Er(r,z) and Btheta(r,z) rf data from + ! files "1Tx.T7 or 1Txx.T7 or 1Txxx.T7. Here, the grid + ! is uniform in r and z. + subroutine read2told_Data(this,ifile) + implicit none + include 'mpif.h' + integer, intent(in) :: ifile + type (fielddata), intent(inout) :: this + integer :: myrank,ierr,i,ii,jj,kk,ll,n,nn,Ndatalc,j,tmpint + double precision :: tmp1,tmp2,tmp3,tmp4,zdat1,mu0 + character*6 name1 + character*7 name2 + character*8 name3 + double precision :: tmpmax + + name1 = '1Tx.T7' + name2 = '1Txx.T7' + name3 = '1Txxx.T7' + mu0 = 4*2*asin(1.0)*1.0e-7 !call MPI_BARRIER(MPI_COMM_WORLD,ierr) @@ -1093,12 +1150,12 @@ subroutine read2t_Data(this,ifile) call MPI_BARRIER(MPI_COMM_WORLD,ierr) !print*,"Ndata: ",Ndatalc - end subroutine read2t_Data + end subroutine read2told_Data - !> read in analytical function coefficients of - !> Ex(x,y,z), Ey(x,y,z), Ez(x,y,z), Bx(x,y,z), By(x,y,z), - !> Bz(x,y,z) rf data from - !> "rfdatax or rfdataxx or rfdataxxx". + ! read in analytical function coefficients of + ! Ex(x,y,z), Ey(x,y,z), Ez(x,y,z), Bx(x,y,z), By(x,y,z), + ! Bz(x,y,z) rf data from + !"rfdatax or rfdataxx or rfdataxxx". subroutine read4t_Data(this,ifile) implicit none include 'mpif.h' @@ -1202,9 +1259,9 @@ subroutine read4t_Data(this,ifile) print*,"Ndata: ",this%Ndatat end subroutine read4t_Data - !> read in discrete Bz(r,z), Br(r,z) data from - !> files "1Tx.T7 or 1Txx.T7 or 1Txxx.T7 for solenoid. Here, the grid - !> is uniform in r and z. + ! read in discrete Bz(r,z), Br(r,z) data from + ! files "1Tx.T7 or 1Txx.T7 or 1Txxx.T7 for solenoid. Here, the grid + ! is uniform in r and z. subroutine read2tsol_Data(this,ifile) implicit none include 'mpif.h' @@ -1329,11 +1386,11 @@ subroutine read2tsol_Data(this,ifile) !print*,"Ndata: ",Ndatalc end subroutine read2tsol_Data - !> read in discrete complex Ex(x,y,z), Ey(x,y,z), Ez(x,y,z), Bx(x,y,z), By(x,y,z), - !> Bz(x,y,z) rf data from - !> files "1Tx.T7 or 1Txx.T7 or 1Txxx.T7. Here, the grid - !> is uniform in x, y and z. - !> This field can be used to model the traveling wave structure + ! read in discrete complex Ex(x,y,z), Ey(x,y,z), Ez(x,y,z), Bx(x,y,z), By(x,y,z), + ! Bz(x,y,z) rf data from + ! files "1Tx.T7 or 1Txx.T7 or 1Txxx.T7. Here, the grid + ! is uniform in x, y and z. + ! This field can be used to model the traveling wave structure subroutine read3t_Data(this,ifile) implicit none include 'mpif.h' diff --git a/utilities/RFcoefext.f90 b/utilities/RFcoefext.f90 index fea3e9d..40f1ccd 100755 --- a/utilities/RFcoefext.f90 +++ b/utilities/RFcoefext.f90 @@ -31,7 +31,7 @@ program rfcoef emax = 0.0 do i = 1, n ! edata(i) = -(edata(i)-edata(n)) - if(emax.le.abs(edata(i))) then + if(abs(emax).le.abs(edata(i))) then emax = edata(i) endif ! zdata(i) = zdata(i)/100 diff --git a/utilities/RFcoeflcls.f90 b/utilities/RFcoeflcls.f90 index 08854da..e3dbe98 100755 --- a/utilities/RFcoeflcls.f90 +++ b/utilities/RFcoeflcls.f90 @@ -30,7 +30,7 @@ program rfcoef !edata(n) = tmp2/10000. zdata(n) = tmp1 edata(n) = tmp2 - if(emax.le.abs(edata(n))) emax = edata(n) + if(abs(emax).le.abs(edata(n))) emax = edata(n) goto 10 100 continue close(3)