5 c... list square surf. fitting
6 c c(1)+c(2)*(r-r1)+c(3)*(z-z1)+c(4)*(r-r1)**2+c(5)*(z-z1)**2+c(6)*(r-r1)*(z-z1)
8 IMPLICIT REAL*8(a-h,o-z)
10 dimension r(*),z(*),u(*),dp(*)
11 dimension a(6,6),b(6),c(6)
61 s_r= s_r + (r(k)-r(1))
62 s_z= s_z + (z(k)-z(1))
63 s_r2= s_r2 + (r(k)-r(1))**2
64 s_z2= s_z2 + (z(k)-z(1))**2
65 s_rz= s_rz + (r(k)-r(1))*(z(k)-z(1))
69 s_r3= s_r3 + (r(k)-r(1))**3
70 s_rz2= s_rz2 + (r(k)-r(1))*(z(k)-z(1))**2
71 s_r2z= s_r2z + (r(k)-r(1))**2*(z(k)-z(1))
72 s_ur= s_ur + u(k)*(r(k)-r(1))
74 s_z3= s_z3 + (z(k)-z(1))**3
75 s_uz= s_uz + u(k)*(z(k)-z(1))
77 s_r4= s_r4 + (r(k)-r(1))**4
78 s_r2z2= s_r2z2 + (r(k)-r(1))**2*(z(k)-z(1))**2
79 s_r3z= s_r3z + (r(k)-r(1))**3*(z(k)-z(1))
80 s_ur2= s_ur2 + u(k)*(r(k)-r(1))**2
82 s_z4= s_z4 + (z(k)-z(1))**4
83 s_rz3= s_rz3 + (r(k)-r(1))*(z(k)-z(1))**3
84 s_uz2= s_uz2 + u(k)*(z(k)-z(1))**2
86 s_urz= s_urz + u(k)*(r(k)-r(1))*(z(k)-z(1))
90 c the creation the
matrix a and right hand b:
163 c the solution the
matrix equation ac=b.
165 CALL
ge(6,6,a,b,c,ip)
169 det=4.d0*c(4)*c(5)-c(6)**2
171 det_r=-2.d0*c(2)*c(5)+c(6)*c(3)
172 det_z=-2.d0*c(3)*c(4)+c(6)*c(2)
177 um=c(1)+c(2)*rm+c(3)*zm+c(4)*rm**2+c(5)*zm**2+c(6)*rm*zm
203 c... definiton of the first and second derivations.
206 IMPLICIT REAL*8(a-h,o-z)
208 dimension x(*),y(*),f(*),u(*)
209 dimension a(5,5),b(5),s(5)
210 c dimension aa(5,5),w1(5),w2(5)
248 sdxdy =sdxdy + dx *dy
250 sdx2dy=sdx2dy + dx2 *dy
251 sdxdy2=sdxdy2 + dx *dy2
253 sdx4 =sdx4 + dx2 *dx2
254 sdx3dy=sdx3dy + dx2 *dx *dy
255 sdx2y2=sdx2y2 + dx2 *dy2
256 sdxdy3=sdxdy3 + dx *dy2 *dy
257 sdy4 =sdy4 + dy2 *dy2
259 daver2=daver2 + dx2 + dy2
264 fdxdy =fdxdy + df *dx *dy
269 c the creation the
matrix a:
273 a(1,3) = sdx3 * 0.5d0
275 a(1,5) = sdxdy2 * 0.5d0
278 a(2,3) = sdx2dy * 0.5d0
280 a(2,5) = sdy3 * 0.5d0
283 a(3,3) = sdx4 * 0.5d0
285 a(3,5) = sdx2y2 * 0.5d0
288 a(4,3) = sdx3dy * 0.5d0
290 a(4,5) = sdxdy3 * 0.5d0
293 a(5,3) = sdx2y2 * 0.5d0
295 a(5,5) = sdy4 * 0.5d0
297 c the creation the right hand b:
309 s(1) = 1.d0/sqrt(sdx2)/daver
310 s(2) = 1.d0/sqrt(sdy2)/daver
311 s(3) = 1.d0/sdx2/daver
312 s(4) = 1.d0/sqrt(sdx2*sdy2)/daver
313 s(5) = 1.d0/sdy2/daver
322 c the solution the
matrix equation au=b.
326 ccccc CALL f04atf(a,5,b,n,u,aa,5,w1,w2,ifail)
327 CALL
ge(5,5,a,b,u,ip)
329 ccccc
IF( ifail .NE. 0 )
WRITE (6,*)
' IFAIL= ',ifail
340 IMPLICIT REAL*8(a-h,o-z)
342 dimension x(1:m),y(1:m),f(1:m),u(1:n)
343 dimension a(1:9,1:9),b(1:9)
346 REAL*8,
ALLOCATABLE :: aa(:,:),bb(:)
353 IF (.NOT.
ALLOCATED(aa))
ALLOCATE(aa(m,9))
354 IF (.NOT.
ALLOCATED(bb))
ALLOCATE(bb(m))
384 c... the creation the
matrix a:
390 akl=akl+aa(i,k)*aa(i,l)
396 c... the creation the right hand b:
408 c... the solution the
matrix equation au=b.
412 CALL
ge(n,9,a,b,u,ip)
414 IF( ifail .NE. 0 )
WRITE (6,*)
' DERIV9:IFAIL= ',ifail
420 SUBROUTINE ge(N,NZ,A,X,Y,IP)
422 c... gauss elimination
424 IMPLICIT REAL*8(a-h,o-z)
426 dimension a(1:nz,1:nz),x(1:n),y(1:n),ip(1:n)
435 c... max row element search
459 a(k,j)=a(k,j)-am*a(i,j)
467 y(i)=y(i)-a(i,j)*y(j)
472 c... back permutation
485 c green
'S FUNCTION FOR TOROIDAL CURRENT LOOP IN INFINITY AREA.
487 IMPLICIT REAL*8(A-H,O-Z)
493 T=SQRT(4.d0*R*RP/((R+RP)**2+(Z-ZP)**2))
495 C CALCULATION OF COMPLETE ELLIPTIC INTEGRALS OF 1TH AND 2TH KIND.
499 C THE FUNCTIONS MMDELK, MMDELE FROM IMSL LIBRARY.
501 C ELCK=MMDELK(2,T,IFAILK)
502 C ELCE=MMDELE(2,T,IFAILE)
504 C THE FUNCTIONS S21BBF, S21BCF FROM NAG LIBRARY.
506 ELCK= S21BBF(0.D0,TT,1.D0,IFAILK)
507 ELCE=ELCK-T*T/3.D0*S21BCF(0.D0,TT,1.D0,IFAILE)
509 .NE..OR..NE.
IF(IFAILK0IFAILE0) WRITE(*,*)' attention
510 ,
' IFAILK, IFAILE= ',ifailk,ifaile
512 greeni = ( (1.d0-t*t*0.5d0)*elck-elce )*( sqrt(r*rp)/t )
517 c********************************************************************
521 c green
's function derivatives at the point (R,Z)
522 c the source position is (R0,Z0)
523 c to obtain the real values of derivatives dGdr,dGdz must be devided by pi
525 IMPLICIT REAL*8(A-H,O-Z)
528 t=SQRT( 4.D0*R*R0/( (R+R0)**2+(Z-Z0)**2 ) )
532 C THE FUNCTIONS S21BBF, S21BCF FROM NAG LIBRARY.
534 fK= S21BBF(0.D0,tt,1.D0,IFAILK)
535 fE=fK-t*t/3.D0*S21BCF(0.D0,tt,1.D0,IFAILE)
537 .NE..OR..NE.
IF(IFAILK0IFAILE0) WRITE(*,*)' attention
538 *
' IFAILK, IFAILE= ',ifailk,ifaile
540 q = ( (1.d0-t*t*0.5d0)*fk-fe )/t
542 dtdr = 0.5d0*( t/r-t*t*t*(r+r0)/(2.d0*r*r0) )
544 dtdz =-t*t*t*(z-z0)/(4.d0*r*r0)
546 dqdt = -q/t + 0.5d0*( fe/tt-fk)
548 dgdr = 0.5d0*sqrt(r0/r)*q + sqrt(r0*r)*dqdt*dtdr
550 dgdz = sqrt(r0*r)*dqdt*dtdz
555 c********************************************************************
557 SUBROUTINE bint(X,Y,R0,Z0,r1,z1,F,I)
558 IMPLICIT REAL*8(a-h,o-z)
560 c===============functions===============functions================c
565 c======================special functions=========================c
567 d(x1,y1,x2,y2)= sqrt( (x1-x2)**2 + (y1-y2)**2 )
569 tint(t)=(t-pscal)*(0.5d0*dlog(pvec**2+(t-pscal)**2+eps**2)-1.d0)+
570 + pvec*datan((t-pscal)/(pvec+eps))
572 c===============functions===============functions================c
590 pscal=( (-x-r0)*(r1-r0) + (y-z0)*(z1-z0) )/h
591 pvec= ( (-x-r0)*(z1-z0) - (y-z0)*(r1-r0) )/h
593 w = tint(h)-tint(0.d0)
595 pscal=( (x-r0)*(r1-r0) + (y-z0)*(z1-z0) )/h
596 pvec= ( (x-r0)*(z1-z0) - (y-z0)*(r1-r0) )/h
598 w = w - (tint(h)-tint(0.d0))
600 IF( dtm .LT. 0.25d0*h )
THEN
606 c+++ w = w - h * alog( dfj*dfj1/(d(x,y,r0,z0)*d(x,y,r1,z1)) )
608 w = w*dfm-0.5d0*h*(alog(dfj/dtj)*dfj+alog(dfj1/dtj1)*dfj1)
612 c+++ w = w - h * alog( dfm / dtm )
614 w = ( w - h * alog( dfm / dtm ) ) * dfm
619 IF( dtm .LT. 0.25d0*h )
THEN
631 f = f /3.14159265359d0
637 SUBROUTINE bint_d(X,Y,R0,Z0,r1,z1,Fr,Fz,i)
639 IMPLICIT REAL*8(a-h,o-z)
643 d(x1,y1,x2,y2)= dsqrt( (x1-x2)**2 + (y1-y2)**2 )
648 call
grgren(rm,zm,x,y, dgdr,dgdz)
652 fr=dgdr*dell/3.14159265359d0
653 fz=dgdz*dell/3.14159265359d0
657 c********************************************************************
658 subroutine greng(R0,Z0,R,Z,fgreen,dGdr,dGdz)
660 c green
's function derivatives at the point (R,Z)
661 c the source position is (R0,Z0)
662 c to obtain the real values of derivatives dGdr,dGdz must be devided by pi
664 IMPLICIT REAL*8(A-H,O-Z)
667 t=SQRT( 4.D0*R*R0/( (R+R0)**2+(Z-Z0)**2 ) )
671 C THE FUNCTIONS S21BBF, S21BCF FROM NAG LIBRARY.
673 fK= S21BBF(0.D0,tt,1.D0,IFAILK)
674 fE=fK-t*t/3.D0*S21BCF(0.D0,tt,1.D0,IFAILE)
676 .NE..OR..NE.
IF(IFAILK0IFAILE0) WRITE(*,*)' attention
677 *
' IFAILK, IFAILE= ',ifailk,ifaile
679 q = ( (1.d0-t*t*0.5d0)*fk-fe )/t
683 dtdr = 0.5d0*( t/r-t*t*t*(r+r0)/(2.d0*r*r0) )
685 dtdz =-t*t*t*(z-z0)/(4.d0*r*r0)
687 dqdt = -q/t + 0.5d0*( fe/tt-fk)
689 dgdr = 0.5d0*sqrt(r0/r)*q + sqrt(r0*r)*dqdt*dtdr
691 dgdz = sqrt(r0*r)*dqdt*dtdz
695 c********************************************************************
696 subroutine d2gren(R0,Z0,R,Z,d2Gdrz,d2Gdzz,d2Gdrr)
698 c green
's function second derivatives at the point (R,Z)
699 c the source position is (R0,Z0)
700 c to obtain the real values of derivatives dGdr,dGdz must be devided by pi
702 IMPLICIT REAL*8(A-H,O-Z)
705 t=SQRT( 4.D0*R*R0/( (R+R0)**2+(Z-Z0)**2 ) )
709 C THE FUNCTIONS S21BBF, S21BCF FROM NAG LIBRARY.
711 fK= S21BBF(0.D0,tt,1.D0,IFAILK)
712 fE=fK-t*t/3.D0*S21BCF(0.D0,tt,1.D0,IFAILE)
714 .NE..OR..NE.
IF(IFAILK0IFAILE0) WRITE(*,*)' attention
715 *
' IFAILK, IFAILE= ',ifailk,ifaile
717 q = ( (1.d0-t*t*0.5d0)*fk-fe )/t
721 dtdr = 0.5d0*( t/r-t*t*t*(r+r0)/(2.d0*r*r0) )
723 dtdz =-t*t*t*(z-z0)/(4.d0*r*r0)
725 dqdt = -q/t + 0.5d0*( fe/tt-fk)
728 & -(1/r/2-3.d0/4.d0*t**2*(r+r0)/r/r0)*t**3*(z-z0)/r/r0/4.d0
732 & 3.d0/16.d0*t**5*(z-z0)**2/r**2/r0**2-t**3/r/r0/4.d0
736 &(1/r/2-3.d0/4.d0*t**2*(r+r0)/r/r0)*(t/r/2-t**3*(r+r0)/r/r0/4)
737 #-t/r**2/2-t**3/r/r0/4+t**3*(r+r0)/r**2/r0/4
741 & q/t**2+fe/(1-t**2)**2*t+1/(1-t**2)*(fe-fk)/t/2-(fe/(1-t**2)-fk)
745 dgdr = 0.5d0*sqrt(r0/r)*q + sqrt(r0*r)*dqdt*dtdr
746 d2gdzz=sqrt(r*r0)*(d2qdt2*dtdz**2+dqdt*d2tdzz)
747 d2gdrz=sqrt(r*r0)*(dqdt*dtdz/r/2.d0+d2qdt2*dtdr*dtdz+dqdt*d2tdrz)
748 d2gdrr=sqrt(r*r0)*(dqdt*dtdr/r/2.d0+d2qdt2*dtdr*dtdr+dqdt*d2tdrr-
749 & q/r**2/2.d0) + dgdr/r/2.d0
758 c********************************************************************
760 REAL*8 FUNCTION cpr(H,NP,S)
762 IMPLICIT REAL*8(a-h,o-z)
764 f(x)=h*(1.d0-x**np)/(1.d0-x)-s
781 write(6,*)
' ***print from routine CPR:'
782 write(6,*)
' can`t generate grid out of plasma domain'
783 write(6,*)
' program is terminated'
788 IF(dabs(y0).LT.eps) go to 1
789 IF((y0*y2).GT.0.d0) go to 2
803 REAL*8 FUNCTION funsq(R1,R2,R3,R4,Z1,Z2,Z3,Z4)
811 funsq=(r13*z24-r24*z13)*0.5d0
832 IMPLICIT REAL*8(a-h,o-z)
834 dimension u(*), a(*),b(*),c(*),f(*), alf(*),bet(*)
841 dk=c(k)-alf(k-1)*b(k)
843 20 bet(k)=(f(k)+bet(k-1)*b(k))/dk
850 30 u(k)=alf(k)*u(k+1)+bet(k)
857 real*8 function blin_(r0,z0,r1,r2,z1,z2,u1,u2,u3,u4 )
866 u0=(s1*u1+s2*u2+s3*u3+s4*u4)/(s1+s2+s3+s4)
REAL *8 function funsq(R1, R2, R3, R4, Z1, Z2, Z3, Z4)
subroutine bint_d(X, Y, R0, Z0, r1, z1, Fr, Fz, i)
REAL *8 function greeni(R, Z, RP, ZP)
subroutine prog1d(M, U, A, B, C, F, ALF, BET)
subroutine deriv9(X, Y, F, M, N, U)
subroutine bint(X, Y, R0, Z0, r1, z1, F, I)
subroutine deriv5(X, Y, F, M, N, U)
REAL(R8) function ad(IION, X, T)
subroutine axis(n, h, r, f)
real *8 function blin_(r0, z0, r1, r2, z1, z2, u1, u2, u3, u4)
subroutine lsq_sur6(r, z, u, n, c, rm, zm, um, dp)
real(r8) function r2(a, x, xr, xs, yr, ys, psi, psir, F_dia)
subroutine ge(N, NZ, A, X, Y, IP)
subroutine grgren(R0, Z0, R, Z, dGdr, dGdz)
subroutine d2gren(R0, Z0, R, Z, d2Gdrz, d2Gdzz, d2Gdrr)
subroutine integral(n, h, r, f, int)
subroutine greng(R0, Z0, R, Z, fgreen, dGdr, dGdz)
REAL *8 function cpr(H, NP, S)