Except where otherwise noted, this content is Copyright (c) 2020, RTE and licensed under a CC-BY-4.0 license.
In this example, we will test hadar on a realistic (yet simplify) use case. We will perform adequacy between France and Germainy during one day.
import pandas as pd import numpy as np import hadar as hd
fr = pd.read_csv('fr.csv') de = pd.read_csv('de.csv')
study = hd.Study(horizon=48).network()
France loves nuclear, so in this example most of production are nuclear. France has also a bit of solar and when needed country can turn on/off coal generator. We want to optimize adequacy by reduce CO2 production. Therefore: - solar is the cheaper at 10 - then we use nuclear at 30 - and coal at 100
study = study.node('fr')\ .consumption(name='load', cost=10**6, quantity=fr['cons'])\ .production(name='solar', cost=10, quantity=fr['solar'])\ .production(name='nuclear', cost=30, quantity=fr['nuclear'])\ .production(name='coal', cost=100, quantity=fr['coal'])
Germainy has stopped nuclear to switch from renewable energy. So we increase solar and eolien production. When renewable energy are off, Germainy need to start coal generation to match its consumption. Like for France, we want to minimize CO2 production: - solar at 10 - eolien at 15 - coal at 100
study = study.node('de')\ .consumption(name='load', cost=10**6, quantity=de['cons'])\ .production(name='solar', cost=10, quantity=de['solar'])\ .production(name='eolien', cost=15, quantity=de['eolien'])\ .production(name='coal', cost=100, quantity=de['coal'])
Then both side links are set with same cost at 5. In this network, Germany will be import from nuclear french before to start coal. And France will use germain coal to avoid any loss of load.
study = study\ .link(src='fr', dest='de', cost=5, quantity=4000)\ .link(src='de', dest='fr', cost=5, quantity=4000)\ .build()
optimizer = hd.LPOptimizer() res = optimizer.solve(study)
agg = hd.ResultAnalyzer(study, res) plot = hd.HTMLPlotting(agg=agg, unit_symbol='MW', # Set unit quantity time_start='2020-02-01', # Set time interval time_end='2020-02-02')
plot.network().rac_matrix()