00001 subroutine calc_irrot_BNS_CF_mpt(total_iteration)
00002 use phys_constant, only : long, nmpt
00003 use grid_parameter
00004 use def_quantities
00005 use def_matter_parameter
00006 use def_matter_parameter_mpt
00007 use interface_violation_midpoint_MoC_CF_peos_irrot
00008 use interface_violation_gridpoint_MoC_CF_peos_irrot
00009 use interface_violation_midpoint_HaC_CF_peos_irrot
00010 use interface_violation_gridpoint_HaC_CF_peos_irrot
00011 use interface_IO_output_3D_general
00012 use interface_IO_output_2D_general
00013 use interface_IO_output_1D_general
00014 use make_array_2d
00015 use make_array_3d
00016 use make_array_4d
00017 implicit none
00018 real(long), pointer :: pot(:,:,:), HaC_vio(:,:,:), MoC_vio(:,:,:,:)
00019 real(long) :: xa,xb,fa,fb,delta,rm_eps,f1,f2, iter_eps
00020 integer :: total_iteration, iter_count, i, icycle, Nmax=15
00021 integer :: impt
00022 character(30) :: char1, char2, char3, char4, char5
00023
00024 rm_eps = 1.0d-06
00025 total_iteration = 0
00026 char3 = 'bnsphys_all_mpt.txt'
00027 char1 = 'bnsphys_mpt1.txt'
00028 char2 = 'bnsphys_mpt2.txt'
00029
00030 call open_directory_mpt(0)
00031 iter_eps = 1.0d-00
00032 call iter_irrot_BNS_CF_mpt(iter_count,1, iter_eps)
00033 total_iteration = total_iteration + iter_count
00034 write(6,'(a21,i5)') '--- total iteration =', total_iteration
00035 call calc_physical_quantities_irrot_BNS_CF_mpt
00036 call write_last_physq_BNS_mpt
00037 call printout_physq_BNS_all_mpt(char3)
00038 call printout_physq_BNS_plot_mpt(char1,1)
00039 call printout_physq_BNS_plot_mpt(char2,2)
00040
00041 call copy_def_matter_parameter_from_mpt(1)
00042 xa = emdc
00043
00044
00045
00046
00047
00048 call copy_def_quantities_BNS_from_mpt(nmpt)
00049 fa = (admmass_asymp - 2.7d0)/2.7d0
00050 write(6,*) "xa,fa=", xa, fa, " admmass_asymp=", admmass_asymp
00051 call chdir('../')
00052
00053 call open_directory_mpt(1)
00054
00055 xb = xa - 0.01d0*xa
00056 do impt = 1, 2
00057 call copy_def_matter_parameter_from_mpt(impt)
00058 emdc = xb
00059 call copy_def_matter_parameter_to_mpt(impt)
00060 end do
00061 write(6,'(a14,1p,2e20.12)') "emdc COCP1,2: ", def_matter_param_real_(2,1), def_matter_param_real_(2,2)
00062 iter_eps = 1.0d-00
00063 call iter_irrot_BNS_CF_mpt(iter_count,2, iter_eps)
00064 total_iteration = total_iteration + iter_count
00065 write(6,'(a21,i5)') '--- total iteration =', total_iteration
00066 call calc_physical_quantities_irrot_BNS_CF_mpt
00067 call write_last_physq_BNS_mpt
00068 call printout_physq_BNS_all_mpt(char3)
00069 call printout_physq_BNS_plot_mpt(char1,1)
00070 call printout_physq_BNS_plot_mpt(char2,2)
00071
00072
00073
00074
00075
00076
00077 call copy_def_quantities_BNS_from_mpt(nmpt)
00078 fb = (admmass_asymp - 2.7d0)/2.7d0
00079 write(6,*) "xb,fb=", xb, fb, " admmass_asymp= ", admmass_asymp
00080 call chdir('../')
00081
00082 write(6,*) '--------- Initial values for emdc and f(emdc)=(restmass - restmass_sph)/restmass_sph ---------------------------'
00083 write(6,'(a30,i2,1p,2e20.12)') '(cycle,emdc,(M0-M0sph)/M0sph)=', 0,xa,fa
00084 write(6,'(a30,i2,1p,2e20.12)') '(cycle,emdc,(M0-M0sph)/M0sph)=', 1,xb,fb
00085
00086 if ( dabs(fa)>dabs(fb) ) then
00087 f1 = xa
00088 xa = xb
00089 xb = f1
00090
00091 f1 = fa
00092 fa = fb
00093 fb = f1
00094 endif
00095
00096 icycle = 1
00097 do i = 2,Nmax
00098 icycle = icycle + 1
00099 if ( dabs(fa)>dabs(fb) ) then
00100 f1 = xa
00101 xa = xb
00102 xb = f1
00103 f1 = fa
00104 fa = fb
00105 fb = f1
00106 end if
00107 delta = (xb-xa)/(fb-fa)
00108 xb = xa
00109 fb = fa
00110 delta = delta*fa
00111 if ( dabs(delta) < rm_eps ) then
00112 write(6,*) 'Convergence...'
00113 call copy_def_matter_parameter_from_mpt(1)
00114 write(6,*) '------------------------------------------------------------------'
00115 write(6,*) 'Central Emden = ',emdc
00116
00117 write(6,*) "Calculating constraint violations at gridpoints of COCP-1..."
00118 call copy_from_mpatch_all_BNS_CF(1)
00119 call copy_def_metric_and_matter_from_mpt(1)
00120 call copy_def_matter_irrot_from_mpt(1)
00121 call alloc_array4d(MoC_vio,0,nrg,0,ntg,0,npg,1,3)
00122 call alloc_array3d(HaC_vio,0,nrg,0,ntg,0,npg)
00123 call alloc_array3d(pot,0,nrg,0,ntg,0,npg)
00124 call excurve_CF('ns')
00125 call excurve_CF_gridpoint
00126
00127 MoC_vio(0:nrg,0:ntg,0:npg,1:3) = 0.0d0
00128 call violation_gridpoint_MoC_CF_peos_irrot(MoC_vio,'ns')
00129 pot = 0.0d0
00130 pot(0:nrg,0:ntg,0:npg) = MoC_vio(0:nrg,0:ntg,0:npg,2)
00131 char1 = 'MoC_by_3D_mpt1.txt'
00132 call IO_output_3D_general(char1,'g','g',pot)
00133 char1 = 'MoC_by_xy_mpt1.txt'
00134 call IO_output_2D_general(char1,'g','g',pot,'xy')
00135 char1 = 'MoC_by_phi000_mpt1.txt'
00136 call IO_output_1D_general(char1,'g','g',pot,-1,ntg/2,0)
00137 char1 = 'MoC_by_phi180_mpt1.txt'
00138 call IO_output_1D_general(char1,'g','g',pot,-1,ntg/2,npg/2)
00139
00140 HaC_vio = 0.0d0
00141 call violation_gridpoint_HaC_CF_peos_irrot(HaC_vio,'ns')
00142 char1 = 'HaC_3D_mpt1.txt'
00143 call IO_output_3D_general(char1,'g','g',HaC_vio)
00144 char1 = 'HaC_xy_mpt1.txt'
00145 call IO_output_2D_general(char1,'g','g',HaC_vio,'xy')
00146 char1 = 'HaC_phi000_mpt1.txt'
00147 call IO_output_1D_general(char1,'g','g',HaC_vio,-1,ntg/2,0)
00148 char1 = 'HaC_phi180_mpt1.txt'
00149 call IO_output_1D_general(char1,'g','g',HaC_vio,-1,ntg/2,npg/2)
00150
00151 deallocate(MoC_vio)
00152 deallocate(HaC_vio)
00153 deallocate(pot)
00154
00155 return
00156 end if
00157
00158 if (i.lt.10) then
00159 xa = xa - i*delta/10.0d0
00160 else
00161 xa = xa - delta
00162 end if
00163 if (i.lt.7) then
00164 iter_eps = dmin1(10.0d0**(-i), dabs(delta))
00165 else
00166 iter_eps = rm_eps
00167 end if
00168
00169 call open_directory_mpt(icycle)
00170 do impt = 1, 2
00171 call copy_def_matter_parameter_from_mpt(impt)
00172 emdc = xa
00173 call copy_def_matter_parameter_to_mpt(impt)
00174 end do
00175 write(6,'(a14,1p,2e20.12)') "emdc COCP1,2: ", def_matter_param_real_(2,1), def_matter_param_real_(2,2)
00176 write(6,*) '------------------------------------------------------------------'
00177
00178 call iter_irrot_BNS_CF_mpt(iter_count,icycle,iter_eps)
00179 total_iteration = total_iteration + iter_count
00180 write(6,'(a21,i5)') '--- total iteration =', total_iteration
00181 call calc_physical_quantities_irrot_BNS_CF_mpt
00182 call write_last_physq_BNS_mpt
00183 call printout_physq_BNS_all_mpt(char3)
00184 call printout_physq_BNS_plot_mpt(char1,1)
00185 call printout_physq_BNS_plot_mpt(char2,2)
00186
00187
00188
00189
00190
00191
00192 call copy_def_quantities_BNS_from_mpt(nmpt)
00193 fa = (admmass_asymp - 2.7d0)/2.7d0
00194 write(6,'(a30,i2,1p,2e20.12)') '(cycle,emdc,(Madm-2.7)/2.7)=',icycle,xa,fa
00195 call chdir('../')
00196
00197 end do
00198 write(6,*) 'No convergence after ',Nmax,' iterations.'
00199
00200 end subroutine calc_irrot_BNS_CF_mpt