00001 subroutine calc_omega_drot_bisection(vphiy,alphw,psiw,bvydw,hyydw,omega)
00002 use phys_constant, only : long
00003 use coordinate_grav_r, only : rg
00004 use def_matter_parameter
00005
00006 implicit none
00007 real(long), intent(in):: vphiy, alphw, psiw, bvydw, hyydw
00008 real(long), intent(inout):: omega
00009
00010
00011
00012 real(long) :: Jome, omega0, omega1, omegam
00013 real(long) :: sgg0, sgg1, sggm, sgg0m, sgg1m
00014 real(long) :: p4a2, ovyu, ov2, ovphi, term1, term2, term3
00015 real(long) :: ddomega, del_omega
00016 real(long) :: error, small, smallome = 1.0d-30, largeome
00017 integer :: i, numero, ic, nic
00018
00019
00020
00021 if (ome .le.0.0d0) ome = 0.01d0
00022 if (omega.le.0.0d0) omega = 0.01d0
00023
00024 p4a2 = psiw**4/alphw**2
00025 numero = 1
00026
00027 if (vphiy.lt.0.001d0*rg(1)) then
00028 omega = ome
00029 return
00030 end if
00031
00032
00033
00034 largeome = ome
00035
00036
00037
00038 nic = 100
00039
00040
00041 del_omega = - ome*0.01d0
00042 small = ome
00043
00044 ic = 0
00045 do
00046 ic = ic + 1
00047 do i = 0, 1
00048 if (i.eq.0) omega = small + dble(ic)*del_omega
00049 if (i.eq.1) omega = small + dble(ic-1)*del_omega
00050
00051 Jome = A2DR*omega*((ome/omega)**index_DR - 1.0d0)
00052 ovyu = bvydw + omega*vphiy
00053
00054
00055 ov2 = ovyu**2*(1.0d0 + hyydw)
00056 ovphi = ovyu*vphiy*(1.0d0 + hyydw)
00057 term1 = 1.0d0 - p4a2*ov2
00058 term2 = p4a2*ovphi
00059
00060 if (i.eq.0) sgg0 = Jome*term1 - term2
00061 if (i.eq.1) sgg1 = Jome*term1 - term2
00062 end do
00063
00064 if (sgg0*sgg1.le.0.0d0) then
00065 omega0 = small + dble(ic)*del_omega
00066 omega1 = small + dble(ic-1)*del_omega
00067 exit
00068 end if
00069 if (ic.ge.nic) then
00070 omega0 = smallome
00071 omega1 = largeome
00072 exit
00073 end if
00074
00075 end do
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 do
00086 omegam = (omega0 + omega1)*0.5d0
00087 do i = 0, 2
00088 if (i.eq.0) omega = omega0
00089 if (i.eq.1) omega = omega1
00090 if (i.eq.2) omega = omegam
00091
00092 Jome = A2DR*omega*((ome/omega)**index_DR - 1.0d0)
00093 ovyu = bvydw + omega*vphiy
00094
00095
00096 ov2 = ovyu**2*(1.0d0 + hyydw)
00097 ovphi = ovyu*vphiy*(1.0d0 + hyydw)
00098 term1 = 1.0d0 - p4a2*ov2
00099 term2 = p4a2*ovphi
00100
00101 if (i.eq.0) sgg0 = Jome*term1 - term2
00102 if (i.eq.1) sgg1 = Jome*term1 - term2
00103 if (i.eq.2) sggm = Jome*term1 - term2
00104 end do
00105 sgg0m = sgg0*sggm
00106 sgg1m = sgg1*sggm
00107
00108 ddomega = omega1 - omega0
00109 omega = omegam
00110 if (sggm.eq.0.0d0) then
00111 ddomega = 0.0d0
00112 else if (sgg0m.gt.0.0d0.and.sgg1m.lt.0.0d0) then
00113 omega0 = omegam
00114 else if (sgg0m.lt.0.0d0.and.sgg1m.gt.0.0d0) then
00115 omega1 = omegam
00116 else
00117 write(6,*) omega0, omegam, omega1
00118 write(6,*) sgg0, sggm, sgg1
00119 stop 'calc_omega_drot_bisection.f90_type0'
00120 end if
00121
00122 if (omega.gt.ome) omega = ome
00123 if (omega.le.0.0d0) omega = small
00124
00125 error = dabs(ddomega/omega)
00126 numero = numero + 1
00127 if (numero>1000) then
00128 write(6,*) omega0, omegam, omega1
00129 write(6,*) vphiy, ome, ddomega
00130 write(6,*) ome, p4a2, bvydw
00131 write(6,*) Jome, ovyu, omega
00132 write(6,*)' numero = ', numero, ' error =',error
00133 end if
00134
00135 if (numero>1010) stop 'rotation law'
00136 if (dabs(error)<1.0d-14) exit
00137
00138
00139
00140
00141
00142 end do
00143
00144 end subroutine calc_omega_drot_bisection