This is the Simulation module. The Simulation layer takes of creating output variables, writing data to disk, iterating over data and calculations at each interval in the simulation and setting any parameters required to perform the simulation. It gets all its info from the model, which in turn gets it from each layer which gets info from the layers’ sources.

Simulations Parameter

class carousel.core.simulations.SimParameter(*args, **kwargs)[source]

See Simulation attributes for list of parameter arguments.

Simulations Registry

class carousel.core.simulations.SimRegistry[source]

Registry for simulations.

Simulations Base

class carousel.core.simulations.SimBase[source]

Meta class for simulations.


class carousel.core.simulations.Simulation(simfile=None, settings=None, **kwargs)[source]

A class for simulations.

  • simfile (str) – Filename of simulation configuration file.
  • settings – keyword name of simulation parameter to use for settings

Simulation attributes can be passed directly as keyword arguments directly to Simulation or in a JSON file or as class attributes in a subclass or a combination of all 3 methods.

To get a list of Simulation attributes and defaults get the attrs attribute.

Any additional settings provided as keyword arguments will override settings from file.

Attribute defaults are given in square brackets if not specified.


class attributes and their defaults


ID for this particular simulation, used for path & file names, defaults to hyphenation of the class name and date/time in ISO format.


path where Carousel simulation files are stored, defaults to Carousel/Simulations in the $HOME directory


list of commands corresponding to methods exposed to model, defaults to [‘start’, ‘pause’]


dictionary of batch data to simulate [None]


thresholds for dynamic calculations as a dictionary of maximum and minimum limits for each data, eg: {‘DNI’: [0, 1400]} will limit DNI between zero and the solar constant [None]


length of each interval [1-hour]


simulation length [1-year]


frequency output is displayed, default is every interval


fields displayed, default is None which displays all fields


frequency output is saved, default to number_intervals


fields written to disk, default is None which writes all fields

calc_order = None

order of calculations


Check if data loaded for all sources in data layer.

Parameters:data (Data) – data layer from model
Returns:dictionary of data sources and objects or None if not loaded
cmd_queue = None

command queue

idx_iter = None

index iterator


Generator that resumes from same index, or restarts from sent index.


Initialize the simulation. Organize calculations by dependency.

Parameters:calc_reg (CalcRegistry) – Calculation registry.
interval_idx = None

interval index, start at zero


Data loaded property, read only. True if data loaded.


Completion property, read only. True if finished.


Initialization property, read only. True if initialized.


Pause property, read only. True if paused.

number_intervals = None

total number of intervals simulated

param_file = None

parameter file

parameters = None

simulation parameters from keyword arguments


Pause the simulation. How is this different from stopping it? Maintain info sufficient to restart simulation. Sets is_paused to True. Will this state allow analysis? changing parameters? What can you do with a paused simulation? Should be capable of saving paused simulation for loading/resuming later, that is the main usage. EG: someone else need computer, or power goes out, so on battery backup quickly pause simulation, and save. Is save automatic? Should there be a parameter for auto save changed?

settings = None

name of sim settings used for parameters

start(model, progress_hook=None)[source]

Start the simulation from time zero.

  • model – Model with layers and registries containing parameters
  • progress_hook (function) – A function that receives either a string or a list containing the index followed by tuples of the data or outputs names and values specified by write_fields in the simfile.


The model registries should contain the following layer registries: * DataRegistry, * FormulaRegistry, * OutputRegistry, * CalcRegistry