intensive class

Upload: jieqian-zhang

Post on 07-Apr-2018

223 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/3/2019 Intensive Class

    1/163

    COMSOL MultiphysicsIntensive Training Course

    Walter Frei, Ph.D.COMSOL, Inc.

    1

  • 8/3/2019 Intensive Class

    2/163

    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

  • 8/3/2019 Intensive Class

    3/163

    Hands on: Joule heating induced thermal

    expansion of a microresistorProblem:Voltage applied to this beamcreates resistive heating

    Heating the structurecauses thermal expansion

    Material properties are

    temperature dependent

    Want to find the deformationand stresses

    0.2V

    Ground

    3

  • 8/3/2019 Intensive Class

    4/163

    The DC Problem

    0)( V

    Governing Equation for the

    Conductive Media DCApplication 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

  • 8/3/2019 Intensive Class

    5/163

    The Heat Transfer Problem

    2VQ

    Governing Equation for the

    Heat Transfer Application Mode

    QTk

    Natural Convection

    h=5 W/m2K

    Text=300 K

    T=300 K

    T=300 K

    Thermal

    Conductivity

    Ohmic heat generation

    calculated by Conductive Media DC

    5

  • 8/3/2019 Intensive Class

    6/163

    )(T

    The Coupled DC+Heat Problem

    QTk

    0)( V

    The material properties of

    titanium are temperature

    dependent

    )(Tkk

    6

  • 8/3/2019 Intensive Class

    7/163

    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

  • 8/3/2019 Intensive Class

    8/163

    The Structural Mechanics Problem

    Feet are fixed

    to substrate

    The material experiences avolumetric thermal expansion

    due to the temperature given by:),(x

    T,VT

    0TT

    Assume small strain linear deformation theory

    8

  • 8/3/2019 Intensive Class

    9/163

    The finite element method

    V+ T

    Before you begin:1) Physics2) CAD3) Boundary Conditions4) Material Properties

    bAx

    This course focuses on:1) Efficient model set-up2) Meshing3) Solving

    4) Finding mistakes

    9

  • 8/3/2019 Intensive Class

    10/163

    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 summaryof all data inside the file

    10

  • 8/3/2019 Intensive Class

    11/163

    Lecture 1: Introduction to linear and

    non-linear single physics steady-state finite element problems

    11

  • 8/3/2019 Intensive Class

    12/163

    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)

    12

  • 8/3/2019 Intensive Class

    13/163

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

    2+ (k

    1)u

    3= c

    (k2+k3)u2 + (-k3)u3 = 0

    (-k3)u2 + (k1+k3)u3 =p

    Algebra

    Constraint Equations

    System Equations

    k1(u

    3- 0 ) + k

    2(u

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

    13

  • 8/3/2019 Intensive Class

    14/163

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

    Ku=b

    u=K-1b

    k1= 6 N/m

    k2=k

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

    14

  • 8/3/2019 Intensive Class

    15/163

    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 solution2) Doubling the magnitude of the load doubles the magnitude of the solution3) Changing the sign of the load changes only the sign of the solution

    load

    solution

    load

    solution

    Linear Non-Linear 15

  • 8/3/2019 Intensive Class

    16/163

    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)

    OutrageouslyNon-linear

    There are no clear distinctionsbetween these three cases

    16

  • 8/3/2019 Intensive Class

    17/163

    Not all non-linear problems have a (unique) solution

    load

    solution

    No solution

    17

    load

    solution

    No unique solution

  • 8/3/2019 Intensive Class

    18/163

    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

    18

  • 8/3/2019 Intensive Class

    19/163

    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

    ufuu

    solution

    5.0

    4

    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 19

  • 8/3/2019 Intensive Class

    20/163

    Solving a FE system matrix is equivalent to takinga single Newton-Raphson iteration

    f(u) = 2- 4 u = 0

    00

    0 ' uf

    uf

    uusolution

    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

    0

    0 'solution

    bKu1solution

    20

  • 8/3/2019 Intensive Class

    21/163

    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

    21

  • 8/3/2019 Intensive Class

    22/163

    Similarly, if we have a non-linear system matrix

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

    iiiiii

    iii ubuuKuSu

    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 the known as the JACOBIAN

    22

  • 8/3/2019 Intensive Class

    23/163

    The possibility of convergence of a non-linearproblem 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-convergentif starting on thisside of the line

    u0= -1

    23

  • 8/3/2019 Intensive Class

    24/163

    Finding a good starting point, u0,canimprove convergence

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

    u

    f(u)

    slowconvergence

    fast

    convergence

    It is not strictly possibleto define slow or fast

    convergence.

    Finding a good startingpoint is a matter ofexperience, and luck.

    24

  • 8/3/2019 Intensive Class

    25/163

    A damping factor, , is used to improve convergence

    u

    f(u)

    i

    iii

    uf

    ufuu

    '1

    choose (< 1) & ( |fi| )

    recomputefi+1

    (ui+1

    )

    end

    |fi|

    undamped |fi+1|

    intermediate |fi+1|

    final |fi+1|

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

    Problem: This requires many more evaluations 25

  • 8/3/2019 Intensive Class

    26/163

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

    f(u) = 1- exp(u) u = 0

    Almost all problems have a

    zero solution at zero loadRamping up the load is aphysically reasonable approach

    26

  • 8/3/2019 Intensive Class

    27/163

    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

    27

  • 8/3/2019 Intensive Class

    28/163

    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

  • 8/3/2019 Intensive Class

    29/163

    Hands-on: heat flow through a square

    T=0K

    q = 100 W/m2

    k, Thermal conductivity

    1x1m square

    Build this 2D model in BASE Heat Transfer,Save this model, we will build upon this

    Mesh

    Solution

    Tinitial=0K

    Insulated

    Insulated

    29

  • 8/3/2019 Intensive Class

    30/163

    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

  • 8/3/2019 Intensive Class

    31/163

    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 thisaffect the solution? What about the other cases? Set back to T=0 afterwards

    31

  • 8/3/2019 Intensive Class

    32/163

    Ramp up the heat load and monitor peak temperature

    32

    T

    k=(1-T/200[K])[W/(m*K)]

    Qin

    Tmax

    ?

    Why does this happen?

  • 8/3/2019 Intensive Class

    33/163

    Non-linear solver settings

    Stop conditions forNewton iterations

    Toggling off damping is

    rarely, if ever, useful

    Can choose differentdefaults for the damping

    Augmented Lagrangiansolver settings, used instructural contactproblems only

    33

  • 8/3/2019 Intensive Class

    34/163

    Advanced solver settings

    All other settings arethere for historicalreasons and are relatedto memory management

    Wave-type problems usecomplex numbers, andrequire this be on

    Stores time-dependentsolution to temp fileduring the solve, andgets loaded into RAMonce the solve is done

    Wave-type problems withperiodic boundary

    conditions require this tobe checked on

    34

  • 8/3/2019 Intensive Class

    35/163

    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 additionalintermediate steps in an attempt to ramp towards the final solution. This is similar to,but more computationally demanding than, damping. The intermediate steps do notget stored, and they can require more time.

    35

  • 8/3/2019 Intensive Class

    36/163

    Using the parametric solver with severalparameters

    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 previoussolution is still used asthe initial condition, butthe software does nottake intermediate steps. T

    k

    (0,8)

    (5,4)

    (7.5,2)

    (10,0.5)

    36

  • 8/3/2019 Intensive Class

    37/163

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

    37

  • 8/3/2019 Intensive Class

    38/163

    Achieving convergence for non-linear problems

    Assuming that the problem iswell-posed, try solving it

    1) Check the initial condition

    2) Use parametric solver to ramp load1

    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 meshand check that thesolution 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

  • 8/3/2019 Intensive Class

    39/163

    39

    Linear problems are much easier to debugThe error is usually some variation of these mistakes:

    What are the stresses in the eggshell for these two cases?

  • 8/3/2019 Intensive Class

    40/163

    40

    Linear problems are much easier to debugThe error is usually some variation of these mistakes:

    If balanced forces are acting upon

    an object, where is the object?

  • 8/3/2019 Intensive Class

    41/163

    COMSOL Expressions

    41

  • 8/3/2019 Intensive Class

    42/163

    Application notes: Problem constants

    These constants can be entered into anything underneath the Physics... menu

    Units are tracked and converted to the default unit system42

  • 8/3/2019 Intensive Class

    43/163

    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 tabThe same within a subdomainetc...

    43

  • 8/3/2019 Intensive Class

    44/163

    Expressions are evaluated both before and

    during the solution

    Square brackets are used to specify units, they arenot strictly necessary, but are encouraged

    44

  • 8/3/2019 Intensive Class

    45/163

    How to enter more complicated expressions

    1) Options... Functions... Table...

    Pick appropriate extrapolationand interpolation method

    45

  • 8/3/2019 Intensive Class

    46/163

    How to enter more complicated expressions

    2) Options... Functions... Piecewise Analytic Functions...

    Use General Function type

    Pick appropriate extrapolationmethod and smoothing function

    46

  • 8/3/2019 Intensive Class

    47/163

    Entering x-y data from a file

    (1)

    (2)

    (3)

    (4)

    % Grid-2.00 0.00 2.00-1.00 2.00% Data0.25 0.00 -0.25-0.50 0.00 0.50

    The data can be on a

    square grid, or read infrom another analysispackage on anunstructured mesh.

    47

  • 8/3/2019 Intensive Class

    48/163

    Functions with a discontinuity

    In COMSOL such functions can bewritten as Boolean expressions:

    (t>0)(t>=0)(t>0)&&(t1)||(t

  • 8/3/2019 Intensive Class

    49/163

    Material Properties

    Can also use:

    www.matweb.com

    www.efunda.com

    49

  • 8/3/2019 Intensive Class

    50/163

    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

  • 8/3/2019 Intensive Class

    51/163

    COMSOL derivative variables

    Given solution variables: T, V, etc...The spatial derivatives are given by: Tx, Ty, Tz, Vx, Vy, Vz, etc...

    Tx

    Tx T

    y

    Ty T

    z

    Tz

    The time derivatives (if solving atransient problem) are: Tt, Vt, etc... Tt

    Tt

    These can be mixed:

    yx

    T

    t

    2

    2

    2

    Txytt

    The edge and surface tangentderivatives are: TTx, TTy, TTz, etc...

    xT TnnITTx

    51

  • 8/3/2019 Intensive Class

    52/163

    Application Mode Variables

    Each application model has its own automatically defined variablesthat have an underscore and a suffixThey are all listed underneath Phyics... Equation System...

    For example:

    fluxx_ht =-kxx_ht*Tx-kxy_ht*Ty-kxz_ht*Tz

    z

    Tk

    y

    Tk

    x

    Tkq

    z

    Tk

    y

    Tk

    x

    Tkq

    z

    Tk

    y

    Tk

    x

    Tkq

    zzzyzxz

    yzyyyxy

    xzxyxxx

    T kq52

  • 8/3/2019 Intensive Class

    53/163

    Hands on: pre-stressed micromirror

    Aspect ratio is >10, so sweptmeshing is reasonable

    Large deformation analysis

    Intermediate solutions are required tohelp the model converge to solution

    53

  • 8/3/2019 Intensive Class

    54/163

    CAD and Meshing

    54

  • 8/3/2019 Intensive Class

    55/163

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

  • 8/3/2019 Intensive Class

    56/163

    COMSOL Draw Mode

    Draw 2 rectanglesGet 3 domains

    Continuity is automatically assumed at interior boundaries

    Overlapping geometry is OK, once you switch tosubdomain 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

  • 8/3/2019 Intensive Class

    57/163

    Deleting interior boundaries and splitting objects

    Draw a square & circle Union into one object Delete interior boundaries

    Split into three objects

    57

  • 8/3/2019 Intensive Class

    58/163

    Using COMSOL Groups

    APPROACH #1

    1) Select each object2) Apply properties

    3) Switch to Groups tab4) Verify groups visually

    58

  • 8/3/2019 Intensive Class

    59/163

    Using COMSOL Groups

    APPROACH #2

    1) Switch to Groups tab2) Create a Group name3) Give properties for

    group

    4) Switch to subdomain tab5) Select each object6) Assign it to a group

    59

  • 8/3/2019 Intensive Class

    60/163

    MESHING: The free mesh parameters

    Usually want to adjust each one of these fields,both globally and locally

    The Subdomain,Boundary, Edge, andPoint tabs locallyoverwrite the Global

    settings

    60

  • 8/3/2019 Intensive Class

    61/163

    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

  • 8/3/2019 Intensive Class

    62/163

    Element growth rate

    This controls the maximum element size between adjacent elements

    62

  • 8/3/2019 Intensive Class

    63/163

    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

  • 8/3/2019 Intensive Class

    64/163

    Mesh curvature cutoff radius=0.25

    If: redge < (rcutoff) x (Lmax)

    Then: r = (rcutoff) x (Lmax)

    As a result: The element size of these edges is:

    (Mesh Curvature Cutoff) x (Mesh Curvature Factor)

    Maximum element size is 0.05

    Lmax

    64

  • 8/3/2019 Intensive Class

    65/163

    Resolution of narrow regions

    Resolution=1 Resolution=5

    Puts approximately the specified numberof elements into the narrow regions 65

  • 8/3/2019 Intensive Class

    66/163

    2D Triangular, Quadrilateral, Mapped, andBoundary Layer Meshes, and when to use them

    Triangle Quad Mapped Boundary Layer

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

  • 8/3/2019 Intensive Class

    67/163

    3D Tetrahedral, Extruded, Revolved, Swept, andBoundary Layer Meshes

    Tetrahedral Extruded Revolved

    Swept Boundary Layer67

    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)

  • 8/3/2019 Intensive Class

    68/163

    The wrong way to work with 3D CAD files:

    CADDesigners

    AnalysisStaff

    CAD File

    68

  • 8/3/2019 Intensive Class

    69/163

    3D CAD pitfalls

    Working with overly detailed geometry, extraneous features

    Sliver faces (drafts), short edges

    Fillets, fillets, fillets

    69

    Downloaded from thomasnet.com

  • 8/3/2019 Intensive Class

    70/163

    70

    Making the reverse of the part is usually

    easier to do in the original CAD program

    COMSOL can cap rectangular andcircular planar faces on 3D objects, othercapping operations are more difficult

  • 8/3/2019 Intensive Class

    71/163

    Include a fillet to remove a singularity

    71

    Consider DC current flow. Cuta notch out of a square block,

    apply insulating boundaryconditions, because it is

    insulating, so current can onlygo in the direction shown but

    not perpendicular to thesurface.

    Here, the insulating boundary conditionmeans that current can only flowtangentially to the boundary, as shown

    by the arrows.

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

    This geometry implies that the current

    takes a sharp bend over zero radius.

    This is independent of the mesh!

  • 8/3/2019 Intensive Class

    72/163

    Although the fillet/ sharp angle introducesa 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 thiscase voltage, will be the same, regardless of the mesh

    V=0.5 V=0.5 V=0.5

  • 8/3/2019 Intensive Class

    73/163

    An example from structural mechanics

    73

    Some fillets should stay

  • 8/3/2019 Intensive Class

    74/163

    If a corner introduces gradients into the solution,then consider adding a realistic fillet

    74

    FLUID FLOW EXAMPLEAdding a small, physicallyrealistic, fillet at interior cornerscan be helpful for convergence

  • 8/3/2019 Intensive Class

    75/163

    Boundary conditions can introduce singularities

    75

    P

    A cantilever beam fixed at one end

    A fixed boundary

    condition meansthe material isinfinitely stiff

    Where will there be a singularity? How is it manifested?

    Is this model convergent? If so, with respect to what?

    Point loadStiffness:left infinite stiffness, right, finite

  • 8/3/2019 Intensive Class

    76/163

    Boundary conditions can introduce singularities

    76

    T = 50K

    T

    =

    0K

    T

    =

    100Kx

    TkAq

    q?

  • 8/3/2019 Intensive Class

    77/163

    CAD Pitfalls: Glancing contact

    77

    Introduce a slightintersection to avoid

    the sharp interiorangle of the element

  • 8/3/2019 Intensive Class

    78/163

    CAD Pitfalls: Narrow regions

    78

    - Approximate this via a boundary condition- Consider using a reduced dimension model

  • 8/3/2019 Intensive Class

    79/163

    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

    Lmax

    Lmin

  • 8/3/2019 Intensive Class

    80/163

    Demo: CAD meshing and de-featuring

    Import: repair_demo_1.x_b fromC:\COMSOL\caddata directory

    93,429 elements

    using defaultNormal mesh

    80

  • 8/3/2019 Intensive Class

    81/163

    Fillets and small surfaces are present

    81

  • 8/3/2019 Intensive Class

    82/163

    Try repairing the part with a tolerance of 1e-3

    45,517 elements

    82

    Draw CAD repairrepair change from 1e-5 to 1e-3

  • 8/3/2019 Intensive Class

    83/163

    Try changing the resolution of narrow regions

    By changing from 0.5 to 0.1, resulting in

    50,797 elements, almost 50% less!

    83

  • 8/3/2019 Intensive Class

    84/163

    Tricks for diagnosing CADIf you are unable to put a 3D mesh on the part, 99% of thetime, it is one of the problems we discussed in the previouscases, (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 meshto help find the problem.

    Try interactivesurface meshing

    This is a mesh onthe surface only,but it can visuallyguide you to theproblem areas

    84

  • 8/3/2019 Intensive Class

    85/163

    Good CAD data hasjust enough detail

    to capture the

    physics, but notone detail more.85

  • 8/3/2019 Intensive Class

    86/163

    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

    NormalizedM

    ax.

    Disp.

    Make sure to study thesolution variable, andnot a derived variable

    86

  • 8/3/2019 Intensive Class

    87/163

    Numerical Error

    k= exp(u) N/m

    u

    p = 2 N

    Force balance on node:

    f(u) = p - k u = 0f(u) = 2- exp(u) u = 0

    u

    f(u)

    usolution 0.853

    This problem has an exactsolution, but we are solving itnumerically via Newton-Raphson iterations.

    The error can be minimized bytaking many iterations, but a

    computer usually cannot findan exact answer for tworeasons:

    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

  • 8/3/2019 Intensive Class

    88/163

    Discretization Error

    A finite element basis function can onlyapproximately represent a true solution.

    The error can be minimized by usingsmaller elements, or increasing elementorder.

    This is MESH or DISCRETIZATIONerror

    10 1st order elements

    16 1st order elements

    4 2nd order elements

    uexact-umodel

    88

  • 8/3/2019 Intensive Class

    89/163

    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

    TotalError

    Discretization error and numerical error

    Mesh errordecreases withmore elements

    Numerical errorincreases withmore elements

    Total error will be about 10-6

    1

    st

    order elements

    89

    Square root of instrument precision

  • 8/3/2019 Intensive Class

    90/163

    Element shape functions discretize curved edges

    Domain

    Single 1st

    ordertriangular element Single 2nd

    ordertriangular element

    Isoparametric elements use polynomialexpressions to approximate the domain shape

    90

  • 8/3/2019 Intensive Class

    91/163

    Geometric discretization error

    Four linear elementsdiscritizing a unit circle

    Error: (-2)/

    1.E-06

    1.E-04

    1.E-02

    1.E+00

    1 10

    Elements per Chord

    Error

    1st order

    2nd order3rd order

    This mesh adequatelydescribes the geometry, butnot necessarily the solution!

    91

  • 8/3/2019 Intensive Class

    92/163

    Total Error vs. memory requirements

    n: # of elementsper side (5 in this

    example)

    n=1

    n=1 n=2

    n=20

    Insulatedquartercylinderwith heatgeneration 92

  • 8/3/2019 Intensive Class

    93/163

    Memory requirements depend on mesh type

    18 elements

    49 nodes

    ~3 adjoining elements

    9 elements

    40 nodes

    ~4 adjoining elements

    [Kelement]6x6[Kelement]8x8

    Error is a related to how far apart the nodes are,and is usually not a function of element type. 93

  • 8/3/2019 Intensive Class

    94/163

    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

    currentcarrying

    wire

    94

  • 8/3/2019 Intensive Class

    95/163

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

    Use boundary layer meshing when thereare high gradients normal to a boundary

  • 8/3/2019 Intensive Class

    96/163

    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 2nd order is usually only of academic interest

    96

  • 8/3/2019 Intensive Class

    97/163

    The stationary adaptive mesher

    Triangular and tetrahedral elementsONLY are subdivided based on theL2 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

  • 8/3/2019 Intensive Class

    98/163

    Guidelines for meshing refinement

    1. Start with a mesh that you believe will resolve the gradients on thesolution that you expect, use the previously mentioned techniquesto 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 theconvergence 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

  • 8/3/2019 Intensive Class

    99/163

    End of Day 1

    Questions?

    99

  • 8/3/2019 Intensive Class

    100/163

    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

  • 8/3/2019 Intensive Class

    101/163

    Lecture 2: Different ways of

    solving the linear system matrix

    Ku=b101

  • 8/3/2019 Intensive Class

    102/163

    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

    u3r(u)

    SolutionThe solution, f(usolution) = 0, isthe point where r(u), is at aminimum

    102

  • 8/3/2019 Intensive Class

    103/163

    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, thisconverges 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 thesame 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

    bK

    K

    b0u

    1sol

    usol

    103

    Finding the minim m of the q adratic f nction

  • 8/3/2019 Intensive Class

    104/163

    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 thiscourse, 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: 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

  • 8/3/2019 Intensive Class

    105/163

    Introduction to iterative methods for finding theminimum 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 onlythat we can repeatedly evaluate r(u)as opposed to the direct methods,

    which get to the minimum by in onestep by evaluating [r(u)]-1

    105

    Th i l l i K ff t th l ith

  • 8/3/2019 Intensive Class

    106/163

    The numerical values in K can affect the algorithm

    u2

    u3r(u)

    Quadraticsurface

    r(u) = bu-Kuu

    Conditionnumber = 1

    Conditionnumber = 2

    Conditionnumber = 10

    The higher the condition number the morenumerical error creeps into the solution 106

  • 8/3/2019 Intensive Class

    107/163

    Ill-conditioned matrices require more iterations

    Numerical error becomes significant107

    A better iterative method for finding the minimum:

  • 8/3/2019 Intensive Class

    108/163

    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 canevaluate r(u),r(u) andr(u)

    CG converges in at mostniterations

    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

  • 8/3/2019 Intensive Class

    109/163

    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

  • 8/3/2019 Intensive Class

    110/163

    All iterative methods in COMSOL are somevariation upon the CG method

    Conjugate Gradient,F/GMRES, BiCGStab, Geometric MultigridThe 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 possiblepreconditioner is thematrix M=K-1

    Ku = b MKu = Mb 110

    Wh t d t k b t it ti l

  • 8/3/2019 Intensive Class

    111/163

    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 does depend 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 andpreconditioners for many physics, to find these settings, read the manualsor open a new model file, select a space dimension of 3D and the physicsyou want to solve

    111

  • 8/3/2019 Intensive Class

    112/163

    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

  • 8/3/2019 Intensive Class

    113/163

    The linear system solver GUI

    113

    Monitor the memory requirements of the direct

  • 8/3/2019 Intensive Class

    114/163

    y qsolvers 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 iterativesolvers and compare to the default

    114

    This curve shows the iterativesolver approaching thebottom of the residual

    surface

    Th S l M

  • 8/3/2019 Intensive Class

    115/163

    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 propertiesor via the Solver Manager form

    Solver Parameters Allows you to select the solver type and linear system solver

    115

  • 8/3/2019 Intensive Class

    116/163

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

    116

  • 8/3/2019 Intensive Class

    117/163

    Computer architecture issues, 32- vs. 64-bit

    A 32-bit architecture can store at most 232 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

    S

  • 8/3/2019 Intensive Class

    118/163

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

    S l l i f D bl

  • 8/3/2019 Intensive Class

    119/163

    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 solveda linear problem

    119

  • 8/3/2019 Intensive Class

    120/163

    Lecture 3: Multiphysics FE Problems

    120

    Consider two simple physics, on the same geometry

  • 8/3/2019 Intensive Class

    121/163

    p p y g y

    q=100 W/m2

    T=0K

    All other surfacesinsulated

    0

    0100

    0

    2

    T

    KTTk

    Tk

    m

    Wn

    in the domain

    right boundary

    left boundary

    other boundaries

    fT=

    KTu

    T-

    bT

    Heat Transfer Conductive Media DC

    All other surfacesinsulated

    V=1VV=0V

    0

    01

    0

    V

    VVVV

    V in the domain

    right boundary

    left boundary

    other boundaries

    fV= K

    Vu

    V- b

    V

    k= 1 W/mK = 1S/m

    121

    How to solve this linear problem

  • 8/3/2019 Intensive Class

    122/163

    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 asingle Newton-Raphson iteration: bKuSuu

    0

    1

    0sol

    122

    Now, consider a coupled multiphysics problem

  • 8/3/2019 Intensive Class

    123/163

    p p y p

    = (1-0.001T) S/m

    The temperature solution now affects thematerial properties of the DC problem

    fT= K

    Tu

    T- b

    T f

    V

    = KV

    (uT

    )uV

    - bV

    q=100 W/m2

    T=0K

    All other surfacesinsulated

    Heat Transfer Conductive Media DC

    All other surfacesinsulated

    V=1VV=0Vk= 1 W/mK

    123

    How to solve this coupled multiphysics problem

  • 8/3/2019 Intensive Class

    124/163

    fT(uT) = KTuT- bT

    fV(uV) = KV(uT)uV- bVTake the two system equations:

    buuKbb

    u

    u

    ufuf

    0uf

    uf

    V

    T

    V

    T

    VVTV

    TT

    This coupled problem is solved viaNewton-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 exactsame 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

    Consider more couplings between the physics

  • 8/3/2019 Intensive Class

    125/163

    q=100 W/m2

    T=0K

    Heat Transfer Conductive Media DC

    All other surfacesinsulated

    V=1VV=0VQ(V)

    k= 1 W/mK (T)

    fT= KTuT- bT(uv) fV= KV(uT)uV- bV

    Volumetric resistiveheating due to current

    ubuuKb

    ub

    u

    u

    ufuf

    ufuf

    uf

    V

    VT

    V

    T

    VVTV

    VTTT

    iiii

    iiiiii

    ufuufuu

    ubuuKuSuu

    1

    1

    1

    1

    Same equation

    as before

    125

    Consider all possible couplings between the physics

  • 8/3/2019 Intensive Class

    126/163

    (T,V)

    q(T,V)

    V=V(T,V)

    fT= KT(uV,uT)uT- bT(uV,uT)

    k(T,V)

    ),( VTQvol

    ubuuK

    uub

    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:

    126

    Different two-way couplings have different

  • 8/3/2019 Intensive Class

    127/163

    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)

    127

    Definitions of various types of couplings

  • 8/3/2019 Intensive Class

    128/163

    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

  • 8/3/2019 Intensive Class

    129/163

    p p y psegregated 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(u

    T,i, u

    V,i)-1b

    T(u

    T,i, u

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

    129

    Solving in a segregated sense has some advantages

  • 8/3/2019 Intensive Class

    130/163

    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:

    The Jacobian is O(2) times smaller in memory

    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 approachwill not work, and a direct solver is often necessary since theiterative solvers are not tuned for a general Jacobian matrix.

    130

    Achieving convergence for multiphysics problems

  • 8/3/2019 Intensive Class

    131/163

    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

  • 8/3/2019 Intensive Class

    132/163

    pthrough a square

    J=10 A/m2

    VL=0

    TL=0

    All other surfaces insulated

    Set up an Inward Current Flowon the right side

    k=1 W/mK =1 S/m

    All other surfaces insulated

    Identical to previous problem

    Conductive Media DC Application ModeHeat Transfer Application Mode

    Set up and solve this uncoupled linearproblem

    q=100 W/m2

    132

    Consider the following multi-physics couplings:

  • 8/3/2019 Intensive Class

    133/163

    Consider the following multi physics couplings:

    VolumetricHeat Load

    ThermalConductivity

    ElectricConductivity

    NormalCurrent

    IterationsSolution

    Times (sec)

    Linear 0 1 1 10 1 6.0

    weak non-linear

    uncoupled0 1-(T/10000) 1-(V/1000) 10 3 18.0

    one-way loadcoupled

    Q_dc 1 1 10 3 44.0

    weak two-wayload 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

  • 8/3/2019 Intensive Class

    134/163

    Hands on exercises: Ramp up the appliedcurrent, and monitor peak temperature

    134

    exp(-T/600) exp(-T/600)

    Jin

    Tmax

    ?

    Ramp up inward current flow from 0-20 A/m2 using the parametric solver.Plot the temperature distribution. What happens? Why?

    ThermalConductivity

    ElectricConductivity

    1 1Case 1

    Case 2

    Hands on exercises: Ramp up the applied

  • 8/3/2019 Intensive Class

    135/163

    Hands on exercises: Ramp up the appliedvoltage, and monitor peak temperature

    135

    exp(-T/600) exp(-T/600)

    V

    Tmax

    ?

    Ramp up applied voltage, how high can it go? Why?

    ThermalConductivity

    ElectricConductivity

    1 1Case 1

    Case 2

    Same as before

    Using the segregated solver

  • 8/3/2019 Intensive Class

    136/163

    Pick the best solverfor each physics

    Can choose adifferent dampingfor each physics

    136

    When in doubt, set each physics to run to

  • 8/3/2019 Intensive Class

    137/163

    convergence at each iteration

    initialize uT,i, uV,i

    do {

    do {

    non-linear solution for uT,i+1use uT,iand uV,i as initial conditions

    }

    do {

    non-linear solution for uV,i+1use uT,i+1and uV,i as initial conditions

    }

    i = i+1

    }

    while ( not_converged)

    These settings are equivalent to solving thecomplete non-linear problem at each iteration. 137

    Additional physics and couplings

  • 8/3/2019 Intensive Class

    138/163

    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 Ndimensions onto an N+1 dimension

    Projection: Takes the integral of a quantity in Ndimensions and projects it ontoan 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)

  • 8/3/2019 Intensive Class

    139/163

    Adding Ordinary Differential Equations (ODE s)

    k

    p(t)

    u

    c

    0)( tpkuucumForces

    00 0,0 uuuu

    m

    139

    Solving an ODE: Damped harmonic oscillator

  • 8/3/2019 Intensive Class

    140/163

    00,10

    0

    uu

    kuuu

    dunderdampe,2

    overdamped,2

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

  • 8/3/2019 Intensive Class

    141/163

    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

  • 8/3/2019 Intensive Class

    142/163

    g g p g p

    Set up and solve this Incompressible Steady StateNavier-Stokes fluid flow problem, (=1e3, =1e-3):

    4 mm1 mm

    Wall, no slip

    Wall, no slip

    Inlet, Pressure,

    no viscous stressP = 0.1Pa

    Outlet, Pressure,

    no viscous stressP = 0 Pa

    Solution, exhibiting

    entrance effect

    In post-processing, do aboundary integration of:

    rho_ns*u*1[m]

    AvdA

    The mass flux integral is taken perunit inch out of the modeling plane

    142

    Adding an integration coupling variable step 2

  • 8/3/2019 Intensive Class

    143/163

    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 calledMassFlux, as shown below

    143

    Adding an integration coupling variable step 3

  • 8/3/2019 Intensive Class

    144/163

    Adding an integration coupling variable, step 3

    Modify the appliedpressure at the inlet

    Add a global equation

    This adds an equation,AppliedP,

    that must be satisfied.

    COMSOL adjusts the inlet pressureto satisfy the condition on the totalmass flux through the boundary

    Solve again, and integrate the mass flux across theboundary. Mass flux, which is a function of fluid velocity,

    has be fixed by applying a constraint on pressure.

    Caution! This approach will, undersome conditions, introduce a factorof two into the model. If you see this,switch to Non-ideal Constraints

    144

    Adding your own governing equation

  • 8/3/2019 Intensive Class

    145/163

    Adding your own governing equation

    145

    Coefficient Formof the PDE

    General Formof the PDE

    Weak Formof the PDE

    0othersall,,,

    QfTukc

    fuauuuc

    QFTyk

    Txk

    xTk

    xTk

    F

    ,*

    *

    Heat TransferPDE

    QTk

    test(T)*Q_ht+test(Ty)*Ty*k_ht-test(Tx)*Tx*k_ht-

    0

    dvqdvQukv

    Most common PDEsare implemented

    Enter thecoefficients for thePDE of interest

    More compact wayof entering certainequations

    Most flexible,requires that youknow how to get tothe weak form

    Review

  • 8/3/2019 Intensive Class

    146/163

    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

  • 8/3/2019 Intensive Class

    147/163

    Hands on: Fluid Structure Interaction

    Fluid moves through the domain,solid deforms the domain

    The mesh deforms the due to thestructural analysis

    Loads are automatically passedbetween the two physics usingthe FSI application mode

    147

  • 8/3/2019 Intensive Class

    148/163

    Lecture 4: Time-stepping and reducingthe error in the finite element model

    148

    Introduction to time-dependent solutions

  • 8/3/2019 Intensive Class

    149/163

    Introduction to time dependent solutions

    bKuufu

    )(

    t

    QTkt

    TCp

    ttttt

    ttbuKuuu

    1

    ttttt t ubuKu 1

    1111

    ttt

    tt

    ttbuKuuu

    111 tttt tt buuKI

    Governing Equation

    Time-dependent finite element formulation

    Explicit time-stepping

    Implicit time-steppingFaster

    More stable

    Slower

    Simple

    149

    Backward Difference Formula (BDF) order

  • 8/3/2019 Intensive Class

    150/163

    Backward Difference Formula (BDF) order

    111 tttt tt buuKI

    t+1

    k(t)

    A polynomial is fit throughn previous points topredict properties att+1

    Here, the BDF order is n=3

    tt-1t-2150

    COMSOL picks its own optimum timesteps

  • 8/3/2019 Intensive Class

    151/163

    COMSOL picks its own optimum timesteps

    These are the outputtimesteps, the timesyou want to see thesolution at.

    They do not affect theinternal timesteps.

    The internal timestepsare controlled by theTOLERANCES.

    151

    Absolute and Relative Tolerance

  • 8/3/2019 Intensive Class

    152/163

    Solutions withinRelative tolerance

    Solutions withinAbsolute tolerance

    t

    u

    t

    u

    True solution

    t

    u

    At solutions near

    zero, the relativetolerance cannot beused, since it wouldresult in very small

    timesteps

    t

    u

    Tighten both the

    absolute andrelative tolerance

    until you aresatisfied with theresults over time.

    152

    The absolute tolerance can be different forh l ti i bl

  • 8/3/2019 Intensive Class

    153/163

    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 optionsSelecting the physics at

  • 8/3/2019 Intensive Class

    154/163

    pp g p

    Specify when to store,

    and which time-stepsto solve at.

    Give a condition to stopat, when this expressionbecomes negative

    Selecting the physics atstartup will usually load

    the appropriate settingsinto this form.

    For wave type problems,gen-alpha is often better.

    BDF order, set max andmin to 2 and 1 for waveproblems.

    154

    Make sure not to impose any ringing loads,

    l th ll th

  • 8/3/2019 Intensive Class

    155/163

    unless they are really there

    155

    Load

    time

    Response

    time

    A reasonable starting point is necessary

  • 8/3/2019 Intensive Class

    156/163

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

    156

    Convergence of a transient problem

  • 8/3/2019 Intensive Class

    157/163

    t

    u

    Outside envelop is absoluteand relative tolerance

    True solution(unknown)

    Observe the solution with respect to time andmonitor 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 tod ti

  • 8/3/2019 Intensive Class

    158/163

    space and time

    Transient 1-D slab

    Tfixed

    x

    Tinitq

    T

    increasingtime

    Hands on:

    1) Go back to heat transfer 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

    158

    There are two ways to minimize this problem

  • 8/3/2019 Intensive Class

    159/163

    y p

    Modify the mesh

    Use boundary layermeshing to better resolvethe step in the solution

    Modify the physics

    Use a smoothed stepfunction to gradually rampup the heat load:

    flc1hs(t-0.01,0.01)

    t

    qq

    159

    Solving transient problems

  • 8/3/2019 Intensive Class

    160/163

    g p

    Begin by assuming the problem is well posed, try solving it byramping 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...

  • 8/3/2019 Intensive Class

    161/163

    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

  • 8/3/2019 Intensive Class

    162/163

    g p y

    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 MassTransfer, Incorpera & DeWitt

    Nonlinear Finite Elements for Continuaand Structures, Belytchko, Liu, Moran

    Whatever FEA book you like

  • 8/3/2019 Intensive Class

    163/163

    Closing Remarks and Questions