Skip to content

Commit

Permalink
chore: add rate type to pump model result (#209)
Browse files Browse the repository at this point in the history
* chore: add rate type to pump model result
  • Loading branch information
frodehk authored Sep 27, 2023
1 parent 8cf9e1b commit 21deeb7
Show file tree
Hide file tree
Showing 4 changed files with 337 additions and 117 deletions.
54 changes: 54 additions & 0 deletions src/libecalc/core/graph_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
CompressorModelResult,
CompressorModelStageResult,
CompressorStreamConditionResult,
PumpModelResult,
TurbineModelResult,
)
from libecalc.dto.types import RateType
Expand Down Expand Up @@ -649,6 +650,59 @@ def get_asset_result(self) -> libecalc.dto.result.EcalcModelResult:
)
]
)
elif consumer_node_info.component_type in [ComponentType.PUMP, ComponentType.PUMP_SYSTEM]:
component = self.graph.get_component(consumer_id)
for model in consumer_result.models:
models.extend(
[
PumpModelResult(
parent=consumer_id,
name=model.name,
componentType=model.component_type,
component_level=ComponentLevel.MODEL,
energy_usage=model.energy_usage,
is_valid=model.is_valid,
energy_usage_cumulative=model.energy_usage.to_volumes().cumulative(),
timesteps=model.timesteps,
power_cumulative=(
model.power.to_volumes().to_unit(Unit.GIGA_WATT_HOURS).cumulative()
if model.power is not None
else None
),
power=model.power,
inlet_liquid_rate_m3_per_day=TimeSeriesRate(
timesteps=model.timesteps,
values=model.inlet_liquid_rate_m3_per_day
if model.inlet_liquid_rate_m3_per_day is not None
else [math.nan] * len(model.timesteps),
unit=Unit.STANDARD_CUBIC_METER_PER_DAY,
rate_type=RateType.STREAM_DAY,
),
inlet_pressure_bar=TimeSeriesFloat(
timesteps=model.timesteps,
values=model.inlet_pressure_bar
if model.inlet_pressure_bar is not None
else [math.nan] * len(model.timesteps),
unit=Unit.BARA,
),
outlet_pressure_bar=TimeSeriesFloat(
timesteps=model.timesteps,
values=model.outlet_pressure_bar
if model.outlet_pressure_bar is not None
else [math.nan] * len(model.timesteps),
unit=Unit.BARA,
),
operational_head=TimeSeriesFloat(
timesteps=model.timesteps,
values=model.operational_head
if model.operational_head is not None
else [math.nan] * len(model.timesteps),
unit=Unit.POLYTROPIC_HEAD_JOULE_PER_KG,
),
)
]
)

else:
models.extend(
[
Expand Down
10 changes: 5 additions & 5 deletions src/libecalc/dto/result/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from libecalc.dto.result.emission import EmissionIntensityResult, EmissionResult
from libecalc.dto.result.simple import SimpleComponentResult, SimpleResultData
from libecalc.dto.result.tabular_time_series import TabularTimeSeries
from libecalc.dto.result.types import opt_float
from pydantic import Field, validator
from typing_extensions import Annotated

Expand Down Expand Up @@ -137,10 +136,11 @@ class PumpModelResult(ConsumerModelResultBase):
"""The Pump result component."""

componentType: Literal[ComponentType.PUMP]
inlet_liquid_rate_m3_per_day: Optional[List[opt_float]]
inlet_pressure_bar: Optional[List[opt_float]]
outlet_pressure_bar: Optional[List[opt_float]]
operational_head: Optional[List[float]]
inlet_liquid_rate_m3_per_day: Optional[TimeSeriesRate]
inlet_pressure_bar: Optional[TimeSeriesFloat]
outlet_pressure_bar: Optional[TimeSeriesFloat]
operational_head: Optional[TimeSeriesFloat]
is_valid: TimeSeriesBoolean


class TurbineModelResult(EcalcResultBaseModel):
Expand Down
195 changes: 139 additions & 56 deletions src/tests/ecalc_cli/snapshots/test_app/test_json_true/test_v3.json
Original file line number Diff line number Diff line change
Expand Up @@ -3607,34 +3607,83 @@
13510.67
]
},
"inlet_liquid_rate_m3_per_day": [
18000.0,
19000.0,
15000.0,
16000.0,
14000.0,
15000.0,
18000.0,
15000.0,
12000.0,
14000.0,
16000.0,
14000.0
],
"inlet_pressure_bar": [
10.0,
10.0,
10.0,
10.0,
10.0,
10.0,
10.0,
10.0,
10.0,
10.0,
10.0,
10.0
],
"inlet_liquid_rate_m3_per_day": {
"rate_type": "STREAM_DAY",
"regularity": [
1.0,
1.0,
1.0,
1.0,
1.0,
1.0,
1.0,
1.0,
1.0,
1.0,
1.0,
1.0
],
"timesteps": [
"2020-01-01 00:00:00",
"2021-01-01 00:00:00",
"2022-01-01 00:00:00",
"2023-01-01 00:00:00",
"2024-01-01 00:00:00",
"2024-12-01 00:00:00",
"2026-01-01 00:00:00",
"2027-01-01 00:00:00",
"2028-01-01 00:00:00",
"2029-01-01 00:00:00",
"2030-01-01 00:00:00",
"2031-01-01 00:00:00"
],
"unit": "Sm3/d",
"values": [
18000.0,
19000.0,
15000.0,
16000.0,
14000.0,
15000.0,
18000.0,
15000.0,
12000.0,
14000.0,
16000.0,
14000.0
]
},
"inlet_pressure_bar": {
"timesteps": [
"2020-01-01 00:00:00",
"2021-01-01 00:00:00",
"2022-01-01 00:00:00",
"2023-01-01 00:00:00",
"2024-01-01 00:00:00",
"2024-12-01 00:00:00",
"2026-01-01 00:00:00",
"2027-01-01 00:00:00",
"2028-01-01 00:00:00",
"2029-01-01 00:00:00",
"2030-01-01 00:00:00",
"2031-01-01 00:00:00"
],
"unit": "bara",
"values": [
10.0,
10.0,
10.0,
10.0,
10.0,
10.0,
10.0,
10.0,
10.0,
10.0,
10.0,
10.0
]
},
"is_valid": {
"timesteps": [
"2020-01-01 00:00:00",
Expand Down Expand Up @@ -3667,34 +3716,68 @@
]
},
"name": "Produced water reinjection pump",
"operational_head": [
18811.88,
18811.88,
18811.88,
18811.88,
18811.88,
18811.88,
18811.88,
18811.88,
18811.88,
18811.88,
18811.88,
18811.88
],
"outlet_pressure_bar": [
200.0,
200.0,
200.0,
200.0,
200.0,
200.0,
200.0,
200.0,
200.0,
200.0,
200.0,
200.0
],
"operational_head": {
"timesteps": [
"2020-01-01 00:00:00",
"2021-01-01 00:00:00",
"2022-01-01 00:00:00",
"2023-01-01 00:00:00",
"2024-01-01 00:00:00",
"2024-12-01 00:00:00",
"2026-01-01 00:00:00",
"2027-01-01 00:00:00",
"2028-01-01 00:00:00",
"2029-01-01 00:00:00",
"2030-01-01 00:00:00",
"2031-01-01 00:00:00"
],
"unit": "J/kg",
"values": [
18811.88,
18811.88,
18811.88,
18811.88,
18811.88,
18811.88,
18811.88,
18811.88,
18811.88,
18811.88,
18811.88,
18811.88
]
},
"outlet_pressure_bar": {
"timesteps": [
"2020-01-01 00:00:00",
"2021-01-01 00:00:00",
"2022-01-01 00:00:00",
"2023-01-01 00:00:00",
"2024-01-01 00:00:00",
"2024-12-01 00:00:00",
"2026-01-01 00:00:00",
"2027-01-01 00:00:00",
"2028-01-01 00:00:00",
"2029-01-01 00:00:00",
"2030-01-01 00:00:00",
"2031-01-01 00:00:00"
],
"unit": "bara",
"values": [
200.0,
200.0,
200.0,
200.0,
200.0,
200.0,
200.0,
200.0,
200.0,
200.0,
200.0,
200.0
]
},
"parent": "e1c82c648513148fb53d7b9dcff878ca",
"power": {
"rate_type": "STREAM_DAY",
Expand Down
Loading

0 comments on commit 21deeb7

Please sign in to comment.