Skip to content

Commit

Permalink
Tweaked crater exterior function
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Dec 6, 2016
1 parent dca7b04 commit 81bcac6
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions src/crater/crater_form_exterior_rootfind.f90
Original file line number Diff line number Diff line change
Expand Up @@ -43,34 +43,41 @@ subroutine crater_form_exterior_rootfind(user,surf,crater,domain,deltaMtot)
real(DP) :: resultat,AA,BB,CC,DD,EE,FA,FB,FC,Tol1,PP,QQ,RR,SS,xm
integer(I4B) :: i,j, ev,br
integer(I4B),parameter :: NTRY = 50
integer(I4B),parameter :: NBRACKET = 5
real(DP),parameter :: FIRSTFACTOR = 1.6_DP
integer(I4B),parameter :: NBRACKET = 10
real(DP),parameter :: FIRSTFACTOR = 3.2_DP
real(DP) :: factor
real(DP) :: f1,f2

! Executable code
if (abs(deltaMtot) < VSMALL) return
if (deltaMtot > 0._DP) return
lastloop = .false.
factor=FIRSTFACTOR
factor = FIRSTFACTOR
startrd = RIMDROP
x1 = startrd
x2 = startrd / factor


! First bracket the root
f1 = crater_form_exterior_func(user,surf,crater,domain,x1,deltaMtot,lastloop)
f2 = crater_form_exterior_func(user,surf,crater,domain,x2,deltaMtot,lastloop)
do j = 1, NTRY
if (f1 * f2 < 0._DP) exit
if (abs(f1) < abs(f2)) then
x1 = x1 + factor * (x1 - x2)
f1 = crater_form_exterior_func(user,surf,crater,domain,x1,deltaMtot,lastloop)
else
x2 = x2 + factor * (x2 - x1)
f2 = crater_form_exterior_func(user,surf,crater,domain,x2,deltaMtot,lastloop)
end if

end do
bracket: do br=1,NBRACKET
factor = factor / 2
x1 = startrd
x2 = startrd / factor
f1 = crater_form_exterior_func(user,surf,crater,domain,x1,deltaMtot,lastloop)
f2 = crater_form_exterior_func(user,surf,crater,domain,x2,deltaMtot,lastloop)
do j = 1, NTRY
if (f1 * f2 < 0._DP) exit bracket
if (abs(f1) < abs(f2)) then
x1 = x1 + factor * (x1 - x2)
f1 = crater_form_exterior_func(user,surf,crater,domain,x1,deltaMtot,lastloop)
else
x2 = x2 + factor * (x2 - x1)
f2 = crater_form_exterior_func(user,surf,crater,domain,x2,deltaMtot,lastloop)
end if
if (abs(f1) > huge(f1).or.(abs(f2) > huge(f2))) cycle bracket
!write(*,*)
!write(*,*) j,factor,x1,x2,f1,f2,crater%fcrat
!read(*,*)
end do
end do bracket
!!if (f1 * f2 >= 0._DP) then
! write(*,*) crater%fcrat
! write(*,*) deltaMtot
Expand Down

0 comments on commit 81bcac6

Please sign in to comment.