@@ -114,9 +114,9 @@ Subroutine Custom_MHD_Diagnostics(buffer)
114114 Real * 8 , Allocatable :: buff1(:,:,:,:),buff2(:,:,:,:)
115115 Real * 8 , Allocatable :: inducttmp(:,:,:,:), sheartmp(:,:,:,:), advtmp(:,:,:,:), comptmp(:,:,:,:), bfieldtmp(:,:,:,:)
116116 Real * 8 , Allocatable :: sheartmp1(:,:,:,:), sheartmp2(:,:,:,:)
117- Real * 8 , Allocatable :: advtmp1(:,:,:,:), advtmp2(:,:,:,:), advtmp3(:,:,:,:), advtmp4(:,:,:,:), advtmp5(:,:,:,:)
117+ Real * 8 , Allocatable :: advtmp1(:,:,:,:), advtmp2(:,:,:,:), advtmp3(:,:,:,:)
118118 Real * 8 , Allocatable :: comptmp1(:,:,:,:), comptmp2(:,:,:,:)
119-
119+ Real * 8 , Allocatable :: divv_r(:,:,:), divv_theta(:,:,:), divv_phi(:,:,:)
120120
121121 Real * 8 :: del2b
122122 Real * 8 , Allocatable :: ovstheta(:), ovs2theta(:)
@@ -146,12 +146,14 @@ Subroutine Custom_MHD_Diagnostics(buffer)
146146 Allocate (advtmp1(1 :n_phi,my_r% min:my_r% max,my_theta% min:my_theta% max,1 :3 ))
147147 Allocate (advtmp2(1 :n_phi,my_r% min:my_r% max,my_theta% min:my_theta% max,1 :3 ))
148148 Allocate (advtmp3(1 :n_phi,my_r% min:my_r% max,my_theta% min:my_theta% max,1 :3 ))
149- Allocate (advtmp4(1 :n_phi,my_r% min:my_r% max,my_theta% min:my_theta% max,1 :3 ))
150- Allocate (advtmp5(1 :n_phi,my_r% min:my_r% max,my_theta% min:my_theta% max,1 :3 ))
151149
152150 Allocate (comptmp1(1 :n_phi,my_r% min:my_r% max,my_theta% min:my_theta% max,1 :3 ))
153151 Allocate (comptmp2(1 :n_phi,my_r% min:my_r% max,my_theta% min:my_theta% max,1 :3 ))
154152
153+ Allocate (divv_r(1 :n_phi,my_r% min:my_r% max,my_theta% min:my_theta% max))
154+ Allocate (divv_theta(1 :n_phi,my_r% min:my_r% max,my_theta% min:my_theta% max))
155+ Allocate (divv_phi(1 :n_phi,my_r% min:my_r% max,my_theta% min:my_theta% max))
156+
155157 ovstheta = 1.0d0 / sintheta
156158 ovs2theta = 1.0d0 / sin2theta
157159
@@ -1110,36 +1112,39 @@ Subroutine Custom_MHD_Diagnostics(buffer)
11101112 advtmp1(PSI,1 ) = - buff1(PSI,vr)* buff2(PSI,dbrdr)
11111113 advtmp2(PSI,1 ) = - buff1(PSI,vtheta)* buff2(PSI,dbrdt)/ radius(r)
11121114 advtmp3(PSI,1 ) = - buff1(PSI,vphi)* buff2(PSI,dbrdp)/ radius(r)/ sintheta(t)
1113- advtmp4(PSI,1 ) = - 2.0d0 * buff1(PSI,vr)* buff2(PSI,br)/ radius(r)
1114- advtmp5(PSI,1 ) = 0.0d0
11151115
11161116 advtmp1(PSI,2 ) = - buff1(PSI,vr)* buff2(PSI,dbtdr)
11171117 advtmp2(PSI,2 ) = - buff1(PSI,vtheta)* buff2(PSI,dbtdt)/ radius(r)
11181118 advtmp3(PSI,2 ) = - buff1(PSI,vphi)* buff2(PSI,dbtdp)/ radius(r)/ sintheta(t)
1119- advtmp4(PSI,2 ) = buff1(PSI,vr)* buff2(PSI,btheta)/ radius(r)
1120- advtmp5(PSI,2 ) = - buff1(PSI,vtheta)* buff2(PSI,btheta)* cottheta(t)/ radius(r)
11211119
11221120 advtmp1(PSI,3 ) = - buff1(PSI,vr)* buff2(PSI,dbpdr)
11231121 advtmp2(PSI,3 ) = - buff1(PSI,vtheta)* buff2(PSI,dbpdt)/ radius(r)
11241122 advtmp3(PSI,3 ) = - buff1(PSI,vphi)* buff2(PSI,dbpdp)/ radius(r)/ sintheta(t)
1125- advtmp4(PSI,3 ) = buff1(PSI,vr)* buff2(PSI,bphi)/ radius(r)
1126- advtmp5(PSI,3 ) = buff1(PSI,vtheta)* buff2(PSI,bphi)* cottheta(t)/ radius(r)
11271123
11281124 Do j = 1 ,3
1129- advtmp(PSI,j) = advtmp1(PSI,j) + advtmp2(PSI,j) + advtmp3(PSI,j) + &
1130- &advtmp4(PSI,j) + advtmp5(PSI,j)
1125+ advtmp(PSI,j) = advtmp1(PSI,j) + advtmp2(PSI,j) + advtmp3(PSI,j)
11311126 Enddo
11321127 END_DO
11331128
11341129 ! get compression
11351130 ! ALTERNATE compression: -B (div v) (but TRANSVERSE compression only)
1131+ ! 3 parts: transverse to r, theta, phi (do this separately, I think it
1132+ ! sums to the right thing
11361133 DO_PSI
1137- comptmp1(PSI,1 ) = - buff2(PSI,br)* (buff1(PSI,dvtdt)+ buff1(PSI,vtheta)* cottheta(t))/ radius(r)
1138- comptmp2(PSI,1 ) = - buff2(PSI,br)* buff1(PSI,dvpdp)/ radius(r)/ sintheta(t)
1139- comptmp1(PSI,2 ) = - buff2(PSI,btheta)* (buff1(PSI,dvrdr)+ 2.0d0 * buff1(PSI,vr)/ radius(r))
1140- comptmp2(PSI,2 ) = - buff2(PSI,btheta)* buff1(PSI,dvpdp)/ radius(r)/ sintheta(t)
1141- comptmp1(PSI,3 ) = - buff2(PSI,bphi)* (buff1(PSI,dvrdr)+ 2.0d0 * buff1(PSI,vr)/ radius(r))
1142- comptmp2(PSI,3 ) = - buff2(PSI,bphi)* (buff1(PSI,dvtdt)+ buff1(PSI,vtheta)* cottheta(t))/ radius(r)
1134+ divv_r(PSI) = - buff1(PSI, dvrdr)
1135+ divv_theta(PSI) = - (buff1(PSI,dvtdt)+ buff1(PSI,vr))/ radius(r)
1136+ divv_phi(PSI) = - (buff1(PSI,dvpdp)/ sintheta(t) + &
1137+ &buff1(PSI,vr) + cottheta(t)* buff1(PSI,vtheta))/ radius(r)
1138+
1139+ comptmp1(PSI,1 ) = buff2(PSI,br)* divv_theta(PSI)
1140+ comptmp2(PSI,1 ) = buff2(PSI,br)* divv_phi(PSI)
1141+
1142+ comptmp1(PSI,2 ) = buff2(PSI,btheta)* divv_r(PSI)
1143+ comptmp2(PSI,2 ) = buff2(PSI,btheta)* divv_phi(PSI)
1144+
1145+ comptmp1(PSI,3 ) = buff2(PSI,bphi)* divv_r(PSI)
1146+ comptmp2(PSI,3 ) = buff2(PSI,bphi)* divv_theta(PSI)
1147+
11431148 Do j = 1 ,3
11441149 comptmp(PSI,j) = comptmp1(PSI,j) + comptmp2(PSI,j)
11451150 Enddo
@@ -1226,18 +1231,6 @@ Subroutine Custom_MHD_Diagnostics(buffer)
12261231 END_DO
12271232 Call Add_Quantity(qty)
12281233 Endif
1229- If (compute_quantity(ialtadvec_work_r4 + j-1 + offset2)) Then
1230- DO_PSI
1231- qty(PSI) = advtmp4(PSI,j)* bfieldtmp(PSI,j)
1232- END_DO
1233- Call Add_Quantity(qty)
1234- Endif
1235- If (compute_quantity(ialtadvec_work_r5+ j-1 + offset2)) Then
1236- DO_PSI
1237- qty(PSI) = advtmp5(PSI,j)* bfieldtmp(PSI,j)
1238- END_DO
1239- Call Add_Quantity(qty)
1240- Endif
12411234
12421235 ! Comp. terms
12431236 If (compute_quantity(ialtcomp_work_r1+ j-1 + offset2)) Then
@@ -1325,18 +1318,6 @@ Subroutine Custom_MHD_Diagnostics(buffer)
13251318 END_DO
13261319 Call Add_Quantity(qty)
13271320 Endif
1328- If (compute_quantity(ialtadvec_r4 + j-1 + offset2)) Then
1329- DO_PSI
1330- qty(PSI) = advtmp4(PSI,j)
1331- END_DO
1332- Call Add_Quantity(qty)
1333- Endif
1334- If (compute_quantity(ialtadvec_r5+ j-1 + offset2)) Then
1335- DO_PSI
1336- qty(PSI) = advtmp5(PSI,j)
1337- END_DO
1338- Call Add_Quantity(qty)
1339- Endif
13401321
13411322 ! Comp. terms
13421323 If (compute_quantity(ialtcomp_r1+ j-1 + offset2)) Then
@@ -1376,12 +1357,14 @@ Subroutine Custom_MHD_Diagnostics(buffer)
13761357 DeAllocate (advtmp1)
13771358 DeAllocate (advtmp2)
13781359 DeAllocate (advtmp3)
1379- DeAllocate (advtmp4)
1380- DeAllocate (advtmp5)
13811360
13821361 DeAllocate (comptmp1)
13831362 DeAllocate (comptmp2)
13841363
1364+ DeAllocate (divv_r)
1365+ DeAllocate (divv_theta)
1366+ DeAllocate (divv_phi)
1367+
13851368 ! Edit Above This Line
13861369 ! =============================================
13871370
0 commit comments