Simulation

Simulation

Simulation()

Simulation environment object for handling projects and print messages

It is the entry point of every OpenSimula program:

import opensimula as osm

sim = osm.Simulation()
pro = sim.new_project("Project one")
pro.read_json("project.json")
pro.simulate()

Attributes:

Name Type Description
console_print bool

Print the messages in the console when they are added. Defaults to True.

new_project

new_project(project_name)

Create new project in the Simulation

Parameters:

Name Type Description Default
project_name str

Name of the project to be added to the simulation environment

required

Returns:

Type Description
Project

The new project, None if there is already a project with that name.

del_project

del_project(project)

Delete project from Simulation

Parameters:

Name Type Description Default
project Project

Project to be removed from the simulation environment

required

project

project(name)

Find and return a project using its name

Parameters:

Name Type Description Default
name str

name of the project

required

Returns:

Type Description
Project

project found, None if not found.

project_list

project_list()

Projects list in the simulation environment

Returns:

Type Description
list of Project

Projects of the simulation environment.

project_dataframe

project_dataframe(string_format=False)

Parameters of all the projects as a table

Parameters:

Name Type Description Default
string_format bool

Convert every value to string. Defaults to False.

False

Returns:

Type Description
DataFrame

One row per project, one column per parameter.

message

message(message)

Add new message

Store de message in the message_list and print if console_print = True

Parameters:

Name Type Description Default
message Message

message to add

required

message_list

message_list()

List of messages

Returns:

Type Description
list of Message

Messages added with message(), in order.

plot

plot(dates, variables, names=[], axis=[], frequency=None, value='mean', interval=None)

Draw variables graph (using plotly)

Parameters:

Name Type Description Default
dates array of datetime

Dates of the values, usually project.dates().

required
variables list of Variable

Variables to draw.

required
names list of str

Names of the series; variables beyond the list are named "component:variable". Defaults to [].

[]
axis list of int

y axis (1 or 2) of each variable; variables beyond the list use the first axis. Defaults to [].

[]
frequency None or str

frequency of the values: None, "hourly", "daily", "monthly", "yearly". Defaults to None.

None
value str

"mean", "sum", "sum_pos", "sum_neg", "max" or "min". Defaults to "mean".

'mean'
interval None or list of two dates

List with the start and end dates of the period to be included in the dataframe, if the value is None all values are included.

None