Skip to content

Commit 7f47e7f

Browse files
committed
Count each equation once in the solver residual average
The full equation loop already includes composition. Remove the obsolete composition pass so each included residual contributes once to the mean. Maximum residuals, equation weights and the Newton system are unchanged. The older structural loop and separate composition loop were disjoint in r1396. Duplicate counting is present by r3731 and predates public Git history, so no introducing PR has been verified. The extracted sizequ passed 57 numerical checks covering weighted means, ignored equations, maximum residuals and nonfinite inputs.
1 parent 478cf4c commit 7f47e7f

1 file changed

Lines changed: 3 additions & 17 deletions

File tree

‎star/private/solver_support.f90‎

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ subroutine sizequ(s, nvar, equ_norm, equ_max, k_max, j_max, ierr) ! equ = resid
188188
real(dp), intent(out) :: equ_norm, equ_max
189189
integer, intent(out) :: k_max, j_max, ierr
190190

191-
integer :: j, k, num_terms, n, nz, nvar_hydro, nvar_chem, skip_eqn1, skip_eqn2, skip_eqn3
191+
integer :: j, k, num_terms, n, nz, nvar_hydro, skip_eqn1, skip_eqn2, skip_eqn3
192192
real(dp) :: sumequ, absq
193193

194194
logical :: dbg
@@ -205,7 +205,6 @@ subroutine sizequ(s, nvar, equ_norm, equ_max, k_max, j_max, ierr) ! equ = resid
205205
dbg = s% solver_check_everything
206206

207207
nvar_hydro = min(nvar, s% nvar_hydro)
208-
nvar_chem = s% nvar_chem
209208

210209
nz = s% nz
211210
n = nz
@@ -217,6 +216,8 @@ subroutine sizequ(s, nvar, equ_norm, equ_max, k_max, j_max, ierr) ! equ = resid
217216
if (s% convergence_ignore_equL_residuals) skip_eqn1 = s% i_equL
218217
if (s% convergence_ignore_alpha_RTI_residuals) skip_eqn2 = s% i_dalpha_RTI_dt
219218
if (s% do_burn .or. s% do_mix) then
219+
! Count each equation once. The loop over all variables replaced the
220+
! structural sum, so a separate composition pass would count those rows twice.
220221
num_terms = num_terms + nvar*nz
221222
if (skip_eqn1 > 0) num_terms = num_terms - nz
222223
if (skip_eqn2 > 0) num_terms = num_terms - nz
@@ -270,21 +271,6 @@ subroutine sizequ(s, nvar, equ_norm, equ_max, k_max, j_max, ierr) ! equ = resid
270271
end do
271272
end do
272273
end if
273-
if (s% do_burn .or. s% do_mix) then
274-
num_terms = num_terms + nvar_chem*nz
275-
do k = 1, nz
276-
do j = nvar_hydro+1, nvar
277-
absq = abs(s% equ(j,k)*s% residual_weight(j,k))
278-
sumequ = sumequ + absq
279-
if (absq > equ_max) then
280-
equ_max = absq
281-
j_max = j
282-
k_max = k
283-
end if
284-
end do
285-
end do
286-
end if
287-
288274
equ_norm = sumequ/num_terms
289275
if (dbg) write(*,4) trim(s% nameofequ(j_max)) // ' sizequ equ_max norm', &
290276
k_max, s% solver_iter, s% model_number, equ_max, equ_norm

0 commit comments

Comments
 (0)