Skip to main content

A Python library for creating right triangle plots for partially miscible extraction (for wankat book)

Project description

Extraction Triangle

A Python library for creating right triangle plots, particularly useful for ternary (three-component) extraction data visualization. This library provides functionality similar to ternary plots but uses right triangle geometry, making it ideal for binary and ternary extraction systems and related applications.

Features

  • Three-Component System Support: Full support for ternary systems (A, B, C components)
  • Solubility Envelope Curves: Plot and interpolate binodal curves from experimental data
  • Conjugate Curves: Draw tie line curves connecting equilibrium phases
  • Tie Line Networks: Visualize multiple tie lines for phase equilibrium data
  • Create right triangle coordinate systems with multiple orientations
  • Plot data points on right triangle grids with component fraction labels
  • Customizable triangle orientation and scaling
  • Support for contour plots and heatmaps
  • Grid lines with component fraction annotations
  • Export capabilities for various formats
  • Specialized methods for extraction processes

Installation

pip install extraction-triangle

Quick Start

Basic Two-Component Plot

import numpy as np
from extraction_triangle import RightTrianglePlot

# Create sample data
x_data = [0.1, 0.3, 0.5, 0.7, 0.9]
y_data = [0.8, 0.6, 0.4, 0.2, 0.1]

# Create right triangle plot
rt_plot = RightTrianglePlot()
rt_plot.scatter(x_data, y_data)
rt_plot.add_labels("Component A", "Component B")
rt_plot.show()

Three-Component Extraction System

# Component fractions (must sum to 1)
solute = [0.2, 0.4, 0.6]           # Component A
extract_solvent = [0.3, 0.4, 0.3]  # Component B  
raffinate_solvent = [0.5, 0.2, 0.1] # Component C

# Create ternary plot
rt_plot = RightTrianglePlot()
rt_plot.scatter_ternary(solute, extract_solvent, raffinate_solvent, 
                       c=['red', 'blue', 'green'], s=100)

# Add grid with component fraction labels
rt_plot.add_grid(show_labels=True)
rt_plot.add_labels("Solute", "Extract Solvent", "Raffinate Solvent")
rt_plot.add_corner_labels("Pure Solute", "Pure Extract", "Pure Raffinate")
rt_plot.show()

Solubility Envelope and Tie Line Curves

# Add solubility envelope (binodal curve) from experimental data
water_data = [0.95, 0.85, 0.70, 0.50, 0.30, 0.15, 0.05]
acetone_data = [0.04, 0.12, 0.25, 0.40, 0.55, 0.70, 0.85]
chloroform_data = [0.01, 0.03, 0.05, 0.10, 0.15, 0.15, 0.10]

# Create plot with solubility envelope curve
rt_plot = RightTrianglePlot()
rt_plot.add_solubility_envelope(water_data, acetone_data, chloroform_data,
                               interpolate=True, n_points=150,
                               color='blue', linewidth=3, 
                               fill=True, fill_alpha=0.2,
                               label='Solubility Envelope')

# Add tie line curves connecting equilibrium phases
phase1_data = {'a': [0.80, 0.65, 0.45], 'b': [0.15, 0.28, 0.42], 'c': [0.05, 0.07, 0.13]}
phase2_data = {'a': [0.10, 0.18, 0.35], 'b': [0.20, 0.35, 0.55], 'c': [0.70, 0.47, 0.10]}

rt_plot.add_tie_lines(phase1_data, phase2_data, 
                     color='red', show_points=True,
                     labels=['Aqueous Phase', 'Organic Phase'])

rt_plot.add_labels("Water", "Acetone", "Chloroform")
rt_plot.show()

Triangle Coordinate System

The right triangle represents a three-component system where:

  • U-axis (horizontal): Component A fraction (0 to 1)
  • V-axis (vertical): Component B fraction (0 to 1)
  • Hypotenuse: Component C fraction = 1 - A - B

This is particularly useful for:

  • Liquid-liquid extraction: Solute, extract solvent, raffinate solvent
  • Solubility envelope curves: Binodal curves defining two-phase regions
  • Tie line curves: Curved relationships between equilibrium phases
  • Mass transfer processes: Different phase compositions
  • Chemical separations: Multi-component mixtures

Use Cases

  • Liquid-liquid extraction diagrams with solubility envelopes
  • Ternary phase equilibrium visualization with curved tie lines
  • Binodal curve interpolation from experimental data
  • Binary and ternary separation processes
  • Chemical engineering applications
  • Process optimization studies
  • Selectivity and efficiency mapping

Documentation

For detailed documentation and examples, visit: [Documentation Link]

License

MIT License

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

extraction_triangle-0.1.0.tar.gz (23.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

extraction_triangle-0.1.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: extraction_triangle-0.1.0.tar.gz
  • Upload date:
  • Size: 23.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for extraction_triangle-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c1f3b672ee9caff635e42f70a5540b68affe24b32c68c7cbb929f077cffdb98c
MD5 15d24adb73d659f96a3d74f005c7c84d
BLAKE2b-256 e0ed8f6c70669d7ccd572271c99ba26795d1d021725ee5e552943a0794877a2d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for extraction_triangle-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c24767a5e3dcd9291669677b289d8c388843c9ce3259ee6cbf9db5b587fd43bf
MD5 c1cb38511ba3b7dda96a70e2dc516f96
BLAKE2b-256 71cbbbe2d6ead1638ceb90facad942d9d2e9e22ed3b63021d6315dd79fc64721

See more details on using hashes here.

Supported by

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