1

Intro to Finite Element
Modeling & COMSOL
(a mini-course)
CEE-268, Winter 2006
By Michael Cardiff
2
What is a model?
Straight from the OED:

“a system or thing used as an example to
follow or imitate - a simplified description,
especially a mathematical one, of a system or
process, to assist calculations and
predictions.”
3
What is a numerical model?
A model which estimates the solution to a “hard”
problem (usually a set of PDEs) through
numerical approximations.
A finite-difference example
2
2
2
÷ =
c
c
x
y
0 ) 1 (
0 ) 0 (
=
=
y
y
x = 0
y = 0
x = 1
y = 0
?
Analytical Solution:
1. Integrate the
expression using
calculus tricks

2. Plug in BC’s to get
values for integration
constants
A finite-difference example
2 ) ( ' '
2
1 2 3 5 . 1 5 . 2
) (
2 ) ( ' ) ( '
2
÷ = ~ ~
A
+ ÷
A
÷
x
y y y
x
x y x y
x y
x
y y
x y
A
÷
~
1 2
) ( '
5 . 1 x
y y
x y
A
÷
~
2 3
) ( '
5 . 2
x
4
x
0
x
1
x
2
x
3

x A
?
Numerical Solution:
1. Approximate
derivatives using
numerical tricks

2. Write all equations into
a single matrix and
solve.
A finite-difference example
0 ) (
0 ) (
) ( 2 2
... 1
1 1
0 0
2
1 1
= =
= =
A ÷ = + ÷
=
+ +
+ ÷
n n
i i i
x y y
x y y
x y y y
n i f or
(
(
(
(
(
(
¸
(

¸

A ÷
A ÷
A ÷
A ÷
=
(
(
(
(
(
(
¸
(

¸

(
(
(
(
(
(
¸
(

¸

÷
÷
÷
÷
÷
2
2
2
2
1
2
1
) ( 2
) ( 2
...
) ( 2
) ( 2
...
2 1
1 2 1
. . .
1 2 1
1 2
x
x
x
x
y
y
y
y
n
n
7
When should we use numerical
methods?
Necessary Assumptions for the methods we
have studied so far:

•2-D problems, in plan view generally
•Horizontal-only flow (Dupuit-Forchheimer
assumption)
•Isotropic, homogeneous domain
•Steady-state conditions (no change in time)
•Darcy’s law applies in the full domain

8
When should we use numerical
methods?

• To get approximate solutions to problems that
cannot be solved analytically, for example:
o Problems with complicated geometries and/or boundaries
o Problems with difficult to solve PDEs

• To test the applicability of a simple rule under a
variety of conditions (for example, the Ghyben-
Herzberg relation)

• To verify the correctness of an analytical solution
9
Issues to Remember
• It may take a long time to get your
solution (or you may get a lack of
convergence!)
• When/if you get a solution, it is only an
approximate solution.
• The solutions may be highly dependent
on the data you give to COMSOL
(anisotropy, heterogeneity, etc)
• Your data has errors.
10
COMSOL
Based on the Finite Element (FE) Method

(+) FE can handle complex geometries and boundary
conditions with ease. FD is basically restricted to
rectangular shapes.

(+) FD only tries to minimize error at discrete points, whereas
FE tries to minimize the error over the entire element (line
segments in 1-D, triangles in 2-D)

(–) The mathematics behind FE are more involved than FD.
11
COMSOL
COMSOL
Geometry (“CAD”)
PDE Definition
Discretization
PDE Solution
Post-Processing
12
COMSOL Geometry
Two options:
• Simple UI for 1-D, 2-D,
and 3-D
– Points, lines, planes,
circles, etc.
– Object mathematics,
scaling, rotation,
reflection
– Extrusion / Revolving
in 3-D
• Import from standard
CAD software
– VRML, dxf

13
COMSOL PDE Definition
• Pre-defined
physical PDEs
(coupled
through “multi-
physics”)

OR

• General PDE
solution mode
14
COMSOL PDE Definition
•Define parameter values within
each shape (subdomain)
– Hydraulic conductivity in
aquifer

•Define boundary conditions
– Head at specified boundary

•Define known values at points
– Known extraction rate at
point-source well

•Couple physics as necessary
– Solute transport
(advection/diffusion equation)
coupled to fluid velocity
(Darcy’s Law or N-S equations)

15
COMSOL Discretization
Automatic Meshing Options:

– Element shape
(triangular, square)

– Element type (Linear,
Quadratic, Cubic)

– Mesh parameters (rate of
element growth, mesh
size sensitivity)

– Advanced: moving
meshes / automatic
refinement
16
COMSOL PDE Solving
Options:

– Transient (time
dependent) or Stationary
(steady state) solving

– Great assortment of FE
algorithms
• UMFPACK, GMRES,
Multi-grid, Conjugate
Gradient

– Can solve individual parts
of problems, store
solutions, or iterate
17
COMSOL Post-Processing
• For any given physics, many
variables will be output
– Example: Darcy’s law will
have head, velocity,
pressure as output

• Variety of standard
visualizations:
– Surface, contour,
streamline, arrow, and
animated plots

• Further analysis:
– Subdomain / boundary
integration
– Cross-sectional plots
18
COMSOL
Compared with other methods of modeling:

(+) Relatively easy to use graphical interface

(+) Uses state-of-the-art solvers and optimizers. Runs well on a
suitably-equipped (lots of RAM) desktop PC.

(–) Lots of default options / hidden parameters

(–) Interface changes based on what type of physics you are
solving for. “Multiphysics” gets even more cumbersome.

What is a model? Straight from the OED: “a system or thing used as an example to follow or imitate .a simplified description.” 2 . of a system or process. especially a mathematical one. to assist calculations and predictions.

What is a numerical model? A model which estimates the solution to a “hard” problem (usually a set of PDEs) through numerical approximations. 3 .

Plug in BC’s to get values for integration constants 2 y  2 2 x y (0)  0 y (1)  0 . Integrate the expression using calculus tricks 2.A finite-difference example ? x=0 y=0 x=1 y=0 Analytical Solution: 1.

5 ) x  y3  2 y2  y1 ( x ) 2  2 . Approximate derivatives using numerical tricks 2. y' ( x1.5 )  y '( x1.5 )  y' ' ( x2 )  y '( x2.5 )  y' ( x2.A finite-difference example ? x0 x1 x2 x3 x4 x y2  y1 x y3  y2 x Numerical Solution: 1. Write all equations into a single matrix and solve.

    2 1 2 1   yn 1   2(x)      yn   2(x) 2  1  2      .. ....    .n yi 1  2 yi  yi 1  2(x) 2 y0  y ( x0 )  0 yn 1  y ( xn 1 )  0 y1   2(x) 2  2 1    1 2 1  y   2 2   2(x)       .  .A finite-difference example for i  1.. ..

in plan view generally •Horizontal-only flow (Dupuit-Forchheimer assumption) •Isotropic.When should we use numerical methods? Necessary Assumptions for the methods we have studied so far: •2-D problems. homogeneous domain •Steady-state conditions (no change in time) •Darcy’s law applies in the full domain 7 .

for example: o Problems with complicated geometries and/or boundaries o Problems with difficult to solve PDEs • To test the applicability of a simple rule under a variety of conditions (for example. the GhybenHerzberg relation) • To verify the correctness of an analytical solution 8 .When should we use numerical methods? • To get approximate solutions to problems that cannot be solved analytically.

• The solutions may be highly dependent on the data you give to COMSOL (anisotropy. heterogeneity. 9 . etc) • Your data has errors.Issues to Remember • It may take a long time to get your solution (or you may get a lack of convergence!) • When/if you get a solution. it is only an approximate solution.

triangles in 2-D) (+) (–) The mathematics behind FE are more involved than FD. FD only tries to minimize error at discrete points.COMSOL Based on the Finite Element (FE) Method (+) FE can handle complex geometries and boundary conditions with ease. whereas FE tries to minimize the error over the entire element (line segments in 1-D. FD is basically restricted to rectangular shapes. 10 .

COMSOL Geometry (“CAD”) PDE Definition COMSOL Discretization PDE Solution Post-Processing 11 .

– Object mathematics. 2-D. circles.COMSOL Geometry Two options: • Simple UI for 1-D. and 3-D – Points. etc. rotation. lines. dxf 12 . scaling. planes. reflection – Extrusion / Revolving in 3-D • Import from standard CAD software – VRML.

COMSOL PDE Definition • Pre-defined physical PDEs (coupled through “multiphysics”) OR • General PDE solution mode 13 .

COMSOL PDE Definition •Define parameter values within each shape (subdomain) – Hydraulic conductivity in aquifer •Define boundary conditions – Head at specified boundary •Define known values at points – Known extraction rate at point-source well •Couple physics as necessary – Solute transport (advection/diffusion equation) coupled to fluid velocity (Darcy’s Law or N-S equations) 14 .

COMSOL Discretization Automatic Meshing Options: – Element shape (triangular. Quadratic. square) – Element type (Linear. mesh size sensitivity) – Advanced: moving meshes / automatic refinement 15 . Cubic) – Mesh parameters (rate of element growth.

COMSOL  PDE Solving Options: – Transient (time dependent) or Stationary (steady state) solving – Great assortment of FE algorithms • UMFPACK. or iterate 16 . Conjugate Gradient – Can solve individual parts of problems. Multi-grid. store solutions. GMRES.

streamline. arrow. many variables will be output – Example: Darcy’s law will have head. contour. and animated plots • Further analysis: – Subdomain / boundary integration – Cross-sectional plots 17 .COMSOL  Post-Processing • For any given physics. pressure as output • Variety of standard visualizations: – Surface. velocity.

(–) Lots of default options / hidden parameters (–) Interface changes based on what type of physics you are solving for. 18 . “Multiphysics” gets even more cumbersome.COMSOL Compared with other methods of modeling: (+) Relatively easy to use graphical interface (+) Uses state-of-the-art solvers and optimizers. Runs well on a suitably-equipped (lots of RAM) desktop PC.

Sign up to vote on this title
UsefulNot useful