![Python versions](https://img.shields.io/badge/python-3.11%20%7C%203.12-blue)
[![PyPI version](https://badge.fury.io/py/pyIClab.svg)](https://badge.fury.io/py/pyIClab)
# 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:
```sh
pip install pyIClab
```
For MacOS:
```sh
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:
```python
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](https://github.com/xiaoxiaozhu123/pyIClab/blob/main/demo_chromatogram.png?raw=true)
## Or build your IC system step by step
Import the necessary components from the PyICLab package.
```python
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
```python
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
```python
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.
```python
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.
```python
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.
```python
ic = IonChromatograph('SimpleIC', competing_ions=('OH-',), lockon=valve)
```
Prepare a simple solution and inject it into the loop.
```python
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.
```python
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.
```python
commands = '''
0.0 min, sixport, inject
0.5 min, sixport, load
'''
ic.reset_commands(commands)
```
Think we are all set. Let's go.
```python
ic.go('12 min')
```
Use the `.plot` method to show the effluent composition.
```python
detector.plot()
```
![demo-chromatogram](https://github.com/xiaoxiaozhu123/pyIClab/blob/main/demo_chromatogram02.png?raw=true)
Raw data
{
"_id": null,
"home_page": null,
"name": "pyIClab",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": "ion chromatography, hplc, analytical chemistry, modeling",
"author": null,
"author_email": "\"Kai \\\"Kenny\\\" Zhang\" <PyICLab@outlook.com>",
"download_url": "https://files.pythonhosted.org/packages/f1/4b/fd4132fe4bb6406458e761f9fc27138db383309d11d29ad2abc13239cbfc/pyiclab-2024.9.16.tar.gz",
"platform": null,
"description": "![Python versions](https://img.shields.io/badge/python-3.11%20%7C%203.12-blue)\n[![PyPI version](https://badge.fury.io/py/pyIClab.svg)](https://badge.fury.io/py/pyIClab)\n\n# PyICLab\n\nPyICLab is an open-source Python package designed for in-silico simulations of ion chromatography (IC). \n\n## Features\n\n- Implementations of IC components\n- Built-in numerical models\n- Flow path management\n- Suitable for complex IC setups and conditions\n\n## Installation\n\nPyICLab can be installed via PyPI using pip. Ensure you have Python 3.11 or higher.\n\nFor Windows:\n```sh\npip install pyIClab\n```\nFor MacOS:\n```sh\npip3 install pyIClab\n```\n### Note for Apple Silicon Users\n\nPyICLab 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. \n\n### Dependencies\n\nPyICLab requires the following Python packages:\n\n- `numpy>=1.26.4`\n- `scipy>=1.12.0`\n- `pandas>=2.2.0`\n- `pint>=0.23`\n- `matplotlib>=3.8.2`\n- `seaborn>=0.13.2`\n- `phreeqpython>=1.5.0`\n- `pyEQL>=0.12.2`\n- `beautifulsoup4>=4.12.3`\n- `tqdm>=4.66.2`\n- `quadprog`\n- `deprecated`\n\n## Get Started\n\nHere is a simple example to demonstrate the basic usage of PyICLab:\n\n```python\nfrom pyIClab._testing_toolkit import PackedIC\nfrom pyIClab.beadedbag import mpl_custom_rcconfig\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n\nic = PackedIC()\nic.go(tmax='10 min')\n\ndetector = ic.detectors.pop()\ndf = detector.get_signals()\n\nsns.set()\nplt.rcParams.update(mpl_custom_rcconfig)\nfig, ax = plt.subplots()\nax.plot('time', 'signal', data=df)\nax.set_xlabel('Time, min')\nax.set_ylabel('Concentration, mM')\nplt.show()\n```\n![demo-chromatogram](https://github.com/xiaoxiaozhu123/pyIClab/blob/main/demo_chromatogram.png?raw=true)\n\n## Or build your IC system step by step\nImport the necessary components from the PyICLab package.\n```python\nfrom pyIClab import (\n IonChromatograph, Eluent, SwitchingValve,\n SampleLoop, Dummy, QuickSuppressor, Detector,\n )\n```\nCreate the necessary accessories for a basic IC system. Ensure each accessory has a unique name. This includes:\n- An IC pump (Eluent)\n- A six-port valve\n- A 25-\u00b5L sample loop\n```python\neluent = Eluent.HydroxideIsocratic('18 mM', fr='1 mL/min') # Name defaults to 'KOH'\nvalve = SwitchingValve.SixPort() # Name defaults to 'SixPort'\nloop = SampleLoop('Loop', V='25 uL')\n```\n\nUse a built-in column initializer with a primitive stationary phase database\n```python\ncolumn = Dummy.Column() # Name defaults to 'Dummy'\n```\n\nPyICLab provides several suppressor implementations. Here is the simplest one. Visit `pyIClab.assemblies.signals` for more options. Also, add a detector to the system.\n\n```python\nsuppressor = QuickSuppressor('Suppressor', kind='anion')\ndetector = Detector('Detector')\n```\n\nConnect all the accessories and install the IC system. I bet you have done it a lot.\n```python\nvalve.assemble(0, eluent)\nvalve.assemble(1, column)\nvalve.assemble([2, 5], loop)\ncolumn.assemble(suppressor)\nsuppressor.assemble(detector)\n```\n\nNow 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.\n```python\nic = IonChromatograph('SimpleIC', competing_ions=('OH-',), lockon=valve)\n```\n\nPrepare a simple solution and inject it into the loop.\n\n```python\nsolution = {\n 'F-': '0.05 mM',\n 'Cl-': '0.075 mM',\n 'NO2-': '0.09 mM',\n 'Br-': '0.1 mM',\n 'NO3-': '0.125 mM',\n 'SO4-2': '0.15 mM',\n}\nic.inject(solution, 'Loop')\n```\n\nSet 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.\n\n```python\nic.set_ModelConstructor('DSM_SEConstrutor', 'Dummy')\n```\n\nSet commands for the IC system as if it were real. You can also use `.add_command()` to add commands one by one.\n\n```python\ncommands = '''\n 0.0 min, sixport, inject\n 0.5 min, sixport, load\n'''\nic.reset_commands(commands)\n```\n\nThink we are all set. Let's go.\n```python\nic.go('12 min')\n```\n\nUse the `.plot` method to show the effluent composition.\n\n```python\ndetector.plot()\n```\n![demo-chromatogram](https://github.com/xiaoxiaozhu123/pyIClab/blob/main/demo_chromatogram02.png?raw=true)\n",
"bugtrack_url": null,
"license": "GPL-3.0",
"summary": "A python toolkit for ion chromatography",
"version": "2024.9.16",
"project_urls": null,
"split_keywords": [
"ion chromatography",
" hplc",
" analytical chemistry",
" modeling"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b7ebde6002916d11dfff848cd9d81403e5bfca43d273aa7bb6aaae9af2e949ec",
"md5": "c4c2fdb1875d3262dffefa784112d047",
"sha256": "5e10c62be361c12c0718282ba9ec0a61557922a533fb45055ac6be2f132e6021"
},
"downloads": -1,
"filename": "pyIClab-2024.9.16-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c4c2fdb1875d3262dffefa784112d047",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 115401,
"upload_time": "2024-09-16T12:46:35",
"upload_time_iso_8601": "2024-09-16T12:46:35.692213Z",
"url": "https://files.pythonhosted.org/packages/b7/eb/de6002916d11dfff848cd9d81403e5bfca43d273aa7bb6aaae9af2e949ec/pyIClab-2024.9.16-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f14bfd4132fe4bb6406458e761f9fc27138db383309d11d29ad2abc13239cbfc",
"md5": "6f7582281c934a453de0eaaf5b5dd315",
"sha256": "e9ffdbe91ec6bcccee64560b639f07baa8a220e28392de98ff7a06457f678a4b"
},
"downloads": -1,
"filename": "pyiclab-2024.9.16.tar.gz",
"has_sig": false,
"md5_digest": "6f7582281c934a453de0eaaf5b5dd315",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 106020,
"upload_time": "2024-09-16T12:46:37",
"upload_time_iso_8601": "2024-09-16T12:46:37.179947Z",
"url": "https://files.pythonhosted.org/packages/f1/4b/fd4132fe4bb6406458e761f9fc27138db383309d11d29ad2abc13239cbfc/pyiclab-2024.9.16.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-16 12:46:37",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "pyiclab"
}