Metadata-Version: 2.4
Name: absorptionlib
Version: 1.1.0
Summary: Thermophysical properties of salt solutions (NaOH, LiBr, LiCl, CaCl2) for absorption systems
Author-email: Dorian Höffner <dorian.hoeffner@tu-berlin.de>
License: MIT License
        
        Copyright (c) 2024 Dorian Höffner
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering :: Physics
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: numpy
Requires-Dist: scipy
Requires-Dist: matplotlib
Requires-Dist: pyXSteam
Dynamic: license-file

# absorptionlib

This package contains thermophysical property functions for the following aqueous solutions used in absorption systems:
- NaOH-water
- LiBr-water
- LiCl-water
- CaCl2-water

If you use this package, please cite:

Höffner et al. 2025 — Potentials of absorption thermal energy storage systems in seasonal application

DOI: https://doi.org/10.18462/iir.tptpr2025.1130

### Installation and Usage

```
pip install absorptionlib
```

```python
# Import
from absorptionlib import NaOH, LiBr, LiCl, CaCl2

# Example Usage
p = 100000  # [Pa]
x = 0.4     # [kg NaOH / kg solution]
t_sat = NaOH.saturation_temperature(x, p)
print(round(t_sat, 2))
```
**Output**
```
129.75
```

### Units

All functions use the same units throughout the package:

| Symbol | Meaning                                | Unit  |
|--------|----------------------------------------|-------|
| x      | Salt mass fraction                     | kg salt / kg solution |
| T      | Temperature                            | °C    |
| p      | Pressure                               | Pa    |

### Warnings and errors

Each function checks its inputs against the validity range of the underlying
correlation:

- Inputs outside the *validated* range emit an `OutOfRangeWarning` (the value
  is still computed and returned).
- State points below the crystallization line emit a `CrystallizationWarning`.
- Physically invalid inputs raise a `ValueError`.

Every property function accepts `prevent_errors=True`, which suppresses all
warnings and returns `float('nan')` instead of raising a `ValueError` — useful
inside optimizers and root finders:

```python
NaOH.enthalpy(0.4, 80, prevent_errors=True)
```

Warnings can also be controlled globally:

```python
import absorptionlib
absorptionlib.disable_warnings()   # silence all package warnings
absorptionlib.enable_warnings()    # restore them

# or with the standard library, e.g. turn warnings into exceptions:
import warnings
warnings.filterwarnings("error", category=absorptionlib.CrystallizationWarning)
```

# Quick documentation

Each submodule has its own "in-line" documentation, which can be called with the
`documentation()` function. Each property function has a docstring, which can be
printed with the `explain()` function.

```python
# How to get quick documentation on the modules
NaOH.documentation()  # or LiBr, LiCl, CaCl2

# How to get quick documentation for functions
NaOH.explain("enthalpy")    # prints docstring of NaOH.enthalpy
LiCl.explain("pTDiagram")   # prints docstring of LiCl.pTDiagram
```

### Available Property Functions

| Function Name             | Description                                                                    | NaOH | LiBr | LiCl | CaCl2 |
|---------------------------|--------------------------------------------------------------------------------|:----:|:----:|:----:|:-----:|
| saturation_temperature    | Boiling point temperature of the solution [°C]                                | x    | x    | x    | x     |
| saturation_pressure       | Equilibrium (vapor) pressure of the solution [Pa]                             | x    | x    | x    | x     |
| saturation_concentration  | Saturation concentration at given pressure and temperature [kg/kg]            | x    | x    | x    | x     |
| enthalpy                  | Specific enthalpy of the solution [kJ/kg]                                     | x    | x    | x    | x     |
| differential_enthalpy_AD  | Differential enthalpy of dilution [kJ/kg H2O]                                 |      |      | x    | x     |
| density                   | Density of the solution [kg/m³]                                               | x    | x    | x    | x     |
| specific_heat_capacity    | Specific heat capacity of the solution [kJ/(kg K)]                            | x    |      | x    | x     |
| dynamic_viscosity         | Dynamic viscosity of the solution [Pa s]                                      | x    |      | x    | x     |
| thermal_conductivity      | Thermal conductivity of the solution [W/(m K)]                                | x    |      |      |       |
| diffusion_coefficient     | Self diffusion coefficient of the solution [m²/s]                             |      |      | x    | x     |
| solubility_temperature    | Crystallization temperature at given concentration [°C]                       | x    | x    | x    | x     |
| hxDiagram                 | Plots the enthalpy-concentration diagram                                      | x    | x    | x    | x     |
| pTDiagram                 | Plots the pressure-temperature diagram                                        | x    | x    | x    | x     |
| crystallization_curve     | Plots (or returns) the crystallization curve                                  | x    | x    | x    | x     |

# Diagrams

You can construct diagrams (pT-diagram, hx-diagram, crystallization curve) with the package. For example:

```python
NaOH.pTDiagram()
```

![pT-Diagram](https://github.com/dorianhoeffner/absorptionlib/blob/main/graphics/pTDiagram_example.png)

Note: The plots can be styled with the usual matplotlib syntax. If the plot should be editable, use `NaOH.pTDiagram(editablePlot=True)`. To reproduce the same-looking plot, set up matplotlib using:

```python
import matplotlib.pyplot as plt
plt.rcParams['font.family'] = 'Georgia'
plt.rcParams['mathtext.fontset'] = 'custom'
plt.rcParams['mathtext.rm'] = 'Georgia'
plt.rcParams['mathtext.it'] = 'Georgia:italic'
```
