Part 1 - Context and building the simulator
===========================================

In this project, we are going to implement a virtual power plant on 
Ethereum (using Solidity) and a Python client that will interact 
with this system.

In this context, our virtual power plant aims to manage a rather simplied
energy market between actors of a community.

Context
^^^^^^^
The goal is to implement a simple system to manage the energy 
in an small community. We will consider that this community 
is composed of participant that have different **equipements**. Those 
equipments can either be a **solar panel** (producing energy) or a **water 
heater** (consuming energy). We will simplify a bit the situation by considering
that each equipment is a participant. In other words, each participant can 
either produce or sell energy.

Each participant can place **orders** when they will need to buy energy from the community 
and they can sell energy when they produce. An order (either a selling or buying order) 
is composed of two informations : a quantity and a price per unit.

Orders will then be matched, in a **market**, with each others so participants can buy the energy 
they need or sell the energy they produced.

In this project we won't actually implement a real system (that will produce and consume energy 
over the course of one whole day) but rather a **simulator** that will trigger the different actions
in the system as they would have occured in a real world system. Instead of continously monitoring 
the energy production and demand, the simulator will execute the system at a given frequency (e.g 
once per hour) Such simulators are other easier to implement than real world system and can be used
to validate a prototype for later refinment. The simulator should output its data (energy produced, 
energy consumed, wallet of participants, ...) as a CSV file that you can later use with tools like 
Excel.

Our python simulator will interact with a **smart contract** that will manage the energy market. 

Phase 1 - Design 
^^^^^^^^^^^^^^^^

In this part of the project, we will design our system without coding first.

Implementing a software, even a small one, can be a daunting task. It can be 
really helpful to think in advance what we want to create before trying to 
implement it. That's what we are going to do here by designing first our system. 

The important tasks of this part is to identify the things we will need to implement (classes,
functions, interactions between the classes, ...). For our project we need to also 
think in advance about what will be implemented on the blockchain part (through smart contract)
and what will be implemented on the python part.

Specifications
--------------

From the explanations above, try to :

- Identify the differents entities interacting in the system (those entities will be later 
  implemented as classes or as a smart contract)
- Identify the different actions that can occur in the system (those actions will be later 
  implemented as functions)
- Identify what will occur on the python part (users part) and what will occur on the smart 
  contract part

.. admonition:: Question

    What important pieces of informations should be kept by the system about 
    an "order"? In other words, what would define an "order"?

.. admonition:: Question

    In our project, what would be managed by the blockchain? What would not
    be managed by the blockchain? (think of issues like "enforcing 
    market rules", "estimating production and demand"...)

Our specification should take the form of a design document detailing everything that needs 
to be implemented. You can imagine that you could give this document to a software engineering 
team. This team should be able to implement what you imagined based on the design document.

.. admonition:: Task

   This document should include a diagram representing the virtual power plants, its different actors, 
   the blockchain database nodes and the information flow between all those actors. This 
   diagram should illustrate how the system could work (you can mention the function calls 
   to the blockchain).

.. admonition:: Question

   In our Labs, we used "Ganache" which is a development tool. How our development environment
   differ from a "production" environment? You can include a diagram to illustrate the difference 
   between our "ganache environment" and a "real world" blockchain network that could host our 
   application.

Phase 2 - Implementing the Python simulator
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The goal here is to implement a simple simulator to illustrate how your contract work. 
This simulator will consist in a script that will represent a usage 
scenario of your market system. Different actors with different accounts 
can place selling and buying orders and see their wallet evolve when the "order matching" 
function will work. 

In this part we won't actually implement the smart contract, we already have a lot to do!

Here are python classes and parameters for the equipment:
- :download:`PV </_static/PV.py>`
- :download:`WaterHeater </_static/WaterHeater.py>`
- :download:`Data </_static/ProjectData.csv>`
- :download:`Parameters </_static/ProjectParameters.JSON>`

