Skip to content

Commit

Permalink
fix: yaml models schema
Browse files Browse the repository at this point in the history
Removed yellow lines from all_energy_usage_models
  • Loading branch information
jsolaas committed Jan 15, 2024
1 parent c448942 commit b5d3451
Show file tree
Hide file tree
Showing 5 changed files with 250 additions and 2,579 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def to_dto(self):


class YamlCurve(YamlBase):
speed: float
speed: float = None
rate: List[float]
head: List[float]
efficiency: List[float]
Expand Down Expand Up @@ -89,7 +89,7 @@ class YamlSingleSpeedChart(YamlBase):
title="TYPE",
)
chart_type: Literal[YamlChartType.SINGLE_SPEED] = YamlChartType.SINGLE_SPEED
curves: YamlCurve = Field(..., description="One single compressor chart curve.", title="CURVE")
curve: YamlCurve = Field(..., description="One single compressor chart curve.", title="CURVE")
units: YamlUnits = None

def to_dto(self):
Expand Down Expand Up @@ -132,6 +132,7 @@ class YamlGenericFromInputChart(YamlBase):
description="Polytropic efficiency for compressor chart",
title="POLYTROPIC_EFFICIENCY",
)
units: YamlUnits = None

def to_dto(self):
raise NotImplementedError
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import enum
from typing import List, Optional, Union
from typing import List, Literal, Optional, Union

from typing_extensions import Annotated

Expand All @@ -9,12 +9,6 @@
from pydantic import Field

from libecalc.presentation.yaml.yaml_types import YamlBase
from libecalc.presentation.yaml.yaml_types.models.yaml_compressor_chart import (
YamlGenericFromDesignPointChart,
YamlGenericFromInputChart,
YamlSingleSpeedChart,
YamlVariableSpeedChart,
)
from libecalc.presentation.yaml.yaml_types.models.yaml_enums import YamlPressureControl


Expand Down Expand Up @@ -42,9 +36,7 @@ class YamlCompressorStageBase(YamlBase):
description="Inlet temperature in Celsius for stage",
title="INLET_TEMPERATURE",
)
compressor_chart: Union[
YamlSingleSpeedChart, YamlVariableSpeedChart, YamlGenericFromDesignPointChart, YamlGenericFromInputChart
] = Field(
compressor_chart: str = Field(
...,
description="Reference to compressor chart model for stage, must be defined in MODELS or FACILITY_INPUTS",
title="COMPRESSOR_CHART",
Expand All @@ -62,21 +54,24 @@ class YamlSingleSpeedCompressorStage(YamlCompressorStageBase):
),
]
]
compressor_chart: YamlSingleSpeedChart
compressor_chart: str = Field(
...,
description="Reference to compressor chart model for stage, must be defined in MODELS or FACILITY_INPUTS",
title="COMPRESSOR_CHART",
)


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
pressure_drop_ahead_of_stage: float = Field(
None,
description="Pressure drop before compression stage [in bar]",
title="PRESSURE_DROP_AHEAD_OF_STAGE",
)
compressor_chart: str
control_margin: float = Field(
None,
)
control_margin_unit: Literal["PERCENTAGE", "FRACTION"] = Field(None)


class YamlCompressorStage(YamlCompressorStageBase):
Expand Down Expand Up @@ -114,7 +109,7 @@ class YamlCompressorStageMultipleStreams(YamlCompressorStageBase):
]
]
stream: Union[str, List[str]] = Field(
...,
None,
description="Reference to stream from STREAMS.",
title="STREAM",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@
YamlModelType,
YamlPressureControl,
)
from libecalc.presentation.yaml.yaml_types.models.yaml_fluid import (
YamlCompositionFluidModel,
YamlPredefinedFluidModel,
)
from libecalc.presentation.yaml.yaml_types.yaml_stream import YamlStream


class YamlCompressorTrainBase(YamlBase):
Expand All @@ -32,24 +27,16 @@ class YamlCompressorTrainBase(YamlBase):
description="Name of the model. See documentation for more information.",
title="NAME",
)
fluid_model: Union[YamlPredefinedFluidModel, YamlCompositionFluidModel] = Field(
..., description="Reference to a fluid model", title="FLUID_MODEL"
maximum_power: float = Field(
None,
description="Optional constant MW maximum power the compressor train can require",
title="MAXIMUM_POWER",
)
maximum_power: Optional[
Annotated[
float,
Field(
...,
description="Optional constant MW maximum power the compressor train can require",
title="MAXIMUM_POWER",
),
]
]


class YamlSingleSpeedCompressorTrain(YamlCompressorTrainBase):
type: Literal[YamlModelType.SINGLE_SPEED_COMPRESSOR_TRAIN] = Field(
YamlModelType.SINGLE_SPEED_COMPRESSOR_TRAIN,
...,
description="Defines the type of model. See documentation for more information.",
title="TYPE",
)
Expand All @@ -59,7 +46,7 @@ class YamlSingleSpeedCompressorTrain(YamlCompressorTrainBase):
title="COMPRESSOR_TRAIN",
)
pressure_control: YamlPressureControl = Field(
...,
None,
description="Method for pressure control",
title="PRESSURE_CONTROL",
)
Expand Down Expand Up @@ -94,14 +81,15 @@ class YamlSingleSpeedCompressorTrain(YamlCompressorTrainBase):
),
]
]
fluid_model: str = Field(..., description="Reference to a fluid model", title="FLUID_MODEL")

def to_dto(self):
raise NotImplementedError


class YamlVariableSpeedCompressorTrain(YamlCompressorTrainBase):
type: Literal[YamlModelType.VARIABLE_SPEED_COMPRESSOR_TRAIN] = Field(
YamlModelType.VARIABLE_SPEED_COMPRESSOR_TRAIN,
...,
description="Defines the type of model. See documentation for more information.",
title="TYPE",
)
Expand All @@ -111,7 +99,7 @@ class YamlVariableSpeedCompressorTrain(YamlCompressorTrainBase):
title="COMPRESSOR_TRAIN",
)
pressure_control: YamlPressureControl = Field(
...,
None,
description="Method for pressure control",
title="PRESSURE_CONTROL",
)
Expand All @@ -136,14 +124,15 @@ class YamlVariableSpeedCompressorTrain(YamlCompressorTrainBase):
),
]
]
fluid_model: str = Field(..., description="Reference to a fluid model", title="FLUID_MODEL")

def to_dto(self):
raise NotImplementedError


class YamlSimplifiedVariableSpeedCompressorTrain(YamlCompressorTrainBase):
type: Literal[YamlModelType.SIMPLIFIED_VARIABLE_SPEED_COMPRESSOR_TRAIN] = Field(
YamlModelType.SIMPLIFIED_VARIABLE_SPEED_COMPRESSOR_TRAIN,
...,
description="Defines the type of model. See documentation for more information.",
title="TYPE",
)
Expand All @@ -163,18 +152,35 @@ class YamlSimplifiedVariableSpeedCompressorTrain(YamlCompressorTrainBase):
),
]
]
fluid_model: str = Field(..., description="Reference to a fluid model", title="FLUID_MODEL")
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


class YamlMultipleStreamsStream(YamlBase):
type: Literal["INGOING", "OUTGOING"]
name: str
fluid_model: str = Field(None, description="Reference to a fluid model", title="FLUID_MODEL")


class YamlVariableSpeedCompressorTrainMultipleStreamsAndPressures(YamlCompressorTrainBase):
type: Literal[YamlModelType.VARIABLE_SPEED_COMPRESSOR_TRAIN_MULTIPLE_STREAMS_AND_PRESSURES] = Field(
YamlModelType.VARIABLE_SPEED_COMPRESSOR_TRAIN_MULTIPLE_STREAMS_AND_PRESSURES,
...,
description="Defines the type of model. See documentation for more information.",
title="TYPE",
)
streams: List[YamlStream] = Field(
streams: List[YamlMultipleStreamsStream] = Field(
...,
description="A list of all in- and out-going streams for the compressor train. "
"The same equation of state (EOS) must be used for each INGOING stream fluid models",
Expand All @@ -185,6 +191,21 @@ class YamlVariableSpeedCompressorTrainMultipleStreamsAndPressures(YamlCompressor
description="A list of all stages in compressor model.",
title="STAGES",
)
pressure_control: YamlPressureControl = Field(
None,
description="Method for pressure control",
title="PRESSURE_CONTROL",
)
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class YamlPredefinedFluidModel(YamlBase):
description="Name of the model. See documentation for more information.",
title="NAME",
)
type: Literal[YamlModelType.FLUID] = YamlModelType.FLUID
type: Literal[YamlModelType.FLUID]

def to_dto(self):
raise NotImplementedError
Expand Down
Loading

0 comments on commit b5d3451

Please sign in to comment.