00001 module grid_points_binary_in_asympto
00002   use phys_constant, only : long
00003   implicit none
00004 
00005   real(long), pointer :: rb_a(:,:,:), thb_a(:,:,:), phib_a(:,:,:)
00006   real(long), pointer :: hrb_a(:,:,:), hthb_a(:,:,:), hphib_a(:,:,:)
00007 
00008 contains
00009 
00010 subroutine allocate_grid_points_binary_in_asympto
00011   use phys_constant, only : long, pi
00012   use grid_parameter, only : nrg, ntg, npg
00013   use make_array_3d
00014   implicit none
00015 
00016 
00017 
00018   call alloc_array3d(rb_a,-2,nrg+2,0,ntg,0,npg)
00019   call alloc_array3d(thb_a,-2,nrg+2,0,ntg,0,npg)
00020   call alloc_array3d(phib_a,-2,nrg+2,0,ntg,0,npg)
00021   call alloc_array3d(hrb_a,1,nrg,1,ntg,1,npg)
00022   call alloc_array3d(hthb_a,1,nrg,1,ntg,1,npg)
00023   call alloc_array3d(hphib_a,1,nrg,1,ntg,1,npg)
00024 
00025 end subroutine allocate_grid_points_binary_in_asympto
00026 
00027 
00028 
00029 subroutine calc_grid_points_binary_in_asympto(impt_bin,impt_apt)
00030   use phys_constant, only : long, pi
00031   use coordinate_grav_r, only : rg, hrg
00032   use coordinate_grav_extended, only : rgex, hrgex
00033   use coordinate_grav_theta, only : thg
00034   use coordinate_grav_phi, only : phig
00035   use grid_parameter, only : nrg, ntg, npg, ntgxy, npgxzp, npgxzm, rgin
00036   use def_binary_parameter, only : dis
00037   use trigonometry_grav_theta, only :  sinthg, costhg, hsinthg, hcosthg
00038   use trigonometry_grav_phi, only :  sinphig, cosphig, hsinphig, hcosphig
00039   implicit none
00040 
00041   real(long) :: small = 1.0d-10
00042   real(long) :: rrgg, sth, cth, sphi, cphi
00043   real(long) :: point_line_dis2, root_det, dis_bin
00044   real(long) :: x0, y0, z0, rg_exc_dis2, xxyy2, phi_rot
00045   integer    :: irg, itg, ipg, impt_bin, impt_apt
00046 
00047 
00048 
00049 
00050   dis_bin = dis
00051   phi_rot = 0.0d0
00052   if (impt_bin.eq.2) phi_rot = pi
00053 
00054   do ipg = 0, npg
00055     do itg = 0, ntg
00056       do irg = -2, nrg + 2
00057         rb_a(irg,itg,ipg) = 0.0d0
00058         thb_a(irg,itg,ipg) = 0.0d0
00059         phib_a(irg,itg,ipg) = 0.0d0
00060 
00061         rrgg = rgex(irg)
00062         sth = sinthg(itg)
00063         cth = costhg(itg)
00064         sphi = sinphig(ipg)
00065         cphi = cosphig(ipg)
00066         x0 = rrgg*sth*cphi
00067         y0 = rrgg*sth*sphi
00068         z0 = rrgg*cth
00069 
00070         rg_exc_dis2 = (x0 - dis_bin)**2 + y0**2 + z0**2
00071         xxyy2       = (x0 - dis_bin)**2 + y0**2
00072 
00073         if (rg_exc_dis2.ge.rgin) then 
00074           rb_a(irg,itg,ipg)  = sqrt(rg_exc_dis2)
00075           thb_a(irg,itg,ipg) = atan2(sqrt(xxyy2),z0)
00076           phib_a(irg,itg,ipg)= &
00077           &  dmod(2.0d0*pi+datan2(y0,x0+dis_bin)+phi_rot,2.0d0*pi)
00078         end if
00079 
00080       end do
00081     end do
00082   end do
00083 
00084 
00085 
00086   do ipg = 1, npg
00087     do itg = 1, ntg
00088       do irg = 1, nrg
00089         hrb_a(irg,itg,ipg) = 0.0d0
00090         hthb_a(irg,itg,ipg) = 0.0d0
00091         hphib_a(irg,itg,ipg) = 0.0d0
00092 
00093         rrgg = hrgex(irg)
00094         sth = hsinthg(itg)
00095         cth = hcosthg(itg)
00096         sphi = hsinphig(ipg)
00097         cphi = hcosphig(ipg)
00098         x0 = rrgg*sth*cphi
00099         y0 = rrgg*sth*sphi
00100         z0 = rrgg*cth
00101 
00102         rg_exc_dis2 = (x0 - dis_bin)**2 + y0**2 + z0**2
00103         xxyy2       = (x0 - dis_bin)**2 + y0**2
00104 
00105         if (rg_exc_dis2.lt.rgin) then 
00106           hrb_a(irg,itg,ipg)  = sqrt(rg_exc_dis2)
00107           hthb_a(irg,itg,ipg) = atan2(sqrt(xxyy2),z0)
00108           hphib_a(irg,itg,ipg)= &
00109           &  dmod(2.0d0*pi+datan2(y0,x0+dis_bin)+phi_rot,2.0d0*pi)
00110         end if
00111 
00112       end do
00113     end do
00114   end do
00115 
00116 end subroutine calc_grid_points_binary_in_asympto
00117 end module grid_points_binary_in_asympto