source: PSPA/parmelaPSPA/trunk/elispdp.f @ 412

Last change on this file since 412 was 12, checked in by lemeur, 12 years ago

parmela pspa initial

File size: 1.4 KB
Line 
1      subroutine elipsdp(nt90,n,x,y,a,b,xc,yc,e)
2c
3c      subroutine for parmila to fit an elipse to a set of phase space
4c      points.
5c      n = no of points
6c      x,y = coordinates
7c      a,b = alpha & beta of ellipse
8c      xc,yc = mean for x and y
9c      e = emittance
10c      e = gamma*x**2 + 2*alpha*x*y + beta*y**2
11c      note that we do not let the centroid shift from the minimum e value
12c
13c--------------------------------------------------------------------------
14      implicit double precision (a,b,e,f,r,s,x,y)
15c
16      include 'ucom.h'
17c
18      dimension x(n),y(n)
19c--------------------------------------------------------------------------
20c*
21      fx=0.
22      fy=0.
23      sx=0.
24      sy=0.
25      sxy=0.
26c      minimize e
27      do 10 i = 1,n
28      fx = fx + x(i)
29      fy = fy + y(i)
30      sx = sx + x(i)*x(i)
31      sxy = sxy + x(i)*y(i)
32      sy = sy + y(i)*y(i)
33 10   continue
34      xc = fx/n
35      yc = fy/n
36      scx = sx/n - xc*xc
37      scy = sy/n - yc*yc
38      scxy = sxy/n - xc*yc
39      rbm=(scx*scy - scxy*scxy)
40      if(rbm.le.0.) then
41       if(nt90.eq.1) then
42       write(nemit,*)
43     *' no calculation of emittances for (x,xp): negative square root'
44       else
45       write(nemit,*)
46     *' no calculation of emittances for (y,yp): negative square root'
47       endif
48      else
49      e = dsqrt(rbm)
50           a = -scxy/e
51           b = scx/e
52      endif
53      return
54      end
55c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*
Note: See TracBrowser for help on using the repository browser.