Skip to contents

Create a seasonal wave function that oscillates between -1 and 1, with a specified period and shift. The wave peaks at the specified shift time.

Usage

seasonal(times, period = 1, shift = 0)

Arguments

times

Vector of simulation times

period

Duration of wave in simulation time units. Defaults to 1.

shift

Timing of wave peak in simulation time units. Defaults to 0.

Value

Seasonal interpolation function

Details

Equivalent of Seasonal() in Insight Maker

See also

step(), pulse(), ramp()

Other input: pulse(), ramp(), step()

Examples

# Create a simple model with a seasonal wave
sfm <- xmile() |>
  build("a", "stock") |>
  # Specify the global variable "times" as simulation times
  build("input", "constant", eqn = "seasonal(times, 10, 0)") |>
  build("inflow", "flow", eqn = "input(t)", to = "a")

sim <- simulate(sfm, only_stocks = FALSE)
plot(sim)