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()

demo-chromatogram

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()

demo-chromatogram

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.1.tar.gz (104.0 kB view details)

Uploaded Source

Built Distribution

pyIClab-2024.6.6.1-py3-none-any.whl (111.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyiclab-2024.6.6.1.tar.gz
  • Upload date:
  • Size: 104.0 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.1.tar.gz
Algorithm Hash digest
SHA256 66be821a8900ca43e864031d05e28c7a58fb5bbfc76fe3eeac2903a35da20d3a
MD5 916c85dc522608198f1ded20a6df3aea
BLAKE2b-256 6b54863d5fd5a152812c634582ace2c3e1de0a4ee3b869cc117c2426885dfea4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyIClab-2024.6.6.1-py3-none-any.whl
  • Upload date:
  • Size: 111.9 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 00657b9c3220dbab4795c1f9f6c2472ea1c8b4fcfcc47aa2e9617d4d6e14b2fc
MD5 276dac13c9c29f7100a317974f4b3df7
BLAKE2b-256 299b6f7cdb678ba47ffbfe029c805dc12a6cec80cfccf50b584c80ee453d9b3a

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