Intensive Training Class: COMSOL Multiphysics v4.0a Chandan Kumar, Ph.D. COMSOL, Inc.
Contents Day1
Introduction to COMSOL Multiphysics GUI
Model Definitions
Hands on #3
Meshing
Hands on #2
Geometry
Modeling Procedure Example: H Cell Hands on #1
Hands on #4
Solving
Hands on #5
Contents Day1
Introduction to COMSOL Multiphysics GUI
Model Definitions
Hands on #3
Meshing
Hands on #2
Geometry
Modeling Procedure Example: H Cell Hands on #1
Hands on #4
Solving
Hands on #5
Contents Day 2
Results
Equation Based Modeling
Hands on #8
Solvers Infinite Element and PML (Perfectly Matched Layer)
Hands on #7
Linear and Non-linear FEA
Hands on #6
Hands on #9
Time dependent problems
Hands on #10
COMSOL Multiphysics 4.0 Product Line COMSOL MULTIPHYSICS ® AC/DC MODULE RF MODULE
CHEMICAL REACTION
STRUCTURAL MECHANICS MODULE
ENGINEERING MODULE
ACOUSTICS MODULE
BATTERIES & FUEL CELLS MODULE
HEAT
MEMS MODULE
TRANSFER MODULE
PLASMA MODULE
EARTH SCIENCE MODULE
CFD MODULE
OPTIMIZATION MODULE
LIVELINK™ FOR SOLIDWORKS ® LIVELINK™ FOR AUTODESK ® INVENTOR ® LIVELINK™ FOR PRO /ENGINEER ® CAD IMPORT MODULE
MATERIAL LIBRARY
Supported Platforms: Windows, Linux, Mac OSX
LIVELINK™ FOR MATLAB ®
System requirements • A 32-bit architecture can store at most 232 numbers (~4GB RAM) – In practice, due to inefficient memory managers, most OS’s 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 OS’s 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 OS’s (Windows, Linux, MAC 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 (NVIDIA 512 MB appears to work well)
CAD Import Module – supported file types File formats
DXF (.dxf)
Comments
Does not require CAD Import Module
STL (.stl) VRML (.vrml, .vrl) Parasolid (.x_t, .xmt_txt, .x_b, .xmt_bin)
Requires the CAD Import Module
ACIS (.sat, .sab) Step (.STEP) IGES (.IGES) Solidworks (.sldprt, .sldasm) Pro/ENGINEER (.prt, .asm) Autodesk Inventor (.ipt, .iam) CATIA V5 (.CATPart, .CATProduct)
Requires the CAD Import Module and CATIA Import Module
CAD Import Module
• Imported CAD files can be translated to parasolid format or
COMSOL format. COMSOL has its own CAD kernel. • Geometry in COMSOL can be exported as parasolid files or
COMSOL files (.mphbin, .mphtxt). • CAD Import Module does not support any real-time
communication between COMSOL and other CAD packages.
CAD Livelinks •
LiveLinks for SolidWorks *, AutoDesk Inventor *, and Pro/ENGINEER * – Bidirectional Updates of
Geometry Dimensions
• Any LiveLink for CAD includes
a CAD Import Module * Trademarks of respective holders
Other supported file formats File formats
NETEX-G (.asc) ODB++(X) (.xml)
Comments
Requires AC/DC Module, RF Module or MEMS Module
GDS (.gdx) SPICE (.cir) NASA file (.dat) CHEMKIN (.dat)
Requires Chemical Reaction Engineering Module
CAPE-OPEN (direct connection) NASTRAN Bulk Data (.nas, .bdf, .nastran, .dat)
Supported mesh formats
VRML (.vrml, .vrl) STL (.stl) MATLAB models and functions (.m)
Requires Livelink MATLAB
COMSOL Multiphysics GUI
COMSOL Multiphysics – Graphics Window Graphics window Shows
geometry, mesh and
results. Select
geometry, domains, boundaries, edges and points by clicking within this window. The
icons at the top right let you change the visualization (zoom, transparency, hide objects/boundaries etc).
COMSOL Multiphysics – Model Builder
Model Builder window: Inverted
tree structure with root at the
top. Branches
contain information on the modeling steps and sequences.
Almost
all steps are recorded. Option to Enable/Disable or Delete steps.
A
step listed lower in the order takes precedence over an earlier step.
Inverted
triangle icon on top right corner to see more features (equation view, etc.).
COMSOL Multiphysics – Settings Window
Settings window: • Actively changes based on the branch
selected in the t he Model Builder. • Input and change model settings related
to physics, mesh, results, etc.
COMSOL Multiphysics – Status Window • Messages window: Information on number
of mesh elements and DOFs, solution time. t ime. • Progress window: Shows the progress and
related information on convergence while a model is being solved. • Results window: Displays numerical results
from Derived Values.
COMSOL Desktop – Top Menubar
Only if you are working with Livelink MATLAB
COMSOL Desktop – Model Library Select a model and click Dynamic Help icon to get documentation
• Example models categorized under
Modules and application areas. • Each example has a model file and
documentation.
Open model file
The COMSOL workflow
COMSOL Desktop – Material Browser • List of materials and respective material
properties. • Intended for use in the Materials branch of
the Model Builder. • Built-In comes with COMSOL Multiphysics. • Other materials are available with
appropriate add-on Modules Add your own material library. See www.matweb.com.
• Material Library has properties of 2500+
materials and is a separate product -Temperature dependent properties of solids - Temperature and pressure dependent properties of some fluids
COMSOL Multiphysics – Selection List
Provides a numbered list of geometry, domains, boundaries, edges or points.
COMSOL Desktop – Help Menu Help > Help Desk
COMSOL 4.0a GUI – Other Information • All windows can be resized dynamically
Windows can be shrunk or closed to maximize graphics area • Windows can be moved around within the main window or detached into a separate, floating, window • All branches can be renamed • The interface is designed for widescreen usage •
– You can also split the interface across dual monitors
•
Try these out yourself
COMSOL is designed for a three-button mouse
Left Mouse Button (LMB)
Right Mouse Button (RMB)
Middle Mouse Button (MMB) Many mice have a scroll wheel in the center that is also a button. Hold down the scroll wheel to click the MMB.
Using the mouse to move the graphics Click and hold down, while moving the mouse, the: LMB: will orbit the view
MMB: zoom in/out
• Click the LMB on the Graphics window and
try these out. • Try other options, zoom, transparency,
resize and reset the COMSOL Desktop.
RMB: pan the display
Resetting the Desktop Options > Desktop Layout > Reset Desktop
The COMSOL workflow
Constructing a model in COMSOL 1) 2) 3) 4) 5) 6) 7)
Define the problem type that you wish to solve Sketch, or import, your CAD geometry Define the material properties for each domain Set the loads & boundary conditions Mesh the domains Solve the model Post-process and report results
Define the Space Dimension Click the Next button to proceed to the next step
3D – The full Cartesian modeling space 2D axisymmetric – structures and solutions are assumed to be invariant around a centerline 2D – structure and solutions are invariant out of the plane 1D, 1D axisymmetric - variations along only one axis 0D – lumped parameter modeling, no spatial variations
Define the Application or Physics Select the physics that you are interested in. Multiple physics can be selected at one time. Once all physics are selected, click next.
Click the Add Selected button to add that physics to the model This is the variable name you will be solving for
Define the Study or Analysis type Finally, click Finish
Select the temporal behavior appropriate for the physics you are interested in. The most common types are: Stationary – No time variations Time Dependent – Fully transient behavior Frequency Domain – Known excitation frequency
A new model – graphical user interface
This is how the COMSOL Desktop should look after performing the initial steps
Exercise: Chemical Diffusion in an H cell •
Physics – Laminar Flow – Convection & Diffusion
See model file: Example_Hcell
H-Cell Setup •
Set Space Dimension to “3D”
•
Fluid Flow> Single Phase Flow> Laminar Flow Study>Stationary
•
Geometry: • Import >CAD > H_cell_GEOM_3D Global definitions (Import these files) • Parameters> Load> H_cell_constants
Set up Navier-Stokes Flow Laminar Flow: • Compressibility > incompressible • Fluid Properties: – Set Density to “rho”
22
– Set Dynamic Viscosity to “eta”
Boundary Conditions: • Defaults to Wall, No-Slip • Boundaries 2 & 8: (Inlets)
8 20 P =
Inlet, Pressure no viscous stress Set P0 to “p0”
•
Boundaries 20 & 22: (Outlets) Outlet, Pressure no viscous stress Set P0 to “0”
2
P =
p0
0
Mesh and Solve for Flow Mesh with Tetrahedral •
Set Predefined mesh size to “Extra Fine”
• Add Free Tetrahedral
Study > Compute
Set up Convection - Diffusion Model 1 – Add Physics Chemical Species Transport> Transport of Diluted Species (click end flag) 22
Convection & Diffusion: •
Diffusion to “D”
•
Velocity: Velocity field
c =
0
8 20
Boundary Conditions: • • • •
Defaults to Insulation Boundary 2: Concentration c=c0 Boundary 8: Concentration c=0 Boundaries 20 & 22: Outflow
2 c =
c0
Solve Coupled Equations Viscosity Function of Concentration •
eta = eta*(1+alpha*c^2)
Parametric Solver •
D = 1e-10 5e-11 1e-11
Study 1 •
Compute
Postprocessing • Slice plot for concentration
Hands-on #1: Cavity Radiation First multiphysics model • Heat Transfer • Surface to Surface Radiation • Stationary problem (steady-state solution) •
Model Definitions • • • • • • • • •
Global and Local Definitions Parameters and Variables Selection View Identity and Contact Pairs Functions Probes Model Couplings Coordinate systems
Global Definitions • Global Definitions can be used to define: – Parameters – Variables – Functions
• Quantities have global scope in the model file. They
can be used in multiple models in the same model file
Local Definitions • Model 1 > Definitions • Only valid within the model
Parameters and Variables Parameters
Variables
Only global scope
Can have either global or local scope at different geometry level (domain, boundary, edge, point)
Accepts only scalar values
Accepts numeric values, expressions involving other scalar variables or spatially dependent (vector) variables
Useful to run parametric analysis on any model input including geometry dimensions
Useful to store expressions which may be called in the model settings and postprocessing
Selection Model 1 > Definitions > Selection • Allows you to group several geometric entities which can be used in Physics or Mesh settings • Any number of selection groups can be created and customnamed •
View View 1
• •
Model 1 > Definitions > View Control visualization parameters – Transparency – Grid – Lighting
•
Hide geometry objects, domains, boundary, edges and points
View 2
Identity and Contact Pairs Identity Pairs
Contact Pairs
Only applicable to an assembly geometry
Only applicable to an assembly geometry
Could be useful for any physics interface
Only applicable for MEMS Module and Structural Mechanics Module
Make the solution across two connected boundaries (one from each connecting part) continuous. Identity Pair
Define boundaries where the parts may come into contact but cannot penetrate each other under deformation
See model file: Example_pairs Contact Pair
Functions
Right-click on Model > Definitions
Can be used to define input signal, material properties or other parameters that depend on: • Time • Spatial coordinates • Other variables from other physics
Built-in Functions - Examples Ramp
Pulse
See model file: Example_functions
Step
Triangle wave
Square Wave
Arbitrary Interpolation
Functions with a discontinuity
In COMSOL such functions can be written as Boolean expressions: (t>0) (t>=0) (t>0)&&(t<1) (t>1)||(t<0) These can cause numerical difficulties!!!
COMSOL has smoothed step functions and derivatives built-in: flc1hs(t,scale), fldc1hs(t,scale) flc2hs(t,scale), fldc2hs(t,scale)
Functions with a discontinuity: Phase change
When materials change phase the properties can undergo abrupt changes.
Adding smoothing helps the problem from a numerical point of view, and is a good reflection of the “mushy zone”
However, this is usually the worst possible approach!!
Usually, we want to smoothly transition between two values P_step P2 P1 T Set up this type of function:
P1 – (p1-P2)*flc2hs(T-T0,dT) Step function
Example: Melting Ice (no convection) Ice, T= -5°C
T0 dT k_S k_L rho_S rho_L Cp_S Cp_L LH_melting
0[degC] 0.5 2.31[W/m/K] 0.613[W/m/K] 918[kg/m^3] 997[kg/m^3] 2052[J/kg/K] 4179[J/kg/K] 333[kJ/kg]
Ice
Water
Freezing point Mushy zone width, in K Thermal conductivity of ice Thermal conductivity of water Density of ice Density of water Specific heat of ice Specific heat of water Latent heat of melting of H20
Incorporating latent heat Integral of the area between the curves must equal the latent heat Specific Heat Phase 2 See model file: Example_discontinuity
Phase 1
T Transition, or mushy zone
Probes • • • • •
Monitor the development of a scalar quantity from a dynamic simulation (time-dependent, frequency, parametric). Results appear as a table and plot Domain Probe Boundary Probe Edge Probe
•
Domain Point Probe Boundary Point Probe
•
Global variable Probe
•
Probe Average, Maximum, Minimum or Integral of any expression in selected domains, boundaries or edges Probe any expression at a point in a selected domain or boundary
Probe a global variable
Probes - Example
See model file: Example_probes
Model Couplings •
Mapping operators
Source
Coupling Operator
Destination
•
Scalar coupling - Mapping from n-D space to 0-D (scalar)
•
Vector coupling - Mapping from n-D to m-D space
Scalar Coupling Operators Integration • Average • Maximum • Minimum •
1. Define the operators on selected domains, boundaries, edges or points 2. Use these operators on any variable/expression in model settings or postprocessing
Vector Coupling Operators •
Extrusion – maps values between domains of same or lower to higher dimensions See model file: Example_extrusion
•
Projection – maps values between domains of higher to lower dimensions See model file: Example_projection
•
Boundary Similarity – maps an expression defined on a part of a boundary to another part of a boundary with the same shape
•
Identity Mapping – maps between geometric entities which overlap in different frames. When it is evaluated at a specific set of coordinates in the destination frame, its argument is evaluated with the same coordinates in the source frame.
List of Built-in Operators Unary and binary operators (relational, logical, arithmetic) • Special operators (derivatives, mean, if , etc.) • Mathematical functions (sin, cos, atan2 , log , abs, sqrt , etc.) • Physical constants ( g , k_B, mu0 , etc.). Append the name with _const (e.g. g_const ) •
For a complete list, see: Help > Help Desk > COMSOL Multiphysics > Global and Local Definitions > Operators, Functions, and Variables Reference
List of system variables Time: t Position: x, y, z, r, X, Y, Z, R Edge/Surface Parameter: s, s1, s2 Edge/Surface Normal: n, nx, ny, nz, nr Edge Tangent: tx, ty, tz, tr Surface Tangents: t1x, t1y, t1z, t2x, t2y, t2z Numerical Constants: eps, i, j, pi Eigenvalues: lambda Mesh Information: h, dom, meshtype, meshelement, dvol, qual
For a complete list, see: Help > Help Desk > COMSOL Multiphysics > Global and Local Definitions > Variables
COMSOL derivative variables Given solution variables: T, V, etc... The spatial derivatives are given by: Tx, Ty, Tz, Vx, Vy, Vz, etc...
Tx T x
Ty T y
The edge and surface tangent derivatives are: TTx, TTy, TTz, etc...
Tz
TTx
The time derivatives (if solving a transient problem) are: Tt, Vt, etc...
These can be mixed:
T z
I nn T
Tt
T
x
T t
2 2T Txytt 2 t x y
Exercise – Tube Resonances Wikipedia: • Open Tube: f = (nv) / (2L) n = 1,2, 3,… • Closed Tube: f = (nv) / (4L) n = 1,2, 3,… •
v = Sound Speed = 343 m/sec (air)
•
L = Tube Length
•
If L = 0.3 m, d = 20 mm
Open Tube: f = 572 Hz • Closed Tube f = 286 Hz •
OPEN BOTH ENDS
OPEN ONE END
Modeling Closed Tube • • • • • •
3D > Acoustics > Pressure Aocustics>Eigenfreq Aocustics>Eigenfreq Geometry> Cylinder > r=0.01 L=0.3 Add air Pressure acoustics Model> Default Boundary > Pick Top End > Sound Soft Study1: Set no. of eigenfrequencies = 2
Closed Tube COMSOL: f = 286.001 Hz • Closed Tube Analytic: f = 286 Hz •
See model file: Example_Tube_Resonance_ Simple
Add Valves
Top Open
•
Gemometry> Workplane > z-x Circle > r = 0.006, located at x = 0.02 Transform>Array> x= 5, every x=0.05 Extrude (negative) 0.011 Composite Object (no internal bound) Mesh, Solve Now f = 285.12
•
Open 2nd from top valve f = 472.53 Hz
•
Close 2nd, open bottom two, f = 712.46 Hz
• • • • •
See model file: Example_Tube_Resonance_ Valves
Bottom Closed
472 Hz
712 Hz
Hands-on #2: Rock Fracture Flow Geophysics – flow due to potential • Uses built-in Diffusion equation • Adaptive mesh refinement • Uses interpolation function •
– Open the data file rock_fracture_flow_aperture_data.txt
– Check the space delimited data format – % Grid = defines the grid – % Data = specify the data on the grid
Geometry •
Geometry Settings and CAD kernel
•
Building blocks for 2D and 3D geometries – Primitive shapes in 2D and 3D – Workplane – CAD operations
•
Importing CAD geometries
•
Geometry sequencing and parameterization
•
Finalize Geometry: Union vs. Assembly
•
Successful geometry for FEA models
Geometry settings in COMSOL Option to choose geometric units
Absolute repair tolerance = relative repair tolerance x maximum coordinate of the input objects
• Geometric entities that have a distance less
than the absolute repair tolerance are merged • Important for creating composites COMSOL kernel = mphbin file CAD Import Module kernel = parasolid file
Technical Note: CAD Modeling kernels •
CAD kernel: A fancy name for a software library that is used to describe a geometry in modeling space
•
COMSOL Kernel: Proprietary internal format, but written to address specific needs of the COMSOL userbase – Limitation: You cannot write out a COMSOL Kernel CAD file into any other
CAD format
•
PARASOLID Kernel: Proprietary 3 rd party format, ubiquitous in the CAD/CAM/CAE industry – All COMSOL CAD Module products are based upon this kernel – Advantage: You can write data back out to in parasolid format and open the
geometry in another program
Primitive shapes in 2D and 3D • •
Right-click on Geometry in Model Builder These shapes are building blocks 2D Primitives
3D Primitives
Workplane
Using a workplane to embed 2D surfaces Shows the workplane geometry
Embeds the 2D geometries in the 3D area
Exercise: Dissect a sphere using workplane
Other CAD operations • • • • • • •
Extrude Revolve Chamfer (only in 2D) Fillet (only in 2D) Split Delete Boolean Operations
•
Transforms – Array – Copy – Mirror – Move – Rotate – Scale
•
Conversions
– Union
– Convert to Solid
– Intersection
– Convert to Surface
– Difference
– Convert to Curve
– Compose
– Convert to Point – Convert to COMSOL
Importing CAD geometries • • •
Right-click on Model Builder > Geometry Option 1 – Import a CAD file Option 2 – Use CAD LiveLink
CAD Import vs. LiveLink File Import Reasons for Already have the data in this Using format Advantages
Only need the CAD file, nothing else
Disadvantages Cannot easily modify the CAD
data, the COMSOL model will not update if you need to change the original CAD file
Live-Links Allows you to do all CAD modeling in 3rd party CAD packages Can modify the CAD data and the COMSOL model will update automatically Requires that you have the CAD program installed and open on the same computer
You can have a model with both
Build CAD in COMSOL or Import?
COMSOL Advantages
Import (File Import OR Live-Link)
Everything is in one native file format
Can use a full-featured CAD tool for modeling
The CAD will be well-suited for analysis
Live-Link functionality is “best-of-both-
Disadvantages COMSOL is not a high end
worlds”
Requires additional expertise, software, $$$
CAD package External CAD is not always suited for COMSOL modeling
You can have a model with both
Geometry sequencing • All geometry steps added are • • •
recorded sequentially Order of adding geometry steps is important Easy to go back and change information in certain steps Do not need to rebuild geometry from scratch
Geometry parameterization •
Create parameters to define geometry dimensions
•
Setup the model only with information on physics and meshing
• Add a Parametric Sweep study – Uses geometry sequence steps and parameter value to rebuild geometries – Solve the same multiphysics problem for varying geometry dimensions
•
Parametric sweep can involve: – One parameter – Ordered pair of parameters – Nested parameters
Geometry parameterization - Example See model file: Example_geom_parametric
•
Vary only width – Values: 1 1.5 2 – 3 solutions
Study 1 > Parametric Sweep
•
Vary both width and height – Use same parametric sweep – Names: width height – Values: 1 0.1 1.5 0.15 2 0.2 – 3 solutions
•
Vary both width and height – Use two parametric sweeps (nested) – Name: width, Values: 1 1.5 2 – Name: height, Values: 0.1 0.15 0.2 – 9 solutions
Understanding the icons
Green Box: You are here
Red X: Invalid entry in the settings
Gray icon: Disabled
Gray triangle: Geometry at this step needs rebuilding Gray box: You are here, but need to rebuild
The finalize node
Union vs. Assembly
•
Union – Default option to be used in most cases – Combines all geometry into one finalized geometry
• Assembly – Detached geometry – Required for identity and contact pairs – Allows you to mesh adjoining boundaries independently – Imprints create a copy of adjacent boundaries
Union vs. Assembly - Examples See model file: Example_assembly
Inspect each of these cases
Assembly – Slit boundary conditions
Geometry exercise
Example 1: Five steps
Example 2: Four steps
Example 3: Ten steps
Example 4: Ten steps
CAD repair exercise • •
Open a new 3D file Import the geometry file repair_demo_1.x_b
•
Mesh it using Normal Free tetrahedral mesh Number of mesh elements = 89592
•
Geometry 1 > CAD Repair > Repair
•
• Absolute repair tolerance = 1e-3 • •
Mesh it using Normal Free tetrahedral mesh Number of mesh elements = 63373
Successful geometry for FEA • Avoid excessive small details • Avoid singularities in the geometry • Use the geometry required to analyze the physics • Avoid high aspect ratio • Use symmetry
Avoid excessive small details • • •
Working with overly detailed geometry, extraneous features Sliver faces (drafts), small faces, short edges Fillets, fillets, fillets
Downloaded from thomasnet.com
Avoid singularities in the geometry See model file: Example_geom_singularity • Consider DC current flow • Cut a notch out of a square block,
apply insulating boundary conditions • Notch introduces a singularity in electric field and resistive heating • Apply a fillet at the notch • How does the fillet affect the solution? - Locally - Globally
Avoid singularities in the geometry • Resistive heating at notch vs. fillet radius • Solution changes by order of magnitude • Strong local effect
• Total resistive heating vs. fillet radius • Negligible change in solution 0.001% • Weak global effect
Use the geometry required to analyze the physics
Actual part
Geometry of flow path
• COMSOL can cap rectangular and circular planar faces on
3D objects, other capping operations are more difficult • Try to get the negative geometry in the original CAD package
89
Avoid high aspect ratio Thin layer inbetween two bulk materials
• 2D aspect ratios of up to 1000:1 are possible (but difficult) • In 3D, due to memory and accuracy constraints, try to stay
below 100:1 • Approximate this via a boundary condition • Consider using a reduced dimension model • Try using Infinite Elements or Perfectly Matched Layers (PML) as appropriate to model infinitely extended region
Use symmetry • Use symmetry planes • Model on reduced geometry
- Less mesh - Less memory - Less time • Consider using: - 2D if there is no variation in geometry and solution out-of-plane - 2D axisymmetry if there is no variation in geometry and solution about an axis of revolution
Materials • Adding user-defined materials – Built-in safety checks – Adding or removing properties – Calling functions
•
Modifying properties of materials from the Material Browser – Using your own expression
•
Plotting material property functions – Plotting built-in properties as functions of temperature – Plotting built-in properties as functions of temperature and pressure
User-defined Materials Model 1 > Materials > Material
Essential properties required are selected based on the chosen physics in the model
Values must be assigned to these essential material properties
Add/remove properties and functions Model 1 > Materials > Material 1 > Basic
Select a property and delete it from the list
Call a function
Modifying material properties • • •
In Model Builder , select Model 1 > Materials > s o m e m a t er i al In the Settings panel, find the Material Contents area Type in your own expression or call a user-defined function
Plotting material properties Try the following • Add these material from the Material Browser • Liquids and Gases > Liquids > Ethanol •
– We will plot density as a function of temperature
•
Liquids and Gases > Gas > Freon12 vapor – We will plot density as a function of pressure and temperature
Property as a function of temperature Materials > Ethanol > Basic > Piecewise (rho)
1-D Plot
Temperature-dependent expression
Property as a function of pressure and temperature Materials > Freon12 vapor > Basic > Analytic (rho)
Pressure and Temperaturedependent expression 2-D Plot
Pressure and Temperature range for plot
Hands-on #3: Permanent Magnet Magnetostatics – no current • Symmetry and antisymmetry boundaries • Automatic calculation of magnetostatic force • Stationary problem •
Mesh •
Geometry discretization using mesh – Element order – Discretization error – Memory requirements
•
Meshing 2D and 3D geometries – Unstructured and structured mesh elements – Mesh sequencing – Converting structured to unstructured mesh
•
Mesh parameters – Element size – Growth rate – Resolution
Why do we mesh? •
• •
The finite element method works by dividing the complex CAD shape up into smaller pieces, or elements, over which it is easy to approximate the solution via polynomials. The more elements, the better the approximation of the solution. The more elements, the longer to solve, and more RAM is needed.
How finely do we need to mesh? • • •
You rarely know this ahead of time with 100% certainty The mesh needs to be fine enough to resolve all of the gradients in the solution Perform a mesh convergence study Solution
Increasing number of elements
Geometric discretization error 1
10
Four linear elements discretizing a unit circle
1.E+00
1st order
Error: (π -2)/π
1.E-02 r o r r E
1.E-04
3rd
order
2nd order
1.E-06
Elements per Chord
This mesh adequately describes the geometry, but not necessarily the solution!
Meshing notes: The more elements, the better, but this has some practical limits Displacement
P
1.000
. p s i D . x a M0.995 d e z i l a m r o N 0.990 0
1
2
3
4
Refinement Iteration
5
Make sure to study the solution variable, and not a derived variable
Numerical Error k = exp(u) N/m p = 2 N
This problem has an exact solution, but we are solving it numerically via NewtonRaphson iterations.
u
The error can be minimized by taking many iterations, but a computer usually cannot find an exact answer for two reasons:
Force balance on node: f (u) = p ku=0 f (u) = 2 - exp(u) u = 0 f (u)
1) Numerical approximations,
usolution≈ 0.853 u
2) Operations such as exp( u) are approximate This is NUMERICAL error
Discretization Error 10 1st order elements
4 2nd order elements
exact-umodel
u
16 1st order elements
A finite element basis function can only approximately represent a true solution. The error can be minimized by using smaller elements, or increasing element order. This is MESH or DISCRETIZATION error
Discretization error and numerical error 1.E+00
Mesh error
decreases with more elements
r o r r E l a t o T
1.E-02
Numerical error is an inherent
1.E-04
property of computers, which cannot exactly represent numbers. It increases with more elements.
1.E-06
1.E-08
1.E-10 1
10
100
1000
10000
100000
Number of Elements pe r Wavele ngth
1st order elements
1000000
Total Error vs. memory requirements n: # of elements per side
n=2
n=1
n=1 n=20
Insulated quarter cylinder with heat generation
Meshing options for 2D
Explore
2D mesh sequence See model file: Example_mesh_2D_sequence
Boundary Layer Stretching factor: Ratio between 2 consecutive Boundary layers.
Thickness adjustment: Thickness of first layer. Automatic Means 1/20th of the local domain element height.
Meshing options for 3D
What kind of meshes can we use?
Tetrahedral Most general, any 3D part can be tet meshed. Use this as much as possible.
Hexahedral
Prismatic
- Only appropriate for certain geometries - When solution is known to vary slowly in one axis - Large deformations of the mesh - Contact problems
Hybrid mesh
Boundary Layer Meshing
A semi-automatic hybrid approach between prismatic and tetrahedral meshing. It is meant for situations when you know that there will be high gradients normal to some surfaces, but you want the flexibility of the tetrahedral mesh in the remainder of the domains.
Predefined and custom mesh options •
Predefined – 9 options from Extremely Coarse to Extremely Fine
•
Custom
Mesh parameters •
Maximum element size (positive number) – Maximum allowed element size
•
Minimum element size (positive number) – Minimum allowed element size
•
Element growth rate (a number between 1 and 2) – Rate at which the element size can grow from a region with small elements
to a region with larger elements
•
Resolution of curvature (positive number) – Determines the size of boundary elements compared to the curvature of the
geometric boundary – Max element size along boundary = curvature radius x resolution of curvature – Lower value gives finer mesh
•
Resolution of narrow regions (positive number) – Control the number of layers of elements that are created in narrow regions – A value between 0 to 1 produces anisotropic element
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
Element growth rate •
This controls the maximum element size between adjacent elements
Resolution of curvature radius=0.5
Maximum element size is 0.05
Resolution of narrow regions
Resolution=1
Resolution=5 Puts approximately the specified number of elements into the narrow regions
2D Triangular, Quadrilateral, Mapped, and Boundary Layer Meshes
Triangle
Quad
Mapped
Boundary Layer
Example 1: Use a sequence of meshing commands to build up customized meshes 1) Global Mesh size set
4) Swept meshes of differing distributions
2) Local mesh size on three faces
3) Tetrahedral mesh
Example 2: Creating additional partitioning geometry objects can help with swept meshing
Example 3: Split the domain by extruding curves
Example 4: The distribution of elements along edges can be specifically controlled
Meshing Exercise – Different element types
Tetrahedral vs. prismatic elements
current carrying wire
23,000 elements
2,500 elements
186k d.o.f.
83K d.o.f.
22s solve time
17s solve time
150 MB for K matrix
150 MB for K matrix
Solvers are tuned to take advantage of tetrahedral elements
Hands-on #4: Micromirror • • • • • •
MEMS model Advanced structural mechanics problem Prestressed structure Geometric nonlinearity Mapped and Swept mesh Parametric study
Solving •
Study defines how to solve a model – Study Steps – Solver Configuration – Job Configuration
Default Study node You can add multiple study steps to solve one physics at a time. COMSOL automatically uses the first study step as an input to the second study step. See model file: Example_StudySteps Different study types
Solving •
•
Solver Configuration contains all the solver settings and sequences. To look at the Solver configuration before solving enable “view more options”
Solving •
Solver Configurations: Show default Solver or Create Custom Solver
Type Variables
Solving • Adaptive Meshing – Stationary or Eigenvalue problems – Evaluates residual, calculates local error
and refines mesh based on local error.
Solving • Adaptive Meshing Example To add adaptive mesh refinement in Study3 – Right click on Study3 and
select Show Default Solver – Right click Stationary Solver 1 and select Adaptive Mesh Refinement – Right click Study 3 and select Compute
Open model file: Example_Adaptive_Meshing