Initializing Models

Initializing Models#

The central modeling object in Energia is the Model. Be sure to create and activate your environment before running any of the code in Tutorials and Examples. Instructions for the same can be found in the Installation tutorial.

If you are unsure about what components you will need in modeling, use:

from energia import *

If you know what your need, provide the import individually

from energia import Model, si_units, time_units

Any of the components initialized using the functions in energia.library.components can also be provided using component definitions. For example,

m = Model(init=[si_units, time_units])

Is the same as,

m = Model()

# Base units
m.m = Unit(label='m')  # meter
m.kg = Unit(label='kg')  # kilogram

m.km = 1000 * m.m  # kilometer

# Derived units
m.kW = 1000 * Unit(label='W')  # kilowatt
m.MW = 1000 * m.kW  # megawatt
m.GW = 1000 * m.MW  # gigawatt

m.J = Unit(label='J')  # joule
m.kJ = 1000 * m.J  # kilojoule
m.MJ = 1000 * m.kJ  # megajoule

# Time units
m.h = TemporalScales([1, 365, 24, 60, 60], ['y', 'd', 'h', 'min', 's'])

You can check your definitions at any time

m.units
[m, kg, km, kW, MW, GW, J, kJ, MJ]
m.periods
[s, min, h, d, y]