00001 subroutine iteration_qeos(iter_count)
00002 use phys_constant, only : long, nnrg, nntg, nnpg
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_matter_parameter
00014 use interface_interpo_fl2gr
00015 use interface_poisson_solver
00016
00017
00018 use interface_source_HaC_CF_qeos
00019 use interface_source_trG_CF_qeos
00020 use interface_source_MoC_CF_qeos
00021 use interface_sourceterm_MoC_peos
00022 use interface_compute_shift
00023 use interface_compute_alps2alph
00024 use interface_hydrostatic_eq_qeos
00025 use interface_calc_surface_qeos
00026 use interface_update_grfield
00027 use interface_update_matter
00028 use interface_update_parameter_qeos
00029 use interface_update_surface
00030 use interface_error_matter
00031 use interface_error_matter_type2
00032 use interface_error_surface
00033 use interface_error_monitor_matter
00034 use interface_error_monitor_surface
00035 use interface_error_metric
00036 use interface_error_metric_type0
00037 use interface_error_metric_type2
00038 implicit none
00039 real(long), pointer :: sou(:,:,:), pot(:,:,:), sou2(:,:,:)
00040 real(long), pointer :: potf(:,:,:), rhof_bak(:,:,:)
00041 real(long), pointer :: potrs(:,:), rs_bak(:,:)
00042 real(long), pointer :: potx(:,:,:), poty(:,:,:), potz(:,:,:)
00043 real(long), pointer :: potx_bak(:,:,:), poty_bak(:,:,:), potz_bak(:,:,:)
00044 real(long), pointer :: souvec(:,:,:,:)
00045 real(long) :: work(0:nnrg,0:nntg,0:nnpg)
00046 real(long) :: error_rhof, error_rs, count
00047 real(long) :: error_psi = 0.0d0, error_alph = 0.0d0, error_tmp = 0.0d0,
00048 error_bvxd = 0.0d0, error_bvyd = 0.0d0, error_bvzd = 0.0d0
00049 real(long) :: error_rhof_tmp = 1.0d0, error_metric_tmp = 1.0d0
00050 integer :: iter_count, flag = 0, hydro_iter = 4, conv_rs_count = 0
00051 integer :: flag_tmp = 0, flag_param = 99,
00052 flag_psi = 0, flag_alph = 0, flag_rs = 0, &
00053 flag_bvxd = 0, flag_bvyd = 0, flag_bvzd = 0
00054 integer :: irf, itf, ipf, irg, itg, ipg, ihy
00055
00056 call alloc_array3d(sou,0,nrg,0,ntg,0,npg)
00057 call alloc_array3d(sou2,0,nrg,0,ntg,0,npg)
00058 call alloc_array3d(potx,0,nrg,0,ntg,0,npg)
00059 call alloc_array3d(poty,0,nrg,0,ntg,0,npg)
00060 call alloc_array3d(potz,0,nrg,0,ntg,0,npg)
00061 call alloc_array3d(pot,0,nrg,0,ntg,0,npg)
00062 call alloc_array3d(potf,0,nrf,0,ntf,0,npf)
00063 call alloc_array3d(rhof_bak,0,nrf,0,ntf,0,npf)
00064 call alloc_array3d(potx_bak,0,nrg,0,ntg,0,npg)
00065 call alloc_array3d(poty_bak,0,nrg,0,ntg,0,npg)
00066 call alloc_array3d(potz_bak,0,nrg,0,ntg,0,npg)
00067 call alloc_array2d(potrs,0,ntf,0,npf)
00068 call alloc_array2d(rs_bak,0,ntf,0,npf)
00069 call alloc_array4d(souvec,0,nrg,0,ntg,0,npg,1,3)
00070
00071 iter_count = 0
00072
00073 do
00074 iter_count = iter_count + 1
00075 count = dble(iter_count)
00076 conv_gra = dmin1(conv0_gra,conv_ini*count)
00077 conv_den = dmin1(conv0_den,conv_ini*count)
00078
00079 rhog = 0.0d0
00080 call calc_vector_x_grav(1)
00081 call calc_vector_x_matter(1)
00082 call calc_vector_phi_grav(1)
00083 call calc_vector_phi_matter(1)
00084 call interpo_fl2gr(rhof, rhog)
00085 call interpo_gr2fl_metric_CF
00086 call rotation_law
00087 call excurve
00088
00089
00090 call source_HaC_CF_qeos(sou)
00091 call poisson_solver(sou,pot)
00092 pot = pot + 1.0d0
00093 call update_grfield(pot,psi,conv_gra)
00094
00095 call update_parameter_qeos(conv_den)
00096
00097
00098
00099 call source_trG_CF_qeos(sou)
00100 call poisson_solver(sou,pot)
00101 pot = pot + 1.0d0
00102 call compute_alps2alph(pot,psi)
00103 call update_grfield(pot,alph,conv_gra)
00104
00105 call update_parameter_qeos(conv_den)
00106
00107
00108
00109 call source_MoC_CF_qeos(souvec)
00110 work(1:nrg, 1:ntg, 1:npg) = souvec(1:nrg, 1:ntg, 1:npg, 1)
00111 sou2(1:nrg, 1:ntg, 1:npg) = work(1:nrg, 1:ntg, 1:npg)
00112 call poisson_solver(sou2,potx)
00113 work(1:nrg, 1:ntg, 1:npg) = souvec(1:nrg, 1:ntg, 1:npg, 2)
00114 sou2(1:nrg, 1:ntg, 1:npg) = work(1:nrg, 1:ntg, 1:npg)
00115 call poisson_solver(sou2,poty)
00116 work(1:nrg, 1:ntg, 1:npg) = souvec(1:nrg, 1:ntg, 1:npg, 3)
00117 sou2(1:nrg, 1:ntg, 1:npg) = work(1:nrg, 1:ntg, 1:npg)
00118 call poisson_solver(sou2,potz)
00119
00120 work( 0:nrg, 0:ntg, 0:npg) = potx(0:nrg, 0:ntg, 0:npg)
00121 souvec(0:nrg, 0:ntg, 0:npg, 1) = work(0:nrg, 0:ntg, 0:npg)
00122 work( 0:nrg, 0:ntg, 0:npg) = poty(0:nrg, 0:ntg, 0:npg)
00123 souvec(0:nrg, 0:ntg, 0:npg, 2) = work(0:nrg, 0:ntg, 0:npg)
00124 work( 0:nrg, 0:ntg, 0:npg) = potz(0:nrg, 0:ntg, 0:npg)
00125 souvec(0:nrg, 0:ntg, 0:npg, 3) = work(0:nrg, 0:ntg, 0:npg)
00126
00127 potx_bak(0:nrg,0:ntg,0:npg) = bvxd(0:nrg,0:ntg,0:npg)
00128 poty_bak(0:nrg,0:ntg,0:npg) = bvyd(0:nrg,0:ntg,0:npg)
00129 potz_bak(0:nrg,0:ntg,0:npg) = bvzd(0:nrg,0:ntg,0:npg)
00130 call update_grfield(potx,bvxd,conv_gra)
00131 call update_grfield(poty,bvyd,conv_gra)
00132 call update_grfield(potz,bvzd,conv_gra)
00133 call update_parameter_qeos(conv_den)
00134
00135 call error_metric_type2(bvxd,potx_bak,error_tmp,flag_tmp,'ns')
00136 flag_bvxd = max ( flag_bvxd, flag_tmp)
00137 error_bvxd = dmax1(error_bvxd,error_tmp)
00138 call error_metric_type2(bvyd,poty_bak,error_tmp,flag_tmp,'ns')
00139 flag_bvyd = max ( flag_bvyd, flag_tmp)
00140 error_bvyd = dmax1(error_bvyd,error_tmp)
00141 call error_metric_type2(bvzd,potz_bak,error_tmp,flag_tmp,'ns')
00142 flag_bvzd = max ( flag_bvzd, flag_tmp)
00143 error_bvzd = dmax1(error_bvzd,error_tmp)
00144 call printout_error_metric(iter_count,error_bvxd)
00145 call printout_error_metric(iter_count,error_bvyd)
00146 call printout_error_metric(iter_count,error_bvzd)
00147
00148
00149 write(6,*) "====>", flag_bvxd, flag_bvyd, flag_bvzd
00150
00151
00152 if (error_rhof_tmp.le.eps*0.1d0.and.error_metric_tmp.gt.eps*2.0d0.or. (chrot=='p' .and. chgra=='e' .and. chope=='r')) then
00153 write(6,*)' ## SKIP HYDRO ##'
00154 else
00155 do ihy = 1, hydro_iter
00156 call interpo_gr2fl_metric_CF
00157 call rotation_law
00158 call hydrostatic_eq_qeos(potf)
00159
00160 rhof_bak = rhof
00161 call update_matter(potf,rhof,conv_den)
00162 call calc_surface_qeos(potrs, rhof)
00163
00164
00165
00166 call update_surface(potrs,rs,conv_den)
00167
00168 call reset_fluid_qeos
00169 call update_parameter_qeos(conv_den)
00170 call calc_vector_x_matter(1)
00171 call calc_vector_phi_matter(1)
00172
00173
00174
00175
00176
00177
00178
00179
00180 if (ihy.eq.1) then
00181
00182
00183
00184
00185 call error_matter_type2(rhof,rhof_bak,error_rhof,flag)
00186 call error_surface(rs,rs_bak,error_rs,flag_rs)
00187 call printout_error(iter_count,error_rhof)
00188 call printout_error_matter('rhof ',iter_count,error_rhof)
00189 call printout_error_matter('rs ',iter_count,error_rs)
00190 call error_monitor_matter(rhof,rhof_bak,'rhof ',2,ntf/2,2)
00191 call error_monitor_surface(rs, rs_bak,'rs ',2,2)
00192 end if
00193 end do
00194
00195 end if
00196
00197
00198
00199
00200 if (chrot=='p' .and. chgra=='e' .and. chope=='r') then
00201 if ( (flag_bvxd==0).and.(flag_bvyd==0).and.(flag_bvzd==0) ) exit
00202 else
00203 if (flag == 0) exit
00204 end if
00205
00206 if (iter_count >= iter_max) exit
00207
00208 error_rhof_tmp = error_rhof
00209 error_metric_tmp = dmax1(error_psi,error_alph, &
00210 & error_bvxd,error_bvyd,error_bvzd)
00211
00212 flag = 0
00213 flag_psi = 0
00214 flag_alph = 0
00215 flag_bvxd = 0
00216 flag_bvyd = 0
00217 flag_bvzd = 0
00218 flag_param= 0
00219 error_rhof = 0.0d0
00220 error_psi = 0.0d0
00221 error_alph = 0.0d0
00222 error_bvxd = 0.0d0
00223 error_bvyd = 0.0d0
00224 error_bvzd = 0.0d0
00225
00226 end do
00227
00228 deallocate(sou)
00229 deallocate(sou2)
00230 deallocate(potx)
00231 deallocate(poty)
00232 deallocate(potz)
00233 deallocate(pot)
00234 deallocate(potf)
00235 deallocate(rhof_bak)
00236 deallocate(potx_bak)
00237 deallocate(poty_bak)
00238 deallocate(potz_bak)
00239 deallocate(potrs)
00240 deallocate(souvec)
00241 end subroutine iteration_qeos