Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Membrane Model

This notebook demonstrates a 2D membrane model with a shell-in-tube geometry. The model simulates counter-current plug flow with radial diffusion. A membrane separates the inner retentate side from the outer annular permeate side, and a substance permeates from one side to the other through the membrane.

The purpose of this example is to illustrate how to couple two submodels at a shared interface, using either explicit coupling (iterating on the interface value) or fully implicit coupling (one linear system for both sides). The governing equations and boundary conditions are given below.

Governing Equation

The governing equation for both the retentate and permeate sides is:

∂c∂t+divz(v c)−divr(D divr(c))=0\frac{\partial c}{\partial t} + \mathrm{div}_z (v \, c) - \mathrm{div}_r (D \, \mathrm{div}_r(c)) = 0

Both sides are plug flow in zz (retentate and permeate flow counter-current), with radial diffusion.

Boundary Conditions

At the membrane interface, the boundary conditions are:

D∂cret∂n=P (cperm−cret),RpermRretD∂cperm∂n=P (cret−cperm)D \frac{\partial c_\mathrm{ret}}{\partial n} = P \, (c_\mathrm{perm} - c_\mathrm{ret}), \qquad \frac{R_\mathrm{perm}}{R_\mathrm{ret}} D \frac{\partial c_\mathrm{perm}}{\partial n} = P \, (c_\mathrm{ret} - c_\mathrm{perm})

Here nn is the outward normal of each subdomain. pymrm boundary conditions always use the outward normal (pitfall P1): the membrane interface is the upper radial boundary of the retentate domain, so there ∂/∂n=∂/∂r\partial/\partial n = \partial/\partial r, while it is the lower radial boundary of the permeate domain, so there ∂/∂n=−∂/∂r\partial/\partial n = -\partial/\partial r. The two conditions above look alike but therefore impose opposite-signed fluxes when written in terms of rr.

The notebook is divided into sections for parameter initialization, explicit coupling, and implicit coupling, ending with a check of the boundary conditions actually imposed at the interface.

Function to Compute and Print Mass Balances

This function calculates the mass flow rates at the inlet, outlet, and membrane interface for both the retentate and permeate sides. It also checks the overall mass balance to ensure conservation of mass.

Explicit Coupling

In this section, the retentate and permeate submodels are coupled explicitly. The coupling is achieved by iteratively updating the boundary conditions at the membrane interface.

<Figure size 640x480 with 2 Axes>
retentate side: inlet molar flow = 7.85398e-06, membrane molar flow out = 4.27200e-06, outlet molar flow = 3.58198e-06
retentate balance: 3.51519e-20
permeate side:  inlet molar flow = 0.00000e+00, membrane molar flow in  = 4.27200e-06, outlet molar flow = 4.27200e-06
permeate balance: -9.56463e-14
overall balance: 6.52794e-14

Implicit Coupling

In this section, the retentate and permeate submodels are coupled implicitly. The coupling is achieved by solving a single system of equations that includes the interface conditions.

<Figure size 640x480 with 2 Axes>
retentate side: inlet molar flow = 7.85398e-06, membrane molar flow out = 4.27200e-06, outlet molar flow = 3.58198e-06
retentate balance: -3.45166e-19
permeate side:  inlet molar flow = 0.00000e+00, membrane molar flow in  = 4.27200e-06, outlet molar flow = 4.27200e-06
permeate balance: -7.64363e-18
overall balance: -1.00873e-17

Checking the result

describe_bc prints a boundary-condition dictionary as the equation it actually imposes. bc_r_ret and bc_r_perm look symmetric (same a, b, d), but because pymrm boundary conditions always use the outward normal (pitfall P1), the sign of the flux term flips between the retentate (inner, upper rr boundary) and permeate (outer, lower rr boundary) sides.

Retentate side interface bc (upper r boundary):
lower (r=0, outward normal -r): -1*dc_ret/dr + 0*c_ret = 0  [Neumann]
upper (r=0.005, outward normal +r): 0.0001*dc_ret/dr + 0.002*c_ret = 0.002  [Robin]

Permeate side interface bc (lower r boundary):
lower (r=0.0055, outward normal -r): -0.00011*dc_perm/dr + 0.002*c_perm = 0.002  [Robin]
upper (r=0.007, outward normal +r): 1*dc_perm/dr + 0*c_perm = 0  [Neumann]