Coverage for backend/ahuora-compounds/ahuora_property_packages/build_package.py: 58%
36 statements
« prev ^ index » next coverage.py v7.10.7, created at 2026-07-22 05:22 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2026-07-22 05:22 +0000
1from ahuora_property_packages.modular.template_builder import build_peng_robinson, build_coolprop
2from .helmholtz.helmholtz_builder import build_helmholtz_package
3from ahuora_property_packages.humid_air import build_humid_air_package
4from ahuora_property_packages.milk import build_milk_package
5from ahuora_property_packages.types import PackageName, States
6from ahuora_property_packages.seawater.seawater_builder import build_seawater_package
7from .saltwater.saltwater_extended import SaltwaterExtendedParameterBlock
8from ahuora_property_packages.combustion.biomass_builder import (
9 build_biomass_and_flue_package,
10 build_biomass_combustion_reaction_package)
11from typing import List
13def build_package(package_name: PackageName, compound_list: List[str], valid_states: List[States]=["Liq", "Vap"], property_package=None): # type: ignore
14 """ Builds a property package
16 Args:
17 package_name (PackageName): Name of the property package to build.
18 compound_list (List[str]): List of compound names to include in the package.
19 valid_states (List[States], optional): List of valid states for the compounds.
21 Returns:
22 object: IDAES ParameterBlock object.
24 Raises:
25 ValueError: If the package name or states are invalid
26 """
28 # Type checking states
29 for state in valid_states:
30 if state not in ["Liq", "Vap"]: 30 ↛ 31line 30 didn't jump to line 31 because the condition on line 30 was never true
31 raise ValueError(f"Invalid state {state}. Valid states are: Liq, Vap")
33 # Type checking package
34 match package_name:
35 case "peng-robinson": 35 ↛ 36line 35 didn't jump to line 36 because the pattern on line 35 never matched
36 return build_peng_robinson( compound_list, valid_states)
37 case "coolprop": 37 ↛ 38line 37 didn't jump to line 38 because the pattern on line 37 never matched
38 return build_coolprop( compound_list, valid_states)
39 case "helmholtz": 39 ↛ 40line 39 didn't jump to line 40 because the pattern on line 39 never matched
40 return build_helmholtz_package(compound_list)
41 case "milk":
42 return build_milk_package(compound_list)
43 case "humid_air": 43 ↛ 44line 43 didn't jump to line 44 because the pattern on line 43 never matched
44 return build_humid_air_package(compound_list)
45 case "biomass_and_flue": 45 ↛ 46line 45 didn't jump to line 46 because the pattern on line 45 never matched
46 return build_biomass_and_flue_package(compound_list)
47 case "biomass_combustion_reaction": 47 ↛ 48line 47 didn't jump to line 48 because the pattern on line 47 never matched
48 return build_biomass_combustion_reaction_package(compound_list, pp=property_package)
49 case "seawater": 49 ↛ 51line 49 didn't jump to line 51 because the pattern on line 49 always matched
50 return build_seawater_package(compound_list)
51 case "saltwater":
52 return SaltwaterExtendedParameterBlock()
53 case "genericML":
54 raise NotImplementedError("Generic ML package is not implemented yet.")
55 case _:
56 raise ValueError(f"Invalid package name {package_name}. Expected a valid property package type, e.g helmholtz")