00001 subroutine adjust_A2B2(flag_st,istep_st)
00002 use phys_constant, only : long
00003 use grid_parameter, only : nrf, ntfeq, npfxzp
00004 use def_matter, only : omef
00005 use def_matter_parameter, only : ome, A2DR, DRAT_A2DR, B2DR, DRAT_B2DR
00006 use interface_minv
00007 use make_array_1d
00008 use interface_search_max_radial
00009 implicit none
00010 integer, parameter :: nst = 2
00011 integer :: flag_st, istep_st
00012 integer :: ii, i, j, k
00013 integer, save :: count_st
00014 real(long) :: fac0, error_st
00015 real(long), save :: msec_x_oold(nst), msec_x_old(nst)
00016 real(long), save :: msec_f_oold(nst), msec_f_old(nst)
00017 real(long), save :: msec_dx(nst), msec_x_der(nst), msec_f_der(nst)
00018 real(long), save :: msec_ff(nst,nst)
00019 real(long) :: jacobian_at_x_old(nst+1,nst+1), rhs_at_x_old(nst)
00020 real(long) :: facp(5) = (/ 1.0d-1, 2.0d-1, 4.0d-1, 7.0d-1, 1.0d-0 /)
00021
00022
00023 real(long), pointer :: omef_x(:)
00024 real(long) :: omef_max, x_omax, omef_eq
00025 integer :: irf_omax
00026
00027
00028
00029 call alloc_array1d(omef_x,0,nrf)
00030 omef_x(0:nrf)=omef(0:nrf,ntfeq,npfxzp)
00031 irf_omax = maxloc(omef_x,DIM=1) - 1
00032
00033
00034
00035 call search_max_radial(irf_omax,omef_x,omef_max,x_omax)
00036 omef_eq = omef(nrf,ntfeq,npfxzp)
00037 deallocate(omef_x)
00038
00039 if (istep_st.eq.-1) then
00040 msec_x_oold(1) = A2DR
00041 msec_x_oold(2) = B2DR
00042 msec_f_oold(1) = omef_eq /ome - DRAT_A2DR
00043 msec_f_oold(2) = omef_max/ome - DRAT_B2DR
00044 msec_x_old(1:nst) = msec_x_oold(1:nst) + 0.01*msec_x_oold(1:nst)
00045 A2DR = msec_x_old(1)
00046 B2DR = msec_x_old(2)
00047 istep_st = istep_st + 1
00048 flag_st = 1
00049 count_st = 0
00050 return
00051 end if
00052
00053 write(6,*)'istep A2B2', istep_st
00054 write(6,'(a5,1p,3e14.6)')'xoold', (msec_x_oold(ii),ii=1,nst)
00055 write(6,'(a5,1p,3e14.6)')'x_old', (msec_x_old(ii),ii=1,nst)
00056 write(6,'(a5,1p,3e14.6)')'f_old', (msec_f_old(ii),ii=1,nst)
00057 write(6,'(a5,1p,3e14.6)')'x_der', (msec_x_der(ii),ii=1,nst)
00058 write(6,'(a5,1p,3e14.6)')'f_der', (msec_f_der(ii),ii=1,nst)
00059
00060 if (istep_st.eq.0) then
00061 msec_f_old(1) = omef_eq /ome - DRAT_A2DR
00062 msec_f_old(2) = omef_max/ome - DRAT_B2DR
00063 end if
00064 if (istep_st.ge.1) then
00065 ii = istep_st
00066 msec_f_der(1) = omef_eq /ome - DRAT_A2DR
00067 msec_f_der(2) = omef_max/ome - DRAT_B2DR
00068 msec_dx(ii) = msec_x_oold(ii) - msec_x_old(ii)
00069 msec_ff(1:nst,ii) = msec_f_der(1:nst)
00070 end if
00071
00072
00073 if (istep_st.ge.0.and.istep_st.lt.nst) then
00074 ii = istep_st + 1
00075 msec_x_der(1:nst) = msec_x_old(1:nst)
00076 msec_x_der(ii) = msec_x_oold(ii)
00077 A2DR = msec_x_der(1)
00078 B2DR = msec_x_der(2)
00079 istep_st = istep_st + 1
00080 flag_st = 1
00081 return
00082 end if
00083
00084
00085
00086 do i = 1, nst
00087 do j = 1, nst
00088 jacobian_at_x_old(i,j) = (msec_ff(i,j) - msec_f_old(i))/msec_dx(j)
00089 end do
00090 end do
00091
00092 do j = 1, nst
00093 rhs_at_x_old(j) = 0.0d0
00094 do k = 1, nst
00095 rhs_at_x_old(j) = rhs_at_x_old(j) + jacobian_at_x_old(j,k)*msec_x_old(k)
00096 end do
00097 rhs_at_x_old(j) = rhs_at_x_old(j) - msec_f_old(j)
00098 end do
00099
00100 call minv(jacobian_at_x_old, rhs_at_x_old, nst, nst+1)
00101
00102
00103 count_st = count_st + 1
00104 ii = min0(5,count_st)
00105
00106 fac0 = facp(ii)
00107 msec_x_oold(1:nst) = msec_x_old(1:nst)
00108 msec_x_old( 1:nst) = fac0*rhs_at_x_old(1:nst)+(1.0d0-fac0) &
00109 & *msec_x_oold(1:nst)
00110 A2DR = msec_x_old(1)
00111 B2DR = msec_x_old(2)
00112 istep_st = 0
00113
00114 call error_adjust_parameter(nst,msec_x_old,msec_x_oold, &
00115 & error_st,flag_st)
00116
00117 write(6,'(1a30,2(7x,i5))') ' -- parameter iteration # -- ',count_st
00118 write(6,'(1a30,1p,2e12.4)')' -- A2DR OLD -> NEW -- ', &
00119 & msec_x_oold(1), msec_x_old(1)
00120 write(6,'(1a30,1p,2e12.4)')' -- B2DR OLD -> NEW -- ', &
00121 & msec_x_oold(2), msec_x_old(2)
00122
00123 return
00124 end subroutine adjust_A2B2