Skip to content

Bug get_density() function for gas commodity #411

@tolga-akan

Description

@tolga-akan

A bug has been identified in get_density() function in asset_tocomponent_base.py. Ideally, condition (elif NetworkSettings.NETWORK_TYPE_GAS in carrier.name:) should use a case‑insensitive comparison to detect the commodity name: str(NetworkSettings.NETWORK_TYPE_GAS).upper() in str(carrier.name).upper(). However, updating the condition causes the unit test test_gas_network_pipe_split_head_loss in test_head_loss.py to fail. The reason is that in the test ESDL, the commodity name is defined as "gas", whereas NetworkSettings.NETWORK_TYPE_GAS returns "Gas". With a case‑insensitive comparison, this elif condition no longer matches, causing the code to use the default density from the else branch (6.2). That value makes the test pass. This indicates a potential underlying bug in the head‑loss calculation logic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions