Skip to content

Commit

Permalink
Merge pull request #45 from portyanikhin/44-unable-to-impose-mixture-…
Browse files Browse the repository at this point in the history
…phase-during-creation

The `specify_phase` and `unspecify_phase` methods of the `Fluid` and `Mixture` classes now returns `self` (for methods chaining)
  • Loading branch information
portyanikhin authored Oct 2, 2024
2 parents ae105d4 + 6433d2c commit a715e81
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 73 deletions.
2 changes: 1 addition & 1 deletion PyPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
[![codecov](https://codecov.io/gh/portyanikhin/PyFluids/branch/main/graph/badge.svg?token=I1LL66AOJW)](https://codecov.io/gh/portyanikhin/PyFluids)
[![Code style: black](https://img.shields.io/badge/code%20style-black-black)](https://github.com/psf/black)

A simple, full-featured, lightweight [CoolProp](http://www.coolprop.org) wrapper for Python.
Simple, full-featured, lightweight [CoolProp](http://www.coolprop.org) wrapper for Python.

_**See [full documentation](https://github.com/portyanikhin/PyFluids).**_
58 changes: 29 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![codecov](https://codecov.io/gh/portyanikhin/PyFluids/branch/main/graph/badge.svg?token=I1LL66AOJW)](https://codecov.io/gh/portyanikhin/PyFluids)
[![Code style: black](https://img.shields.io/badge/code%20style-black-black)](https://github.com/psf/black)

A simple, full-featured, lightweight [CoolProp](http://www.coolprop.org) wrapper for Python.
Simple, full-featured, lightweight [CoolProp](http://www.coolprop.org) wrapper for Python.

## Navigation

Expand Down Expand Up @@ -182,20 +182,20 @@ For more information, see the docstrings.
* `specify_phase` - specify the phase state for all further calculations.
* `unspecify_phase` - unspecify the phase state and go back to calculating it based on the inputs.
* `clone` - performs deep (full) copy of the fluid instance.
* `isentropic_compression_to_pressure` - the process of isentropic compression to a given pressure.
* `compression_to_pressure` - the process of compression to a given pressure.
* `isenthalpic_expansion_to_pressure` - the process of isenthalpic expansion to a given pressure.
* `isentropic_expansion_to_pressure` - the process of isentropic expansion to a given pressure.
* `expansion_to_pressure` - the process of expansion to a given pressure.
* `cooling_to_temperature` - the process of cooling to a given temperature.
* `cooling_to_enthalpy` - the process of cooling to a given enthalpy.
* `heating_to_temperature` - the process of heating to a given temperature.
* `heating_to_enthalpy` - the process of heating to a given enthalpy.
* `bubble_point_at_pressure` - bubble point at a given pressure.
* `bubble_point_at_temperature` - bubble point at a given temperature.
* `dew_point_at_pressure` - dew point at a given pressure.
* `dew_point_at_temperature` - dew point at a given temperature.
* `two_phase_point_at_pressure` - two-phase point at a given pressure.
* `isentropic_compression_to_pressure` - the process of isentropic compression to given pressure.
* `compression_to_pressure` - the process of compression to given pressure.
* `isenthalpic_expansion_to_pressure` - the process of isenthalpic expansion to given pressure.
* `isentropic_expansion_to_pressure` - the process of isentropic expansion to given pressure.
* `expansion_to_pressure` - the process of expansion to given pressure.
* `cooling_to_temperature` - the process of cooling to given temperature.
* `cooling_to_enthalpy` - the process of cooling to given enthalpy.
* `heating_to_temperature` - the process of heating to given temperature.
* `heating_to_enthalpy` - the process of heating to given enthalpy.
* `bubble_point_at_pressure` - bubble point at given pressure.
* `bubble_point_at_temperature` - bubble point at given temperature.
* `dew_point_at_pressure` - dew point at given pressure.
* `dew_point_at_temperature` - dew point at given temperature.
* `two_phase_point_at_pressure` - two-phase point at given pressure.
* `mixing` - the mixing process.
* `as_json` - converts the fluid instance to a JSON string.
* `as_dict` - converts the fluid instance to a dict.
Expand All @@ -209,8 +209,8 @@ For more information, see the docstrings.
* `specify_phase` - specify the phase state for all further calculations.
* `unspecify_phase` - unspecify the phase state and go back to calculating it based on the inputs.
* `clone` - performs deep (full) copy of the mixture instance.
* `cooling_to_temperature` - the process of cooling to a given temperature.
* `heating_to_temperature` - the process of heating to a given temperature.
* `cooling_to_temperature` - the process of cooling to given temperature.
* `heating_to_temperature` - the process of heating to given temperature.
* `as_json` - converts the mixture instance to a JSON string.
* `as_dict` - converts the mixture instance to a dict.

Expand All @@ -221,18 +221,18 @@ For more information, see the docstrings.
* `update` - updates the state of the humid air.
* `reset` - resets all properties.
* `clone` - performs deep (full) copy of the humid air instance.
* `dry_cooling_to_temperature` - the process of cooling without dehumidification to a given temperature.
* `dry_cooling_to_enthalpy` - the process of cooling without dehumidification to a given enthalpy.
* `wet_cooling_to_temperature_and_relative_humidity` - the process of cooling with dehumidification to a given temperature and relative humidity ratio.
* `wet_cooling_to_temperature_and_absolute_humidity` - the process of cooling with dehumidification to a given temperature and absolute humidity ratio.
* `wet_cooling_to_enthalpy_and_relative_humidity` - the process of cooling with dehumidification to a given enthalpy and relative humidity ratio.
* `wet_cooling_to_enthalpy_and_absolute_humidity` - the process of cooling with dehumidification to a given enthalpy and absolute humidity ratio.
* `heating_to_temperature` - the process of heating to a given temperature.
* `heating_to_enthalpy` - the process of heating to a given enthalpy.
* `humidification_by_water_to_relative_humidity` - the process of humidification by water (isenthalpic) to a given relative humidity ratio.
* `humidification_by_water_to_absolute_humidity` - the process of humidification by water (isenthalpic) to a given absolute humidity ratio.
* `humidification_by_steam_to_relative_humidity` - the process of humidification by steam (isothermal) to a given relative humidity ratio.
* `humidification_by_steam_to_absolute_humidity` - the process of humidification by steam (isothermal) to a given absolute humidity ratio.
* `dry_cooling_to_temperature` - the process of cooling without dehumidification to given temperature.
* `dry_cooling_to_enthalpy` - the process of cooling without dehumidification to given enthalpy.
* `wet_cooling_to_temperature_and_relative_humidity` - the process of cooling with dehumidification to given temperature and relative humidity ratio.
* `wet_cooling_to_temperature_and_absolute_humidity` - the process of cooling with dehumidification to given temperature and absolute humidity ratio.
* `wet_cooling_to_enthalpy_and_relative_humidity` - the process of cooling with dehumidification to given enthalpy and relative humidity ratio.
* `wet_cooling_to_enthalpy_and_absolute_humidity` - the process of cooling with dehumidification to given enthalpy and absolute humidity ratio.
* `heating_to_temperature` - the process of heating to given temperature.
* `heating_to_enthalpy` - the process of heating to given enthalpy.
* `humidification_by_water_to_relative_humidity` - the process of humidification by water (isenthalpic) to given relative humidity ratio.
* `humidification_by_water_to_absolute_humidity` - the process of humidification by water (isenthalpic) to given absolute humidity ratio.
* `humidification_by_steam_to_relative_humidity` - the process of humidification by steam (isothermal) to given relative humidity ratio.
* `humidification_by_steam_to_absolute_humidity` - the process of humidification by steam (isothermal) to given absolute humidity ratio.
* `mixing` - the mixing process.
* `as_json` - converts the humid air instance to a JSON string.
* `as_dict` - converts the humid air instance to a dict.
Expand Down
14 changes: 7 additions & 7 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 27 additions & 23 deletions pyfluids/fluids/abstract_fluid.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,24 +365,28 @@ def reset(self):
self.__surface_tension = None
self.__temperature = None

def specify_phase(self, phase: Phases):
def specify_phase(self, phase: Phases) -> AbstractFluid:
"""
Specify the phase state for all further calculations.
:param phase: Phase state.
:return: Current fluid instance.
"""
self._backend.specify_phase(phase.value)
return self

def unspecify_phase(self):
def unspecify_phase(self) -> AbstractFluid:
"""
Unspecify the phase state and
go back to calculating it based on the inputs.
Unspecify the phase state and go back to calculating it based on the inputs.
:return: Current fluid instance.
"""
self._backend.unspecify_phase()
return self

def isentropic_compression_to_pressure(self, pressure: float) -> AbstractFluid:
"""
The process of isentropic compression to a given pressure.
The process of isentropic compression to given pressure.
:param pressure: Absolute pressure [Pa].
:return: The state of the fluid at the end of the process.
Expand All @@ -398,7 +402,7 @@ def compression_to_pressure(
self, pressure: float, isentropic_efficiency: float
) -> AbstractFluid:
"""
The process of compression to a given pressure.
The process of compression to given pressure.
:param pressure: Absolute pressure [Pa].
:param isentropic_efficiency: Compressor isentropic efficiency
Expand All @@ -425,7 +429,7 @@ def compression_to_pressure(

def isenthalpic_expansion_to_pressure(self, pressure: float) -> AbstractFluid:
"""
The process of isenthalpic expansion to a given pressure.
The process of isenthalpic expansion to given pressure.
:param pressure: Absolute pressure [Pa].
:return: The state of the fluid at the end of the process.
Expand All @@ -439,7 +443,7 @@ def isenthalpic_expansion_to_pressure(self, pressure: float) -> AbstractFluid:

def isentropic_expansion_to_pressure(self, pressure: float) -> AbstractFluid:
"""
The process of isentropic expansion to a given pressure.
The process of isentropic expansion to given pressure.
:param pressure: Absolute pressure [Pa].
:return: The state of the fluid at the end of the process.
Expand All @@ -455,7 +459,7 @@ def expansion_to_pressure(
self, pressure: float, isentropic_efficiency: float
) -> AbstractFluid:
"""
The process of expansion to a given pressure.
The process of expansion to given pressure.
:param pressure: Absolute pressure [Pa].
:param isentropic_efficiency: Expander isentropic efficiency
Expand Down Expand Up @@ -484,7 +488,7 @@ def cooling_to_temperature(
self, temperature: float, pressure_drop: float = 0
) -> AbstractFluid:
"""
The process of cooling to a given temperature.
The process of cooling to given temperature.
:param temperature: Temperature
[by default, °C; you can change this using the configuration file].
Expand All @@ -502,7 +506,7 @@ def cooling_to_enthalpy(
self, enthalpy: float, pressure_drop: float = 0
) -> AbstractFluid:
"""
The process of cooling to a given enthalpy.
The process of cooling to given enthalpy.
:param enthalpy: Enthalpy [J/kg].
:param pressure_drop: Pressure drop in the heat exchanger (optional) [Pa].
Expand All @@ -519,7 +523,7 @@ def heating_to_temperature(
self, temperature: float, pressure_drop: float = 0
) -> AbstractFluid:
"""
The process of heating to a given temperature.
The process of heating to given temperature.
:param temperature: Temperature
[by default, °C; you can change this using the configuration file].
Expand All @@ -537,7 +541,7 @@ def heating_to_enthalpy(
self, enthalpy: float, pressure_drop: float = 0
) -> AbstractFluid:
"""
The process of heating to a given enthalpy.
The process of heating to given enthalpy.
:param enthalpy: Enthalpy [J/kg].
:param pressure_drop: Pressure drop in the heat exchanger (optional) [Pa].
Expand All @@ -552,29 +556,29 @@ def heating_to_enthalpy(

def bubble_point_at_pressure(self, pressure: float) -> AbstractFluid:
"""
Bubble point at a given pressure.
Bubble point at given pressure.
:param pressure: Absolute pressure [Pa].
:return: Bubble point at a given pressure.
:return: Bubble point at given pressure.
"""
return self.with_state(Input.pressure(pressure), Input.quality(0))

def bubble_point_at_temperature(self, temperature: float) -> AbstractFluid:
"""
Bubble point at a given temperature.
Bubble point at given temperature.
:param temperature: Temperature
[by default, °C; you can change this using the configuration file].
:return: Bubble point at a given temperature.
:return: Bubble point at given temperature.
"""
return self.with_state(Input.temperature(temperature), Input.quality(0))

def dew_point_at_pressure(self, pressure: float) -> AbstractFluid:
"""
Dew point at a given pressure.
Dew point at given pressure.
:param pressure: Absolute pressure [Pa].
:return: Dew point at a given pressure.
:return: Dew point at given pressure.
"""
return self.with_state(
Input.pressure(pressure),
Expand All @@ -585,11 +589,11 @@ def dew_point_at_pressure(self, pressure: float) -> AbstractFluid:

def dew_point_at_temperature(self, temperature: float) -> AbstractFluid:
"""
Dew point at a given temperature.
Dew point at given temperature.
:param temperature: Temperature
[by default, °C; you can change this using the configuration file].
:return: Dew point at a given temperature.
:return: Dew point at given temperature.
"""
return self.with_state(
Input.temperature(temperature),
Expand All @@ -602,12 +606,12 @@ def two_phase_point_at_pressure(
self, pressure: float, quality: float
) -> AbstractFluid:
"""
Two phase point at a given pressure.
Two phase point at given pressure.
:param pressure: Absolute pressure [Pa].
:param quality: Vapor quality
[by default, %; you can change this using the configuration file].
:return: Two phase point at a given pressure.
:return: Two phase point at given pressure.
"""
return self.with_state(Input.pressure(pressure), Input.quality(quality))

Expand Down
Loading

0 comments on commit a715e81

Please sign in to comment.