You are on page 1of 163

COMSOL Multiphysics

Intensive Training Course


Walter Frei, Ph.D.
COMSOL, Inc.
1
Syllabus
Day 1
Introduction and remarks
Hands on: Microresistor beam
Theoretical Notes: Non-linear single physics problems
Applied Notes: Using COMSOL expressions
LUNCH
Hands on: Large deformation micromirror
Applied Notes: CAD Modeling & Meshing
Day 2
Hands on: Laminar Static Mixer
Theoretical Notes: Solving
Theoretical Notes: Multiphysics problems
LUNCH
Hands on: Fluid-Structure Interaction
Theoretical Notes: Transient problems
Q & A





2
Hands on: Joule heating induced thermal
expansion of a microresistor
Problem:
Voltage applied to this beam
creates resistive heating

Heating the structure
causes thermal expansion

Material properties are
temperature dependent

Want to find the deformation
and stresses
0.2V
Ground
3
The DC Problem
0 ) ( = V V V o
Governing Equation for the
Conductive Media DC
Application Mode
Grounded
V=0.2 V
Conductivity
A steady state voltage difference is applied to the titanium beam in air
All other surfaces
are insulated
4
The Heat Transfer Problem
2
V V =o Q
Governing Equation for the
Heat Transfer Application Mode
( ) Q T k = V V
Natural Convection
h=5 W/m
2
K
T
ext
=300 K
T =300 K
T =300 K
Thermal
Conductivity
Ohmic heat generation
calculated by Conductive Media DC
5
) (T o o =
The Coupled DC+Heat Problem
( ) Q T k = V V
0 ) ( = V V V o
The material properties of
titanium are temperature
dependent
) (T k k =
6
The nonlinear material functions
7
k
T
T

(1-T/1000[K])*7.407e5[S/m]
exp(-T/1000[K])*7.5[W/m/K]
Consider these one at a time
The Structural Mechanics Problem
Feet are fixed
to substrate
The material experiences a
volumetric thermal expansion
due to the temperature given by:
) , ( x T,V T
( )
0
T T =o c
Assume small strain linear deformation theory
8
The finite element method
V+
T

Before you begin:
1) Physics
2) CAD
3) Boundary Conditions
4) Material Properties
b Ax =
This course focuses on:
1) Efficient model set-up
2) Meshing
3) Solving
4) Finding mistakes
9
Saving COMSOL Files
When saving a file, the *.mph format (default) is a binary format
The *.m file is a MATLAB script format that logs all commands

If you go to File... Reset... you will delete the mesh, solution, and log
This is an efficient way of emailing a file among colleagues

File... Generate Report... is a good way of getting a simple summary
of all data inside the file


10
Lecture 1: Introduction to linear and
non-linear single physics steady-
state finite element problems
11
A very simple finite element problem...
p= 2 N
k
2
= 4 N/m k
3
= 4 N/m
u
1
u
2
u
3
We can write a force balance on each node:
Node 1
c
k
1
(u
3
-u
1
)
Node 2
k
3
(u
3
-u
2
) -k
2
(u
2
-u
1
)
k
1
= 6 N/m
k
2
(u
2
-u
1
)
Constraint Force
Node 3
p
-k
1
(u
3
-u
1
)
-k
3
(u
3
-u
2
)
12
Write the force balance as three equations:
However, we now have three equations in four unknowns, c, u
1
, u
2
, u
3
k
1
(u
3
-u
1
) + k
2
(u
2
-u
1
) = c
k
2
(u
2
-u
1
) - k
3
(u
3
-u
2
) = 0
k
1
(u
3
-u
1
) + k
3
(u
3
-u
2
) = p
(k
2
)u
2
+ (k
1
)u
3
= c
(k
2
+k
3
)u
2
+ (-k
3
)u
3
= 0
(-k
3
)u
2
+ (k
1
+k
3
)u
3
= p
Algebra
Constraint Equations
System Equations
k
1
(u
3
- 0 ) + k
2
(u
2
- 0 ) = c
k
2
(u
2
- 0 ) - k
3
(u
3
- u
2
) = 0
k
1
(u
3
- 0 ) + k
3
(u
3
- u
2
) = p
Three equations, three
unknowns: c,u
2
, u
3
But we also have a constraint, u
1
=0

13
Can now solve the problem
(k
2
)u
2
+ (k
1
)u
3
= c
(k
2
+k
3
)u
2
+ (-k
3
)u
3
= 0
(-k
3
)u
2
+ (k
1
+k
3
)u
3
= p
| | { } c
u
u
k k =
)
`

3
2
1 2
)
`

=
)
`

+
+
p u
u
k k k
k k k 0
3
2
3 1 3
3 3 2
Solve the system
equations first
Ku=b
u=K
-1
b
k
1
= 6 N/m
k
2
=k
3
= 4 N/m
p=2 N
)
`

=
)
`

250 . 0
125 . 0
3
2
u
u
Can also solve the
constraint equations,
if desired
| | { } 2
250 . 0
125 . 0
6 4 =
)
`

14
So far, we have only solved a linear problem
A linear problem must have all three of these properties:

1) Applying zero loads results in a zero solution
2) Doubling the magnitude of the load doubles the magnitude of the solution
3) Changing the sign of the load changes only the sign of the solution
load
solution
load
solution
Linear Non-Linear
15
What makes a problem non-linear?
Material properties that depend upon the solution, k(u)
Loads that depend upon the solution, b(u)
u
k,b(u)
Linear
u
k,b(u)
Weakly Non-linear
u
k,b(u)
Strongly Non-linear
u
k,b(u)
Outrageously
Non-linear
There are no clear distinctions
between these three cases
16
Not all non-linear problems have a (unique) solution
load
solution
No solution
17
load
solution
No unique solution
Two very simple finite element examples
k = 4 N/m
u

p = 2 N
Force balance on node:
f (u) = p - ku = 0
f (u) = 2 - 4 u = 0
f (u)
u
solution
= 0.5
u

k

= exp(u) N/m
u

p = 2 N
Force balance on node:
f (u) = p - k u = 0
f (u) = 2 - exp(u) u = 0
u

f (u)
u
solution
0.853
18
First, solve the linear problem
f (u) = 2 - 4 u = 0
f (u)
u
solution
=0.5
Algorithm:
1) Start at a point, e.g. u
0
= 0
2) Find the slope, f (u
0
)
3) Solve the problem:
( )
( )
0
0
0
' u f
u f
u u
solution
=
5 . 0
4
2
0 =
|
.
|

\
|

=
solution
u
(1)
(2)
(3)
( )
( )
i
i
i i
u f
u f
u u
'
1
=
+
This is a single Newton-Raphson iteration:
For a linear problem, the starting point does not matter
19
Solving a FE system matrix is equivalent to taking
a single Newton-Raphson iteration
f (u) = 2 - 4 u = 0
( )
( )
0
0
0
' u f
u f
u u
solution
=
5 . 0
4
2
0 =
|
.
|

\
|

=
solution
u
)
`

=
)
`

+
+
p u
u
k k k
k k k 0
3
2
3 1 3
3 3 2
( )
)
`

=
)
`

+
+

)
`

=
0
0 0
3
2
3 1 3
3 3 2
u
u
k k k
k k k
p
u f
f (u) = b - Ku, u
0
= 0
( )
( )
( )
K
b
K
Ku b
0
u f
u f
u u =

= =
0
0
0
0
'
solution
b K u
1
=
solution
20
The non-linear problem is solved the same way
Algorithm:
1) Start at a point, e.g. u
0
= 0
2) Take repeated Newton-
Raphson iterations
3) Terminate when:
f (u) = 2 - exp(u) u
u

f (u)
tolerance u u f f
i i i i
<
+ +
/ & /
1 1
21
Similarly, if we have a non-linear system matrix
f (u) = b(u) - K(u)u
( )
( )
( ) ( ) ( ) ( )
i i i i i
i
i
i i
u b u u K u S u
u f
u f
u u = =

+
1
1
'
f(u) = S(u)
Iterate until:
tolerance f f
i i i i
<
+ +
u u / & /
1 1
p= 2
k
2
= exp(u
2
-u
1
) k
3
= 4
u
1
u
2
u
3
k
1
= 6 + (u
3
-u
1
)
2
S(u) is the known as the JACOBIAN
22
The possibility of convergence of a non-linear
problem is dependent upon the starting point, u
0
Non-linear problems have a radius of convergence
f (u) = 2 - exp(u) u
u

f (u)
Non-convergent
if starting on this
side of the line
u
0
= -1

23
Finding a good starting point, u
0
, can
improve convergence

f (u) = 2 - exp(u) u
u

f (u)
slow
convergence
fast
convergence
It is not strictly possible
to define slow or fast
convergence.
Finding a good starting
point is a matter of
experience, and luck.
24
A damping factor, , is used to improve convergence
u

f (u)
( )
( )
|
|
.
|

\
|
=
+
i
i
i i
u f
u f
u u
'
1
o
choose ( < 1) & (<
previous
)
while ( |f
i+1
| > |f
i
| )
recompute f
i+1
(u
i+1
)
end
|f
i
|
undamped |f
i+1
|
intermediate |f
i+1
|
final |f
i+1
|
f (u) = 2 - exp(u) u
Problem: This requires many more evaluations
25
A better solution is to ramp up the load
f (u)
f (u) = 2 - exp(u) u
k

= exp(u) N/m
u

p = 2 N
u

Recall that: Load
Load
f (u) = 1 - exp(u) u = 0
Almost all problems have a
zero solution at zero load
Ramping up the load is a
physically reasonable approach
26
Ramping up the non-linearity can also work
f (u)
f (u) = 2 - exp(u) u = 2 - ku
u

Non-linearity
f (u) = 2 - 1u
f (u) = 2 - {(1-0.5)+(0.5exp(u)}u
f (u) = 2 - exp(u) u
Identify non-linearity
- k
NL
= exp(u)

Linearize around chosen u
0
- k
LIN
= exp(u
0
=0) = 1

Use an intermediate value
- k = (1-)k
LIN
+k
NL
- starts at 0

Use intermediate solution as new u
0


Ramp from 0 to 1

27
Review
At this point, you should know:
What is meant by a finite element problem
The difference between a linear and non-linear problem
How linear and non-linear finite element problems are solved
Why a non-linear problem may not converge
Strategies for getting a non-linear problem to converge



28
Hands-on: heat flow through a square
T=0K
q = 100 W/m
2
k, Thermal conductivity
1x1m square
Build this 2D model in BASE Heat Transfer,
Save this model, we will build upon this
Mesh
Solution
T
initial
=0K
Insulated
Insulated
29
30
Study the following cases:
T
k
T
k = 0.1+exp(-(T/25[K])^2)[W/(m*K)]
= 1[W/(m*K)]
T
k
= (1+T/200[K])[W/(m*K)]
T
=(0.1+10*(T>25[K]))[W/(m*K)]
k
Questions:
How many iterations did each case take? Was damping used?


What does the temperature and thermal conductivity solution look like?


Did they all converge? Why not?


Try solving case #2 with an initial temperature of 50[K], how does this
affect the solution? What about the other cases?
Set back to T=0 afterwards

31
Ramp up the heat load and monitor peak temperature
32
T
k
=(1-T/200[K])[W/(m*K)]
Q
in
T
max
?
Why does this happen?
Non-linear solver settings
Stop conditions for
Newton iterations
Toggling off damping is
rarely, if ever, useful
Can choose different
defaults for the damping
Augmented Lagrangian
solver settings, used in
structural contact
problems only
33
Advanced solver settings
All other settings are
there for historical
reasons and are related
to memory management
Wave-type problems use
complex numbers, and
require this be on
Stores time-dependent
solution to temp file
during the solve, and
gets loaded into RAM
once the solve is done
Wave-type problems with
periodic boundary
conditions require this to
be checked on
34
Using the parametric solver with one parameter
Consider again, the outrageously non-linear problem, k=0.1+10*(T>25)

Try instead: k=0.1+10*flc2hs(T-25,STEP)

Try the parametric solver with STEP = 8, 4, 2, 1, 0.5, 0.25

Try with STEP = 8, 0.25


When using the parametric solver with one parameter, COMSOL will take additional
intermediate steps in an attempt to ramp towards the final solution. This is similar to,
but more computationally demanding than, damping. The intermediate steps do not
get stored, and they can require more time.
35
Using the parametric solver with several
parameters
Now try: k = 0.1+DK*flc2hs(T-25,STEP)

Try: DK, STEP = 0 8 5 4 7.5 2 10 0.5 10 0.25

STEP
DK
(0,8)
(5,4)
(7.5,2)
(10,0.5)
(10,0.25)
When using several
parameters, the previous
solution is still used as
the initial condition, but
the software does not
take intermediate steps. T
k
(0,8)
(5,4)
(7.5,2)
(10,0.5)
36
Other methods for getting convergence
Observe the solution during the non-linear iterations
Toggle ON Plot while solving on the Solver Parameters form
Toggle ON Highly non-linear problem
This also ramps up Dirichlet boundary conditions

Run example
from booklet
37
Achieving convergence for non-linear problems
Assuming that the problem is
well-posed, try solving it
1) Check the initial condition
2) Use parametric solver to ramp load
1
3) Use parametric solver to ramp non-linearity
4) Refine the mesh
Does the problem have a steady-state solution?
Are there additional effects? Check all assumptions.
Perform a mesh
refinement study.
Try a finer mesh
and check that the
solution is similar.
DONE
Not converging?
1) Very similar to toggling on Highly non-linear problem
Not converging?
Not converging?
Not converging?
Not converging?
Converging?
Not converging?
Converging?
38
39
Linear problems are much easier to debug
The error is usually some variation of these mistakes:
What are the stresses in the eggshell for these two cases?
40
Linear problems are much easier to debug
The error is usually some variation of these mistakes:
If balanced forces are acting upon
an object, where is the object?
COMSOL Expressions
41
Application notes: Problem constants
These constants can be entered into anything underneath the Physics... menu
Units are tracked and converted to the default unit system
42
COMSOL expressions
EXPRESSIONS
Expressions are defined via the Options... Expressions... submenu
These expressions can be entered into anything underneath the Physics... menu
Units are tracked and converted to the default unit system
The same everywhere
The same within a geometry tab
The same within a subdomain
etc...
43
Expressions are evaluated both before and
during the solution
Square brackets are used to specify units, they are
not strictly necessary, but are encouraged
44
How to enter more complicated expressions
1) Options... Functions... Table...
Pick appropriate extrapolation
and interpolation method
45
How to enter more complicated expressions
2) Options... Functions... Piecewise Analytic Functions...
Use General Function type
Pick appropriate extrapolation
method and smoothing function
46
Entering x-y data from a file
(1)
(2)
(3)
(4)
% Grid
-2.00 0.00 2.00
-1.00 2.00
% Data
0.25 0.00 -0.25
-0.50 0.00 0.50
The data can be on a
square grid, or read in
from another analysis
package on an
unstructured mesh.
47
Functions with a discontinuity
In COMSOL such functions can be
written as Boolean expressions:
(t>0)
(t>=0)
(t>0)&&(t<1)
(t>1)||(t<0)

These can cause numerical difficulties!!!

COMSOL has these smoothed step
functions and derivatives built-in:
flc1hs(t,scale), fldc1hs(t,scale)
flc2hs(t,scale), fldc2hs(t,scale)
flsmhs(t,scale), fldsmhs(t,scale)
flsmsign(t,scale), fldsmsign(t,scale)
48
Material Properties
Can also use:

www.matweb.com

www.efunda.com
49
Reserved COMSOL variable names
t
x, y, z, r, X, Y, Z, R
s, s1, s2
n, nx, ny, nz, nr
tx, ty, tz, tr
t1x, t1y, t1z, t2x, t2y, t2z
un, unx, uny, unz
dn, dnx, dny, dnz
eps, i, j, pi
lambda
h, dom, meshtype, meshelement, dvol,
qual, reldetjac, reldetjacmin
Time:
Position:
Edge/Surface Parameter:
Edge/Surface Normal:
Edge Tangent:
Surface Tangents:
Edge/Surface Up Normal:
Edge/Surface Down Normal:
Numerical Constants:
Eigenvalues:
Mesh Information:
50
COMSOL derivative variables
Given solution variables: T, V, etc...
The spatial derivatives are given by: Tx, Ty, Tz, Vx, Vy, Vz, etc...

T
x c
c
= Tx
T
y c
c
= Ty
T
z c
c
= Tz
The time derivatives (if solving a
transient problem) are: Tt, Vt, etc...
T
t c
c
= Tt
These can be mixed:
|
|
.
|

\
|
c c
c
c
c
=
y x
T
t
2
2
2
Txytt
The edge and surface tangent
derivatives are: TTx, TTy, TTz, etc...
( ) ( )
x
T V =
T
nn I TTx
51
Application Mode Variables
Each application model has its own automatically defined variables
that have an underscore and a suffix
They are all listed underneath Phyics... Equation System...

For example:
fluxx_ht =-kxx_ht*Tx-kxy_ht*Ty-kxz_ht*Tz
z
T
k
y
T
k
x
T
k q
z
T
k
y
T
k
x
T
k q
z
T
k
y
T
k
x
T
k q
zz zy zx z
yz yy yx y
xz xy xx x
c
c

c
c

c
c
=
c
c

c
c

c
c
=
c
c

c
c

c
c
=
T V = k q
52
Hands on: pre-stressed micromirror
Aspect ratio is >10, so swept
meshing is reasonable
Large deformation analysis
Intermediate solutions are required to
help the model converge to solution
53
CAD and Meshing
54
Geometry modeling choices
COMSOL geometry modeling tools
Suitable for simple geometries
Foreign CAD tools
Import STEP, ACIS, or PARASOLID format, IGES and STL are poor choices
Specialized CAD packages have greater flexibility in geometry definition
New ECAD Import, Imports 2D layout files, builds 3D geometry
CAD import is one-way
Solidworks and Inventor live-link (after the geometry is modified
during modeling, with this, you can connect the two)
Bi-directional interface,
build CAD, build FEM, update CAD, automatic FEM update
Can drive dimensions from within COMSOL
Limited to CAD capabilities in those packages
Scan data (MRI, geophysical)
Simpleware(native), MIMICS(native), Avizo, Amira...

55
COMSOL Draw Mode
Draw 2 rectangles
Get 3 domains
Continuity is automatically assumed at interior boundaries

Overlapping geometry is OK, once you switch to
subdomain mode you will get what you see on the screen
(assign subdomain into defined groups, group
definition will remain even the objectives are removed)
56
Deleting interior boundaries and splitting objects
Draw a square & circle
Union into one object Delete interior boundaries
Split into three objects
57
Using COMSOL Groups
APPROACH #1
1) Select each object
2) Apply properties
3) Switch to Groups tab
4) Verify groups visually

58
Using COMSOL Groups
APPROACH #2
1) Switch to Groups tab
2) Create a Group name
3) Give properties for
group
4) Switch to subdomain tab
5) Select each object
6) Assign it to a group
59
MESHING: The free mesh parameters
Usually want to adjust each one of these fields,
both globally and locally
The Subdomain,
Boundary, Edge, and
Point tabs locally
overwrite the Global
settings
60
Maximum element size
This sets the maximum length of the edge of any element
If you do not pick a value, COMSOL uses L/10, where L is the
maximum dimension of the model
Do not use maximum element size scaling factor
61
Element growth rate
This controls the maximum element size between adjacent elements
62
Mesh curvature factor
radius=0.5
Local element size will be:
(radius of curvature)x(mesh curvature factor)
Maximum element size is 0.05
63
Mesh curvature cutoff
radius=0.25
If: r
edge
< (r
cutoff
) x (L
max
)
Then: r = (r
cutoff
) x (L
max
)
As a result: The element size of these edges is:
(Mesh Curvature Cutoff) x (Mesh Curvature Factor)
Maximum element size is 0.05
L
max
64
Resolution of narrow regions
Resolution=1 Resolution=5
Puts approximately the specified number
of elements into the narrow regions
65
2D Triangular, Quadrilateral, Mapped, and
Boundary Layer Meshes, and when to use them
Triangle Quad
Mapped Boundary Layer
66
Transient thermal heating, high gradients
in the solution normal to boundary
Which will be the best mesh to resolve the gradient?
Gradient need to be more resolved close to the inner
curve and less/no at outer curve, also gradient is
only perpendicular to curve not along the curve.
So triangle and quad is too much considering the direction
along the curve. So Map is the optimum.

Boundary is specially good for modeling skin problem
because it give special meshes on the boundary
3D Tetrahedral, Extruded, Revolved, Swept, and
Boundary Layer Meshes
Tetrahedral Extruded
Revolved
Swept Boundary Layer
67
Tetrahedral is most useful. Swept: you work out the condition for surface, or
some subdomains, than swept for the rest (that is not so important,
or not of that interest)
The wrong way to work with 3D CAD files:
CAD
Designers
Analysis
Staff
CAD File
68
3D CAD pitfalls
Working with overly detailed geometry, extraneous features
Sliver faces (drafts), short edges
Fillets, fillets, fillets

69
Downloaded from thomasnet.com
70
Making the reverse of the part is usually
easier to do in the original CAD program
COMSOL can cap rectangular and
circular planar faces on 3D objects, other
capping operations are more difficult
Include a fillet to remove a singularity
71
Consider DC current flow. Cut
a notch out of a square block,
apply insulating boundary
conditions, because it is
insulating, so current can only
go in the direction shown but
not perpendicular to the
surface.
Here, the insulating boundary condition
means that current can only flow
tangentially to the boundary, as shown
by the arrows.

This is enforced no matter how much
you zoom in on the notch.

This geometry implies that the current
takes a sharp bend over zero radius.

This is independent of the mesh!
Although the fillet/ sharp angle introduces
a singularity, it may not matter for the
quantity of interest
72
With mesh refinement, a derived quantity, such as resistive heating,
may diverge at a sharp corner, but the actual solution variable, in this
case voltage, will be the same, regardless of the mesh
V=0.5 V=0.5 V=0.5
An example from structural mechanics
73
Some fillets should stay
If a corner introduces gradients into the solution,
then consider adding a realistic fillet
74
FLUID FLOW EXAMPLE
Adding a small, physically
realistic, fillet at interior corners
can be helpful for convergence
Boundary conditions can introduce singularities
75
P
A cantilever beam fixed at one end
A fixed boundary
condition means
the material is
infinitely stiff
Where will there be a singularity? How is it manifested?

Is this model convergent? If so, with respect to what?
Point load
Stiffness:left infinite stiffness, right, finite
Boundary conditions can introduce singularities
76
T = 50K
T

=

0
K

T

=

1
0
0
K

x
T
kA q
A
A
=
q?
CAD Pitfalls: Glancing contact
77
Introduce a slight
intersection to avoid
the sharp interior
angle of the element
CAD Pitfalls: Narrow regions
78
- Approximate this via a boundary condition
- Consider using a reduced dimension model
CAD Pitfalls: High aspect ratios
79
2D aspect ratios of up to 1000:1 are possible (but difficult)

In 3D, due to memory are accuracy constraints, try to stay below 100:1
L
max
L
min
Demo: CAD meshing and de-featuring
Import: repair_demo_1.x_b from
C:\COMSOL\caddata directory
93,429 elements
using default
Normal mesh
80
Fillets and small surfaces are present
81
Try repairing the part with a tolerance of 1e-3
45,517 elements
82
Draw CAD repairrepair change from 1e-5 to 1e-3
Try changing the resolution of narrow regions
By changing from 0.5 to 0.1, resulting in
50,797 elements, almost 50% less!
83
Tricks for diagnosing CAD
If you are unable to put a 3D mesh on the part, 99% of the
time, it is one of the problems we discussed in the previous
cases, (small edges and small intersections, etc), but it
is hard to find. In that case, instead of doing a 3D mesh,
just select the surface of the geometry and do a 2D mesh
to help find the problem.

Try interactive
surface meshing
This is a mesh on
the surface only,
but it can visually
guide you to the
problem areas
84
Good CAD data has
just enough detail
to capture the
physics, but not
one detail more.
85
Meshing notes: The more elements, the better,
but this has some practical limits
P
Displacement
0.990
0.995
1.000
0 1 2 3 4 5
Refinement Iteration
N
o
r
m
a
l
i
z
e
d

M
a
x
.

D
i
s
p
.
Make sure to study the
solution variable, and
not a derived variable
86
Numerical Error
k

= exp(u) N/m
u

p = 2 N
Force balance on node:
f (u) = p - k u = 0
f (u) = 2 - exp(u) u = 0
u

f (u)
u
solution
0.853
This problem has an exact
solution, but we are solving it
numerically via Newton-
Raphson iterations.

The error can be minimized by
taking many iterations, but a
computer usually cannot find
an exact answer for two
reasons:

1) Numerical approximations,
e.g. 1 2
-1
+2
-2
+2
-3
+2
-4
+...

2) Operations such as exp(u)
are approximate

This is NUMERICAL error
87
Discretization Error
A finite element basis function can only
approximately represent a true solution.
The error can be minimized by using
smaller elements, or increasing element
order.
This is MESH or DISCRETIZATION error
10 1
st
order elements
16 1
st
order elements
4 2
nd
order elements
u
exact
-u
model
88
1.E-10
1.E-08
1.E-06
1.E-04
1.E-02
1.E+00
1 10 100 1000 10000 100000 1000000
Number of Elements per Wavelength
T
o
t
a
l

E
r
r
o
r
Discretization error and numerical error
Mesh error
decreases with
more elements
Numerical error
increases with
more elements
Total error will be about 10
-6
1
st
order elements
89
Square root of instrument precision
Element shape functions discretize curved edges
Domain
Single 1
st
order
triangular element
Single 2
nd
order
triangular element
Isoparametric elements use polynomial
expressions to approximate the domain shape
90
Geometric discretization error
Four linear elements
discritizing a unit circle
Error: (-2)/
1.E-06
1.E-04
1.E-02
1.E+00
1 10
Elements per Chord
E
r
r
o
r
1
st
order
2
nd
order
3
rd
order
This mesh adequately
describes the geometry, but
not necessarily the solution!
91
Total Error vs. memory requirements
n: # of elements
per side (5 in this
example)
n=1
n=1
n=2
n=20
Insulated
quarter
cylinder
with heat
generation
92
Memory requirements depend on mesh type
18 elements
49 nodes
~3 adjoining elements
9 elements
40 nodes
~4 adjoining elements
[K
element
]
6x6
[K
element
]
8x8
Error is a related to how far apart the nodes are,
and is usually not a function of element type. 93
Tetrahedral vs. prismatic elements
2,500 elements
83K d.o.f.
17s solve time
150 MB for K matrix

23,000 elements
186k d.o.f.
22s solve time
150 MB for K matrix
Solvers are tuned to take advantage of tetrahedral elements
current
carrying
wire
94
When to use quad/hex/prism elements:
95
ALE moving mesh formulations
High aspect ratio geometry
Known small gradients in one direction
Large deformation structural analysis
If also solving a contact problem, use linear elements
For almost all other cases, use triangular or
tetrahedral elements
Use boundary layer meshing when there
are high gradients normal to a boundary
When to use linear elements?
Almost never

If you already have a very fine mesh due to geometric complexity

Very large models where you can only get low accuracy

Transient problems

Higher than 2
nd
order is usually only of academic interest

96
The stationary adaptive mesher
Triangular and tetrahedral elements
ONLY are subdivided based on the
L2 norm error estimate.
Toggle this on, solve, then toggle off.
Do not change the settings.
Discuss
Initial mesh
Final mesh
Go back to the square model, case 3

k = 0.1+exp(-(T/25[K])^2)[W/(m*K)]

Turn on adaptive mesh refinement
97
Guidelines for meshing refinement
1. Start with a mesh that you believe will resolve the gradients on the
solution that you expect, use the previously mentioned techniques
to get an answer
2. If it is easy to manually put more elements in regions where you
observe steep gradients in the solution, then do so. Monitor the
convergence of the solution as you proceed
3. Use adaptive mesh refinement to automatically refine the mesh,
but be prepared to devote time and RAM to the solution
4. If the solution itself does not change, to a tolerance that you
consider acceptable, then the solution is converged

98
End of Day 1

Questions?
99
Hands on: Laminar Static Mixer
1) Solve fluid flow problem
2) Re-mesh with a finer mesh
3) Map solution onto new mesh
4) Solve convection-diffusion problem
100
Lecture 2: Different ways of
solving the linear system matrix
Ku=b
101
Lets take another look at the system equations
( ) 0 Ku b u f = =
)
`

=
)
`

+
+

)
`

=
0
0 0
3
2
3 1 3
3 3 2
u
u
k k k
k k k
p
Define a quadratic function: r(u) = b u-Ku u
u
2
u
3
r(u)

Solution
The solution, f(u
solution
) = 0, is
the point where r(u), is at a
minimum
102
Finding the minimum of a quadratic function
r (u) = 2u
2
- 3u + 1
r (u)
u
Newtons method:
( )
( )
0
0
0
u
u
u u
r
r
sol
' '
'
=
For a quadratic function, this
converges in one iteration, for any u
0
r(u) = 4u

- 3
r(u) = 4
( )
( )
75 . 0
4
3 0 4
0
0
0
0
=

=
' '
'
=
u r
u r
u u
sol
u
0
= 0
Via our choice of r(u), this reduces to the
same equation from the previous section:
r(u) = b - Ku
r(u) = - K
r(u) = b u-Ku u
( )
( ) K
Ku b
u
u
u
u u

=
' '
'
=
0
0
0
0
0
r
r
sol
0 u =
0
b K
K
b
0 u
1
= + =
sol
u
sol

103
Finding the minimum of the quadratic function,
r(u), by the direct method means solving u=K
-1
b
This is known as Gaussian Elimination, or LU factorization
The numerical algorithms are beyond the scope of this
course, but they have the following important properties:
For 3D, requires O(n
2
)-O(n
3
) numeric operations, where n is the length of u
Requires O(n
2
)-O(n
3
) memory
Robustness of the algorithm is only very weakly dependent upon K
The direct solvers in COMSOL are:
PARDISO: fast, multi-core capable, BEST FIRST CHOICE
SPOOLES: slow, uses the least memory
UMFPACK: fast, robust, uses the most memory
PARDISO out-of-core, uses disk memory, VERY SLOW
104
Introduction to iterative methods for finding the
minimum of a quadratic function, a naive approach
1) Start here
2) Search along coordinate axis
3) Find the minimum along that axis
4) Repeat until converged
This iterative method requires only
that we can repeatedly evaluate r(u)
as opposed to the direct methods,
which get to the minimum by in one
step by evaluating [r(u)]
-1

105
The numerical values in K can affect the algorithm
u
2
u
3
r(u)

Quadratic
surface
r(u) = b u-Ku u
Condition
number = 1
Condition
number = 2
Condition
number = 10
The higher the condition number the more
numerical error creeps into the solution
106
Ill-conditioned matrices require more iterations
Numerical error becomes significant
107
A better iterative method for finding the minimum:
The Conjugate Gradient (CG) method
3) Find the minimum along that vector
The CG method requires that we can
evaluate r(u), r(u) and r(u)
CG converges in at most n iterations

CG does NOT compute K
-1

2) Initially, find the gradient vector
1) Start here
4) Find the conjugate gradient vector
*

5) Repeat 3-4 until converged
*
)
See e.g. Wikipedia, or Scientific Computing by Michael Heath
108
Condition number matters for iterative methods
Numerical error becomes significant
for ill-conditioned matrices
A matrix with a condition number of 1
will converge in one iteration, (rare!)
All iterative methods in COMSOL are some
variation upon the CG method
Conjugate Gradient, F/GMRES, BiCGStab, Geometric Multigrid
The details of these algorithms are beyond the scope of this course

These methods all make use of PRECONDITIONERS

The system equation, Ku=f, is multiplied by a preconditioner matrix, M,
to improve the condition number

Exercise: Show that
the best possible
preconditioner is the
matrix M=K
-1
Ku = b MKu = Mb
110
What you need to know about iterative solvers
They converge in at most n iterations (good)
Solution time is O(n
1
-n
2
) (good)
Solution time does depend on condition number
Memory requirements are O(n
1
-n
2
) (very good)
They are less robust that the direct solvers (neutral)
Convergence depends upon condition number
An ill-conditioned problem is often set up incorrectly
Different physics require different iterative methods (bad)
This is an ongoing research topic
Often cannot solve two physics with the same solver
Improvements in methods are ongoing
We have tried to find the best combination of iterative solvers and
preconditioners for many physics, to find these settings, read the manuals
or open a new model file, select a space dimension of 3D and the physics
you want to solve


111
Review
At this point, you should know:
What a direct solver does
Advantages and disadvantages of a direct solver
What an iterative solver does
What a preconditioner does
Advantages and disadvantages of an iterative solver



112
The linear system solver GUI
113
Monitor the memory requirements of the direct
solvers and convergence of iterative solvers for
the unit square as you refine the mesh
In class exercise:
Build a 3D heat transfer model
Try out different direct and iterative
solvers and compare to the default
114
This curve shows the iterative
solver approaching the
bottom of the residual
surface
The Solve Menu
Solve Problem
Uses the settings in the Solver Parameter and Solver Manager
Restart
Try to avoid this, it is better to use the Solver Manager
Update Model
Maps old solution onto a new mesh
Evaluates any additional expressions that you have added
Get Initial Value
Displays, as the solution, the specified initial condition
These are specified either via the Init tab on subdomain properties
or via the Solver Manager form
Solver Parameters
Allows you to select the solver type and linear system solver


115
Using the parametric solvers
Solve > Solver Parameters > Parametric solver
This scans over a set of expressions (frequency, load) but not time
All results are saved in the same model file (and can be compared)
Solve > Parametric Sweep
Also scans over a set of expressions
Can wrap this around a transient simulation
Results are saved in different model files
Can take advantage of parallel computing
File > Solidworks/Inventor Connection > Geometric Parameter Sweep
Scans over a set of geometric dimensions
Must define COMSOL expressions that drive CAD equations
Results are saved in different model files
This is the way to vary the geometry

Work the electric
impedance
sensor model
116
Computer architecture issues, 32- vs. 64-bit
A 32-bit architecture can store at most 2
32
numbers (~4GB RAM)
In practice, due to inefficient memory managers, most OSs can only allocate
about 1.5GB per process, and the available memory becomes fragmented
COMSOL allocates memory in chunks, and will fail if it tries to exceed ~1.5GB
A 64-bit system can address virtually unlimited memory
In practice, most desktop OSs address up to 128 GB RAM
Still need to have the RAM available for good performance
To solve a large model, a 64-bit computer and 64-bit OS is needed
No significant performance difference between OSs (Win, Linux, OSX)
There is no reliable way to predict memory requirements and speed
Too many variables involved, and some can have big effects
COMSOL recommends:
64-bit computer, 4-16GB RAM to start, leave room to expand, good graphics card

117
Solver selection for 1D and 2D problems
Begin with the default solver, UMFPACK or SPOOLES
Try out PARDISO, which may use less memory and solve faster
If running out of memory:
Use PARDISO out-of-core
Upgrade your computer, 64-bit & more memory
Make sure that your problem is not overly complicated, typical 2D models
should solve easily on a 32-bit computer with 2GB of RAM

If you are seeing differences between the solvers, check the
problem very carefully, this usually indicates a mistake in the model
If using PARDISO for fluid-flow type problems, turn off Check Tolerances in
the solver settings
118
Solver selection for 3D problems
Set up a linear problem first
Use the default solver settings for the physics you are solving
If you run out of memory, upgrade to 64-bit and more RAM
Monitor the memory requirements as you grow the problem size

Setup a non-linear problem only after you have successfully solved
a linear problem


119
Lecture 3: Multiphysics FE Problems
120
Consider two simple physics, on the same geometry
q=100 W/m
2
T=0K
All other surfaces
insulated
( )
0
0
100
0
2
= V
=
= V
= V V
T
K T
T k
T k
m
W
n
in the domain
right boundary
left boundary
other boundaries
f
T
= K
T
u
T
- b
T

Heat Transfer Conductive Media DC
All other surfaces
insulated
V=1V

V=0V
( )
0
0
1
0
= V
=
=
= V V
V
V V
V V
V o
in the domain
right boundary
left boundary
other boundaries
f
V
= K
V
u
V
- b
V

k = 1 W/mK
= 1S/m
121
This part of the matrix is zero because:
f
V
/ u
T
= 0
This part of the matrix is zero because:
f
T
/ u
V
= 0
How to solve this linear problem
f
T
(u
T
) = K
T
u
T
- b
T

f
V
(u
V
) = K
V
u
V
- b
V

( )
)
`

)
`

=
V
T
V
T
V
T
b
b
u
u
K 0
0 K
u f
Combine the two linear system equations:
( ) b Su
b
b
u
u
u f 0
0 u f
u f =
)
`

)
`

c c
c c
=
V
T
V
T
V V
T T
Solve this linear problem with a
single Newton-Raphson iteration:
( ) b Ku S u u =

0
1
0 sol
122
Now, consider a coupled multiphysics problem
= (1-0.001T) S/m
The temperature solution now affects the
material properties of the DC problem
f
T
= K
T
u
T
- b
T

f
V
= K
V
(u
T
)u
V
- b
V

q=100 W/m
2
T=0K
All other surfaces
insulated
Heat Transfer Conductive Media DC
All other surfaces
insulated
V=1V

V=0V
k = 1 W/mK
123
How to solve this coupled multiphysics problem
f
T
(u
T
) = K
T
u
T
- b
T

f
V
(u
V
) = K
V
(u
T
)u
V
- b
V
Take the two system equations:
( ) ( ) b u u K
b
b
u
u
u f u f
0 u f
u f =
)
`

)
`

c c c c
c c
=
V
T
V
T
V V T V
T T
This coupled problem is solved via
Newton-Raphson iterations:
( ) ( ) ( )
( ) | | ( )
i i i i
i i i i i
u f u u f u u
b u u K u S u u
1
1
1
1

+
c c =
=
Combine these into a single system equation:
This coupled multiphysics problem is solved in the exact
same way that a non-linear single physics problem is solved
Can no longer use the iterative solvers, since they are tuned
for single physics, and often can not handle the coupled terms
124
q=100 W/m
2
T=0K
Heat Transfer Conductive Media DC
All other surfaces
insulated
V=1V

V=0V
Q(V)
k = 1 W/mK
(T)
Consider more couplings between the physics
f
T
= K
T
u
T
- b
T
(u
v
) f
V
= K
V
(u
T
)u
V
- b
V

Volumetric resistive
heating due to current
( )
( )
( ) ( ) u b u u K
b
u b
u
u
u f u f
u f u f
u f =
)
`

)
`

c c c c
c c c c
=
V
V T
V
T
V V T V
V T T T
( ) ( ) ( ) ( )
( ) | | ( )
i i i i
i i i i i i
u f u u f u u
u b u u K u S u u
1
1
1
1

+
c c =
=
Same equation
as before
125
(T,V)
Consider all possible couplings between the physics
q(T,V)

V=V(T,V)

f
T
= K
T
(u
V
,u
T
)u
T
- b
T
(u
V
,u
T
)
k(T,V)
) , ( V T Q
vol
( )
( )
( )
( ) ( ) u b u u K
u u b
u u b
u
u
u f u f
u f u f
u f =
)
`

)
`

c c c c
c c c c
=
T V V
T V T
V
T
V V T V
V T T T
,
,
( ) ( ) ( ) ( )
( ) | | ( )
i i i i
i i i i i i
u f u u f u u
u b u u K u S u u
1
1
1
1

+
c c =
=
f
V
= K
V
(u
V
,u
T
)u
V
- b
V
(u
V
,u
T
)
V=V(T,V)

T=T(T,V)

General Newton-
Raphson multi-
physics iteration:
126
Different two-way couplings have different
computational requirements
( )
( )
( )
( ) ( ) u b u u K
u u b
u u b
u
u
u f u f
u f u f
u f =
)
`

)
`

c c c c
c c c c
=
T V V
T V T
V
T
V V T V
V T T T
,
,
If one or both of these are zero, then the memory requirements are less
If the couplings are weak then the problem converges faster
(T,V)
q(T,V)

V=V(T,V)

k(T,V)
) , ( V T Q
vol
V=V(T,V)

T=T(T,V)

127
Definitions of various types of couplings
One-way coupled
Information passes from one physics to the next, in one direction
Two-way coupled
Information gets passed back and forth between physics
Load coupled
The results from one physics affect only the loading on the other physics
Material coupled
The results from one physics affect the materials properties of other physics
Non-linear coupled
The results of one physics affects both that, and other, physics
Fully coupled
All of the above
Weakly coupled
The physics do not strongly affect the loads/properties in other physics
Strongly coupled
The opposite of weakly coupled

128
It is possible to solve multiphysics problems in a
segregated sense, solving each physics separately
( )
( )
( )
)
`

)
`

c c c c
c c c c
=
T V V
T V T
V
T
V V T V
V T T T
u u b
u u b
u
u
u f u f
u f u f
u f
,
,
Assume that these are approximately zero and ignore them
initialize u
T,i
, u
V,i

do {
u
T,i+1
= u
T,i
+S
T
(u
T,i
, u
V,i
)
-1
b
T
(u
T,i
, u
V,i
)
u
V,i+1
= u
V,i
+S
V
(u
T,i+1
, u
V,i
)
-1
b
V
(u
T,i+1
, u
V,i
)
i=i+1
}
while ( not_converged )
is damping
129
Solving in a segregated sense has some advantages
( )
)
`

)
`

c c c c
c c c c
=
V
T
V
T
V V T V
V T T T
b
b
u
u
u f u f
u f u f
u f ( )
)
`

)
`

c c
c c
=
V
T
V
T
V V
T T
b
b
u
u
u f 0
0 u f
u f
Less memory to store matrices:
Less memory to solve:
The Jacobian is O(2) times smaller in memory
( ) ( ) ( ) ( )
i i i i i i
u b u u K u S u u =

+
1
1
u
T,i+1
= u
T,i
+S
T
(u
T,i
, u
V,i
)
-1
b
T
(u
T,i
, u
V,i
)
u
V,i+1
= u
V,i
+S
V
(u
T,i+1
, u
V,i
)
-1
b
V
(u
T,i+1
, u
V,i
)
Jacobian is exactly 2 times smaller in degrees of freedom
The optimal iterative solver can be used for each physics
If the problem is strongly coupled, then the segregated approach
will not work, and a direct solver is often necessary since the
iterative solvers are not tuned for a general Jacobian matrix.
130
Achieving convergence for multiphysics problems
Set up the coupled problem and try solving it with a direct solver
If it is not converging:
Check initial conditions
Ramp the loads up
Ramp up the non-linear effects
Make sure that the problem is well posed (this can be very difficult!)
If you are running out of memory, or the solution time is very long:
Use the segregated solver and select the optimal solver (direct or iterative) for
each physics, or group of physics, in the problem. FOR 3D, START HERE!
Upgrade hardware
Try the PARDISO out-of-core solver
Perform a mesh refinement study


131
Hands on example: heat and current flow
through a square
J=10 A/m
2
V
L
=0

T
L
=0

All other surfaces insulated
Set up an Inward Current Flow
on the right side
k=1 W/mK

=1 S/m

All other surfaces insulated
Identical to previous problem
Conductive Media DC Application Mode Heat Transfer Application Mode
Set up and solve this uncoupled linear problem
q=100 W/m
2
132
Consider the following multi-physics couplings:
Volumetric
Heat Load
Thermal
Conductivity
Electric
Conductivity
Normal
Current
Iterations
Solution
Times (sec)
Linear 0 1 1 10 1 6.0
weak non-linear
uncoupled
0 1-(T/10000) 1-(V/1000) 10 3 18.0
one-way load
coupled
Q_dc 1 1 10 3 44.0
weak two-way
load coupled
Q_dc 1 1 10+(T/100) 3 48.0
weak fully
coupled
Q_dc 1-(V/1000) 1-(T/10000) 10+(T/100) 3 58.0
133
Thermal problem Electric problem
Hands on exercises: Ramp up the applied
current, and monitor peak temperature
134
exp(-T/600) exp(-T/600)
J
in
T
max
?
Ramp up inward current flow from 0-20 A/m
2
using the parametric solver.
Plot the temperature distribution. What happens? Why?
Thermal
Conductivity
Electric
Conductivity
1 1 Case 1
Case 2
Hands on exercises: Ramp up the applied
voltage, and monitor peak temperature
135
exp(-T/600) exp(-T/600)
V

T
max
?
Ramp up applied voltage, how high can it go? Why?
Thermal
Conductivity
Electric
Conductivity
1 1 Case 1
Case 2
Same as before
Using the segregated solver
Pick the best solver
for each physics
Can choose a
different damping
for each physics
136
When in doubt, set each physics to run to
convergence at each iteration
initialize u
T,i
, u
V,i

do {
do {
non-linear solution for u
T,i+1

use u
T,i
and u
V,i
as initial conditions
}
do {
non-linear solution for u
V,i+1

use u
T,i+1
and u
V,i
as initial conditions
}
i = i+1
}
while ( not_converged )
These settings are equivalent to solving the
complete non-linear problem at each iteration.
137
Additional physics and couplings
Physics... Global Equations...
Used to add an equation that must be satisfied during the solution
Adding additional constraints
Adding an Ordinary Differential Equation to the model
Options... Coupling Variables
Integration: Integrates quantities over a domain and makes them global
Extrusion: Takes expressions in N dimensions onto an N+1 dimension
Projection: Takes the integral of a quantity in N dimensions and projects it onto
an entity that has dimension N-1
Adding your own equations
Almost unlimited options, see booklet for example
Coefficient form
General form, simpler syntax than coefficient
Weak form, most flexible, but you need to know the terminology

138
Adding Ordinary Differential Equations (ODEs)
k
p(t)
u

c
0 ) ( = + + + =

t p ku u c u m Forces
( ) ( )
0 0
0 , 0 u u u u = =
m
139
Solving an ODE: Damped harmonic oscillator
( ) ( ) 0 0 , 1 0
0
= =
= + +
u u
ku u u

|
d underdampe , 2
overdamped , 2
damped critically , 2
k
k
k
<
>
=
|
|
|
overdamped, =100
underdamped, =1
critically damped, =10
Set up and solve this transient problem.
Solve for t = 0:0.01:10
140
Using a global equation as a constraint
141
P
F?
Set up this problem:
The load, P, on the cantilever beam causes some y-deflection, v, at the end.

What force, F, must be applied to get zero deflection at the end?
v
Adding an integration coupling variable, step 1
Set up and solve this Incompressible Steady State
Navier-Stokes fluid flow problem, (=1e3, =1e-3):
4 mm
1 mm
Wall, no slip
Wall, no slip
Inlet, Pressure,
no viscous stress
P = 0.1Pa
Outlet, Pressure,
no viscous stress
P = 0 Pa
Solution, exhibiting
entrance effect
In post-processing, do a
boundary integration of:
rho_ns*u*1[m]
A vd
A
}

The mass flux integral is taken per


unit inch out of the modeling plane
142
Adding an integration coupling variable, step 2
Go to Options... Constants...

Add a constant: MassFluxApplied = 1[g/s]

Go to Options... Integration Coupling Variables... Boundary Variables...

Add a variable to boundary 1 called MassFlux, as shown below
143
Adding an integration coupling variable, step 3
Modify the applied
pressure at the inlet
Add a global equation
This adds an equation, AppliedP,
that must be satisfied.
COMSOL adjusts the inlet pressure
to satisfy the condition on the total
mass flux through the boundary
Solve again, and integrate the mass flux across the
boundary. Mass flux, which is a function of fluid velocity,
has be fixed by applying a constraint on pressure.
Caution! This approach will, under
some conditions, introduce a factor
of two into the model. If you see this,
switch to Non-ideal Constraints
144
Adding your own governing equation
145
Coefficient Form
of the PDE
General Form
of the PDE
Weak Form
of the PDE
( )
0 others all , , , = = = =
= V + + + V V
Q f T u k c
f u au u u c | o
Q F
Ty k
Tx k
x T k
x T k
F
=
)
`

=
)
`

c c
c c
= I
= I V
,
*
*
Heat Transfer
PDE
( ) Q T k = V V
( )
test(T) * Q_ht + test(Ty) * Ty * k_ht - test(Tx) * Tx * k_ht -
0 = I + O + V V
} }
I O
d vq d vQ u k v
Most common PDEs
are implemented
Enter the
coefficients for the
PDE of interest
More compact way
of entering certain
equations
Most flexible,
requires that you
know how to get to
the weak form
Review
At this point, you should know:
What a multi-physics problem is
How a multi-physics problem is solved
The definition of a coupled multi-physics problem
The difference between a load and a material coupling
The difference between one- and two-way couplings
How the couplings can affect solve time & memory requirements
What the segregated solver does
How to add additional couplings and physics




146
Hands on: Fluid-Structure Interaction
Fluid moves through the domain,
solid deforms the domain
The mesh deforms the due to the
structural analysis
Loads are automatically passed
between the two physics using
the FSI application mode
147
Lecture 4: Time-stepping and reducing
the error in the finite element model
148
Introduction to time-dependent solutions
b Ku u f
u
= =
c
c
) (
t
( ) Q T k
t
T
C
p
= V V
c
c

t t t
t t
t t
b u K
u u u
=
A

=
c
c
+1
( )
t t t t t
t u b u K u + A =
+1
1 1 1
1
+ + +
+
=
A

=
c
c
t t t
t t
t t
b u K
u u u
( )
1 1 1 + + +
A = A
t t t t
t t b u u K I
Governing Equation
Time-dependent finite element formulation
Explicit time-stepping
Implicit time-stepping
Faster
More stable
Slower
Simple
149
Backward Difference Formula (BDF) order
( )
1 1 1 + + +
A = A
t t t t
t t b u u K I
t+1
k(t)
A polynomial is fit through
n previous points to
predict properties at t+1
Here, the BDF order is n=3
t t-1 t-2
150
COMSOL picks its own optimum timesteps
These are the output
timesteps, the times
you want to see the
solution at.
They do not affect the
internal timesteps.
The internal timesteps
are controlled by the
TOLERANCES.
151
Absolute and Relative Tolerance
Solutions within
Relative tolerance
Solutions within
Absolute tolerance
t
u
t
u
True solution
t
u
At solutions near
zero, the relative
tolerance cannot be
used, since it would
result in very small
timesteps
t
u
Tighten both the
absolute and
relative tolerance
until you are
satisfied with the
results over time.
152
The absolute tolerance can be different for
each solution variable
Temperature:
Relative Tolerance: 1%
Absolute tolerance: 0.1K
Voltage:
Relative Tolerance: 1%
Absolute tolerance: 0.001V
Often need to set this
when solving multi-
physics problems
153
Other timestepping options
Specify when to store,
and which time-steps
to solve at.
Give a condition to stop
at, when this expression
becomes negative
Selecting the physics at
startup will usually load
the appropriate settings
into this form.
For wave type problems,
gen-alpha is often better.
BDF order, set max and
min to 2 and 1 for wave
problems.
154
Make sure not to impose any ringing loads,
unless they are really there
155
Load

time

Response

time

A reasonable starting point is necessary
The load applied at t = 0 must agree with the initial condition
It is helpful to a have a load with time derivative zero at t = 0
The Init tab of the Subdomain Settings form sets initial conditions
The Solver Manager... Initial Value tab overwrites that information
Most common mistake:
Initial conditions for fluid flow: u = 0
Velocity/Pressure inlet condition
that does NOT ramp up from zero

Solution:
Use flc1hs function to ramp load
and to keep db/dt(t=0)=0
t
u
t
b
u(t
initial
) = [K
steady-state
]
-1
b(t
initial
)

156
Convergence of a transient problem
t
u
Outside envelop is absolute
and relative tolerance
True solution
(unknown)
Observe the solution with respect to time and
monitor the magnitude of the changes as the
tolerances are increased.
The problem is converged when you say it is.
157
The mesh must be fine enough with respect to
space and time
Transient 1-D slab
T
fixed


x
T
init

q


T
increasing
time
Hands on:
1) Go back to heat transfer square model
2) Change the analysis type to Transient
3) Set material properties: =1, C
p
=1
4) Solve transiently for 1 second (default)
5) Store all timesteps taken by solver
6) Examine results at initial timesteps
158
There are two ways to minimize this problem
Modify the mesh
Use boundary layer
meshing to better resolve
the step in the solution
Modify the physics
Use a smoothed step
function to gradually ramp
up the heat load:
flc1hs(t-0.01,0.01)
t
q q
159
Solving transient problems
Begin by assuming the problem is well posed, try solving it by
ramping all loads up from consistent initial conditions
Tighten the tolerances and see if you get a converging answer
If it is not converging:
Refine the mesh
Smooth out abrupt differences in loads and properties as reasonable
Try linearized properties
Some non-linear properties may require a very fine mesh and small time-step
Check the physics carefully
If the solution takes a long time, or runs out of memory
Use the time-dependent segregated solver using all previous guidelines
Upgrade hardware


160
What we have learned...
Theory of non-linear single physics finite element modeling
Meshing techniques and guidelines
Theory of multiphysics modeling, adding couplings to the model
Understanding what the solver is doing
Transient modeling


How to get confidence in your results




161
Bibliography & Resources
The Model Library:
www.comsol.com/showroom
COMSOL Papers database:
www.comsol.com/papers
Google Scholar, 5000+ papers:
www.scholar.google.com
Books written with COMSOL:
www.comsol.com/academic/books/
COMSOL Support:
http://www.comsol.com/support
COMSOL Exchange:
www.comsol.com/community/exchange/

162
COMSOL Documentation&References

Nonlinear Programming, Bertsekas

Scientific Computing, Heath

Fundamentals of Heat and Mass
Transfer, Incorpera & DeWitt

Nonlinear Finite Elements for Continua
and Structures, Belytchko, Liu, Moran

Whatever FEA book you like

Closing Remarks and Questions
163

You might also like