Upload
george-opar
View
255
Download
10
Embed Size (px)
Citation preview
8/16/2019 Comsol 2 Day Advanced Day1
1/130
DAY 1
Course presenter: Christiaan Hattingh
MTC
COMSOL South Africa
Course developed by: Niklas Rom, Anders Ekerot, Christiaan Hattingh
COMSOL AB
Advanced 2-day Training Course
8/16/2019 Comsol 2 Day Advanced Day1
2/130
File pack - Trial install
1. Copy all files from the flash drive1. 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.
2. 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.
2. Install COMSOL – use the install disc in your trial pack.1. You will be prompted to accept the license agreement and then to enter a passcode or license file.
2. 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).
3. 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).
4. 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.5. 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 dmg‟s and for linux zip files – please install at least the multiphysics
patch from these, the others are not essential for the workshop.
3. 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.
8/16/2019 Comsol 2 Day Advanced Day1
3/130
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 – PDE‟s
– PDE‟s and ODE‟s – PDE‟s and distributed ODE‟s
– DAE‟s
– Complex valued equations
• Cluster computing introduction
• News in COMSOL 4.2a
8/16/2019 Comsol 2 Day Advanced Day1
4/130
Structure
1. Presentations
1. Slides
2. Included in your file pack as PDF for reference after the course.
2. Demonstrations (interactive)1. Presenter will demonstrate in COMSOL 4.2a: you can either just follow the
demonstration or you can participate...your choice.
2. 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 containsadditional information and detailed sections on specific issues.
8/16/2019 Comsol 2 Day Advanced Day1
5/130
COMSOL Multiphysics
• Finite element analysis – Single physics
– Multiphysics
• Flexible Graphical User Interface – 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
8/16/2019 Comsol 2 Day Advanced Day1
6/130
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
8/16/2019 Comsol 2 Day Advanced Day1
7/130
Everything can link to everything
8/16/2019 Comsol 2 Day Advanced Day1
8/130
Geometry, CAD Import and Mesh
8/16/2019 Comsol 2 Day Advanced Day1
9/130
Modeling procedure - 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
Draw or import the geometry
8/16/2019 Comsol 2 Day Advanced Day1
10/130
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
8/16/2019 Comsol 2 Day Advanced Day1
11/130
• 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
Live Links and CAD Import
8/16/2019 Comsol 2 Day Advanced Day1
12/130
Importing CAD Files
• When you have other
geometry tools
8/16/2019 Comsol 2 Day Advanced Day1
13/130
CAD design for FEA
• During design of parts:
– Apply fillets and chamfers late in theCAD modeling process.
– Remove small features not importantfor the physics.
– Avoid narrow strips of faces.
• During design of assemblies:
– Avoid missalignment of components.
– Avoid separate design of matingfaces.
– Remove all small gaps andclearances from the model.
– Try to build components in the contextof another.
8/16/2019 Comsol 2 Day Advanced Day1
14/130
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
Remove C5, C6
Modify C1 or C4
C4
C3
C1
C2
C3
C1C2
C5
C6
C4
Example: spike
8/16/2019 Comsol 2 Day Advanced Day1
15/130
Repair Example – Sliver Faces
Remove face and
extend other faces
to fill gap
8/16/2019 Comsol 2 Day Advanced Day1
16/130
Working with 3D CAD files, the wrong way:
Designers Analysis
Staff
CAD File
8/16/2019 Comsol 2 Day Advanced Day1
17/130
Do not work with the fully detailed CAD model
272K DOF
This cannot be
defeatured by
COMSOLDownloaded fromthomasnet.com
8/16/2019 Comsol 2 Day Advanced Day1
18/130
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
8/16/2019 Comsol 2 Day Advanced Day1
19/130
Avoid short edges in the CAD file
GOOD
BAD
1637 elements
935 elements
8/16/2019 Comsol 2 Day Advanced Day1
20/130
Avoid sliver and thin faces
12,556 elements
8/16/2019 Comsol 2 Day Advanced Day1
21/130
Fillets, sometimes you want them, sometimes you
don’t
8/16/2019 Comsol 2 Day Advanced Day1
22/130
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
8/16/2019 Comsol 2 Day Advanced Day1
23/130
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.
8/16/2019 Comsol 2 Day Advanced Day1
24/130
Remember:
Good CAD data has just enough detail to capture the
physics, but not one detail more.
8/16/2019 Comsol 2 Day Advanced Day1
25/130
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
8/16/2019 Comsol 2 Day Advanced Day1
26/130
Mesh – Supported elements
• 3D
– Tetrahedral, hexahedral, prism and pyramid
• 2D
– Triangular and quadrilateral
• 1D
– Discretized domains into intervals
8/16/2019 Comsol 2 Day Advanced Day1
27/130
Automatic and interactive meshing
Free tetrahedral
Boundary layer
Mapped
Swept
Mixed
Adaptive
Model courtesy Metelli S.p.A.
8/16/2019 Comsol 2 Day Advanced Day1
28/130
Live Demo – Meshing techniques
• 3D Geometry Import
• Different features
• Combine different
techniques
Boundary layers
Swept
Free quadFree triangular
8/16/2019 Comsol 2 Day Advanced Day1
29/130
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.
8/16/2019 Comsol 2 Day Advanced Day1
30/130
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 criteriaCyan – Prism
Green – Pyramid
Hex - Magenta
8/16/2019 Comsol 2 Day Advanced Day1
31/130
Hands-on – Mesh plotting
• Look at the mesh statistics
• Plot the mesh and isolate different
element types.
8/16/2019 Comsol 2 Day Advanced Day1
32/130
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 youobserve 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 youconsider acceptable, then the solution is converged
5. In 4.2a you can compare solutions using the new “join” dataset.
32
8/16/2019 Comsol 2 Day Advanced Day1
33/130
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
N o r m a l i z e d M a
x .
D i s p .
Make sure to study the
solution variable, and
not a derived variable
33
8/16/2019 Comsol 2 Day Advanced Day1
34/130
Review
• By now, you should know
– Different options for drawing a geometry using COMSOL‟s 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 yourmesh.
– 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).
8/16/2019 Comsol 2 Day Advanced Day1
35/130
BREAK?
End of first session
8/16/2019 Comsol 2 Day Advanced Day1
36/130
Multiphysics couplings and Result
Visualisation
8/16/2019 Comsol 2 Day Advanced Day1
37/130
Lets start by considering a real
multiphysics example
8/16/2019 Comsol 2 Day Advanced Day1
38/130
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
8/16/2019 Comsol 2 Day Advanced Day1
39/130
Part 1 – Electric currents
• Single physics
• Linear
• No source terms
Electric currents
V
0)( V e
Ground15 A
8/16/2019 Comsol 2 Day Advanced Day1
40/130
Part 2 – Electric currents and Heat transfer
Electric currents
V
Heat transfer
T
Q = e|V |2
0)( V e
QT T T ))((
T = 20 C
)( amb flux T T hq T = ?
• One way coupled multiphysics
• Coupling through Load
• Non-linear problem, σT(T)
8/16/2019 Comsol 2 Day Advanced Day1
41/130
Part 3 – Electric currents and Heat transfer
Electric currents
V
Heat transfer
T
Q = e|V |2
0)( V e
QT T T ))((
T e
T = 20 C
)( amb flux T T hq T = ?
• Two way coupled
• Non-linear
Couplings through load (strong) and
material property (weak)
8/16/2019 Comsol 2 Day Advanced Day1
42/130
Part 4 – Thermal stress
Electric currents
V
Heat transfer
T
Q = e|V |2
0)( V e
QT T T ))((
T e
Solid Mechanics
u, v, w
Fixed
Free
ref T T
Fv
• One way coupling
• Can be solved separately
8/16/2019 Comsol 2 Day Advanced Day1
43/130
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. In an equation
this is the source term (right-hand side).• Material coupled
– The results from one physics affect the material properties of other physics – most oftenthis is temperature.
• 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
46
8/16/2019 Comsol 2 Day Advanced Day1
44/130
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
8/16/2019 Comsol 2 Day Advanced Day1
45/130
Results Visualization and data sets
• All solutions are stored in data sets. Several data sets can be stored from a single study or frommultiple 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 ofthese 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.
8/16/2019 Comsol 2 Day Advanced Day1
46/130
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
8/16/2019 Comsol 2 Day Advanced Day1
47/130
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
8/16/2019 Comsol 2 Day Advanced Day1
48/130
Exercise - Power Transistor
• Predefined interface – Joule Heating
• Find the operating temperature of the power transistor
• One way coupled problem
Electric currents
V
Heat transfer
T
Joule heating
Q = |V |2
Applied current
8/16/2019 Comsol 2 Day Advanced Day1
49/130
Exercise - Radar Cross Section
• Boat hit by a radar
– background field in an electromagnetic scattering problem.
Incident field Response field (top) Response field (norm)
8/16/2019 Comsol 2 Day Advanced Day1
50/130
Exercise – Result Vizualisation
• Volume
• Surface
• Contour
• Plot Scalar Quantities
8/16/2019 Comsol 2 Day Advanced Day1
51/130
BREAK?
End of session 2
8/16/2019 Comsol 2 Day Advanced Day1
52/130
Equation-Based Modeling:
PDEs, ODEs, and Algebraic Equations
f auuuuct
ud
t
ue aa
)(
2
2
8/16/2019 Comsol 2 Day Advanced Day1
53/130
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
8/16/2019 Comsol 2 Day Advanced Day1
54/130
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…
8/16/2019 Comsol 2 Day Advanced Day1
55/130
When is Equation-based Modeling Needed?
• But: we don‟t 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.
8/16/2019 Comsol 2 Day Advanced Day1
56/130
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: COMSOL‟s nonlinear solver gets all the nonlinear info
with gradients and all. Faster and more robust convergence.
8/16/2019 Comsol 2 Day Advanced Day1
57/130
8/16/2019 Comsol 2 Day Advanced Day1
58/130
PDEs
8/16/2019 Comsol 2 Day Advanced Day1
59/130
Linear Model Problems: Fundamental Phenomena
• Laplace‟s equation
• Heat equation
• Wave equation
• Helmholtz equation
• Convective Transport equation
0 u
0)( uk ut
0)( uutt
For inhomogeneous versions, replace 0 with a functiondepending on the independent variables
uu )(
0 xt buu
8/16/2019 Comsol 2 Day Advanced Day1
60/130
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.
8/16/2019 Comsol 2 Day Advanced Day1
61/130
8/16/2019 Comsol 2 Day Advanced Day1
62/130
8/16/2019 Comsol 2 Day Advanced Day1
63/130
d(u,x) with no Recover smoothing
d(u,x) with 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.
8/16/2019 Comsol 2 Day Advanced Day1
64/130
Coefficient Form, Interpretations
mass damping/mass
diffusion
convection
source
convection
absorption
source
f auuuuct
ud
t
ue aa
)(
2
2
8/16/2019 Comsol 2 Day Advanced Day1
65/130
mass dampedmass
elastic stress initial/thermalstress
body force(gravitation)
a
ae
d
c
c
u
2
2( )a ae d c a f
t t
u u
u u u u
Coefficient Form, Structural Analysis Wave
Equation
density
damping coefficient
stress, u= displacement vector
stiffness, “spring constant”
8/16/2019 Comsol 2 Day Advanced Day1
66/130
2
2( )a a
u ue d c u u u au f
u t
accumulation/storage
diffusion
convection
source
convection
absorption
source
Coefficient Form, Transport Diffusion Equation
8/16/2019 Comsol 2 Day Advanced Day1
67/130
2
2( )a a
u ue d c u u u au f
u t
0
0
2
2
t
u
t
u
Coefficient Form, Steady-State Equation
8/16/2019 Comsol 2 Day Advanced Day1
68/130
2
2
( )a au u
e d c u u u au f u t
diffusion Helmholtz term
source2
2
( )
2
c u k u f
a k
k
Helmholtz equation:
Coefficient Form, Frequency-Response Wave
Equation
Wave number
Wave length
8/16/2019 Comsol 2 Day Advanced Day1
69/130
Demo:
lambda=2.5
k=2*pi/lambda
a= - k^2
f=0
u=1 one end
u=0 other end
file: Helmholtz.mph
8/16/2019 Comsol 2 Day Advanced Day1
70/130
2
2
( )a au u
e d c u u u au f u t
accumulation/storage
diffusion
source
Transient Diffusion Equation ~ Heat Equation
sourceheatvolume
f
k c
C d a
8/16/2019 Comsol 2 Day Advanced Day1
71/130
“Heat Source” f=1
“Cooling” u=0 at ends
Demo:
c=1
da=1
f=0
Transient 0->100 s
file: Transient_Diffusion.mph
8/16/2019 Comsol 2 Day Advanced Day1
72/130
General Form – A more compact formulation
• inside domain
• on domain boundary
• For Poisson‟s equation, the corresponding general form implies
• All other coefficients are 0
R
u
RG
T
0
n
uyux .u R
1 F
F t
ud
t
ue aa
2
2
8/16/2019 Comsol 2 Day Advanced Day1
73/130
Weak Form
• General form
• Multiply by test function v and integrate
• Use Green‟s first identity on the terms involving “del” expressions
• Rearranged
• Subdomain integral above is entered in the “weak” field:-test(ux)*ux - test(uy)*uy + test(u)*F – da*test(u)*ut
On the boundary, set constr: u
a
ud v dA v dA vFdA
t
au
d v dA v ds v dA vFdAt
n
0 au
v vF d v dA v ds
t
n
a
ud F t
8/16/2019 Comsol 2 Day Advanced Day1
74/130
8/16/2019 Comsol 2 Day Advanced Day1
75/130
PDEs+ODEs
8/16/2019 Comsol 2 Day Advanced Day1
76/130
2
2( )a a
u ue d c u u u au f
u t
Transient Diffusion Equation + ODE
integralvolumeof integrale tim
solutionof integral volume
dt U w
dV uU
t
V
What if we wish to measure the global accumulation of “heat” over time?
8/16/2019 Comsol 2 Day Advanced Day1
77/130
2
2( )a a
u ue d c u u u au f
u t
Transient Diffusion Equation + ODE
0
],[ 10
U wt
U dt
dwdt U w
dV uU
t t t
V
=> This is a “Global” ODE in w
What if we wish to measure the global accumulation of “heat” over time?
8/16/2019 Comsol 2 Day Advanced Day1
78/130
Setting up a spatial integration operand
Global Equation ODE:
8/16/2019 Comsol 2 Day Advanced Day1
79/130
Same time-dependent problem as
earlier
Time-dependent 0,10,100
Volume integration of u
ODE: wt-U
8/16/2019 Comsol 2 Day Advanced Day1
80/130
file: Transient_Diffusion_with_ODE.mph
8/16/2019 Comsol 2 Day Advanced Day1
81/130
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
Solves for the total mass that has exited at time t.
3. In COMSOL rearrange terms to left-handside: Mt-mdot=0.
4. File: fluid_valve_time_int.mph
8/16/2019 Comsol 2 Day Advanced Day1
82/130
PDEs + Distributed ODEs
8/16/2019 Comsol 2 Day Advanced Day1
83/130
2
2( )a a
u ue d c u u u au f
u t
Transient Diffusion Equation + Distributed ODE
solutionof integraltimelocal ),,(),,( dt z y xu z y x P t
What if we get “damage” from local accumulation of “heat”.
Example of real application: bioheating
We want to visualize the P -field to assess local damage.
Let‟s assume damage happens where P>20.
8/16/2019 Comsol 2 Day Advanced Day1
84/130
2
2( )a a
u ue d c u u u au f
u t
Transient Diffusion Equation + Distributed ODE
solutionof integraltimelocal ),,(),,( dt z y xu z y x P t
What if we get “damage” from local accumulation of “heat”.
Example of real application: bioheating
spacein pointeachatudt
dP
8/16/2019 Comsol 2 Day Advanced Day1
85/130
2
2( )a a
u ue d c u u u au f
u t
Transient Diffusion Equation + Distributed ODE
solutionof integraltimelocal udt
dP
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
8/16/2019 Comsol 2 Day Advanced Day1
86/130
Volume where P>20 and
we get damage
file: Transient_Diffusion_with_distributed_ODE.mph
8/16/2019 Comsol 2 Day Advanced Day1
87/130
2
2( )a a
u ue d c u u u au f
u t
Transient Diffusion Equation + Distributed ODE
Let‟s make this more realistic by adding phase change:
1) assume that damage is irreversible
2) assume that for the damage locations the diffusion coefficient takesa different value:
c=1+2.75*(P(x,y,z)>20)
solutionof integraltimelocal ),,(),,( dt z y xu z y x P t
8/16/2019 Comsol 2 Day Advanced Day1
88/130
8/16/2019 Comsol 2 Day Advanced Day1
89/130
Phase Change
Phase change: c=1+2.75*(P(x,y,z)>20)
Also:
Irreversible change!
Negative u’s aren’t allowed to decrease P
Once P>20, the change in diffusion coefficient c from 1 to
3.75 is permanent
)1),,((),,( dt z y xu z y x P t
8/16/2019 Comsol 2 Day Advanced Day1
90/130
Phase Change
More advanced phase change: c=1+2.75*(P(x,y,z)>20)
Also:
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
)1),,((),,( dt z y xu z y x P
t
Plot c to see phase change!
8/16/2019 Comsol 2 Day Advanced Day1
91/130
Phase Change
More advanced phase change: c=1+2.75*(P(x,y,z)>20)
Also:
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
)1),,((),,( dt z y xu z y x P
t
Plot c to see phase change!
Diffusion coefficient with phase front clearly visible
for two different mesh cases. c=1 in blue areas
8/16/2019 Comsol 2 Day Advanced Day1
92/130
and c=3.75 in red areas.
file: Transient_Diffusion_with_distributed_ODE_and_pchange.mph
8/16/2019 Comsol 2 Day Advanced Day1
93/130
8/16/2019 Comsol 2 Day Advanced Day1
94/130
Distributed Algebraic Equations
8/16/2019 Comsol 2 Day Advanced Day1
95/130
Example: Ideal gas law
• Assume u =(u,v,w) and p given by Navier-Stokes
• Want to solve Convection-Conduction in gas:
• given by ideal gas law:
• Easy - analytical
0u)(
T C T k
RT
pM
8/16/2019 Comsol 2 Day Advanced Day1
96/130
Example: Non-ideal gas law
• Assume u =(u,v,w) and p given by Navier-Stokes
• Want to solve Convection-Conduction in gas:
• given by non-ideal gas law:
• Needed for high molecular weight at very high pressures
• Difficult – implicit equation
• How to proceed?
0)1)((* 2 DC B p A
0u)( T C T k
8/16/2019 Comsol 2 Day Advanced Day1
97/130
Example: Non-ideal gas law
• 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)
0)1)((* 2 DC B p A
8/16/2019 Comsol 2 Day Advanced Day1
98/130
Distributed Algebraic Equation
• How to solve:
• 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
0)1)((* 2 DC B p A
The solution u corresponding to theequation A*(p+B*u^2)*(1-C*u)-D*u,
where p=x*y is spatially varying
8/16/2019 Comsol 2 Day Advanced Day1
99/130
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
Di t ib t d Al b i E ti
8/16/2019 Comsol 2 Day Advanced Day1
100/130
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=2±sqrt(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 get1 or 3 depending on our starting guess. See next slide.
Di t ib t d Al b i E ti
8/16/2019 Comsol 2 Day Advanced Day1
101/130
Distributed Algebraic Equation
u=3
u=2
u=1u=2
file: Distributed_Algebraic_Second_Order.mph
8/16/2019 Comsol 2 Day Advanced Day1
102/130
Distributed Algebraic Transcendental Equation
• How to solve:
• Transcendental equation in
• Same method
0))sin(1)((* 2 DC B p A
8/16/2019 Comsol 2 Day Advanced Day1
103/130
Complex Valued Equations
• COMSOL can also handle complex valued quantities
• Example: Lambert W function with no closed form representation
• Coefficient form with f = w*exp(w)-(x+j*y)
• c=0 and all others zero as well
)*(
)(
yi xwe z we
z ww
iy x z
we z
ww
w
8/16/2019 Comsol 2 Day Advanced Day1
104/130
Complex Arithmetics
• Can compute:
real(w)
imag(w)
abs(w)
arg(w)
conj(w)
8/16/2019 Comsol 2 Day Advanced Day1
105/130
imag(w)
file: Lambert_W.mph
8/16/2019 Comsol 2 Day Advanced Day1
106/130
BREAK?
End of session
8/16/2019 Comsol 2 Day Advanced Day1
107/130
Parallel Computing and Clusters
• Two Ways of Using Clusters for Simulation
– Parameter Sweeps
– Very Large Models
8/16/2019 Comsol 2 Day Advanced Day1
108/130
EM Field: Power Inductor
4 Million DOF / 11 GB RAM / Solution Time 6 Hours
8/16/2019 Comsol 2 Day Advanced Day1
109/130
Structural Analysis: Elbow Bracket of Steel
3.5 Million DOF / 7 GB RAM / Solution Time 0.4 Hours
8/16/2019 Comsol 2 Day Advanced Day1
110/130
8/16/2019 Comsol 2 Day Advanced Day1
111/130
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
8/16/2019 Comsol 2 Day Advanced Day1
112/130
Clusters
One or severalclients
Client Server/Remote
desktop
Head node
Subnodes
8/16/2019 Comsol 2 Day Advanced Day1
113/130
Running COMSOL in parallel
• COMSOL can run a job on
many cores
in parallel (Shared-memory
processing or multithreading)
• COMSOL can run a job onmany physical nodes (cluster
computing)
• Both parallel operations above
can be used in combination to
maximize parallelizationbenefits
• 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
8/16/2019 Comsol 2 Day Advanced Day1
114/130
Four Ways to Run a Cluster job
1. Submit batch job from the command line of the headnode
– Direct control through commands,
can be used in shell scripts
– 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 –nn 8 mpd boothead:~>
comsol –nn 8 batch –inputfile in.mphhead:~>
comsol mpd allexit
head:~>
comsol –nn 8 mpd boothead:~>
comsol –nn 8 batch –inputfile in.mphhead:~>
comsol mpd allexit
head:~>
comsol –clustersimple –nn 8ead:~>comsol –clustersimple –nn 8
See comsol h
for details
8/16/2019 Comsol 2 Day Advanced Day1
115/130
Four Ways to Run a Cluster job, cont
3. Start the COMSOL desktop GUI as a normal (non cluster) process on theheadnode. 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:~>
comsolead:~>
comsol
8/16/2019 Comsol 2 Day Advanced Day1
116/130
Four Ways to Run a Cluster job, cont
4. Start the COMSOL desktop GUI locally on a computer, separated fromthe Linux cluster (like a Macintosh or Windows PC). Then start a cluster-
enabled 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 –clustersimplehead:~>comsol server -nn 8 –clustersimple client/server
8/16/2019 Comsol 2 Day Advanced Day1
117/130
Two Ways of Using Clusters for Simulation
Parametric sweeps Distributed
8/16/2019 Comsol 2 Day Advanced Day1
118/130
The performance of the cluster
Each NODE contains:
CPU
CoresRAM
Communication Links
(MPI)
More nodes are faster, but performance is also a function of :
• Cores per Node
• Speed of each Core
• RAM per Node
• Communication Link Speed
8/16/2019 Comsol 2 Day Advanced Day1
119/130
Definitions
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 (Shared-
Memory Processing)
Computational node:
COMSOL process.
Communicates with other
computational nodes through
MPI
8/16/2019 Comsol 2 Day Advanced Day1
120/130
Windows HPC Server 2008
COMSOL
DesktopHead
Node
Windows HPC
Server 2008
Scheduler (job
manager)
nodes
nodes
nodes
8/16/2019 Comsol 2 Day Advanced Day1
121/130
8/16/2019 Comsol 2 Day Advanced Day1
122/130
Which solvers support distribution?
• Parametric sweeps: All default solvers
• Distributed solve: Direct solvers SPOOLES or MUMPS
P i B fit S d (HPCS 2008R2)
8/16/2019 Comsol 2 Day Advanced Day1
123/130
Primary Benefit: Speedup (HPCS 2008R2)
p
pT
T S 1
0
2
4
6
8
10
12
1 2 4 6 8 10 12
S p e e d u
p
Number of Nodes
Definition:
P – number of nodes
T1 – Sequential execution time
Tp – Parallel execution time
8/16/2019 Comsol 2 Day Advanced Day1
124/130
V L M d l
8/16/2019 Comsol 2 Day Advanced Day1
125/130
Very Large Models
Ab b d R di ti i th H B i
8/16/2019 Comsol 2 Day Advanced Day1
126/130
Absorbed Radiation in the Human Brain
8/16/2019 Comsol 2 Day Advanced Day1
127/130
Primar Benefit E tended Memor
8/16/2019 Comsol 2 Day Advanced Day1
128/130
Primary Benefit: Extended Memory
One node: Out of RAM; killed after one hour.
Four nodes: Solution fits in RAM; solves in 5 minutes.
8/16/2019 Comsol 2 Day Advanced Day1
129/130
4PM?
End of Session
8/16/2019 Comsol 2 Day Advanced Day1
130/130
COMSOL 4.2A HIGHLIGHTS
http://www.comsol.com/products/4.2a/
http://www.comsol.com/products/4.2a/http://www.comsol.com/products/4.2a/