diff --git a/src/libecalc/presentation/yaml/yaml_types/models/yaml_compressor_chart.py b/src/libecalc/presentation/yaml/yaml_types/models/yaml_compressor_chart.py index 0b549390f9..d33bfcdaf6 100644 --- a/src/libecalc/presentation/yaml/yaml_types/models/yaml_compressor_chart.py +++ b/src/libecalc/presentation/yaml/yaml_types/models/yaml_compressor_chart.py @@ -87,7 +87,7 @@ class YamlSingleSpeedChart(YamlBase): description="Defines the type of model. See documentation for more information.", title="TYPE", ) - chart_type: Literal[YamlChartType.VARIABLE_SPEED] = YamlChartType.VARIABLE_SPEED + chart_type: Literal[YamlChartType.SINGLE_SPEED] = YamlChartType.SINGLE_SPEED curves: YamlCurve = Field(..., description="One single compressor chart curve.", title="CURVE") units: YamlUnits = None diff --git a/src/libecalc/presentation/yaml/yaml_types/models/yaml_compressor_stages.py b/src/libecalc/presentation/yaml/yaml_types/models/yaml_compressor_stages.py index c161300be0..89e2fd1754 100644 --- a/src/libecalc/presentation/yaml/yaml_types/models/yaml_compressor_stages.py +++ b/src/libecalc/presentation/yaml/yaml_types/models/yaml_compressor_stages.py @@ -1,11 +1,14 @@ import enum -from typing import List, Union +from typing import Annotated, List, Optional, Union from pydantic import Field from libecalc.presentation.yaml.yaml_types import YamlBase from libecalc.presentation.yaml.yaml_types.models.yaml_compressor_chart import ( - YamlCompressorChart, + YamlGenericFromDesignPointChart, + YamlGenericFromInputChart, + YamlSingleSpeedChart, + YamlVariableSpeedChart, ) from libecalc.presentation.yaml.yaml_types.models.yaml_enums import YamlPressureControl @@ -29,65 +32,141 @@ class YamlInterstageControlPressure(YamlBase): class YamlCompressorStageBase(YamlBase): - inlet_temperature: str = Field( + inlet_temperature: float = Field( ..., description="Inlet temperature in Celsius for stage", title="INLET_TEMPERATURE", ) - compressor_chart: YamlCompressorChart = Field( + compressor_chart: Union[ + YamlSingleSpeedChart, YamlVariableSpeedChart, YamlGenericFromDesignPointChart, YamlGenericFromInputChart + ] = Field( ..., description="Reference to compressor chart model for stage, must be defined in MODELS or FACILITY_INPUTS", title="COMPRESSOR_CHART", ) +class YamlSingleSpeedCompressorStage(YamlCompressorStageBase): + pressure_drop_ahead_of_stage: Optional[ + Annotated[ + float, + Field( + ..., + description="Pressure drop before compression stage [in bar]", + title="PRESSURE_DROP_AHEAD_OF_STAGE", + ), + ] + ] + compressor_chart: YamlSingleSpeedChart + + +class YamlVariableSpeedCompressorStage(YamlCompressorStageBase): + pressure_drop_ahead_of_stage: Optional[ + Annotated[ + float, + Field( + ..., + description="Pressure drop before compression stage [in bar]", + title="PRESSURE_DROP_AHEAD_OF_STAGE", + ), + ] + ] + compressor_chart: YamlVariableSpeedChart + + class YamlCompressorStage(YamlCompressorStageBase): - pressure_drop_ahead_of_stage: str = Field( - ..., - description="Pressure drop before compression stage [in bar]", - title="PRESSURE_DROP_AHEAD_OF_STAGE", - ) + pressure_drop_ahead_of_stage: Optional[ + Annotated[ + float, + Field( + ..., + description="Pressure drop before compression stage [in bar]", + title="PRESSURE_DROP_AHEAD_OF_STAGE", + ), + ] + ] class YamlCompressorStageMultipleStreams(YamlCompressorStageBase): - control_margin: str = Field( - 0.0, - description="Surge control margin, see documentation for more details.", - title="CONTROL_MARGIN", - ) - control_margin_unit: YamlControlMarginUnits = Field( - YamlControlMarginUnits.PERCENTAGE, - description="The unit of the surge control margin.", - title="CONTROL_MARGIN_UNIT", - ) + control_margin: Optional[ + Annotated[ + float, + Field( + 0.0, + description="Surge control margin, see documentation for more details.", + title="CONTROL_MARGIN", + ), + ] + ] + control_margin_unit: Optional[ + Annotated[ + YamlControlMarginUnits, + Field( + YamlControlMarginUnits.PERCENTAGE, + description="The unit of the surge control margin.", + title="CONTROL_MARGIN_UNIT", + ), + ] + ] stream: Union[str, List[str]] = Field( ..., description="Reference to stream from STREAMS.", title="STREAM", ) - pressure_drop_ahead_of_stage: str = Field( - ..., - description="Pressure drop before compression stage [in bar]", - title="PRESSURE_DROP_AHEAD_OF_STAGE", - ) - interstage_control_pressure: YamlInterstageControlPressure = Field( + pressure_drop_ahead_of_stage: Optional[ + Annotated[ + float, + Field( + ..., + description="Pressure drop before compression stage [in bar]", + title="PRESSURE_DROP_AHEAD_OF_STAGE", + ), + ] + ] + interstage_control_pressure: Optional[ + Annotated[ + YamlInterstageControlPressure, + Field( + ..., + description="Pressure control. Can only be specified for one (only one) of the stages 2, ..., N.", + title="INTERSTAGE_CONTROL_PRESSURE", + ), + ] + ] + + +class YamlUnknownCompressorStages(YamlCompressorStageBase): + maximum_pressure_ratio_per_stage: Optional[ + Annotated[ + float, + Field( + ..., + description="Maximum pressure ratio per stage. Number of compressors will be large enough to ensure no " + "pressure ratios are above a given maximum pressure ratio per stage, but not larger", + title="MAXIMUM_PRESSURE_RATIO_PER_STAGE", + ), + ] + ] + + +class YamlCompressorStages(YamlBase): + stages: List[YamlCompressorStage] = Field( ..., - description="Pressure control. Can only be specified for one (only one) of the stages 2, ..., N.", - title="INTERSTAGE_CONTROL_PRESSURE", + description="List of compressor stages", + title="STAGES", ) -class YamlUnknownCompressorStages(YamlCompressorStageBase): - maximum_pressure_ratio_per_stage: str = Field( +class YamlSingleSpeedCompressorStages(YamlBase): + stages: List[YamlSingleSpeedCompressorStage] = Field( ..., - description="Maximum pressure ratio per stage. Number of compressors will be large enough to ensure no " - "pressure ratios are above a given maximum pressure ratio per stage, but not larger", - title="MAXIMUM_PRESSURE_RATIO_PER_STAGE", + description="List of compressor stages", + title="STAGES", ) -class YamlCompressorStages(YamlBase): - stages: List[YamlCompressorStage] = Field( +class YamlVariableSpeedCompressorStages(YamlBase): + stages: List[YamlVariableSpeedCompressorStage] = Field( ..., description="List of compressor stages", title="STAGES", diff --git a/src/libecalc/presentation/yaml/yaml_types/models/yaml_compressor_trains.py b/src/libecalc/presentation/yaml/yaml_types/models/yaml_compressor_trains.py index 279099c633..5022cd7317 100644 --- a/src/libecalc/presentation/yaml/yaml_types/models/yaml_compressor_trains.py +++ b/src/libecalc/presentation/yaml/yaml_types/models/yaml_compressor_trains.py @@ -1,4 +1,4 @@ -from typing import List, Literal, Union +from typing import Annotated, List, Literal, Optional, Union from pydantic import Field @@ -6,12 +6,18 @@ from libecalc.presentation.yaml.yaml_types.models.yaml_compressor_stages import ( YamlCompressorStageMultipleStreams, YamlCompressorStages, + YamlSingleSpeedCompressorStages, YamlUnknownCompressorStages, + YamlVariableSpeedCompressorStages, ) from libecalc.presentation.yaml.yaml_types.models.yaml_enums import ( YamlModelType, YamlPressureControl, ) +from libecalc.presentation.yaml.yaml_types.models.yaml_fluid import ( + YamlCompositionFluidModel, + YamlPredefinedFluidModel, +) from libecalc.presentation.yaml.yaml_types.yaml_stream import YamlStream @@ -21,26 +27,19 @@ class YamlCompressorTrainBase(YamlBase): description="Name of the model. See documentation for more information.", title="NAME", ) - fluid_model: str = Field(..., description="Reference to a fluid model", title="FLUID_MODEL") - pressure_control: YamlPressureControl = Field( - ..., - description="Method for pressure control", - title="PRESSURE_CONTROL", - ) - power_adjustment_constant: float = Field( - 0.0, - description="Constant to adjust power usage in MW", - title="POWER_ADJUSTMENT_CONSTANT", - ) - maximum_power: str = Field( - ..., description="Optional constant MW maximum power the compressor train can require", title="MAXIMUM_POWER" - ) - calculate_max_rate: str = Field( - ..., - description="Optional compressor train max standard rate [Sm3/day] in result if set to true. " - "Default false. Use with caution. This will increase runtime significantly.", - title="CALCULATE_MAX_RATE", + fluid_model: Union[YamlPredefinedFluidModel, YamlCompositionFluidModel] = Field( + ..., description="Reference to a fluid model", title="FLUID_MODEL" ) + maximum_power: Optional[ + Annotated[ + float, + Field( + ..., + description="Optional constant MW maximum power the compressor train can require", + title="MAXIMUM_POWER", + ), + ] + ] class YamlSingleSpeedCompressorTrain(YamlCompressorTrainBase): @@ -49,16 +48,47 @@ class YamlSingleSpeedCompressorTrain(YamlCompressorTrainBase): description="Defines the type of model. See documentation for more information.", title="TYPE", ) - maximum_discharge_pressure: str = Field( - ..., - description="Maximum discharge pressure in bar (can only use if pressure control is DOWNSTREAM_CHOKE)", - title="MAXIMUM_DISCHARGE_PRESSURE", - ) - compressor_train: YamlCompressorStages = Field( + compressor_train: YamlSingleSpeedCompressorStages = Field( ..., description="Compressor train definition", title="COMPRESSOR_TRAIN", ) + pressure_control: YamlPressureControl = Field( + ..., + description="Method for pressure control", + title="PRESSURE_CONTROL", + ) + maximum_discharge_pressure: Optional[ + Annotated[ + float, + Field( + ..., + description="Maximum discharge pressure in bar (can only use if pressure control is DOWNSTREAM_CHOKE)", + title="MAXIMUM_DISCHARGE_PRESSURE", + ), + ] + ] + calculate_max_rate: Optional[ + Annotated[ + float, + Field( + ..., + description="Optional compressor train max standard rate [Sm3/day] in result if set to true. " + "Default false. Use with caution. This will increase runtime significantly.", + title="CALCULATE_MAX_RATE", + ), + ] + ] + power_adjustment_constant: Optional[ + Annotated[ + float, + Field( + 0.0, + description="Constant to adjust power usage in MW", + title="POWER_ADJUSTMENT_CONSTANT", + ), + ] + ] def to_dto(self): raise NotImplementedError @@ -70,11 +100,37 @@ class YamlVariableSpeedCompressorTrain(YamlCompressorTrainBase): description="Defines the type of model. See documentation for more information.", title="TYPE", ) - compressor_train: YamlCompressorStages = Field( + compressor_train: YamlVariableSpeedCompressorStages = Field( ..., description="Compressor train definition", title="COMPRESSOR_TRAIN", ) + pressure_control: YamlPressureControl = Field( + ..., + description="Method for pressure control", + title="PRESSURE_CONTROL", + ) + calculate_max_rate: Optional[ + Annotated[ + float, + Field( + ..., + description="Optional compressor train max standard rate [Sm3/day] in result if set to true. " + "Default false. Use with caution. This will increase runtime significantly.", + title="CALCULATE_MAX_RATE", + ), + ] + ] + power_adjustment_constant: Optional[ + Annotated[ + float, + Field( + 0.0, + description="Constant to adjust power usage in MW", + title="POWER_ADJUSTMENT_CONSTANT", + ), + ] + ] def to_dto(self): raise NotImplementedError @@ -91,6 +147,17 @@ class YamlSimplifiedVariableSpeedCompressorTrain(YamlCompressorTrainBase): description="Compressor train definition", title="COMPRESSOR_TRAIN", ) + calculate_max_rate: Optional[ + Annotated[ + float, + Field( + ..., + description="Optional compressor train max standard rate [Sm3/day] in result if set to true. " + "Default false. Use with caution. This will increase runtime significantly.", + title="CALCULATE_MAX_RATE", + ), + ] + ] def to_dto(self): raise NotImplementedError @@ -111,7 +178,7 @@ class YamlVariableSpeedCompressorTrainMultipleStreamsAndPressures(YamlCompressor stages: List[YamlCompressorStageMultipleStreams] = Field( ..., description="A list of all stages in compressor model.", - title="STREAMS", + title="STAGES", ) def to_dto(self): diff --git a/src/libecalc/presentation/yaml/yaml_types/models/yaml_enums.py b/src/libecalc/presentation/yaml/yaml_types/models/yaml_enums.py index 799e4e8ec2..611085185c 100644 --- a/src/libecalc/presentation/yaml/yaml_types/models/yaml_enums.py +++ b/src/libecalc/presentation/yaml/yaml_types/models/yaml_enums.py @@ -15,6 +15,7 @@ class YamlModelType(str, enum.Enum): class YamlChartType(str, enum.Enum): + SINGLE_SPEED = "SINGLE_SPEED" VARIABLE_SPEED = "VARIABLE_SPEED" GENERIC_FROM_INPUT = "GENERIC_FROM_INPUT" GENERIC_FROM_DESIGN_POINT = "GENERIC_FROM_DESIGN_POINT" diff --git a/src/libecalc/presentation/yaml/yaml_types/models/yaml_fluid.py b/src/libecalc/presentation/yaml/yaml_types/models/yaml_fluid.py index 35d6976b72..8d1cf2612d 100644 --- a/src/libecalc/presentation/yaml/yaml_types/models/yaml_fluid.py +++ b/src/libecalc/presentation/yaml/yaml_types/models/yaml_fluid.py @@ -37,7 +37,7 @@ class YamlPredefinedFluidModel(YamlBase): description="Name of the model. See documentation for more information.", title="NAME", ) - type: YamlModelType.FLUID + type: YamlModelType = YamlModelType.FLUID def to_dto(self): raise NotImplementedError