Skip to content

Commit fe0117e

Browse files
committed
refactor: delete conftest from src/libecalc/fixtures
1 parent c5e0107 commit fe0117e

6 files changed

Lines changed: 133 additions & 157 deletions

File tree

src/libecalc/fixtures/__init__.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,3 @@
33
from .cases.compressor_systems_and_compressor_train_temporal import compressor_systems_and_compressor_train_temporal
44
from .cases.ltp_export import ltp_export_yaml
55
from .compressor_process_simulations.compressor_process_simulations import * # noqa: F403
6-
from .conftest import (
7-
fuel_gas,
8-
medium_fluid_dto,
9-
predefined_variable_speed_compressor_chart_dto,
10-
rich_fluid_dto,
11-
)

src/libecalc/fixtures/conftest.py

Lines changed: 0 additions & 125 deletions
This file was deleted.

tests/libecalc/core/conftest.py

Lines changed: 97 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import libecalc.common.fixed_speed_pressure_control
77
import libecalc.common.serializable_chart
88
import libecalc.dto.fuel_type
9+
from libecalc.common.serializable_chart import ChartCurveDTO, VariableSpeedChartDTO
910
from libecalc.domain.infrastructure.energy_components.legacy_consumer.tabulated import TabularConsumerFunction
1011
from libecalc.domain.infrastructure.energy_components.legacy_consumer.tabulated.common import VariableExpression
1112
from libecalc.domain.infrastructure.energy_components.turbine import Turbine
@@ -22,23 +23,23 @@
2223

2324

2425
@pytest.fixture
25-
def medium_fluid() -> FluidModel:
26+
def fluid_model_medium() -> FluidModel:
2627
return FluidModel(
2728
eos_model=EoSModel.SRK,
2829
composition=FluidComposition.model_validate(MEDIUM_MW_19P4),
2930
)
3031

3132

3233
@pytest.fixture
33-
def rich_fluid() -> FluidModel:
34+
def fluid_model_rich() -> FluidModel:
3435
return FluidModel(
3536
eos_model=EoSModel.SRK,
3637
composition=FluidComposition.model_validate(RICH_MW_21P4),
3738
)
3839

3940

4041
@pytest.fixture
41-
def dry_fluid() -> FluidModel:
42+
def fluid_model_dry() -> FluidModel:
4243
return FluidModel(
4344
eos_model=EoSModel.SRK,
4445
composition=FluidComposition.model_validate(DRY_MW_18P3),
@@ -236,10 +237,10 @@ def variable_speed_compressor_chart_dto() -> libecalc.common.serializable_chart.
236237

237238
@pytest.fixture
238239
def variable_speed_compressor_train_dto(
239-
medium_fluid_dto, variable_speed_compressor_chart_dto
240+
fluid_model_medium, variable_speed_compressor_chart_dto
240241
) -> dto.VariableSpeedCompressorTrain:
241242
return dto.VariableSpeedCompressorTrain(
242-
fluid_model=medium_fluid_dto,
243+
fluid_model=fluid_model_medium,
243244
stages=[
244245
dto.CompressorStage(
245246
compressor_chart=variable_speed_compressor_chart_dto,
@@ -257,10 +258,10 @@ def variable_speed_compressor_train_dto(
257258

258259
@pytest.fixture
259260
def variable_speed_compressor_train_two_stages_dto(
260-
medium_fluid_dto, variable_speed_compressor_chart_dto
261+
fluid_model_medium, variable_speed_compressor_chart_dto
261262
) -> dto.VariableSpeedCompressorTrain:
262263
return dto.VariableSpeedCompressorTrain(
263-
fluid_model=medium_fluid_dto,
264+
fluid_model=fluid_model_medium,
264265
stages=[
265266
dto.CompressorStage(
266267
compressor_chart=variable_speed_compressor_chart_dto,
@@ -350,3 +351,92 @@ def create_tabular_consumer_function(
350351
)
351352

352353
return create_tabular_consumer_function
354+
355+
356+
@pytest.fixture
357+
def predefined_variable_speed_compressor_chart_dto() -> VariableSpeedChartDTO:
358+
"""NOT USED CURRENTLY, KEPT FOR FUTURE REFERENCE"""
359+
return VariableSpeedChartDTO(
360+
curves=[
361+
ChartCurveDTO(
362+
speed_rpm=7689.0,
363+
rate_actual_m3_hour=[2900.0666, 3503.8068, 4002.5554, 4595.0148],
364+
polytropic_head_joule_per_kg=[82530.702036, 78443.25272100001, 72239.03594100001, 60107.539661999996],
365+
efficiency_fraction=[0.723, 0.7469, 0.7449, 0.7015],
366+
),
367+
ChartCurveDTO(
368+
speed_rpm=8787.0,
369+
rate_actual_m3_hour=[3305.5723, 4000.1546, 4499.2342, 4996.8728, 5241.9892],
370+
polytropic_head_joule_per_kg=[
371+
107428.875417,
372+
101959.123527,
373+
95230.48671000001,
374+
84305.752866,
375+
78230.827962,
376+
],
377+
efficiency_fraction=[0.7241, 0.7449, 0.7464, 0.722, 0.7007],
378+
),
379+
ChartCurveDTO(
380+
speed_rpm=9886.0,
381+
rate_actual_m3_hour=[3708.8713, 4502.2531, 4993.5959, 5507.8114, 5924.3308],
382+
polytropic_head_joule_per_kg=[
383+
135823.185648,
384+
129322.210482,
385+
121892.878719,
386+
110621.46830400001,
387+
98633.21175900001,
388+
],
389+
efficiency_fraction=[0.723, 0.7473, 0.748, 0.7306, 0.704],
390+
),
391+
ChartCurveDTO(
392+
speed_rpm=10435.0,
393+
rate_actual_m3_hour=[3928.0389, 4507.4654, 5002.1249, 5498.9912, 6248.5937],
394+
polytropic_head_joule_per_kg=[
395+
151422.09804,
396+
146980.631331,
397+
140775.67978200002,
398+
131074.593345,
399+
109705.500756,
400+
],
401+
efficiency_fraction=[0.7232, 0.7437, 0.7453, 0.7414, 0.701],
402+
),
403+
ChartCurveDTO(
404+
speed_rpm=10984.0,
405+
rate_actual_m3_hour=[4138.6974, 5002.4758, 5494.3704, 6008.6962, 6560.148],
406+
polytropic_head_joule_per_kg=[
407+
167543.961912,
408+
159657.01326900002,
409+
151353.646803,
410+
139907.430036,
411+
121474.81477800001,
412+
],
413+
efficiency_fraction=[0.7226, 0.7462, 0.7468, 0.7349, 0.7023],
414+
),
415+
ChartCurveDTO(
416+
speed_rpm=11533.0,
417+
rate_actual_m3_hour=[4327.9175, 4998.517, 5505.8851, 6027.6167, 6506.9064, 6908.2832],
418+
polytropic_head_joule_per_kg=[
419+
185235.416955,
420+
178887.22567200003,
421+
171985.250079,
422+
161764.148295,
423+
147514.415994,
424+
133600.348539,
425+
],
426+
efficiency_fraction=[0.7254, 0.7444, 0.745, 0.7466, 0.7266, 0.7019],
427+
),
428+
ChartCurveDTO(
429+
speed_rpm=10767.0,
430+
rate_actual_m3_hour=[4052.9057, 4500.6637, 4999.41, 5492.822, 6000.6263, 6439.4876],
431+
polytropic_head_joule_per_kg=[
432+
161345.07,
433+
157754.61000000002,
434+
152506.26,
435+
143618.4,
436+
131983.74000000002,
437+
117455.13,
438+
],
439+
efficiency_fraction=[0.724, 0.738, 0.7479, 0.74766, 0.7298, 0.7014],
440+
),
441+
],
442+
)

tests/libecalc/core/consumers/conftest.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@
1616
from libecalc.domain.infrastructure.energy_components.generator_set.generator_set_component import (
1717
GeneratorSetEnergyComponent,
1818
)
19-
from libecalc.domain.infrastructure.energy_components.legacy_consumer.tabulated import (
20-
TabularConsumerFunction,
21-
)
22-
from libecalc.domain.infrastructure.path_id import PathID
19+
from libecalc.domain.infrastructure.energy_components.legacy_consumer.tabulated import TabularConsumerFunction
2320
from libecalc.domain.infrastructure.energy_components.legacy_consumer.tabulated.common import VariableExpression
21+
from libecalc.domain.infrastructure.path_id import PathID
2422
from libecalc.domain.regularity import Regularity
25-
from libecalc.dto.types import ConsumerUserDefinedCategoryType
23+
from libecalc.dto import Emission, FuelType
24+
from libecalc.dto.types import ConsumerUserDefinedCategoryType, FuelTypeUserDefinedCategoryType
2625
from libecalc.expression import Expression
2726
from libecalc.presentation.yaml.yaml_entities import MemoryResource
2827

@@ -32,6 +31,22 @@ def methane_values():
3231
return [0.005, 1.5, 3, 4]
3332

3433

34+
@pytest.fixture
35+
def fuel_gas() -> dict[Period, FuelType]:
36+
return {
37+
Period(datetime(1900, 1, 1), datetime(2021, 1, 1)): FuelType(
38+
name="fuel_gas",
39+
user_defined_category=FuelTypeUserDefinedCategoryType.FUEL_GAS,
40+
emissions=[
41+
Emission(
42+
name="co2",
43+
factor=Expression.setup_from_expression(value="2.20"),
44+
)
45+
],
46+
)
47+
}
48+
49+
3550
@pytest.fixture
3651
def tabulated_fuel_consumer_factory(fuel_gas, expression_evaluator_factory, tabulated_energy_usage_model_factory):
3752
def create_tabulated_fuel_consumer(

tests/libecalc/core/models/compressor_modelling/conftest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ def single_speed_chart_dto() -> libecalc.common.serializable_chart.SingleSpeedCh
115115

116116

117117
@pytest.fixture
118-
def single_speed_compressor_train(medium_fluid_dto, single_speed_chart_dto) -> dto.SingleSpeedCompressorTrain:
118+
def single_speed_compressor_train(fluid_model_medium, single_speed_chart_dto) -> dto.SingleSpeedCompressorTrain:
119119
return dto.SingleSpeedCompressorTrain(
120-
fluid_model=medium_fluid_dto,
120+
fluid_model=fluid_model_medium,
121121
stages=[
122122
dto.CompressorStage(
123123
compressor_chart=single_speed_chart_dto.model_copy(deep=True),
@@ -315,11 +315,11 @@ def variable_speed_compressor_train_two_compressors_one_stream(
315315

316316
@pytest.fixture
317317
def variable_speed_compressor_train_two_compressors_one_stream_dto(
318-
medium_fluid_dto,
318+
fluid_model_medium,
319319
variable_speed_compressor_chart_dto,
320320
) -> dto.VariableSpeedCompressorTrainMultipleStreamsAndPressures:
321321
stream = MultipleStreamsAndPressureStream(
322-
fluid_model=medium_fluid_dto,
322+
fluid_model=fluid_model_medium,
323323
name="in_stream_stage_1",
324324
typ=FluidStreamType.INGOING,
325325
)

0 commit comments

Comments
 (0)