iteration_BBH_CF.f90

Go to the documentation of this file.
00001 subroutine iteration_BBH_CF(iter_count)
00002   use phys_constant, only :  long
00003   use grid_parameter
00004   use coordinate_grav_r
00005   use coordinate_grav_phi
00006   use coordinate_grav_theta
00007   use weight_midpoint_grav
00008   use make_array_2d
00009   use make_array_3d
00010   use make_array_4d
00011   use def_metric
00012   use def_matter
00013   use def_bh_parameter, only : bh_bctype
00014   use def_vector_bh
00015   use interface_poisson_solver_binary_bhex_homosol
00016   use interface_sourceterm_exsurf_eqm_binary
00017   use interface_sourceterm_surface_int
00018   use interface_compute_shift
00019   use interface_compute_alps2alph
00020   use interface_update_grfield
00021   use interface_update_parameter
00022   use interface_error_metric_type0
00023   use interface_error_metric_type2
00024   use interface_interpolation_fillup_binary
00025 !
00026   use interface_bh_boundary_d_psi
00027   use interface_bh_boundary_nh_psi_test
00028   use interface_bh_boundary_d_alps
00029   use interface_bh_boundary_CF
00030   use interface_outer_boundary_d_psi
00031   use interface_outer_boundary_d_alps
00032   use interface_outer_boundary_d_bvxd
00033   use interface_outer_boundary_d_bvyd
00034   use interface_outer_boundary_d_bvzd
00035   use interface_outer_boundary_d_Bfun
00036   use interface_outer_boundary_n_Bfun
00037   use interface_outer_boundary_d_potx
00038   use interface_outer_boundary_d_poty
00039   use interface_outer_boundary_d_potz
00040   use interface_sourceterm_HaC_CF
00041   use interface_sourceterm_trG_CF
00042   use interface_sourceterm_MoC_CF
00043   use interface_sourceterm_MoC_CF_type1_bhex
00044   use interface_sourceterm_Bfun
00045   use interface_interpolation_fillup_binary_parity
00046   use interface_sourceterm_exsurf_eqm_binary_parity
00047   use interface_compute_shift_v2
00048   use interface_compute_dBfun
00049   use gnufor2
00050 !
00051   implicit none
00052   real(long), pointer :: sou(:,:,:), pot(:,:,:)
00053   real(long), pointer :: Bfun(:,:,:), potx(:,:,:), poty(:,:,:), potz(:,:,:) 
00054   real(long), pointer :: pot_bak(:,:,:), work(:,:,:)
00055   real(long), pointer :: potx_bak(:,:,:), poty_bak(:,:,:), potz_bak(:,:,:) 
00056   real(long), pointer :: dBfundx(:,:,:), dBfundy(:,:,:), dBfundz(:,:,:) 
00057   real(long), pointer :: souvec(:,:,:,:)
00058   real(long), pointer :: sou_exsurf(:,:), dsou_exsurf(:,:)
00059   real(long), pointer :: sou_bhsurf(:,:), dsou_bhsurf(:,:)
00060   real(long), pointer :: sou_outsurf(:,:), dsou_outsurf(:,:)
00061   real(long) :: count, error_psi,error_alph, error_bvxd, error_bvyd, error_bvzd
00062   real(long) :: error_potx, error_poty, error_potz, error_Bfun
00063   real(long) :: pari
00064   integer    :: iter_count, flag_psi=0, flag_alph=0, 
00065                flag_bvxd=0, flag_bvyd=0, flag_bvzd=0
00066   integer    :: flag_potx=0, flag_poty=0, flag_potz=0, flag_Bfun=0
00067   integer    :: irg, itg, ipg, ihy, nn, ii
00068   character(2) :: chgreen
00069   character(30) :: char1, char2, char3
00070 !
00071   call alloc_array4d(souvec,0,nrg,0,ntg,0,npg,1,3)
00072   call alloc_array3d(sou,0,nrg,0,ntg,0,npg)
00073 !  call alloc_array3d(Bfun,0,nrg,0,ntg,0,npg)
00074 !  call alloc_array3d(dBfundx,0,nrg,0,ntg,0,npg)
00075 !  call alloc_array3d(dBfundy,0,nrg,0,ntg,0,npg)
00076 !  call alloc_array3d(dBfundz,0,nrg,0,ntg,0,npg)
00077   call alloc_array3d(pot,0,nrg,0,ntg,0,npg)
00078   call alloc_array3d(potx,0,nrg,0,ntg,0,npg)
00079   call alloc_array3d(poty,0,nrg,0,ntg,0,npg)
00080   call alloc_array3d(potz,0,nrg,0,ntg,0,npg)
00081   call alloc_array3d(pot_bak,0,nrg,0,ntg,0,npg)
00082   call alloc_array3d(potx_bak,0,nrg,0,ntg,0,npg)
00083   call alloc_array3d(poty_bak,0,nrg,0,ntg,0,npg)
00084   call alloc_array3d(potz_bak,0,nrg,0,ntg,0,npg)
00085   call alloc_array3d(work,0,nrg,0,ntg,0,npg)
00086   call alloc_array2d(sou_exsurf,0,ntg,0,npg)
00087   call alloc_array2d(dsou_exsurf,0,ntg,0,npg)
00088   call alloc_array2d(sou_bhsurf,0,ntg,0,npg)
00089   call alloc_array2d(dsou_bhsurf,0,ntg,0,npg)
00090   call alloc_array2d(sou_outsurf,0,ntg,0,npg)
00091   call alloc_array2d(dsou_outsurf,0,ntg,0,npg)
00092 !
00093   iter_count = 0
00094 !
00095   do
00096     iter_count = iter_count + 1      
00097     count = dble(iter_count) 
00098     conv_gra = dmin1(conv0_gra,conv_ini*count)
00099     conv_den = dmin1(conv0_den,conv_ini*count)
00100 !---
00101 !    call calc_vector_x_grav(1)
00102 !    call calc_vector_x_matter(1)
00103 !    call calc_vector_phi_grav(1)
00104 !    call calc_vector_phi_matter(1)
00105     call calc_vector_bh(2)
00106     call excurve
00107     call excurve_CF_gridpoint_bhex
00108 !---
00109     sou(0:nrg,0:ntg,0:npg) = 0.0d0
00110     call sourceterm_HaC_CF(sou)
00111     call sourceterm_exsurf_eqm_binary(psi,sou_exsurf,dsou_exsurf)
00112     call sourceterm_surface_int(psi,0,sou_bhsurf,dsou_bhsurf)
00113     call sourceterm_surface_int(psi,nrg,sou_outsurf,dsou_outsurf)
00114     call bh_boundary_CF(sou_bhsurf,dsou_bhsurf,'psi ')
00115     call outer_boundary_d_psi(sou_outsurf)
00116     if (bh_bctype.eq.'TU') chgreen = 'dd'
00117     if (bh_bctype.eq.'AH') chgreen = 'nd'
00118     call poisson_solver_binary_bhex_homosol(chgreen,sou, &
00119     &                                       sou_exsurf,dsou_exsurf, &
00120     &                                       sou_bhsurf,dsou_bhsurf, & 
00121     &                                       sou_outsurf,dsou_outsurf,pot)
00122     pot_bak = psi
00123     call update_grfield(pot,psi,conv_gra)
00124     call interpolation_fillup_binary(psi)
00125     call error_metric_type0(psi,pot_bak,error_psi,flag_psi,'bh')
00126 !---
00127     sou(0:nrg,0:ntg,0:npg) = 0.0d0
00128     alps(0:nrg,0:ntg,0:npg) = alph(0:nrg,0:ntg,0:npg)*psi(0:nrg,0:ntg,0:npg)
00129     call sourceterm_trG_CF(sou)
00130     call sourceterm_exsurf_eqm_binary(alps,sou_exsurf,dsou_exsurf)
00131     call sourceterm_surface_int(alps,0,sou_bhsurf,dsou_bhsurf)
00132     call sourceterm_surface_int(alps,nrg,sou_outsurf,dsou_outsurf)
00133     call bh_boundary_CF(sou_bhsurf,dsou_bhsurf,'alps')
00134     call outer_boundary_d_alps(sou_outsurf)
00135     call poisson_solver_binary_bhex_homosol('dd',sou, &
00136     &                                       sou_exsurf,dsou_exsurf, &
00137     &                                       sou_bhsurf,dsou_bhsurf, & 
00138     &                                       sou_outsurf,dsou_outsurf,pot)
00139     call compute_alps2alph(pot,psi)
00140     pot_bak = alph
00141     call update_grfield(pot,alph,conv_gra)
00142     call interpolation_fillup_binary(alph)
00143     call error_metric_type0(alph,pot_bak,error_alph,flag_alph,'bh')
00144 !---
00145     call sourceterm_MoC_CF_type1_bhex(souvec)
00146     do ii = 1, 3
00147       sou(0:nrg,0:ntg,0:npg) = souvec(0:nrg,0:ntg,0:npg,ii)
00148       if      (ii.eq.1) then 
00149         work(0:nrg,0:ntg,0:npg) = bvxd(0:nrg,0:ntg,0:npg)
00150         pari = -1.0d0
00151       else if (ii.eq.2) then
00152         work(0:nrg,0:ntg,0:npg) = bvyd(0:nrg,0:ntg,0:npg)
00153         pari = -1.0d0
00154       else if (ii.eq.3) then
00155         work(0:nrg,0:ntg,0:npg) = bvzd(0:nrg,0:ntg,0:npg)
00156         pari =  1.0d0
00157       end if
00158       call sourceterm_exsurf_eqm_binary_parity(work,sou_exsurf,dsou_exsurf,&
00159       &                                        pari)
00160       call sourceterm_surface_int(work,0,sou_bhsurf,dsou_bhsurf)
00161       call sourceterm_surface_int(work,nrg,sou_outsurf,dsou_outsurf)
00162       if      (ii.eq.1) then 
00163         call bh_boundary_CF(sou_bhsurf,dsou_bhsurf,'bvxd')
00164         call outer_boundary_d_bvxd(sou_outsurf)
00165       else if (ii.eq.2) then
00166         call bh_boundary_CF(sou_bhsurf,dsou_bhsurf,'bvyd')
00167         call outer_boundary_d_bvyd(sou_outsurf)
00168       else if (ii.eq.3) then
00169         call bh_boundary_CF(sou_bhsurf,dsou_bhsurf,'bvzd')
00170         call outer_boundary_d_bvzd(sou_outsurf)
00171       end if
00172       call poisson_solver_binary_bhex_homosol('dd',sou, &
00173       &                                       sou_exsurf,dsou_exsurf, &
00174       &                                       sou_bhsurf,dsou_bhsurf, & 
00175       &                                       sou_outsurf,dsou_outsurf,pot)
00176       if (ii.eq.1) potx(0:nrg,0:ntg,0:npg) = pot(0:nrg,0:ntg,0:npg)
00177       if (ii.eq.2) poty(0:nrg,0:ntg,0:npg) = pot(0:nrg,0:ntg,0:npg)
00178       if (ii.eq.3) potz(0:nrg,0:ntg,0:npg) = pot(0:nrg,0:ntg,0:npg)
00179     end do
00180 !
00181     potx_bak = bvxd
00182     poty_bak = bvyd
00183     potz_bak = bvzd
00184     call update_grfield(potx,bvxd,conv_gra)
00185     call update_grfield(poty,bvyd,conv_gra)
00186     call update_grfield(potz,bvzd,conv_gra)
00187 !    call reset_bh_boundary_CF
00188     call interpolation_fillup_binary_parity(bvxd,-1.0d0)
00189     call interpolation_fillup_binary_parity(bvyd,-1.0d0)
00190     call interpolation_fillup_binary_parity(bvzd,1.0d0)
00191     if (bh_bctype.eq.'TU') call reset_metric_CF
00192     call error_metric_type2(bvxd,potx_bak,error_bvxd,flag_bvxd,'bh')
00193     call error_metric_type2(bvyd,poty_bak,error_bvyd,flag_bvyd,'bh')
00194     call error_metric_type2(bvzd,potz_bak,error_bvzd,flag_bvzd,'bh')
00195 !---
00196     call printout_error_metric_combined(iter_count,error_psi,error_alph,&
00197     &                                  error_bvxd,error_bvyd,error_bvzd)
00198 !
00199     if ((flag_psi==0).and.(flag_alph==0).and. &
00200     &   (flag_bvxd==0).and.(flag_bvyd==0).and.(flag_bvzd==0)) exit
00201     if (iter_count >= iter_max) exit
00202 !    if (iter_count >= 50 .and. error_psi > 1.5d0) exit
00203 !    if (iter_count >= 50 .and. error_alph > 1.5d0) exit
00204 !    if (iter_count >= 50 .and. error_bvxd > 1.5d0) exit
00205 !    if (iter_count >= 50 .and. error_bvyd > 1.5d0) exit
00206 !    if (iter_count >= 50 .and. error_bvzd > 1.5d0) exit
00207     flag_psi = 0
00208     flag_alph = 0
00209     flag_bvxd = 0
00210     flag_bvyd = 0
00211     flag_bvzd = 0
00212     flag_Bfun = 0
00213   end do
00214 !
00215   deallocate(souvec)
00216   deallocate(sou)
00217 !  deallocate(Bfun)
00218 !  deallocate(dBfundx)
00219 !  deallocate(dBfundy)
00220 !  deallocate(dBfundz)
00221 !  deallocate(potx)
00222 !  deallocate(poty)
00223 !  deallocate(potz)
00224   deallocate(pot)
00225   deallocate(potx)
00226   deallocate(poty)
00227   deallocate(potz)
00228   deallocate(pot_bak)
00229   deallocate(potx_bak)
00230   deallocate(poty_bak)
00231   deallocate(potz_bak)
00232   deallocate(work)
00233   deallocate(sou_exsurf)
00234   deallocate(dsou_exsurf)
00235   deallocate(sou_bhsurf)
00236   deallocate(dsou_bhsurf)
00237   deallocate(sou_outsurf)
00238   deallocate(dsou_outsurf)
00239 end subroutine iteration_BBH_CF

Generated on 27 Oct 2011 for Cocal by  doxygen 1.6.1