00001 subroutine iteration_WL(iter_count)
00002 use phys_constant, only : long, nnrg, nntg, nnpg
00003 use def_formulation, only : chgra, chope
00004 use def_metric_hij, only : hxxd, hxyd, hxzd, hyyd, hyzd, hzzd
00005 use grid_parameter
00006 use coordinate_grav_r
00007 use coordinate_grav_phi
00008 use coordinate_grav_theta
00009 use weight_midpoint_grav
00010 use make_array_2d
00011 use make_array_3d
00012 use make_array_4d
00013 use def_metric
00014 use def_matter
00015 use interface_interpo_fl2gr
00016 use interface_poisson_solver
00017
00018
00019
00020 use interface_compute_shift
00021 use interface_compute_alps2alph
00022 use interface_hydrostatic_eq_WL_peos
00023 use interface_calc_surface
00024 use interface_update_grfield
00025 use interface_update_matter
00026 use interface_update_parameter_WL_peos
00027 use interface_update_surface
00028 use interface_error_matter
00029 use interface_source_HaC_WL
00030 use interface_source_MoC_WL
00031 use interface_source_trfreeG_WL
00032 use interface_source_trG_WL
00033 use interface_error_metric_type0
00034 use interface_error_metric_type2
00035 implicit none
00036 real(long), pointer :: sou(:,:,:), pot(:,:,:), sou2(:,:,:)
00037 real(long), pointer :: potf(:,:,:), emd_bak(:,:,:), pot_bak(:,:,:)
00038 real(long), pointer :: potrs(:,:)
00039 real(long), pointer :: potx(:,:,:), poty(:,:,:), potz(:,:,:)
00040 real(long), pointer :: potx_bak(:,:,:), poty_bak(:,:,:), potz_bak(:,:,:)
00041 real(long), pointer :: souvec(:,:,:,:), souten(:,:,:,:)
00042 real(long), pointer :: pot1(:,:,:), pot2(:,:,:), pot3(:,:,:)
00043 real(long), pointer :: pot4(:,:,:), pot5(:,:,:), pot6(:,:,:)
00044 real(long), pointer :: bk1(:,:,:), bk2(:,:,:), bk3(:,:,:)
00045 real(long), pointer :: bk4(:,:,:), bk5(:,:,:), bk6(:,:,:)
00046 real(long), pointer :: work(:,:,:)
00047
00048 real(long) :: error_emd, count
00049 integer :: iter_count, flag = 0, hydro_iter = 4
00050 integer :: irf, itf, ipf, irg, itg, ipg, ihy
00051
00052 real(long) :: error_all(20)
00053 integer :: flag_all(20) = (/0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0/)
00054
00055 call alloc_array3d(sou,0,nrg,0,ntg,0,npg)
00056 call alloc_array3d(pot,0,nrg,0,ntg,0,npg)
00057 call alloc_array3d(sou2,0,nrg,0,ntg,0,npg)
00058 call alloc_array3d(potf,0,nrf,0,ntf,0,npf)
00059 call alloc_array3d(emd_bak,0,nrf,0,ntf,0,npf)
00060 call alloc_array2d(potrs,0,ntf,0,npf)
00061 call alloc_array3d(potx,0,nrg,0,ntg,0,npg)
00062 call alloc_array3d(poty,0,nrg,0,ntg,0,npg)
00063 call alloc_array3d(potz,0,nrg,0,ntg,0,npg)
00064 call alloc_array4d(souvec,0,nrg,0,ntg,0,npg,1,3)
00065 call alloc_array4d(souten,0,nrg,0,ntg,0,npg,1,6)
00066 call alloc_array3d(pot1,0,nrg,0,ntg,0,npg)
00067 call alloc_array3d(pot2,0,nrg,0,ntg,0,npg)
00068 call alloc_array3d(pot3,0,nrg,0,ntg,0,npg)
00069 call alloc_array3d(pot4,0,nrg,0,ntg,0,npg)
00070 call alloc_array3d(pot5,0,nrg,0,ntg,0,npg)
00071 call alloc_array3d(pot6,0,nrg,0,ntg,0,npg)
00072 call alloc_array3d(pot_bak,0,nrg,0,ntg,0,npg)
00073 call alloc_array3d(potx_bak,0,nrg,0,ntg,0,npg)
00074 call alloc_array3d(poty_bak,0,nrg,0,ntg,0,npg)
00075 call alloc_array3d(potz_bak,0,nrg,0,ntg,0,npg)
00076 call alloc_array3d(bk1,0,nrg,0,ntg,0,npg)
00077 call alloc_array3d(bk2,0,nrg,0,ntg,0,npg)
00078 call alloc_array3d(bk3,0,nrg,0,ntg,0,npg)
00079 call alloc_array3d(bk4,0,nrg,0,ntg,0,npg)
00080 call alloc_array3d(bk5,0,nrg,0,ntg,0,npg)
00081 call alloc_array3d(bk6,0,nrg,0,ntg,0,npg)
00082 call alloc_array3d(work,0,nrg,0,ntg,0,npg)
00083
00084 iter_count = 0
00085 do
00086 iter_count = iter_count + 1
00087 count = dble(iter_count)
00088 conv_gra = dmin1(conv0_gra,conv_ini*count)
00089 conv_den = dmin1(conv0_den,conv_ini*count)
00090
00091 emdg = 0.0d0
00092 call interpo_fl2gr(emd, emdg)
00093
00094 call calc_vector_x_grav(1)
00095 call calc_vector_x_matter(1)
00096 call calc_vector_phi_grav(1)
00097 call calc_vector_phi_matter(1)
00098 call calc_shift_down2up
00099 call calc_shift2rotshift
00100
00101
00102 if (chgra == 'i') call cleargeometry
00103 if (chgra /= 'i') then
00104 call cristoffel_midpoint
00105 call cristoffel_gridpoint
00106 call riccitensor_midpoint
00107 end if
00108 if (chgra == 'h'.or.chgra == 'c'.or.chgra == 'C' &
00109 &.or.chgra == 'H'.or.chgra == 'W') then
00110 call liegmab_midpoint
00111 call liegmab_gridpoint
00112 end if
00113
00114 call excurve_WL_midpoint
00115 call excurve_WL_gridpoint
00116 call ap2alps
00117
00118
00119 call source_HaC_WL(sou)
00120
00121 call poisson_solver(sou,pot)
00122 pot(0:nrg,0:ntg,0:npg) = pot(0:nrg,0:ntg,0:npg) + 1.0d0
00123 pot_bak(0:nrg,0:ntg,0:npg) = psi(0:nrg,0:ntg,0:npg)
00124 call update_grfield(pot,psi,conv_gra)
00125 call update_parameter_WL_peos(conv_den)
00126 call error_metric_type0(psi,pot_bak,error_all(1),flag_all(1),'ns')
00127
00128
00129 call source_trG_WL(sou)
00130 call poisson_solver(sou,pot)
00131 pot(0:nrg,0:ntg,0:npg) = pot(0:nrg,0:ntg,0:npg) + 1.0d0
00132 pot_bak(0:nrg,0:ntg,0:npg) = alph(0:nrg,0:ntg,0:npg)
00133 call compute_alps2alph(pot,psi)
00134 call update_grfield(pot,alph,conv_gra)
00135 call update_parameter_WL_peos(conv_den)
00136 call error_metric_type0(alph,pot_bak,error_all(2),flag_all(2),'ns')
00137
00138 call printout_error_metric_combined_2(iter_count,error_all(1),error_all(2))
00139
00140 call source_MoC_WL(souvec,sou)
00141 work(1:nrg, 1:ntg, 1:npg) = souvec(1:nrg, 1:ntg, 1:npg, 1)
00142 sou2(1:nrg, 1:ntg, 1:npg) = work(1:nrg, 1:ntg, 1:npg)
00143 call poisson_solver(sou2,potx)
00144 work(1:nrg, 1:ntg, 1:npg) = souvec(1:nrg, 1:ntg, 1:npg, 2)
00145 sou2(1:nrg, 1:ntg, 1:npg) = work(1:nrg, 1:ntg, 1:npg)
00146 call poisson_solver(sou2,poty)
00147 work(1:nrg, 1:ntg, 1:npg) = souvec(1:nrg, 1:ntg, 1:npg, 3)
00148 sou2(1:nrg, 1:ntg, 1:npg) = work(1:nrg, 1:ntg, 1:npg)
00149 call poisson_solver(sou2,potz)
00150 call poisson_solver(sou,pot)
00151 work( 0:nrg, 0:ntg, 0:npg) = potx(0:nrg, 0:ntg, 0:npg)
00152 souvec(0:nrg, 0:ntg, 0:npg, 1) = work(0:nrg, 0:ntg, 0:npg)
00153 work( 0:nrg, 0:ntg, 0:npg) = poty(0:nrg, 0:ntg, 0:npg)
00154 souvec(0:nrg, 0:ntg, 0:npg, 2) = work(0:nrg, 0:ntg, 0:npg)
00155 work( 0:nrg, 0:ntg, 0:npg) = potz(0:nrg, 0:ntg, 0:npg)
00156 souvec(0:nrg, 0:ntg, 0:npg, 3) = work(0:nrg, 0:ntg, 0:npg)
00157 call compute_shift(potx, poty, potz, souvec, pot)
00158
00159 potx_bak = bvxd
00160 poty_bak = bvyd
00161 potz_bak = bvzd
00162 call update_grfield(potx,bvxd,conv_gra)
00163 call update_grfield(poty,bvyd,conv_gra)
00164 call update_grfield(potz,bvzd,conv_gra)
00165 call update_parameter_WL_peos(conv_den)
00166 call error_metric_type2(bvxd,potx_bak,error_all(3),flag_all(3),'ns')
00167 call error_metric_type2(bvyd,poty_bak,error_all(4),flag_all(4),'ns')
00168 call error_metric_type2(bvzd,potz_bak,error_all(5),flag_all(5),'ns')
00169 call printout_error_metric_combined_3(iter_count,error_all(3), &
00170 & error_all(4),error_all(5))
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183 call source_trfreeG_WL(souten)
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193 bk1(0:nrg,0:ntg,0:npg) = hxxd(0:nrg,0:ntg,0:npg)
00194 bk2(0:nrg,0:ntg,0:npg) = hxyd(0:nrg,0:ntg,0:npg)
00195 bk3(0:nrg,0:ntg,0:npg) = hxzd(0:nrg,0:ntg,0:npg)
00196 bk4(0:nrg,0:ntg,0:npg) = hyyd(0:nrg,0:ntg,0:npg)
00197 bk5(0:nrg,0:ntg,0:npg) = hyzd(0:nrg,0:ntg,0:npg)
00198 bk6(0:nrg,0:ntg,0:npg) = hzzd(0:nrg,0:ntg,0:npg)
00199 hxxd(0:nrg,0:ntg,0:npg) = 0.0d0
00200 hxyd(0:nrg,0:ntg,0:npg) = 0.0d0
00201 hxzd(0:nrg,0:ntg,0:npg) = 0.0d0
00202 hyyd(0:nrg,0:ntg,0:npg) = 0.0d0
00203 hyzd(0:nrg,0:ntg,0:npg) = 0.0d0
00204 hzzd(0:nrg,0:ntg,0:npg) = 0.0d0
00205
00206
00207
00208 if (chope == 'L') then
00209
00210 sou(0:nrg,0:ntg,0:npg) = souten(0:nrg,0:ntg,0:npg,1)
00211 call poisson_solver(sou,pot1)
00212 sou(0:nrg,0:ntg,0:npg) = souten(0:nrg,0:ntg,0:npg,2)
00213 call poisson_solver(sou,pot2)
00214 sou(0:nrg,0:ntg,0:npg) = souten(0:nrg,0:ntg,0:npg,3)
00215 call poisson_solver(sou,pot3)
00216 sou(0:nrg,0:ntg,0:npg) = souten(0:nrg,0:ntg,0:npg,4)
00217 call poisson_solver(sou,pot4)
00218 sou(0:nrg,0:ntg,0:npg) = souten(0:nrg,0:ntg,0:npg,5)
00219 call poisson_solver(sou,pot5)
00220 sou(0:nrg,0:ntg,0:npg) = souten(0:nrg,0:ntg,0:npg,6)
00221 call poisson_solver(sou,pot6)
00222
00223 end if
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237 hxxd(0:nrg,0:ntg,0:npg) = pot1(0:nrg,0:ntg,0:npg)
00238 hxyd(0:nrg,0:ntg,0:npg) = pot2(0:nrg,0:ntg,0:npg)
00239 hxzd(0:nrg,0:ntg,0:npg) = pot3(0:nrg,0:ntg,0:npg)
00240 hyyd(0:nrg,0:ntg,0:npg) = pot4(0:nrg,0:ntg,0:npg)
00241 hyzd(0:nrg,0:ntg,0:npg) = pot5(0:nrg,0:ntg,0:npg)
00242 hzzd(0:nrg,0:ntg,0:npg) = pot6(0:nrg,0:ntg,0:npg)
00243
00244
00245
00246
00247
00248
00249
00250 call invhij
00251 call gauge_hiju
00252 call invhij_up2down
00253 call adjusthij
00254
00255
00256
00257 pot1(0:nrg,0:ntg,0:npg) = hxxd(0:nrg,0:ntg,0:npg)
00258 pot2(0:nrg,0:ntg,0:npg) = hxyd(0:nrg,0:ntg,0:npg)
00259 pot3(0:nrg,0:ntg,0:npg) = hxzd(0:nrg,0:ntg,0:npg)
00260 pot4(0:nrg,0:ntg,0:npg) = hyyd(0:nrg,0:ntg,0:npg)
00261 pot5(0:nrg,0:ntg,0:npg) = hyzd(0:nrg,0:ntg,0:npg)
00262 pot6(0:nrg,0:ntg,0:npg) = hzzd(0:nrg,0:ntg,0:npg)
00263
00264 hxxd(0:nrg,0:ntg,0:npg) = bk1(0:nrg,0:ntg,0:npg)
00265 hxyd(0:nrg,0:ntg,0:npg) = bk2(0:nrg,0:ntg,0:npg)
00266 hxzd(0:nrg,0:ntg,0:npg) = bk3(0:nrg,0:ntg,0:npg)
00267 hyyd(0:nrg,0:ntg,0:npg) = bk4(0:nrg,0:ntg,0:npg)
00268 hyzd(0:nrg,0:ntg,0:npg) = bk5(0:nrg,0:ntg,0:npg)
00269 hzzd(0:nrg,0:ntg,0:npg) = bk6(0:nrg,0:ntg,0:npg)
00270
00271 call update_grfield(pot1,hxxd,conv_gra*0.6d0)
00272 call update_grfield(pot2,hxyd,conv_gra*0.6d0)
00273 call update_grfield(pot3,hxzd,conv_gra*0.6d0)
00274 call update_grfield(pot4,hyyd,conv_gra*0.6d0)
00275 call update_grfield(pot5,hyzd,conv_gra*0.6d0)
00276 call update_grfield(pot6,hzzd,conv_gra*0.6d0)
00277
00278 call invhij
00279
00280 call update_parameter_WL_peos(conv_den)
00281 call error_metric_type2(hxxd,bk1,error_all(6),flag_all(6),'ns')
00282 call error_metric_type2(hxyd,bk2,error_all(7),flag_all(7),'ns')
00283 call error_metric_type2(hxzd,bk3,error_all(8),flag_all(8),'ns')
00284 call error_metric_type2(hyyd,bk4,error_all(9),flag_all(9),'ns')
00285 call error_metric_type2(hyzd,bk5,error_all(10),flag_all(10),'ns')
00286 call error_metric_type2(hzzd,bk6,error_all(11),flag_all(11),'ns')
00287 call printout_error_metric_combined_3(iter_count,error_all(6), &
00288 & error_all(7),error_all(8))
00289 call printout_error_metric_combined_3(iter_count,error_all(9), &
00290 & error_all(10),error_all(11))
00291
00292
00293
00294
00295
00296 9000 continue
00297
00298
00299
00300
00301 do ihy = 1, hydro_iter
00302 if (ihy.eq.1) emd_bak = emd
00303 call interpo_gr2fl_metric_WL
00304 call hydrostatic_eq_WL_peos(potf)
00305 call calc_surface(potrs, potf)
00306 call update_matter(potf,emd,conv_den)
00307 call update_surface(potrs,rs,conv_den)
00308 call reset_fluid
00309 call update_parameter_WL_peos(conv_den)
00310 call calc_vector_x_matter(1)
00311 call calc_vector_phi_matter(1)
00312
00313 if (ihy.eq.hydro_iter) then
00314 call error_matter(emd,emd_bak,error_all(12),flag_all(12))
00315 call printout_error(iter_count,error_all(12))
00316 end if
00317 end do
00318
00319 if (flag_all(1)==0.and.flag_all(2)==0.and.flag_all(3)==0.and.&
00320 & flag_all(4)==0.and.flag_all(5)==0.and.flag_all(6)==0.and.&
00321 & flag_all(7)==0.and.flag_all(8)==0.and.flag_all(9)==0.and.&
00322 & flag_all(10)==0.and.flag_all(11)==0.and.flag_all(12)==0.and.&
00323 & flag_all(13)==0.and.flag_all(14)==0.and.flag_all(15)==0.and.&
00324 & flag_all(16)==0.and.flag_all(17)==0.and.flag_all(18)==0.and.&
00325 & flag_all(19)==0.and.flag_all(20)==0) exit
00326 if (iter_count >= iter_max) exit
00327 flag = 0
00328 flag_all(1:20) = 0
00329
00330 end do
00331
00332 deallocate(sou)
00333 deallocate(pot)
00334 deallocate(sou2)
00335 deallocate(potf)
00336 deallocate(emd_bak)
00337 deallocate(potrs)
00338 deallocate(potx)
00339 deallocate(poty)
00340 deallocate(potz)
00341 deallocate(souvec)
00342 deallocate(souten)
00343 deallocate(pot1)
00344 deallocate(pot2)
00345 deallocate(pot3)
00346 deallocate(pot4)
00347 deallocate(pot5)
00348 deallocate(pot6)
00349 deallocate(pot_bak)
00350 deallocate(potx_bak)
00351 deallocate(poty_bak)
00352 deallocate(potz_bak)
00353 deallocate(bk1)
00354 deallocate(bk2)
00355 deallocate(bk3)
00356 deallocate(bk4)
00357 deallocate(bk5)
00358 deallocate(bk6)
00359 deallocate(work)
00360 end subroutine iteration_WL