Create pulse function
pulse.Rd
Create a pulse function that jumps from zero to a specified height at a specified time, and returns to zero after a specified width. The pulse can be repeated at regular intervals.
Arguments
- start
Start time of pulse in simulation time units.
- height
Height of pulse. Defaults to 1.
- width
Width of pulse in simulation time units. This cannot be equal to or less than 0. To indicate an instantaneous pulse, specify the simulation step size.
- repeat_interval
Interval at which to repeat pulse. Defaults to NULL to indicate no repetition.
Examples
# Create a simple model with a pulse function
# that starts at time 5, jumps to a height of 2
# with a width of 1, and does not repeat
sfm = xmile() %>%
build("a", "stock") %>%
build("input", "constant", eqn = "pulse(5, 2, 1)") %>%
build("inflow", "flow", eqn = "input(t)", to = "a")
sim = simulate(sfm)
plot(sim)
# Create a pulse that repeats every 5 time units
sfm = sfm %>%
build("input", eqn = "pulse(5, 2, 1, 5)")
sim = simulate(sfm)
plot(sim)