Comsol Postprosessing and Visualization Handbook Part-2
Comsol Postprosessing and Visualization Handbook Part-2
Specialized Techniques
for Postprocessing and
Visualization in
COMSOL Multiphysics®
Specialized Techniques for Postprocessing and
Visualization in COMSOL Multiphysics
COMSOL, COMSOL Multiphysics, Capture the Concept,
COMSOL Desktop, LiveLink, and Simulation for Everyone are
either registered trademarks or trademarks of COMSOL AB. All
other trademarks are the property of their respective owners,
and COMSOL AB and its subsidiaries and products are not
affiliated with, endorsed by, sponsored by, or supported by those
trademark owners.
©2015 COMSOL.
Contact Information
Visit the Contact COMSOL page at www.comsol.com/contact to
submit general inquiries, contact Technical Support, or search for
an address and phone number. You can also visit the Worldwide
Sales Offices page at www.comsol.com/contact/offices for address
and contact information.
Further Resources
Further writing and tutorials on postprocessing in COMSOL®
software are available here:
VIDEOS
http://www.comsol.com/videos?workflow=workflowstep-results
BLOG ARTICLES
http://www.comsol.com/blogs/category/all/postprocessing/
DISCUSSION FORUM
www.comsol.com/community/forums/results-and-visualization/
ii
TABLE OF CONTENTS
INTRODUCTION 1
PLOT EXPRESSIONS AND RESULTS INTERPRETATION
▪ Creating Your Own Expressions 2
▪ Using Derived Values to Verify Your Model 4
▪ Mesh Plots 5
▪ Deformations, Height Expressions, and Scaling 6
▪ Operations for Results Interpretation 7
VISUALIZATION TOOLS
▪ View and Camera Control 13
▪ Lighting and Scene 20
APPLICATION-SPECIFIC PLOT TYPES
▪ Far-Field Plots 23
▪ Particle Tracing 24
ADVANCED TIPS & TRICKS
▪ Ideas for Powerful Visualization 26
▪ Animations 30
▪ Rendering and Smoothing 31
LOWER-DIMENSION POSTPROCESSING
▪ Terminology Refresher 33
▪ Thin Layer Attributes 34
▪ Discontinuities 36
▪ The Up and Down Operators 36
▪ The Side Operator 37
▪ Comparing Domain and Boundary Plots 38
▪ Summary 40
CONCLUDING REMARKS 41
iii
iv
INTRODUC TION
INTRODUCTION
Welcome back! If you’re reading this, hopefully
that means you found the first part of this
handbook set, Essentials of Postprocessing and
Visualization in COMSOL Multiphysics®, helpful
for understanding the postprocessing and
visualization techniques used in the COMSOL
Multiphysics® software.
check the contribution from each term. Change Now disable the electric field norm plot and add
the expression to the product of the current and an arrow volume. The default plot expression is
the electric field in the x-direction (ec.Jx*ec.Ex); the current density. You can use the plot settings
it looks nearly the same as the previous image. shown below or adjust them to your liking.
NOTES
Expressions follow the naming pattern of interface.quantity. For example, ec.Jx*ec.Ex is the product of the x-components of
the current density and electric field vectors, as defined in the Electric Currents physics interface. Many other mathematical
operators and functions are built in to the COMSOL® software, and a list is available in the Global and Local Definitions section
of the COMSOL Multiphysics Reference Manual available with the COMSOL documentation. You can also create your own
variables and operators and type them in manually, provided their definitions are accurate on the entity being plotted.
The resulting arrow plot will show the strength them so that we can start from scratch to
of the current at different locations in the demonstrate the process. Then add two global
busbar. Below, the arrow plot is shown with a evaluations using the right-click menu.
color expression based on the strength of the
electric field norm, ec.normE. The first global evaluation will be performed on
the power flowing through the device. In the
settings, navigate to Replace Expression > Model >
Component 1 > Heat Transfer > Global > Net powers
and choose ht.ntefluxInt - Total net energy rate.
Click Evaluate. A table will open beneath the elements will affect the geometric and numerical
Graphics window showing the value of the total representation of your application. Both result in
REFERENCE
net energy power: 0.99996 W. Since the only heat poor accuracy. We’ve previously discussed using
flux input was set to 1W, we can see that energy is derived values to check whether the mesh is fine For an introduction to global
conserved with a reasonable level of accuracy. enough. Now we’ll focus on its quality. evaluations, turn to the Data
Sets, Derived Values, and
The second global evaluation will be performed One way to determine the quality of the mesh Tables chapter in Essentials
on the mass flow. In the settings for Global or visualize elements on the model geometry is of Postprocessing and
Evaluation 2, navigate to Replace Expression > to create a mesh plot. These don’t even require Visualization in COMSOL
Model 1 > Component 1 > Laminar flow and solving the model in order to plot them. Multiphysics. For more
choose spf.out1.Mflow - Mass flow. information about derived
In the heat sink model under the Component 1 values and interpreting
node, right-click the Mesh node and choose results, turn to the section
Plot. You’ll see something like this: called Operations for Results
Interpretation at the end of
this chapter.
HINT
In the image below, the color settings are set to Under the Scale tab, make sure to set the scale
the WaveLight color table with a symmetrized factor to 0.1 or less (you’ll see why this is
color range: necessary if you set it to a larger quantity, like 1).
Then click Plot.
AVERAGES
Averages can be calculated over a set of domains
for a specific data set. We’ll check out a model
of turbulent flow in a pipe to demonstrate this
(although once again, these techniques are REFERENCE
applicable to many types of models). If you have
the CFD Module installed, open the solved pipe For an introduction to data
elbow model from File > Application Libraries > sets and derived values, turn
CFD Module > Single-Phase Benchmarks. to the Data Sets, Derived
Values, and Tables chapter in
This model simulates the flow in a 90° pipe Essentials of Postprocessing
elbow using a κ-ω turbulence model. It contains and Visualization in
two different components; we will examine the COMSOL Multiphysics.
second one.
Click Evaluate. The table that appears will show We’ll test this on the pulley model we used in the
the pressure, approximately 1970 Pa. Essentials of Postprocessing and Visualization
in COMSOL Multiphysics handbook, where we
introduced readers to solutions, cut points, and
tables. Open the model from File > Application
Libraries > COMSOL Multiphysics > Structural
Mechanics > stresses in pulley.
The contour colors show clear distinction The new plot shows the value of each contour,
between the areas of high and low stress; with the highest stress appearing at the thinnest
the contour of highest stress can be used to area of the joint (around 63 MPa). These labels
determine whether the pulley will fail. are very helpful for an at-a-glance look at the
data; if the stress is too high in one area, you’ll
know immediately.
JOINING
The Join function combines solutions from two
data sets, allowing you to compare them. This
is helpful for visualizing the difference between
two solutions, creating sums that contain
multiple solutions, or seeing how two different
meshes affect the results.
If we create a new 3D plot group using a surface The Explicit combination method allows you
based on Join 1, we’ll find that the slowest air to implement operations while still preserving
HINT
flow (U0 = 0.05 m/s) results in temperatures individual data sets within the join function—
around 64 K hotter than the fastest air flow. they remain usable, for example, in the As demonstrated here, joining
expression of a plot that uses a Join solution. doesn’t actually require two
COMSOL creates two new operators that access solvers—you can also use a
the quantities from the data sets; therefore a Join data set to examine one
function f(u)-g(v) could be implemented using solution evaluated at two
the Explicit method, as long as u is a valid different parameter values.
variable available in f and v is available in g.
FILTERS
Sometimes, an entire plot area will actually
block your view of the inside of a model. But
COMSOL makes it easy to “peel” the plot so that
you can see better. This function is called a filter
and can be added to 2D and 3D plots (except the
streamline type).
REFERENCE
For a brief introduction to isosurfaces, see the Plot Types chapter in Essentials of
Postprocessing and Visualization in COMSOL Multiphysics.
In this case, adding a solution that contains only We can now see the temperature surfaces
half the geometry would require creating a cut everywhere that y>0.
plane and a lot of careful selecting. We’ll use a
filter instead. Change the Element nodes to fulfill expression
field to At least one but not all.
Right-click the isosurface plot node and choose
Filter. The filter settings allow you to choose a
logical expression to designate an area of the
plot surface to include. For instance, setting
the expression to y>0 will exclude areas of the
isosurfaces that lie in the -y quadrants of the
coordinate system.
VISUALIZATION TOOLS
VIEW AND CAMERA CONTROL The cards in this chapter will demonstrate
shortcuts using the busbar model (File >
The View node is one of the most powerful Application Libraries > COMSOL Multiphysics >
tools available for orienting your object in the Multiphysics > busbar), but we encourage you to
Graphics window. Found under the Definitions try these out on one of your own simulations.
node, views can help you set up the exact Here’s what the Camera settings look like:
perspective and scene style that you want. This
is where lights are added, angled, and dimmed,
where color and position are arranged, and
where regions of a model can be hidden or
revealed. To draw a parallel to the world of
theater, the View node lets you set the stage
before the curtain rises and the show begins.
Right-click and drag. This first shortcut moves the visible frame left, right, up, or down on the
camera’s viewfinder plane (the plane of the Graphics window). This changes the View Offset.
Left-click and drag while holding the Alt key. This shortcut rotates the camera around an axis
perpendicular to the plane of the Graphics window:
Center-click and drag. Another very simple action is zooming in on the area where the mouse
is located. While the zoom buttons in the Graphics tools are quick and easy, they zoom in on the
center of the visible window by specific increments and are not affected by the location of the mouse.
This action gives you more precise control over the zoom angle:
Left-click and drag while holding the CTRL key. The following shortcut changes the pan and tilt of
the camera. This effect changes the position and angle from which the camera sees the component
geometry (in contrast to the first shortcut, where the visible frame moves within the camera’s
viewfinder plane). The orange icon indicates the direction of the camera. Since this shortcut moves
and rotates the camera with respect to the component geometry, the model will appear to move in
the opposite direction of the mouse.
Right-click and drag while holding the CTRL key. This shortcut moves the camera up, down, left,
and right, but keeps it facing the same direction. The camera moves with respect to the component’s
geometry, so the geometry will appear to move in the opposite direction as the camera (but the same
direction as the mouse).
Center-click and drag while holding the Alt key. This last shortcut keeps the component geometry
in the center of the camera view and dollies the camera in and out (forward and back). Unlike
zooming, it is not affected by the location of the mouse, nor does this action change the zoom angle
of the lens.
LIGHTING AND SCENE To create good lighting for this engine, we’ll
need to use several lights aimed in different
HINT
Lighting can help to illuminate regions of a directions.
The reciprocating engine model where it’s hard to tell what’s going on,
has a great geometry for putting new perspective on a results plot. These Expand the Displacement plot group under
experimenting with multiple finishing touches can cast a device in a whole Results. This plot shows the displacement of the
surfaces, deformations, and new light. different components after the engine has begun
different lighting approaches. running. If you expand the Surface 1 subnode,
For hints on creating the To experiment with the lighting and scene tools you’ll see a deformation. This deformation
image below, turn to page in COMSOL, we’ll use the Reciprocating Engine moves the visible geometry to the engine’s
29 in the Advanced Tips and model. If you have the Multibody Dynamics position at 0.16 seconds, but keeps the outline of
Tricks chapter. Module installed, this model is found under File the original position.
> Application Libraries > Multibody Dynamics
Module > Automotive and Aerospace. (If you Navigate to the View node for the Displacement
don’t have the already-solved model in your plot group. Once you’ve explored the existing
libraries, download it from File > Help > Update lights and the Hide Geometric Entities 1 node
COMSOL Application Library.) The techniques (which hides the middle engine piston), delete
shown here are applicable to any geometry, but Directional Lights 1, 2, and 3.
we’ll use the engine because it has curves, nooks,
and crannies that make the effects easy to see. If we go back to the displacement plot we’ll see
the dark engine with all the lights off, as shown
This example analyzes the multibody below. In the View node, the geometry should
dynamics of a three-cylinder engine and appear in plain gray.
the thermodynamics of the air-fuel mixture
in the cylinders. The simulation results are
used to determine the pressure variation in
the combustion chamber, rotational speed
(rpm), the motion of different components of
the assembly, and the power output from the
cylinders. The geometry contains a flywheel,
crankshaft, journal, and crank and piston for
each of the three cylinders.
Directional lights like the ones we’ve added here A headlight points from the camera position; it
are the most commonly used lights, but there is locked to the camera’s coordinate system, and
are several other types of lights available in its position and direction cannot be changed.
COMSOL. If you right-click View 2 again, you
can add a point light, a spotlight, or a headlight.
We’ll now take a look at an example of an The settings for a far-field plot in the SIW model
RF device where you might want to know its are shown below.
radiation pattern.
For this SIW, we can plot the far-field norm cells in small microfluidic systems. We’ll now
variable, emw.normEfar. The plot below is scaled demonstrate some options for postprocessing using
ACOUSTICS MODELING
up to make details more visible and depicts the Particle Tracing Module in a simulation of a
You might use a similar the far-field norm of the electric field for an static mixer.
process in an acoustic operating frequency of 12.25 GHz.
simulation, to visualize If you have the Particle Tracing Module
the acoustic pressure field installed, open the tutorial from Application
at distances far away from Libraries > Particle Tracing Module > Fluid
the object you’re modeling. Flow > laminar mixer particle. The geometry is a
The example below shows flow channel containing a series of static blades
the far-field sound pressure that are twisted in alternating directions. In this
levels around a tonpilz piezo example, the mixing performance is evaluated
transducer. Such devices by computing the trajectories of solid particles
are used, for example, in carried by water through the mixing blades.
sonar systems where high-
power, low-frequency sound We will start from some of the plots that are
generation is needed. included in this tutorial. Click on the 3D plot
group named Particle Trajectories (fpt). This
plot displays the particle trajectories up to a
Increasing the angle resolutions will give a selected time, with a color expression indicating
smoother and clearer depiction of the far-field. the shear rate at the particles’ current positions.
In the image below, a rigid translation is used
to move the waveguide down so that the entire This plot can be adjusted easily to visualize the
far-field radiation pattern is visible. particles’ progression at different times. The
sequence below shows trajectories for three
different times, t=1 s (left), t=1.6 s (center), and
t=3 s (right), with the color expression changed
to spf.U to indicate the magnitude of the particle
velocities. To control the color range manually,
expand the Range tab in the settings for the
Color Expression 1 subnode.
PARTICLE TRACING
The Particle Tracing Module is used to solve a set
of ordinary differential equations for the motion of
distinct particles. As the particles move, they can
be affected by external fields through a wide variety
of forces, such as electric, magnetic, drag, and
dielectrophoretic forces. There are many options for
including particle-boundary, particle-particle, and
particle-field interactions. The physics interfaces
are usable for a range of simulation topics, such as
ion transport in electromagnetic fields, large-scale
planetary movement, and separation of biological
The Particle Trajectories plot provides a more The main drawback of the phase portrait is that
realistic depiction of the mixing performance than it plots all particle positions in phase space at the
a streamline plot would. Streamline plots are used same time, not at the same position along the
to visualize vector quantities using curves tangent length of the mixer. A better way to evaluate the
to an instantaneous vector field. (See the Plot mixing performance at specific locations in the
Types chapter of the Essentials of Postprocessing mixer geometry is to use a Poincaré Map. This type
and Visualization in COMSOL Multiphysics of plot shows the locations where particles intersect
handbook for an introduction to streamline with one or more surfaces defined using a Cut
plots.) The Particle Tracing for Fluid Flow physics Plane data set.
interface, on the other hand, treats the particles
as distinct entities instead of a continuous field, Click on 3D Plot Group 4. In this plot we can see
and solves a distinct set of ordinary differential the particle groups on different planes in space after
equations for each particle so that it correctly mixing has begun, and can tell that they are not
accounts for the inertia of the particles. fully mixed by the time they reach the outlet. This
Poincaré Map uses planes located at 0.006, 0.016,
Another useful way to visualize how particles 0.026, 0.036, and 0.042 meters along the y-axis.
are mixed is to use a Phase Portrait plot. In a
Phase Portrait, each particle is depicted as a
colored dot at some location in a user-defined
phase space. For example, the two coordinate
axes can be two different components of the
particle position; alternatively you can plot
particle position along one axis and particle
speed along the other.
We’ll add a range to this, so that we create a Add a deformation to this line plot, with the
series of vertical cut lines in the new plane. Click x-component set to u and the y-component set
ARROW PLOTS
the Range button next to the Distances field to v (the components of the velocity field).
to open a dialogue box for the range. Enter the In the same way that an arrow
following settings: For the arrow line plot, set the data set to Cut Line surface plot uses arrows on
2D 1 and the scale factor to 0.025; the velocity field a planar surface to depict a
• Start: 0.01 should automatically be entered for the expression. vector quantity, an arrow line
• Step: 0.006 (this will create a line every plot depicts a quantity using
6 millimeters from the start point) Click Plot. Now we have a 2D cross-sectional arrows on lines.
view equivalent to the 3D plot we saw earlier.
• Stop: 0.04
The new plot group will contain surfaces from The array will initially look blurry:
the Stress (solid), Temperature (ht), Electric
Potential (ecs), and Surface Losses plot groups,
spaced 50 mm apart along the z-axis:
Also copy the surface under the Temperature (ht) There are several ways to finish the array, but
TRANSLATIONS node. After you’ve pasted it into your plot group, it is often easier to duplicate the surfaces that
do a few things before adding a new deformation: already exist in a plot group than copy and paste
You can only add a single under the Title tab set the title type to None, and everything from the other plot groups. Create
deformation to each surface under the Coloring and Style tab uncheck the two more surface plots: one showing the electric
plot. Therefore, the plot Color Legend box (this will ensure that when potential and another showing the surface losses.
containing the deformation you duplicate this surface, you won’t end up with The following table includes the expressions and
that shows displacement in multiple titles and color legends, which can really deformations we’ve used for each, but adjust the
the circuit cannot also be crowd up the Graphics window.) deformation settings to your liking:
translated in the z-direction.
Each of the other surfaces Now add a deformation to the temperature plot.
uses a deformation to In the image shown below it is shifted down by
translate them in the -50 mm in the z-direction. Set the scale factor to
z-direction. 1 and the x- and y-components to zero.
ANIMATIONS
One of the final capabilities of COMSOL that
we’ll touch on here is exporting results. This can
take the form of plots, tables, animations, and
reports. Some techniques for exporting data and
generating results are discussed in the Exporting
Results chapter in Essentials of Postprocessing
and Visualization in COMSOL Multiphysics. In
this section, we will focus on animations.
LOWER-DIMENSION POSTPROCESSING
When postprocessing a simulation that contains However, the internal surface jutting out from
thin walls modeled as surfaces or layers with an two of the walls is also considered a boundary
assigned mathematical thickness (rather than even though it does not act as a divider between
a geometric thickness), you will occasionally domains.
see different results when plotting on different
types of entities. This means it’s important to be
careful in cases that we refer to as lower-dimension
postprocessing.
TERMINOLOGY REFRESHER
First let’s do a quick refresher of some
terminology. The COMSOL software uses
the following conventions when referring to
geometric entities:
THIN LAYER ATTRIBUTES When plotting domain quantities for a thin layer,
COMSOL treats the results slightly differently
In the COMSOL software, a “thin layer” refers depending on the type of plot being used:
to a surface where physics will be solved by
mathematically accounting for the real thickness • When using a surface plot to represent
of a wall instead of meshing it. These layers are results on a boundary, the software will
treated as boundaries, while the surrounding area usually display the average of the results
or areas are treated as domains. from both domains using information
from the solver about the boundary
The benefit of using thin layer modeling— layer close to the wall, if any.
especially in multiphysics scenarios—is that it • When using a domain plot that falls on
reduces computational time by circumventing the the location of the boundary, the software
need to mesh a thin 3D layer. chooses results from one domain to
display based on the location of the plot,
Lower-dimension postprocessing is a powerful i.e., which domain it falls inside of.
tool that enables you to analyze results on one or
both sides of a thin layer and is used for modeling
The latter are treated differently because the
electrical, mechanical, fluid, and chemical
domain plot—for example, a 3D slice plot—will
applications. In this section, we’ll discuss different
by definition fall on either side of the thin layer’s
operations that can be used in COMSOL to
geometry. Even plots located “exactly” on the
correctly postprocess such scenarios and avoid
interface between two domains will fall on one
falling into traps.
side, since plotting on the exact intersection
is not numerically possible. This means that
In modeling a three-dimensional wall as a two-
domain plots will show values from one domain
dimensional layer, COMSOL treats the thin
or the other, but not a combination.
layer as a boundary that is adjacent to as many
domains as touch the wall.
The implications of this functionality are that
results may look slightly different depending on
the plot type used.
The up and down operators are available on The interior baffles, on the other hand, face
geometric entities of dimension one lower domain 2 on both sides:
ENTITY INDICES
than the model itself. For instance, in a
three-dimensional model, up(expression) and COMSOL can also plot
down(expression) can only be plotted on two- entity indices such as
dimensional entities—boundaries. domains. In the figure below,
the expression dom has been
This means, for instance, that COMSOL will plot plotted on a 3D volume,
up(spf.U) on a surface plot, but will return an showing the two different
error if the expression is attempted on a domain domains in red and blue.
plot such as a 3D slice plot, which has the same
dimension as the model.
Since the interior baffles are adjacent only But we have to be careful here. The plot showing
to domain 2, they disappear in this plot. The the temperature from domain 1 appears to
outer baffles are the only ones adjacent to both be monochromatic—this is not an error, but
domain 1 and domain 2, and so they are the occurs because the color is saturated with
only ones with data available for domain 1. values very close together, while the other plots
contain values that are much farther apart. If we
You may notice a similar effect if you plot variations disable the other plots to view the left plot alone
on side(m,expression) on 3D line plots containing (showing results from domain 1), we can see
only certain selections of the geometry’s edges— clearly that there is a gradient:
depending on which results you plot on which
edges, certain lines may disappear, or you may see
an error message when you try to plot on edges that
do not have data for that domain.
As we discussed before, the software still has you’re following along, change the x-coordinates
to choose one domain to plot in. Using style of its plane to be slightly farther than x=0.5.
inheritance will once again force a common color
range between the plots, so that we can see if the
slice plot looks different than the surface plot:
The slice plot once again matches the data from the
surface plot, but we’re now examining the other
side of the wall.
SUMMARY
We have now discussed several different uses of Also recall that unexpected discontinuities may
thin-layer modeling and distinguished between appear in a plot for several reasons when using
operators that can be used when postprocessing lower-dimension postprocessing:
results on a single side. To recap:
• The average of the temperatures from
• The up and down operators can be each side of a boundary may not
applied to show results on one side of a smoothly transition from one boundary
geometric entity, provided that the entity to the next; therefore adjacent boundaries
is of dimension one lower than the model may appear to have discontinuities
itself and has an upside/downside. between them.
• The side operator can be applied to • Since domain plots “choose” results from
entities of many dimensions lower than one side or the other to display, adjacent
that of the model. This expression plots domains may also appear to have
on entities of dimension n using results discontinuities when transitioning from
from the specified adjacent entity of one to the next if they are not showing
dimension n+1. results from the same side.
• When viewing results with a combination
of domain plots and surface plots, there
may be apparent differences between
them—since the default surface plot
shows an average, it is unlikely to have the
same values as the results shown on the
domain plot.
HEAT EXCHANGER
Model of an air-filled shell and tube heat
exchanger with water flowing in the inner
tubes. Simulation results reveal flow
velocity, temperature distribution, and
pressure within the vessel.
CONCLUDING REMARKS
This concludes our guide to the advanced
postprocessing tools in COMSOL. This was by no
means an exhaustive walk-through, nor did we
name every operation or type of plot available.
However, we hope that this guide was a good read
for you and will enable you to better comprehend,
refine, and share your results.
HELMHOLTZ COIL
Being able to easily verify, interpret, validate, Simulation results show
and implement design changes from your the uniform magnetic field
model makes the engineering process more between an identical pair of
straightforward and also more enjoyable. circular coils where current
Ultimately these tools are meant to aid you flows in the same direction
in making design decisions, showcasing your in each coil.
findings, and addressing changes to your product.
As you delve further into the flexible and powerful
postprocessing tools of COMSOL Multiphysics,
we hope you will find that your device designs,
your research, and your ability to meet customers’
needs reach new horizons.