pymembrane Documentation#

Welcome to the pymembrane documentation Version Badge

This module is a Python library for modeling, simulating and optimizing spiral membrane-based processes.

Author: Hedi Romdhana

Email: hedi.romdhana@agroparistech.fr

Elementary mass transfers in a spiral membrane#

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#

pymembrane on PyPI

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 float

Atmospheric pressure

bar

Pin float

Inlet pressure

bar

T float

Inlet temperature

°C

L float

Membrane length

m

S float

Membrane area

DP float

Pressure loss across the membrane

bar

Aw float

Water permeability

m/h/bar

Vin float

Inlet volumetric flow rate

m³/h

solutes list

List of solutes

Cin list

Inlet solute concentrations

mol/m³

B list

Membrane mass transfer coefficients

m/h

k list

Boundary layer mass transfer coefficients

m/h

Returns#

Return

Description

Unit

Vr_out float

Retentate volumetric flow rate at the membrane outlet

m³/h

Vp_out float

Permeate volumetric flow rate at the membrane outlet

m³/h

Cr_out ndarray

Solute concentrations in the retentate at the membrane outlet

mol/m³

Cp_out ndarray

Solute concentrations in the permeate at the membrane outlet

mol/m³

FRV ndarray

Flow rate volume ratio along the membrane

T ndarray

Transmission coefficient along the membrane

mol/mol

R ndarray

Rejection coefficient along the membrane

-

FRV_out float

Flow rate volume ratio at the membrane outlet

-

T_out ndarray

Transmission coefficient at the membrane outlet

mol/mol

R_out ndarray

Rejection coefficient at the membrane outlet

-

net_balance float

Net volumetric mass balance

m³/h

solute_net_balance ndarray

Solute mass balance

mol/h

spiral_membrane.calcul(solver_method='taylor', taylor_terms=2)#

Simulates the filtration process.

Parameters#

solver_method str

The method used for solving concentration at the membrane interface.

Options are 'fsolve', 'root', 'taylor' (default), 'fixed_point'.

taylor_terms int

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

_images/index-1.png

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)

_images/index-2.png

Retention of solutes along the membrane#