Skip to content

Commit

Permalink
refactor!: use yaml objects in mapper
Browse files Browse the repository at this point in the history
BREAKING CHANGE: H2O no longer supported in fluid composition, use
'water'
  • Loading branch information
jsolaas committed Oct 3, 2024
1 parent 9741159 commit 328ce12
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 131 deletions.
65 changes: 0 additions & 65 deletions src/libecalc/fixtures/cases/ltp_export/loading_storage_ltp_yaml.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class EnergyUsageModelCommon(YamlBase):
None,
title="CONDITIONS",
description="Logical conditions for the consumer to be used.\n\n$ECALC_DOCS_KEYWORDS_URL/CONDITION",
)
) # TODO: Validate either or between conditions and condition
power_loss_factor: YamlExpressionType = Field(
None,
title="POWERLOSSFACTOR",
Expand Down
65 changes: 0 additions & 65 deletions src/tests/libecalc/presentation/exporter/test_ltp.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
no_el_consumption,
simple_direct_el_consumer,
)
from libecalc.fixtures.cases.ltp_export.loading_storage_ltp_yaml import (
ltp_oil_loaded_yaml_factory,
)
from libecalc.fixtures.cases.ltp_export.utilities import (
get_consumption,
get_sum_ltp_column,
Expand Down Expand Up @@ -417,68 +414,6 @@ def test_no_emitters_or_fuelconsumers():
assert f"It is required to specify at least one of the keywords {EcalcYamlKeywords.fuel_consumers}, {EcalcYamlKeywords.generator_sets} or {EcalcYamlKeywords.installation_venting_emitters} in the model."


def test_total_oil_loaded_old_method():
"""Test total oil loaded/stored for LTP export. Using original method where direct/venting emitters are
modelled as FUELSCONSUMERS using DIRECT.
Verify correct volume when model includes emissions related to both storage and loading of oil,
and when model includes only loading.
"""
time_vector = [
datetime(2027, 1, 1),
datetime(2028, 1, 1),
]
variables = VariablesMap(time_vector=time_vector, variables={})

regularity = 0.6
emission_factor = 2
fuel_rate = 100

# Create model with both loading and storage
asset_loading_storage = ltp_oil_loaded_yaml_factory(
emission_factor=emission_factor,
rate_types=[RateType.STREAM_DAY, RateType.STREAM_DAY],
fuel_rates=[fuel_rate, fuel_rate],
emission_name="ch4",
regularity=regularity,
categories=["LOADING", "STORAGE"],
consumer_names=["loading", "storage"],
)

# Create model with only loading, not storage
asset_loading_only = ltp_oil_loaded_yaml_factory(
emission_factor=emission_factor,
rate_types=[RateType.STREAM_DAY],
fuel_rates=[fuel_rate],
emission_name="ch4",
regularity=regularity,
categories=["LOADING"],
consumer_names=["loading"],
)

ltp_result_loading_storage = get_consumption(
model=asset_loading_storage, variables=variables, time_vector=time_vector_yearly
)
ltp_result_loading_only = get_consumption(
model=asset_loading_only, variables=variables, time_vector=time_vector_yearly
)

loaded_and_stored_oil_loading_and_storage = get_sum_ltp_column(
ltp_result_loading_storage, installation_nr=0, ltp_column_nr=2
)
loaded_and_stored_oil_loading_only = get_sum_ltp_column(ltp_result_loading_only, installation_nr=0, ltp_column_nr=1)

# Verify output for total oil loaded/stored, if only loading is specified.
assert loaded_and_stored_oil_loading_only is not None

# Verify correct volume for oil loaded/stored
assert loaded_and_stored_oil_loading_and_storage == fuel_rate * 365 * regularity

# Verify that total oil loaded/stored is the same if only loading is specified,
# compared to a model with both loading and storage.
assert loaded_and_stored_oil_loading_and_storage == loaded_and_stored_oil_loading_only


def test_electrical_and_mechanical_power_installation():
"""Check that new total power includes the sum of electrical- and mechanical power at installation level"""
variables = VariablesMap(time_vector=time_vector_installation, variables={})
Expand Down

0 comments on commit 328ce12

Please sign in to comment.