Vous êtes sur la page 1sur 130

Advanced 2-day Training Course

DAY 1
Course presenter:

Course developed by:

Christiaan Hattingh
MTC
COMSOL South Africa
Niklas Rom, Anders Ekerot, Christiaan Hattingh
COMSOL AB

File pack - Trial install


1.

Copy all files from the flash drive


1.
2.

2.

Install COMSOL use the install disc in your trial pack.


1.
2.

3.

4.
5.

3.

To a folder on the desktop or some other place that is easy to access. We will use these files during the training at
various stages.
Please call me and return the flash drive before proceeding, or pass the flash drive on to other attendants who still
need to copy the files. I will then give you a trial pack with the install disc.

You will be prompted to accept the license agreement and then to enter a passcode or license file.
Windows/Mac users select the passcode option. Browse to the files you have copied (using file explorer!) and
open the trial license txt file. In the file you will find the passcode. Copy and paste the whole code into the relevant
input box (using Ctrl-V).
Users of Linux select the license file option and then browse and select the file via the button (the file is in the
folder of copied files from the flash drive).
Just use the default install options as you proceed through the install wizard, ie click next, next until you reach
the button install then click on it and the install process will start.
In the folder you copied from the flash disc there are some hotfix patch files in a folder (4_2_updatesAndHotfixes)
for windows there are .exe files, for mac dmgs and for linux zip files please install at least the multiphysics
patch from these, the others are not essential for the workshop.

You may use the trial pack for install on another computer/for other colleagues at your
company/institution just use the same passcode that you received today. The license
is valid for about two weeks. The exact date of expiry is listed inside the passcode file.

Agenda Day 1

Geometry, CAD, Import and Meshing

Geometry creation in COMSOL


CAD import
Meshing sequences
Mesh quality and visualization

Multiphysics couplings, and Result Visualization


Predefined multiphysics couplings
Different types of couplings
Datasets and results visualization

Equation-based modeling

PDEs
PDEs and ODEs
PDEs and distributed ODEs
DAEs
Complex valued equations

Cluster computing introduction


News in COMSOL 4.2a

Structure
1. Presentations
1.
2.

Slides
Included in your file pack as PDF for reference after the course.

2. Demonstrations (interactive)
1.
2.

Presenter will demonstrate in COMSOL 4.2a: you can either just follow the
demonstration or you can participate...your choice.
Demonstration models are included in your file pack.

3. Exercises
1.

On your own laptop follow the exercises step-by-step as outlined in the


document: 2-day_adv_exercises_all_42.pdf. This document also contains
additional information and detailed sections on specific issues.

COMSOL Multiphysics

Finite element analysis

Flexible Graphical User Interface

Single physics
Multiphysics

Unlimited Multiphysics combination


All steps in modeling procedure
Material databases
Mathematical tools
Parameterization jobs

Adaptable

Predefined Multiphysics
User defined Multiphysics
Non-linear equations

PDE
ODE and DAE

3D mesh of a power
transistor

Visualization of
temperature distribution

Model just about any physics


Traditional approach to modeling

Acoustics

Structural analysis

Mass transport

Electromagnetism

Fluid dynamics

Heat transfer

Multiphysics

Induction heating

Acoustic-Structure interaction

Non-isothermal fluids

Joule heating with thermal expansion

Fluid-Structure interaction

User defined

Piezoelectric button for elevators

Everything can link to everything

Geometry, CAD Import and Mesh

Modeling procedure - Geometry

Draw or import the geometry

COMSOL Multiphysics built-in CAD tools.


Workplanes
Boolean operators
Conversions and transforms
Extrusion and revolution
Useful for most geometries

CAD Import
STEP, IGES, SAT, Parasolid,
Repair and defeaturing
More flexibility in geometry modeling

Live Links
SolidWorks
Pro/E, CREO Parametric
Autodesk Inventor, AutoCAD
SpaceClaim

Hands-on Modelling Exercise

Page 5-27 in exercise PDF


Creating a 2D and 3D geometry
Using COMSOL built-in tools
Parametrization
Use of basic features and operators
Workplanes

Live Links and CAD Import

LiveLinks for SolidWorks, Inventor, and Pro/E, CREO,


AutoCAD and Spaceclaim
Bidirectional Updates of Geometry Dimensions (1-window for
SolidWorks)

CAD Import Module now supports these formats


Parasolid (.x_t, .x_b)
SAT (.sat, .sab)
STEP (.step, .stp)
IGES (.igs, .iges)
Autodesk Inventor part (.ipt)
Autodesk Inventor assembly (.iam)
Pro/ENGINEER (.prt, .asm)
SolidWorks (.sldprt, .sldasm)

Any LiveLink for CAD includes a CAD Import Module

Importing CAD Files


When you have other
geometry tools

CAD design for FEA

During design of parts:


Apply fillets and chamfers late in the
CAD modeling process.
Remove small features not important
for the physics.
Avoid narrow strips of faces.

During design of assemblies:


Avoid missalignment of components.
Avoid separate design of mating
faces.
Remove all small gaps and
clearances from the model.
Try to build components in the context
of another.

Automatic Repair During Import

Removing short edges, small faces, sliver faces


Healing gaps
Removing self-intersections, spikes and discontinuities
Correcting invalid topology
Absolute import tolerance 10-5 m
Example: spike
C3

C3
C5
C6
C1

C4
C2

Remove C5, C6
Modify C1 or C4

C4
C1

C2

Repair Example Sliver Faces

Remove face and


extend other faces
to fill gap

Working with 3D CAD files, the wrong way:

CAD File

Designers

Analysis
Staff

Do not work with the fully detailed CAD model

This cannot be
defeatured by
COMSOL

Downloaded from
thomasnet.com

272K DOF

Sometimes, the CAD file has the wrong information

Making the reverse of the part is usually much


easier to do in the original CAD program

Avoid short edges in the CAD file


1637 elements

BAD
GOOD

935 elements

Avoid sliver and thin faces

12,556 elements

Fillets, sometimes you want them, sometimes you


dont

Tricks for diagnosing CAD


If you are unable to put a 3D mesh on the part

Try interactive
surface meshing

This is a mesh on
the surface only,
but it can visually
guide you to the
problem areas

Hands-on CAD import Exercise

Part 1: Import of 3D CAD file of engine


piston:
Compare 3D CAD models suitable for
Finite Element Analysis (FEA) versus
design.
p.28-31 in PDF exercise book.

Part 2: Import of an IGES file:


Use repair functionality to create a
solid.
p.32-36 in PDF exercise book.

Remember:
Good CAD data has just enough detail to capture the
physics, but not one detail more.

Meshing Overview

Various Mesh Algorithms


Free Mesh (see exercise 2)
Mapped Mesh
Swept Mesh
Boundary Layer Mesh

Interactive Meshing

Click on boundaries/domains/etc. and just


mesh directly from the toolbar

More Features
Extrude and Revolve 2D Meshes
Copy Meshes
Mesh Import (Nastran)
Mesh Statistics
Mesh Visualization

Mesh Supported elements


3D
Tetrahedral, hexahedral, prism and pyramid

2D
Triangular and quadrilateral

1D
Discretized domains into intervals

Automatic and interactive meshing

Mapped

Free tetrahedral

Mixed

Model courtesy Metelli S.p.A.

Boundary layer

Swept

Adaptive

Live Demo Meshing techniques


Swept

3D Geometry Import

Boundary layers

Different features
Combine different
techniques

Free quad

Free triangular

Hands-on Meshing Exercise

p.37-45 in PDF exercise book


Import of a 3D Parasolid file
Key instructive element

Learn how to use the meshing


sequence

On a realistic geometry you create a


mesh consisting of different element
types.
Save your file under a different name
and keep the model open for the next
exercise.

Live Demo Mesh statistics and plotting


Why pyramids?
Tansitioning element

Combine hexes with tets


Between domains
Boundary layers
At sharp corners/edges
Boundary layers

But this is handled automatically


by the meshing algorithm

Plotting techniques for


mesh

Mesh statistics
Plot different elements
Mesh quality criteria

Cyan Prism
Green Pyramid
Hex - Magenta

Hands-on Mesh plotting

Look at the mesh statistics


Plot the mesh and isolate different
element types.

Guidelines for meshing refinement


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

32

Meshing notes: The more elements, the better,


but this has some practical limits
Displacement

Normalized Max. Disp.

1.000

0.995

0.990
0

Refinement Iteration

Make sure to study the


solution variable, and
not a derived variable
33

Review
By now, you should know
Different options for drawing a geometry using COMSOLs CAD system.
How to deal with imported CAD geometries, to examine CAD geometries and
repair them. (but alas, the real world awaits...)
Different meshing options and techniques, and analysing and plotting your
mesh.
The impact of geometry quality and features on the discretization of the model
(mesh), and consequently/additionally...
The impact of mesh size and quality on simulation time and the results of the
simulation (relative error).

End of first session

BREAK?

Multiphysics couplings and Result


Visualisation

Lets start by considering a real


multiphysics example

Multiphysics example - Automotive Fuse


Made of Aluminum Alloy
Acrylic plastic cover
Resistive heating from the
electric currents

Involved physics
Electric currents DC
Heat Transfer
Thermal expansion

Part 1 Electric currents


Electric currents
V

( eV ) 0

Single physics
Linear
No source terms

Ground

15 A

Part 2 Electric currents and Heat transfer


Electric currents
V

q flux h(T Tamb )

( eV ) 0
Q = e|V|2

( T (T )T ) Q
Heat transfer
T
One way coupled multiphysics
Coupling through Load
Non-linear problem, T(T)

T = 20 C

T=?

Part 3 Electric currents and Heat transfer


Electric currents
V

q flux h(T Tamb )

( eV ) 0

e T

Q = e|V|2

( T (T )T ) Q
Heat transfer
T
Two way coupled

Non-linear
Couplings through load (strong) and
material property (weak)

T = 20 C

T=?

Part 4 Thermal stress


Electric currents
V

Free

( eV ) 0

e T

Q = e|V|2

( T (T )T ) Q
Heat transfer

Fixed

T Tref
Solid Mechanics
u, v, w

Fv

One way coupling


Can be solved separately

Definitions of various types of couplings

One-way coupled

Two-way coupled

All of the above

Weakly coupled

The results of one physics affects both that, and other, physics

Fully coupled

The results from one physics affect the material properties of other physics most often
this is temperature.

Non-linear coupled

The results from one physics affect only the loading on the other physics. In an equation
this is the source term (right-hand side).

Material coupled

Information gets passed back and forth between physics

Load coupled

Information passes from one physics to the next, in one direction

The physics do not strongly affect the loads/properties in other physics

Strongly coupled

The opposite of weakly coupled


46

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:
Try an iterative solver
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

Perform a mesh refinement and/or error refinement study to


validate your solution
47

Results Visualization and data sets

All solutions are stored in data sets. Several data sets can be stored from a single study or from
multiple studies.
When visualizing data you can plot in 1D, 2D or 3D depending on the data set and application
thereof to the plot group.
You can also create special data sets which refer to other data sets:
On a specified selection of geometric entities in the model or by creating your own
geometry intersecting with the domain/boundaries.
By combining data sets with the join feature.
The Derived Values section allow for scalar evaluations of quantities that either exist in the
default variable list or as created by yourself. Probe evaluations will also be stored here.
The evaluations will also be stored in the tables section and can be plotted or exported. If you
do a manual point and click evaluation on a surface plot, for example, it will also be stored in a
table.
In the export section you can define various ways of exporting data referring to a specific plot
group so once it is set up it is easy to export in a specific format with a single click. Some of
these export options are available directly above the graphics window, in the case where you
just want to quickly export an image, for example.
Finally, there is the automated report generator you can also customize the template to export
exactly the data you want.

Pick your own visualization exercise example


Pick one of the following model exercises
(open the solved problem from the model library if necessary, and just explore visualization)

Busbar
Power transistor
Boat radar cross section
Plot exercise in the PDF exercise book p.46-62

You can also browse in the Model library for other models

Exercise - Busbar
Electric conductor, typically found in high
power applications

Parameterized Geometry
Joule Heating
Thermal Expansion
Flow and Cooling
All files needed on product DVD in Model
Library

Exercise - Power Transistor


Electric currents
V
Joule heating
Q = |V|2
Heat transfer
T
Applied current

Predefined interface Joule Heating


Find the operating temperature of the power transistor
One way coupled problem

Exercise - Radar Cross Section


Boat hit by a radar
background field in an electromagnetic scattering problem.

Incident field

Response field (top)

Response field (norm)

Exercise Result Vizualisation


Volume
Surface
Contour
Plot Scalar Quantities

End of session 2

BREAK?

Equation-Based Modeling:
PDEs, ODEs, and Algebraic Equations

2u
u
ea 2 d a
(cu u ) u au f
t
t

Content
Partial Differential Equations (PDEs)
PDE Interfaces
Boundary Conditions

Ordinary Differential Equations (ODEs)


Global ODEs
Distributed ODEs

Algebraic Equations
Global algebraic equations
Distributed algebraic equations

When is Equation-based Modeling Needed?


Try to avoid equation-based modeling if possible
Using built-in physics interfaces enables ready-made post processing variables
and other tools for faster model setup and much lower risk of human error
Long-time users sometimes use equation-based modeling even though it is not
needed any longer. It may have been needed in the past but not any longer,
examples:
Thin Thermally Resistive Layer (contact resistance) boundary condition for Heat
Transfer in Solids. In older versions this required manual gluing of two physics
interfaces using equations on the boundary.
Adsorption (physics interface in in 4.2). Previously required weak form modeling.
and many more

When is Equation-based Modeling Needed?


But: we dont have every imaginable physics equation built-into
COMSOL (yet!). So there is sometimes a need for custom
modeling.
Or you might be deriving a new mathematical model, or using a
particular/unique model from literature.
Also if you cannot afford all the modules you need to simulate a
particular model, then you could get by modeling certain
phenomena directly from the equations. (time vs. money?)
You can combine equation based modeling with any physics
interface as if it is just another physics interface.

Custom-Modeling in COMSOL

COMSOL Multiphysics allows you to model with PDEs


or ODEs directly:
use one of the equation-template user interfaces

You do *not* need to write user-subroutines in


COMSOL to implement your own equation!
Benefit: COMSOLs nonlinear solver gets all the nonlinear info
with gradients and all. Faster and more robust convergence.

Customization Approaches

Four modeling approaches:


1. Ready-made physics interfaces
2. First principles with the equation templates
3. Start with ready-made physics interface and add additional
terms.
4. Start with a ready-made physics interface and add your own
separate equation (PDE,ODE) to represent physics that is not
already available as a ready-made application mode

PDEs

Linear Model Problems: Fundamental Phenomena

u 0

Laplaces equation
Heat equation

ut (ku) 0

Wave equation

utt (u) 0

Helmholtz equation

(u) u

For inhomogeneous versions, replace 0 with a function


depending on the independent variables

Convective Transport equation

ut bu x 0

COMSOL PDE Modes: Graphical User Interfaces


Can be used for scalar equations or systems
Note: coefficients may become operators of higher degree

Coefficient form
Coefficients correspond to common physical parameters (e.g., diffusion,
advection, etc.)

General form
Very flexible and compact

Weak form
PDE form that is the foundation of the FEM
Integral form that gives even more flexibility
Requires more expert knowledge

Q: Which to use?
A: Whichever is more convenient for you and your simulation.

Coefficient Form: Coefficient Matching

2u
u
ea 2 d a
(cu u ) u au f
t
t
n (c u u ) qu g hT

hu r

inside
domain

on boundary

Example: Poissons equation

u 1
u0

inside subdomain

on subdomain boundary

Implies c=f=h=1 and all other coefficients are 0.

Demo:
Block: 10x1x1
PDE: default Poissons
equation with unknown u.
Dirichlet boundary
condition everywhere: u=0

Demo:

ux uxz, d(u,x),
ux,
smoothing

file: Poisson_Default.mph

d(u,x) with no Recover smoothing

The Recover feature applies


polynomial-preserving recovery on
the partial derivatives (gradients).

Higher-order approximation of the


solution on a patch of mesh
elements around each mesh vertex.

d(u,x) with Recover smoothing

Coefficient Form, Interpretations

diffusion

source

absorption

2u
u
ea 2 d a
(cu u ) u au f
t
t
mass

damping/
mass

convection

convection

source

Coefficient Form, Structural Analysis Wave


Equation
elastic stress

initial/thermal
stress

2u
u
ea 2 d a
(cu u ) u au f
t
t
mass

damped
mass

body force
(gravitation)

ea

density

da

damping coefficient

cu

stress, u= displacement vector

stiffness, spring constant

Coefficient Form, Transport Diffusion Equation

diffusion

source

absorption

2u
u
ea 2 d a
(cu u ) u au f
u
t
accumulation/storage

convection

convection

source

Coefficient Form, Steady-State Equation


2u
u
ea 2 d a
(cu u ) u au f
u
t
u
0
t
2u
0
2
t

Coefficient Form, Frequency-Response Wave


Equation
diffusion

Helmholtz term

2u
u
ea 2 d a
(cu u ) u au f
u
t
Helmholtz equation:

(cu ) k 2u f
a k 2
k

Wave number

Wave length

source

Demo:
lambda=2.5
k=2*pi/lambda
a= - k^2

f=0
u=1 one end

u=0 other end

file: Helmholtz.mph

Transient Diffusion Equation ~ Heat Equation


diffusion

2u
u
ea 2 d a
(cu u ) u au f
u
t
source

accumulation/storage

d a C
ck
f volume heat source

Demo:
c=1

da=1

Cooling u=0 at ends

f=0

Transient 0->100
0
s

Heat Source f=1

file: Transient_Diffusion.mph

General Form A more compact formulation

u
u
inside domain
ea 2 d a
F
t
t
T

on domain boundary
n G
u

0R

For Poissons equation, the corresponding general form implies

All other coefficients are 0

ux uy F 1
R u.

Weak Form

u
da
F
t

General form

Multiply by test function v and integrate

Use Greens first identity on the terms involving del expressions

Rearranged

Subdomain integral above is entered in the weak field:

u
da v t dA v dA vFdA

u
da v t dA v n ds v dA vFdA
u

0 v vF d a v dA v n ds
t

-test(ux)*ux - test(uy)*uy + test(u)*F da*test(u)*ut


On the boundary, set constr: u

Coefficient Form vs. Weak Form:


Poissons equation

2u
u
ea 2 d a
(cu u ) u au f
t
t

u 1
Using Weak Form:
-test(ux)*ux - test(uy)*uy + test(u)*f = 0

(f=1)

PDEs+ODEs

Transient Diffusion Equation + ODE


2u
u
ea 2 d a
(cu u ) u au f
u
t
What if we wish to measure the global accumulation of heat over time?

U udV volume integral of solution


V

w U dt
t

time integral of volume integral

Transient Diffusion Equation + ODE


2u
u
ea 2 d a
(cu u ) u au f
u
t
What if we wish to measure the global accumulation of heat over time?

U udV
V

dw
w U dt
U
dt
t [ t 0 ,t1 ]
wt U 0

=> This is a Global ODE in w

Setting up a spatial integration operand

Global Equation ODE:


Same time-dependent
time
problem as
earlier

Time
Time-dependent
0,10,100
Volume integration of u

ODE: wt-U

file: Transient_Diffusion_with_ODE.mph

Demo

Compute total mass

You set up this integration in two steps:


1. An Integration model coupling is added under the Definitions node in the model
tree to make a space-integral for the mass flow rate m-dot.
2. Next, you need to add an ordinary differential equation (ODE) to integrate the
flowrate with respect to time. The ODE

3.
4.

Solves for the total mass that has exited at time t.


In COMSOL rearrange terms to left-handside: Mt-mdot=0.
File: fluid_valve_time_int.mph

PDEs + Distributed ODEs

Transient Diffusion Equation + Distributed ODE


2u
u
ea 2 d a
(cu u ) u au f
u
t
What if we get damage from local accumulation of heat.
Example of real application: bioheating

P( x, y, z ) u ( x, y, z )dt

local time integral of solution

We want to visualize the P-field to assess local damage.


Lets assume damage happens where P>20.

Transient Diffusion Equation + Distributed ODE


2u
u
ea 2 d a
(cu u ) u au f
u
t
What if we get damage from local accumulation of heat.
Example of real application: bioheating

P( x, y, z ) u ( x, y, z )dt

local time integral of solution

dP

u at each point in space


dt

Transient Diffusion Equation + Distributed ODE


2u
u
ea 2 d a
(cu u ) u au f
u
t

dP
u local time integral of solution
dt
But this can be seen as a PDE with no spatial derivatives =

= Distributed ODE
Use coefficient form with unknown field P, f = u, da=1
Let all other coefficients be zero

Volume where P>20 and


we get damage

file: Transient_Diffusion_with_distributed_ODE.mph

Transient Diffusion Equation + Distributed ODE

2u
u
ea 2 d a
(cu u ) u au f
u
t

P( x, y, z ) u ( x, y, z )dt

local time integral of solution

Lets make this more realistic by adding phase change:


1) assume that damage is irreversible

2) assume that for the damage locations the diffusion coefficient takes
a different value:
c=1+2.75*(P(x,y,z)>20)

Phase Change

Phase change: c=1+2.75*(P(x,y,z)>20)


P>20 evaluates to either 0 (false) or 1 (true)
c takes two values: 1 or 3.75 depending on if damage is
done at a point or not

Phase Change
Phase change: c=1+2.75*(P(x,y,z)>20)
Also:

P( x, y, z ) (u ( x, y, z ) 1)dt
t

Irreversible change!

Negative us arent allowed to decrease P


Once P>20, the change in diffusion coefficient c from 1 to
3.75 is permanent

Phase Change
More advanced phase change: c=1+2.75*(P(x,y,z)>20)
Also:

P( x, y, z ) (u ( x, y, z ) 1)dt
t

For convergence:
inequalities may need smoothing:
P>20

==> step1(P at 20,ds=5)

u>1

==> step2(u at 1,ds=0.5)

also: fine enough mesh to resolve phase fronts

Plot c to see phase change!

Phase Change
More advanced phase change: c=1+2.75*(P(x,y,z)>20)
Also:

P( x, y, z ) (u ( x, y, z ) 1)dt
t

For convergence:
inequalities may need smoothing:
P>20

==> step1(P at 20,ds=5)

u>1

==> step2(u at 1,ds=0.5)

also: fine enough mesh to resolve phase fronts

Diffusion coefficient with phase front clearly visible


for two different mesh cases. c=1 in blue areas
and c=3.75 in red areas.

file: Transient_Diffusion_with_distributed_ODE_and_pchange.mph

Note: since there is no spatial


dependency in the distributed
ODE, you can sometimes
improve the accuracy by
changing the finite element
shape function from the
default Lagrange to
Discontinuous scalar density.

Distributed Algebraic Equations

Example: Ideal gas law

Assume u=(u,v,w) and p given by Navier-Stokes


Want to solve Convection-Conduction in gas:

(kT ) C u T 0

given by ideal gas law:

Easy - analytical

pM

RT

Example: Non-ideal gas law

Assume u=(u,v,w) and p given by Navier-Stokes


Want to solve Convection-Conduction in gas:

(kT ) C u T 0

given by non-ideal gas law: A * ( p B )(1 C ) D


Needed for high molecular weight at very high pressures
Difficult implicit equation
How to proceed?
2

Example: Non-ideal gas law

A * ( p B 2 )(1 C ) D 0
How to solve:
Third order equation in
Pressure p is function of space
So: this is an algebraic equation at each point in space!
(distributed)

Distributed Algebraic Equation

How to solve:
A * ( p B 2 )(1 C ) D
Third order equation in
Pressure p is function of space
So: this is an algebraic equation at each point in space
See as PDE with no space or time derivatives!

A*(p+B*rho^2)*(1-C*rho)-D*rho
or if unknown is u:
A*(p+B*u^2)*(1-C*u)-D*u

Here we let: A=1,B=2,C=3, D=4, p=x*y

How: Put the entire equation in the source (f) term and zero out the rest

The solution u corresponding to the


equation A*(p+B*u^2)*(1-C*u)-D*u,
A*(
where p=x*y is spatially varying.
Here the equation is solved for each
point within the unit square.

file: Distributed_Algebraic_State_Law.mph

Distributed Algebraic Equation

What about nonlinear equations with multiple solutions?


Which solution do you get?
For simplicity, consider the equation (u-2)^2-p=0, where p is a constant
This can be entered as earlier with an f=(u-2)^2-p
The solution is easy to get analytically: u=2sqrt(p)
The solution you get will depend on the Initial Guess given by the PDE
Physics Interface

If we let p=x*y and let our modeling region be the unit square, then at
(x,y)=(0,0) we should get the unique solution u=2 but at (x,y)=(1,1) we get
1 or 3 depending on our starting guess. See next slide.

Distributed Algebraic Equation


u=3

u=2

u=2

u=1

file: Distributed_Algebraic_Second_Order.mph

Distributed Algebraic Transcendental Equation

How to solve: A * ( p B 2 )(1 C sin( )) D 0


Transcendental equation in
Same method

Complex Valued Equations


COMSOL can also handle complex valued quantities
Example: Lambert W function with no closed form representation

z we w
z x iy
w w( z )
we z we ( x i * y )
w

Coefficient form with f = w*exp(w)-(x+j*y)


c=0 and all others zero as well

Complex Arithmetics

Can compute:
real(w)
imag(w)
abs(w)
arg(w)
conj(w)

imag(w)

file: Lambert_W.mph

End of session

BREAK?

Parallel Computing and Clusters

Two Ways of Using Clusters for Simulation


Parameter Sweeps
Very Large Models

EM Field: Power Inductor


4 Million DOF / 11 GB RAM / Solution Time 6 Hours

Structural Analysis: Elbow Bracket of Steel


3.5 Million DOF / 7 GB RAM / Solution Time 0.4 Hours

Computational Challenges

Multiphysics means memory requirements multiply.


Parameter sweeps means that CPU time multiply.

Parallel computing

Shared memory
COMSOL uses all available cores
Mesh, solvers, postprocessing...
Free of charge

Distributed memory (Cluster)


Windows and Linux
Windows Cluster management
HPC server 2008
Compute Cluster 2003

Uses shared memory on each node


Free cluster nodes

Core
Host/Computer

COMSOL process

Clusters
Client Server/Remote
desktop

One or several
clients
Head node

Subnodes

Running COMSOL in parallel


COMSOL can run a job on
many cores
in parallel (Shared-memory
processing or multithreading)
COMSOL can run a job on
many physical nodes (cluster
computing)
Both parallel operations above
can be used in combination to
maximize parallelization
benefits
Cluster computing requires a
floating network license.

Processor core
A COMSOL job can use many
cores in parallel in a node by
Shared-memory processing

Node
A COMSOL job can use many nodes in
parallel by cluster computing

Four Ways to Run a Cluster job


See comsol -h
for details

1. Submit batch job from the command line of the headnode

Direct control through commands,


head:~>comsol nn 8 mpd boot
head:~>comsol nn 8 batch inputfile in.mph
can be used in shell scripts
head:~>comsol mpd allexit
Requires completed and saved
model mph file
Consumes 1 license seat regardless of number of compute nodes used
Needed if you use custom schedulers like LSF or PBS

2. Start a cluster-enabled COMSOL desktop GUI on headnode


Allows interactive modeling and
cluster job submission by the click of a button from
within the COMSOL Deskop GUI.
No command line proficiency needed
Consumes 1 license seat regardless of number
computer nodes used.
Not for use with custom schedulers
head:~>comsol clustersimple nn 8

Four Ways to Run a Cluster job, cont


3.

Start the COMSOL desktop GUI as a normal (non cluster) process on the
headnode. Then add a Cluster Computing feature to the model tree,
which branches off from the GUI a cluster job as a batch job.

Allows interactive modeling, and


cluster job submission as a separated batch job from the COMSOL Deskop GUI.
No command line proficiency needed
Allows you to submit and queue multiples jobs (different scenarios) from one
COMSOL Desktop process and continue working while the jobs are computing BUT
Consumes 1 or 2 license seats depending on
cluster configuration (regardless of number of compute nodes used).

head:~>comsol

Four Ways to Run a Cluster job, cont


4.

Start the COMSOL desktop GUI locally on a computer, separated from


the Linux cluster (like a Macintosh or Windows PC). Then start a clusterenabled COMSOL server on the cluster. Connect the desktop client to
the COMSOL server

Same as alternative 2 above, except that the COMSOL desktop is on a work computer,
separated from the cluster.

head:~>comsol server -nn 8 clustersimple

client/server

Two Ways of Using Clusters for Simulation

Parametric sweeps

Distributed

The performance of the cluster

Each NODE contains:

CPU
Cores

Communication Links
(MPI)

RAM

More nodes are faster, but performance is also a function of :

Cores per Node


Speed of each Core
RAM per Node
Communication Link Speed

Definitions
Computational node:
COMSOL process.
Communicates with other
computational nodes through
MPI

Host: Hardware physical machine with


network adapter and unique
network address. Part of the cluster.
Listed in mpd.hosts. Sometimes referred
to as physical node.

Core: Processor core.


used in Shared-memory
parallelism by a COMSOL
computational node,
through SMP (SharedMemory Processing)

Windows HPC Server 2008

nodes

COMSOL
Desktop

Windows HPC
Server 2008

Scheduler (job
manager)

Head
Node

nodes

nodes

Message Passing Interface


There are several implementations of MPI.
Windows: COMSOL uses the Windows HPC Server 2008 MPI
libraries.

Linux: COMSOL uses the Intel MPI library shipped with COMSOL
You can also configure COMSOL to work with most MPI
implementations based on MPICH2

Which solvers support distribution?


Parametric sweeps: All default solvers
Distributed solve: Direct solvers SPOOLES or MUMPS

Primary Benefit: Speedup (HPCS 2008R2)


T1
Sp
Tp

P number of nodes
T1 Sequential execution time
Tp Parallel execution time

10
Speedup

Definition:

12

8
6

4
2
0

4
6
8
10
Number of Nodes

12

Notes on Results
As parallel computation per node increases,
speedup increases.
E.g., 600 frequencies has greater speedup than 60.
Consider the positive impact on optimization.
Theoretically speedup could be linear S p p.

Serial operations, like file saving and logging, impact


actual results.

Very Large Models

Absorbed Radiation in the Human Brain

Primary Benefit: Extended Memory


One node: Out of RAM; killed after one hour.
Four nodes: Solution fits in RAM; solves in 5 minutes.

End of Session

4PM?

http://www.comsol.com/products/4.2a/

COMSOL 4.2A HIGHLIGHTS

Vous aimerez peut-être aussi