Migration from hoses

INRAe \ Olivier Vitrac

UMR 0782/Paris-Saclay Food and Product Engineering, Group modeling and engineering through calculation

UMT SafeMat/Safe Materials between AgroParisTech/INRAe and LNE.

Migration from hosesModeling instructionsSUMMARY1. NEW DOCUMENT2. GLOBAL DEFINITIONS3. GEOMETRY 13.1 Preparation3.2 Rectangle 1 (r1)3.3 Rectangle 2 (r2)4. ADD MATERIAL4.1 Define the liquid circulating through the hose (inner)4.2 Define the properties of the polymer in the hose walls5. LAMINAR FLOW (SPF)5.1 Domain selection and master equation5.2 Inlet5.3 Outlet6. SETTING THE PHYSICS OF MIGRATION (tds)6.1 Domain selection and master equation6.2 Transport properties 1 (initially for domains 1 and 2)6.3 Transport properties 2 (override for domain 2 hose)6.4 Partition condition (between 2 hose and 1 inner)6.5 Inflow 16.6 Outflow 16.7 Initial Values 1 (default value for 1 innerand 2 hose)6.8 Initial Values 2 (override for for 2 hose)6.9 Mass-Based Concentrations 17. Setting MESH: Mesh 17.1 Mapped 1 (1 inner)7.2 Mapped 2 (2 hose)8. STUDY 1Step 1: Stationary (spf)9. STUDY 2Step 1: Time Dependent (tds)10. PROBES10.1 Boundary Probe 110.2 Linear Projection 110.3 Variables 111. RUN Study 212. POST-PROCESSING12.1 Cut Line 2D 1 (middle)12.2 Cut Line 2D 1 (outlet)12.3 Cut Line 2D 1 (inlet)12.4 Cut Line 2D 1 (axis)12.5 1D plot group for middle12.6 1D plot group for outlet12.7 1D plot group for inlet12.8 1D plot group for axis13. PLOT VELOCITY PROFILE14. SENSITIVITY ANALYSIS15. EXPLORATION WITH MATLAB15.1 Launch Matlab with Comsol as a server15.2 Load a model15.3 Global parameters15.4 Extract concentration profiles along the hose15.5 Mass balance for probe1: integration of Jmig with time15.6 Mass balance from 2D concentration profiles15.7 Comparison of mass balances (flow and residual amounts)15.8 Launching calculations for different flow rates: 16. THIS TEMPLATE AS A MATLAB FUNCTION17. THE EXAMPLES AS A SINGLE SCRIPT

Modeling instructions

SUMMARY

This tutorial explains how to simulate migration from a cylindrical hose in presence of a laminar flow. The procedure has been designed for COMSOL Multiphysics 5.5. This version implements a partition boundary condition, which simplifies substantially the implementation and accelerates convergence.

The instructions and results are provided "AS IS". The full template is available both as a Comsol file and a Matlab file. Detailed Matlab examples are available as a script.

1. NEW DOCUMENT

In the New window, click Model Wizard .

  1. In the Model Wizard window, click 2D Axisymmetric.

2D

  1. In the Select Physics tree, select Fluid Flow>Single-Phase Flow>Laminar Flow (spf).
  2. Click Add.

Note: Velocity components are noted: spf.u (along ) and spf.w (along ).

  1. Click Study.
  2. In the Select Study tree, select General Studies>Stationary .

steady

  1. Go back to Physics.
  2. In the Select Physics tree, select Chemical Species Transport>Transport of Diluted Species (tds) .
  3. Click Add.

tds

Note: Concentration field will be defined in all domain as c with default units . The additional Time-Dependent problem cannot be set with the wizard

  1. Click Done.

As show on the horizontal bar, it is recommended to complete setting in the following order: Definitions, Geometry, Sketch, Materials, Mesh, Study. At this stage, save your project.

2. GLOBAL DEFINITIONS

  1. In the Model Builder window, under Global Definitions click Parameters 1 .
  2. In the Settings window for Parameters , locate the Parameters section.
  3. Click Load from File .
  4. Browse to the location of this template and double-click the file hose_parameters.txt.

parameters

Notations are standard (wit units between [ ]) and are summarized for convenience in Table 1. SI units and mol/volume units are used internally for concentrations.

Table 1. Short description of input parameters.

Entityrelated parameters
Hoseradii (, ), length ()
Circulating liquidComsol Multiphysics offers a database of materials (water, olive oil). Most of the properties (density with temperature) can be picked from there. However, some viscosities are missing. I included to fill the gap.
Flowflow rate: , initial/inlet concentrations , , pressure at the end of the hose: (it can be higher than the atmospheric pressure, if the hose is submerged in a liquid)
Polymerdenisty:
Solute: molecular mass, diffusivities: , ; partition coefficient (respectively to volume concentrations)

3. GEOMETRY 1

3.1 Preparation

  1. In the Model Builder window, under Component 1 (comp1) click Geometry 1 .
  2. In the Settings window for Geometry , locate the Units section.
  3. From the Length unit list, choose mm (or keep m, it affects only plots).

3.2 Rectangle 1 (r1)

  1. In the Geometry toolbar, click Rectangle.
  2. In the Settings window for Rectangle , locate the Size and Shape section.
  3. In the Width text field, type ri.
  4. In the Height text field, type L .
  5. Click Build Selected .
  6. Click the Zoom Extents button in the Graphics toolbar.
  7. Change the Label to inner. r1

3.3 Rectangle 2 (r2)

  1. In the Geometry toolbar, click Rectangle.
  2. In the Settings window for Rectangle , locate the Size and Shape section.
  3. In the Width text field, type re-ri.
  4. In the Height text field, type L.
  5. Locate the Position section. In the r text field, type ri.
  6. Click Build Selected.
  7. Click the Zoom Extents button in the Graphics toolbar.
  8. Change the Label to hose.

r2

4. ADD MATERIAL

4.1 Define the liquid circulating through the hose (inner)

  1. In the Home toolbar, click Add Material to open the Add Material window.
  2. Go to the Add Material window.
  3. In the tree, select Liquids and Gases>Liquids>Olive Oil .

oil

  1. Click Add to Component in the window toolbar.
  2. In the Home toolbar, click Add Material to close the Add Material window.
  3. Set the material active only for domain 1.
  4. Set the missing viscosity muF.
  5. Rename the material Food simulant.

F

Future modifications (override) of the liquid simulant can be carried out directly in the section Material Contents. Only the properties in connection with the simulated physics are shown.

4.2 Define the properties of the polymer in the hose walls

  1. In the Home toolbar, click Add Material to open the Add Material window.
  2. Go to the Add Material window.
  3. Search for polyethylene (or any other polymer, the Materials library needs to have been installed).
  4. Click Add Material
  5. Set the material active only for domain 2.
  6. Rename the material Polymer.

polymer

Note that viscosity may be active because we did not restrict the flow to domain 1

5. LAMINAR FLOW (SPF)

5.1 Domain selection and master equation

  1. In the Model Builder window, under Component 1 (comp1) click Laminar Flow (spf).
  2. In the Settings window for Laminar Flow , locate the Domain Selection section.
  3. From the Selection list, remove 2 (hose) and be sure to pick only domain 1 (inner)
  4. Set Temperature to 313.15 K (standard temperature used in migration testing).

spf

Note that the flow is weakly compressible and that the same model could be used in industrial setups.in

5.2 Inlet

  1. In the Physics toolbar, click Boundaries and choose Inlet.
  2. Select Boundary 3 (top) only.
  3. In the Settings window for Inlet , locate the Boundary Condition section.
  4. From the list, choose Fully developed flow.
  5. Locate the Fully Developed Flow section. In the flow rate field (), set Q.

inlet

5.3 Outlet

  1. In the Physics toolbar, click Boundaries and choose Outlet.
  2. Select Boundary 2 only.
  3. Set pressure at the boundary equal to Patm

outlet

6. SETTING THE PHYSICS OF MIGRATION (tds)

6.1 Domain selection and master equation

  1. Check that the domains 1 (inner) and 2 (hose) are selected.
  2. Since no study has been defined yet, choose time-dependent.
  3. Verify that convection is checked as transport mechanism

tds

Note that we have only one single species, but several could be added.

6.2 Transport properties 1 (initially for domains 1 and 2)

  1. In the Physics toolbar, select Transport properties 1 (you cannot restrict the properties to a specific domain at this stage).
  2. Select spf as velocity field
  3. Type Df as diffusion coefficient.

tp1

 

6.3 Transport properties 2 (override for domain 2 hose)

  1. In the Physics toolbar, right click on Transport of Diluted Species, add Transport properties
  2. Select domain 2 (hose)
  3. Type Dp as diffusion coefficient

tp2

6.4 Partition condition (between 2 hose and 1 inner)

  1. In the Physics toolbar, right click on Transport of Diluted Species, add Partition condition
  2. Select boundary condition 4
  3. Type Kfp as partition coefficient
  4. Check reverse direction

K

6.5 Inflow 1

The inflow may contain some amount of migrants (e.g., connected pipes)

  1. In the Physics toolbar, right click on Transport of Diluted Species, add Inflow.
  2. Select boundary condition 3.
  3. Type Cfin as inflow concentration

inflow

6.6 Outflow 1

The outflow is a free flow such as if the leaving liquid was pouring without contact in a beaker/recipient.

  1. In the Physics toolbar, right click on Transport of Diluted Species, add Outflow.
  2. Select boundary condition 2

outflow

6.7 Initial Values 1 (default value for 1 innerand 2 hose)

  1. Type Cf0 as initial values

IC1

6.8 Initial Values 2 (override for for 2 hose)

  1. In the Physics toolbar, right click on Transport of Diluted Species, add Initial Values.
  2. Select domain condition 2 (hose)
  3. Type Cp0 as **initial concentration.

IC2

6.9 Mass-Based Concentrations 1

This step enable to get mass concentration available (). Mass concentration will be available as tds.cmass_c.

  1. Type M as Molar Mass

mass

 

7. Setting MESH: Mesh 1

A mapped mesh is required for stability and efficiency. Do not use triangular mesh.

7.1 Mapped 1 (1 inner)

  1. In the Model Builder window, right-click Mapped 1 and choose Distribution.
  2. Select Boundaries 2 and 3 only.
  3. In the Settings window for Distribution , locate the Distribution section.
  4. From the Distribution type list, choose Predefined.
  5. In the Number of elements text field, type 20.
  6. In the Element ratio text field, type 25.

md1

  1. In the Model Builder window, right-click Mapped 1 and choose Distribution.
  2. Select Boundaries 1 and 4 only.
  3. In the Settings window for Distribution , locate the Distribution section.
  4. From the Distribution type list, choose Number of elements of elements.
  5. In the Number of elements text field, type 50 .

md2

7.2 Mapped 2 (2 hose)

  1. In the Model Builder window, right-click Mapped 1 and choose Distribution.
  2. Select Boundaries 5 and 6 only.
  3. In the Settings window for Distribution , locate the Distribution section.
  4. From the Distribution type list, choose Predefined.
  5. In the Number of elements text field, type 30.
  6. In the Element ratio text field, type 25.
  7. Check reverse order direction (we need a good resolution towards inner).

md3

  1. In the Model Builder window, right-click Mapped 1 and choose Distribution.
  2. Select Boundaries 1 and 4 only.
  3. In the Settings window for Distribution , locate the Distribution section.
  4. From the Distribution type list, choose Number of elements of elements.
  5. In the Number of elements text field, type 50 .

md4

8. STUDY 1

Step 1: Stationary (spf)

  1. In the Model Builder window, under Study 1 click Step 1: Stationary.
  2. In the Settings window for Stationary , locate the Physics and Variables Selection section.
  3. In the table, clear the Solve for check box for Transport of Diluted Species (tds), keep only spf.
  4. In the Study toolbar, click Compute .

spf

Clearing Transport of Dilutes Species remove the definitions of tds during the resolution of spf at steady-state.

 

9. STUDY 2

Step 1: Time Dependent (tds)

  1. In the Study toolbar, click Study Steps and choose Stationary>Time dependent.
  2. Choose min as Time unit.
  3. Enter ({range(0,0.05,sqrt(10000))})^2 as Times to mimic diffusion time scale.

study2

Keep spf, if not the velocity flow will not be available to calculate tds.

10. PROBES

We need probes and additional variables to retrieve easily results.

The preferred quantity to understand mass transfer (migration) under various flow conditions is amount of transferred substance in or .

10.1 Boundary Probe 1

  1. Type migration rate as label.
  2. Type Jmig as name.
  3. Choose Integral as Probe Type.
  4. Select Boundary 2 only.
  5. Enter -tds.tflux_cz*M as Expression.
  6. Keep checked Compute surface integral (as we use cylindrical coordinate system, the expression will be multiplied by ).

probe

TIP: Probes will be plotted during integration of PDE system. The names of available internal variables can be listed with the tool with the two triangles (red and green) near the Expression title. -tds.tflux_cz is the total (convective+diffusive flux) along .

10.2 Linear Projection 1

Projection is used to get the linear profile along the hose. The projection is defined from a source plane (defined by 3 vertices) onto a line (defined by 2 vertices). The so-defined is operator will be available as linproj1() in subsequent calculations.

  1. Select domain 1 (inner).
  2. Pick 2,4,3 as Source Vertices.
  3. Pick 2,1 as Destination Vertices.

linproj

10.3 Variables 1

A new variable Jmigz is created and will be available for post-processing and plotting. It is defined as the amount of substance crossing the hose at the position . Note that this amount is originating from all the positions above and in a less extent (negligible) from below by diffusion.

  1. Type Jmigz as label.
  2. Enter linproj1(-tds.tflux_cz*M) as Expression.
  3. Type J profile along z as Description.

vars

11. RUN Study 2

  1. Run once Study 1 if you forget.
  2. Run Study 2.

proberesult

During calculations, probe 1 (migration rate) is shown as well as tabulated values. The calculations are completed in 24 s on .

table

conc3D

 

Default plots are generated at the end of the simulation.

12. POST-PROCESSING

Plot concentration profiles along lines.

12.1 Cut Line 2D 1 (middle)

  1. Type middle as label.
  2. Choose Study2/.... as Dataset.
  3. Type 0 and L/2 for Point 1.
  4. Type ri+re and L/2 for Point 2.

line1

 

12.2 Cut Line 2D 1 (outlet)

  1. Type outlet as label.
  2. Choose Study2/.... as Dataset.
  3. Type 0 and 0 for Point 1.
  4. Type ri+re and 0 for Point 2.

Note that this line is also available as a boundary.

12.3 Cut Line 2D 1 (inlet)

  1. Type inlet as label.
  2. Choose Study2/.... as Dataset.
  3. Type 0 and L for Point 1.
  4. Type ri+re and L for Point 2.

Note that this line is also available as a boundary.

12.4 Cut Line 2D 1 (axis)

1 Type axis as label. 2 Choose Study2/.... as Dataset. 3 Type 0 and L for Point 1. 4 Type 0 and 0 for Point 2.

Note that this line is also available as a boundary.

12.5 1D plot group for middle

1 Type 1D middle cross-section as label. 2 Choose middle as Dataset. 3 Choose Interpolated as Time Selection 4 Type range(0,100,10000) as Times.

middleplot

5 Add a line graph in Results>1D middle cross-section 6 Type tds.cmass_c as expression 5 Click plot (top left icon in the settings section)

middleprofile

12.6 1D plot group for outlet

  1. Type 1D outlet cross-section as label.
  2. Choose outlet as Dataset.
  3. Click plot (top left icon in the settings section)

outletplot

12.7 1D plot group for inlet

The differences between middle and outlet are very small but now look at inlet profiles.

  1. Type 1D inlet cross-section as label.
  2. Choose inlet as Dataset.
  3. Click plot (top left icon in the settings section)

inletplot

12.8 1D plot group for axis

  1. Type 1D axis profile as label.
  2. Choose axis as Dataset.
  3. Choose Interpolated as Time Selection
  4. Type range(0,100,10000) as Times.

axisgrp

  1. Add a line graph in Results>1D axis cross-section
  2. Type Jmig as expression
  3. Click plot (top left icon in the settings section)

axisplot

13. PLOT VELOCITY PROFILE

  1. Type 1D Velocities as label.
  2. Choose Study 1/Sol.... as Dataset.
  3. Add a line graph in Results>1D Velocities
  4. Select boundary 2 (outlet).
  5. Type spf.U as expression.
  6. Check reversed arc length (boundaries are oriented; by reversing it the interface is on the right).
  7. Click plot (top left icon in the settings section)

velocityprofile

We check that the profile is parabolic.

14. SENSITIVITY ANALYSIS

Calculations are really fast and many configurations can be tested. The problem simulated here is known as Graetz problem. It is particularly useful to understand as a 1D model including a mass transfer resistance at the boundary can achieve similar results or at least overestimate previous results.

  • Further discussion pending.

  • In further analyses, it is encouraged to introduce the Graetz number, whose reciprocal value expresses the relative distance from the entrance/inlet, where mass transfer are affected by the flow. Beyond this value, the concentration profiles are fully developed (i.e., the length of the mass boundary layer ).

    As a rule of thumb, the concentration profiles can be considered fully developed as soon as or better .

15. EXPLORATION WITH MATLAB

15.1 Launch Matlab with Comsol as a server

15.2 Load a model

>>

Solution 'sol1' with datasets: 'dset1' Solution 'sol2' with datasets: 'dset2' 'dset3'

mphnavigator

nav

Note the buttom copy at the bottom left to copy the path as a Matlab command. Some outputs remain Java objects and require to be converted in proper Matlab types.

mphsearch

search

The search engine enables to identify the path and properties of any quantity. The depicted object tbl1 contains the data of the probe1 (Jmig).

figure, mphgeom(model)

geom

Note that the inlet is in top position () and the outlet at the bottom ().

params = mphgetexpressions(model.param)

params =

14×5 cell array

15.3 Global parameters

We need to extract the main parameters of the model to interpret the simulation results.

15.4 Extract concentration profiles along the hose

Concentrations profiles along the hose between (inlet) and (outlet) with a step equal to and 20 time steps chosen on square-root time scale.

concprof

The layout is defined by mphplot().

15.5 Mass balance for probe1: integration of Jmig with time

Comsol calculates surface integrals more accurately than Matlab can do as it as access to the original mesh. It is, however, much easier to carry out post-processing calculations directly in Matlab. The code below calculates the total amount of solute, which has left the hose through the outlet.

IntJmig

15.6 Mass balance from 2D concentration profiles

The 2D concentration profiles in inner and hose are interpolated on a regular grid. Successive integrations are applied to carry out a full mass balance.

Note that the calculations and the comparison with Jmig.M neglects the amount of solute in inner.

>>

maximum mass balance error (flow vs residual) 1.79% (theoretical: -0.00543%)

conc2D

It is obvious that the effects of radii ( and ) cannot be extrapolated from one single simulation. By contrast, the effect of and can be easily extrapolated from a sufficiently long hose and sufficiently long simulations. This feature is shown as iso-migration contours with (contact time) and (length).

Note that the vertical coordinate has been replaced by to get the inlet at the position . The following figure describes the relative loss of solute for each section according to its position respectively to the inlet.

isomig

15.7 Comparison of mass balances (flow and residual amounts)

Note that the amount of solute in the fluid (in inlet) is neglected at each time. As a result, the red curve (from residual concentration) is above the blue one (from the flow leaving through the outlet).

cmpmassbalances

15.8 Launching calculations for different flow rates:

Use the following script as a template to study other effects. Execution time can be beyond 10 min, adjust the number of flow rates before launching it.

Changing the flow rate requires to restart std1.

flowrates

The results confirm previous analysis, increasing flow rate (for a same hose) reduces the effect of (solubility is limiting in these simulations). Simulations evolve from a linear shape (low values) to the typical kinetics vs the square-root of time (high values). The upper limit is a kinetics in a closed system for (Dirichlet condition forcing the concentration to be 0 at the interface). The linear shape can be obtained in closed-systems with low mass Biot numbers ( with ) .

16. THIS TEMPLATE AS A MATLAB FUNCTION

This template is provided for convenience as a Matlab function

17. THE EXAMPLES AS A SINGLE SCRIPT

For convenience, the detailed examples above are given as a single script. Be patient, if you run it at once.

Do not forget to launch Matlab with Comsol as a server.See instructions in 15.1.