Skip to content
Snippets Groups Projects
Commit 78860c60 authored by Mikkel Friis-Møller's avatar Mikkel Friis-Møller
Browse files

updated docs and readme

parent 36df4be7
No related branches found
No related tags found
1 merge request!13updated docs and readme
Pipeline #27318 passed
[![pipeline status](https://gitlab.windenergy.dtu.dk/TOPFARM/edwin/badges/main/pipeline.svg)](https://gitlab.windenergy.dtu.dk/TOPFARM/edwin/-/commits/main) [![pipeline status](https://gitlab.windenergy.dtu.dk/TOPFARM/edwin/badges/main/pipeline.svg)](https://gitlab.windenergy.dtu.dk/TOPFARM/edwin/-/commits/main)
[![coverage report](https://gitlab.windenergy.dtu.dk/TOPFARM/edwin/badges/main/coverage.svg)](https://gitlab.windenergy.dtu.dk/TOPFARM/edwin/commits/main)
[![PyPi](https://img.shields.io/pypi/v/ed_win)](https://pypi.org/project/ed_win/)
[![License](https://img.shields.io/pypi/l/ed_win)](https://gitlab.windenergy.dtu.dk/TOPFARM/EDWIN/blob/main/LICENSE)
# EDWIN # EDWIN
EDWIN: Electrical network Design for WINdfarms EDWIN: Electrical network Design for WINdfarms
## Quick Start:
`pip install ed_win`
## Source code repository (and issue tracker):
[https://gitlab.windenergy.dtu.dk/TOPFARM/EDWIN](https://gitlab.windenergy.dtu.dk/TOPFARM/EDWIN)
## License:
[MIT](https://gitlab.windenergy.dtu.dk/TOPFARM/EDWIN/blob/main/LICENSE)
## Documentation, installation, etc:
[https://topfarm.pages.windenergy.dtu.dk/EDWIN](https://topfarm.pages.windenergy.dtu.dk/EDWIN).
# 'filled_by_setup.py' # 'filled_by_setup.py'
__version__ = '0.0.0' __version__ = '0.0.1'
__release__ = '0.0.0' __release__ = '0.0.1'
No preview for this file type
No preview for this file type
...@@ -32,6 +32,19 @@ class HeuristicDriver(Driver): ...@@ -32,6 +32,19 @@ class HeuristicDriver(Driver):
class WindFarmNetwork(): class WindFarmNetwork():
def __init__(self, initial_layout, driver=HeuristicDriver(), cables=[]): def __init__(self, initial_layout, driver=HeuristicDriver(), cables=[]):
"""WindFarmNetwork object
Parameters
----------
initial_layout : array-like
The shape of the array is (i, j), where i is 2 and j is the number of turbines + 1.
i=1 is x and i=2 is y. j=0 is the coordinates of the offshore sub station and j=1: are the turbine coordinates.
driver : Driver
Driver object
cables : array-like
The shape of the array is (n, m), where n is the number of available cables and m is 3.
m=1 is cross-section, m=2 is the allowed number of connected WTs and m=3 is the price/km of the cable
"""
self.initial_layout = initial_layout self.initial_layout = initial_layout
self.driver = driver self.driver = driver
self.cables = cables self.cables = cables
...@@ -44,6 +57,22 @@ class WindFarmNetwork(): ...@@ -44,6 +57,22 @@ class WindFarmNetwork():
setattr(self.driver, 'wfn', self) setattr(self.driver, 'wfn', self)
def design(self, x=None, y=None, **kwargs): def design(self, x=None, y=None, **kwargs):
"""designs or optimizes the electrical wind farm network
Parameters
----------
x : array-like
concatenated list of sub station and turbine x-coordinates
y : array-like
concatenated list of sub station and turbine y-coordinates
Returns
-------
cost : float
The cost of the electrical network
state : DataFrame
The current network tree with the columns f{self.columns}
"""
if isinstance(x, type(None)): if isinstance(x, type(None)):
x = self.initial_layout['x'] x = self.initial_layout['x']
if isinstance(y, type(None)): if isinstance(y, type(None)):
......
from abc import ABC, abstractmethod
from edwin.collection_system import collection_system
from edwin.c_mst_cables import plot_network
import pandas as pd
import numpy as np
class Driver(ABC):
@abstractmethod
def run():
'''
'''
class HeuristicDriver(Driver):
def __init__(self, option=3, Inters_const=True, max_it=20000):
self.option = option
self.Inters_const = Inters_const
self.max_it = max_it
Driver.__init__(self)
def run(self, x, y):
T, cables_cost = collection_system(x,
y,
self.option,
self.Inters_const,
self.max_it,
self.wfn.cables)
return T, cables_cost
class WindFarmNetwork():
def __init__(self, initial_layout, driver=HeuristicDriver(), cables=[]):
self.initial_layout = initial_layout
self.driver = driver
self.cables = cables
self.state = None
self.T = None
self.columns = ['from_node', 'to_node', 'cable_length', 'cable_type', 'cable_cost']
self.setup()
def setup(self):
setattr(self.driver, 'wfn', self)
def design(self, x=None, y=None, **kwargs):
<<<<<<< HEAD
x = x or self.initial_layout['x']
y = y or self.initial_layout['y']
=======
if isinstance(x, type(None)):
x = self.initial_layout['x']
if isinstance(y, type(None)):
y = self.initial_layout['y']
>>>>>>> upd
self.x = x
self.y = y
T, cost = self.driver.run(x, y)
state = pd.DataFrame(T, columns=self.columns)
state = state.astype({'from_node': int,
'to_node': int,
'cable_type': int})
self.T = T
self.cost = cost
self.state = state
return cost, state
def plot(self):
if self.state is not None:
self.design()
plot_network(self.x, self.y, self.cables, self.T)
class Constraints(dict):
def __init__(self, **kwargs):
dict.__init__(self, {'crossing': False,
'tree': False,
'thermal_capacity': False,
'number_of_main_feeders': False})
self.update(kwargs)
def main():
if __name__ == '__main__':
initial_layout = dict(x=np.array([0., 2000., 4000., 6000.,
8000., 498.65600569, 2498.65600569, 4498.65600569,
6498.65600569, 8498.65600569, 997.31201137, 2997.31201137,
4997.31201137, 11336.25662483, 8997.31201137, 1495.96801706,
3495.96801706, 5495.96801706, 10011.39514341, 11426.89538545,
1994.62402275, 3994.62402275, 5994.62402275, 7994.62402275,
10588.90471566]),
y=np.array([0., 0., 0., 0.,
0., 2000., 2000., 2000.,
2000., 2000., 4000., 4000.,
4000., 6877.42528387, 4000., 6000.,
6000., 6000., 3179.76530545, 5953.63051694,
8000., 8000., 8000., 8000.,
4734.32972738]))
settings = {'option': 3,
'Inters_const': True,
'max_it': 20000}
cables = np.array([[500, 3, 100000], [800, 5, 150000], [1000, 10, 250000]])
wfn = WindFarmNetwork(initial_layout=initial_layout,
driver=HeuristicDriver(**settings),
cables=cables)
cost, state = wfn.design()
wfn.plot()
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment