Package: energysim
Compatible with Python 3.6 and above.
Documentation availablehere.What is energysim?energysimis a python based cosimulation tool designed to simplify multi-energy cosimulations. The tool was initially calledFMUWorld, since it focussed exclusively on combining models developed and packaged as Functional Mockup Units (FMUs). However, it has since been majorly updated to become a more generalisable cosimulation tool to include a more variety of energy system simulators.The idea behind development ofenergysimis to simplify cosimulation to focus on the high-level applications, such as energy system planning, evaluation of control strategies, etc., rather than low-level cosimulation tasks such as message exchange, time progression coordination, etc.Currently,energysimallows users to combine:Dynamic models packaged asFunctional Mockup Units.Pandapower networks packaged aspickle files.PyPSA models (still under testing) asExcel files.User-defined external simulators interfaced with.py functions.CSV data filesInstallationenergysimcan be installed withpipusing:pip install energysimDependenciesenergysimrequires the following packages to work:FMPyPandapowerPyPSANumPyPandasMatplotlibNetworkXtqdmPyTablesUsageenergysimcosimulation is designed for an easy-plug-and-play approach. The main component is theworld()object. This is the “playground” where all simulators, and connections are added and the options for simulation are specified.world()can be imported by implementing:from energysim import worldInitializationOnceworldis imported, it can be initialized with basic simulation parameters using:my_world = world(start_time=0, stop_time=1000, logging=True, t_macro=60)worldaccepts the following parameters :start_time: simulation start time (0 by default).stop_time: simulation end time (1000 by default).logging: Flag to toggle update on simulation progress (True by default).t_macro: Time steps at which information between simulators needs to be exchanged. (60 by default).Adding SimulatorsAfter initializing the world cosimulation object, simulators can be added to the world using theadd_simulator()method:my_world.add_simulator(sim_type='fmu', sim_name='FMU1',
sim_loc=/path/to/sim, inputs=['v1', 'v2'], outputs=['var1','var2'], step_size=1)where:sim_type: ‘fmu’, ‘powerflow’, ‘csv’, ‘external’sim_name: Unique simulator name.sim_loc: A raw string address of simulator location.outputs: Variables that need to be recorded from the simulator during simulation.inputs: Input variables to the simulator.step_size: Internal step size for simulator (1e-3 by default).Please see documentation onadd_simulatorto properly add simulators toenergysim.
The values to simulator input are kept constant for the duration between two macro time steps.Connections between simulatorsOnce all the required simulators are added, the connections between them can be specified with a dictionary as followsconnections = {'sim1.output_variable1' : 'sim2.input_variable1',
   'sim3.output_variable2' : 'sim4.input_variable2',
   'sim1.output_variable3' : 'sim2.input_variable3',}This dictionary can be passed onto the world object:my_world.add_connections(connections)Initializing simulator variablesInitialization is important to start-up simulator in a cosimulation. If the simulators are not internally initialized, or of users want to use different initial conditions for the simulators, it can easily be done inenergysim. To provide initial values to the simulators, aninitdictionary can be specified and given to theworldobjectinitializations = {'sim_name1' : (['sim_variables'], [values]),
                   'sim_name2' : (['sim_variables'], [values])}
options = {'init' : initializations}
my_world.options(options)Executing simulationThesimulate()function can be called to simulate the world.
Whenrecord_allis True,energysimrecords the value of variables not only at macro time steps, but also at micro time steps specified by the user when adding the simulators. This allows the users to get a better understanding of simulators in between macro time steps. When set to False, variables are only recorded at macro time step. This is useful in case a long term simulation (for ex. a day) is performed, but one of the simulators has a time step in milli-seconds.pbarcan be used to toggle the progress bar for the simulation:my_world.simulate(pbar=True, record_all=False)Extracting ResultsResults can be extracted by callingresults()function onmy_worldobject. This returns a dictionary object with each simulators’ results as pandas dataframe. Additionally,to_csvflag can be toggled to export results to csv files.results = my_world.results(to_csv=True)More information is provided on the documentation page.## Citing
Please cite the following paper if you useenergysim:
Gusain, D, Cvetković, M & Palensky, P 2019, Energy flexibility analysis using FMUWorld. in 2019 IEEE Milan PowerTech., 8810433, IEEE, 2019 IEEE Milan PowerTech, PowerTech 2019, Milan, Italy, 23/06/19.https://doi.org/10.1109/PTC.2019.8810433