Upload
efgsdgerg
View
213
Download
0
Tags:
Embed Size (px)
DESCRIPTION
asf
Citation preview
Results
• Results = Postprocessing section
• Working with Data Sets
• Getting Derived Values
• Cross section plots
• Revolving solution
• Report = Exporting results
Menubar options
Point evaluationCut lines Cut planes • Slice
• Isosurface
• Volume
• Surface
• Line (edge)
• Arrow (in volume)
• Streamline
• Animate (transient
and parametric only)
Data Sets – Solution and Selection
Choose desired
geometric level
Select the desired
geometric entities
Results can be
visualized only on
the desired
geometric entities
1
2
3
4
Derived Values
• Results > Derived Values
• Allows you to evaluate and visualize numerical data
• Automatically creates table under Results > Table
Integrate any spatially
dependent variable on
appropriate geometric
entity level
Evaluates a variable at a point
or geometric vertices
Evaluates global variables,
lumped parameters and built-in
physical constants
Cross sections – Cut line
1Create a cut line
by selecting any
two points
2See the
coordinates under
Results > Data
Sets > Cut Line
3
Check the plot
along that cut line
in an automatically
created new 1D
Plot Group
Cross sections – Cut plane
1Create a cut plane
2
See the
coordinates
under
Results >
Data Sets >
Cut Plane
3
Check the plot along
that cut plane in an
automatically created
new 2D Plot Group
Revolving solution
2D solution
3D solution
See model file:
Example_results_revolve
Exporting results
Exported data can
be read into a
spreadsheet
Hands-on #6: Tuning Fork
• Structural model
• Eigenfrequency analysis
• Mode shapes
Equation-based Modeling in COMSOL
• PDEs, ODEs, and Algebraic Equations
• Use COMSOL’s GUI – no need for subroutines
• Why solve equations?
– Purely mathematical problems
– Combining predefined physics interface with additional equations
– Represent physics which is not available in the predefined options
• What does it mean to “solve” a PDE?
– Well-posed problems; existence, uniqueness, and smoothness
– Garbage in -> garbage out
• COMSOL uses the finite element method (FEM) to numerically
approximate solutions
Equations interface: Classical PDEs
• Built-in options for more common PDE forms
• Easy to use if you can fit your problem into any of these forms
• Available for 1D, 2D and 3D geometries
0 u
0)( uutt
uu )(
fu
Equations interface: More options
• Open-ended options for solving almost any PDE
• Options to enter in either differential or integral (weak) form
• Available for 1D, 2D and 3D geometries
• ODEs and DAEs can be solved on 0D
Coefficient Form
ru
guuc )( non boundary
mass damped mass
diffusion
convection
source
convection
absorption
source
fauuuuct
ud
t
ue aa
)(
2
2
In the domain
Example: Poisson’s equation
1 u
0u
inside subdomain
on subdomain boundary
Implies c = f = 1 and all other coefficients are 0.
mass damped mass
elastic stress initial/thermal stress
body force (gravitation)
a
ae
d
c
c
u
2
2( )a ae d c a f
t t
u uu u u u
Coefficient Form: Structural Analysis
density
damping coefficient
stress
Stiffness, “spring constant”
This is how
COMSOL solves
other physics
Information on equation interface
• PDEs can have as many variables (u1, u2, u3,…)
• Variables can be real or complex (u1 = a+j*b)
• Coefficients can be almost anything
- Scalar (numerical values)
- Vector or tensors (for multiple variables)
- Parameters and Variables (user-defined expressions)
- Functions of spatial coordinates and time (non-linear in space and/or
time)
- Functions of other physics variables (when PDE is coupled to another
predefined physics in a multiphysics model)
- Functions of variables being solved for (nonlinear in solution space)
- Derivatives of variables (highly nonlinear PDEs, also a way to
implement higher order equations)
The weak form is a variational statement of the problem in
which we integrate against a test function.
This has the effect of relaxing the problem; instead of finding
an exact solution everywhere, we are finding a solution that
satisfies the strong form on average over the domain.
Modeling using weak Form
Modeling using weak Form
Example1: Modeling using weak form Squeeze
film damping Velocity v
h
vdr
dphr
dr
d
r
12
1 3
Boundary Conditions:
0dr
dpat r = 0 and p = 0 at r = r0
pambient
p < pambient
lubricant
Example2: Damped harmonic oscillator
0)( tpkuucumForces
00 0,0 uuuu
k
p(t)
u
c m
00,10
0
uu
kuuu
dunderdampe ,2
overdamped ,2
damped critically ,2
k
k
k
Damped harmonic oscillator
overdamped, β=100
underdamped, β=1
critically damped, β=10
beta is a parameter
• 2nd order ODE
• 0D model
• Transient + Parametric
See model file:
Example_harmonic_oscillator
Example 2: CFD + Global equation
Set up and solve this Incompressible Steady State
Navier-Stokes fluid flow problem, (ρ=1e3, η=1e-3):
4 mm1 mm
Wall, no slip
Wall, no slip
Inlet, Pressure,
no viscous stress
P = p_in
Outlet, Pressure,
no viscous stress
P = 0 Pa
Solution, exhibiting
entrance effect
Integration coupling
operator on inlet:
spf.rho*u*1[m]
AvdfluxmassA
The mass flux integral is taken per unit
length out of the modeling plane 155
CFD + Global equation
mass_flux is a variable
• Combine CFD + equation
• Evaluate required pressure to get
desired mass flux at the inlet
• 2D model
• Stationary + Parametric
See model file:
Example_CFD_massflux
mass_flux_required is a parameter
Hands-on #7: Spherically Symmetric Transport
• Spherical symmetry
represented as 1D
• Equation-based model
• Time-dependent
Linear and Nonlinear FEA
• FEA formulation
• Linear problem
• Nonlinear problem
• Suggestions on convergence
A very simple finite element problem...
p= 2 Nk2 = 4 N/m k3 = 4 N/m
u1 u2u3
We can write a force balance on each node:
Node 1
c
k1(u3-u1)
Node 2
k3(u3-u2)-k2(u2-u1)
k1 = 6 N/m
k2(u2-u1)
Constraint Force
Node 3
p
-k1(u3-u1)
-k3(u3-u2)
Write the force balance as three equations:
However, we now have three equations in four unknowns, c, u1, u2, u3
k1(u3-u1) + k2(u2-u1) = c
k2(u2-u1) - k3(u3-u2) = 0
k1(u3-u1) + k3(u3-u2) = p
(k2)u2 + (k1)u3 = c
(k2+k3)u2 + (-k3)u3 = 0
(-k3)u2 + (k1+k3)u3 = p
Algebra
Constraint Equations
System Equations
k1(u3 - 0 ) + k2(u2 - 0 ) = c
k2(u2 - 0 ) - k3(u3 - u2) = 0
k1(u3 - 0 ) + k3(u3 - u2) = p
Three equations, three
unknowns: c,u2, u3
But we also have a constraint, u1=0
Can now solve the problem
(k2)u2 + (k1)u3 = c
(k2+k3)u2 + (-k3)u3 = 0
(-k3)u2 + (k1+k3)u3 = p
cu
ukk
3
2
12
pu
u
kkk
kkk 0
3
2
313
332
Solve the system
equations first
Ku=b
u=K-1b
k1= 6 N/m
k2=k3= 4 N/m
p=2 N
250.0
125.0
3
2
u
u
Can also solve the
constraint equations,
if desired
2250.0
125.064
Linear and nonlinear problems
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
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
Linear
u
k(u), b(u)
Weakly Non-linear
u
k(u), b(u)
Strongly Non-linear
u
k(u), b(u)
“Outrageously”
Non-linear
There are no clear distinctions
between these three cases
Not all non-linear problems have a (unique) solution
load
solution
No solution
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)
usolution= 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)
usolution≈ 0.853
First, solve the linear problem
f (u) = 2 - 4 u = 0
f (u)
usolution=0.5
Algorithm:
1) Start at a point, e.g. u0 = 0
2) Find the slope, f’(u0)
3) Solve the problem:
0
00
' uf
ufuusolution
5.04
20
solutionu
(1)(2)
(3)
i
iii
uf
ufuu
'1 This is a single Newton-Raphson iteration:
For a linear problem, the starting point does not matter
Solving a FE system matrix is equivalent to taking
a single Newton-Raphson iteration
f (u) = 2 - 4 u = 0
0
00
' uf
ufuusolution
5.04
20
solutionu
pu
u
kkk
kkk 0
3
2
313
332
0
00
3
2
313
332
u
u
kkk
kkk
puf
f (u) = b - Ku, u0 = 0
K
b
K
Kub0
uf
ufuu
0
0
00
'solution
bKu1solution
4 u = 2
The non-linear problem is solved the same way
Algorithm:
1) Start at a point, e.g. u0 = 0
2) Take repeated Newton-
Raphson iterations
3) Terminate when:
f (u) = 2 - exp(u) u
u
f (u)
toleranceuuff iiii /&/ 11
Similarly, if we have a non-linear system matrix
f (u) = b(u) - K(u)u
iiiii
i
iii uuKubuSu
uf
ufuu
1
1'
f′(u) = S(u)
Iterate until: toleranceff iiii uu /&/ 11
p= 2k2 = exp(u2-u1) k3 = 4
u1 u2u3
k1 = 6 + (u3-u1)2
S(u) is known as the JACOBIAN
The possibility of convergence of a non-linear
problem is dependent upon the starting point, u0
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
u0= -1
Finding a good starting point, u0, 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
A damping factor, α, is used to improve convergence
u
f (u)
i
iii
uf
ufuu
'1
choose (α < 1) & (α<αprevious)
while ( |fi+1| > |fi| )
recompute fi+1(ui+1)
end
|fi|
undamped |fi+1|
intermediate |fi+1|
final |fi+1|
f (u) = 2 - exp(u) u
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
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
- kNL = exp(u)
Linearize around chosen u0
- kLIN = exp(u0=0) = 1
Use an intermediate value
- k = (1-χ)kLIN+χkNL
- χ starts at 0
Use intermediate solution as new u0
Ramp χ from 0 to 1
Example - Heat flow through a square
T=0K
q = 100 W/m2
k, Thermal conductivity
1x1m square
Build this 2D model in Heat Transfer,
Save this model, we will build upon this
Mesh
Solution
Tinitial=0K
Insulated
Insulated
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 #3 with an initial temperature of 50[K], how does this
affect the solution? What about the other cases?
– Set back to T=0 afterwards
Ramp up the heat load and monitor peak temperature
T
k =(1-T/200[K])[W/(m*K)]
Qin
Tmax
?
Why does this happen?
Use qflux as a parameter and ramp it up
as range(50,5,110)
The stationary adaptive mesher
Initial mesh
Final mesh
Meshes > Mesh 2
Go back to the square model, case 3
k = 0.1+exp(-(T/25[K])^2)[W/(m*K)]
Add Study 1 > Solver Sequences > Solver
Sequence 1 > Stationary 1 > Adaptive mesh
refinement
Triangular and tetrahedral
elements ONLY are subdivided
based on the L2 norm error
estimate.
The Study node
Assign the parameter, mesh
and physics to be used in this
study
This section contains more
information about the solver
settings
Stationary solver settings
…Solver Configurations > Stationary Solver 1
Stop condition for
Newton iterations
• COMSOL can inspect the
stiffness matrix and decide whether
the problem is linear or nonlinear
• We can also explicitly choose
linear or nonlinear
Solver settings – more information
…Solver Configurations > Stationary Solver 1 > Fully Coupled 1
Linear system of equations is
solved using the specified solver
Stop condition for
Newton iterations
Can choose different
damping methods
Convergence Criteria
Non-linear solver algorithm
Linearized about an initial guess point
Calculate relative error E:
If decrease
Stop iterations when weighted relative error < relative tolerance
0)( Uf
0U
00
' UfUUf UUU 01
is the damping factor 10
10
' UfEUf
1__ iterationcurrentiterationcurrent EE
Revisit: k = (0.1+10*(T>25[K]))
Instead of using a “jump” in k, use a smoothing function
Now try: k = 0.1+DK*flc2hs(T-25,STEP)[W/(m*K)]
Try: DK, STEP = 0 8 2.5 4 5 2 7.5 0.5 10 0.25
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
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?
Not converging?
Not converging?
Not converging?
Not converging?
Converging?
Not converging?
Converging?
Hands on #8: H-Bend Waveguide
• Electromagnetic Waves
• Frequency domain study
Solving the Linear System Matrix
• Linear system matrix
• Direct methods
• Iterative methods
• Suggestions on solver selection
Let’s take another look at the system equations
0Kubuf
0
00
3
2
313
332
u
u
kkk
kkk
p
Define a quadratic function: r(u) = b·u-½Ku·u
u2
u3r(u)
SolutionThe solution, f(usolution) = 0, is
the point where r(u), is at a
minimum
Finding the minimum of a quadratic function
r (u) = 2u2 - 3u + 1
r (u)
u
Newton’s method: 0
00
u
uuu
r
rsol
For a quadratic function, this
converges in one iteration, for any u0
r′(u) = 4u - 3
r″(u) = 4
75.04
3040
0
00
ur
uruusol
u0 = 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
Kubu
u
uuu
0
0
0
00
r
rsol
0u 0
bKK
b0u
1sol
usol
Finding the minimum of the quadratic function,
r(u), by the direct method means solving u=K-1b
• 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(n2)-O(n3) numeric operations, where n is the length of u
– Robustness of the algorithm is only very weakly dependent upon K
• The direct solvers in COMSOL are:
– MUMPS: fast, required for cluster computation
– PARDISO: fast, multi-core capable
– SPOOLES: slow, uses the least memory, multi-core capable
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 in one
step by evaluating [r″(u)]-1
The numerical values in K can affect the algorithm
u2
u3r(u)
Quadratic
surface
r(u) = b·u-½Ku·u
Condition
number = 1
Condition
number = 2
Condition
number = 10The higher the condition number the more
numerical error creeps into the solution
Ill-conditioned matrices require more iterations
Numerical error becomes significant
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 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
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, GMRES, FGMRES and BiCGStab
The details of these algorithms are beyond the scope of this course
All these methods make use of PRECONDITIONERS
The system equation, Ku = b, 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
What you need to know about iterative solvers
• They converge in at most n iterations (good)
• Solution time is O(n1-n2) (good)– Solution time depends on condition number
• Memory requirements are O(n1-n2) (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
Solver selection for 1D and 2D problems
• Begin with the default solver, MUMPS, PARDISO or SPOOLES
• If running out of memory:
– Use MUMPS or 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
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
FEA formulation in Multiphysics problems
• Interpreting multiphysics FEA
• Fully-coupled and Segregated Solvers
• Suggestions on convergence of multiphysics problems
Consider two simple physics, on the same geometry
q=100 W/m2
T=0K
All other surfaces
insulated
0
0
100
0
2
T
KT
Tk
Tk
m
Wn
in the domain
right boundary
left boundary
other boundaries
fT = KTuT - bT
Heat Transfer Electric currents
All other surfaces
insulated
V=1VV=0V
0
0
1
0
V
VV
VV
V in the domain
right boundary
left boundary
other boundaries
fV = KVuV - bV
k = 1 W/mK σ = 1S/m
This part of the matrix is zero because: ∂fV / ∂uT = 0
This part of the matrix is zero because: ∂fT / ∂uV = 0
How to solve this linear problem
fT (uT) = KTuT - bT
fV (uV) = KVuV - bV
V
T
V
T
V
T
b
b
u
u
K0
0Kuf
Combine the two linear system equations:
bSub
b
u
u
uf0
0ufuf
V
T
V
T
VV
TT
Solve this linear problem with a
single Newton-Raphson iteration: bKuSuu
0
1
0sol
Now, consider a coupled multiphysics problem
σ = (1-0.001×T) S/m
The temperature solution now affects the
material properties of the electrical problem
fT = KTuT - bTfV = KV(uT)uV - bV
q=100 W/m2
T=0K
All other surfaces
insulated
All other surfaces
insulated
V=1VV=0Vk = 1 W/mK
Heat Transfer Electric currents
How to solve this coupled multiphysics problem
fT (uT) = KTuT - bT
fV (uV) = KV(uT)uV - bV
Take the two system equations:
buuKb
b
u
u
ufuf
0ufuf
V
T
V
T
VVTV
TT
This coupled problem is solved via
Newton-Raphson iterations:
iiii
iiiii
ufuufuu
buuKuSuu
1
1
1
1
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
May no longer use the iterative solvers, since they are tuned
for single physics, and often can not handle the coupled terms
q=100 W/m2
T=0K
All other surfaces
insulated
V=1VV=0VQ(V)
k = 1 W/mK σ(T)
Consider more couplings between the physics
fT = KTuT - bT(uv) fV = KV(uT)uV - bV
Volumetric resistive
heating due to current
ubuuKb
ub
u
u
ufuf
ufufuf
V
VT
V
T
VVTV
VTTT
iiii
iiiiii
ufuufuu
ubuuKuSuu
1
1
1
1
Same equation
as before
Heat Transfer Electric currents
σ(T,V)
Consider all possible couplings between the physics
q(T,V)
V=V(T,V)
fT = KT(uV,uT)uT - bT(uV,uT)
k(T,V)
),( VTQvol
ubuuKuub
uub
u
u
ufuf
ufufuf
TVV
TVT
V
T
VVTV
VTTT
,
,
iiii
iiiiii
ufuufuu
ubuuKuSuu
1
1
1
1
fV = KV(uV,uT)uV - bV(uV,uT)
V=V(T,V)T=T(T,V)
General Newton-
Raphson multi-
physics iteration:
Different two-way couplings have different
computational requirements
ubuuKuub
uub
u
u
ufuf
ufufuf
TVV
TVT
V
T
VVTV
VTTT
,
,
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)
),( VTQvolV=V(T,V)
T=T(T,V)
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
It is possible to solve multiphysics problems in a
segregated sense, solving each physics separately
TVV
TVT
V
T
VVTV
VTTT
uub
uub
u
u
ufuf
ufufuf
,
,
Assume that these are approximately zero and ignore them
initialize uT,i, uV,i
do {
uT,i+1= uT,i+αST(uT,i, uV,i)-1bT(uT,i, uV,i)
uV,i+1= uV,i+αSV(uT,i+1, uV,i)-1bV(uT,i+1, uV,i)
i=i+1
}
while ( not_converged )
α is damping
Solving in a segregated sense has some advantages
V
T
V
T
VVTV
VTTT
b
b
u
u
ufuf
ufufuf
V
T
V
T
VV
TT
b
b
u
u
uf0
0ufuf
Less memory to store matrices:
Less memory to solve:
iiiiii ubuuKuSuu
1
1
uT,i+1= uT,i+αST(uT,i, uV,i)-1bT(uT,i, uV,i)
uV,i+1= uV,i+αSV(uT,i+1, uV,i)-1bV(uT,i+1, uV,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.
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
An uncoupled problem
J=10 A/m2
VL=0TL=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
q=100 W/m2
Heat Transfer Electric currents
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 3.572
Non-linear
uncoupled0 1-(T/10000) 1-(V/1000) 10 2 9.422
One-way load
coupled
Joule
Heating1 1 10 3 27.846
Two-way load
coupled
Joule
Heating1 1 10+(T/100) 3 29.703
Fully coupledJoule
Heating1-(V/1000) 1-(T/10000) 10+(T/100) 3 29.469
Thermal problem Electric problem
Try yourself: heat and current flow through a
unit cube
J=10 A/m2
VL=0TL=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
Set up and solve this coupled problem
q=100 W/m2
Heat Transfer Electric currents
Q(V) W/m3
Try yourself: Ramp up the applied current,
and monitor peak temperature
exp(-T/600) exp(-T/600)
Jin
Tmax
?
• Use the parametric solver
• Ramp up inward current density range(0,2,20)
• Plot the temperature distribution.
• What happens?
• Why?
Thermal
Conductivity
Electric
Conductivity
1 1Case 1
Case 2
Hands on exercises: Instead of current
density apply a voltage
exp(-T/600) exp(-T/600)
V
Tmax
?
• Ramp up applied voltage range(0,20,140)
• How high can it go?
• Why?
Thermal
Conductivity
Electric
Conductivity
1 1Case 1
Case 2
Same as before
Try boundary layer mesh with 50 layers where needed.
Keep mesh size to fine.
Using the segregated solver
Study > Solver Configurations > Solver
1> Stationary Solver1>Segregated
Can add multiple
Segregated steps as
required
Segregated step
Choose the
variable/s that you
want to solve in this
segregated step
Choose the linear
system solver and
the damping method
for each segregated
step
Study > Solver Configurations > Solver
1> Stationary Solver1>Segregated
When in doubt, set each physics to run to
convergence at each iteration
initialize uT,i, uV,i
do {
do {
non-linear solution for uT,i+1
use uT,i and uV,i as initial conditions
}
do {
non-linear solution for uV,i+1
use uT,i+1 and uV,i as initial conditions
}
i = i+1
}
while ( not_converged )
These settings are equivalent
to solving the complete non-
linear problem at each
iteration.
Recap: Working with solvers
• A problem could be Linear or Nonlinear
• The linear system of equations could be solved using a Direct
Solver or an Iterative Solver
• A multiphysics problem could be solved using a Fully-Coupled
Approach or Segregated Approach
You cannot model everything
• You can never model the
entire universe
• Boundary conditions
represent the outside
• Two types: physical walls and
artificial boundaries
• Use artificial boundaries to
model only the region of
interest
Model
Everything else
BC
BC
BC BC
Something else
Infinite Elements• Currently in ACDC and Heat Transfer
• Draw Rectangle, 2 Large Circles,
– Add Outer Inf Elem Geom
• Subdomain > Make Circles Not Active and
infinite elements (aluminum)
• Rectangle Boundaries Thermal Insulation
• Left Circle: T = 300[K] Right Circle T = 273[K]
• Compute
• subdmain – make active infinite elements
• Subdomain – Inf Elem Tab – Match Matls
• Inf Elems >Cartesian,
• compute Hide Inf Element Subdomains
See model file:
Example_Infinite Elements
Perfectly Matched Layers
Absorbing Subdomain
• Absorbs incident waves without reflection
• Artificial boundary for non-enclosed spaces
• Used instead of radiation boundary condition
• Make thickness at least one wavelength with
atleast 5 elements
PML
• Circle 1: R= 8 Center: (0,2)
• Circle 2: R=10 Center: (0,2)
• Circle 3: R= 4 Center: (0,0)
• Union C1+C2
• Difference all
• f =100 Hz c =343 m/sec (air)
• L=c/f = 3.4 Mesh Size = 3.4/5
• Inner Circle Acceleration BC, a0=1Sound Hard Wall Radiation - Cylindrical PML - Cylindrical
See model file: Example_PML
Hands-on #9: Piezoacoustic Transducer
• 3-physics: Piezoelectric
material (structural +
electrical) + Acoustics
• Uses symmetry
• Perfectly Matched Layer
• Custom mesh
• Frequency domain
• mm scale geometry
Time-dependent problems
• Time-dependent formulation
• Tolerance and other attributes of time-dependent solver
• Suggestions on convergence of time-dependent problems
Introduction to time-dependent solutions
bKuufu
)(
t
QTkt
TCp
ttttt
ttbuK
uuu
1
ttttt t ubuKu 1
1111
ttt
tt
ttbuK
uuu
111 tttt tt buuKI
Governing Equation
Time-dependent finite element formulation
Explicit time-stepping
Implicit time-steppingFaster
More stable
Slower
Simple
Backward Difference Formula (BDF) order
111 tttt tt buuKI A polynomial is fit through n
previous points to predict
properties at t+1
Here, the BDF order is n = 3
t+1
k(t)
tt-1t-2
• Keep Max order
to 2 for stable
Scheme
• Higher order
means more
accuracy but
smaller time steps
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.
Absolute and Relative Tolerance
Solutions within
Relative tolerance
Solutions within
Absolute tolerance
t
u
t
u
True solution
t
uAt 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.
The absolute tolerance can be different for
each solution variable
Temperature:
Absolute tolerance: ±0.1K
Voltage:
Absolute tolerance: ±0.001V
Often need to set this when
solving multi-physics problems
Other timestepping options
Free - time stepping method
chooses time steps freely
Intermediate - force the
time stepping method to
take at least one step in
each subinterval of the
times specified
Strict - force the time
stepping method to take
steps that end at the times
specified
Selecting the physics at
startup will usually load
the appropriate settings.
For wave type problems,
Generalized-alpha is
often better.
BDF order, set max and
min to 2 and 1 for wave
problems.
More timestepping options
Specify for which steps
the solutions should be
stored
Make sure not to impose any “ringing” loads,
unless they are really there
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 Physics > Initial Values node is used to set initial conditions
• The Solver Configurations > Dependent Variables > Initial Valuesarea can be used to overwrite 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 flc2hs or a smoothed step
function to ramp load from an initial
conditiont
u
t
b
u(tinitial) = [K]-1b(tinitial)
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.
The mesh must be fine enough with respect to
space and time
Transient 1-D slab
Tfixed
x
Tinitq
T
increasing
time
Try yourself:
1) Heat transfer in a unit square model
2) Change the analysis type to Transient
3) Set material properties: ρ=1, Cp=1
4) Solve transiently for 1 second (default)
5) Store all timesteps taken by solver
6) Examine results at initial timesteps
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
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
Hands-on #10: Star Chip
• Laminar flow
• Multiple pulsating inlets
with phase difference
• Swept mesh
• Time-dependent boundary
conditions
• Setting absolute tolerance
Summary
• COMSOL graphical user interface
• Variables, functions, model couplings
• Geometry creation, sequencing, parametrization, CAD import
• Handling built-in and user-defined materials
• Meshing techniques
• Postprocessing techniques
• PDE interface
• Linear and nonlinear problems
• Direct and iterative solvers
• Fully-coupled and segregated approach
• Time-dependent study
End of Slides