Skip to content

Commit

Permalink
Don't log NaN errors and limit output to top 5
Browse files Browse the repository at this point in the history
  • Loading branch information
visr committed Sep 23, 2024
1 parent cae6838 commit 16f897d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions core/src/logging.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,21 @@ function log_bottlenecks(model; converged::Bool)
flow_error = @. abs(cache.nlsolver.cache.atmp / u)
perm = sortperm(flow_error; rev = true)
errors = Pair{Symbol, Float64}[]
error_count = 0
max_errors = 5
for i in perm
node_id = Symbol(id_from_state_index(p, u, i))
error = flow_error[i]
if error < model.config.solver.reltol
# Stop reporting errors if they are too small or too many
if error < model.config.solver.reltol || error_count >= max_errors
break
end
push!(errors, node_id => error)
if isnan(error)
continue
else
push!(errors, node_id => error)
error_count += 1
end
end
if !isempty(errors)
@logmsg level "Convergence bottlenecks in descending order of severity:" errors...
Expand Down

0 comments on commit 16f897d

Please sign in to comment.