pymembrane Documentation#
Welcome to the pymembrane documentation
This module is a Python library for modeling, simulating and optimizing spiral membrane-based processes.
Author: Hedi Romdhana
Elementary mass transfers in a spiral membrane#
The diagram above depicts the mass transfer phenomena taking place in a spiral membrane.
Feed flow (\(\dot{V}_{in}\)): The feed enters the membrane module containing water and solutes and flows in the direction of \(\vec{e}_x\), parallel to the membrane surface, through both retentate and permeate channels.
Retentate (\(\dot{V}_{r}\)): The retentate flow travels along the membrane and contains the solutes that are rejected by the membrane, leading to an increase in solute concentration along the membrane length. In the retentate side, the mass boundary layer (\(\delta\)) is formed, and diffusive flux (\(\Phi_{\delta, j}\)) occurs back towards the bulk due to concentration polarization.
Permeate (\(\dot{V}_{p}\)): The permeate stream contains water and a reduced concentration of solutes. Solutes pass through the membrane (\(\beta\)) with diffusive flux (\(\Phi_{\beta, j}\)) across the membrane thickness.
Mass boundary layer (\(\delta\)): A boundary layer forms in the retentate side due to the accumulation of solutes, generating a diffusive flux (\(\Phi_{\delta, j}\)) directed away from the membrane.
Membrane thickness (\(\beta\)): The thickness of the membrane (\(\beta\)) represents resistance for the solutes, where diffusion of solutes happens from the retentate-membrane interface to the permeate-membrane interface.
Transmembrane flux (\(J_w\)): Represents the water flux driven by transmembrane pressure. The presence of solutes creates osmotic pressure differences that influence this flux.
Setup#
To install pymembrane, you can use pip from PyPI:
pip install pymembrane
If you want to upgrade to the latest version, use the following command:
pip install --upgrade pymembrane
Make sure to have Python 3.7 or a later version.
pymembrane Module#
This module defines classes and functions to simulate spiral membrane filtration processes.
spiral_membrane#
- class spiral_membrane(**args)#
A class that simulates the spiral membrane filtration process.
Parameters# Parameter
Description
Unit
Patm
floatAtmospheric pressure
barPin
floatInlet pressure
barT
floatInlet temperature
°CL
floatMembrane length
mS
floatMembrane area
m²DP
floatPressure loss across the membrane
barAw
floatWater permeability
m/h/barVin
floatInlet volumetric flow rate
m³/hsolutes
listList of solutes
Cin
listInlet solute concentrations
mol/m³B
listMembrane mass transfer coefficients
m/hk
listBoundary layer mass transfer coefficients
m/hReturns# Return
Description
Unit
Vr_out
floatRetentate volumetric flow rate at the membrane outlet
m³/hVp_out
floatPermeate volumetric flow rate at the membrane outlet
m³/hCr_out
ndarraySolute concentrations in the retentate at the membrane outlet
mol/m³Cp_out
ndarraySolute concentrations in the permeate at the membrane outlet
mol/m³FRV
ndarrayFlow rate volume ratio along the membrane
T
ndarrayTransmission coefficient along the membrane
mol/molR
ndarrayRejection coefficient along the membrane
-FRV_out
floatFlow rate volume ratio at the membrane outlet
-T_out
ndarrayTransmission coefficient at the membrane outlet
mol/molR_out
ndarrayRejection coefficient at the membrane outlet
-net_balance
floatNet volumetric mass balance
m³/hsolute_net_balance
ndarraySolute mass balance
mol/h
- spiral_membrane.calcul(solver_method='taylor', taylor_terms=2)#
Simulates the filtration process.
Parameters# solver_method
strThe method used for solving concentration at the membrane interface.
Options are
'fsolve','root','taylor'(default),'fixed_point'.taylor_terms
intNumber of terms to use in the Taylor series approximation (if applicable).
Exemples#
Instantiate spiral_membrane class#
In this example, we demonstrate how to initialize and configure the spiral_membrane class from the pymembrane module to simulate a membrane filtration process. The parameters are set for a spiral membrane, and solute-specific details are provided. Finally, the properties of the initialized object are printed to illustrate the initial configuration.
1from pymembrane.membrane import membrane
2
3# Instantiate the spiral membrane object with key parameters
4sm = membrane.spiral_membrane(
5 L=4.5, # Length of the membrane in meters
6 DP=0.5, # Pressure loss across the membrane in bar
7 S=118.5, # Membrane area in m²
8 Pin=9.5, # Inlet pressure in bar
9 Vin=10.0, # Inlet volumetric flow rate in m³/h
10 T=25 # Inlet temperature in °C
11 )
12
13# Specify the solutes present in the feed solution
14sm.solutes = ['sucrose', 'fructose', 'lactic acid']
15
16# Set the membrane mass transfer coefficients (B) for each solute in m/h
17sm.B = [0.000144, 5.4e-05, 0.00027]
18
19# Set the boundary layer mass transfer coefficients (k) for each solute in m/h
20sm.k = [0.036, 0.0432, 0.0684]
21
22# Set the inlet concentrations of each solute in the feed stream in mol/m³
23sm.Cin = [0.1454, 2.4083, 3.5628]
24
25# Print the details of the membrane configuration
26print(sm)
print(sm) is used to display the initialized configuration of the spiral_membrane object.
It provides a summary of all the parameters, solutes, and coefficients defined above.
Expected Output:
+---------------+----------------------------------------+---------+------------------------------+
| Vin | 10.000 | m³/h | Inlet flow rate |
| T | 25.0 | °C | Inlet temperature |
| Patm | 1.0 | bar | Atmospheric pressure |
| Pin | 9.5 | bar | Inlet pressure |
| S | 118.50 | m² | Membrane area |
| L | 4.50 | m | Membrane length |
| Aw | 5.300e-03 | m/h/bar | Water permeability |
| DP | 0.500 | bar | Pressure loss |
| Cin | [0.145, 2.408, 3.563] | mol/m³ | Inlet solute concentrations |
| solutes | ['sucrose', 'fructose', 'lactic acid'] | | Solutes list |
| B | [0.000144, 5.4e-05, 0.00027] | m/h | Membrane mass transfer |
| k | [0.036, 0.0432, 0.0684] | m/h | Boundary layer mass transfer |
+---------------+----------------------------------------+---------+------------------------------+
Membrane simulation#
1# Run the membrane simulation
2sm.calcul()
3# Print the summary results after the simulation
4print(sm.res)
Expected Output:
+--------------------+-----------------------+---------+----------------------+
| Vr_out | 5.100 | m3/h | retentate flowrate |
| Vp_out | 4.900 | m3/h | permeate flowrate |
| Cp_out | [0.002, 0.011, 0.058] | mol/m3 | solutes in permeate |
| Cr_out | [0.283, 4.711, 6.93] | mol/m3 | solutes in retentate |
| calculation_time | 0.031 | s | calculation time |
| net_balance | 2.665e-15 | m3/h | net mass balance |
| solute_net_balance | [0.0, 3.553e-15, 0.0] | mol/h | solute net balance |
| FRV_out | 1.961 | - | FRV |
| R_out | [0.992, 0.998, 0.992] | - | rejection |
| T_out | [0.008, 0.002, 0.008] | mol/mol | transmission |
+--------------------+-----------------------+---------+----------------------+
Volume flowrate profiles#
In this example, we visualize the flow rate profiles of the retentate and permeate along the length of the membrane.
1import matplotlib.pyplot as plt
2plt.plot(sm.res.x[0:], sm.res.Vr[0:], label="Retentate")
3plt.plot(sm.res.x[0:], sm.res.Vp[0:], label="Permeate")
4plt.xlabel("Membrane position [m]")
5plt.ylabel("Volume flowrate [m³/h]")
6plt.grid()
7plt.legend()
8plt.show()
Expected Plot:
(Source code, png, pdf, svg)
Flowrate profiles along the membrane#
Retention profiles of solutes#
In this second example, we demonstrate how to plot the retention profiles (Retention rate) of each solute along the membrane.
1for i in range(len(sm.solutes)):
2 plt.plot(sm.res.x[1:],sm.res.R[i,1:],label=sm.solutes[i])
Expected Plot:
(Source code, png, pdf, svg)
Retention of solutes along the membrane#