Modeler’s Corner
Running Models Using Calendar-Based Timesteps
Rick Kossik
Principal
GoldSim Technology Group
rkossik@goldsim.com
GoldSim allows you to run models based on either elapsed time or calendar date/time. Running calendar date/time models, however, can be a bit tricky, since calendar-based models are complicated by variability of the basic time units (e.g., the number of days in a month changes for each month, and due to leap years, the length of a year is also variable). So how do you instruct GoldSim to have a timestep once per month (e.g., on the 1st day of each month) or once per quarter (e.g., on the 1st day of each quarter)?
This can be accomplished by using Time phases. Time phases can be used to create a simulation with timesteps at the beginning of every month, every quarter, or every year. Time phases are created within the Time tab of the Simulation Settings dialog. Phases can have different durations and timestep lengths. By default, there is a single time phase in GoldSim, with a duration (a time range) equal to the simulation duration. The timestep length is equal to the duration divided by the number of timesteps specified in the #Steps field for the phase:

In this example, there is a single time phase with a duration of 100 days and a timestep of one day.
You can add a new phase by pressing the Add… button. You will then be prompted for the Start-Time for the new phase.
When you are carrying out a Date-time simulation, you must enter the date and time for the start of the new phase:

This could, for example, result in the following:

In this example, there are two time phases, each with different durations consisting of a single step.
Given this information, you could use time phases to create a monthly timestep as follows:
- Set up your simulation as a Date-time simulation.
- Create a separate phase for each month (with the specified Start-Time for the phase being the 1st of each month), specifying that each phase has 1 step.
This approach works well on shorter simulations. However, if your simulation required a large number of phases, it would be tedious to create each phase (e.g., a 10 year simulation with monthly timesteps would require 120 phases to be manually created).
To address this, GoldSim provides a "shortcut" for automatically creating new phases. In particular, if you have specified your Basic Time Settings to run a Date-time simulation, a number of context menu options are provided when you right-click within a defined phase in the Time Phase Settings portion of the dialog:

Selecting Add a step for each calendar month causes GoldSim to insert a new Phase starting on the first day of each month:

Each phase has a single step with the length automatically adjusted for the actual length of time between each step. Similarly, selecting Add a step for each calendar quarter causes GoldSim to insert a new Phase starting on the first day of each quarter:

Selecting Add a step for each calendar year causes GoldSim to insert a new Phase starting on the first day of each year:

Suggestions?
Do you have any suggestions for future Modeler's Corner articles? If so, I'd love to hear from you. Please contact me directly at rkossik@goldsim.com.
|