-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: define yaml classes for remaining elements in MODELS #307
Merged
frodehk
merged 7 commits into
main
from
ECALC-505-define-yaml-classes-for-elements-in-models
Dec 14, 2023
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5a1487d
chore: add yaml class single speed compressor train
frodehk 5822a62
chore: add yaml class for variable speed compressor train
frodehk e0b78f6
chore: add not implemented
frodehk ea01bbb
chore: add yaml classes for multiple streams and stages
frodehk 5840701
chore: update yaml class multiple streams
frodehk afde757
chore: update yaml class for pressure control
frodehk 3a5d499
chore: change some types
frodehk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
src/libecalc/presentation/yaml/yaml_types/models/yaml_compressor_stages.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import enum | ||
from typing import List, 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, | ||
) | ||
from libecalc.presentation.yaml.yaml_types.models.yaml_enums import YamlPressureControl | ||
|
||
|
||
class YamlControlMarginUnits(enum.Enum): | ||
FRACTION = "FRACTION" | ||
PERCENTAGE = "PERCENTAGE" | ||
|
||
|
||
class YamlInterstageControlPressure(YamlBase): | ||
upstream_pressure_control: YamlPressureControl = Field( | ||
..., | ||
description="Pressure control.", | ||
title="UPSTREAM_PRESSURE_CONTROL", | ||
) | ||
downstream_pressure_control: YamlPressureControl = Field( | ||
..., | ||
description="Pressure control.", | ||
title="DOWNSTREAM_PRESSURE_CONTROL", | ||
) | ||
|
||
|
||
class YamlCompressorStageBase(YamlBase): | ||
inlet_temperature: str = Field( | ||
..., | ||
description="Inlet temperature in Celsius for stage", | ||
title="INLET_TEMPERATURE", | ||
) | ||
compressor_chart: YamlCompressorChart = Field( | ||
..., | ||
description="Reference to compressor chart model for stage, must be defined in MODELS or FACILITY_INPUTS", | ||
title="COMPRESSOR_CHART", | ||
) | ||
|
||
|
||
class YamlCompressorStage(YamlCompressorStageBase): | ||
pressure_drop_ahead_of_stage: str = 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", | ||
) | ||
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( | ||
..., | ||
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: str = 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="List of compressor stages", | ||
title="STAGES", | ||
) |
118 changes: 118 additions & 0 deletions
118
src/libecalc/presentation/yaml/yaml_types/models/yaml_compressor_trains.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
from typing import List, Literal, Union | ||
|
||
from pydantic import Field | ||
|
||
from libecalc.presentation.yaml.yaml_types import YamlBase | ||
from libecalc.presentation.yaml.yaml_types.models.yaml_compressor_stages import ( | ||
YamlCompressorStageMultipleStreams, | ||
YamlCompressorStages, | ||
YamlUnknownCompressorStages, | ||
) | ||
from libecalc.presentation.yaml.yaml_types.models.yaml_enums import ( | ||
YamlModelType, | ||
YamlPressureControl, | ||
) | ||
from libecalc.presentation.yaml.yaml_types.yaml_stream import YamlStream | ||
|
||
|
||
class YamlCompressorTrainBase(YamlBase): | ||
name: str = Field( | ||
..., | ||
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", | ||
) | ||
|
||
|
||
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", | ||
) | ||
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( | ||
..., | ||
description="Compressor train definition", | ||
title="COMPRESSOR_TRAIN", | ||
) | ||
|
||
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", | ||
) | ||
compressor_train: YamlCompressorStages = Field( | ||
..., | ||
description="Compressor train definition", | ||
title="COMPRESSOR_TRAIN", | ||
) | ||
|
||
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", | ||
) | ||
compressor_train: Union[YamlCompressorStages, YamlUnknownCompressorStages] = Field( | ||
..., | ||
description="Compressor train definition", | ||
title="COMPRESSOR_TRAIN", | ||
) | ||
|
||
def to_dto(self): | ||
raise NotImplementedError | ||
|
||
|
||
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( | ||
..., | ||
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", | ||
title="STREAMS", | ||
) | ||
stages: List[YamlCompressorStageMultipleStreams] = Field( | ||
..., | ||
description="A list of all stages in compressor model.", | ||
title="STREAMS", | ||
) | ||
|
||
def to_dto(self): | ||
raise NotImplementedError |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is a mistake to define this as needed in YamlBase, as I have done currently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean it should be defined in YamlBase instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, it doesnt matter that much. We want to skip
dtos
completely, and map directly to domain. dtos are no longer needed, but we will need some clever ways to map to domain. WIP :)