comsol multiphysics solver sequence and settings

26
24/12/2011 1 Solver Sequences and Settings The Study Node

Upload: yaser-akar

Post on 01-Oct-2015

273 views

Category:

Documents


31 download

DESCRIPTION

Comsol Multiphysics Solver Sequence and Settings

TRANSCRIPT

  • 24/12/2011

    1

    Solver Sequences and Settings

    The Study Node

  • 24/12/2011

    2

    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

    3

    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

    4

    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

    5

    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

    6

    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

    7

    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

    8

    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

    9

    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

    10

    Solver settings more information

    Solver Sequence 1 > Stationary 1 > Fully Coupled 1

    Linear system of equations is

    solved using the specified solver

    Stop condition for

    Newton iterations

    Can choose different

    damping methods

    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

  • 24/12/2011

    11

    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?

    Solving the Linear System Matrix

    Linear system matrix

    Direct methods

    Iterative methods

    Suggestions on solver selection

  • 24/12/2011

    12

    Lets 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) = bu-Kuu

    u2

    u3 r(u)

    Solution The 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

    Newtons 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) = bu-Kuu

    K

    Kubu

    u

    uuu

    00

    0

    00

    r

    rsol

    0u 0

    bKK

    b0u

    1sol

    usol

  • 24/12/2011

    13

    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

  • 24/12/2011

    14

    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 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

  • 24/12/2011

    15

    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

  • 24/12/2011

    16

    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

    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

  • 24/12/2011

    17

    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

  • 24/12/2011

    18

    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

  • 24/12/2011

    19

    Time-dependent problems

    Time-dependent formulation

    Tolerance and other attributes of time-dependent solver

    Suggestions on convergence of time-dependent problems

    Time-dependent Study

  • 24/12/2011

    20

    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

  • 24/12/2011

    21

    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.

    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.

  • 24/12/2011

    22

    More timestepping options

    Give a condition to stop

    at, when this expression

    becomes negative

    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

  • 24/12/2011

    23

    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

    Solution:

    Use flc1hs function to ramp load

    and to keep db/dt(t=0)=0

    t

    u

    t

    b

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

    Segregated Solvers

  • 24/12/2011

    24

    Segregation

    Coupled solver

    Segregated solver

    Physics 1

    Physics 2

    Physics 3

    Physics 1

    Physics 2

    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/12/2011

    25

    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

  • 24/12/2011

    26

    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