-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathtime_series_fluid_model.py
More file actions
54 lines (47 loc) · 2.21 KB
/
Copy pathtime_series_fluid_model.py
File metadata and controls
54 lines (47 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from libecalc.common.ddd import value_object
from libecalc.common.errors.exceptions import ProgrammingError
from libecalc.common.time_utils import Period
from libecalc.presentation.yaml.domain.time_series_expression import TimeSeriesExpression
from libecalc.process.fluid_stream.fluid_model import EoSModel, FluidComposition, FluidModel
@value_object
class TimeSeriesFluidComposition:
water: TimeSeriesExpression
nitrogen: TimeSeriesExpression
CO2: TimeSeriesExpression
methane: TimeSeriesExpression
ethane: TimeSeriesExpression
propane: TimeSeriesExpression
i_butane: TimeSeriesExpression
n_butane: TimeSeriesExpression
i_pentane: TimeSeriesExpression
n_pentane: TimeSeriesExpression
n_hexane: TimeSeriesExpression
def get_value(self, period: Period) -> FluidComposition:
"""Evaluate all component expressions and materialize the fluid composition for the given period."""
try:
index = self.methane.get_periods().index(period)
except ValueError as error:
raise ProgrammingError(f"Period {period} is not available for the fluid composition.") from error
return FluidComposition(
water=self.water.get_masked_values()[index],
nitrogen=self.nitrogen.get_masked_values()[index],
CO2=self.CO2.get_masked_values()[index],
methane=self.methane.get_masked_values()[index],
ethane=self.ethane.get_masked_values()[index],
propane=self.propane.get_masked_values()[index],
i_butane=self.i_butane.get_masked_values()[index],
n_butane=self.n_butane.get_masked_values()[index],
i_pentane=self.i_pentane.get_masked_values()[index],
n_pentane=self.n_pentane.get_masked_values()[index],
n_hexane=self.n_hexane.get_masked_values()[index],
)
@value_object
class TimeSeriesFluidModel:
eos_model: EoSModel
composition: TimeSeriesFluidComposition
def get_value(self, period: Period) -> FluidModel:
"""Materialize a fluid model with the composition evaluated for the given period."""
return FluidModel(
eos_model=self.eos_model,
composition=self.composition.get_value(period),
)