Giter Site home page Giter Site logo

alexanderkell / elecsim Goto Github PK

View Code? Open in Web Editor NEW
43.0 2.0 10.0 566.38 MB

Long term electricity market agent based model simulation used to observe the effect of policy on investment decisions

Home Page: https://elecsim.readthedocs.io

License: MIT License

Python 0.65% Jupyter Notebook 76.24% R 0.01% HTML 23.11% CSS 0.01% Dockerfile 0.01%
electricity-market python3 agent-based-modeling scenario-tester

elecsim's Introduction

ElecSim

ElecSim is an agent-based model of an electricity market written in python. ElecSim can be generalised to any country, with the starting parameters set in a scenario file. However, ElecSim comes setup with data for the UK electricity market.

Through the manipulation of a scenario file, one can build a custom environment of electricity producers with their respective power plants, and an electricity market which matches demand with supply.

ElecSim allows practitioners to explore the effect of different policy options and starting conditions on electricity markets.

For the full papers which detail ElecSim, see publications [1] and [2].

Features

  • Integration of major power plant types
  • Default parameter data included for the UK
  • Example model library

Anaconda Environment

It is recommended that the user uses a (conda environment)[https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html] to isolate the packages when running ElecSim.

Create a conda environment on the command line, with the following command:

conda create -n elecsim python=3.7

Activate the environment with:

> conda activate elecsim

Later, to recover the system-wide "normal" python, deactivate the environment with:

> conda elecsim

Installation

It is recommended to install elecsim by first downloading the latest repository from github:

git clone https://github.com/alexanderkell/elecsim.git

Then, you can install elecsim as a python package with the following command from the directory where the elecsim folder has been saved:

python -m pip install -e "elecsim[dev]"

This allows you to make changes to the elecsim code, and for the changes to be immediately updated in your environment for the elecsim package.

Next, install the requirement packages for elecsim to run, from inside the elecsim folder:

python -m pip install -r requirements.txt

Getting started

Once ElecSim is installed, create a python file and fill it with the following code:

from elecsim.model.world import World 

number_of_years = 20
number_of_time_steps = 8

if __name__ == "__main__":
    world = World(2018, log_level="info", market_time_splices=8, number_of_steps=number_of_years*number_of_time_steps)
    for years in range(number_of_years):
        for time_steps in range(number_of_time_steps):
            world.step()

This code imports the World class. We use logging to display useful information of the run. This can be turned to 'warning' or changed to 'debug' for further information.

We instantiate the model to start in the year 2018. The first for loop steps the model 20 times, which is equivalent to 20 years in the model. The second for loop iterates through the 8 representative days. If you would like to run the model for a single year, just edit the number_of_years variable.

To see the output data check the directory where you ran the code, which should contain a folder called ElecSim_Output with CSVs. You can visualise this data in a visualisation proram of your choice. For instance seaborn, excel or ggplot.

Custom Scenario

Whilst elecsim comes with a fully parametrised case study of the UK in 2018, you can update the scenario data however you wish. Here we show you how to edit a scenario file for a model run.

Open the scenario file found here and make the required changes.

For a scenario of the Scottish electricity market we make the following changes:

segment_demand_diff = [17568, 21964, 23127, 24327, 25520, 26760, 27888, 28935, 29865, 30721, 31567, 32315, 33188, 34182, 35505, 37480, 39585, 42206, 45209, 52152]
# Peak demand in Scotland is 9.5 times smaller than that of the UK as a whole
segment_demand_diff = [x/9.5 for x in segment_demand_diff]
...
historical_hourly_demand = pd.read_csv('{}/data/processed/electricity_demand/uk_all_year_demand.csv'.format(ROOT_DIR))
historical_hourly_demand.demand = historical_hourly_demand.demand/9.5
...
# We read a new file containing power plants of Scotland
power_plants = pd.read_csv('/path/to/power_plants/scotland_plants.csv', dtype={'Start_date': int})

We then pass this new scenario file into the World class as shown below:

from elecsim.model.world import World 

if __name__ == "__main__":
    world = World(initialization_year = 2018, scenario_file='/path/to/scenario.py', log_level="warning")
    for years in range(20):
        for time_steps in range(8):
            world.step()

This will now run the Scottish scenario for 20 years, with 8 representative days per year.

Questions

If you run into an issue, please submit a ticket here and we'll be happy to help you get started.

elecsim's People

Contributors

alexanderkell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

elecsim's Issues

Basic Examples

I get a none-type error when I use the simple world = World(...) initialization. Are there any examples I can access via a notebook?

Compatibility issues with panda 2.0

Hey,

First of all thanks for all the effort! However I found a piece of code that needs to be updated, see the following StackOverflow entry:
https://stackoverflow.com/questions/75956209/error-dataframe-object-has-no-attribute-append

File ~\anaconda3\lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec
exec(code, globals, locals)

File c:\users\lothar\documents\github\elecsim\tst.py:1
from elecsim.model.world import World

File ~\Documents\GitHub\elecsim\elecsim_init_.py:1
from elecsim.model.world import World

File ~\Documents\GitHub\elecsim\elecsim\model\world.py:15
from elecsim.plants.fuel.capacity_factor.capacity_factor_calculations import (

File ~\Documents\GitHub\elecsim\elecsim\plants\fuel\capacity_factor\capacity_factor_calculations.py:9
import elecsim.scenario.scenario_data

File ~\Documents\GitHub\elecsim\elecsim\scenario\scenario_data.py:143
carbon_price_all_years = concatenate_carbon_price()

File ~\Documents\GitHub\elecsim\elecsim\scenario\scenario_data.py:138 in concatenate_carbon_price
carbon_cost = historical_carbon_price.append(carbon_price_scenario_df, sort=True)

File ~\anaconda3\lib\site-packages\pandas\core\generic.py:5989 in getattr
return object.getattribute(self, name)

AttributeError: 'DataFrame' object has no attribute 'append'

Cloning Issue

Good day!

I am an undergraduate student looking to pursue the use your software to simulate market operations for a specific scenario. In the process of following the instructions linked I've come across multiple errors and one with regards to cloning the repository, which seems to cause the other problems in using the program such as installation of the requirements.txt file. I was wondering if it is an error on my part as I am not too familiar with using github, or if there is a way I could work around it. Attached below is the error which occurs upon cloning the repository
ElecSim Error.docx
Thank you so much!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.