30 use,
intrinsic :: ieee_arithmetic, only: ieee_is_finite
32 integer,
intent(in) :: iw_b(3)
35 double precision :: bvec(ixglo1:ixghi1,ixglo2:ixghi2,&
37 double precision :: current(ixglo1:ixghi1,ixglo2:ixghi2,&
39 double precision :: divb(ixglo1:ixghi1,ixglo2:ixghi2,ixglo3:ixghi3)
40 double precision :: local(5),global(5),b(3),j(3),jxb(3)
41 double precision :: b2,j2,jxb2,volume,hcell
42 integer :: iigrid,igrid,ix1,ix2,ix3,idirmin
45 do iigrid=1,igridstail
50 bvec(:,:,:,1:3)=ps(igrid)%w(:,:,:,iw_b(:))
51 if(
b0field) bvec(:,:,:,1:3)=bvec(:,:,:,1:3)+&
52 block%B0(:,:,:,iw_b(:),0)
62 j=current(ix1,ix2,ix3,:)
66 jxb2=dot_product(jxb,jxb)
67 volume=
block%dvolume(ix1,ix2,ix3)
68 hcell=volume**(1.d0/3.d0)
70 local(1)=local(1)+dsqrt(jxb2/b2)*volume
71 local(3)=local(3)+hcell**2*jxb2/b2*volume
73 local(2)=local(2)+dsqrt(j2)*volume
74 local(4)=local(4)+hcell**2*divb(ix1,ix2,ix3)**2*volume
75 local(5)=local(5)+b2*volume
80 call mpi_allreduce(local,global,5,mpi_double_precision,mpi_sum,&
82 if(.not.all(ieee_is_finite(global))) &
83 call mpistop(
'non-finite common NLFFF diagnostic')
85 if(global(2)>0.d0)
metrics%cw_sin_theta=global(1)/global(2)
86 if(global(5)>0.d0)
then
87 metrics%epsilon_force=dsqrt(max(0.d0,global(3))/global(5))
88 metrics%epsilon_div=dsqrt(max(0.d0,global(4))/global(5))
90 metrics%magnetic_energy=0.5d0*global(5)
96 use,
intrinsic :: ieee_arithmetic, only: ieee_is_finite
98 double precision,
intent(in) :: b(:,:,:,:),dx1,dx2,dx3
100 double precision :: db(3,3),j(3),bv(3),jxb(3),divb,b2,j2,jxb2
101 double precision :: sum_cross,sum_j,sum_force,sum_div,sum_b2,h,volume
104 sum_cross=0.d0; sum_j=0.d0; sum_force=0.d0
105 sum_div=0.d0; sum_b2=0.d0
106 h=(dx1*dx2*dx3)**(1.d0/3.d0)
112 db(ic,1)=dense_derivative(b(:,jj,k,ic),i,dx1)
113 db(ic,2)=dense_derivative(b(i,:,k,ic),jj,dx2)
114 db(ic,3)=dense_derivative(b(i,jj,:,ic),k,dx3)
116 j=(/db(3,2)-db(2,3),db(1,3)-db(3,1),db(2,1)-db(1,2)/)
118 jxb=nlfff_cross3(j,bv)
119 b2=dot_product(bv,bv)
121 jxb2=dot_product(jxb,jxb)
123 sum_cross=sum_cross+dsqrt(jxb2/b2)*volume
124 sum_force=sum_force+h**2*jxb2/b2*volume
126 sum_j=sum_j+dsqrt(j2)*volume
127 divb=db(1,1)+db(2,2)+db(3,3)
128 sum_div=sum_div+h**2*divb**2*volume
129 sum_b2=sum_b2+b2*volume
133 if(.not.ieee_is_finite(sum_cross+sum_j+sum_force+sum_div+sum_b2)) &
134 error stop
'non-finite common dense NLFFF diagnostic'
136 if(sum_j>0.d0)
metrics%cw_sin_theta=sum_cross/sum_j
138 metrics%epsilon_force=dsqrt(max(0.d0,sum_force)/sum_b2)
139 metrics%epsilon_div=dsqrt(max(0.d0,sum_div)/sum_b2)
141 metrics%magnetic_energy=0.5d0*sum_b2
subroutine curlvector(qvec, ixil, ixol, curlvec, idirmin, idirmin0, ndir0, fourthorder)
Calculate curl of a vector qvec within ixL Options to employ standard second order CD evaluations use...
subroutine, public evaluate_nlfff_metrics_dense(b, dx1, dx2, dx3, metrics)
Evaluate the same metrics on a replicated uniform dense field. Plane 1 is the lower boundary and plan...