Skip to main content

A python toolkit for ion chromatography

Project description

Python versions PyPI version

PyICLab

PyICLab is an open-source Python package designed for in-silico simulations of ion chromatography (IC).

Features

  • Implementations of IC components
  • Built-in numerical models
  • Flow path management
  • Suitable for complex IC setups and conditions

Installation

PyICLab can be installed via PyPI using pip. Ensure you have Python 3.11 or higher.

For Windows:

pip install pyIClab

For MacOS:

pip3 install pyIClab

Note for Apple Silicon Users

PyICLab currently DOES NOT support the ARM64 architecture directly. To use PyICLab on Apple Silicon, you are advised to build your Python3 environment using an x86 version of conda/miniconda.

Dependencies

PyICLab requires the following Python packages:

  • numpy>=1.26.4
  • scipy>=1.12.0
  • pandas>=2.2.0
  • pint>=0.23
  • matplotlib>=3.8.2
  • seaborn>=0.13.2
  • phreeqpython>=1.5.0
  • pyEQL>=0.12.2
  • beautifulsoup4>=4.12.3
  • tqdm>=4.66.2
  • quadprog
  • deprecated

Get Started

Here is a simple example to demonstrate the basic usage of PyICLab:

from pyIClab._testing_toolkit import PackedIC
from pyIClab.beadedbag import mpl_custom_rcconfig
import seaborn as sns
import matplotlib.pyplot as plt

ic = PackedIC()
ic.go(tmax='10 min')

detector = ic.detectors.pop()
df = detector.get_signals()

sns.set()
plt.rcParams.update(mpl_custom_rcconfig)
fig, ax = plt.subplots()
ax.plot('time', 'signal', data=df)
ax.set_xlabel('Time, min')
ax.set_ylabel('Concentration, mM')
plt.show()

chrom_demo

Or build your IC system step by step

Import the necessary components from the PyICLab package.

from pyIClab import (
    IonChromatograph, Eluent, SwitchingValve,
    SampleLoop, Dummy, QuickSuppressor, Detector,
    )

Create the necessary accessories for a basic IC system. Ensure each accessory has a unique name. This includes:

  • An IC pump (Eluent)
  • A six-port valve
  • A 25-µL sample loop
eluent = Eluent.HydroxideIsocratic('18 mM', fr='1 mL/min') # Name defaults to 'KOH'
valve = SwitchingValve.SixPort() # Name defaults to 'SixPort'
loop = SampleLoop('Loop', V='25 uL')

Use a built-in column initializer with a primitive stationary phase database

column = Dummy.Column() # Name defaults to 'Dummy'

PyICLab provides several suppressor implementations. Here is the simplest one. Visit pyIClab.assemblies.signals for more options. Also, add a detector to the system.

suppressor = QuickSuppressor('Suppressor', kind='anion')
detector = Detector('Detector')

Connect all the accessories and install the IC system. I bet you have done it a lot.

valve.assemble(0, eluent)
valve.assemble(1, column)
valve.assemble([2, 5], loop)
column.assemble(suppressor)
suppressor.assemble(detector)

Now we can build a basic IC system. Setting lockon=valve means that when accessing the IC system, PyICLab will find all the accessories by starting with the valve. All accessories traced back to the valve will be included in the IC system.

ic = IonChromatograph('SimpleIC', competing_ions=('OH-',), lockon=valve)

Prepare a simple solution and inject it into the loop.

solution = {
    'F-': '0.05 mM',
    'Cl-': '0.075 mM',
    'NO2-': '0.09 mM',
    'Br-': '0.1 mM',
    'NO3-': '0.125 mM',
    'SO4-2': '0.15 mM',
}
ic.inject(solution, 'Loop')

Set a model constructor for the sole column in the IC system. PyICLab provides built-in model constructors that allow you to configure model parameters in one code line. Use help(pyIClab.interface.DSMConstrutorForColumns) for more information.

ic.set_ModelConstructor('DSM_SEConstrutor', 'Dummy')

Set commands for the IC system as if it were real. You can also use .add_command() to add commands one by one.

commands = '''
    0.0 min, sixport, inject
    0.5 min, sixport, load
'''
ic.reset_commands(commands)

Think we are all set. Let's go.

ic.go('12 min')

Use the .plot method to show the effluent composition.

detector.plot()

chrom_demo

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

pyiclab-2024.6.6.tar.gz (326.1 kB view details)

Uploaded Source

Built Distribution

pyIClab-2024.6.6-py3-none-any.whl (111.8 kB view details)

Uploaded Python 3

File details

Details for the file pyiclab-2024.6.6.tar.gz.

File metadata

  • Download URL: pyiclab-2024.6.6.tar.gz
  • Upload date:
  • Size: 326.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.9

File hashes

Hashes for pyiclab-2024.6.6.tar.gz
Algorithm Hash digest
SHA256 222e4de6cfe626f02ea2bfba779f393cd7b41a7333111246a32b5fdf3868a9b9
MD5 48d464e392913d44617eea1429bcb42c
BLAKE2b-256 171081091286870935f98ba78ab2518c478c3afaf99518f7f84eae58411dc8bc

See more details on using hashes here.

File details

Details for the file pyIClab-2024.6.6-py3-none-any.whl.

File metadata

  • Download URL: pyIClab-2024.6.6-py3-none-any.whl
  • Upload date:
  • Size: 111.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.9

File hashes

Hashes for pyIClab-2024.6.6-py3-none-any.whl
Algorithm Hash digest
SHA256 054848f220574309f65f1a7930ef210d495937efcdccff2f9f3d5f1956c0458e
MD5 3848aa2626cbf0d59900869eecba9b6e
BLAKE2b-256 bbd06c153c6be4e20bae34901fcb2de28132f7b72e5d1a59bf55afee96a4ada9

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