From c093f99408ac1340540e441a9bd1bfe0c7f6c7c4 Mon Sep 17 00:00:00 2001 From: niklasmarxer Date: Mon, 26 Jan 2026 20:08:04 -0800 Subject: [PATCH 1/3] Refactor: Strict SI units, remove aliases, standardize CP/RHO --- steer_materials/Fuels.py | 30 ++++++++ steer_materials/Gases.py | 141 ++++++++++++++++++++++++++++++++++++ steer_materials/Liquids.py | 87 ++++++++++++++++++++++ steer_materials/__init__.py | 3 + 4 files changed, 261 insertions(+) create mode 100644 steer_materials/Fuels.py create mode 100644 steer_materials/Gases.py create mode 100644 steer_materials/Liquids.py diff --git a/steer_materials/Fuels.py b/steer_materials/Fuels.py new file mode 100644 index 0000000..9ccaa55 --- /dev/null +++ b/steer_materials/Fuels.py @@ -0,0 +1,30 @@ +""" +Fuel material classes. + +Classes: + NaturalGas: Natural gas properties for combustion calculations + +Volumeless, weightless property classes - just characteristics. +All properties in SI units. +""" +from steer_core.Mixins.TypeChecker import ValidationMixin +from steer_core.Mixins.Serializer import SerializerMixin +from steer_core.Mixins.Dunder import DunderMixin + + +class NaturalGas( + ValidationMixin, + DunderMixin, + SerializerMixin +): + """Natural gas properties for boiler calculations. + + Values are for typical pipeline-quality natural gas (mainly methane). + All values in SI units (J/kg). + """ + + # Lower Heating Value (net calorific value) [J/kg] + LHV = 47.0e6 + + # Higher Heating Value (gross calorific value) [J/kg] + HHV = 52.2e6 diff --git a/steer_materials/Gases.py b/steer_materials/Gases.py new file mode 100644 index 0000000..3b4cc7e --- /dev/null +++ b/steer_materials/Gases.py @@ -0,0 +1,141 @@ +""" +Gas material classes with thermodynamic properties. + +Classes: + CO2: Carbon dioxide + N2: Nitrogen + FlueGas: Combustion flue gas / air properties + +All properties in SI units. +""" +from steer_core.Constants.Units import ( + K_TO_C, + C_TO_K, + BAR_TO_PA, + PA_TO_BAR, +) +from steer_core.Mixins.TypeChecker import ValidationMixin +from steer_core.Mixins.Serializer import SerializerMixin +from steer_core.Mixins.Dunder import DunderMixin +from steer_core.Mixins.Thermodynamics import ThermodynamicsMixin + + +class CO2( + ThermodynamicsMixin, + ValidationMixin, + DunderMixin, + SerializerMixin +): + """Carbon dioxide thermodynamic properties. + + Volumeless, weightless property class - just characteristics. + All values in SI units. + """ + + # Molecular weight [kg/mol] + MW = 0.04401 + + # Heat capacity [J/(kg·K)] (Gas phase, STP) + CP = 844.0 + + # Density [kg/m³] (Gas phase, STP) + RHO = 1.84 + + # Antoine equation coefficients for sublimation curve + # log10(P) = A - B / (T + C) + # Valid range: approximately -120°C to -60°C + ANTOINE_A = 9.81 + ANTOINE_B = 1347.79 + ANTOINE_C = 273.0 + + # Phase change enthalpies [J/kg] + H_SUBLIMATION = 571000.0 # solid → gas + H_FUSION = 196000.0 # solid → liquid + + # Heat capacities [J/(kg·K)] + CP_SOLID = 950.0 + CP_LIQUID = 2500.0 + + # Triple point + T_TRIPLE = 216.55 # K (-56.6°C) + P_TRIPLE = 5.18e5 # Pa + + # Typical pipeline conditions + P_PIPELINE = 150e5 # Pa (150 bar) + RHO_LIQUID = 1100.0 # kg/m³ + + @classmethod + def sublimation_pressure(cls, T: float) -> float: + """Calculate CO2 sublimation pressure at given temperature. + + Args: + T: Temperature [K] + + Returns: + Pressure [Pa] + """ + # Antoine equation gives mmHg, convert to Pa + T_celsius = T + K_TO_C # Convert K to C + P_mmhg = cls.antoine_pressure(T_celsius, cls.ANTOINE_A, cls.ANTOINE_B, cls.ANTOINE_C) + return P_mmhg * 133.322 # mmHg to Pa + + @classmethod + def sublimation_temperature(cls, P: float) -> float: + """Calculate CO2 sublimation temperature at given pressure. + + Args: + P: Pressure [Pa] + + Returns: + Temperature [K] + """ + P_mmhg = P / 133.322 # Pa to mmHg + T_celsius = cls.antoine_temperature(P_mmhg, cls.ANTOINE_A, cls.ANTOINE_B, cls.ANTOINE_C) + return T_celsius + C_TO_K # Convert C to K + + +class N2( + ThermodynamicsMixin, + ValidationMixin, + DunderMixin, + SerializerMixin +): + """Nitrogen properties. + + Volumeless, weightless property class - just characteristics. + All values in SI units. + """ + + # Molecular weight [kg/mol] + MW = 0.02801 + + # Heat capacity [J/(kg·K)] (Gas phase, STP) + CP = 1040.0 + + # Density [kg/m³] (Gas phase, STP) + RHO = 1.15 + + +class FlueGas( + ThermodynamicsMixin, + ValidationMixin, + DunderMixin, + SerializerMixin +): + """Flue gas and air properties. + + Typical values for combustion flue gas. + Exact values depend on fuel composition. + + Volumeless, weightless property class - just characteristics. + All values in SI units. + """ + + # Molecular weight [kg/mol] + MW = 0.029 # Approximate for air-like mixture + + # Heat capacity [J/(kg·K)] + CP = 1050.0 + + # Density at ambient conditions (~25°C, 1 atm) [kg/m³] + RHO = 1.2 diff --git a/steer_materials/Liquids.py b/steer_materials/Liquids.py new file mode 100644 index 0000000..806bd14 --- /dev/null +++ b/steer_materials/Liquids.py @@ -0,0 +1,87 @@ +""" +Liquid material classes with thermodynamic properties. + +Classes: + Water: Pure water properties + Steam: Steam properties + +Volumeless, weightless property classes - just characteristics. +All properties in SI units (Pa, K, J/mol, etc). +""" +from steer_core.Constants.Units import ( + K_TO_C, + C_TO_K, + BAR_TO_PA, + PA_TO_BAR, +) +from steer_core.Mixins.TypeChecker import ValidationMixin +from steer_core.Mixins.Serializer import SerializerMixin +from steer_core.Mixins.Dunder import DunderMixin +from steer_core.Mixins.Thermodynamics import ThermodynamicsMixin + + +class Water( + ThermodynamicsMixin, + ValidationMixin, + DunderMixin, + SerializerMixin +): + """Water thermodynamic properties. + + All values in SI units. + """ + + # Molecular weight [kg/mol] + MW = 0.018015 + + # Latent heat of vaporization [J/kg] at 100°C + LAMBDA_VAPORIZATION = 2260000.0 + + # Heat capacity [J/(kg·K)] + CP = 4180.0 + + # Density [kg/m³] + RHO = 1000.0 + + # NIST Antoine parameters for water vapor pressure + # log10(P_bar) = A - B / (T_K + C) + ANTOINE_A = 5.19621 + ANTOINE_B = 1730.63 + ANTOINE_C = -39.724 + + @classmethod + def vapor_pressure(cls, T: float) -> float: + """Calculate water vapor pressure at given temperature. + + Args: + T: Temperature [K] + + Returns: + Vapor pressure [Pa] + """ + # T is in Kelvin for this NIST equation + P_bar = cls.antoine_pressure(T, cls.ANTOINE_A, cls.ANTOINE_B, cls.ANTOINE_C) + return P_bar * BAR_TO_PA # bar to Pa + + +# Alias for Water class +H2O = Water + + +class Steam( + ThermodynamicsMixin, + ValidationMixin, + DunderMixin, + SerializerMixin +): + """Steam thermodynamic properties. + + Reference: Steam tables (IAPWS-IF97) + All values in SI units (J/kg). + """ + + # Latent heat of vaporization [J/kg] + # At different pressures for reboiler calculations + LAMBDA_LP = 2200000.0 # ~2-3 bar (LP steam, ~120-135°C) + LAMBDA_MP = 2015000.0 # ~10 bar (MP steam, ~180°C) + LAMBDA_6BAR = 2086000.0 # 6 bar saturated (~159°C) diff --git a/steer_materials/__init__.py b/steer_materials/__init__.py index 0e3a154..d38cc6d 100644 --- a/steer_materials/__init__.py +++ b/steer_materials/__init__.py @@ -1,2 +1,5 @@ __version__ = "0.1.17" +from .Gases import CO2, N2, FlueGas +from .Liquids import Water, Steam +from .Fuels import NaturalGas From 9c1f3435f1bb6ceb3192a46dc7e2eb3ae994be77 Mon Sep 17 00:00:00 2001 From: niklasmarxer Date: Wed, 28 Jan 2026 10:54:42 -0800 Subject: [PATCH 2/3] Reverting init changes --- steer_materials/__init__.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/steer_materials/__init__.py b/steer_materials/__init__.py index d38cc6d..0e3a154 100644 --- a/steer_materials/__init__.py +++ b/steer_materials/__init__.py @@ -1,5 +1,2 @@ __version__ = "0.1.17" -from .Gases import CO2, N2, FlueGas -from .Liquids import Water, Steam -from .Fuels import NaturalGas From 749dfda5e16d2c2ac6ad381318b1220fe740efff Mon Sep 17 00:00:00 2001 From: Tom-Eliot Jullien Date: Wed, 29 Apr 2026 19:33:22 -0700 Subject: [PATCH 3/3] Removed temporarily the files that were problematic Co-authored-by: Copilot --- .gitignore | 2 + .vscode/settings.json | 14 ---- steer_materials/Fuels.py | 30 -------- steer_materials/Gases.py | 141 ------------------------------------- steer_materials/Liquids.py | 87 ----------------------- 5 files changed, 2 insertions(+), 272 deletions(-) delete mode 100644 .vscode/settings.json delete mode 100644 steer_materials/Fuels.py delete mode 100644 steer_materials/Gases.py delete mode 100644 steer_materials/Liquids.py diff --git a/.gitignore b/.gitignore index a6045cf..4acf67a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,9 @@ __pycache__/ +.vscode/ build/ scripts/ *.egg-info/ *.DS_Store dist/ Archive/ +.vscode/ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 5753cba..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "python.testing.unittestArgs": [ - "-v", - "-s", - "./test", - "-p", - "test*.py" - ], - "python.testing.pytestEnabled": false, - "python.testing.unittestEnabled": true, - "python.analysis.extraPaths": [ - "/Users/nsiemons/Drive/Code_projects/STEER/steer-core" - ] -} \ No newline at end of file diff --git a/steer_materials/Fuels.py b/steer_materials/Fuels.py deleted file mode 100644 index 9ccaa55..0000000 --- a/steer_materials/Fuels.py +++ /dev/null @@ -1,30 +0,0 @@ -""" -Fuel material classes. - -Classes: - NaturalGas: Natural gas properties for combustion calculations - -Volumeless, weightless property classes - just characteristics. -All properties in SI units. -""" -from steer_core.Mixins.TypeChecker import ValidationMixin -from steer_core.Mixins.Serializer import SerializerMixin -from steer_core.Mixins.Dunder import DunderMixin - - -class NaturalGas( - ValidationMixin, - DunderMixin, - SerializerMixin -): - """Natural gas properties for boiler calculations. - - Values are for typical pipeline-quality natural gas (mainly methane). - All values in SI units (J/kg). - """ - - # Lower Heating Value (net calorific value) [J/kg] - LHV = 47.0e6 - - # Higher Heating Value (gross calorific value) [J/kg] - HHV = 52.2e6 diff --git a/steer_materials/Gases.py b/steer_materials/Gases.py deleted file mode 100644 index 3b4cc7e..0000000 --- a/steer_materials/Gases.py +++ /dev/null @@ -1,141 +0,0 @@ -""" -Gas material classes with thermodynamic properties. - -Classes: - CO2: Carbon dioxide - N2: Nitrogen - FlueGas: Combustion flue gas / air properties - -All properties in SI units. -""" -from steer_core.Constants.Units import ( - K_TO_C, - C_TO_K, - BAR_TO_PA, - PA_TO_BAR, -) -from steer_core.Mixins.TypeChecker import ValidationMixin -from steer_core.Mixins.Serializer import SerializerMixin -from steer_core.Mixins.Dunder import DunderMixin -from steer_core.Mixins.Thermodynamics import ThermodynamicsMixin - - -class CO2( - ThermodynamicsMixin, - ValidationMixin, - DunderMixin, - SerializerMixin -): - """Carbon dioxide thermodynamic properties. - - Volumeless, weightless property class - just characteristics. - All values in SI units. - """ - - # Molecular weight [kg/mol] - MW = 0.04401 - - # Heat capacity [J/(kg·K)] (Gas phase, STP) - CP = 844.0 - - # Density [kg/m³] (Gas phase, STP) - RHO = 1.84 - - # Antoine equation coefficients for sublimation curve - # log10(P) = A - B / (T + C) - # Valid range: approximately -120°C to -60°C - ANTOINE_A = 9.81 - ANTOINE_B = 1347.79 - ANTOINE_C = 273.0 - - # Phase change enthalpies [J/kg] - H_SUBLIMATION = 571000.0 # solid → gas - H_FUSION = 196000.0 # solid → liquid - - # Heat capacities [J/(kg·K)] - CP_SOLID = 950.0 - CP_LIQUID = 2500.0 - - # Triple point - T_TRIPLE = 216.55 # K (-56.6°C) - P_TRIPLE = 5.18e5 # Pa - - # Typical pipeline conditions - P_PIPELINE = 150e5 # Pa (150 bar) - RHO_LIQUID = 1100.0 # kg/m³ - - @classmethod - def sublimation_pressure(cls, T: float) -> float: - """Calculate CO2 sublimation pressure at given temperature. - - Args: - T: Temperature [K] - - Returns: - Pressure [Pa] - """ - # Antoine equation gives mmHg, convert to Pa - T_celsius = T + K_TO_C # Convert K to C - P_mmhg = cls.antoine_pressure(T_celsius, cls.ANTOINE_A, cls.ANTOINE_B, cls.ANTOINE_C) - return P_mmhg * 133.322 # mmHg to Pa - - @classmethod - def sublimation_temperature(cls, P: float) -> float: - """Calculate CO2 sublimation temperature at given pressure. - - Args: - P: Pressure [Pa] - - Returns: - Temperature [K] - """ - P_mmhg = P / 133.322 # Pa to mmHg - T_celsius = cls.antoine_temperature(P_mmhg, cls.ANTOINE_A, cls.ANTOINE_B, cls.ANTOINE_C) - return T_celsius + C_TO_K # Convert C to K - - -class N2( - ThermodynamicsMixin, - ValidationMixin, - DunderMixin, - SerializerMixin -): - """Nitrogen properties. - - Volumeless, weightless property class - just characteristics. - All values in SI units. - """ - - # Molecular weight [kg/mol] - MW = 0.02801 - - # Heat capacity [J/(kg·K)] (Gas phase, STP) - CP = 1040.0 - - # Density [kg/m³] (Gas phase, STP) - RHO = 1.15 - - -class FlueGas( - ThermodynamicsMixin, - ValidationMixin, - DunderMixin, - SerializerMixin -): - """Flue gas and air properties. - - Typical values for combustion flue gas. - Exact values depend on fuel composition. - - Volumeless, weightless property class - just characteristics. - All values in SI units. - """ - - # Molecular weight [kg/mol] - MW = 0.029 # Approximate for air-like mixture - - # Heat capacity [J/(kg·K)] - CP = 1050.0 - - # Density at ambient conditions (~25°C, 1 atm) [kg/m³] - RHO = 1.2 diff --git a/steer_materials/Liquids.py b/steer_materials/Liquids.py deleted file mode 100644 index 806bd14..0000000 --- a/steer_materials/Liquids.py +++ /dev/null @@ -1,87 +0,0 @@ -""" -Liquid material classes with thermodynamic properties. - -Classes: - Water: Pure water properties - Steam: Steam properties - -Volumeless, weightless property classes - just characteristics. -All properties in SI units (Pa, K, J/mol, etc). -""" -from steer_core.Constants.Units import ( - K_TO_C, - C_TO_K, - BAR_TO_PA, - PA_TO_BAR, -) -from steer_core.Mixins.TypeChecker import ValidationMixin -from steer_core.Mixins.Serializer import SerializerMixin -from steer_core.Mixins.Dunder import DunderMixin -from steer_core.Mixins.Thermodynamics import ThermodynamicsMixin - - -class Water( - ThermodynamicsMixin, - ValidationMixin, - DunderMixin, - SerializerMixin -): - """Water thermodynamic properties. - - All values in SI units. - """ - - # Molecular weight [kg/mol] - MW = 0.018015 - - # Latent heat of vaporization [J/kg] at 100°C - LAMBDA_VAPORIZATION = 2260000.0 - - # Heat capacity [J/(kg·K)] - CP = 4180.0 - - # Density [kg/m³] - RHO = 1000.0 - - # NIST Antoine parameters for water vapor pressure - # log10(P_bar) = A - B / (T_K + C) - ANTOINE_A = 5.19621 - ANTOINE_B = 1730.63 - ANTOINE_C = -39.724 - - @classmethod - def vapor_pressure(cls, T: float) -> float: - """Calculate water vapor pressure at given temperature. - - Args: - T: Temperature [K] - - Returns: - Vapor pressure [Pa] - """ - # T is in Kelvin for this NIST equation - P_bar = cls.antoine_pressure(T, cls.ANTOINE_A, cls.ANTOINE_B, cls.ANTOINE_C) - return P_bar * BAR_TO_PA # bar to Pa - - -# Alias for Water class -H2O = Water - - -class Steam( - ThermodynamicsMixin, - ValidationMixin, - DunderMixin, - SerializerMixin -): - """Steam thermodynamic properties. - - Reference: Steam tables (IAPWS-IF97) - All values in SI units (J/kg). - """ - - # Latent heat of vaporization [J/kg] - # At different pressures for reboiler calculations - LAMBDA_LP = 2200000.0 # ~2-3 bar (LP steam, ~120-135°C) - LAMBDA_MP = 2015000.0 # ~10 bar (MP steam, ~180°C) - LAMBDA_6BAR = 2086000.0 # 6 bar saturated (~159°C)