Skip to content

Commit

Permalink
Don't let SubMinLineSearch try to push species concentrations above 1
Browse files Browse the repository at this point in the history
  • Loading branch information
maxposchmann committed Dec 15, 2022
1 parent 85624b9 commit 3058b37
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/gem/Subminimization.f90
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ subroutine SubMinLineSearch(iSolnPhaseIndex)
implicit none

integer :: i, j, k, iSolnPhaseIndex
real(8) :: dStepLength, dTemp, dMaxChange
real(8) :: dStepLength, dTemp, dMaxChange, dChange

! Initialize variables:
dStepLength = 1D0
Expand Down Expand Up @@ -575,9 +575,15 @@ subroutine SubMinLineSearch(iSolnPhaseIndex)
! Absolute species index:
i = iFirst + j - 1
! Apply step length:
dMolFraction(i) = dMolFraction(i) + dStepLength * dRHS(j)
dChange = dStepLength * dRHS(j)
if (dMolFraction(i) + dChange > 1D0) then
dChange = 1D0 - dMolFraction(i)
end if
dMolFraction(i) = dMolFraction(i) + dChange
! Store maximum change to the mole fraction:
dTemp = DMAX1(dTemp, DABS(dRHS(j)))
if (dChange > dTemp) then
dTemp = dChange
end if
end do

! Iterate to satisfy Wolfe conditions:
Expand Down

0 comments on commit 3058b37

Please sign in to comment.