00001 subroutine calc_circular_orbit_spin(total_iteration,niq)
00002 use phys_constant, only : long
00003 use def_bh_parameter, only : ome_bh, spin_bh
00004 use def_quantities
00005 use def_iter_quantities
00006 use make_array_1d
00007 use make_array_2d
00008 use interface_msec_store_f_vector
00009 use interface_msec_copy_to_iter_quantities
00010 use interface_minv
00011 implicit none
00012 real(long) :: delta, cf, edis
00013
00014 real(long), pointer :: jacobian_at_x_old(:,:), msec_ff(:,:)
00015 real(long), pointer :: rhs_at_x_old(:), msec_dx(:), msec_x_der(:), msec_f_der(:)
00016
00017 integer :: total_iteration, iter_count, Nmax=30
00018 integer :: istep, ii, i, j, k, niq
00019
00020 call alloc_array2d(jacobian_at_x_old,1,niq+1,1,niq+1)
00021 call alloc_array2d(msec_ff ,1,niq ,1,niq)
00022 call alloc_array1d(rhs_at_x_old,1,niq)
00023 call alloc_array1d(msec_dx ,1,niq)
00024 call alloc_array1d(msec_x_der ,1,niq)
00025 call alloc_array1d(msec_f_der ,1,niq)
00026
00027 delta = 1.0d-10
00028
00029 istep = 0
00030 write(6,'(a13,i5,1p,10e20.12)') 'First point: ', istep, (msec_x_oold(i),i=1,niq)
00031 if (niq.eq.1) then
00032 call msec_copy_to_iter_quantities(msec_x_oold)
00033 call iteration_BBH_CF(iter_count)
00034 total_iteration = total_iteration + iter_count
00035 write(6,'(a21,i5)') '--- total iteration =', total_iteration
00036 call calc_physical_quantities_BBH_CF
00037 call msec_store_f_vector(msec_f_oold)
00038 call save_solution(0)
00039 call write_last_physq
00040 call printout_physq_console_BBH
00041 endif
00042 write(6,*) '-----------------------------------------------------------------------------------------------'
00043
00044 do i=1,niq
00045 msec_x_old(i) = msec_x_oold(i) + 0.05*msec_x_oold(i)
00046 end do
00047
00048 istep = 1
00049 write(6,'(a11,i5,1p,10e20.12)') 'New point: ', istep, (msec_x_old(i),i=1,niq)
00050 call msec_copy_to_iter_quantities(msec_x_old)
00051 call iteration_BBH_CF(iter_count)
00052 total_iteration = total_iteration + iter_count
00053 write(6,'(a21,i5)') '--- total iteration =', total_iteration
00054 call calc_physical_quantities_BBH_CF
00055 call msec_store_f_vector(msec_f_old)
00056 call save_solution(1)
00057 call write_last_physq
00058 call printout_physq_console_BBH
00059 write(6,*) '-----------------------------------------------------------------------------------------------'
00060
00061 do ii = 2,Nmax
00062 istep = istep+1
00063 if (niq > 1) then
00064 do i=1,niq
00065 msec_dx(i) = msec_x_oold(i) - msec_x_old(i)
00066 msec_x_der(1:niq) = msec_x_old(1:niq)
00067 msec_x_der(i) = msec_x_oold(i)
00068
00069 write(6,'(a11,i5,i5,1p,10e20.12)') 'Add point: ', istep, i, (msec_x_der(j),j=1,niq)
00070 call msec_copy_to_iter_quantities(msec_x_der)
00071 call iteration_BBH_CF(iter_count)
00072 total_iteration = total_iteration + iter_count
00073 write(6,'(a21,i5)') '--- total iteration =', total_iteration
00074 call calc_physical_quantities_BBH_CF
00075 call msec_store_f_vector(msec_f_der)
00076
00077 call write_last_physq
00078 call printout_physq_console_BBH
00079 write(6,*) '************************************************************************************************'
00080
00081 msec_ff(1:niq,i) = msec_f_der(1:niq)
00082 end do
00083 else
00084 msec_dx(1) = msec_x_oold(1) - msec_x_old(1)
00085 msec_ff(1,1) = msec_f_oold(1)
00086 endif
00087
00088 do i=1,niq
00089 do j=1,niq
00090 jacobian_at_x_old(i,j) = (msec_ff(i,j) - msec_f_old(i))/msec_dx(j)
00091 end do
00092 end do
00093
00094 do j=1,niq
00095 rhs_at_x_old(j) = 0.0d0
00096 do k=1,niq
00097 rhs_at_x_old(j) = rhs_at_x_old(j) + jacobian_at_x_old(j,k)*msec_x_old(k)
00098 end do
00099 rhs_at_x_old(j) = rhs_at_x_old(j) - msec_f_old(j)
00100 end do
00101
00102 call minv(jacobian_at_x_old, rhs_at_x_old, niq, niq+1)
00103
00104 msec_x_oold(1:niq) = msec_x_old(1:niq)
00105 msec_f_oold(1:niq) = msec_f_old(1:niq)
00106
00107
00108 if (ii.lt.10) then
00109 cf = dble(ii)/10.0d0
00110 msec_x_old(1:niq) = cf*rhs_at_x_old(1:niq) + (1.0d0-cf)*msec_x_oold(1:niq)
00111 else
00112 msec_x_old(1:niq) = rhs_at_x_old(1:niq)
00113 end if
00114
00115 write(6,'(a11,i5,1p,10e20.12)') 'New point: ', istep, (msec_x_old(i),i=1,niq)
00116 call msec_copy_to_iter_quantities(msec_x_old)
00117 call iteration_BBH_CF(iter_count)
00118 total_iteration = total_iteration + iter_count
00119 write(6,'(a21,i5)') '--- total iteration =', total_iteration
00120 call calc_physical_quantities_BBH_CF
00121 call msec_store_f_vector(msec_f_old)
00122 call save_solution(istep)
00123 call write_last_physq
00124 call printout_physq_console_BBH
00125 write(6,*) '-----------------------------------------------------------------------------------------------'
00126
00127
00128 edis = 0
00129 do i=1,niq
00130 edis = edis + (msec_x_oold(i) - msec_x_old(i))*(msec_x_oold(i) - msec_x_old(i))
00131 end do
00132 edis = sqrt(edis)
00133 if (edis < delta) then
00134 write(6,*) '================================================================================================'
00135 write(6,'(a13,i5,1p,10e20.12)') 'Convergence: ', istep, (msec_x_old(i),i=1,niq)
00136 exit
00137 end if
00138 end do
00139 if (istep.eq.Nmax) then
00140 if (edis.lt.delta) then
00141 write(6,*) 'Convergence after ',istep-1,' iterations.'
00142 else
00143 write(6,*) 'No convergence after ',Nmax-1,' iterations.'
00144 endif
00145 else
00146 write(6,*) 'Convergence after ',istep-1,' iterations.'
00147 endif
00148 write(6,*) 'Deallocating jacobian_at_x_old,ff,rhs_at_x_old...'
00149 deallocate(jacobian_at_x_old, msec_ff, rhs_at_x_old, msec_dx, msec_x_der, msec_f_der)
00150 end subroutine calc_circular_orbit_spin