Skip to content

Commit

Permalink
uid added for each component
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinksyTRD committed May 14, 2024
1 parent 1fb062e commit c5cf414
Show file tree
Hide file tree
Showing 35 changed files with 1,041 additions and 151 deletions.
2 changes: 1 addition & 1 deletion RunFEEMSSim/RunFeemsSim/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.3"
__version__ = "0.2.4"
2 changes: 1 addition & 1 deletion RunFEEMSSim/RunFeemsSim/_modidx.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"branch": "master",
"doc_baseurl": "/RunFeemsSim/",
"doc_host": "https://kevinkoosup.yum@sintef.no.github.io",
"git_url": "https://SintefOceanEnergySystem@dev.azure.com/SintefOceanEnergySystem/FEEMSService/_git/RunFEEMSSim",
"git_url": "https://github.com/SINTEF/FEEMS",
"lib_path": "RunFeemsSim",
},
"syms": {
Expand Down
2 changes: 1 addition & 1 deletion RunFEEMSSim/settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ author = Kevin Koosup Yum
author_email = kevinkoosup.yum@sintef.no
copyright = SINTEF
branch = master
version = 0.2.3
version = 0.2.4
min_python = 3.10
audience = Developers
language = English
Expand Down
14 changes: 13 additions & 1 deletion feems/feems/components_model/component_base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Union, List, Tuple, Optional, TypeVar, Dict
from dataclasses import dataclass, field
from uuid import uuid4

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -52,6 +53,7 @@ def __init__(
power_type: TypePower,
rated_power: Power_kW = Power_kW(0.0),
rated_speed: Speed_rpm = Speed_rpm(0.0),
uid: Optional[str] = None,
):
self.type = type_
self.power_type = power_type
Expand All @@ -61,6 +63,8 @@ def __init__(
self.status = np.ones(1).astype(bool) # Status on/off
self.power_input = np.array([0]) # power input
self.power_output = np.array([0]) # power output
# if uid is not given, create a random uid
self.uid = str(uuid4()) if uid is None else uid

def get_type_name(self) -> str:
return self.type.name
Expand Down Expand Up @@ -94,9 +98,15 @@ def __init__(
eff_curve: np.ndarray = np.array([1]),
rated_speed: Speed_rpm = Speed_rpm(0.0),
file_name: str = None,
uid: Optional[str] = None,
):
super(BasicComponent, self).__init__(
name, type_, power_type, rated_power, rated_speed
name=name,
type_=type_,
power_type=power_type,
rated_power=rated_power,
rated_speed=rated_speed,
uid=uid
)
if file_name is not None:
df = pd.read_csv(file_name, index_col=0)
Expand Down Expand Up @@ -417,6 +427,7 @@ def __init__(
components: List[BasicComponent],
rated_power: Power_kW = None,
rated_speed: Speed_rpm = None,
uid: Optional[str] = None,
):
self.component_names = []
self.components = components
Expand Down Expand Up @@ -445,4 +456,5 @@ def __init__(
rated_power=rated_power,
rated_speed=rated_speed,
eff_curve=efficiency_points,
uid=uid,
)
39 changes: 37 additions & 2 deletions feems/feems/components_model/component_electric.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def __init__(
rated_speed: Speed_rpm = Speed_rpm(0),
switchboard_id: SwbId = SwbId(0),
file_name: str = None,
uid: Optional[str] = None,
):
super().__init__(
type_=type_,
Expand All @@ -61,6 +62,7 @@ def __init__(
rated_speed=rated_speed,
eff_curve=eff_curve,
file_name=file_name,
uid=uid,
)
self.power_type = power_type
if power_type in [
Expand Down Expand Up @@ -91,6 +93,7 @@ def __init__(
switchboard_id: SwbId = SwbId(0),
number_poles: int = 1,
eff_curve: np.ndarray = np.ones(1),
uid: Optional[str] = None,
):
super(ElectricMachine, self).__init__(
type_=type_,
Expand All @@ -100,6 +103,7 @@ def __init__(
rated_speed=rated_speed,
eff_curve=eff_curve,
switchboard_id=switchboard_id,
uid=uid,
)
self.number_of_poles = number_poles

Expand Down Expand Up @@ -203,6 +207,7 @@ def __init__(
eff_charging: float = 0.975,
eff_discharging: float = 0.975,
switchboard_id: SwbId = SwbId(0),
uid: Optional[str] = None,
):
rated_power = Power_kW(rated_capacity_kwh * discharge_rate_c)
super().__init__(
Expand All @@ -211,6 +216,7 @@ def __init__(
rated_power,
power_type=TypePower.ENERGY_STORAGE,
switchboard_id=switchboard_id,
uid=uid,
)
self.rated_capacity_kWh = rated_capacity_kwh
self.charging_rate_C = charging_rate_c
Expand Down Expand Up @@ -337,9 +343,16 @@ def __init__(
switchboard_id: SwbId,
rated_power: Power_kW,
rated_speed: Speed_rpm = Speed_rpm(0),
uid: Optional[str] = None,
):
super(SerialSystemElectric, self).__init__(
type_, power_type, name, components, rated_power, rated_speed
type_=type_,
power_type=power_type,
name=name,
components=components,
rated_power=rated_power,
rated_speed=rated_speed,
uid=uid,
)

#: Set the load sharing mode 0 as default value if the component is either a power source,
Expand All @@ -361,13 +374,15 @@ def __init__(
eff_curve: np.ndarray,
fuel_type: TypeFuel = TypeFuel.HYDROGEN,
fuel_origin: FuelOrigin = FuelOrigin.RENEWABLE_NON_BIO,
uid: Optional[str] = None,
):
super(FuelCell, self).__init__(
type_=TypeComponent.FUEL_CELL,
power_type=TypePower.POWER_SOURCE,
name=name,
rated_power=rated_power,
eff_curve=eff_curve,
uid=uid,
)
self.fuel_type = fuel_type
self.fuel_origin = fuel_origin
Expand Down Expand Up @@ -441,6 +456,7 @@ def __init__(
converter: ElectricComponent,
switchboard_id: SwbId,
number_modules: int = 1,
uid: Optional[str] = None,
):
super(FuelCellSystem, self).__init__(
name=name,
Expand All @@ -449,6 +465,7 @@ def __init__(
eff_curve=converter._efficiency_points,
power_type=TypePower.POWER_SOURCE,
switchboard_id=switchboard_id,
uid=uid,
)
self.converter = converter
self.fuel_cell = fuel_cell_module
Expand Down Expand Up @@ -515,6 +532,7 @@ def __init__(
battery: Battery,
converter: ElectricComponent,
switchboard_id: SwbId,
uid: Optional[str] = None,
):
super().__init__(
name=name,
Expand All @@ -525,6 +543,7 @@ def __init__(
eff_charging=battery.eff_charging,
eff_discharging=battery.eff_discharging,
switchboard_id=switchboard_id,
uid=uid,
)
self.type = TypeComponent.BATTERY_SYSTEM
self.rated_power = converter.rated_power
Expand Down Expand Up @@ -588,13 +607,15 @@ def __init__(
aux_engine: Engine,
generator: ElectricMachine,
rectifier: ElectricComponent = None,
uid: Optional[str] = None,
):
super(Genset, self).__init__(
name=name,
type_=TypeComponent.GENSET,
power_type=TypePower.POWER_SOURCE,
rated_power=generator.rated_power,
rated_speed=generator.rated_speed,
uid=uid,
)
self.fuel_type = aux_engine.fuel_type
self.aux_engine = aux_engine
Expand Down Expand Up @@ -666,6 +687,7 @@ def __init__(
rated_power: Power_kW,
rated_speed: Speed_rpm = Speed_rpm(0),
shaft_line_id: int = 1,
uid: Optional[str] = None,
):
super(PTIPTO, self).__init__(
TypeComponent.PTI_PTO_SYSTEM,
Expand All @@ -675,6 +697,7 @@ def __init__(
switchboard_id,
rated_power,
rated_speed,
uid=uid,
)
self.shaft_line_id = shaft_line_id
self.full_pti_mode = np.zeros(1).astype(bool)
Expand All @@ -691,6 +714,7 @@ class SuperCapacitor(ElectricComponent):
:param eff_charging: Efficiency for charging in percentage
:param eff_discharging: Efficiency for discharging in percentage
:param switchboard_id: Switchboard ID
:param uid: Unique ID
"""

def __init__(
Expand All @@ -702,13 +726,15 @@ def __init__(
eff_charging: float = 0.995,
eff_discharging: float = 0.995,
switchboard_id: SwbId = SwbId(0),
uid: Optional[str] = None,
):
super().__init__(
TypeComponent.SUPERCAPACITOR,
name,
rated_power,
power_type=TypePower.ENERGY_STORAGE,
switchboard_id=switchboard_id,
uid=uid,
)
self.rated_capacity_Wh = rated_capacity_wh
self.soc0 = soc0
Expand Down Expand Up @@ -821,6 +847,7 @@ def __init__(
supercapacitor: SuperCapacitor,
converter: ElectricComponent,
switchboard_id: SwbId,
uid: Optional[str] = None,
):
super().__init__(
name=name,
Expand All @@ -830,6 +857,7 @@ def __init__(
eff_charging=supercapacitor.eff_charging,
eff_discharging=supercapacitor.eff_discharging,
switchboard_id=switchboard_id,
uid=uid,
)
self.converter = converter
self.supercapacitor = supercapacitor
Expand Down Expand Up @@ -882,14 +910,19 @@ class ShorePowerConnection(ElectricComponent):
"""

def __init__(
self, name: str, rated_power: Power_kW, switchboard_id: SwbId = SwbId(0)
self,
name: str,
rated_power: Power_kW,
switchboard_id: SwbId = SwbId(0),
uid: Optional[str] = None,
):
super().__init__(
TypeComponent.SHORE_POWER,
name,
rated_power,
power_type=TypePower.POWER_SOURCE,
switchboard_id=switchboard_id,
uid=uid,
)


Expand Down Expand Up @@ -929,13 +962,15 @@ def __init__(
name: str,
cogas: COGAS,
generator: ElectricMachine,
uid: Optional[str] = None,
):
super().__init__(
name=name,
type_=TypeComponent.COGES,
power_type=TypePower.POWER_SOURCE,
rated_power=generator.rated_power,
rated_speed=generator.rated_speed,
uid=uid,
)
self.fuel_type = cogas.fuel_type
self.cogas = cogas
Expand Down
20 changes: 19 additions & 1 deletion feems/feems/components_model/component_mechanical.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,15 @@ def __init__(
file_name: str = None,
emissions_curves: List[EmissionCurve] = None,
engine_cycle_type: EngineCycleType = EngineCycleType.DIESEL,
uid: Optional[str] = None,
):
super(Engine, self).__init__(
name=name,
type_=type_,
power_type=TypePower.POWER_SOURCE,
rated_power=rated_power,
rated_speed=rated_speed,
uid=uid,
)
self.fuel_type = fuel_type
self.fuel_origin = fuel_origin
Expand Down Expand Up @@ -238,6 +240,7 @@ def __init__(
pilot_fuel_type: TypeFuel.DIESEL,
pilot_fuel_origin: FuelOrigin = FuelOrigin.FOSSIL,
emissions_curves: List[EmissionCurve] = None,
uid: Optional[str] = None,
):
super().__init__(
type_=type_,
Expand All @@ -249,6 +252,7 @@ def __init__(
fuel_type=fuel_type,
fuel_origin=fuel_origin,
emissions_curves=emissions_curves,
uid=uid,
)
self.bspfc_curve = bspfc_curve
self.pilot_fuel_type = pilot_fuel_type
Expand Down Expand Up @@ -321,13 +325,15 @@ def __init__(
name,
engine: Union[Engine, EngineDualFuel],
shaft_line_id: int = 1,
uid: Optional[str] = None,
):
super().__init__(
name=name,
power_type=TypePower.POWER_SOURCE,
type_=TypeComponent.MAIN_ENGINE,
rated_power=engine.rated_power,
rated_speed=engine.rated_speed,
uid=uid,
)
self.engine = engine
self.shaft_line_id = shaft_line_id
Expand Down Expand Up @@ -392,9 +398,17 @@ def __init__(
rated_speed: Speed_rpm = Speed_rpm(0),
shaft_line_id: int = 1,
file_name: str = None,
uid: Optional[str] = None,
):
super(MechanicalPropulsionComponent, self).__init__(
type_, power_type, name, rated_power, eff_curve, rated_speed, file_name
type_=type_,
power_type=power_type,
name=name,
rated_power=rated_power,
eff_curve=eff_curve,
rated_speed=rated_speed,
file_name=file_name,
uid=uid,
)
self.shaft_line_id = shaft_line_id

Expand All @@ -406,11 +420,13 @@ def __init__(
engine: Union[Engine, EngineDualFuel],
gearbox: BasicComponent,
shaft_line_id: int = 1,
uid: Optional[str] = None,
):
super(MainEngineWithGearBoxForMechanicalPropulsion, self).__init__(
name=name,
engine=engine,
shaft_line_id=shaft_line_id,
uid=uid,
)
self.gearbox = gearbox

Expand Down Expand Up @@ -478,6 +494,7 @@ def __init__(
fuel_origin: FuelOrigin = FuelOrigin.FOSSIL,
emissions_curves: List[EmissionCurve] = None,
nox_calculation_method: NOxCalculationMethod = NOxCalculationMethod.TIER_3,
uid: Optional[str] = None,
):
"""Constructor for COGES component"""
# Validate the inputs for curves. The length of the curves should be the same and the x values should be the same.
Expand Down Expand Up @@ -505,6 +522,7 @@ def __init__(
rated_power=rated_power,
eff_curve=eff_curve,
rated_speed=rated_speed,
uid=uid,
)
self.gas_turbine_power_curve = gas_turbine_power_curve
self.steam_turbine_power_curve = steam_turbine_power_curve
Expand Down
Loading

0 comments on commit c5cf414

Please sign in to comment.