Skip to main content

A lightweight pinch analysis package

Project description

pina

Tests codecov Code style: black Imports: isort

Installation

To install this package, run

python -m pip install git+https://github.com/FitzOReilly/pina.git#egg=pina

Basic example

This is a basic example using the four stream problem from Pinch Analysis and Process Integration: A User Guide On Process Integration for the Efficient Use of Energy, Second edition, Ian C. Kemp, p. 4. Its data looks as follows:

Stream number and type Heat flow [kW] Supply Temperature [°C] Target Temperature [°C]
1. Cold -230 20 135
2. Hot 330 170 60
3. Cold -240 80 140
4. Hot 180 150 30

ΔTmin = 10 K

We can input the data with the following code:

from pina import PinchAnalyzer, make_stream

# Arguments: heat flow, supply temperature, target temperature
cold_1 = make_stream(-230, 20, 135)
hot_1 = make_stream(330, 170, 60)
cold_2 = make_stream(-240, 80, 140)
hot_2 = make_stream(180, 150, 30)

min_temp_diff = 10
temp_shift = min_temp_diff / 2

analyzer = PinchAnalyzer(temp_shift)
analyzer.add_streams(cold_1, hot_1, cold_2, hot_2)

The PinchAnalyzer class calculates the energy targets, the pinch temperature(s) and the coordinates of the composite curves. The following properties can be requested from it:

  • heating_demand
  • cooling_demand
  • hot_utility_target
  • cold_utility_target
  • heat_recovery_target
  • pinch_temps
  • cold_composite_curve
  • hot_composite_curve
  • shifted_cold_composite_curve
  • shifted_hot_composite_curve
  • grand_composite_curve

For example:

print(
    "Heating demand:       {}\n"
    "Cooling demand:       {}\n"
    "Hot utility target:   {}\n"
    "Cold utility target:  {}\n"
    "Heat recovery target: {}\n"
    "Pinch temperature(s): {}".format(
        analyzer.heating_demand,
        analyzer.cooling_demand,
        analyzer.hot_utility_target,
        analyzer.cold_utility_target,
        analyzer.heat_recovery_target,
        analyzer.pinch_temps,
    )
)

Output:

Heating demand:       470.0
Cooling demand:       510.0
Hot utility target:   20.0
Cold utility target:  60.0
Heat recovery target: 450.0
Pinch temperature(s): [85.0]

Plotting

This package deliberately does not include any plotting functions, but using it together with plotting libraries is simple. Here is an example that uses matplotlib to create a figure with two subplots: the hot and cold composite curves on the left and the grand composite curve on the right:

from matplotlib import pyplot as plt

fig, ax = plt.subplots(1, 2, figsize=(16, 7))

ax[0].plot(*analyzer.hot_composite_curve, color="tab:red", linestyle="--", label="HCC")
ax[0].plot(*analyzer.cold_composite_curve, color="tab:blue", linestyle="-", label="CCC")
ax[0].legend()
ax[0].set_title("Hot and cold composite curves")
ax[0].set_xlabel("Heat flow [kW]")
ax[0].set_ylabel("Actual temperature [\u2103]")

ax[1].plot(*analyzer.grand_composite_curve, color="k", linestyle="-", label="GCC")
ax[1].legend()
ax[1].set_title("Grand composite curve")
ax[1].set_xlabel("Net heat flow [kW]")
ax[1].set_ylabel("Shifted temperature [\u2103]")

# Make the y-axis equal in both plots
ylims = (*ax[0].get_ylim(), *ax[1].get_ylim())
minmax_ylims = (min(ylims), max(ylims))
ax[0].set_ylim(minmax_ylims)
ax[1].set_ylim(minmax_ylims)

plt.show()

Output: Four stream example

More examples

More examples can be found in the examples folder. They show some additional features:

  • Streams carrying latent heat (e.g. evaporation and condensation)
  • Streams consisting of multiple segments
  • Streams with individual temperature shifts

Anything else?

Nope, that's all. Enjoy :-)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pina-0.1.0.tar.gz (27.5 kB view details)

Uploaded Source

Built Distribution

pina-0.1.0-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file pina-0.1.0.tar.gz.

File metadata

  • Download URL: pina-0.1.0.tar.gz
  • Upload date:
  • Size: 27.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.25.1

File hashes

Hashes for pina-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d0d63b45f7127bbaed187c6c71d6f1dce21d69cc51dc40362dadc3b6ba408281
MD5 cdd17d710814e9a2b3c16ddee91f996d
BLAKE2b-256 1cf3553754ee105e7f3753339ba28c260544aee9f099b9e6dd190fadb7c62c34

See more details on using hashes here.

File details

Details for the file pina-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pina-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.25.1

File hashes

Hashes for pina-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eb800d14dafaf0528b33f5f81b3a5b773d9a664547355470a4d02824f5646fd7
MD5 e010d0acd1116b8f9ee6ac709ffc28ee
BLAKE2b-256 34c761aca81085aaef73572dbea61e6a6afe3d2eb4b80b44e18bc0f1aec00f5d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page