Changeset 18 in PSPA for parmelaPSPA


Ignore:
Timestamp:
Sep 24, 2012, 4:31:45 PM (12 years ago)
Author:
lemeur
Message:

corr. bug dans distrir.f

Location:
parmelaPSPA/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • parmelaPSPA/trunk/cread.f

    r12 r18  
    2727     6 'WIGGLER','ALPHAM','STAT','POISSON','SEXTUPOLE'/
    2828      data lfnr,nextr/0,1/  ! lfnr look for next run (or end)
     29
    2930      if (jj.eq.100) lfnr=1
    3031   10 continue
  • parmelaPSPA/trunk/distrir.f

    r12 r18  
    1818        pas=xmax/nbin
    1919        ntot=0
    20 c-------
     20
     21c------- correction Guy Le Meur 24-09-2012
     22        do 10 i=1,nbin
     23           n(i)=0
     24 10     continue
     25
    2126        do 20 i=1,nbin
    2227          if(fac.lt.0.5) then
     
    3338              n(i)=int(const2*exp(-((i-0.5)*pas)**2/(2*sigsq))
    3439     1             *(i-0.5)*pas*pas+0.5)
    35           ntot=ntot+n(i)
     40     
     41              ntot=ntot+n(i)
    3642              if(ntot.gt.npoints) then
    3743                 n(i)=n(i)-ntot+npoints
  • parmelaPSPA/trunk/input.f

    r12 r18  
    100100     * .4987,.4990,.4993,.4995,.4997,.49975,.4998,.49985,.4999,.49995,
    101101     * .5/
     102
    102103      do  1 i=1,imaa  ! mcd
    103104      zcath(i)=0.     ! mcd
     
    598599c
    599600c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     601
    600602      if (nn.lt.10) then
    601603        write(nnout,10001)nn
     
    69269410007   format (' gun cavity length =',t40,1pg12.3,' cm')
    693695      endif
     696
     697
    694698c-----
    695699c
     
    707711c----------------------------- ran = 1 ----
    708712      if(vv(10).eq.1) then
    709       do 10008 i = np1,npoints
    710 c        choose time (phase) of generation, relative to center of the pulse
    711 10009 continue
    712       call rannor(u,v)
    713       if (abs(u).gt.tfac) go to 10009
    714       phase = u*sigdeg
     713         do 10008 i = np1,npoints
     714c     choose time (phase) of generation, relative to center of the pulse
     71510009       continue
     716            call rannor(u,v)
     717            if (abs(u).gt.tfac) go to 10009
     718            phase = u*sigdeg
    715719c     choose intial energy at cathode
    716 10010 continue
    717       call rannor(u,v)
    718       e = ecath + u*decath
    719       if (e.le.0.) go to 10010
    720       betcat = sqrt(2.*e/erest)
    721       gamma = 1./sqrt(1. - betcat**2)
    722 c        choose initial momentum, isotropic, but betaz > 0
    723       cose = sandom(d)
    724       sine = sqrt(1. - cose**2)
    725       phi = twopi*sandom(d)
    726       bx = betcat*sine*cos(phi)
    727       by = betcat*sine*sin(phi)
    728       bz = betcat*cose
    729       cor(2,i) = gamma*bx
    730       cor(4,i) = gamma*by
    731       cor(6,i) = gamma*bz
    732 c        choose (x,y,z)
    733 10011 continue
    734       call rannor(u,v)
    735       x0 = u*rsig
    736       y0 = v*rsig
    737       rsq = x0**2 + y0**2
    738       if (rsq.gt.rmaxsq) go to 10011
     72010010       continue
     721            call rannor(u,v)
     722            e = ecath + u*decath
     723            if (e.le.0.) go to 10010
     724            betcat = sqrt(2.*e/erest)
     725            gamma = 1./sqrt(1. - betcat**2)
     726c     choose initial momentum, isotropic, but betaz > 0
     727            cose = sandom(d)
     728            sine = sqrt(1. - cose**2)
     729            phi = twopi*sandom(d)
     730            bx = betcat*sine*cos(phi)
     731            by = betcat*sine*sin(phi)
     732            bz = betcat*cose
     733            cor(2,i) = gamma*bx
     734            cor(4,i) = gamma*by
     735            cor(6,i) = gamma*bz
     736c     choose (x,y,z)
     73710011       continue
     738            call rannor(u,v)
     739            x0 = u*rsig
     740            y0 = v*rsig
     741            rsq = x0**2 + y0**2
     742            if (rsq.gt.rmaxsq) go to 10011
    739743c----------------------------------
    740       if((spota.eq.0.).or.(spotd.eq.0)) go to 10021
    741           anglex10 = atan(x0/spotd)
    742           delta = spotd*(1-(cos(spota)/cos(spota+(anglex10))))
    743           delta = delta*360./wavel
    744           x0= spotd*sin(anglex10)/cos(anglex10+spota)
    745           phase=phase+delta
    746 10021   continue
     744            if((spota.eq.0.).or.(spotd.eq.0)) go to 10021
     745            anglex10 = atan(x0/spotd)
     746            delta = spotd*(1-(cos(spota)/cos(spota+(anglex10))))
     747            delta = delta*360./wavel
     748            x0= spotd*sin(anglex10)/cos(anglex10+spota)
     749            phase=phase+delta
     75010021       continue
    747751c---------------------------------------
    748       uph(i)=phase
    749       if(uph(i).gt.uphmax)uphmax=uph(i)
    750       if(uph(i).lt.uphmin)uphmin=uph(i)     
     752            uph(i)=phase
     753            if(uph(i).gt.uphmax)uphmax=uph(i)
     754            if(uph(i).lt.uphmin)uphmin=uph(i)     
    751755c---------------------------------------
    752       ux0(i)=x0
    753       if(ux0(i).gt.ux0max)ux0max=ux0(i)
    754       if(ux0(i).lt.ux0min)ux0min=ux0(i)
    755       vy0(i)=y0
    756       if(vy0(i).gt.vy0max)vy0max=vy0(i)
    757       if(vy0(i).lt.vy0min)vy0min=vy0(i)
     756            ux0(i)=x0
     757            if(ux0(i).gt.ux0max)ux0max=ux0(i)
     758            if(ux0(i).lt.ux0min)ux0min=ux0(i)
     759            vy0(i)=y0
     760            if(vy0(i).gt.vy0max)vy0max=vy0(i)
     761            if(vy0(i).lt.vy0min)vy0min=vy0(i)
    758762c-----
    759       z0 = 0.
    760       if (ajones.gt.0.) then
    761 c        calculate the shape of the cathode surface
    762         z0 = cathod(rsq)
    763         zcath(i) = z0
    764       endif
     763            z0 = 0.
     764            if (ajones.gt.0.) then
     765c     calculate the shape of the cathode surface
     766               z0 = cathod(rsq)
     767               zcath(i) = z0
     768            endif
    765769c-----
    766 c        shift initial (x,y,z) so that the particle will emerge from
    767 c        the photocathode at (x0,y0,z0) at time = phase
    768       toff = (wtstep + phase)*wavel/360.
    769       cor(1,i) = x0 - toff*bx
    770       cor(3,i) = y0 - toff*by
    771       cor(5,i) = z0 - toff*bz
    772 10008 continue
    773       else  !  vv(10).ne.1
    774 c----
    775       call distriphase(degmax,sigdeg,npoints-1)
    776       call distrir(rmax,rsig,npoints-1)
    777 c----
    778       do 10012 i = np1,npoints
    779 c        choose time (phase) of generation, relative to center of the pulse
    780 c----
    781       u=distp(i-1)
    782 c----
    783       phase=u
    784 c----
    785 c        choose intial energy at cathode
    786 10013 continue
    787       call rannor(u,v)
    788 c----
    789       e = ecath + u*decath
    790       if (e.le.0.) go to 10013
    791       betcat = sqrt(2.*e/erest)
    792       gamma = 1./sqrt(1. - betcat**2)
    793 c        choose initial momentum, isotropic, but betaz > 0
    794       cose = sandom(d)
    795       sine = sqrt(1. - cose**2)
    796       phi = twopi*sandom(d)
    797       bx = betcat*sine*cos(phi)
    798       by = betcat*sine*sin(phi)
    799       bz = betcat*cose
    800       cor(2,i) = gamma*bx
    801       cor(4,i) = gamma*by
    802       cor(6,i) = gamma*bz
    803 c        choose (x,y,z)
    804 c----
    805 c----
    806       if(vv(10).eq.2) then
    807 10014      continue
    808            call rannor(u,v)
    809            x0=u*rsig
    810            y0=v*rsig
    811            rsq=x0**2+y0**2
    812            if(rsq.gt.rmaxsq) go to 10014
    813       else                              !  vv(10) .ne.2
    814            x0 = xr(i-1)
    815            y0 = yr(i-1)
    816       endif                             !  vv(10) .eq. 2
     770c     shift initial (x,y,z) so that the particle will emerge from
     771c     the photocathode at (x0,y0,z0) at time = phase
     772            toff = (wtstep + phase)*wavel/360.
     773            cor(1,i) = x0 - toff*bx
     774            cor(3,i) = y0 - toff*by
     775            cor(5,i) = z0 - toff*bz
     77610008    continue
     777      else                      !  vv(10).ne.1
     778c---- 
     779         call distriphase(degmax,sigdeg,npoints-1)
     780         call distrir(rmax,rsig,npoints-1)
     781c---- 
     782         do 10012 i = np1,npoints
     783c     choose time (phase) of generation, relative to center of the pulse
     784c---- 
     785            u=distp(i-1)
     786c---- 
     787            phase=u
     788c---- 
     789c     choose intial energy at cathode
     79010013       continue
     791            call rannor(u,v)
     792c---- 
     793            e = ecath + u*decath
     794            if (e.le.0.) go to 10013
     795            betcat = sqrt(2.*e/erest)
     796            gamma = 1./sqrt(1. - betcat**2)
     797c     choose initial momentum, isotropic, but betaz > 0
     798            cose = sandom(d)
     799            sine = sqrt(1. - cose**2)
     800            phi = twopi*sandom(d)
     801            bx = betcat*sine*cos(phi)
     802            by = betcat*sine*sin(phi)
     803            bz = betcat*cose
     804            cor(2,i) = gamma*bx
     805            cor(4,i) = gamma*by
     806            cor(6,i) = gamma*bz
     807c     choose (x,y,z)
     808c---- 
     809c---- 
     810            if(vv(10).eq.2) then
     81110014          continue
     812               call rannor(u,v)
     813               x0=u*rsig
     814               y0=v*rsig
     815               rsq=x0**2+y0**2
     816               if(rsq.gt.rmaxsq) go to 10014
     817            else                !  vv(10) .ne.2
     818               x0 = xr(i-1)
     819               y0 = yr(i-1)
     820            endif               !  vv(10) .eq. 2
    817821c----------------------------------
    818       if((spota.eq.0.).or.(spotd.eq.0)) go to 10022
    819           anglex10 = atan(x0/spotd)
    820           delta = spotd*(1-(cos(spota)/cos(spota+(anglex10))))
    821           delta = delta*360./wavel
    822           x0= spotd*sin(anglex10)/cos(anglex10+spota)
    823           phase=phase+delta
    824 10022   continue
     822            if((spota.eq.0.).or.(spotd.eq.0)) go to 10022
     823            anglex10 = atan(x0/spotd)
     824            delta = spotd*(1-(cos(spota)/cos(spota+(anglex10))))
     825            delta = delta*360./wavel
     826            x0= spotd*sin(anglex10)/cos(anglex10+spota)
     827            phase=phase+delta
     82810022       continue
    825829c---------------------------------------
    826       uph(i)=phase
    827       if(uph(i).gt.uphmax)uphmax=uph(i)
    828       if(uph(i).lt.uphmin)uphmin=uph(i)
    829 c----
    830       ux0(i)=x0
    831       if(ux0(i).gt.ux0max)ux0max=ux0(i)
    832       if(ux0(i).lt.ux0min)ux0min=ux0(i)
    833       vy0(i)=y0
    834       if(vy0(i).gt.vy0max)vy0max=vy0(i)
    835       if(vy0(i).lt.vy0min)vy0min=vy0(i)
    836 c----
    837       z0 = 0.
    838       if (ajones.gt.0.) then
    839       rsq = x0**2 + y0**2
    840 c         calculate the shape of the cathode surface
    841           z0 = cathod(rsq)
    842           zcath(i) = z0
    843       endif
    844 c        shift initial (x,y,z) so that the particle will emerge from
    845 c        the photocathode at (x0,y0,z0) at time = phase
    846       toff = (wtstep + phase)*wavel/360.
    847       cor(1,i) = x0 - toff*bx
    848       cor(3,i) = y0 - toff*by
    849       cor(5,i) = z0 - toff*bz
    850 10012 continue
     830            uph(i)=phase
     831            if(uph(i).gt.uphmax)uphmax=uph(i)
     832            if(uph(i).lt.uphmin)uphmin=uph(i)
     833c----
     834            ux0(i)=x0
     835            if(ux0(i).gt.ux0max)ux0max=ux0(i)
     836            if(ux0(i).lt.ux0min)ux0min=ux0(i)
     837            vy0(i)=y0
     838            if(vy0(i).gt.vy0max)vy0max=vy0(i)
     839            if(vy0(i).lt.vy0min)vy0min=vy0(i)
     840c----
     841            z0 = 0.
     842            if (ajones.gt.0.) then
     843               rsq = x0**2 + y0**2
     844c     calculate the shape of the cathode surface
     845               z0 = cathod(rsq)
     846               zcath(i) = z0
     847            endif
     848c     shift initial (x,y,z) so that the particle will emerge from
     849c     the photocathode at (x0,y0,z0) at time = phase
     850            toff = (wtstep + phase)*wavel/360.
     851            cor(1,i) = x0 - toff*bx
     852            cor(3,i) = y0 - toff*by
     853            cor(5,i) = z0 - toff*bz
     85410012    continue
     855
    851856c----------
    852       endif ! vv(1).eq.1
     857      endif                     ! vv(1).eq.1
    853858c----------
     859
    854860      if(ip.eq.2) then
    855861         open(unit=ninput,file='input10',status='unknown')
  • parmelaPSPA/trunk/parmelamainv503.f

    r12 r18  
    346346      open(unit=nin,file='parmin',status='old',
    347347     *     access='sequential',form='formatted')
    348       open(unit=nnout,file='parmdebug',status='new',
     348      open(unit=nnout,file='parmdebug',status='unknown',
    349349     *        access='sequential',form='formatted')
    350350      call ouvrir
Note: See TracChangeset for help on using the changeset viewer.