seasonal: Create a seasonal wave function

View source: R/custom_func.R

seasonalR Documentation

Create a seasonal wave function

Description

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.

Details

Equivalent of Seasonal() in Insight Maker

Value

Seasonal interpolation function

See Also

step(), pulse(), ramp()

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)


sdbuildR documentation built on Nov. 19, 2025, 5:07 p.m.