iteration_WL.f90

Go to the documentation of this file.
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 !  use interface_sourceterm_HaC_peos
00018 !  use interface_sourceterm_trG_peos
00019 !  use interface_sourceterm_MoC_peos
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   implicit none
00034   real(long), pointer :: sou(:,:,:), pot(:,:,:), sou2(:,:,:)
00035   real(long), pointer :: potf(:,:,:), emd_bak(:,:,:)
00036   real(long), pointer :: potrs(:,:)
00037   real(long), pointer :: potx(:,:,:), poty(:,:,:), potz(:,:,:)
00038   real(long), pointer :: souvec(:,:,:,:), souten(:,:,:,:)
00039   real(long), pointer :: pot1(:,:,:), pot2(:,:,:), pot3(:,:,:)
00040   real(long), pointer :: pot4(:,:,:), pot5(:,:,:), pot6(:,:,:)
00041   real(long), pointer :: bk1(:,:,:), bk2(:,:,:), bk3(:,:,:)
00042   real(long), pointer :: bk4(:,:,:), bk5(:,:,:), bk6(:,:,:)
00043   real(long), pointer :: work(:,:,:)
00044 !  real(long) :: work(0:nnrg,0:nntg,0:nnpg)
00045   real(long) :: error_emd, count
00046   integer    :: iter_count, flag = 0, hydro_iter = 4
00047   integer    :: irf, itf, ipf, irg, itg, ipg, ihy
00048 !
00049   call alloc_array3d(sou,0,nrg,0,ntg,0,npg)
00050   call alloc_array3d(pot,0,nrg,0,ntg,0,npg)
00051   call alloc_array3d(sou2,0,nrg,0,ntg,0,npg)
00052   call alloc_array3d(potf,0,nrf,0,ntf,0,npf)
00053   call alloc_array3d(emd_bak,0,nrf,0,ntf,0,npf)
00054   call alloc_array2d(potrs,0,ntf,0,npf)
00055   call alloc_array3d(potx,0,nrg,0,ntg,0,npg)
00056   call alloc_array3d(poty,0,nrg,0,ntg,0,npg)
00057   call alloc_array3d(potz,0,nrg,0,ntg,0,npg)
00058   call alloc_array4d(souvec,0,nrg,0,ntg,0,npg,1,3)
00059   call alloc_array4d(souten,0,nrg,0,ntg,0,npg,1,6)
00060   call alloc_array3d(pot1,0,nrg,0,ntg,0,npg)
00061   call alloc_array3d(pot2,0,nrg,0,ntg,0,npg)
00062   call alloc_array3d(pot3,0,nrg,0,ntg,0,npg)
00063   call alloc_array3d(pot4,0,nrg,0,ntg,0,npg)
00064   call alloc_array3d(pot5,0,nrg,0,ntg,0,npg)
00065   call alloc_array3d(pot6,0,nrg,0,ntg,0,npg)
00066   call alloc_array3d(bk1,0,nrg,0,ntg,0,npg)
00067   call alloc_array3d(bk2,0,nrg,0,ntg,0,npg)
00068   call alloc_array3d(bk3,0,nrg,0,ntg,0,npg)
00069   call alloc_array3d(bk4,0,nrg,0,ntg,0,npg)
00070   call alloc_array3d(bk5,0,nrg,0,ntg,0,npg)
00071   call alloc_array3d(bk6,0,nrg,0,ntg,0,npg)
00072   call alloc_array3d(work,0,nrg,0,ntg,0,npg)
00073 !
00074   iter_count = 0
00075   do
00076     iter_count = iter_count + 1      
00077     count = dble(iter_count) 
00078     conv_gra = dmin1(conv0_gra,conv_ini*count)
00079     conv_den = dmin1(conv0_den,conv_ini*count)
00080 !
00081     emdg = 0.0d0
00082     call interpo_fl2gr(emd, emdg)
00083 !
00084     call calc_vector_x_grav(1)
00085     call calc_vector_x_matter(1)
00086     call calc_vector_phi_grav(1)
00087     call calc_vector_phi_matter(1)
00088     call calc_shift_down2up
00089     call calc_shift2rotshift
00090 !
00091 !==============================================
00092     if (chgra == 'i') call cleargeometry
00093     if (chgra /= 'i') then 
00094       call cristoffel_midpoint
00095       call cristoffel_gridpoint
00096       call riccitensor_midpoint
00097     end if
00098     if (chgra == 'h'.or.chgra == 'c'.or.chgra == 'C' &
00099         &.or.chgra == 'H'.or.chgra == 'W') then 
00100       call liegmab_midpoint
00101       call liegmab_gridpoint
00102     end if
00103 !
00104     call excurve_WL_midpoint
00105     call excurve_WL_gridpoint
00106     call ap2alps
00107 !==============================================
00108 ! --
00109     call source_HaC_WL(sou)
00110 !
00111     call poisson_solver(sou,pot)
00112     pot = pot + 1.0d0
00113     call update_grfield(pot,psi,conv_gra)
00114     call update_parameter_WL_peos(conv_den)
00115 ! --
00116 !
00117     call source_trG_WL(sou)
00118     call poisson_solver(sou,pot)
00119     pot = pot + 1.0d0
00120     call compute_alps2alph(pot,psi)
00121     call update_grfield(pot,alph,conv_gra)
00122     call update_parameter_WL_peos(conv_den)
00123 ! --
00124     call source_MoC_WL(souvec,sou)
00125     work(1:nrg, 1:ntg, 1:npg) = souvec(1:nrg, 1:ntg, 1:npg, 1)
00126     sou2(1:nrg, 1:ntg, 1:npg) = work(1:nrg, 1:ntg, 1:npg)
00127     call poisson_solver(sou2,potx)
00128     work(1:nrg, 1:ntg, 1:npg) = souvec(1:nrg, 1:ntg, 1:npg, 2)
00129     sou2(1:nrg, 1:ntg, 1:npg) = work(1:nrg, 1:ntg, 1:npg)
00130     call poisson_solver(sou2,poty)
00131     work(1:nrg, 1:ntg, 1:npg) = souvec(1:nrg, 1:ntg, 1:npg, 3)
00132     sou2(1:nrg, 1:ntg, 1:npg) = work(1:nrg, 1:ntg, 1:npg)
00133     call poisson_solver(sou2,potz)
00134     call poisson_solver(sou,pot)
00135     work(  0:nrg, 0:ntg, 0:npg)    = potx(0:nrg, 0:ntg, 0:npg)
00136     souvec(0:nrg, 0:ntg, 0:npg, 1) = work(0:nrg, 0:ntg, 0:npg)
00137     work(  0:nrg, 0:ntg, 0:npg)    = poty(0:nrg, 0:ntg, 0:npg)
00138     souvec(0:nrg, 0:ntg, 0:npg, 2) = work(0:nrg, 0:ntg, 0:npg)
00139     work(  0:nrg, 0:ntg, 0:npg)    = potz(0:nrg, 0:ntg, 0:npg)
00140     souvec(0:nrg, 0:ntg, 0:npg, 3) = work(0:nrg, 0:ntg, 0:npg)
00141     call compute_shift(potx, poty, potz, souvec, pot)
00142     call update_grfield(potx,bvxd,conv_gra)
00143     call update_grfield(poty,bvyd,conv_gra)
00144     call update_grfield(potz,bvzd,conv_gra)
00145     call update_parameter_WL_peos(conv_den)
00146 !
00147 !==============================================
00148 !
00149 !      write(6,"(a6,1p,3e11.3)") 'step 7', ome, ber, radi
00150 !
00151 ! --  For hij
00152 !
00153   if (chgra == 'i') go to 9000
00154 !
00155 !do irg=0,nrg
00156 !write(6,*) souten(irg,ntg/2,1,1), hxxd(irg,ntg/2,1)
00157 !end do
00158   call source_trfreeG_WL(souten)
00159 !  call surfhijsource(ssouten,dssouten,iter,chgra,chope)
00160 !
00161 !  if (chope == 'H') then
00162 !    call hrhafn(ome)
00163 !  end if
00164 !
00165 !do irg=0,nrg
00166 !write(6,*) souten(irg,ntg/2,1,1), hxxd(irg,ntg/2,1)
00167 !end do
00168   bk1(0:nrg,0:ntg,0:npg) = hxxd(0:nrg,0:ntg,0:npg)
00169   bk2(0:nrg,0:ntg,0:npg) = hxyd(0:nrg,0:ntg,0:npg)
00170   bk3(0:nrg,0:ntg,0:npg) = hxzd(0:nrg,0:ntg,0:npg)
00171   bk4(0:nrg,0:ntg,0:npg) = hyyd(0:nrg,0:ntg,0:npg)
00172   bk5(0:nrg,0:ntg,0:npg) = hyzd(0:nrg,0:ntg,0:npg)
00173   bk6(0:nrg,0:ntg,0:npg) = hzzd(0:nrg,0:ntg,0:npg)
00174   hxxd(0:nrg,0:ntg,0:npg) = 0.0d0
00175   hxyd(0:nrg,0:ntg,0:npg) = 0.0d0
00176   hxzd(0:nrg,0:ntg,0:npg) = 0.0d0
00177   hyyd(0:nrg,0:ntg,0:npg) = 0.0d0
00178   hyzd(0:nrg,0:ntg,0:npg) = 0.0d0
00179   hzzd(0:nrg,0:ntg,0:npg) = 0.0d0
00180 !
00181 ! --  Poisson solver.  
00182 !
00183   if (chope == 'L') then
00184 !
00185     sou(0:nrg,0:ntg,0:npg) = souten(0:nrg,0:ntg,0:npg,1)
00186     call poisson_solver(sou,pot1)
00187     sou(0:nrg,0:ntg,0:npg) = souten(0:nrg,0:ntg,0:npg,2)
00188     call poisson_solver(sou,pot2)
00189     sou(0:nrg,0:ntg,0:npg) = souten(0:nrg,0:ntg,0:npg,3)
00190     call poisson_solver(sou,pot3)
00191     sou(0:nrg,0:ntg,0:npg) = souten(0:nrg,0:ntg,0:npg,4)
00192     call poisson_solver(sou,pot4)
00193     sou(0:nrg,0:ntg,0:npg) = souten(0:nrg,0:ntg,0:npg,5)
00194     call poisson_solver(sou,pot5)
00195     sou(0:nrg,0:ntg,0:npg) = souten(0:nrg,0:ntg,0:npg,6)
00196     call poisson_solver(sou,pot6)
00197 !
00198   end if
00199 !
00200 !do irg=0,nrg
00201 !write(6,*) souten(irg,ntg/2,1,1)
00202 !end do
00203 ! --  Helmholtz solver.  
00204 !
00205 !  if (chope == 'H') then
00206 !    if (ii == 1) then
00207 !      call hegr4(sou,pot,cosmpg,cosmpg,pnag,0,0,0,4)
00208 !      call hegr4sfout(ome,ssou,dssou,spot,cosmpg,cosmpg,pnag,0,0,0,4)
00209 !    end if
00210 !  end if
00211 !
00212   hxxd(0:nrg,0:ntg,0:npg) = pot1(0:nrg,0:ntg,0:npg)
00213   hxyd(0:nrg,0:ntg,0:npg) = pot2(0:nrg,0:ntg,0:npg)
00214   hxzd(0:nrg,0:ntg,0:npg) = pot3(0:nrg,0:ntg,0:npg)
00215   hyyd(0:nrg,0:ntg,0:npg) = pot4(0:nrg,0:ntg,0:npg)
00216   hyzd(0:nrg,0:ntg,0:npg) = pot5(0:nrg,0:ntg,0:npg)
00217   hzzd(0:nrg,0:ntg,0:npg) = pot6(0:nrg,0:ntg,0:npg)
00218 !
00219 ! --  Set det(gamma_{ab}) = psi^12 and Dirac gauge for new variable.
00220 !
00221 !do irg=0,nrg
00222 !write(6,*) souten(irg,ntg/2,1,1), hxxd(irg,ntg/2,1)
00223 !end do
00224   call gauge
00225   call adjusthij
00226 !ccc      call hijdet1(iter)
00227 !
00228 ! --  improve by iteration
00229 !
00230   pot1(0:nrg,0:ntg,0:npg) = hxxd(0:nrg,0:ntg,0:npg)
00231   pot2(0:nrg,0:ntg,0:npg) = hxyd(0:nrg,0:ntg,0:npg)
00232   pot3(0:nrg,0:ntg,0:npg) = hxzd(0:nrg,0:ntg,0:npg)
00233   pot4(0:nrg,0:ntg,0:npg) = hyyd(0:nrg,0:ntg,0:npg)
00234   pot5(0:nrg,0:ntg,0:npg) = hyzd(0:nrg,0:ntg,0:npg)
00235   pot6(0:nrg,0:ntg,0:npg) = hzzd(0:nrg,0:ntg,0:npg)
00236 !
00237   hxxd(0:nrg,0:ntg,0:npg) = bk1(0:nrg,0:ntg,0:npg)
00238   hxyd(0:nrg,0:ntg,0:npg) = bk2(0:nrg,0:ntg,0:npg)
00239   hxzd(0:nrg,0:ntg,0:npg) = bk3(0:nrg,0:ntg,0:npg)
00240   hyyd(0:nrg,0:ntg,0:npg) = bk4(0:nrg,0:ntg,0:npg)
00241   hyzd(0:nrg,0:ntg,0:npg) = bk5(0:nrg,0:ntg,0:npg)
00242   hzzd(0:nrg,0:ntg,0:npg) = bk6(0:nrg,0:ntg,0:npg)
00243 !
00244   call update_grfield(pot1,hxxd,conv_gra)
00245   call update_grfield(pot2,hxyd,conv_gra)
00246   call update_grfield(pot3,hxzd,conv_gra)
00247   call update_grfield(pot4,hyyd,conv_gra)
00248   call update_grfield(pot5,hyzd,conv_gra)
00249   call update_grfield(pot6,hzzd,conv_gra)
00250 !
00251   call invhij
00252 !
00253   call update_parameter_WL_peos(conv_den)
00254 !
00255 !      write(6,"(a6,1p,3e11.3)") 'step 9', ome, ber, radi
00256 !
00257 ! --  IWM formalism
00258 !
00259  9000 continue
00260 !
00261 !==============================================
00262 !
00263 ! -- Hydro equations.
00264 do ihy = 1, hydro_iter
00265 if (ihy.eq.1) emd_bak = emd 
00266     call hydrostatic_eq_WL_peos(potf)
00267     call calc_surface(potrs, potf)
00268     call update_matter(potf,emd,conv_den)
00269     call update_surface(potrs,rs,conv_den)
00270     call reset_fluid
00271     call update_parameter_WL_peos(conv_den)
00272     call calc_vector_x_matter(1)
00273     call calc_vector_phi_matter(1)
00274 ! -- calculate error and print it out.
00275 if (ihy.eq.hydro_iter) then
00276     call error_matter(emd,emd_bak,error_emd,flag)
00277     call printout_error(iter_count,error_emd)
00278 end if
00279 end do
00280 !
00281     if (flag == 0) exit
00282     if (iter_count >= iter_max) exit
00283     flag = 0
00284 !
00285   end do
00286 !
00287   deallocate(sou)
00288   deallocate(pot)
00289   deallocate(sou2)
00290   deallocate(potf)
00291   deallocate(emd_bak)
00292   deallocate(potrs)
00293   deallocate(potx)
00294   deallocate(poty)
00295   deallocate(potz)
00296   deallocate(souvec)
00297   deallocate(souten)
00298   deallocate(pot1)
00299   deallocate(pot2)
00300   deallocate(pot3)
00301   deallocate(pot4)
00302   deallocate(pot5)
00303   deallocate(pot6)
00304   deallocate(bk1)
00305   deallocate(bk2)
00306   deallocate(bk3)
00307   deallocate(bk4)
00308   deallocate(bk5)
00309   deallocate(bk6)
00310   deallocate(work)
00311 end subroutine iteration_WL

Generated on 27 Oct 2011 for Cocal by  doxygen 1.6.1