Anda di halaman 1dari 26

24/12/2011

Solver Sequences and Settings

The Study Node

24/12/2011

Study Step
Study Step

Controls:
Which Meshes to use
Which Physics Interfaces to solve for
Some fundamental settings for the study type (e.g.
the continuation solver for a Stationary or the time
span for a Time Dependent)

Solver Sequence
Solver Sequence

Controls the sequence of:


Study Steps
Variables (unknowns) used
Solvers used

24/12/2011

Study Step Pointer

Pointer to Study Step

Note: May point to Study


Step of different Study:
Study 2, Study 3 etc.

Variables

Controls:
Variables Not Solved For
Initial Values
Scaling
Corresponds roughly to Old
Solver Manager Init Page

24/12/2011

Solver Settings

Corresponds to Solver
Parameters of 3.5a.
Solver tolerances are set here

Computing a Solution
Automatically generate a Solver
Sequence corresponding to the Study
steps and compute the solution.

Only generate a Solver Sequence


corresponding to the Study Steps.
For manual inspection/editing. No
computations.

24/12/2011

Computing a Solution: When Editing Low-Level Settings


Compute Using Attached Sequence
Compute Using Attached Sequence will use

a Solver Sequence that you have


manually edited.

Here: using Compute instead would


generate a new default Solver Sequence
to avoid overwriting your changes

Computing a Solution: Sequence Level


Use this Solver Sequence

24/12/2011

Computing a solution
Use the nodes up to and
including this node (here
Variables).

Use all nodes in the Solver


Sequence

Study Type: Bundle of Several Study Steps

One Study Type (Frequency


Domain Model) = Two Study
Steps (Eigenfrequency &
Frequence Domain Modal)

24/12/2011

The Study Node


Study defines how to solve a model
Study Steps
Solver Configurations
Job Configurations

Check Show More


Options to see:
Solver Configurations
Job Configurations

Study Steps

You can add multiple study steps by right-clicking on the Study node
COMSOL automatically uses the solution of the first study step as the
initial value for the second study step

24/12/2011

Solver Configurations

Contains all the solver settings and sequences


This is where you tune the solver
To look at the Solver Configurations before solving, right-click on
Solver Configurations and select Show Default Solver

Solver Configurations More details

Information on study step

Information on variables being


solved and their initial values
Detailed information on solver settings
such as choice of solver, tolerance, etc.

24/12/2011

Stationary Solver Settings

Stationary solver settings


Solver Sequence 1 > Stationary 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

24/12/2011

Solver settings more information


Solver Sequence 1 > Stationary 1 > Fully Coupled 1
Linear system of equations is
solved using the specified solver

Can choose different


damping methods

Stop condition for


Newton iterations

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)

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

10

24/12/2011

Achieving convergence for non-linear problems


DONE

Assuming that the problem is


well-posed, try solving it

Converging?

Not converging?

1) Check the initial condition


Not converging?
Converging?

2) Use parametric solver to ramp load


Not converging?

Perform a mesh
refinement study.
Try a finer mesh
and check that the
solution is similar.

3) Use parametric solver to ramp non-linearity


Not converging?

Not converging?

4) Refine the mesh


Not converging?

Does the problem have a steady-state solution?


Are there additional effects? Check all assumptions.

Solving the Linear System Matrix

Linear system matrix

Direct methods

Iterative methods

Suggestions on solver selection

11

24/12/2011

Lets take another look at the system equations


0 k k
f u 2 3
p k3

k3 u2 0
b Ku 0
k1 k3 u3 0

Define a quadratic function: r(u) = bu-Kuu


r(u)

u3

The solution, f(usolution) = 0, is


the point where r(u), is at a
minimum

Solution

u2

Finding the minimum of a quadratic function


r (u) = 2u2 - 3u + 1
Newtons method:

u sol u 0

r (u)

r u 0
r u 0

For a quadratic function, this


converges in one iteration, for any u0

usol
u

r(u) = 4u - 3
r(u) = 4
u0 = 0

usol u0

r u0
4 0 3
0
0.75

r u0
4

Via our choice of r(u), this reduces to the


same equation from the previous section:
r(u) = bu-Kuu
r(u) = b - Ku
r(u) = - K
r u 0
b Ku 0
u sol u 0
u0
r u 0
K
u0 0

u sol 0

b
K 1b
K

12

24/12/2011

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
Requires O(n2)-O(n3) memory
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

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

13

24/12/2011

Ill-conditioned matrices require more iterations

Numerical error becomes significant

A better iterative method for finding the minimum:


The Conjugate Gradient (CG) method
1) Start here
2) Initially, find the gradient vector
3) Find the minimum along that vector
4) Find the conjugate gradient vector*
5) Repeat 3-4 until converged
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


*) See e.g. Wikipedia, or Scientific Computing by Michael Heath

14

24/12/2011

Condition number matters for iterative methods

A matrix with a condition number of 1


will converge in one iteration, (rare!)

Numerical error becomes significant


for ill-conditioned matrices

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

15

24/12/2011

What you need to know about iterative solvers

They converge in at most n iterations (good)


Solution time is O(n1-n2) (good)

Memory requirements are O(n1-n2) (very good)


They are less robust that the direct solvers (neutral)

Solution time depends on condition number

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
GMRES and incomplete LU, is usually the best choice for multiphysics
problems

Choosing the linear system solver

COMSOL chooses the optimized solver and its settings


based on the chosen space dimension, physics and study type
We can also choose a different solver
- Not recommended in general
- Could be useful for multiphysics problems

16

24/12/2011

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 (write LU factors on hard drive, SLOW)
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
For some nonlinear problems (e.g. fluid-flow), set Check Error Estimate as
No in Study 1 > Solver Sequences > Solver Sequence 1 > Chosen study >
Direct

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

17

24/12/2011

Important notes on solvers

Direct
Robustness of the algorithm is only very weakly dependent upon K
The direct solvers in COMSOL are:
PARDISO: fast, BEST FIRST CHOICE FOR SHARED MEMORY
SPOOLES: slow, uses the least memory (Can run distributed)
MUMPS: slow, robust, uses the most memory BEST FIRST CHOICE FOR CLUSTER

Iterative
Slower than Direct
Convergence depends on condition number of K
Different physics require different solver configurations (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

Time Dependent Solver Settings

18

24/12/2011

Time-dependent problems

Time-dependent formulation

Tolerance and other attributes of time-dependent solver

Suggestions on convergence of time-dependent problems

Time-dependent Study

19

24/12/2011

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.

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

20

24/12/2011

Absolute and Relative Tolerance


u

True solution
t

Solutions within
Relative tolerance

At solutions near zero,


the relative tolerance
cannot be used, since it
would result in very
small timesteps

Solutions within
Tighten both the
Absolute tolerance absolute and relative
t

tolerance until you


are satisfied with the
results over time.

u
t

Other timestepping options


Selecting the physics at
startup will usually load
the appropriate settings.
For wave type problems,
Generalized-alpha is
often better.
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

BDF order, set max and


min to 2 and 1 for wave
problems.

Strict - force the time


stepping method to take
steps that end at the times
specified

21

24/12/2011

More timestepping options


Specify for which steps
the solutions should be
stored

Give a condition to stop


at, when this expression
becomes negative

Make sure not to impose any ringing loads,


unless they are really there
Load

time
Response

time

22

24/12/2011

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 > Solver > Dependent Variables > Initial
Values area 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
t
u

u(tinitial) = [Ksteady-state]-1b(tinitial)

Solution:
Use flc1hs function to ramp load
and to keep db/dt(t=0)=0
t

Segregated Solvers

23

24/12/2011

Segregation

Coupled solver

Segregated solver

Physics 1

Physics 2

Physics 1

Physics 2

Physics 3
Physics 3

Segregation

Easier to obtain good starting guesses


for strongly nonlinear Multiphysics
models and time-dependent models

Extremely memory efficient

Different solver settings for


each step
Good for iterative choices
Solver
Damping

Microwave-thermal-structural
Multiphysics couplings

24

24/12/2011

Using the segregated solver


Study > Solver Sequences > Solver
Sequence > Stationary

Can add multiple


Segregated steps as
required

Segregated step
Study > Solver Sequences > Solver
Sequence > Stationary > Segregated

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

25

24/12/2011

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

Solver Sequences and Settings

26

Anda mungkin juga menyukai