ETS  \$Id: Doxyfile 2162 2020-02-26 14:16:09Z g2dpc $
 All Classes Files Functions Variables Pages
Ev2.f
Go to the documentation of this file.
1 C************************************************************
2 C
3 C NVAR=1 - SQUARED FORM OF SURFACES IS USED:
4 C A1*X**2+A2*X*Y+A3*Y**2+A4*X+A5*Y+A6=0
5 C
6 C NVAR=2 - BILINEAR FORM OF SURFACES IS USED
7 C
8 C NVAR = 11 - TEST FOR NVAR=1
9 C--------------------------------------------------------
10  SUBROUTINE fun(X,F)
11 C
12  IMPLICIT REAL*8(a-h,o-z)
13 C
14  common/cpcoor/ nvar,ifailf,rcp,zcp,uu(5),df
15  common/yscr/ y
16 C
17  sqrt(xxx) = dsqrt(xxx)
18 C
19  IF( nvar .EQ. 1 ) THEN
20 C
21  a1 = 0.5d0*uu(3)
22  a2 = uu(4)
23  a3 = 0.5d0*uu(5)
24  a4 = uu(1)
25  a5 = uu(2)
26  a6 = df
27 C
28  alf = 1.d0
29  ifailf = 0
30 C
31  b = (a2*x+a5) / (2.d0*a3)
32  det = b**2 - (a1*x**2+a4*x+a6)/a3
33  IF( det .LT. 0 ) THEN
34 C WRITE(6,*) ' PROGRAM TERMINATED: DET= ',DET
35 C STOP
36  det = - det
37  alf = 1.d+3
38  ifailf = 1
39  ENDIF
40  det = sqrt( det ) * alf
41  y = -b + det
42  y2 = -b - det
43 C
44  f = (x-rcp)**2 + (y -zcp)**2
45  f2 = (x-rcp)**2 + (y2-zcp)**2
46 C
47  IF (f2 .LT. f ) THEN
48  f = f2
49  y = y2
50  ENDIF
51 C
52  ENDIF
53 C
54 C
55  IF( nvar .EQ. 11 ) THEN
56 C..TEST
57  a1 = 1.d0
58  a2 = 0.d0
59  a3 = 1.d0
60  a4 = 0.d0
61  a5 = 0.d0
62  a6 = -1.d0
63 C......
64  b = (a2*x+a5) / (2.d0*a3)
65  det = sqrt( b**2 - (a1*x**2+a4*x+a6)/a3 )
66  y = -b + det
67  y2 = -b - det
68 C
69  f = (x-rcp)**2 + (y -zcp)**2
70  f2 = (x-rcp)**2 + (y2-zcp)**2
71 C
72  IF (f2 .LT. f ) f = f2
73 C
74  ENDIF
75 C
76  RETURN
77  END
78 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
79 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
80 C***************************************************************
81 C Definition of (IC,JC)-cell, wich contain given (RC,ZC)-point
82 C---------------------------------------------------------------
83 C
84  SUBROUTINE ijmesh( NR,R,NZ,Z, RC,ZC, IC,JC)
85 C
86  IMPLICIT REAL*8(a-h,o-z)
87 C
88  dimension r(1),z(1)
89 C
90  nout = 17
91  nter = 6
92 C
93  IF( (rc.LT.r(1)) .OR. (r(nr).LT.rc) ) THEN
94  ! WRITE(NTER,*) 'PROGRAM WAS INTERRUPTED IN SUBR. "IJMESH" '
95  ! WRITE(NTER,*) 'POINT "RC" IS OUT OF "BOX" : RC =', RC
96  !WRITE(NOUT,*) 'PROGRAM WAS INTERRUPTED IN SUBR. "IJMESH" '
97  !WRITE(NOUT,*) 'POINT "RC" IS OUT OF "BOX" : RC =', RC
98  stop
99  END IF
100  IF( (zc.LT.z(1)) .OR. (z(nz).LT.zc) ) THEN
101  ! WRITE(NTER,*) 'PROGRAM WAS INTERRUPTED IN SUBR. "IJMESH" '
102  ! WRITE(NTER,*) 'POINT "ZC" IS OUT OF "BOX" : ZC =', ZC
103  !WRITE(NOUT,*) 'PROGRAM WAS INTERRUPTED IN SUBR. "IJMESH" '
104  !WRITE(NOUT,*) 'POINT "ZC" IS OUT OF "BOX" : ZC =', ZC
105  stop
106  END IF
107 C
108  DO 1 i=1,nr
109  IF( r(i) .GT. rc ) THEN
110  ic = i - 1
111  go to 2
112  ENDIF
113  1 CONTINUE
114  2 CONTINUE
115 C
116  DO 3 j=1,nz
117  IF( z(j) .GT. zc ) THEN
118  jc = j - 1
119  go to 4
120  ENDIF
121  3 CONTINUE
122  4 CONTINUE
123  RETURN
124  END
125 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
126 C***********************************************************************
127 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
128 C SUM OF ANGLES FOR POINT (UC,VC) AND
129 C CLOSED CURVE U,V(N)
130 C ASSUMING U,V(N) .NE. U,V(1) !!
131 C----------------------------------------------------------
132 C
133  REAL*8 FUNCTION sumang (N,U,V,UC,VC)
134 C
135  include'double.inc'
136 C
137  dimension u(1:n), v(1:n)
138 C
139  sumang=0.
140  reg=1.d-10
141 C
142  DO 1 i =1,n
143  du1=u(i)-uc
144  dv1=v(i)-vc
145  IF(i.NE.n) THEN
146  du2=u(i+1)-uc
147  dv2=v(i+1)-vc
148  ELSE
149  du2=u(1)-uc
150  dv2=v(1)-vc
151  ENDIF
152  ang=dacos((du1*du2+dv1*dv2)/(dsqrt((du1*du1+dv1*dv1)*
153  & (du2*du2+dv2*dv2))+reg))
154  IF(du1*dv2-du2*dv1.GT.0.) THEN
155  sumang=sumang+ang
156  ELSE
157  sumang=sumang-ang
158  ENDIF
159  1 CONTINUE
160 C
161  RETURN
162  END
163 C**********************************************************
164 C MIN. DISTANCE FOR POINT (UC,VC) AND
165 C CURVE U,V(N)
166 C----------------------------------------------------------
167  REAL*8 FUNCTION distan(N,U,V,UC,VC)
168 C
169  include'double.inc'
170 C
171  dimension u(1:n), v(1:n)
172 C
173  sqrt(xxx) = dsqrt(xxx)
174 C
175  distan = 100.d0
176 C
177  DO 1 i =1,n
178  ttt = (u(i)-uc)**2 + (v(i)-vc)**2
179  ttt = sqrt(ttt)
180  IF(ttt.LT.distan) distan = ttt
181  1 CONTINUE
182 C
183  RETURN
184  END
185 C
186 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
187 C POLOIDAL mag. field companents Bp_r, Bp_z and
188 C POLOIDAL mag. field projection on direction FIPRO
189 C COMPUTE FOR GIVEN "PF_PROBE" POINTS:
190 C-----------------------------------------------------------------------
191 C
192  SUBROUTINE bp_prob( NOUT, NTER, KEYPRI,
193  * npro, rpro, zpro, fipro,
194  * brpro, bzpro, bpcom )
195 C
196  include 'double.inc'
197 C
198  dimension rpro(*), zpro(*), fipro(*),
199  * brpro(*), bzpro(*), bpcom(*)
200 C-----------------------------------------------------------------------
201 C
202  IF( npro.NE.0 ) THEN
203  do 1455 i=1,npro
204  call probe( rpro(i), zpro(i), fipro(i),
205  * brpr, bzpr, bpnum )
206  brpro(i) = brpr
207  bzpro(i) = bzpr
208  bpcom(i) = bpnum
209  1455 continue
210 C
211 C WRITE(NOUT, * ) ' '
212 C WRITE(NOUT, * ) '--------------------------------------------'
213 C WRITE(NOUT, * ) 'Poloidal mag. field probe projection '
214 C WRITE(NOUT, * ) ' BPCOM(i), i=1,...,NPRO = ', NPRO
215 C WRITE(NOUT, * ) '--------------------------------------------'
216 C WRITE(NOUT,101) (BPCOM(I), I=1,NPRO)
217 C WRITE(NOUT, * ) ' '
218 C
219  END IF
220 C
221  101 FORMAT(2x,5e14.7)
222 C
223  RETURN
224  END
225 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
226 C Compute POLOIDAL mag. field companents Bp_r, Bp_z
227 C and POLOIDAL mag. field projection on direction FPR
228 C-----------------------------------------------------------------------
229 C
230  SUBROUTINE probe( RPR, ZPR, FPR, BRPR, BZPR, BPNUM )
231 C
232  include 'double.inc'
233  include 'param.inc'
234  include 'comblc.inc'
235 C
236  sin(xxxx) = dsin(xxxx)
237  cos(xxxx) = dcos(xxxx)
238 C-----------------------------------------------------------------------
239 C
240  CALL ijmesh( ni,r,nj,z, rpr,zpr, ic,jc )
241 C
242  drdz = ( r(ic+1) - r(ic) )*( z(jc+1) - z(jc) )
243 C
244  dpsdr = ( (u(ic+1,jc ) - u(ic,jc )) * (z(jc+1) - zpr ) +
245  * (u(ic+1,jc+1) - u(ic,jc+1)) * (zpr - z(jc)) )
246  * / drdz
247  dpsdz = ( (u(ic ,jc+1) - u(ic ,jc)) * (r(ic+1) - rpr ) +
248  * (u(ic+1,jc+1) - u(ic+1,jc)) * (rpr - r(ic)) )
249  * / drdz
250  brpr = - dpsdz / rpr
251  bzpr = dpsdr / rpr
252 C
253  bpnum = brpr*cos(fpr) + bzpr*sin(fpr)
254 C
255  bbb = 1.d0/(2.d0*pi)
256 C
257  brpr = brpr
258  bzpr = bzpr
259  bpnum = bpnum
260 C
261  RETURN
262  END
263 C
264 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
265 C Compute full poloidal flux in given "loop" points
266 C-----------------------------------------------------------------------
267 C
268  SUBROUTINE fl_loo( NOUT, NTER, KEYPRI,
269  * nloo, rloo, zloo,
270  * psloo )
271 C
272  include 'double.inc'
273 C
274  dimension rloo(1), zloo(1), psloo(1)
275 C-----------------------------------------------------------------------
276 C
277  IF( nloo.NE.0 ) THEN
278  do i=1,nloo
279 C
280  call floop( rloo(i), zloo(i), psnum )
281 C
282  if( i.eq.1 ) then
283  psloo(i) = psnum
284  else
285  psloo(i) = psnum - psloo(1)
286  end if
287 C
288  end do
289 C
290 C WRITE(NOUT, * ) ' '
291 C WRITE(NOUT, * ) '--------------------------------------------'
292 C WRITE(NOUT, * ) 'Poloidal mag. flux loop values '
293 C WRITE(NOUT, * ) ' PSLOO(i), i=1,...,NLOO = ', NLOO
294 C WRITE(NOUT, * ) '--------------------------------------------'
295 C WRITE(NOUT,101) (psloo(i), i=1,nloo)
296 C WRITE(NOUT, * ) ' '
297 C
298  END IF
299 C
300  101 FORMAT(2x,5e14.7)
301 C
302  RETURN
303  END
304 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
305 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
306 C Compute full poloidal flux in given "loop" point
307 C-----------------------------------------------------------------------
308  SUBROUTINE floop( RPR, ZPR, PSPR )
309 C
310  include 'double.inc'
311  include 'param.inc'
312  include 'comblc.inc'
313 C
314 C-----------------------------------------------------------------------
315 C
316  CALL ijmesh( ni,r,nj,z, rpr,zpr, ic,jc )
317 C
318  drdz = ( r(ic+1) - r(ic) )*( z(jc+1) - z(jc) )
319 C
320  pspr = ( u(ic ,jc ) * (r(ic+1) - rpr)*(z(jc+1) - zpr) +
321  * u(ic+1,jc ) * ( rpr - r(ic) )*(z(jc+1) - zpr) +
322  * u(ic ,jc+1) * (r(ic+1) - rpr)*( zpr - z(jc) ) +
323  * u(ic+1,jc+1) * ( rpr - r(ic) )*( zpr - z(jc) ) )
324  * / drdz
325 C
326  bbb = 1.d0/(2.d0*pi)
327 C
328  pspr = pspr / bbb
329 C
330  RETURN
331  END
332 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
333 
334 
335 
336 
337 
338 
339 
REAL *8 function sumang(N, U, V, UC, VC)
Definition: Ev2.f:133
subroutine fun(X, F)
Definition: Ev2.f:10
subroutine ijmesh(NR, R, NZ, Z, RC, ZC, IC, JC)
Definition: Ev2.f:84
subroutine fl_loo(NOUT, NTER, KEYPRI, NLOO, RLOO, ZLOO, PSLOO)
Definition: Ev2.f:268
subroutine floop(RPR, ZPR, PSPR)
Definition: Ev2.f:308
subroutine probe(RPR, ZPR, FPR, BRPR, BZPR, BPNUM)
Definition: Ev2.f:230
REAL *8 function distan(N, U, V, UC, VC)
Definition: Ev2.f:167
subroutine bp_prob(NOUT, NTER, KEYPRI, NPRO, RPRO, ZPRO, FIPRO, BRPRO, BZPRO, BPCOM)
Definition: Ev2.f:192