# SPDX-FileCopyrightText: 2023 Alliander
#
# SPDX-License-Identifier: Apache-2.0

"""
Generated from the CGMES 3 files via cimgen: https://github.com/sogno-platform/cimgen
"""

from functools import cached_property
from pydantic import Field
from pydantic.dataclasses import dataclass
from ..utils.dataclassconfig import DataclassConfig
from ..utils.profile import BaseProfile, Profile

from .TurbineGovernorDynamics import TurbineGovernorDynamics


@dataclass(config=DataclassConfig)
class GovSteamEU(TurbineGovernorDynamics):
    """
    Simplified boiler and steam turbine with PID governor.

    mwbase: Base for power values (MWbase) (> 0).  Unit = MW.
    tp: Power transducer time constant (Tp) (>= 0).  Typical value = 0,07.
    ke: Gain of the power controller (Ke).  Typical value = 0,65.
    tip: Integral time constant of the power controller (Tip) (>= 0).  Typical value = 2.
    tdp: Derivative time constant of the power controller (Tdp) (>= 0).  Typical value = 0.
    tfp: Time constant of the power controller (Tfp) (>= 0).  Typical value = 0.
    tf: Frequency transducer time constant (Tf) (>= 0).  Typical value = 0.
    kfcor: Gain of the frequency corrector (Kfcor).  Typical value = 20.
    db1: Deadband of the frequency corrector (db1).  Typical value = 0.
    wfmax: Upper limit for frequency correction (Wfmax) (> GovSteamEU.wfmin).  Typical value = 0,05.
    wfmin: Lower limit for frequency correction (Wfmin) (< GovSteamEU.wfmax).  Typical value = -0,05.
    pmax: Maximal active power of the turbine (Pmax).  Typical value = 1.
    ten: Electro hydraulic transducer (Ten) (>= 0).  Typical value = 0,1.
    tw: Speed transducer time constant (Tw) (>= 0).  Typical value = 0,02.
    komegacor: Gain of the speed governor (Kwcor).  Typical value = 20.
    db2: Deadband of the speed governor (db2).  Typical value = 0,0004.
    wwmax: Upper limit for the speed governor (Wwmax) (> GovSteamEU.wwmin).  Typical value = 0,1.
    wwmin: Lower limit for the speed governor frequency correction (Wwmin) (< GovSteamEU.wwmax).  Typical value = -1.
    wmax1: Emergency speed control lower limit (wmax1).  Typical value = 1,025.
    wmax2: Emergency speed control upper limit (wmax2).  Typical value = 1,05.
    tvhp: Control valves servo time constant (Tvhp) (>= 0).  Typical value = 0,1.
    cho: Control valves rate opening limit (Cho).  Unit = PU / s.  Typical value = 0,17.
    chc: Control valves rate closing limit (Chc).  Unit = PU / s.  Typical value = -3,3.
    hhpmax: Maximum control valve position (Hhpmax).  Typical value = 1.
    tvip: Intercept valves servo time constant (Tvip) (>= 0).  Typical value = 0,15.
    cio: Intercept valves rate opening limit (Cio).  Typical value = 0,123.
    cic: Intercept valves rate closing limit (Cic).  Typical value = -2,2.
    simx: Intercept valves transfer limit (Simx).  Typical value = 0,425.
    thp: High pressure (HP) time constant of the turbine (Thp) (>= 0).  Typical value = 0,31.
    trh: Reheater  time constant of the turbine (Trh) (>= 0).  Typical value = 8.
    tlp: Low pressure (LP) time constant of the turbine (Tlp) (>= 0).  Typical value = 0,45.
    prhmax: Maximum low pressure limit (Prhmax).  Typical value = 1,4.
    khp: Fraction of total turbine output generated by HP part (Khp).  Typical value = 0,277.
    klp: Fraction of total turbine output generated by HP part (Klp).  Typical value = 0,723.
    tb: Boiler time constant (Tb) (>= 0).  Typical value = 100.
    """

    mwbase: float = Field(
        default=0.0,
        in_profiles=[
            Profile.DY,
        ],
    )

    tp: int = Field(
        default=0,
        in_profiles=[
            Profile.DY,
        ],
    )

    ke: float = Field(
        default=0.0,
        in_profiles=[
            Profile.DY,
        ],
    )

    tip: int = Field(
        default=0,
        in_profiles=[
            Profile.DY,
        ],
    )

    tdp: int = Field(
        default=0,
        in_profiles=[
            Profile.DY,
        ],
    )

    tfp: int = Field(
        default=0,
        in_profiles=[
            Profile.DY,
        ],
    )

    tf: int = Field(
        default=0,
        in_profiles=[
            Profile.DY,
        ],
    )

    kfcor: float = Field(
        default=0.0,
        in_profiles=[
            Profile.DY,
        ],
    )

    db1: float = Field(
        default=0.0,
        in_profiles=[
            Profile.DY,
        ],
    )

    wfmax: float = Field(
        default=0.0,
        in_profiles=[
            Profile.DY,
        ],
    )

    wfmin: float = Field(
        default=0.0,
        in_profiles=[
            Profile.DY,
        ],
    )

    pmax: float = Field(
        default=0.0,
        in_profiles=[
            Profile.DY,
        ],
    )

    ten: int = Field(
        default=0,
        in_profiles=[
            Profile.DY,
        ],
    )

    tw: int = Field(
        default=0,
        in_profiles=[
            Profile.DY,
        ],
    )

    komegacor: float = Field(
        default=0.0,
        in_profiles=[
            Profile.DY,
        ],
    )

    db2: float = Field(
        default=0.0,
        in_profiles=[
            Profile.DY,
        ],
    )

    wwmax: float = Field(
        default=0.0,
        in_profiles=[
            Profile.DY,
        ],
    )

    wwmin: float = Field(
        default=0.0,
        in_profiles=[
            Profile.DY,
        ],
    )

    wmax1: float = Field(
        default=0.0,
        in_profiles=[
            Profile.DY,
        ],
    )

    wmax2: float = Field(
        default=0.0,
        in_profiles=[
            Profile.DY,
        ],
    )

    tvhp: int = Field(
        default=0,
        in_profiles=[
            Profile.DY,
        ],
    )

    cho: float = Field(
        default=0.0,
        in_profiles=[
            Profile.DY,
        ],
    )

    chc: float = Field(
        default=0.0,
        in_profiles=[
            Profile.DY,
        ],
    )

    hhpmax: float = Field(
        default=0.0,
        in_profiles=[
            Profile.DY,
        ],
    )

    tvip: int = Field(
        default=0,
        in_profiles=[
            Profile.DY,
        ],
    )

    cio: float = Field(
        default=0.0,
        in_profiles=[
            Profile.DY,
        ],
    )

    cic: float = Field(
        default=0.0,
        in_profiles=[
            Profile.DY,
        ],
    )

    simx: float = Field(
        default=0.0,
        in_profiles=[
            Profile.DY,
        ],
    )

    thp: int = Field(
        default=0,
        in_profiles=[
            Profile.DY,
        ],
    )

    trh: int = Field(
        default=0,
        in_profiles=[
            Profile.DY,
        ],
    )

    tlp: int = Field(
        default=0,
        in_profiles=[
            Profile.DY,
        ],
    )

    prhmax: float = Field(
        default=0.0,
        in_profiles=[
            Profile.DY,
        ],
    )

    khp: float = Field(
        default=0.0,
        in_profiles=[
            Profile.DY,
        ],
    )

    klp: float = Field(
        default=0.0,
        in_profiles=[
            Profile.DY,
        ],
    )

    tb: int = Field(
        default=0,
        in_profiles=[
            Profile.DY,
        ],
    )

    @cached_property
    def possible_profiles(self) -> set[BaseProfile]:
        """
        A resource can be used by multiple profiles. This is the set of profiles
        where this element can be found.
        """
        return {
            Profile.DY,
        }
