00001 subroutine calc_lecc_spin_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_spin
00008 use interface_violation_gridpoint_MoC_CF_peos_spin
00009 use interface_violation_midpoint_HaC_CF_peos_spin
00010 use interface_violation_gridpoint_HaC_CF_peos_spin
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,rm_eps,delta,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 = 'main_bnsphys_all_mpt.txt'
00027
00028 call open_directory_mpt(0)
00029 iter_eps = 1.0d0
00030 call iter_lecc_spin_BNS_CF_mpt(iter_count,1,iter_eps)
00031 total_iteration = total_iteration + iter_count
00032 write(6,'(a21,i5)') '--- total iteration =', total_iteration
00033 call calc_physical_quantities_spin_BNS_CF_mpt
00034 call write_last_physq_BNS_mpt
00035 call printout_physq_BNS_all_mpt(char3)
00036
00037 call copy_def_matter_parameter_from_mpt(1)
00038 xa = emdc
00039 call copy_def_quantities_BNS_from_mpt(1)
00040 fa = (restmass - restmass_sph)/restmass_sph
00041 write(6,*) "xa,fa=", xa, fa, " restmass, restmass_sph = ", restmass, restmass_sph
00042 call chdir('../')
00043
00044 call open_directory_mpt(1)
00045
00046 xb = xa - 0.01d0*xa
00047 do impt = 1, 2
00048 call copy_def_matter_parameter_from_mpt(impt)
00049 emdc = xb
00050 call copy_def_matter_parameter_to_mpt(impt)
00051 end do
00052 write(6,'(a14,1p,2e20.12)') "emdc COCP1,2: ", def_matter_param_real_(2,1), def_matter_param_real_(2,2)
00053 iter_eps = 1.0d0
00054 call iter_lecc_spin_BNS_CF_mpt(iter_count,2,iter_eps)
00055 total_iteration = total_iteration + iter_count
00056 write(6,'(a21,i5)') '--- total iteration =', total_iteration
00057 call calc_physical_quantities_spin_BNS_CF_mpt
00058 call write_last_physq_BNS_mpt
00059 call printout_physq_BNS_all_mpt(char3)
00060
00061 call copy_def_quantities_BNS_from_mpt(1)
00062 fb = (restmass - restmass_sph)/restmass_sph
00063 write(6,*) "xb,fb=", xb, fb, " restmass, restmass_sph = ", restmass, restmass_sph
00064 call chdir('../')
00065
00066 write(6,*) '--------- Initial values for emdc and f(emdc)=(restmass - restmass_sph)/restmass_sph ---------------------------'
00067 write(6,'(a30,i2,1p,2e20.12)') '(cycle,emdc,(M0-M0sph)/M0sph)=', 0,xa,fa
00068 write(6,'(a30,i2,1p,2e20.12)') '(cycle,emdc,(M0-M0sph)/M0sph)=', 1,xb,fb
00069
00070 if ( dabs(fa)>dabs(fb) ) then
00071 f1 = xa
00072 xa = xb
00073 xb = f1
00074
00075 f1 = fa
00076 fa = fb
00077 fb = f1
00078 endif
00079
00080 icycle = 1
00081 do i = 2,Nmax
00082 icycle = icycle + 1
00083 if ( dabs(fa)>dabs(fb) ) then
00084 f1 = xa
00085 xa = xb
00086 xb = f1
00087 f1 = fa
00088 fa = fb
00089 fb = f1
00090 end if
00091 delta = (xb-xa)/(fb-fa)
00092 xb = xa
00093 fb = fa
00094 delta = delta*fa
00095 if ( dabs(delta) < rm_eps ) then
00096 write(6,*) 'Convergence...'
00097 call copy_def_matter_parameter_from_mpt(1)
00098 write(6,*) '------------------------------------------------------------------'
00099 write(6,*) 'Central Emden = ',emdc
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139 return
00140 end if
00141
00142 if (i.lt.10) then
00143 xa = xa - i*delta/10.0d0
00144 else
00145 xa = xa - delta
00146 end if
00147 if (i.lt.7) then
00148 iter_eps = dmin1(10.0d0**(-i), dabs(delta))
00149 else
00150 iter_eps = rm_eps
00151 end if
00152
00153 call open_directory_mpt(icycle)
00154 do impt = 1, 2
00155 call copy_def_matter_parameter_from_mpt(impt)
00156 emdc = xa
00157 call copy_def_matter_parameter_to_mpt(impt)
00158 end do
00159 write(6,'(a14,1p,2e20.12)') "emdc COCP1,2: ", def_matter_param_real_(2,1), def_matter_param_real_(2,2)
00160 write(6,*) '------------------------------------------------------------------'
00161
00162
00163 call iter_lecc_spin_BNS_CF_mpt(iter_count,icycle,iter_eps)
00164 total_iteration = total_iteration + iter_count
00165 write(6,'(a21,i5)') '--- total iteration =', total_iteration
00166 call calc_physical_quantities_spin_BNS_CF_mpt
00167 call write_last_physq_BNS_mpt
00168 call printout_physq_BNS_all_mpt(char3)
00169
00170 call copy_def_quantities_BNS_from_mpt(1)
00171 fa = (restmass - restmass_sph)/restmass_sph
00172 write(6,'(a30,i2,1p,2e20.12)') '(cycle,emdc,(M0-M0sph)/M0sph)=',icycle,xa,fa
00173 call chdir('../')
00174
00175 end do
00176 write(6,*) 'No convergence after ',Nmax,' iterations.'
00177
00178 end subroutine calc_lecc_spin_BNS_CF_mpt