# NOT RUN {
# kinematic wave routing
times = seq(0, 30000, by = 25)
floodwave = ifelse(times >= 9000, 250,
250 + (750/pi)*(1 - cos(pi*times/(60*75))))
route_wave(0.001, 0.045, 1.486, 32.2, 100, 0, initial.condition = 250,
boundary.condition = floodwave, timestep = 25, spacestep = 50,
numnodes=301, monitor.nodes = c(1, 101, 201, 301),
monitor.times = seq(1, length(times), by = 10), engine = "Kinematic")
# dynamic wave routing with zero-gradient downstream condition using MacCormack scheme
route_wave(0.001, 0.045, 1.486, 32.2, 100, 0, initial.condition = 250,
boundary.condition = floodwave, downstream.condition = rep(-1, length(times)),
timestep = 25, spacestep = 500, numnodes = 31, engine = "Dynamic",
scheme = "MacCormack", monitor.nodes = c(1, 11, 21, 31),
monitor.times = seq(1, length(times), by = 10))
# mixed boundary conditions (sudden gate closure) using Lax scheme
lax = route_wave(0.00008, 0.013, 1, 9.81, 6.1, 1.5,
initial.condition = 126, boundary.condition = rep(5.79, 2001),
downstream.condition = rep(0, 2001), timestep = 1, spacestep = 10,
numnodes = 501, monitor.nodes = c(1, 151, 251, 301, 501),
monitor.times = c(1, 501, 1001, 1501, 2001),
engine="Dynamic", scheme="Lax", boundary.type="yQ")
# extract data for a monitored point
require(dplyr)
filter(lax, monitor.type == "node", node == 151)
# }
Run the code above in your browser using DataLab