31 dlr(i,j)=sqrt( (r(i+1,j)-r(i,j))**2+(z(i+1,j)-z(i,j))**2 )
32 st(i,j)=dlr(i,j)*(r(i+1,j)+r(i,j))*0.5d0
40 dlt(i,j)=sqrt( (r(i,j+1)-r(i,j))**2+(z(i,j+1)-z(i,j))**2 )
41 sr(i,j)=dlt(i,j)*(r(i,j+1)+r(i,j))*0.5d0
55 r0=(r1+
r2+r3+r4)*0.25d0
66 z0=(z1+z2+z3+z4)*0.25d0
78 sq_1=
funsq(r1,r12,r0,r14,z1,z12,z0,z14)
79 sq_2=
funsq(
r2,r23,r0,r12,z2,z23,z0,z12)
80 sq_3=
funsq(r3,r34,r0,r23,z3,z34,z0,z23)
81 sq_4=
funsq(r4,r14,r0,r34,z4,z14,z0,z34)
125 cos_2=(dr12*dr23+dz12*dz23)/dlm2
127 vol_2=dlm2*sqrt(sin_2)*(r1+
r2+r4)/12.d0
130 cos_3=(dr34*dr23+dz34*dz23)/dlm3
132 vol_3=dlm3*sqrt(sin_3)*(
r2+r3+r4)/12.d0
137 cos_4=(dr34*dr14+dz34*dz14)/dlm4
139 vol_4=dlm4*sqrt(sin_4)*(r1+r3+r4)/12.d0
142 cos_1=(dr12*dr14+dz12*dz14)/dlm1
144 vol_1=dlm1*sqrt(sin_1)*(r1+
r2+r4)/12.d0
180 vol(i,j)=vol_1+vol_2+vol_3+vol_4
187 s(i,j)=sq_1+sq_2+sq_3+sq_4
210 dlr(i,j)=sqrt( (r(i+1,j)-r(i,j))**2+(z(i+1,j)-z(i,j))**2 )
220 dlt(i,j)=sqrt( (r(i,j+1)-r(i,j))**2+(z(i,j+1)-z(i,j))**2 )
234 r0=(r1+
r2+r3+r4)*0.25d0
245 z0=(z1+z2+z3+z4)*0.25d0
252 sq1(i,j)=
funsq(r1,r12,r0,r14,z1,z12,z0,z14)
253 sq2(i,j)=
funsq(
r2,r23,r0,r12,z2,z23,z0,z12)
254 sq3(i,j)=
funsq(r3,r34,r0,r23,z3,z34,z0,z23)
255 sq4(i,j)=
funsq(r4,r14,r0,r34,z4,z14,z0,z34)
257 s(i,j)=
funsq(r1,
r2,r3,r4,z1,z2,z3,z4)
259 vol1(i,j)=
funsq(r1,
r2,r4,r4,z1,z2,z4,z4)*(rm+rm+rm)/6.d0
260 vol2(i,j)=
funsq(r1,
r2,r3,r3,z1,z2,z3,z3)*(rm+rm+rm)/6.d0
261 vol3(i,j)=
funsq(
r2,r3,r4,r4,z2,z3,z4,z4)*(rm+rm+rm)/6.d0
262 vol4(i,j)=
funsq(r1,r3,r4,r4,z1,z3,z4,z4)*(rm+rm+rm)/6.d0
264 vol(i,j)=(vol1(i,j)+vol2(i,j)+vol3(i,j)+vol4(i,j))
269 dl12= (dr12**2+dz12**2)
273 dl14= (dr14**2+dz14**2)
277 dl23= (dr23**2+dz23**2)
281 dl34= (dr34**2+dz34**2)
284 cos2(i,j)=(dr12*dr23+dz12*dz23)/sqrt(dl12*dl23)
285 sin2(i,j)=1.-cos2(i,j)**2
287 cos3(i,j)=(dr34*dr23+dz34*dz23)/sqrt(dl34*dl23)
288 sin3(i,j)=1.-cos3(i,j)**2
292 cos4(i,j)=(dr34*dr14+dz34*dz14)/sqrt(dl34*dl14)
293 sin4(i,j)=1.-cos4(i,j)**2
295 cos1(i,j)=(dr12*dr14+dz12*dz14)/sqrt(dl12*dl14)
296 sin1(i,j)=1.-cos1(i,j)**2
344 common/com_rot/ ar1(nrp,ntp),ar2(nrp,ntp),ar3(nrp,ntp),
345 + ar4(nrp,ntp),ar5(nrp,ntp),ar6(nrp,ntp)
346 dimension b_tet(nrp,ntp),b_ro(nrp,ntp),rot_b(nrp,ntp)
347 dimension z_err(nrp,ntp)
354 ar1(i,j)= cos2(i-1,j-1)*vol2(i-1,j-1)/(sr(i,j-1)*sin2(i-1,j-1))
358 ar2(i,j)=( -cos2(i-1,j)/sr(i,j)-1.d0/st(i-1,j) )
359 & *vol2(i-1,j)/sin2(i-1,j) +
360 & ( -1.d0/st(i-1,j) )*vol1(i-1,j)/sin1(i-1,j)+
361 & ( cos3(i-1,j-1)/sr(i,j-1)-1.d0/st(i-1,j) )
362 & *vol3(i-1,j-1)/sin3(i-1,j-1) +
363 & ( -1.d0/st(i-1,j) )*vol4(i-1,j-1)/sin4(i-1,j-1)
367 ar3(i,j)=-cos3(i-1,j)*vol3(i-1,j)/(sr(i,j)*sin3(i-1,j))
371 ar4(i,j)= cos1(i,j-1)*vol1(i,j-1)/(sr(i,j-1)*sin1(i,j-1))
375 ar5(i,j)=( -cos1(i,j)/sr(i,j)+1.d0/st(i,j) )
376 & *vol1(i,j)/sin1(i,j) +
377 & ( 1.d0/st(i,j) )*vol2(i,j)/sin2(i,j)+
378 & ( cos4(i,j-1)/sr(i,j-1)+1.d0/st(i,j) )
379 & *vol4(i,j-1)/sin4(i,j-1) +
380 & ( 1.d0/st(i,j) )*vol3(i,j-1)/sin3(i,j-1)
385 ar6(i,j)=-cos4(i,j)*vol4(i,j)/(sr(i,j)*sin4(i,j))
395 b_ro(i,j)=(psi(i,j+1)-psi(i,j))/sr(i,j)
403 b_tet(i,j)=(psi(i+1,j)-psi(i,j))/st(i,j)
411 sqk=sq1(i,j)+sq2(i-1,j)+sq3(i-1,j-1)+sq4(i,j-1)
420 rot_b(i,j)=-( ar1(i,j)*bt1+ar2(i,j)*bt2+ar3(i,j)*bt3+
421 & ar4(i,j)*bt4+ar5(i,j)*bt5+ar6(i,j)*bt6 )/sqk
423 z_err(i,j)=rot_b(i,j)-cur(i,j)
438 common/comaaa/ a12(nrp,ntp),a23(nrp,ntp),a34(nrp,ntp),
439 + a14(nrp,ntp),a13(nrp,ntp),a24(nrp,ntp)
452 a12(i,j)=( (-1.d0/s12 + cos1(i,j)/s14)*vol1(i,j)/sin1(i,j) +
453 + (-1.d0/s12 - cos2(i,j)/s23)*vol2(i,j)/sin2(i,j) )/s12
455 a23(i,j)=( (-1.d0/s23 - cos2(i,j)/s12)*vol2(i,j)/sin2(i,j) +
456 + (-1.d0/s23 + cos3(i,j)/s34)*vol3(i,j)/sin3(i,j) )/s23
458 a34(i,j)=( (-1.d0/s34 + cos3(i,j)/s23)*vol3(i,j)/sin3(i,j) +
459 + (-1.d0/s34 - cos4(i,j)/s14)*vol4(i,j)/sin4(i,j) )/s34
461 a14(i,j)=( (-1.d0/s14 + cos1(i,j)/s12)*vol1(i,j)/sin1(i,j) +
462 + (-1.d0/s14 - cos4(i,j)/s34)*vol4(i,j)/sin4(i,j) )/s14
464 a13(i,j)= (cos2(i,j)/(s12*s23))*vol2(i,j)/sin2(i,j) +
465 + (cos4(i,j)/(s34*s14))*vol4(i,j)/sin4(i,j)
467 a24(i,j)= (-cos1(i,j)/(s12*s14))*vol1(i,j)/sin1(i,j) +
468 + (-cos3(i,j)/(s34*s23))*vol3(i,j)/sin3(i,j)
472 a12(i,j)=( (-1.d0/s12 - cos2(i,j)/s23)*vol2(i,j)/sin2(i,j) )/s12
474 a23(i,j)=( (-1.d0/s23 - cos2(i,j)/s12)*vol2(i,j)/sin2(i,j) +
475 + (-1.d0/s23 + cos3(i,j)/s34)*vol3(i,j)/sin3(i,j) )/s23
477 a34(i,j)=( (-1.d0/s34 + cos3(i,j)/s23)*vol3(i,j)/sin3(i,j) )/s34
479 a13(i,j)= (cos2(i,j)/(s12*s23))*vol2(i,j)/sin2(i,j)
481 a24(i,j)= (-cos3(i,j)/(s34*s23))*vol3(i,j)/sin3(i,j)
497 if(ngav.eq.0) cur_mu=tok*amu0
502 elseif(ngav.eq.2)
then
504 elseif(ngav.eq.-10 .AND. erru.lt.5.d-3)
then
505 call
promat_j(iplas,dfdpsi,
dpdpsi,f,flx_fi,psia,q,rm,psim,iter,
506 * kstep,fvac,psi_eav,pspl_av,psibon0,cur_mu )
507 elseif(ngav.eq.-1 .AND. erru.lt.5.d-3)
then
508 call
promat(iplas,dfdpsi,
dpdpsi,f,flx_fi,psia,q,rm,psim,iter,
509 * kstep,fvac,psi_eav,pspl_av,psibon0,cur_mu )
510 elseif(ngav.eq.-2 .AND. erru.lt.5.d-3)
then
511 call
promat(iplas,dfdpsi,
dpdpsi,f,flx_fi,psia,q,rm,psim,iter,
512 * kstep,fvac,psi_eav,pspl_av,psibon0,cur_mu )
513 elseif(ngav.eq.-3 .AND. erru.lt.5.d-3)
then
515 call
promat_i(iplas,dfdpsi,
dpdpsi,f,flx_fi,psia,q,rm,psim,iter,
516 * kstep,fvac,psi_eav,pspl_av,psibon0,cur_mu )
531 common/comaaa/ a12(nrp,ntp),a23(nrp,ntp),a34(nrp,ntp),
532 + a14(nrp,ntp),a13(nrp,ntp),a24(nrp,ntp)
534 common/compsf/ psf(nrp),sqtor(nrp)
536 dimension amn(nrp),a0(nrp),apl(nrp),capp(nrp)
537 dimension avrc(nrp),delsc(nrp),avrk(nrp),delsk(nrp),delv(nrp)
538 dimension bmn(nrp),b0(nrp),bpl(nrp),wrk1(nrp),wrk2(nrp)
539 dimension rhs(nrp),delv3(nrp)
540 dimension dfdpsn(nrp),delf(nrp)
541 dimension qs(nrp),qsn(nrp),psfn(nrp),dpsdas(nrp)
551 if(iter.eq.1) dfdpsn(i)=0.d0
577 r0=(r1+
r2+r3+r4)*0.25d0
580 zavrc=zavrc+s(i,j)/r0
592 sqtor(i)=sqtor(i-1)+delsc(i-1)
606 sqk=sq1(i,j)+sq2(i-1,j)+sq3(i-1,j-1)+sq4(i,j-1)
609 sqk=sq2(i-1,j)+sq3(i-1,j-1)
610 r0=(3.d0*r(i,j)+r(i-1,j))*0.25d0
615 zdelv3=zdelv3 +sqk*r0**3
638 a2=a34(i-1,j-1)+a12(i-1,j)
640 a4=a23(i-1,j-1)+a14(i,j-1)
641 a6=a14(i,j)+a23(i-1,j)
643 a8=a34(i,j-1)+a12(i,j)
645 a5=-(a1+a2+a3+a4+a6+a7+a8+a9)
657 qmn=-qs(i-1)/(avrc(i-1)*delsc(i-1))
658 qpl=-qs(i) / (avrc(i)*delsc(i))
659 qk=(qmn*dpsdas(i-1)+qpl*dpsdas(i))/(dpsdas(i-1)+dpsdas(i))
661 afmn=qk*qmn*avrk(i)*delsk(i)
662 afpl=qk*qpl*avrk(i)*delsk(i)
670 capp(i)=sapl*delsc(i)
672 if(i.eq.iplas-1)
then
675 capmn=samn*delsc(i-1)
699 rhs(i)=rhs(i)-
dpdpsi(i+1)*delv(i+1)-dwdpsi(i+1)*delv3(i+1)
706 rhs(1)=rhs(1)+amn(2)*psiax
707 rhs(npro)=rhs(npro)+apl(iplas-1)*psip
711 call
prog1d(npro,psf(2),bpl,bmn,b0,rhs,wrk1,wrk2)
723 psfn(i)=(psf(i)-psip)/(psiax-psip)
729 f(i)=-qs(i)*(psf(i+1)-psf(i))/(delsc(i)*avrc(i))
735 qmn=-qs(i-1)/(avrc(i-1)*delsc(i-1))
736 qpl=-qs(i)/(avrc(i)*delsc(i))
737 qk=(qmn*dpsdas(i-1)+qpl*dpsdas(i))/(dpsdas(i-1)+dpsdas(i))
739 dfdpsi(i)=qk*(f(i)-f(i-1))
752 acj=a12(1,j)+a24(1,j)+a34(1,j-1)+a13(1,j-1)
755 skcen=skcen+sq1(1,j)+sq4(1,j-1)
760 * ( (ac0*(psiax-psf(2)))/skcen-rm*
dpdpsi(1)-dwdpsi(1)*rm**3 )*rm
773 a2=a34(i-1,j-1)+a12(i-1,j)
785 call
extrpc( sqtor(i),capp(i),
786 * sqtor(i),sqtor(i-1),sqtor(i-2),sqtor(i-3),
787 * capp(i-1) ,capp(i-2) ,capp(i-3) )
800 * samn*(psip-psf(i-1))+avrk(i)*delsk(i)*dfdpsi(i)
801 * +delv(i)*
dpdpsi(i)+delv3(i)*dwdpsi(i)
804 f(i)=sqrt( f(i-1)**2+dfdpsi(i)*(psip-psf(i-1)) )
806 q(i)=-f(i)*avrk(i)/dpsids
808 write(6,*)
'q(iplas)=',q(i)
819 qmn=-q(i-1)/avrc(i-1)
823 q14=-0.5d0*(q(i)+q(i-1))
832 * ( samn*(psip-psf(i-1))
833 * +delv(i)*
dpdpsi(i)+delv3(i)*dwdpsi(i)-q14*f(i-1) )
837 dfdpsi(i)=(q14/avr14)*(f(i)-f(i-1))/delsk(i)
839 psiai=psia(i)-0.25d0*(psia(i)- psia(i-1))
841 call
extrp2( psiai,dfdpsi(i),
842 * psia(i-3),psia(i-2),psia(i-1),
843 * dfdpsi(i-3) ,dfdpsi(i-2) ,dfdpsi(i-1) )
846 f(i)=dsqrt(f(i-1)**2+dfdpsi(i)*(psip- psf(i-1)))
866 dfdpsi(i)=vrh*dfdpsi(i)+(1.d0-vrh)*dfdpsn(i)
872 delf(i)=dfdpsi(i)-dfdpsn(i)
884 dmon=(delf(i+1)-delf(i))/(delf(i)-delf(i-1))
887 if(dmon.lt.0.d0) wgt=0.5d0
889 delf(i)=wgt*delf(i)+(1.d0-wgt)*
890 * (delf(i-1)*(psf(i+1)-psf(i))+delf(i+1)*(psf(i)-psf(i-1)))/
891 * (psf(i+1)-psf(i-1))
899 dfdpsi(i)=dfdpsn(i)+delf(i)
929 common/comaaa/ a12(nrp,ntp),a23(nrp,ntp),a34(nrp,ntp),
930 + a14(nrp,ntp),a13(nrp,ntp),a24(nrp,ntp)
932 common/compsf/ psf(nrp),sqtor(nrp)
934 dimension amn(nrp),a0(nrp),apl(nrp),qcapp(nrp)
935 dimension avrc(nrp),delsc(nrp),avrk(nrp),delsk(nrp),delv(nrp)
936 dimension bmn(nrp),b0(nrp),bpl(nrp),wrk1(nrp),wrk2(nrp)
937 dimension rhs(nrp),delv3(nrp)
938 dimension dfdpsn(nrp),vw(nrp)
939 dimension dfdpsw(nrp),delf(nrp)
947 psf(i)=psia(i)*(psim-psip)+psip
965 r0=(r1+
r2+r3+r4)*0.25d0
968 zavrc=zavrc+s(i,j)/r0
983 sqtor(i)=sqtor(i-1)+delsc(i-1)
1002 sqk=sq1(i,j)+sq2(i-1,j)+sq3(i-1,j-1)+sq4(i,j-1)
1007 sqk=sq2(i-1,j)+sq3(i-1,j-1)
1008 r0=(3.d0*r(i,j)+r(i-1,j))*0.25d0
1014 zdelv3=zdelv3 +sqk*r0**3
1019 avrk(i)=zavrk/zdelsk
1036 a2=a34(i-1,j-1)+a12(i-1,j)
1038 a4=a23(i-1,j-1)+a14(i,j-1)
1039 a6=a14(i,j)+a23(i-1,j)
1041 a8=a34(i,j-1)+a12(i,j)
1043 a5=-(a1+a2+a3+a4+a6+a7+a8+a9)
1055 qmn=-q(i-1)/(avrc(i-1)*delsc(i-1))
1056 qpl=-q(i) / (avrc(i)*delsc(i))
1057 qk=(qmn*dpsda(i-1)+qpl*dpsda(i))/(dpsda(i-1)+dpsda(i))
1059 afmn=qk*qmn*avrk(i)*delsk(i)
1060 afpl=qk*qpl*avrk(i)*delsk(i)
1070 if(i.eq.iplas-1)
then
1089 zff=amn(i)*psf(i-1)+a0(i)*psf(i)+apl(i)*psf(i+1)
1091 zdfdps=( zff-
dpdpsi(i)*delv(i)-dwdpsi(i)*delv3(i) )
1092 * /(avrk(i)*delsk(i))
1097 deldf=dabs(zdfdps-dfdpsn(i))
1103 errdf=dmax1(deldf,errdf)
1154 f2n1=(amu0*tok*qcapp(iplas-1))**2
1155 f(iplas-1)=dsqrt(f2n1)
1159 f(i-1)=dsqrt( f(i)**2-dfdpsi(i)*(psf(i+1)-psf(i-1)) )
1167 dftor=f(i)*delsc(i)*avrc(i)
1169 psf(i)=psf(i+1)+delpsi
1179 zff=amn(i)*psf(i-1)+a0(i)*psf(i)+apl(i)*psf(i+1)
1181 dfdpsi(i)=( zff-
dpdpsi(i)*delv(i)-dwdpsi(i)*delv3(i) )
1182 * /(avrk(i)*delsk(i))
1183 deldf=dabs(dfdpsi(i)-dfdpsn(i))
1188 errdf=dmax1(deldf,errdf)
1196 if(errdf.gt.1.d-7) go to 736
1200 call
extrp2( psia(i),dfdpsi(i),
1201 * psia(i-3),psia(i-2),psia(i-1),
1202 * dfdpsi(i-3) ,dfdpsi(i-2) ,dfdpsi(i-1) )
1213 acj=a12(1,j)+a24(1,j)+a34(1,j-1)+a13(1,j-1)
1216 skcen=skcen+sq1(1,j)+sq4(1,j-1)
1220 dfdpsi(1)=( ac0*(psf(1)-psf(2))/skcen
1221 * -rm*
dpdpsi(1)-dwdpsi(1)*rm**3 )*rm
1226 delf(i)=dfdpsi(i)-dfdpsw(i)
1238 dmon=(delf(i+1)-delf(i))/(delf(i)-delf(i-1))
1241 if(dmon.lt.0.d0) wgt=0.5d0
1243 delf(i)=wgt*delf(i)+(1.d0-wgt)*
1244 * (delf(i-1)*(psf(i+1)-psf(i))+delf(i+1)*(psf(i)-psf(i-1)))/
1245 * (psf(i+1)-psf(i-1))
1253 dfdpsi(i)=dfdpsw(i)+delf(i)
1277 include
'double.inc'
1279 include
'compol.inc'
1282 dimension ax(nrp),gr_a(nrp)
1283 dimension delsc(nrp),delv(nrp),dvda(nrp)
1290 ax(i)=(i-1.d0)/(iplas-1.d0)
1316 dadr=dadr+0.5d0*(u1+u2)*(z2-z1)
1317 dadz=dadz-0.5d0*(u1+u2)*(
r2-r1)
1319 sss=sss+
funsq(r1,
r2,0.d0,0.d0,z1,z2,0.d0,0.d0)
1320 sqk=sq1(i,j)+sq4(i,j-1)
1321 zdelv=zdelv +sqk*r(1,2)
1328 gr_a(1)=dadr**2+dadz**2
1362 sss=
funsq(r1,
r2,r3,r4,z1,z2,z3,z4)
1364 dadr= 0.5d0*((u1+u2)*(z2-z1)+(u2+u3)*(z3-z2)+
1365 * (u3+u4)*(z4-z3)+(u4+u1)*(z1-z4))/sss
1367 dadz=-0.5d0*((u1+u2)*(
r2-r1)+(u2+u3)*(r3-
r2)+
1368 * (u3+u4)*(r4-r3)+(u4+u1)*(r1-r4))/sss
1373 sqk=sq1(i,j)+sq2(i-1,j)+sq3(i-1,j-1)+sq4(i,j-1)
1376 sqk=sq2(i-1,j)+sq3(i-1,j-1)
1377 r0=(3.d0*r(i,j)+r(i-1,j))*0.25d0
1381 zavgr=zavgr+gr2*sqk*r0
1389 dvda(i)=(delv(i+1)-delv(i))/(ax(i+1)-ax(i))
1403 include
'double.inc'
1405 include
'compol.inc'
1407 dimension qs(1),psfn(1)
1414 psx=0.5d0*(psfn(i)+psfn(i+1))
1421 ps0=0.5d0*(psia(is)+psia(is+1))
1423 if(is.ne.iplas1)
then
1425 pspl=0.5d0*(psia(is+1)+psia(is+2))
1433 if(psx.le.ps0 .AND. psx.ge.pspl)
then
1435 qs(i)=(q0*(pspl-psx)+qpl*(psx-ps0))/(pspl-ps0)
subroutine extrpc(X, F, X0, X1, X2, X3, F1, F2, F3)
REAL *8 function funsq(R1, R2, R3, R4, Z1, Z2, Z3, Z4)
subroutine qunew(qs, psfn)
subroutine procof(icq, cur_mu)
subroutine prog1d(M, U, A, B, C, F, ALF, BET)
subroutine promat(n, dfdpsi, dpdpsi, f, flx_fi, psia, q, rm, psim, iter, kstep, fvac, psi_eav, pspl_av, psibon0, cur_mu)
real(r8) function dpdpsi(psi_n)
subroutine procof_fl(icq)
subroutine extrp2(X, F, X1, X2, X3, F1, F2, F3)
subroutine psib_pla(pspl_av)
real(r8) function r2(a, x, xr, xs, yr, ys, psi, psir, F_dia)
subroutine promat_i(n, dfdpsi, dpdpsi, f, flx_fi, psia, q, rm, psim, iter, kstep, fvac, psi_eav, pspl_av, psibon0, tok)
subroutine promat_j(n, dfdpsi, dpdpsi, f, flx_fi, psia, q, rm, psim, iter, kstep, fvac, psi_eav, pspl_av, psibon0, cur_mu)