Skip to content

Commit

Permalink
Merge pull request #23 from chemics/develop
Browse files Browse the repository at this point in the history
Updates for version 21.5
  • Loading branch information
wigging committed May 9, 2021
2 parents 7062705 + 2402df0 commit 79c9130
Show file tree
Hide file tree
Showing 16 changed files with 568 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.vscode/
pipfile
pipfile.lock

# Created by https://www.gitignore.io/api/vim,latex,linux,macos,python,pycharm,windows,sublimetext,jupyternotebook,visualstudiocode
# Edit at https://www.gitignore.io/?templates=vim,latex,linux,macos,python,pycharm,windows,sublimetext,jupyternotebook,visualstudiocode
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

Version numbers use calendar versioning based on `YY.MM.MICRO`. See the [CalVer](https://calver.org) website for more information about this versioning convention. The format of this changelog follows the approach outlined on the [Keep a Changelog](https://keepachangelog.com) website.

## 21.5

#### Added

- Mass transfer correlations
- Peclet (Pe), Schmidt (Sc), and Sherwood (Sh) dimensionless numbers
- Function to calculate pressure drop using Ergun equation

#### Changed

- Updated contributing guidelines

## v21.4

#### Added
Expand Down
6 changes: 5 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The following is a set of guidelines for contributing to the Chemics Python pack

## Code style

All code in the Chemics package should adhere to the style enforced by the [Flake8][f8] tool. This will ensure a consistent code format throughout the package and prevent syntax errors during development.
All code in the Chemics package should adhere to the style enforced by the [Flake8][f8] tool. This will ensure a consistent code format throughout the package and prevent syntax errors during development. For the Flake8 style settings, ignore the E501, W503, W605 errors and warnings.

## Docstrings

Expand All @@ -32,6 +32,10 @@ Don't forget to edit the changelog based on contributions. Follow the style on t

Finally, new source code should be included in the [Sphinx documentation][sd] located in the `docs/` folder.

## Creating a Pull Request

All Pull Requests should be submitted to the `develop` branch; not to the `main` branch. When a new version is ready to be released the `develop` branch will be merged with the `main` branch.

[f8]: https://pypi.org/project/flake8/
[np]: https://numpydoc.readthedocs.io/en/latest/format.html
[ce]: https://github.com/chemics/chemics-examples
Expand Down
11 changes: 11 additions & 0 deletions chemics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@

from .dimensionless_numbers import archimedes
from .dimensionless_numbers import biot
from .dimensionless_numbers import peclet
from .dimensionless_numbers import prandtl
from .dimensionless_numbers import pyroI
from .dimensionless_numbers import pyroII
from .dimensionless_numbers import reynolds
from .dimensionless_numbers import schmidt
from .dimensionless_numbers import sherwood
from .dimensionless_numbers import flow_regime

from .gas_density import rhog
from .gas_heat_capacity import cp_gas
Expand All @@ -45,13 +49,20 @@

from .geldart import geldart_chart

from .mass_transfer_correlations import molecular_diffusion_coeff
from .mass_transfer_correlations import convective_mt_coeff
from .mass_transfer_correlations import axial_dispersion_coeff
from .mass_transfer_correlations import axial_dispersion_coeff_sc

from .minimum_fluidization_velocity import umf_coeff
from .minimum_fluidization_velocity import umf_ergun
from .minimum_fluidization_velocity import umf_reynolds

from .molecular_weight import mw
from .molecular_weight import mw_mix

from .pressure_drop import pressure_drop_ergun

from .proximate_bases import proximate_bases

from .terminal_velocity import ut
Expand Down
183 changes: 183 additions & 0 deletions chemics/dimensionless_numbers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import chemics as cm


def archimedes(dp, rhog, rhos, mu):
"""
Calculate the dimensionless Archimedes number.
Expand Down Expand Up @@ -69,6 +72,43 @@ def biot(h, d, k):
return bi


def peclet(ui, L, Dax):
"""
Calculate the dimensionless Peclet number for mass transfer.
The Peclet number is defined as the ratio between the bulk mass transport
(convection) and the molecular diffusion.
.. math:: Pe = \\frac{u_i L}{D_{ax}}
Parameters
----------
ui : float
Interstitial velocity [m/s]
L : float
Length or characteristic dimension [m]
Dax : float
Axial dispersion coefficient [m^2/s]
Returns
-------
pe : float
Peclet number [-]
Example
-------
>>> peclet(3.0e-3, 0.25, 4.7e-4)
1.5957
References
----------
J.D. Seader, E.J. Henley, D.K. Roper. Separation Process Principles.
John Wiley & Sons, Inc., 3rd edition, 2011.
"""
pe = ui * L / Dax
return pe


def prandtl(cp=None, mu=None, k=None, nu=None, alpha=None):
"""
Calculate the dimensionless Prandtl number for a fluid or gas.
Expand Down Expand Up @@ -249,3 +289,146 @@ def reynolds(u, d, rho=None, mu=None, nu=None):
raise ValueError('Must provide (u, d, rho, mu) or (u, d, nu)')

return re


def schmidt(mu, rho, Dm):
"""
Calculate the dimensionless Schmidt number.
The Schmidt number represents the ratio between momentum diffusivity
(kinematic viscosity) and mass diffusivity.
.. math:: Sc = \\frac{\\mu}{\\rho D_m}
Parameters
----------
mu : float
Viscosity of the fluid flowing through the packed bed [Pa s]
rho : float
Density of the fluid flowing through the packed bed [kg/m^3]
Dm : float
Molecular diffusion coefficient [m^2/s]
Returns
-------
sc : float
Schmidt number [-]
Example
-------
>>> schmidt(8.90e-4, 997.07, 2.299e-9)
388.26
References
----------
J.D. Seader, E.J. Henley, D.K. Roper. Separation Process Principles.
John Wiley & Sons, Inc., 3rd edition, 2011.
"""
sc = mu / rho / Dm
return sc


def sherwood(k, d, Dm):
"""
Calculate the dimensionless Sherwood number.
The Sherwood number represents the ratio between the convective mass
transfer and the rate of diffusive mass transport.
.. math:: Sh = \\frac{k d}{D_m}
Parameters
----------
k : float
Convective mass transfer coefficient [m/s]
d : float
Particle diameter or characteristic length [m]
Dm : float
Molecular diffusion coefficient [m^2/s]
Returns
-------
sh : float
Sherwood number [-]
Example
-------
>>> sherwood(2.3e-4, 5.0e-6, 4.0e-9)
0.2875
References
----------
J.D. Seader, E.J. Henley, D.K. Roper. Separation Process Principles.
John Wiley & Sons, Inc., 3rd edition, 2011.
"""
sh = k * d / Dm
return sh


def flow_regime(Re=None, u=None, d=None, rho=None, mu=None, nu=None):
"""
Determine flow regime (laminar, transitional or turbulent) considering the
Reynolds number boundaries for the case of a straight, non-smooth pipe.
Laminar regime: Re < 2100
Transitional regime: 2100 <= Re <= 4000
Laminar regime: Re > 4000
Parameters
----------
Re : float, optional
Reynolds number [-]
u : float, optional
Flow speed [m/s]
d : float, optional
Characteristic length or dimension [m]
rho : float, optional
Density of the fluid or gas [kg/m^3]
mu : float, optional
Dynamic viscosity of the fluid or gas [kg/(m s)]
nu : float, optional
Kinematic viscosity of the fluid or gas [m^2/s]
Returns
-------
regime : string
Flow regime. One of laminar, transitional or turbulent.
Examples
--------
>>> flow_regime(u=2.6, d=0.025, rho=910, mu=0.38)
'laminar'
>>> flow_regime(Re=3250)
'transitional'
>>> flow_regime(u=0.25, d=0.102, nu=1.4e-6)
'turbulent'
Raises
------
ValueError
Must provide Re or (u, d, rho, mu) or (u, d, nu)
References
----------
R.H. Perry, D.W. Green. Perry's Chemical Engineers' Handbook.
McGraw-Hill, 8th edition, 2008.
"""
if not Re:
if (rho and mu and not nu) or (nu and not rho and not mu):
Re = cm.reynolds(u, d, rho=rho, mu=mu, nu=nu)
else:
raise ValueError(
'Must provide Re or (u, d, rho, mu) or (u, d, nu)'
)
if Re < 2100:
regime = 'laminar'
elif 2100 <= Re <= 4000:
regime = 'transitional'
elif Re > 4000:
regime = 'turbulent'

return regime
Loading

0 comments on commit 79c9130

Please sign in to comment.