User Defined Functions

Model Viewer User Defined Functions: PULSE, RAMP, STEP

The following Excel user-defined functions (UDFs) provide versatile inputs for dynamic simulation and modeling scenarios. They facilitate accurate representation of controlled input variations over time within Excel, enhancing the analysis capabilities of models.

1. PULSE(volume, time, start_time, time_step, firstPulse, interval)

Functionality:

Generates repeated pulse signals of a specified magnitude (volume) starting at a defined initial pulse time and potentially repeating at regular intervals.

Parameters:

  • volume (numeric): Magnitude of the pulse input.
  • time (numeric): Current simulation or evaluation time.
  • start_time (numeric): Reference start time of the simulation.
  • time_step (numeric): Simulation increment between time points.
  • firstPulse (numeric, optional): Time when the initial pulse occurs (defaults to start_time).
  • interval (numeric, optional): Time between subsequent pulses (defaults to time_step).

Output:

Returns the pulse magnitude (volume / time_step) at specified pulse times; otherwise returns 0.

Example:

=PULSE(10, current_time, 0, 1, 5, 3)

This generates pulses of magnitude 10 every 3 time units, starting at time 5.

2. RAMP(slope, time, start_time, stop_time)

Functionality:

Produces a signal that linearly increases or decreases with a specified rate (slope) between a defined start and optional stop time.

Parameters:

  • slope (numeric): The rate of change per unit time.
  • time (numeric): Current simulation or evaluation time.
  • start_time (numeric, optional): Time at which the ramp begins (defaults to 0).
  • stop_time (numeric, optional): Time at which the ramp stops increasing or decreasing (defaults to current time).

Output:

  • Returns 0 if time is earlier than start_time.
  • Returns (time - start_time) * slope if between start_time and stop_time.
  • Returns (stop_time - start_time) * slope if time is beyond stop_time.

Example:

=RAMP(1.5, current_time, 2, 7)

Output increases linearly from time 2 to 7 at a rate of 1.5 per time step, remaining constant afterward.

3. STEP(height, start_time, time, duration, interval)

Functionality:

Creates instantaneous or periodic step changes of specified height at defined times.

Parameters:

  • height (numeric): Magnitude of the step change.
  • start_time (numeric): Time when the step first occurs.
  • time (numeric): Current simulation or evaluation time.
  • duration (numeric, optional): Length of time the step remains active.
  • interval (numeric, optional): Time between repeating step signals.

Output:

  • Returns height starting at start_time and continuing indefinitely if duration is omitted.
  • If duration is specified, returns height for the duration period.
  • If interval is set, repeats the step at intervals, each active for the specified duration.

Example:

=STEP(5, 3, current_time, 2, 4)

Creates a step of magnitude 5 at time 3, lasting for 2 time units, repeating every 4 units.