Anda di halaman 1dari 14

AC 274 Tutorial (Fall 2017):

Simulating Coupled Heat Transfer and Fluid Flow


in Comsol
The Rayleigh-Bénard Cell for PCR

1 Introduction
We will be going through a computational exercise to demonstrate the principles of heat
transfer (convection) and fluid flow (laminar). As an example, we will simulate a Rayleigh-
Bénard (RB) convection cell used for performing PCR [1] in a single cell. To begin with,
we will review the basic principles of convective heat flow and fluid dynamics. The sections
below heavily borrow the theory material from Ref. [2], so you are encouraged to read
through Ref. [2] for additional details if interested. In our exercise we will build a model
of the RB cell in Comsol and solve the coupled heat/fluid flow problem using the finite-
element method. The end goal of this exercise is to understand some important parameters
for designing a single-cell PCR device using a RB convection cell.

1.1 Basics of Convective Heat Transfer


Convective heat transfer is commonly described by the Newton’s law of cooling (or heating)
which states that the rate of change of temperature of an object is contact with a fluid is
proportional to the difference of the temperature of the object and the surrounding fluid.
Mathematically, this is described by a ordinary linear differential equation shown below
[3].
dT
= α(T − Tsur ) (1)
dt
Here, T is the temperature we want to solve for, Tsur is the temperature of the surrounding
fluid and α is the constant of proportionality. This differential equation can easily be solved
analytically if the temperature at t = 0 and Tsur is known and provides a good model of
convective heat flow. However, Newton’s law of cooling (or heating) is a phenomenological
model and works well only under certain assumptions. For example, the thermal conduc-
tivity of the object has to be much greater than that of the surroundings and the object is

1
assumed to be homogeneous in temperature. Also, at very short time scales Newton’s law
of cooling gives large errors.
A more general approach is to solve the heat equation in a fluid,1 which is a second
order partial differential equation. Unlike the phenomenological Newton’s law from the
previous section, the heat equation can be derived directly from first principles. The heat
equation, also known as the equation of thermal energy, is essentially a form of the energy
conservation principle, which states that the rate of change of total thermal energy is equal
to the rate of exchange of heat flux (conduction), the rate of change of energy due to
convection and pressure variations (compression or expansion), and the rate of change of
energy due to viscous dissipation. Mathematically, we can write this as shown below.

∂U
ρ + ρ~v (∇U ) + ∇ · ~q
∂t} | {z } | {z }
rate of change of
| {z
rate of change of
rate of change of energy from convection energy from conduction
total thermal energy

+ p(∇ · ~v ) + |τ :{z∇~v} = 0 (2)


| {z }
rate of change of energy from rate of change of
compression/expansion energy from viscous dissipation

Here, ρ is the density, ~v is the velocity, p is the pressure, and τ is the viscous stress tensor
of the fluid.2 The thermal energy is denoted by U and the heat flux is given by ~q. We can
obtain more useful information from this equation if we write U in terms of T in Eq. (2),
which gives us the following heat equation [2].

∂T
ρC( + ~v ∇T ) = κ∇2 T − T α∇ · ~v − τ : ∇~v (3)
∂t
Here, C is the specific heat, α is the coefficient of thermal expansion, and κ is the thermal
conductivity. We have also used Fourier’s law i.e. κ∇2 T = −∇ · ~q to write the heat flux,
q, in terms of temperature, T . Now, we have the heat equation in terms of variables and
constants that can be physically measured, thus making a very useful form for engineering.

1.2 Basics of Fluid Dynamics


Just like the heat equation being a form of conservation of energy, we can reformulate the
conservation of momentum for a fluid to create an equation of motion. This basic equation
for fluid motion is the well-known Naviér-Stokes equation [4, 2]. Momentum conservation
1
We will revisit the equations below when we model the coupled heat/fluid flow problem in Comsol.
2
the colon operator in the term τ : ∇~v is known the double dot product, which produces a scalar from
the multiplication of two tensors.

2
for a fluid can be written as follows.

ρ∂~v
+ ∇ · ρ~v~v + ∇p
∂t | {z } |{z}
|{z} rate of change of pressure
rate of change of total momentum by convection force
linear momentum
+ ∇ · τ}
| {z − ρ~g = 0 (4)
|{z}
rate of change of gravitational
momentum by viscous transfer force

Here, ~g is the acceleration due to gravity. Note that τ and the dyadic product ~v~v are
tensors. By expanding the dyadic product, i.e. ∇ · ρ~v~v = ρ~v (∇ · ~v ) + ~v (∇ · ρ~v ), we can
rewrite Eq. (4) in a more commonly used form of the Naviér-Stokes equation as shown
below.
∂~v
ρ + ρ~v (∇ · ~v ) = −~v (∇ · ρ~v ) − ∇p − ∇ · τ + ρ~g (5)
∂t

1.3 Heat Transfer Coupled to Fluid Flow


In order to solve the coupled heat transfer and fluid flow problem we would need to solve
Eqs. (3) and (5). However, you might notice that Eq. 3, a scalar equation with the variables,
~v (fluid velocity) and T (temperature), and Eq. 5, a vector equation with the variables ~v and
p (pressure), together give us four equations with five unknowns – the three components of
velocity (vx , vy , and vz ), pressure, and temperature. Therefore, to be able to solve for the
dependent variables we need more information. We can use the principle of conservation
of mass, which leads us to the continuity equation as shown below.

+ ∇ · ρ~v = 0 (6)
dt
Eq. (6) simply states that the rate of accumulation of mass is equal to the rate of net
mass flowing in. Now, with Eqs. (3), (5), and (6), we have fully formulated the coupled
problem of heat transfer in a flowing fluid. The question now is, how do we solve these?
You probably can tell that it might not be easy to solve these equations analytically. In
fact, as far as we know, there does not exist a general analytical solution to these equations
without using simplifying assumptions. That is where computational methods come to our
rescue.

1.4 Overview of Computational Techniques


There are different numerical methods to solve any set of equations as you have learnt in
this course. For the coupled heat/fluid flow equations, one technique is to use the Taylor
series expansions for the partial derivatives and write these equations in forms of simple
difference equations (finite-difference method) that could be solved for small steps in time

3
one after the other repeatedly (finite-difference time-domain method). The finite-difference
method is intuitively simple but becomes computationally demanding when the shapes of
the objects are complicated. Another popular method is by converting the differential
equations to their so-called weak forms by rewriting them in an integral form and dividing
the domain into small elements to set up a bunch of linear equations that can be solved
iteratively (for example using the Newton-Raphson method). This is known as the finite-
element method.
Choosing which method to use often depends on the computational resources at hand
and the kind of problem we are solving. For example, for simple rectilinear objects the
finite-difference technique is often desirable for its simplicity. Also, for time-dependent
problems, the finite-difference can be simpler to implement. On the other hand, for complex
shaped objects and steady-state analysis, the finite-element method works better. There
has been considerable advances in the area of finite-element time-domain, which can be
robust for strong time-dependent analysis where complicated geometries are involved. It
should be noted that with the increase in available computational resources, advances have
been made on particle-based simulations of fluids, where the fluid is simulated by collective
interactions between fictitious fluid particles. The lattice Boltzmann method is one an
example of such a technique. These particle-based methods can be superior in simulating
multiphase fluid problems, such as mixing of different fluids.
The Comsol Multiphysics software, as you might be aware, is based on the finite-
element method and provides a very convenient way to couple and solve partial differential
equations from different areas of physics. Comsol also provides an interface to create
geometric models and therefore not requiring any additional CAD software. So, for the
purpose of this exercise, we will be using Comsol and the sections below provide the steps
that we will perform to model the RB cell.

2 Simulating Heat Transfer and Fluid Flow in Comsol


This document by no means can cover all the basics of Comsol. For that please refer to
the Comsol Reference guide (you can find this via help within the Comsol application, or
the doc folder inside the directory where Comsol is installed, or simply search on the web).
Here, we will focus only on the parts of Comsol that we will be using for simulating a RB
convection cell.
In this section, we will look at the two physics interfaces that we need to couple –
the fluid flow module and the heat transfer module. Start a new Comsol session with the
Model Wizard and select a geometry (you can select either a three dimensional or a two
dimensional geometry since at this point we are only concerned with the physics modules).
There are multiple ways to setup a coupled heat/fluid flow problem in Comsol (see Fig. 1).
Here, we picked the option (b) from Fig. 1, but you can create the same model using the
other options and are encouraged to try all of the different ways if interested. Select the

4
(a) (b) (c)

Figure 1: Selecting the appropriate physics modules. We can select pre-coupled physics modules
such as (a) Fluid Flow → Nonisothermal Flow → Laminar Flow or (b) Heat Transfer → Conjugate
Heat Transfer → Laminar Flow, where the multiphysics node coupling fluid flow with heat flow is
automatically added. We can also manually couple individual physics nodes by selecting (c) Fluid
Flow → Laminar Flow and Heat Transfer → Heat Transfer in Fluids, and then add a multiphysics
node to couple the equations.

5
appropriate physics modules (see Fig. 1) and then click Study. For now, select a time
dependent study, although at this point we will not perform a study.
In order to get an overview of what Comsol will be solving behind the scene when we
eventually click Compute, we will first take a look at the equations within the relevant
physics modules. Once the appropriate physics modules are selected, you will see a Model
Builder tree in a panel on the left hand side of the application. In this tree, go to Component
1 → Heat Transfer → Fluid 1. With Fluid 1 selected look at the Equation node in the
Settings tab (see Fig. 2a) to find the equation for heat transfer. Similarly, to find the
equations for fluid flow, go to Component 1 → Laminar Flow → Fluid Properties 1. In the
settings tab open the Physical Model node and select Include gravity. Open the Equation
node and find the relevant equations (see Fig. 2b).

(a) The equation for the heat transfer in fluids module.

(b) The equation for laminar fluid flow module.

Figure 2: Identifying the different terms in the equations that the physics modules in Comsol are
solving.

Try to identify and compare the different terms in the equations that Comsol is solving
with Eqs. (3), (5), and (6). Note that the last term on the RHS in the equation in Fig. 2a
(Qvd ) contains the viscous dissipation term of Eq. (3). Also note that the first term on

6
the RHS in the first equation in Fig. 2b is simply an expansion of the stress tensor (τ ) in
Eq. (5).

3 Rayleigh-Bénard Convection Cell and the PCR


A Rayleigh-Bénard (RB) convection cell is a system where a fluid is flowing in a confined
space where it is being heated from below and cooled from above (the below and above are
with respect to the acceleration due to gravity). Real world examples – a pan with water
being heated on a stove or a lava lamp. This simple system of RB convection manifests
a surprising number of interesting phenomena, from stable convection to instabilities and
turbulence to spatiotemporal chaos. A simple RB cell can be modeled as a rectangular box
with a hot temperature boundary on the bottom and a cold temperature boundary on the
top plane. The vertical walls of the box can be assumed to be insulating, such that there
is no heat flux across them.
PCR, or the polymerase chain reaction is a robust way to efficiently replicate DNA and
therefore a valuable tool for molecular biologists and for medical diagnosis. A PCR process
involves a reaction volume that contains a DNA template, primers, enzymes, and a buffer
solution. The DNA template starts off as a regular double stranded DNA where the two
strands are held together by hydrogen bonds. At the denaturing temperature, which is
usually a high temperature, it separates into two single strands. At a lower temperature,
the primers bind to specific regions of the single strands and at an intermediate extension
temperature, the enzymes recreate a double-stranded DNA. So, in one cycle, we go from
a one double-stranded DNA to two single-stranded DNAs to two double-stranded DNAs.
Although the chemical reactions involved with denaturing, annealing, and extension are
very fast, typically a single cycle takes 30–60 s. If the flow is too slow, the molecules
could be lost from circulation due to diffusion, on the other hand, with a flow that is
too fast, there might not be enough time for the reactions resulting in longer times for
amplification. This process can be repeated a number of times for DNA replication. The
typical denaturing, annealing, and extension temperatures are 90–96 ◦ C, 55–60 ◦ C, and
72–75 ◦ C, respectively.
Thus, to use a RB convection cell for PCR, we must achieve the following:

1. Stable, steady-state convective flow in the RB cell.

2. Temperature distributions in the cell with regions having the ranges specified above.

3. A cell volume that will allow convective flow at time scales of ∼ 30 s.

This list above will serve as the design goals for our simulations.

7
4 Simulating a RB Cell for PCR in Comsol
We will be modeling a RB cell that is like the one shown in the Figure 1 of Ref. [1] (See
Fig. 3). We could model the RB cell as a three dimensional box with the bottom heating
plate, top cooling plate, and the side glass walls. However, we can safely assume that the
vertical walls are ideally insulating and the top and bottom planes are able to maintain a
constant uniform temperature. Let’s also assume that the depth of the box is much larger
than the width or the height. With these assumptions we can simplify our model to two
dimensions by simply simulating a 2D slice of the rectangular box. Follow the steps below
to setup a simulation of a RB cell for PCR in Comsol.

Figure 3: Schematic of the RB cell that we will model for PCR (from Fig. 1A of Ref. [1]).

1. Start a New file in the Comsol Application using the Model Wizard. Select 2D for
the Space Dimension and add Heat Transfer → Conjugate Heat Transfer → Laminar
Flow physics modules. Click on Study, select Time Dependent, and then click Done.
Now, you will see the Model Builder tree on the left most panel in the application.
We will exclusively use this tree to edit the model, however, you can also use the
buttons in the interface or the items from the drop-down menus.3

2. Right-click the Global Definitions node in the Model Builder tree and select Parame-
ters. We will add parameter constants to be used to define our model. Later on, you
will see how we can use these parameter definitions to perform parameter sweeps.
Enter the parameters given in the table below (the “–” means don’t enter anything).

3
It is assumed that you will keep saving your work regularly, since Comsol can be a bit crash prone if
you have memory constrains.

8
Table 1: Global parameter list for RB cell

Name Expression Value Description


H cell 6[mm] – height of the cell
AR 0.5 – aspect ratio of the cell
W cell H cell/AR – width of the cell
T hot 97[degC] – temperature at the bottom
T cold 61[degC] – temperature at the top

3. Right-click on the Geometry node and select a rectangle. In the Settings tab find
the Size and Shape node and enter W cell in the Width and H cell in the Height.
Now click Build All Objects to create the rectangle. This rectangle represents two
dimensional slice at a fixed depth through the interior of our 3D RB cell.

4. Next, right-click on the Materials node and select Add Material from Library. Find
the material data for water in the material library under Liquids and Gases → Liquids
→ Water. Now, with Water selected click on the Add to Component button (you
can always also right-click and find the same action).

5. Moving to the physics nodes, expand the Heat Transfer node. We, first have to
specify which parts of our model are solid and which parts are fluids. Since, we
do not have any solid object, select the Fluid 1 node. In its Settings tab, find the
Domain Selection node and make sure that it is Active and the Selection drop-down
menu has Manual selected. Select the entire rectangle by clicking on it. Note, in this
case, we could have also chosen All domains from the drop-down menu since in our
model we only have a single domain. Also, note now that if you select the Solid 1
node, you will find that the Domain Selection box will say (overridden).

6. Let’s now define the boundary conditions4 for the Heat Transfer module. By default,
Comsol applies thermal insulation boundaries, i.e. no heat flux crossing the edge, on
all edges. For the vertical walls we do want thermal insulation boundaries. However,
we want to specify the temperature at the bottom and the top, so we have to change
the boundary conditions on those two edges. Right-click the Heat Transfer node
and you will find all possible boundary conditions. Select Temperature and a new
Temperature 1 node will be added to the Heat Transfer node. In the Settings tab
of the Temperature 1 node, find the Boundary Selection node, make sure its Active
and Manual, and then click on the bottom edge of the rectangle to select it (The
4
An important side note: Boundary conditions are perhaps the single most important part of solving
differential equations that turn a general differential equation into the specific problem that you want to
solve. So, always double-check and make sure your boundary conditions are correctly specified.

9
edge turns blue when selected). Now, in the Temperature node of the Settings tab,
make sure the drop-down menu is showing User defined and in the box enter T hot.
Repeat the above instructions to add a second Temperature boundary condition on
the top edge with the temperature being T cold.

7. Moving down the ladder in the Model Builder tree, select the Laminar Flow node.
In the Settings tab, locate the Physical Model node and make sure Include gravity is
selected (It is not selected by default). When you select Include gravity, you need to
provide Reference Values, i.e., a reference pressure, temperature, and position. We
can keep the reference pressure and temperature at their default values, but change
the reference x and y positions to W cell and H cell, respectively. Also, change the
Compressibility drop-down menu item to Incompressible flow. By selecting Incom-
pressible flow along with Include gravity, we are essentially making the Boussinesq
approximation, where we assume that density variations in the fluid are negligible
expect in the gravitational force term.

8. Since, our cell volume is not very large, we don’t expect there to be large pressure
variations within the fluid. However, the small pressure variations are important for
fluid flow and we do want to accurately calculate the velocity variations in the fluid.
One way to increase the accuracy of a finite-element simulation is to increase the
order of the discrete elements (by default, Comsol creates first-order elements), but
increasing element orders comes at the cost of memory and speed of computation.
So, we strike a balance by using second-order elements for calculating the velocity
and first-order elements for calculating pressure. In order to do that, first, click
on the Model Builder view and select Discretization (this is unselected by default).
Now, when you select the Laminar Flow node, in its Settings tab, you will find a
new Discretization node. Expand this node and from the drop-down menu, select
P2+P1. This will generate second order elements for velocity and first-order elements
for pressure.

9. The default boundary condition for Laminar Flow is the wall boundary, which is
what we need in this case, since the fluid is confined within the box. Select the Wall
1 node in Laminar Flow and take a look at the Settings tab. Make sure that all the
edges are selected in the Boundary Selection node and that the Boundary Condition
node has the Wall condition at No slip. These are all true by default.

10. Now, there is one last boundary constraint we need to add, which is not quite initially
obvious. Select the Laminar Flow node and in its Settings tab, expand the Dependent
Variables node. You will find that the unknowns being solved for are three velocity
components and pressure (see also Sec. 1.3). Now, let’s revisit the equations for fluid
flow [see Fig. 2b, also see Eq. (5)]. In these equations, we find that the variable
pressure only appears after a spatial derivative operator (∇). Therefore, unless we

10
specify the pressure at some point on the boundary, we will not be able to calculate
the spatial derivative.5 In order to specify the pressure at a point, right-click on the
Laminar Flow node and from the Points section, select the Pressure Point Constraint.
This will create a new Pressure Point Constraint 1 node. In its Settings tab, expand
the Point Selection node and click on the bottom right vertex of the rectangle. Now,
for this point, we will specify a pressure of 0[atm] in the Pressure Constraint node.
Note that is the gauge pressure were are providing not the absolute pressure.

11. With the boundary conditions set, we can move to the Multiphysics node in the
Model Builder tree. Expand the Multiphysics node and select the Nonisothermal
Flow node. In its Settings tab, expand the Flow Heating node and check the boxes
for Include work done by pressure changes and Include viscous dissipation. At this
point, all the relevant physics has been implemented in the model.

12. Select the Mesh node in the Model Builder and take a look at the Settings tab. We
will keep the default mesh settings. Click Build All and notice the shape of the finite
elements. At the boundaries the elements are rectangular and small. As we move to
the interior of the domain the elements increase in size and are triangular in shape.
The rectangular elements are shown to be more accurate near the boundaries for fluid
flow problems, while triangular elements can fill any region of space more accurately
than rectangular shapes.

13. Expand the Study node and click on the Time Dependent node. In its Settings tab,
expand the Study Settings and in the Times box enter range(0,1,120) (This will run
the simulation for 120 s while saving results every second). OK, we are now done
with setting up the simulation. Go ahead and click Compute.

5 Results and Discussion


The temperature and velocity distribution in the RB cell at 120 s is shown in Fig. 4. Since,
we solved the time-dependent equations, we can plot the temperature/velocity distributions
at each of the time points we specified, or even better create a animation or gif. Expand
the Results node in the Model Builder and right-click on the Export node. You will find
an Animation option under which you can create an animation that can be played within
Comsol (Player ) or create a movie or gif (file). For now, let’s just create an animation by
selecting Player. A new node called Animation 1 will be created. In its Settings tab, find
and expand the Scene node and from the Subject drop-down select Temperature. Also, in
the Frames node from the Frame selection drop-down, select All. Lastly, in the Advanced
node, uncheck the Synchronize scales between frames. Now, in the Graphics tab on the
right side, click the play button. You can follow the same steps to create an animation for
5
If we do not specify the pressure at any point then the solution will not converge.

11
the velocity distribution. Does this RB cell satisfy the three important requirements for
PCR applications that we stated in Sec. 3? Clearly, the convective flow is not very stable
and does not allow stable temperature regions. So, let’s tweak our design and try to search
for an aspect ratio that will satisfy our design goals.

5.1 Optimizing the Cell Aspect Ratio


Since, we have already defined the aspect ration (AR) as a parameter, we can run a single
simulation where we sweep over a range of values of AR. This is what Comsol calls a
Parametric Sweep. To setup a parameter sweep, right-click on the Study 1 node in the
Model Builder tree and select Parametric Sweep. Now, in the Settings tab of the Parametric
Sweep node, expand Study Settings. Click on the add button (+) to add a new parameter,
and choose AR from the list of parameters. In the Parameter value list enter 0.5 1.5 2.5
3.5 4.5 [you could also specify the same list using the function range(0.5,1,4.5)]. Finally,
click Compute.

12
(a) Temperature distribution at 120 s.

(b) Velocity distribution at 120 s.

Figure 4: Results from the time dependent simulation of a RB cell showing (a) temperature and
(b) velocity distributions at 120s.

13
References
[1] M. Krishnan, M. V. Ugaz, and M. A. Burns, “PCR in a Rayleigh-Bénard Convection
Cell,” Science, 298, 2002

[2] R. Byron Bird, Warren E. Stewart, and Edwin N. Lightfoot, Transport Phenomena,
John Wiley & Sons, Inc., New York, 1966.

[3] Theodore L. Bergman, Adrienne S. Lavine, Frank P. Incropera, and David P. Dewitt,
Introduction to Heat Transfer, John Wiley & Sons, Inc., 2011

[4] Frank M. White, Fluid Mechanics, McGraw-Hill, 1999

14

Anda mungkin juga menyukai