Skip to content

Commit

Permalink
Check leaky Terminals
Browse files Browse the repository at this point in the history
  • Loading branch information
visr committed Oct 1, 2024
1 parent d538627 commit 7396cd7
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion core/src/callback.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,14 @@ Update with the latest timestep:
"""
function update_cumulative_flows!(u, t, integrator)::Nothing
(; p, uprev, tprev, dt) = integrator
(; basin, user_demand, flow_boundary, allocation) = p
(;
basin,
user_demand,
flow_boundary,
allocation,
state_inflow_edge,
state_outflow_edge,
) = p
(; vertical_flux_bmi, vertical_flux_from_input) = basin

# Update tprev
Expand Down Expand Up @@ -150,6 +157,25 @@ function update_cumulative_flows!(u, t, integrator)::Nothing
end
end
end

for (inflow_edge, outflow_edge) in zip(state_inflow_edge, state_outflow_edge)
from_flow = inflow_edge.edge[1]
to_flow = outflow_edge.edge[2]
if from_flow.type == NodeType.Basin
flow = flow_update_on_edge(integrator, inflow_edge.edge)
if to_flow.type == NodeType.Terminal && flow < 0 && to_flow.value != 0
@warn "Unsupported inflow type $(to_flow.type) #$(to_flow.value) with flow $flow"
end
end

if to_flow.type == NodeType.Basin
flow = flow_update_on_edge(integrator, outflow_edge.edge)
if from_flow.type == NodeType.Terminal && flow > 0 && from_flow.value != 0
@warn "Unsupported outflow type $(from_flow.type) #$(from_flow.value) with flow $flow"

Check warning on line 174 in core/src/callback.jl

View check run for this annotation

Codecov / codecov/patch

core/src/callback.jl#L174

Added line #L174 was not covered by tests
end
end
end

return nothing
end

Expand Down

0 comments on commit 7396cd7

Please sign in to comment.