Skip to content

Simulation Clock Advancement Modes

Maggie Sullivan edited this page Jun 13, 2023 · 10 revisions

Once you start a simulation run in Alfalfa, the clock will always advance in 1 minute timesteps, and all output variables will be available at this interval. However, Alfalfa has 3 parameters available when starting a run which impact the rate at which the simulation clock advances: timescale, externalClock, and realtime. These modes are described below:

Advance via an external clock

  1. In this scenario, the model will only advance when explicitly told to advance by an external call. It has no regard for real time passing but sits in an idle state until told to advance. The simulation starts at the specified start time.
  2. Upon call to advance, Alfalfa will look for any points written from external sources, write these into the simulation, and advance the simulation one time step (1-minute in model time).
  3. It then waits to advance until the next call is made.
  4. It will stop if the model has advanced enough times such that the end datetime has passed or if it is specifically told to stop.

Advance at a specified timescale

  1. In this scenario, the timescale parameter is used to control the rate at which the internal clock advances through the simulation. It represents the integer ratio of model_time:real_time. For example, a value of 5 means that the simulation will advance at 5x the rate of real time. In other words, one minute of simulation time will occur every 12 seconds of real time.
  2. Regardless of the start time specified for the run, the simulation will begin running.
  3. Upon reaching the time to advance, Alfalfa will look for any points from external sources, write these into the simulation, and advance the simulation one time step (1-minute in model time).
  4. It then waits X time in real time before advancing through the next time step.
  5. It will proceed until it has reached the specified end datetime or if it is specifically told to stop.
  6. If the simulation falls more than 2 timesteps behind it will throw an error and kill the simulation.

Advance in real time

  1. This scenario is similar to the timescale with the following caveats.
  2. The timescale parameter is always one (i.e. the model advances one minute in model time for every one minute that passes in real time).
  3. If the specified model start time has already passed in real time, the start time will be overwritten to the current time and the simulation will begin. However, if the specified model start time has not already passed in real time, the simulation will not begin until that time in real time is reached.
  4. It will then proceed until it has reached the specified end datetime or if it is specifically told to stop.
  5. All external calls to advance the simulation are ignored.

Model Configuration

Openstudio

Tutorials

Guides

Reference

Modelica

Guides

Alfalfa Interaction

Tutorials

Guides

Reference

Explanation

Alfalfa Development

Guides

General

Reference

Explanation

Clone this wiki locally