From c0ac8a5447390eb0e2caafc1913a8a756d1e9e32 Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Fri, 3 Nov 2023 09:52:38 +0100 Subject: [PATCH 1/3] made list of liquids and gases global in fluids.py --- pandapipes/properties/fluids.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pandapipes/properties/fluids.py b/pandapipes/properties/fluids.py index 9721fa3cd..fd9a275aa 100644 --- a/pandapipes/properties/fluids.py +++ b/pandapipes/properties/fluids.py @@ -18,6 +18,9 @@ logger = logging.getLogger(__name__) +_LIQUIDS = ["water"] +_GASES = ["air", "lgas", "hgas", "hydrogen", "methane", "biomethane_pure", "biomethane_treated"] + class Fluid(JSONSerializableClass): """ @@ -668,17 +671,14 @@ def linear_property(prop): return FluidPropertyLinear.from_path( os.path.join(pp_dir, "properties", fluid_name, prop + ".txt")) - liquids = ["water"] - gases = ["air", "lgas", "hgas", "hydrogen", "methane", "biomethane_pure", "biomethane_treated"] - if fluid_name == "natural_gas": logger.error("'natural_gas' is ambigious. Please choose 'hgas' or 'lgas' " "(high- or low calorific natural gas)") - if fluid_name not in liquids and fluid_name not in gases: + if fluid_name not in _LIQUIDS and fluid_name not in _GASES: raise AttributeError("Fluid '%s' not found in the fluid library. It might not be " "implemented yet." % fluid_name) - phase = "liquid" if fluid_name in liquids else "gas" + phase = "liquid" if fluid_name in _LIQUIDS else "gas" density = interextra_property("density") viscosity = interextra_property("viscosity") From bab5c14f935c100c3009a16dcf46299bb6c31e11 Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Fri, 3 Nov 2023 10:42:02 +0100 Subject: [PATCH 2/3] corrections in fluid library to make call_lib pass again - adapted wrong files for new biomethane properties - added lhv and hhv with exception in case file was not found, as these properties are not absolutely necessary --- .../biomethane_pure/lower_heating_value.txt | 1 - .../biomethane_treated/compressibility.txt | 2 +- .../biomethane_treated/heat_capacity.txt | 2 +- .../lower_heating_value.txt | 1 - pandapipes/properties/fluids.py | 34 +++++++++---------- 5 files changed, 18 insertions(+), 22 deletions(-) delete mode 100644 pandapipes/properties/biomethane_pure/lower_heating_value.txt delete mode 100644 pandapipes/properties/biomethane_treated/lower_heating_value.txt diff --git a/pandapipes/properties/biomethane_pure/lower_heating_value.txt b/pandapipes/properties/biomethane_pure/lower_heating_value.txt deleted file mode 100644 index e7b41c8d4..000000000 --- a/pandapipes/properties/biomethane_pure/lower_heating_value.txt +++ /dev/null @@ -1 +0,0 @@ -# lower heating value in kWh/kg (at normal conditions) diff --git a/pandapipes/properties/biomethane_treated/compressibility.txt b/pandapipes/properties/biomethane_treated/compressibility.txt index 7ebaa69ce..dbb50a0a5 100644 --- a/pandapipes/properties/biomethane_treated/compressibility.txt +++ b/pandapipes/properties/biomethane_treated/compressibility.txt @@ -1,3 +1,3 @@ # source: linear approximation based on CoolProp (http://www.coolprop.org/) # slope in 1/bar, offset for linear property --0.0024789428559189412, 0.9962776221466679 \ No newline at end of file +-0.0024789428559189412 0.9962776221466679 \ No newline at end of file diff --git a/pandapipes/properties/biomethane_treated/heat_capacity.txt b/pandapipes/properties/biomethane_treated/heat_capacity.txt index f9f78e48d..ec06044fc 100644 --- a/pandapipes/properties/biomethane_treated/heat_capacity.txt +++ b/pandapipes/properties/biomethane_treated/heat_capacity.txt @@ -1,6 +1,6 @@ #source CoolProp (http://www.coolprop.org/) # temperature in Kelvin, isobaric heat capacity in J/(kg K) -263.151976.8823234072695 +263.15 1976.8823234072695 265.15 1980.6134982832095 267.15 1984.416050463013 269.15 1988.2894370033634 diff --git a/pandapipes/properties/biomethane_treated/lower_heating_value.txt b/pandapipes/properties/biomethane_treated/lower_heating_value.txt deleted file mode 100644 index e7b41c8d4..000000000 --- a/pandapipes/properties/biomethane_treated/lower_heating_value.txt +++ /dev/null @@ -1 +0,0 @@ -# lower heating value in kWh/kg (at normal conditions) diff --git a/pandapipes/properties/fluids.py b/pandapipes/properties/fluids.py index fd9a275aa..5d35b0f36 100644 --- a/pandapipes/properties/fluids.py +++ b/pandapipes/properties/fluids.py @@ -680,24 +680,22 @@ def linear_property(prop): phase = "liquid" if fluid_name in _LIQUIDS else "gas" - density = interextra_property("density") - viscosity = interextra_property("viscosity") - heat_capacity = interextra_property("heat_capacity") - molar_mass = constant_property("molar_mass") - der_compr = constant_property("der_compressibility") - compr = linear_property("compressibility") - - if (phase == 'gas') & (fluid_name != 'air'): - lhv = constant_property("lower_heating_value") - hhv = constant_property("higher_heating_value") - - return Fluid(fluid_name, phase, density=density, viscosity=viscosity, - heat_capacity=heat_capacity, molar_mass=molar_mass, - compressibility=compr, der_compressibility=der_compr, lhv=lhv, hhv=hhv) - else: - return Fluid(fluid_name, phase, density=density, viscosity=viscosity, - heat_capacity=heat_capacity, molar_mass=molar_mass, compressibility=compr, - der_compressibility=der_compr) + properties = dict() + properties["density"] = interextra_property("density") + properties["viscosity"] = interextra_property("viscosity") + properties["heat_capacity"] = interextra_property("heat_capacity") + properties["molar_mass"] = constant_property("molar_mass") + properties["der_compressibility"] = constant_property("der_compressibility") + properties["compressibility"] = linear_property("compressibility") + + if phase == 'gas': + for entry, name in [("lhv", "lower_heating_value"), ("hhv", "higher_heating_value")]: + try: + properties[entry] = constant_property(name) + except FileNotFoundError: + pass + + return Fluid(fluid_name, phase, **properties) def get_fluid(net): From b1ee8dbdc4753c7becffdc3febcaa81e5dc2146c Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Mon, 20 Nov 2023 12:26:21 +0100 Subject: [PATCH 3/3] added warning when not finding LHV / HHV in fluid lib --- pandapipes/properties/fluids.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandapipes/properties/fluids.py b/pandapipes/properties/fluids.py index 5d35b0f36..7917b2e1d 100644 --- a/pandapipes/properties/fluids.py +++ b/pandapipes/properties/fluids.py @@ -693,7 +693,10 @@ def linear_property(prop): try: properties[entry] = constant_property(name) except FileNotFoundError: - pass + logger.warning( + f"Unable to find {' '.join([n.capitalize() for n in name.split('_')])} for " + f"{fluid_name}" + ) return Fluid(fluid_name, phase, **properties)