Skip to content

Fix writing result on water_balance_error callback error. - #2305

Merged
visr merged 2 commits into
mainfrom
fix/write-arrow-crash
May 30, 2025
Merged

Fix writing result on water_balance_error callback error.#2305
visr merged 2 commits into
mainfrom
fix/write-arrow-crash

Conversation

@evetion

@evetion evetion commented May 27, 2025

Copy link
Copy Markdown
Member

When failing on a water balance error, the saved values are in an inconsistent state (the flows seems to have more timesteps than the basin) crashing our write method.

┌ Error: Too large water balance error
│   id = Basin #40
│   balance_error = -0.001659908081632593
│   relative_error = -0.19294117647058828
└ @ Ribasim /Users/evetion/code/Ribasim/core/src/callback.jl:456
┌ Error: Too large water balance error
│   id = Basin #57
│   balance_error = -0.0018341382494009707
│   relative_error = -2.0
└ @ Ribasim /Users/evetion/code/Ribasim/core/src/callback.jl:456
┌ Warning: Simulation crashed or interrupted.
└ @ Ribasim /Users/evetion/code/Ribasim/core/src/main.jl:51
ERROR: BoundsError: attempt to access 145×886 Matrix{Float64} at index [1:145, 887]
Stacktrace:
  [1] throw_boundserror(A::Matrix{Float64}, I::Tuple{Base.Slice{Base.OneTo{Int64}}, Int64})
    @ Base ./essentials.jl:14
  [2] checkbounds
    @ ./abstractarray.jl:699 [inlined]
  [3] view
    @ ./subarray.jl:214 [inlined]
  [4] maybeview
    @ ./views.jl:149 [inlined]
  [5] dotview
    @ ./broadcast.jl:1228 [inlined]
  [6] get_storages_and_levels(model::Ribasim.Model{OrdinaryDiffEqCore.ODEIntegrator{OrdinaryDiffEqBDF.QNDF{5, 0, ADTypes.AutoSparse{ADTypes.AutoForwardDiff{nothing, ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}}, ADTypes.KnownJacobianSparsityDetector{SparseArrays.SparseMatrixCSC{Bool, Int64}},

@visr visr added the core Issues related to the computational core in Julia label May 27, 2025
Comment thread core/src/write.jl Outdated
Co-authored-by: Martijn Visser <mgvisser@gmail.com>
@visr
visr merged commit d00c61d into main May 30, 2025
@visr
visr deleted the fix/write-arrow-crash branch May 30, 2025 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Issues related to the computational core in Julia

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants