Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Removed conflict text and fixed energy reporting
  • Loading branch information
daminton committed May 15, 2021
1 parent fb2ab8d commit ed0d515
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
7 changes: 1 addition & 6 deletions src/symba/symba_frag_pos.f90
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ subroutine symba_frag_pos (param, symba_plA, family, x, v, L_spin, Ip, mass, rad
end do
write(*, "(' ---------------------------------------------------------------------------')")
write(*,fmtlabel) ' T_frag calc |',ke_frag / abs(Etot_before)
write(*,fmtlabel) ' residual |',1.0_DP - ke_frag / ke_target
write(*,fmtlabel) ' residual |',(ke_frag - ke_target) / abs(Etot_before)

! Calculate the new energy of the system of fragments
call symba_frag_pos_energy_calc(npl, symba_plA, lexclude, ke_after, ke_spin_after, pe_after, Ltot_after,&
Expand Down Expand Up @@ -350,12 +350,7 @@ subroutine symba_frag_pos_kinetic_energy(m_frag, ke_target, L_target, x_frag, v_
logical, intent(out) :: lmerge

! Internals
<<<<<<< HEAD
integer(I4B) :: i, neval
=======
real(DP) :: mtot !! Total mass of fragments
integer(I4B) :: i, nfrag, neval
>>>>>>> Fragmentation
real(DP), parameter :: TOL = 1e-12_DP
real(DP), dimension(:), allocatable :: vflat
logical :: lerr
Expand Down
19 changes: 10 additions & 9 deletions src/util/util_minimize_bfgs.f90
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,8 @@ function util_minimize_bfgs(f, N, x0, eps, lerr) result(x1)
real(DP), dimension(:), allocatable :: x1
! Internals
integer(I4B) :: i, j, k, l, conv, num, fnum
<<<<<<< HEAD
integer(I4B), parameter :: MAXLOOP = 100 !! Maximum number of loops before method is determined to have failed
integer(I4B), parameter :: MAXLOOP = 200 !! Maximum number of loops before method is determined to have failed
real(DP), parameter :: gradeps = 1e-5_DP !! Tolerance for gradient calculations
=======
integer(I4B), parameter :: MAXLOOP = 2000 !! Maximum number of loops before method is determined to have failed
real(DP), parameter :: gradeps = 1e-4_DP !! Tolerance for gradient calculations
>>>>>>> Fragmentation
real(DP), dimension(N) :: S !! Direction vectors
real(DP), dimension(N) :: Snorm !! normalized direction
real(DP), dimension(N,N) :: H !! Approximated inverse Hessian matrix
Expand All @@ -60,7 +55,10 @@ function util_minimize_bfgs(f, N, x0, eps, lerr) result(x1)
if (abs(grad1(k)) > eps) conv = conv + 1
S(k) = -sum(H(:,k) * grad1(:))
end do
if (conv == 0) return
if (conv == 0) then
write(*,*) "Converged on gradient after ",i," iterations"
return
end if
! normalize gradient
Snorm(:) = S(:) / norm2(S)
num = fnum + minimize1D(f, x1, Snorm, N, eps, astar)
Expand All @@ -86,7 +84,10 @@ function util_minimize_bfgs(f, N, x0, eps, lerr) result(x1)
end do
end do
! prevent divide by zero (convergence)
if (abs(Py) < tiny(Py)) return
if (abs(Py) < tiny(Py)) then
write(*,*) "Converged on tiny Py"
return
end if
! set up update
PyH(:,:) = 0._DP
HyP(:,:) = 0._DP
Expand All @@ -102,7 +103,7 @@ function util_minimize_bfgs(f, N, x0, eps, lerr) result(x1)
! update H matrix
H(:,:) = H(:,:) + ((1._DP - yHy / Py) * PP(:,:) - PyH(:,:) - HyP(:,:)) / Py
end do

write(*,*) "Did not converge!"
return

contains
Expand Down

0 comments on commit ed0d515

Please sign in to comment.