Skip to content

Commit

Permalink
Added generator associations
Browse files Browse the repository at this point in the history
  • Loading branch information
Santi committed Jun 23, 2023
1 parent e4116ba commit 222aeb2
Show file tree
Hide file tree
Showing 21 changed files with 1,342 additions and 1,828 deletions.
20 changes: 20 additions & 0 deletions src/GridCal/Engine/Core/Devices/Associations/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# GridCal
# Copyright (C) 2022 Santiago Peñate Vera
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 3 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

from GridCal.Engine.Core.Devices.Associations.generator_fuel import GeneratorFuel
from GridCal.Engine.Core.Devices.Associations.generator_emission import GeneratorEmission
from GridCal.Engine.Core.Devices.Associations.generator_technology import GeneratorTechnology
73 changes: 73 additions & 0 deletions src/GridCal/Engine/Core/Devices/Associations/generator_emission.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# GridCal
# Copyright (C) 2022 Santiago Peñate Vera
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 3 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

from typing import Union
from GridCal.Engine.Core.Devices.editable_device import EditableDevice, DeviceType, GCProp
from GridCal.Engine.Core.Devices import Generator, EmissionGas


class GeneratorEmission(EditableDevice):

def __init__(self, name='',
code='',
idtag=None,
generator: Union[Generator, None] = None,
emission: Union[EmissionGas, None] = None,
rate: float = 0.0):
"""
:param name:
:param idtag:
"""
EditableDevice.__init__(self,
name=name,
code=code,
idtag=idtag,
active=True,
device_type=DeviceType.GeneratorEmissionAssociation,
editable_headers={'idtag': GCProp('', str, 'Unique ID'),
'generator': GCProp('', DeviceType.GeneratorDevice, 'Generator'),
'emission': GCProp('', DeviceType.EmissionGasDevice, 'Emission'),
'rate': GCProp('t/MWh', float, 'Emissions rate'),
},
non_editable_attributes=['idtag'],
properties_with_profile={})

self.generator = generator

self.emission = emission

self.rate = rate

def get_properties_dict(self, version=3):
data = {'id': self.idtag,
'name': self.name,
'code': self.code,
'generator': self.generator,
'emission': self.emission,
'rate': self.rate
}
return data

def get_profiles_dict(self, version=3):
data = {'id': self.idtag}
return data

def get_units_dict(self, version=3):
data = {}
return data
73 changes: 73 additions & 0 deletions src/GridCal/Engine/Core/Devices/Associations/generator_fuel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# GridCal
# Copyright (C) 2022 Santiago Peñate Vera
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 3 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

from typing import Union
from GridCal.Engine.Core.Devices.editable_device import EditableDevice, DeviceType, GCProp
from GridCal.Engine.Core.Devices import Generator, Fuel


class GeneratorFuel(EditableDevice):

def __init__(self, name='',
code='',
idtag=None,
generator: Union[Generator, None] = None,
fuel: Union[Fuel, None] = None,
rate: float = 0.0):
"""
:param name:
:param idtag:
"""
EditableDevice.__init__(self,
name=name,
code=code,
idtag=idtag,
active=True,
device_type=DeviceType.GeneratorFuelAssociation,
editable_headers={'idtag': GCProp('', str, 'Unique ID'),
'generator': GCProp('', DeviceType.GeneratorDevice, 'Generator'),
'fuel': GCProp('', DeviceType.FuelDevice, 'Fuel'),
'rate': GCProp('t/MWh', float, 'Emissions rate'),
},
non_editable_attributes=['idtag'],
properties_with_profile={})

self.generator = generator

self.fuel = fuel

self.rate = rate

def get_properties_dict(self, version=3):
data = {'id': self.idtag,
'name': self.name,
'code': self.code,
'generator': self.generator,
'fuel': self.fuel,
'rate': self.rate
}
return data

def get_profiles_dict(self, version=3):
data = {'id': self.idtag}
return data

def get_units_dict(self, version=3):
data = {}
return data
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# GridCal
# Copyright (C) 2022 Santiago Peñate Vera
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 3 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

from typing import Union
from GridCal.Engine.Core.Devices.editable_device import EditableDevice, DeviceType, GCProp
from GridCal.Engine.Core.Devices import Generator, Technology


class GeneratorTechnology(EditableDevice):

def __init__(self, name='',
code='',
idtag=None,
generator: Union[Generator, None] = None,
technology: Union[Technology, None] = None,
proportion: float = 1.0):
"""
:param name:
:param idtag:
:param device_type:
"""
EditableDevice.__init__(self,
name=name,
code=code,
idtag=idtag,
active=True,
device_type=DeviceType.GeneratorTechnologyAssociation,
editable_headers={'idtag': GCProp('', str, 'Unique ID'),
'generator': GCProp('', DeviceType.GeneratorDevice, 'Generator'),
'technology': GCProp('', DeviceType.Technology, 'Technology'),
'proportion': GCProp('p.u.', float, 'Emissions rate'),
},
non_editable_attributes=['idtag'],
properties_with_profile={})

self.generator = generator

self.technology = technology

self.proportion = proportion

def get_properties_dict(self, version=3):
data = {'id': self.idtag,
'name': self.name,
'code': self.code,
'generator': self.generator,
'technology': self.technology,
'proportion': self.proportion
}
return data

def get_profiles_dict(self, version=3):
data = {'id': self.idtag}
return data

def get_units_dict(self, version=3):
data = {}
return data
4 changes: 2 additions & 2 deletions src/GridCal/Engine/Core/Devices/Injections/battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Battery(Generator):

def __init__(self, name='batt', idtag=None, active_power=0.0, power_factor=0.8, voltage_module=1.0,
is_controlled=True, Qmin=-9999, Qmax=9999, Snom=9999, Enom=9999, p_min=-9999, p_max=9999,
op_cost=1.0, power_prof=None, power_factor_prof=None, vset_prof=None, active=True, Sbase=100,
Cost=1.0, power_prof=None, power_factor_prof=None, vset_prof=None, active=True, Sbase=100,
enabled_dispatch=True, mttf=0.0, mttr=0.0, charge_efficiency=0.9, discharge_efficiency=0.9,
max_soc=0.99, min_soc=0.3, soc=0.8, charge_per_cycle=0.1, discharge_per_cycle=0.1,
r1=1e-20, x1=1e-20, r0=1e-20, x0=1e-20, r2=1e-20, x2=1e-20,
Expand All @@ -109,7 +109,7 @@ def __init__(self, name='batt', idtag=None, active_power=0.0, power_factor=0.8,
vset_prof=vset_prof,
active=active,
p_min=p_min, p_max=p_max,
op_cost=op_cost,
Cost=Cost,
Sbase=Sbase,
enabled_dispatch=enabled_dispatch,
mttf=mttf,
Expand Down
58 changes: 45 additions & 13 deletions src/GridCal/Engine/Core/Devices/Injections/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@

import numpy as np
import pandas as pd
from typing import Union
from matplotlib import pyplot as plt
from GridCal.Engine.basic_structures import Logger
from GridCal.Engine.basic_structures import Logger, Vec, IntVec
from GridCal.Engine.Core.Devices.editable_device import EditableDevice, GCProp
from GridCal.Engine.Core.Devices.enumerations import DeviceType, BuildStatus
from GridCal.Engine.Core.Devices.Aggregation.technology import Technology
from GridCal.Engine.Core.Devices.Aggregation.fuel import Fuel
from GridCal.Engine.Core.Devices.Aggregation.emission_gas import EmissionGas


def make_default_q_curve(Snom, Qmin, Qmax, n=3):
Expand Down Expand Up @@ -143,14 +146,44 @@ class Generator(EditableDevice):
**use_reactive_power_curve**: Use the reactive power curve? otherwise use the plain old limits
"""

def __init__(self, name='gen', idtag=None, code='', active_power=0.0, power_factor=0.8, voltage_module=1.0, is_controlled=True,
Qmin=-9999, Qmax=9999, Snom=9999, power_prof=None, power_factor_prof=None, vset_prof=None,
Cost_prof=None, active=True, p_min=0.0, p_max=9999.0, op_cost=1.0, Sbase=100, enabled_dispatch=True,
mttf=0.0, mttr=0.0, technology: Technology = None,
q_points=None, use_reactive_power_curve=False,
r1=1e-20, x1=1e-20, r0=1e-20, x0=1e-20, r2=1e-20, x2=1e-20,
capex=0, opex=0, build_status: BuildStatus = BuildStatus.Commissioned,
Cost2_prof=None,Cost0_prof=None):
def __init__(self, name='gen',
idtag: Union[str, None] = None,
code: str = '',
active_power: float = 0.0,
power_factor: float = 0.8,
voltage_module: float = 1.0,
is_controlled=True,
Qmin: float = -9999,
Qmax: float = 9999,
Snom: float = 9999,
power_prof: Union[Vec, None] = None,
power_factor_prof: Union[Vec, None] = None,
vset_prof: Union[Vec, None] = None,
active_prof: Union[Vec, None] = None,
active: bool = True,
p_min: float = 0.0,
p_max: float = 9999.0,
Cost: float = 1.0,
Sbase: float = 100,
enabled_dispatch=True,
mttf: float = 0.0,
mttr: float = 0.0,
technology: Technology = None,
q_points=None,
use_reactive_power_curve=False,
r1: float = 1e-20,
x1: float = 1e-20,
r0: float = 1e-20,
x0: float = 1e-20,
r2: float = 1e-20,
x2: float = 1e-20,
capex: float = 0,
opex: float = 0,
build_status: BuildStatus = BuildStatus.Commissioned,
Cost_prof: Union[Vec, None] = None,
Cost2_prof: Union[Vec, None] = None,
Cost0_prof: Union[Vec, None] = None,
):

EditableDevice.__init__(self,
name=name,
Expand Down Expand Up @@ -203,8 +236,7 @@ def __init__(self, name='gen', idtag=None, code='', active_power=0.0, power_fact
'build_status': GCProp('', BuildStatus, 'Branch build status. Used in expansion planning.'),
'enabled_dispatch': GCProp('', bool, 'Enabled for dispatch? Used in OPF.'),
'mttf': GCProp('h', float, 'Mean time to failure'),
'mttr': GCProp('h', float, 'Mean time to recovery'),
'technology': GCProp('', DeviceType.Technology, 'Generator technology')
'mttr': GCProp('h', float, 'Mean time to recovery')
},
non_editable_attributes=['bus', 'idtag'],
properties_with_profile={'active': 'active_prof',
Expand All @@ -217,7 +249,7 @@ def __init__(self, name='gen', idtag=None, code='', active_power=0.0, power_fact

self.bus = None

self.active_prof = None
self.active_prof = active_prof

self.mttf = mttf

Expand Down Expand Up @@ -292,7 +324,7 @@ def __init__(self, name='gen', idtag=None, code='', active_power=0.0, power_fact
self.custom_q_points = False

self.Cost2 = 0.0 # Cost of operation €/MW²
self.Cost = op_cost # Cost of operation €/MW
self.Cost = Cost # Cost of operation €/MW
self.Cost0 = 0.0 # Cost of operation €/MW

self.StartupCost = 0.0
Expand Down
2 changes: 1 addition & 1 deletion src/GridCal/Engine/Core/Devices/Substation/bus.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def __init__(self, name="Bus",
'country': GCProp('', DeviceType.CountryDevice, 'Country of the bus'),
'area': GCProp('', DeviceType.AreaDevice, 'Area of the bus'),
'zone': GCProp('', DeviceType.ZoneDevice, 'Zone of the bus'),
'Substation': GCProp('', DeviceType.SubstationDevice,
'substation': GCProp('', DeviceType.SubstationDevice,
'Substation of the bus.'),
'longitude': GCProp('deg', float, 'longitude of the bus.'),
'latitude': GCProp('deg', float, 'latitude of the bus.')},
Expand Down
3 changes: 2 additions & 1 deletion src/GridCal/Engine/Core/Devices/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
from GridCal.Engine.Core.Devices.Aggregation import *
from GridCal.Engine.Core.Devices.Branches import *
from GridCal.Engine.Core.Devices.Injections import *
from GridCal.Engine.Core.Devices.Substation import *
from GridCal.Engine.Core.Devices.Substation import *
from GridCal.Engine.Core.Devices.Associations import *
Loading

0 comments on commit 222aeb2

Please sign in to comment.