Created
January 30, 2020 07:43
-
-
Save partrita/6dc90106a8abec3b22a06395c2b62fca to your computer and use it in GitHub Desktop.
simple python script for calculator of chromatography
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import click | |
pi = 3.14 | |
@click.group() | |
def cli(): | |
pass | |
@cli.command() | |
@click.option( | |
'-l', '--linearflow', prompt='Linear flow (cm/h)?', | |
type=int, | |
help='The linear flow (cm/h) of your column.') | |
@click.option( | |
'-d', '--diameter', prompt='column diameter in cm?', | |
type=float, | |
help='The column diameter of your column.') | |
def flowrate(linearflow, diameter): | |
""" | |
Volumetric flow rate (ml/min) = [Linear flow (cm/h)/60] x column cross sectional area (cm2) | |
""" | |
flowrate = (float(linearflow)/60.0)*(pi*(float(diameter)**2)/4.0) | |
return click.echo(f'The flow rate is {flowrate} ml/min') | |
@cli.command() | |
@click.option( | |
'-v', '--volumeflow', prompt='Volumetric flow rate (ml/min)?', | |
type=float, | |
help='The volumetric flow rate(ml/min) of your column.') | |
@click.option( | |
'-d', '--diameter', prompt='column diameter in cm?', | |
type=float, | |
help='The column diameter of your column.') | |
def volumeflow(volumeflow, diameter): | |
""" | |
Linear flow rate = [Volumetric flow rate (ml/min) × 60] / column cross sectional area (cm2) | |
""" | |
volumeflow = float(volumeflow)*60.0*4/(pi*(float(diameter))**2) | |
return click.echo(f'The linear flow is {volumeflow} cm/h') | |
@cli.command() | |
@click.option( | |
'-l', '--linearflow', prompt='Linear flow (cm/h)?', | |
type=int, | |
help='The linear flow (cm/h) of your column.') | |
@click.option( | |
'-h', '--bedhight', prompt='Bed height(cm)?', | |
type=int, | |
help='The bed heigt(cm) of your column.') | |
def residencetime(linearflow, bedhight): | |
"""Residence time (min) = [bed height (cm)/flow velocity (cm/h)] x 60""" | |
residence_time = (bedhight/linearflow)*60.0 | |
return click.echo(f'The residence time is {residence_time} min.') | |
if __name__ == '__main__': | |
cli() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment