/[PAMELA software]/eventviewer/flight/src/inter_B_outer.for
ViewVC logotype

Annotation of /eventviewer/flight/src/inter_B_outer.for

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Fri Jul 14 14:18:10 2006 UTC (18 years, 4 months ago) by mocchiut
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
FILE REMOVED
New _BETA_ and buggy version

1 mocchiut 1.1 *************************************************************************
2     *
3     * Subroutine inter_B_outer.f
4     *
5     * it computes the magnetic field in a chosen point x,y,z OUTSIDE the
6     * magnetic cavity, using a trilinear interpolation of
7     * B field measurements (read before by means of ./read_B.f)
8     * the value is computed for the outer map
9     *
10     * needs:
11     * - ../common/common_B_outer.f
12     *
13     * input: coordinates in m
14     * output: magnetic field in T
15     *
16     *************************************************************************
17    
18     subroutine inter_B_outer(x,y,z,res) !coordinates in m, magnetic field in T
19    
20     implicit double precision (a-h,o-z)
21     include './common_B_outer.for'
22    
23    
24     c------------------------------------------------------------------------
25     c
26     c local variables
27     c
28     c------------------------------------------------------------------------
29    
30     real*8 x,y,z !point of interpolation
31     real*8 res(3) !interpolated B components: res = (Bx, By, Bz)
32     real*8 zin
33    
34     integer ic
35     c !index for B components:
36     c ! ic=1 ---> Bx
37     c ! ic=2 ---> By
38     c ! ic=3 ---> Bz
39    
40     integer cube(3)
41     c !vector of indexes identifying the cube
42     c ! containing the point of interpolation
43     c ! (see later...)
44    
45     real*8 xl,xh,yl,yh,zl,zh !cube vertexes coordinates
46    
47     real*8 xr,yr,zr
48     c !reduced variables (coordinates of the
49     c ! point of interpolation inside the cube)
50    
51     real*8 Bp(8)
52     c !vector of values of B component
53     c ! being computed, on the eight cube vertexes
54    
55    
56     c LOWER MAP
57     c ---> up/down simmetry
58     zin=z
59     if(zin.le.edgelzmax)z=-z
60    
61     c------------------------------------------------------------------------
62     c
63     c *** MAP ***
64     c
65     c------------------------------------------------------------------------
66    
67     do ic=1,3 !loops on the three B components
68    
69     c------------------------------------------------------------------------
70     c
71     c chooses the coordinates interval containing the input point
72     c
73     c------------------------------------------------------------------------
74     c e.g.:
75     c
76     c x1 x2 x3 x4 x5... xN
77     c |-----|-+---|-----|-----|---- ... ----|-----|
78     c ~~~~~~~~x
79     c
80     c in this case the right interval is identified by indexes 2-3, so the
81     c value assigned to cube variable is 2
82    
83     cube(1)=INT((nox-1)*(x-poxmin(ic))/(poxmax(ic)-poxmin(ic))) +1
84     cube(2)=INT((noy-1)*(y-poymin(ic))/(poymax(ic)-poymin(ic))) +1
85     cube(3)=INT((noz-1)*(z-pozmin(ic))/(pozmax(ic)-pozmin(ic))) +1
86    
87     c------------------------------------------------------------------------
88     c
89     c if the point falls beyond the extremes of the grid...
90     c
91     c------------------------------------------------------------------------
92     c
93     c ~~~~~~~~~~x1 x2 x3...
94     c - - + - - |-----|-----|----
95     c ~~~~x
96     c
97     c in the case cube = 1
98     c
99     c
100     c ...nx-2 nx-1 nx
101     c ----|-----|-----| - - - + - -
102     c ~~~~~~~~~~~~~~~~~~~~~~~~x
103     c
104     c in this case cube = nx-1
105    
106     if (cube(1).le.0) cube(1) = 1
107     if (cube(2).le.0) cube(2) = 1
108     if (cube(3).le.0) cube(3) = 1
109     if (cube(1).ge.nox) cube(1) = nox-1
110     if (cube(2).ge.noy) cube(2) = noy-1
111     if (cube(3).ge.noz) cube(3) = noz-1
112    
113    
114     c------------------------------------------------------------------------
115     c
116     c temporary variables definition for field computation
117     c
118     c------------------------------------------------------------------------
119    
120     xl = pox(cube(1),ic) !X coordinates of cube vertexes
121     xh = pox(cube(1)+1,ic)
122    
123     yl = poy(cube(2),ic) !Y coordinates of cube vertexes
124     yh = poy(cube(2)+1,ic)
125    
126     zl = poz(cube(3),ic) !Z coordinates of cube vertexes
127     zh = poz(cube(3)+1,ic)
128    
129     xr = (x-xl) / (xh-xl) !reduced variables
130     yr = (y-yl) / (yh-yl)
131     zr = (z-zl) / (zh-zl)
132    
133     Bp(1) = bo(cube(1) ,cube(2) ,cube(3) ,ic) !ic-th component of B
134     Bp(2) = bo(cube(1)+1,cube(2) ,cube(3) ,ic) ! on the eight cube
135     Bp(3) = bo(cube(1) ,cube(2)+1,cube(3) ,ic) ! vertexes
136     Bp(4) = bo(cube(1)+1,cube(2)+1,cube(3) ,ic)
137     Bp(5) = bo(cube(1) ,cube(2) ,cube(3)+1,ic)
138     Bp(6) = bo(cube(1)+1,cube(2) ,cube(3)+1,ic)
139     Bp(7) = bo(cube(1) ,cube(2)+1,cube(3)+1,ic)
140     Bp(8) = bo(cube(1)+1,cube(2)+1,cube(3)+1,ic)
141    
142     c------------------------------------------------------------------------
143     c
144     c computes interpolated ic-th component of B in (x,y,z)
145     c
146     c------------------------------------------------------------------------
147    
148     res(ic) =
149     + Bp(1)*(1-xr)*(1-yr)*(1-zr) +
150     + Bp(2)*xr*(1-yr)*(1-zr) +
151     + Bp(3)*(1-xr)*yr*(1-zr) +
152     + Bp(4)*xr*yr*(1-zr) +
153     + Bp(5)*(1-xr)*(1-yr)*zr +
154     + Bp(6)*xr*(1-yr)*zr +
155     + Bp(7)*(1-xr)*yr*zr +
156     + Bp(8)*xr*yr*zr
157    
158    
159     enddo
160    
161     c LOWER MAP
162     c ---> up/down simmetry
163     if(zin.le.edgelzmax)then
164     z=-z !back to initial ccoordinate
165     res(3)=-res(3) !invert BZ component
166     endif
167    
168     return
169     end

  ViewVC Help
Powered by ViewVC 1.1.23