Comsol Handbook Series
Comsol Handbook Series
Comsol Handbook Series
Essentials of Postprocessing
and Visualization in
COMSOL Multiphysics®
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 are
available here:
VIDEOS
www.comsol.com/search/?s=postprocessing&subset=video
BLOG ARTICLES
www.comsol.com/search/?s=postprocessing&subset=blog
DISCUSSION FORUM
www.comsol.com/community/forums/results-and-visualization/
ii
TABLE OF CONTENTS
INTRODUCTION 1
DATA SETS, DERIVED VALUES, AND TABLES
▪ Solutions 2
▪ Cut Points and Evaluations 3
▪ Tables 6
PLOT TYPES
▪ Choosing a Plot Type 8
▪ 3D Plots 8
▪ 2D Plots 15
▪ 1D Plots 21
USING POSTPROCESSING FOR RESULTS INTERPRETATION 24
EXPORTING RESULTS
▪ Data, Tables, and Mesh 25
▪ Reports 27
TIPS & TRICKS
▪ Shortcuts 28
▪ Rearranging the COMSOL Desktop 28
▪ Showing Meshes on Surface Plots 29
▪ Sliding and Interactive Positioning 30
CONCLUDING REMARKS 31
iii
iv
INTRODUC TION
INTRODUCTION
The orientation, coloring, and arrangement of
an object created using computer modeling can
offer perspective on the geometry, function,
and success of a product. Visualization is an
incredibly important part of the engineering
process. Visually displaying the physics in a
simulation gives an explanation of what’s really
happening inside a device or design: heat
transfer takes on colors that help us understand
its distribution, points of structural failure
become visible and obvious, and the paths fluids
travel are suddenly traceable.
HELMHOLTZ COIL
Simulation of a parallel pair of identical circular
coils spaced one radius apart and wound so that
the current flows through both coils in the same
direction. Results show the uniform magnetic field
between the coils with the primary component
parallel to the axes of the two coils.
NOTES
All the models used in this guide are available in the Model Libraries for
COMSOL® software users. If you are not currently using COMSOL, contact
us at www.comsol.com/contact. You can find more information about the
HINT physics capabilities of COMSOL at www.comsol.com/products.
One useful feature of cut points is the “Snap to closest This guide assumes that you have updated the COMSOL Model Libraries.
boundary” capability—selecting this checkbox will move This can be done from File > Help > Update COMSOL Model Library. Then
the cut point to the boundary closest to your selected click Find Models and, if you’re looking for a specific model, click Uncheck
coordinates, which is very helpful if you want to create a all on the next screen. Navigate to the model that you’re looking for (in this
cut point right on the edge of the geometry. case, it would be COMSOL Multiphysics > Structural Mechanics > Stresses in
Pulley) and click Download.
Right-click Derived Values under the Results Table 1 will now show different values for the
node to see a list of values that can be calculated. maximum displacement and stress at each rpm.
Let’s find the maximum stress on the surface of
the cross section.
The variable we just created measures the • The maximum stress and displacement
diameter at a given rpm. Note that we’ve used R in the cross section for different speeds.
and -R to account for both directions (left and • The table showing the change in
right of zero). distance between two points, created
using the global evaluation.
Now right-click Study 1 and choose Update
Solution. Because this model has already been Let’s take a quick look at the shortcuts that are
solved, we need to update the results. available for tables.
But rather than needing to compute
the study all over again, COMSOL
lets you add this component coupling,
then adjust the existing solution to
account for it. (This especially comes
in handy if you’ve forgotten to create
variables and couplings until after you
have already solved the simulation.)
Click Evaluate. Table 3 will appear, showing the Several of these buttons are self-explanatory.
deformation. The first few entries (for n less Here’s a rundown of the others:
than 2500) will be negative, indicating that the
diameter has decreased. At n=2500, the results • Settings: opens the table settings
will become positive and grow increasingly large window in the center column.
as the rpm increases. • Full Precision: displays the complete
values in the table (to all decimal places).
We’ve completed our global evaluation.
• Table Graph: creates a graph plot using
the data from the table (read more about
TABLES this below). Similarly, the Table Surface
button creates a surface plot using data
HINT Almost done! We’ve seen how to gather and from the table.
organize data from the solvers in several
You can also import tables different ways. Let’s wrap up with a few • Export: exports the table data to a text
from data files by right- comments on using tables effectively. file (.txt).
clicking the Tables node • Display: displays the next table under
under Results, choosing You’ve probably noticed by now that the the Tables node. Clicking the arrow will
Table, and then using the evaluations we performed automatically show a list of all the tables created so far,
import function available generated tables. Tables store information from allowing you to switch between them.
in the settings window to data sets and derived values. Here’s a summary
upload a text or data file. of the tables we created in the pulley model:
This is particularly useful
for comparing results • The results from Cut Point 2D 1, where
from a simulation with we plotted the stress at (19, 54) over
experimental data. different rpms.
PLOT TYPES
So we have data, and we have learned a few ways
to use and manipulate it. Now let’s move on to
the fun part: visualizing results.
In the Surface settings window, we can change There is also an option to Hide Geometric Objects, which hides objects created by a
this under the Coloring and Style tab. Using geometry feature. Hiding geometry objects only applies in certain nodes, such as the
the drop-down list, change the color table from View and Definitions nodes. Actions that hide geometric objects are not reflected
Rainbow to ThermalLight. in the Materials, Physics, Mesh and Results nodes, so Hide Geometric Entities is a
better option when you are not working in the Geometry branch of the model tree.
We can change the arrow size by changing the scale as arrows on planar surfaces or arrows on lines,
factor under the Coloring and Style tab. Check the respectively. The figure below shows arrow
Scale factor box and increase the scale factor to 0.05 lines (along with a regular line plot, deformed)
(again, this is much larger than you would use if plotted on a cut line solution.
you were trying to really visualize the physics).
Now our plot is looking pretty good. Let’s add CONTOUR PLOTS
a color range to the arrow plot so that what’s Let’s add a contour plot on the back wall of the
happening to the velocity is a little clearer. channel. Contour plots are helpful for telling
immediately if a device is approaching its limits
Right-click Arrow Volume 1 and choose Color or is in danger of failure (for instance, showing
Expression. Click Replace Expression, choose the exact temperature during a phase transition
Conjugate Heat Transfer (Laminar Flow) > or indicating that a mechanical structure is
Velocity magnitude (nitf.U), and then click Plot. approaching its yield stress level).
HINT
In a case where we only want to see one layer of arrows in the z-direction, it’s
sometimes more helpful to change the entry method. Instead of Number of
points, change this to Coordinates. This allows you to limit the points used
in the z-direction to only one point and specify its location on the z-axis. For
example, try entering 5[mm] in the coordinates field and see what happens.
Now right-click 3D Plot Group 1 and choose Keep in mind that for this plot, we have two plots
Contour. This will add a contour plot. Make sure overlapping (the original surface and the contours).
to choose Solution 2 for the data set in the plot In this case, they don’t interfere with each other
settings. because they have the same color scheme; however,
in other cases this can be a problem. (See if you can
Change the expression to T (type it into the manipulate your results so that the surface plot no
field). Click Plot. Now we have a contour plot longer contains the back wall.)
showing the wall temperature changing over the
distance of the channel. It’s a little easier to see what’s going on now;
the contour layers show the evolution of the
temperature gradient on the back wall, which
is at its hottest right next to the heat sink. The HINT
contours are very smooth already (try refining
your mesh to get the smoothest results), but let’s Try clicking anywhere
add the lines back in so that we can get a really on the surface to see a
clear idea of what the temperature gradient is. table with values showing
the temperature data at
Duplicate the contour surface you just created, the positions clicked.
and set it to display lines instead of filled levels. Alternatively, check the
Play around with the colors and settings to Level labels box in the
Instead of lines, we can also blend the contours create an image similar to the following: contour plot settings under
so that the space between each level is filled in. the Coloring and Style
Check out the options available in the Levels tab tab to see data for each
and the Coloring and Style tab in the Contour contour level.
settings window:
DIFFERING VISUALS
Your results may not look exactly like the images shown here, since we
obtained these results using a refined mesh and a high-power computer.
We’ve also added a line plot to show some of the data set edges.
REDUCING DIMENSION
In the same way that we’ll use a cut plane with the pyramidal absorber model to
create a 2D plot, it is also possible to use a cut line or cut point to create 1D plots.
These create a data set at a chosen point (over a parameter such as time) or along a
line.
ORIENTATION
A parametric extrusion
will create horizontal layers
regardless of the original
orientation of the cut plane.
PERIODIC ARRAYS Click Plot, and you’ll see that a series of slices (the
From these plots, we can see how the electric extrusion) has appeared in the Graphics window.
field changes with the elevation angle. But to see
this, we had to click Plot each time we changed On each slice, we’ll plot the electric field for a
the parameter value, and could only visualize different value of θ. Add a 3D plot group to the
one surface at a time. What if we want to create Results node and choose Parametric Extrusion
a side-by-side comparison? A periodic array 2D 1 as the data set. Then add a surface to this
offers a way to visualize results with different plot group, and click Plot (the electric field norm
parameter values. is automatically entered in the expression field).
It's crowded! To really get a feel for what’s going Adjust the y-minimum and y-maximum
on in the pyramidal unit cell, let’s go back to coordinates to be -150, 150.
Parametric Extrusion 2D 1 and reduce the
number of values we’re looking at. Add a surface to 2D Plot Group 5 and change
the data set to Cut Plane 1. For this first surface,
choose theta to be 1.22173 (70 degrees). Click
HINT Plot, and the familiar surface appears.
If you experiment with plotting a different variable and would like to return to the Duplicate Surface 1. Remove the title by setting
electric field plot, navigate to Replace Expression > Electromagnetic Waves, Frequency Title type to None under the Title tab. (This
Domain > Electric > Electric field norm (emw.normE) or simply type emw.normE into avoids titles being added for every surface
the expression field to plot it again. created in the plot group.) This time, set the
parameter value to be 0. Click Plot.
In the Parametric Extrusion 2D settings, set The second surface plotted right on top of the
the Parameter selection (theta) value to From first one, causing our earlier results to vanish.
list. Hold the CTRL key when you click to We need to add a deformation so that we can see
select multiple values. Scroll through the list these results side by side.
and choose the following values: 1.134464,
1.308997, and 1.48353 (equivalent to 65, 75, and Right-click the new surface node and choose
85 degrees, respectively). We’ll be looking at the Deformation. We want to shift the second plot
higher elevation angles, where the electric field by the width of the unit cell, which is 50mm.
changes the most. Under the Settings tab, check Change the y-component to -50, set the scale
the Level scale factor box and enter 150. factor to 1, and click Plot.
Several of the data sets use 2D revolutions This plot group shows the electric field translated
to give a better idea of what’s happening in into Cartesian coordinates (the model is created
the 3D device. Under the Data Sets node, in cylindrical coordinates). The norm is plotted
browse through the solutions. Solution 1 and on the circular revolutions we saw earlier
Revolution 2D 1 include the entire geometry. representing the antenna aperture and feed
The revolutions for Solutions 2 and 3 include openings. The arrow plots are shifted upward
only the waveguide feed and the aperture, and downward to be more visible, and show the
respectively, so their plots look like flat circles direction and strength of the electric field.
representing each opening. These will be
important later.
HINT
The figure below shows Line Graphs 1 and 2 The plot below shows Line Graphs 1 and 2,
from 1D Plot Group 1, with Line Graph 1 at a where Line Graph 1 has 12 plus-sign-shaped
width of 3 and Line Graph 2 at a line width of 2. markers and Line Graph 2 has 14 asterisk-
shaped markers.
CYCLING COLORS
The Cycle setting for line color causes the line plots to cycle through the available
colors (in this case only blue and green); this makes it easy to differentiate between
many different line plots overlaid in the same plot group.
Below are examples of a few more combinations 10*log10(emw.nPoav). This plots the near-field
for the two line graphs in this plot group, radiation pattern using a log scale.
including different colors, styles, and markers.
These use color expressions as well: Click on Polar Plot Group 5 and change
the Parameter selection (freq) field to Form
list. In the selection list, select the following
frequencies: 2e8, 5e8, 10e8, 1.3e9, 1.5e9. Use the
scroll bar and hold down the CTRL key to select
multiple values.
POLAR PLOTS
Polar plots are a specific type of 1D plot.
Polar plot groups create graphs using polar
coordinates, with radius r and angle Θ.
These are particularly useful for visualizing
electromagnetic and acoustic applications, such
as the distribution of sound emanating from a
megaphone or the range of an antenna. Polar
plots show quantities based on direction and
distance from a specific point of reference.
REFERENCE
For instructions on creating surface and line
plots, head to pages 8 in the Plot Type chapter.
EXPORTING RESULTS
One of the final capabilities of the COMSOL® Add the expressions you want, then click Export.
software that we’ll touch on here is exporting Navigate to the folder you saved the text file in,
your results. This can take the form of reports, open it, and you’ll have your data there. It’s best to
plots, tables, graphics, or even animations. view the report in a text editor:
A mesh can be exported as a new COMSOL If you only want to export the exact image
Multiphysics® software binary file, which can be shown in the Graphics window, the easiest way
then imported into other models: to do this is to click the Image Snapshot button
in the Graphics window toolbar. From there,
you can choose what to include as well as set the
size and file type:
• Zoom Box: allows you to click and • Transparency: turns the model
drag the mouse to create a rectangular geometry transparent
box, highlighting an area of the
geometry to zoom in on • Image Snapshot: opens a dialog box to
export the current view in the Graphics
• Zoom Selected: zooms in on the area of window as an image
a selected geometric component
• Print: opens a dialog box to print the
• Go to Default 3D View: orients the current view
model in the default 3D view
• XY, YZ, and ZX Views: changes the
view to the xy-, yz-, or zx-plane
Rearranging the COMSOL
Desktop® Environment
• Selection and Hiding tools: similar
to the Hide Geometric Entities The COMSOL Desktop® Environment is very
feature available for View nodes, these flexible and easy to rearrange. Plotting in
selection tools can be used to select multiple windows is done under the Window
or hide entities when in a subnode Settings tab in a plot group node. Windows can
of a Component; they create a Hide also be renamed using these settings.
Geometric Objects node, which does not
apply to the Results node
• Scene Light: turns the scene lighting
completely on or off
CONCLUDING REMARKS
We’ve covered the basics of what you need to
know to do some very savvy postprocessing,
including a few of the more advanced tricks used
to add a finishing flourish. To recap:
31
CUT POINTS AND EVALUATIONS
HEAT EXCHANGER
Model of an air-filled shell and
tube heat exchanger with water
flowing in the inner tubes. Simu-
lation results reveal flow velocity,
temperature distribution, and
pressure within the vessel.