Skip to content

Commit 8f0d54a

Browse files
Reorganize code to support running a single timestep
Support all nodes
1 parent 6a3d729 commit 8f0d54a

File tree

2 files changed

+36
-36
lines changed

2 files changed

+36
-36
lines changed

src/Nodes/IHACRES/IHACRESNode.jl

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -190,42 +190,6 @@ function update_state!(
190190
return nothing
191191
end
192192

193-
"""
194-
run_node!(
195-
node::IHACRESNode, climate::Climate, ts::Int;
196-
inflow=nothing, extraction=nothing, exchange=nothing
197-
)
198-
199-
Run a specific node for a specified time step.
200-
201-
# Arguments
202-
- `node` : An IHACRES node
203-
- `climate` : Climate dataset
204-
- `ts` : current time step
205-
- `inflow` : Time series of inflows from upstream nodes.
206-
- `extraction` : Time series of water orders (expects column of `_releases`)
207-
- `exchange` : Time series of groundwater flux
208-
"""
209-
function run_node!(
210-
node::IHACRESNode, climate::Climate, ts::Int;
211-
inflow=nothing, extraction=nothing, exchange=nothing
212-
)
213-
if checkbounds(Bool, node.outflow, ts)
214-
if node.outflow[ts] != undef
215-
# already ran for this time step so no need to run
216-
return node.outflow[ts], node.level[ts]
217-
end
218-
end
219-
220-
node_name = node.name
221-
rain, et = climate_values(node, climate, ts)
222-
wo = timestep_value(ts, node_name, "releases", extraction)
223-
ex = timestep_value(ts, node_name, "exchange", exchange)
224-
in_flow = timestep_value(ts, node_name, "inflow", inflow)
225-
226-
return run_timestep!(node, rain, et, ts; inflow=in_flow, extraction=wo, exchange=ex)
227-
end
228-
229193
"""
230194
run_timestep!(
231195
node::IHACRESBilinearNode, climate::Climate, timestep::Int,

src/Streamfall.jl

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,42 @@ function run_node!(
220220
return nothing
221221
end
222222

223+
"""
224+
run_node!(
225+
node::NetworkNode, climate::Climate, ts::Int;
226+
inflow=nothing, extraction=nothing, exchange=nothing
227+
)
228+
229+
Run a specific node for a specified time step.
230+
231+
# Arguments
232+
- `node` : A node in a network
233+
- `climate` : Climate dataset
234+
- `ts` : current time step
235+
- `inflow` : Time series of inflows from upstream nodes.
236+
- `extraction` : Time series of water orders (expects column of `_releases`)
237+
- `exchange` : Time series of groundwater flux
238+
"""
239+
function run_node!(
240+
node::NetworkNode, climate::Climate, ts::Int;
241+
inflow=nothing, extraction=nothing, exchange=nothing
242+
)
243+
if checkbounds(Bool, node.outflow, ts)
244+
if node.outflow[ts] != undef
245+
# already ran for this time step so no need to run
246+
return node.outflow[ts], node.level[ts]
247+
end
248+
end
249+
250+
node_name = node.name
251+
rain, et = climate_values(node, climate, ts)
252+
wo = timestep_value(ts, node_name, "releases", extraction)
253+
ex = timestep_value(ts, node_name, "exchange", exchange)
254+
in_flow = timestep_value(ts, node_name, "inflow", inflow)
255+
256+
return run_timestep!(node, rain, et, ts; inflow=in_flow, extraction=wo, exchange=ex)
257+
end
258+
223259
include("Analysis/Analysis.jl")
224260
include("plotting.jl")
225261

0 commit comments

Comments
 (0)