We are often interested in modeling a radiating object, such as an antenna, in free space. We may be building this model to simulate an antenna on a satellite in deep space or, more often, an antenna mounted in an anechoic test chamber.

*An antenna in infinite free space. We only want to model a small region around the antenna.*

Such models can be built using the *Electromagnetic Waves, Frequency Domain* formulation in the RF Module or the Wave Optics Module. These modules provide similar interfaces for solving the frequency domain form of Maxwell’s equations via the finite element method. (For a description of the key differences between these modules, please see my previous blog post, titled “Computational Electromagnetics Modeling, Which Module to Use?“)

Let’s limit ourselves in this blog post to considering only 2D problems, where the electromagnetic wave is propagating in the *x-y* plane, with the electric field polarized in the *z*-direction. We will additionally assume that our modeling domain is purely vacuum, so that the frequency domain Maxwell’s equations reduce to:

\nabla \cdot \left( \mu_r^{-1} \nabla E_z \right) -k_0^2 \epsilon_r E_z= 0

where E_z is the electric field, relative permeability and permittivity \mu_r = \epsilon_r = 1 in vacuum, and k_0 is the wavenumber.

Solving the above equation via the finite element method requires that we have a finite-sized modeling domain, as well as a set of boundary conditions. We want to use boundary conditions along the outside that are transparent to any radiation. Doing so will let our truncated domain be a reasonable approximation of free space. We also want this truncated domain to be as small as possible, since keeping our model size down reduces our computational costs.

Let’s now look at two of the options available within the COMSOL Multiphysics simulation environment for truncating your modeling domain: the scattering boundary condition and the perfectly matched layer.

One of the first transparent boundary conditions formulated for wave-type problems was the Sommerfeld radiation condition, which, for 2D fields, can be written as:

\lim_{ r \to \infty} \sqrt r \left( \frac{\partial E_z}{\partial r} + i k_0 E_z \right) = 0

where r is the radial axis.

This condition is exactly non-reflecting when the boundaries of our modeling domain are infinitely far away from our source, but of course an infinitely large modeling domain is impossible. So, although we cannot apply the Sommerfeld condition exactly, we *can* apply a reasonable approximation of it.

Let’s now consider the boundary condition:

\mathbf{n} \cdot (\nabla E_z) + i k_0 E_z = 0

You can clearly see the similarities between this condition and the Sommerfeld condition. This boundary condition is more formally called the *first-order scattering boundary condition (SBC)* and is trivial to implement within COMSOL Multiphysics. In fact, it is nothing other than a Robin boundary condition with a complex-valued coefficient.

If you would like to see an example of a 2D wave equation implemented from scratch along with this boundary condition, please see the example model of diffraction patterns.

Now, there is a significant limitation to this condition. It is only non-reflecting if the incident radiation is exactly normally incident to the boundary. Any wave incident upon the SBC at a non-normal incidence will be partially reflected. The reflection coefficient for a plane wave incident upon a first-order SBC at varying incidence is plotted below.

*Reflection of a plane wave at the first-order SBC with respect to angle of incidence.*

We can observe from the above graph that as the incoming plane wave approaches grazing incidence, the wave is almost completely reflected. At a 60° incident angle, the reflection is around 10%, so we would clearly like to have a better boundary condition.

COMSOL Multiphysics also includes (as of version 4.4) the second-order SBC:

\mathbf{n} \cdot (\nabla E_z) + i k_0 E_z -\frac{i }{2 k_0} \nabla_t^2 E_z= 0

This equation adds a second term, which takes the second tangential derivative of the electric field along the boundary. This is also quite easy to implement within the COMSOL software architecture.

Let’s compare the reflection coefficient of the first- and second-order SBC:

*Reflection of a plane wave at the first- and second-order SBC with respect to angle of incidence.*

We can see that the second-order SBC is uniformly better. We can now get to a ~75° incident angle before the reflection is 10%. This is better, but still not the best we can achieve. Let’s now turn our attention away from boundary conditions and look at perfectly matched layers.

Recall that we are trying to simulate a situation such as an antenna in an anechoic test chamber, a room with pyramidal wedges of radiation absorbing material on the walls that will minimize any reflected signal. This can be our physical analogy for the perfectly matched layer (PML), which is not a boundary condition, but rather a domain that we add along the exterior of the model that should absorb all outgoing waves.

Mathematically speaking, the PML is simply a domain that has an anisotropic and complex-valued permittivity and permeability. For a sample of a complete derivation of these tensors, please see *Theory and Computation of Electromagnetic Fields*. Although PMLs are theoretically non-reflecting, they do exhibit some reflection due to the numerical discretization: the mesh. To minimize this reflection, we want to use a mesh in the PML that aligns with the anisotropy in the material properties. The appropriate PML meshes are shown below, for 2D circular and 3D spherical domains. Cartesian and spherical PMLs and their appropriate usage are also discussed within the product documentation.

*Appropriate meshes for 2D and 3D spherical PMLs.*

In COMSOL Multiphysics 5.0, these meshes can be automatically set up for 3D problems using the Physics-Controlled Meshing, as demonstrated in this video.

Let’s now look at the reflection from a PML with respect to incident angle as compared to the SBCs:

*Reflection of a plane wave at the first- and second-order SBC and the PML with respect to angle of incidence.*

We can see that the PML reflects the least amount across the widest range. There is still reflection as the wave is propagating almost exactly parallel to the boundary, but such cases are luckily rather rare in practice. An additional feature of the PML, which we will not go into detail about for now, is that it absorbs not only the propagating wave, but also any evanescent field. So, from a physical point of view, the PML truly can be thought of as a material with almost perfect absorption.

Clearly, the PML is the best of the approaches described here. However, the PML does use more memory as compared to the SBC.

So, if you are early in the modeling process and want to build a model that is a bit less computationally intensive, the second-order SBC is a good option. You can also use it in situations where you have a strong reason to believe that any reflections at the SBC won’t greatly affect the results you are interested in.

The first-order SBC is currently the default, for reasons of compatibility with previous versions of the software, but with COMSOL Multiphysics version 4.4 or greater, use the second-order SBC. We have only introduced the plane-wave form of the SBC here, but cylindrical-wave and spherical-wave (in 3D) forms of the first- and second-order SBC’s are also available. Although they do use less memory, they all exhibit more reflection as compared to the PML.

The SBC and the PMLs are appropriate conditions for open boundaries where you do not know much about the fields at the boundaries a *priori*. If, on the other hand, you want to model an open boundary where the fields are known to have a certain form, such as a boundary representing a waveguide, the Port and Lumped Port boundary conditions are more appropriate. We will discuss those conditions in an upcoming blog post.

Before you can fully benefit from a product and get the most out of it, you of course need to learn how to use it first. Without this knowledge, frustration usually follows.

Do you recall your first experience with a smartphone, for example? The technology most likely seemed foreign at the time. These days, however, most would agree that smartphones are actually rather intuitive. We’re confident you will find that this is also the case with COMSOL Multiphysics. Reading the manual and following instructions for any advanced tool is usually the best method for quickly learning how to use it.

To aid you in your simulation learning process, we have created a video tutorial that shows you the basics of setting up a model and running a simulation in COMSOL Multiphysics.

In the video, we use an electrical-thermal-structural coupling to demonstrate the concept of *multiphysics*, which is one of the large advantages for using the COMSOL software. That said, the steps for setting up a model are the same no matter what physics you are modeling. In other words, this video is beneficial for anyone interested in learning the basics of simulating with COMSOL Multiphysics.

*A screenshot of the COMSOL Multiphysics user interface. The model shown includes an electrical-thermal-structural coupling, with Joule heating and thermal expansion.*

My colleague, Amelia Halliday, will begin by presenting the screen you see when you first open COMSOL Multiphysics. She will then continue through the process of creating and running a simulation to investigate the electrical and thermal properties of a thermal actuator. After running a successful simulation, she will continue to add complexity by including thermal expansion. At the end of the video, you will have a basic understanding of how to create and run your own simulations. Links below the video will allow you to jump back to certain modeling steps in order to review them again.

Do not be deterred if this is not your application area; the process for creating a model is the same no matter the physics being modeled.

You will always follow the same workflow when using COMSOL Multiphysics:

- Set up the model environment
- Create geometrical objects
- Specify material properties
- Define physics boundary conditions
- Create the mesh
- Run the simulation
- Postprocess the results

- After watching the full video, get more modeling tips from the “How To” section of our Video Gallery
- If you have any questions while using COMSOL Multiphysics, please contact support

There are many situations in which a rotating object is exposed to loads. For example, think of a rotisserie chicken or a kebab. Meat on a rotating spit is exposed to a heat load, usually a radiative heat source such as coals. Rotation is a simple way to distribute the applied heat. It keeps any regions from getting too hot or too cold and is an easy way to promote uniform cooking.

Now that I’ve got you licking your chops, let’s look at a slightly simpler case.

Today, we will look at the laser heating of a spinning silicon wafer. Although it isn’t quite as delicious to think about as rotating food, I’m sure you will find it equally informative.

As you may know, we already have an example of this in our Model Library and online Model Gallery. The existing example considers a wafer mounted on a rotating stage and heated by a laser traversing back and forth over the surface. The problem is solved in a stationary coordinate system. (Just think of yourself standing outside the process chamber and watching the wafer spinning on the stage.) We will call this the *global coordinate system*.

The laser is modeled as a heat source that moves back and forth along the global *x*-axis, while the wafer rotates about the global *z*-axis. The rotation of the wafer is modeled via the *Translational Motion* feature within the *Heat Transfer in Solids* physics interface, which adds a convective term to the governing transient heat transfer equation:

\rho C_p \frac{\partial T} {\partial t} -\nabla \cdot ( k \nabla T) = -\rho C_p \mathbf{u} \cdot \nabla T

The right-hand side of the above equation accounts for the rotation of the wafer as \mathbf{u}, the velocity vector. This velocity vector can be interpreted as material entering and leaving each element in the finite element mesh — that is, we are solving a problem on an Eulerian frame. Since the geometry is a uniform disk and the applied velocity vector describes a rotation about the axis of the disk, this is a valid approach.

The drawback, however, is when you want to add more physics to the model. The Translational Motion feature is only available within the Heat Transfer physics and for many other physics interfaces that we do not want to solve on an Eulerian frame.

Instead of solving this problem on an Eulerian frame in the global coordinate system, we can solve this problem on a Lagrangian frame, with a rotating coordinate system that moves with the material rotation of the wafer. (Think of yourself as a tiny person standing on the surface of the wafer. The surroundings will appear to be rotating, whereas the wafer will appear stationary.)

The right-hand side of the above governing heat transfer equation becomes zero, but we now need to consider a heat load that not only moves back and forth along the global *x*-axis but also rotates around the *z*-axis of our rotating coordinate system. Although this may sound complicated, it is quite straightforward to implement.

*An observer in the global coordinate system sees a spinning wafer with a laser heat source traversing back and forth along the *x*-axis (left). An observer in a coordinate system rotating with the wafer sees the wafer as stationary, but the heat source moves in a complicated path in the *x*-*y* plane (right.)*

The *General Extrusion* operators provide a mechanism for transforming fields from one coordinate system to another. Some applications that we have already written about include submodeling, coupling different physics interfaces, and evaluating results at a moving point.

Here, we will use the General Extrusion operators to apply a rotational transformation to the applied loads. Our loads are applied in the rotating coordinate system via a coordinate transform from the global coordinate system given by the rotation matrix:

\left\{ \begin{array}{c} x' \\ y' \\ z' \end{array} \right\} = \left[ \begin{array}{ccc} cos \theta & -sin \theta & 0 \\ sin \theta & cos \theta & 0 \\ 0 & 0 & 1 \\ \end{array} \right] \left\{ \begin{array}{c} x \\ y \\ z \end{array} \right\}

We can start with the existing Laser Heating of a Silicon Wafer example and simply remove the existing Translational Motion feature. We then have to add a General Extrusion operator, which implements the above transformation, as shown in the screenshot below. We will also want to implement a second operator that applies the reverse transform, which is done by switching the sign of the rotation.

*The general extrusion operation applies a rotational transform.*

The applied heat load is described via a user-defined function, hf(x,y,t), that describes how the laser heat load moves back and forth along the *x*-axis in the global coordinate system. This moving load is then transformed into the rotating coordinate system via the General Extrusion operator, as shown in the screenshot below.

*The applied heat load in the rotating coordinate system, defined via the global coordinate system and the rotational transform.*

That’s it — you can solve the model just as before.

The results will now be with respect to the rotating coordinate system. It can be more practical for us to plot the temperature solution with respect to the global coordinate system by using the General Extrusion operator that applies the *reverse* transformation. This will give us a visualization of the temperature field as if we were standing outside of the process chamber and were watching the spinning wafer with a thermal camera.

*The second general extrusion operator is used to rotate the results back to the global coordinate system.*

The results of the simulation of the temperature field over time will be identical regardless of whether you use the Translational Motion feature or the General Extrusion operator. Although the General Extrusion operator requires more effort to implement — and does take a bit longer to solve — it is needed if you are interested in more than just the thermal solution.

For example, if you also need to compute a temperature-driven chemical diffusion and reaction process or the evolution of thermal stresses during the wafer heating, these problems should be solved on a coordinate system that rotates with the wafer.

There are of course many other applications where you could use the General Extrusion operator, but I hope I’ve satisfied your appetite for today!

]]>

Recall that in the previous entry, we studied a simple example of 1D heat transfer at steady state with no heat source, where the temperature T is a function of the position x in the domain defined by the interval 1\le x\le 5.

The weak formulation turns the differential equation for the heat transfer physics into an integral equation, with a test function \tilde{T}(x) as a localized sampling function within the integrand to clamp down the solution. Integrating the weak form by parts provides the numerical benefit of reduced differentiation order. It also provides a natural way to specify boundary conditions in terms of the heat flux. For fixed boundary conditions, in terms of the temperature, the weak formulation uses the same mechanism of test functions and its natural boundary conditions to construct additional terms in the equation system.

In the end, we arrived at an exemplary equation that looks like this:

(1)

\int_1^5 \partial_x T(x) \partial_x \tilde{T}(x) \,dx = -2 \tilde{T}_1 -\lambda_2 \tilde{T}_2 -\tilde{\lambda}_2 (T_2-9)

Here, the integrand on the left-hand side involves only the first derivative of the temperature, the first term on the right-hand side defines that the outgoing flux should be 2 at the left boundary (x=1), and the other two terms on the right-hand side together specify that the temperature should be 9 at the right boundary (x=5).

To implement Eq. (1) in COMSOL Multiphysics, we use the Model Wizard to create a new 1D model with a *Weak Form PDE (w)* interface (under *Mathematics > PDE Interfaces*) and a *Stationary* study. The dependent variable can be set to `T`

to match the notation in our equation. For the geometry, we make an *Interval* between 1 and 5. The weak expression under the default “Weak Form PDE 1″ node reads: `-test(Tx)*Tx+1[m^-2]*test(T)`

, where the first term corresponds to the integrand in our Eq. (1) and the second term corresponds to a heat source, which is not in our simple example and should be removed from the input field.

The weak expression now reads: `-test(Tx)*Tx`

, where `Tx`

is the COMSOL Multiphysics notation for \partial_x T(x), the first derivative of the temperature, and `test(Tx)`

is the first derivative of the test function \partial_x \tilde{T}(x). The negative sign comes from the convention that the input field assumes that the expression is on the right-hand side of the equal sign (as seen in the “Equation” section of the settings window), while the integral in our equation is on the left-hand side.

To implement the weak form terms on the right-hand side of Eq. (1) for the boundary conditions, right-click the *Weak Form PDE (w)* node. We see that there are built-in boundary features such as the *Dirichlet Boundary Condition* item, which is available in the pop-up menu for your convenience. However, since here we are interested in entering the equation ourselves, we hover the mouse over the item *More* in the pop-up menu and click on the item *Weak Contribution* in the next pop-up menu.

In the settings window for the “Weak Contribution 1″ node under *Boundary Selection*, we select boundary 1 at the left end of the domain (at x=1). We then enter the weak expression as: `-2*test(T)`

under the section *Weak Contribution* in the same settings window. This takes care of the first term on the right-hand side of Eq. (1), which specifies the outgoing flux to be 2 at the boundary x=1.

For the fixed boundary condition at x=5, where the last two terms on the right-hand side of Eq. (1) together specify that T=9, we create another “Weak Contribution” node at boundary 2 at the right end of the domain and an *Auxiliary Dependent Variable* subnode under it.

We enter `lambda2`

for the *Field variable* name in the subnode and then enter the weak expression as the two terms in Eq. (1): `-lambda2*test(T)-test(lambda2)*(T-9)`

The COMSOL software discretizes the domain by creating a mesh. Let’s right-click the *Mesh 1* node and select *Edge* and then right-click *Edge 1* and select *Distribution*. Then, we set the “Number of elements” to 4 and click *Build All*. We intentionally keep the number of elements small to make it easier when we discuss the discretization in more detail later.

Also, under the *Discretization* section in the settings window for the *Weak Form PDE (w)* interface node, we set the “Element order” to Linear (click on the *Show* button under Model Builder and then the item *Discretization* in the pop-up menu to enable the *Discretization* section):

Now we are ready to click *Compute* and check whether the solution makes sense.

The solution gives a straight line within the domain, which is consistent with the temperature profile at steady state with no heat source. The slope of the line is 2, which is consistent with the boundary condition that the outgoing flux is 2 at x=1. The temperature is 9 at x=5, as specified by the fixed boundary condition. Since there is no heat source, the total heat flux going out of the domain should sum up to zero in the steady state. Thus, the outgoing flux should be -2 at x=5.

We readily verify this by making a point evaluation of the heat flux variable `lambda2`

, as shown in the screenshot below:

Some readers may wonder whether it is always necessary to solve for the auxiliary variable `lambda2`

, the so-called *Lagrange multiplier*, especially if it is not needed by the modeler and solving for it inevitably requires more computation. As we will see in the following posts, COMSOL Multiphysics provides alternative features and allows the user to decide whether or not to solve for the Lagrange multiplier.

Today, we refreshed the concept of the weak formulation and implemented an exemplary weak form equation (1) in COMSOL Multiphysics. The resulting numerical solution behaves as expected from simple physical arguments.

In future blog posts, we will take a look “under the hood” to see how the weak form equations, such as Eq. (1), are discretized and solved numerically. We will see how the same problem can be solved in different ways and how different boundary conditions can be set up for different types of problems.

Stay tuned!

]]>

Streamline plots show curves that are tangent everywhere to an instantaneous vector field. For this reason, they are often used to visualize fluid flow. While they are best known for their wavy shapes, significant care and intention can go into the creation of good streamline plots. We’ll return to a familiar model for this demonstration: the Flow in a Pipe Elbow model. This model is suitable for a demonstration because it can be applied to a range of more complicated devices and processes such as mixers, entire pipe networks, water filtration, and the cooling of electronics.

If you’d like to follow along and have the CFD Module installed, the pipe elbow model can be found under File > Model Libraries > CFD Module > Single-Phase Benchmarks. This model simulates the flow of water at 90°C through a 90-degree bend. Because of the pipe diameter and the high Reynolds number, a turbulence model is used in the simulation.

In the solved model, there is an existing 3D plot group called *Pressure* (*spf2*) that already contains a streamline plot. Let’s take a look:

Only half of the symmetric pipe geometry is modeled, with the inlet at the bottom and the outlet at the top right in this view. The streamlines in this plot group show the instantaneous fluid velocity as water flows toward, through, and away from the bend. We can see a fully developed turbulent flow profile at first; then, a separation zone and turbulent vortices appear after the bend. The color expression in the streamline plot indicates fluid velocity (in m/s).

There are several different ways to arrange streamline plots. In the settings window, the Streamline Positioning tab contains different options for the position. We’ll touch on just a few of them.

In the figure previously shown, the positioning is set to *On selected boundaries*, meaning that a single boundary has been selected for the curves to start at — in this case, the inlet of the pipe — and the user specifies how many streamlines to plot. Currently, there are twenty individual curves released that begin at this boundary, as specified in the *Number* field:

Some of the other positioning tools have slightly different effects. I’ll now set the positioning to *Uniform density*. With this option, the user controls the distance between each curve rather than specifying the number of lines.

This is also where, if you’re not careful, you might end up with a very dense array of streamlines, which can take some time to compute the postprocessing:

The presentation of the streamline density can be adjusted using the tube settings under the Coloring and Style tab. We can either shrink the tube radius (currently set to 0.001 m) or choose a different line style from the *Line type* drop-down list.

For a case like the dense uniformity shown in the previous figure, the line style will show the plot more clearly than the tubes with the radius shown above:

The ribbon style shows the streamlines as flat ribbons. Like the tube style, these are controlled by a user-defined width and scale factor. Both styles share the risk of the same density issue if they are packed together too tightly. For the figure below, I increased the separating distance from 0.01 to 0.02, thereby decreasing the number of ribbon streamlines plotted:

One nice trick you can do with the ribbons, especially for RANS CFD applications, is to set the ribbon width to a variable. I have set the width expression (scaled down) to *k2*, representing the turbulent kinetic energy.

This can be used to help identify vortices in the flow. Below, we can see that the ribbons are much thinner before the bend. They thicken near the bottom of the pipe after the elbow, where the turbulent kinetic energy has increased:

We’ve now seen a few different ways to shape the streamlines, but what are they really representing? Often, one of the best uses for streamlines is to depict the flow velocity as fluid moves through a domain — in this case, the pipe bend. Each of the earlier examples shows a plot that, by default, contains a color expression. Disabling this color expression from the streamline plot will show a very different look. The result is still useful as it shows the turbulent flow in the pipe, but it doesn’t provide the same information (and this is why coloring is so significant):

Let’s take a look at the Color Expression settings. Like most plots, the color expression will be based on a variable of your choice. The variable you choose depends on your application. For this model, it’s important to know the velocity and fluid pressure of the water. I’ll set the expression to show pressure:

Below, you can see how the coloring looks different than it did earlier when it was set to show velocity. This image also shows the extent of the pressure drop brought on by the fluid being forced through a 90-degree bend:

There you have it. We have provided you with a brief example of how streamline plots can be particularly helpful in depicting fluid flow — which could mean air, water, or a chemical mixture — through any domain. I hope you’ll have the opportunity to apply this technique in your future postprocessing efforts.

- Download the Flow in a Pipe Elbow model
- Read the previous blog entry in this postprocessing series

Any field variable *u = u(x,y,z)* in a 3D model could have a different maximum value in various *xy* planes, i.e., *(u _{max})_{i}* at

*A schematic showing different field maximum values on parallel sections.*

The first approach would be to use the built-in postprocessing features such as the Cut Plane data set and the Surface Maximum feature. You could create a Cut Plane data set at a particular *z*-location. The maximum value of any variable at this plane can be evaluated using the Surface Maximum feature (under Derived Values > Maximum > Surface Maximum). With this approach, the cross-sectional maximum can be evaluated at a single *z*-location. This procedure must be repeated for different axial locations to obtain maximum values at each of these cross sections.

The manual procedure outlined in the above section can be automated using LiveLink™ *for* MATLAB® through a simple ‘for’ loop. The built-in wrapper function ‘mphmax’ enables the maximum calculation for a Cut Plane data set. Here is the sample code for evaluating the maximum cross-sectional values (*u _{max}* vector with ‘n’ values) for

z = [z1 z2 z3 zn]; for i = 1:length(z) model.result.dataset('cpl1').set('quickz', z(i)); umax(i) = mphmax(model,'u',2,'dataset','cpl1'); end plot(z, umax)

The Parametric Sweep or Auxiliary Sweep features are available to run COMSOL Multiphysics models for multiple values of any given parameter (used for defining geometry, mesh, and physics settings). Because these sweep features are essentially a ‘for’ loop, we can even utilize the features for a postprocessing analysis such as this.

Let’s look at the various steps needed to create the cross-sectional maximum value plot for the velocity magnitude in the Laminar Static Mixer model. The slice plot below shows the velocity field magnitude at various *z*-locations. Our objective is to obtain the maximum velocity magnitude on each of these slices (cross sections) and plot these slice maximums with respect to the *z*-coordinate.

*Velocity slice plot for the Laminar Static Mixer model.*

The first step is to add a parameter corresponding to the axial coordinate. For this example model, we add a parameter *zp*, as shown in the screenshot below.

*Adding a parameter in the Parameters table.*

Next, we need to add a second study (with a stationary step) to run the Auxiliary/Parametric sweep with respect to the parameter *zp*. The sole purpose of using the second study step is to restructure the available solution data in order to achieve our postprocessing objective. Therefore, in this step, we do not solve for any physics interfaces and simply pass along the solution from Study 1 to this study.

Using the Stationary step settings mentioned above (and also noted in the snapshot below), we then need to compute the second study step.

*Stationary step settings for running the Auxiliary Sweep feature without solving for physics interfaces.*

We now need to add a Parameterized Surface data set (right-click on *Data Sets* under the Results node and select “Parameterized Surface” from the More Data Sets submenu). In the Parameterized Surface settings, we will use Study 2/Solution 1 as the data set and parameter *zp* as the *z*-coordinate expression. This is illustrated in the image below.

*Settings for creating the Parameterized Surface data set.*

In the next step, we need to add a Surface Maximum node to the model (right-click on *Derived Values* under the Results node and choose “Surface Maximum” from the Maximum submenu). We utilize the Parameterized Surface as the data set for evaluating the Surface Maximum, as shown in the Surface Maximum settings below. Now, click on *Evaluate* to create a table with plane maximum values (velocity magnitude) for each of the *z*-coordinate values.

*Settings for evaluating the Surface Maximum using the Parameterized Surface data set.*

Lastly, we can click on the *Table Graph* button (shown in the figure below) to plot the table data. The 1D plot indicates the maximum velocity field magnitude plotted versus the *z*-coordinate location.

*1D plot showing the cross-sectional maximum values for the velocity field magnitude at different *z*-coordinates.*

This post demonstrates a very simple — yet powerful — postprocessing trick for automating the maximum (or the minimum, average, or integration) calculation for any variable on parallel planes. The key concept we have highlighted here is how to use the sweep functionality within COMSOL Multiphysics to restructure the available solution data for postprocessing purposes. We have also presented a scripting solution using LiveLink™ *for* MATLAB® that would require only a few lines of code in order to complete this postprocessing task.

Stay tuned for the next entry in this blog series for additional tips and tricks!

*MATLAB is a registered trademark of The MathWorks, Inc. All other trademarks are the property of their respective owners. For a list of such trademark owners, see http://www.comsol.com/tm. COMSOL AB and its subsidiaries and products are not affiliated with, endorsed by, sponsored by, or supported by these trademark owners.*

Here’s a question for all you electromagnetics-focused simulation engineers out there: Have you ever looked in envy at your structural, fluid, and chemical counterparts as they mesh their models with the click of a button, while you struggle to mesh your infinite elements or perfectly matched layers? Well, now you too can enjoy automatic meshing with a click (or two). Let me show you how.

Measuring the electromagnetic phenomena around an object is common practice that necessitates the creation of a boundary to enclose an air domain around your geometry. In theory, we should include large domains (technically infinite) in our model, but we do not, for obvious reasons.

In COMSOL Multiphysics, this problem is resolved by adding infinite element and perfectly matched layer (PML) domains, which take the place of these large open boundaries. Infinite element domains allow for the modeling of unbounded domains. Perfectly matched layers absorb all of the waves that enter the domain, preventing waves from reflecting off the boundaries.

For a more detailed description of these features, see page 300 of the COMSOL Reference Manual found in the documentation.

Meshing these virtual domains to provide correct results is a time-consuming process when done manually. However, with version 5.0, COMSOL Multiphysics will mesh the domains for you with a Physics-Controlled Mesh option.

*Image and model created by my colleague Jiyoun Munn. With all the time he saved by auto meshing his PMLs, he created this awesome image.*

Meshing infinite element domains is now simply a two-click process. In fact, I can sum up the process of using this feature in one image:

*Enable automatic meshing from the settings window of the physics interface node (e.g., Magnetic Fields, Electric Currents, etc.).*

After enabling the Physics-Controlled Mesh feature and clicking the mesh button, COMSOL Multiphysics will mesh the infinite element domains with a Swept mesh (and the rest of the domains accordingly). That is all.

Of course, there are always those of you who like to have a hand in everything — you know who you are. As is the case with most all COMSOL Multiphysics features, you are still free to inspect the mesh sequence and make edits to your liking.

The video below shows the short process of implementing and using the Physics-Controlled Mesh for infinite elements, as well as how to inspect and edit it.

If Electromagnetic Waves, Frequency Domain Simulations are more your speed, we’ve got you covered too. This process is ever so slightly more complicated. It involves a click of the check box and a specification of the maximum element size. When meshing Electromagnetic Waves, Frequency Domain, the maximum element size must be at most 20% of the wavelength. Dividing your wavelength parameter by 5 is a good practice. Alternatively, you can enter the numerical value instead.

*Enable automatic meshing and specify the maximum element size (based on the wavelength) through dividing it by 5.*

The rest of the process is the same as for infinite elements. Check out the video below to see the full process for the automatic meshing of perfectly matched layers and how to inspect and edit the mesh sequence.

For any COMSOL simulation software users who have models with infinite elements or perfectly matched layers, this simple feature will literally transform your modeling experience by eliminating the arduous task of manually meshing these domains.

If you haven’t already… Download version 5.0 today and get started with automatic meshing for your electromagnetic simulations.

]]>

*Contour plots* are suited to show scalar quantities on a boundary of your model.

Let’s take a look at a structural mechanics example: the Stresses in a Pulley model, which involves stress in a driving pulley that’s caused by loading from the driving belt.

If you want to follow along, this model can also be found under Model Libraries > COMSOL Multiphysics > Structural Mechanics > stresses in pulley.

This particular model examines the pulley at a “frozen” moment in time (a technique known as *kinetostatic analysis*) and evaluates the stress and deformation at different RPMs. The solved model already has a contour plot in the results (2D Plot Group 2), where the contours show the von Mises stress at different locations in the pulley.

As seen in the image below, each contour level indicates a surface where the stress is at a constant level (specified by the color legend):

We can see that the stress is highest in the areas of the pulley that connect the inner region to the outer circle.

Let’s take a look at the contour plot’s settings window.

The Levels tab contains options that control the number of surfaces (levels) depicted in the plot. Adding more levels gives finer control over the surfaces and is useful in cases where you need higher precision.

The image below shows the contour plot with 40 levels instead of 10:

Now we’ll change the contour type (under the Coloring and Style tab) to *Lines* and use 20 levels. Instead of showing surfaces, it will now show only lines that separate each region. This can make it easier to distinguish the colors when using many levels, instead of only a few.

One benefit of using this type of plot in a structural mechanics case is that if the maximum allowable stress is known, then contours can immediately indicate if the threshold has been exceeded. For contour lines, there is a *Level labels* checkbox that appears in the settings:

If we select this, markers will appear on the plot that show which stress values correspond to which line. This conveniently offers a quick view of the values (though, of course, further evaluation is needed if contours indicate stresses close to the maximum):

In order to visualize filled surfaces along with the stress level labels, we can simply include two contour plots: one with the labeled lines and one with filled surfaces. Plotting these together shows the boundaries of each region as a line, along with the stress surfaces for each:

There you have it. Although we’ve explored these contour types using a structural mechanics example, these techniques are applicable to many applications. Next, we’ll take a look at the three-dimensional cousin of contour plots — *isosurfaces* — using an acoustics example.

Isosurfaces, like contours, show surfaces where a quantity is constant throughout a region. However, they are not interchangeable. Isosurfaces are helpful for a variety of applications, as well. A classic example is showing the sound pressure levels in an acoustic device.

For instance, below is an isosurface plot from the Loudspeaker Driver in a Vented Enclosure model that displays the acoustic pressure in a vented loudspeaker enclosure. Again, the color legend indicates the value of the quantity on each surface, rather than showing a gradient.

In COMSOL Multiphysics, this model is available under File > Model Libraries > Acoustics Module > Electroacoustic Transducers > vented loudspeaker enclosure, if you have the Acoustics Module installed.

Note that in COMSOL Multiphysics version 5.0, a new color table named *Spectrum* shows colors in a slightly different range than the *Rainbow* option:

For an acoustics model like this, the settings allow us to choose the specific parameter value (frequency, in Hz) to display the isosurfaces. The image above shows acoustic pressure in the loudspeaker enclosure for a frequency of 1651.6 Hz. When the frequency is set to 1919.3 Hz, the plot looks rather different:

As with contour plots, we can specify the number of levels in the plot settings. One advantage that we don’t see with contour plots, however, is the *interactive positioning tool*:

This allows us to shift all of the surfaces together by a certain factor and see live updates in the Graphics window — try it out yourself. The figures below show the isosurfaces shifted by -10 (left) and 10 (right).

That’s it for this introduction. Hopefully this has given you a good starting point for working with isosurface and contour plots. Next time, we’ll continue exploring plot types by using streamlines to depict fluid flow.

- Download the Stresses in a Pulley model
- Download the Loudspeaker Driver in a Vented Enclosure model
- Read the previous installment of the postprocessing series: Using Slice Plots to Show Results on Cross-Sectional Surfaces

Importing meshes into COMSOL Multiphysics is often necessary when interfacing between different programs. With COMSOL Multiphysics version 5.0, these meshes can be converted into solid geometry objects for further investigation and modeling capabilities. You can also perform boolean operations on the new geometry for CFD, electromagetics, and acoustics applications.

There are multiple options for importing meshes into COMSOL Multiphysics software for users that interface with specialized mesh programs. The mesh formats supported by COMSOL software include NASTRAN® Bulk Data, VRML v1, and STL. Building upon this practice, users of COMSOL Multiphysics version 5.0 now have the option to do more with these imported meshes.

The Create Geometry from Mesh feature adds an additional Component to your model with the geometry included, created from the imported mesh. With this new feature, you can create a surrounding domain around this geometry, as shown in the video further down the page. After creating this separate domain, perform boolean operations such as Difference, Intersection, and Union. If the original geometry is to be meshed as well, the new Copy feature for meshes comes in handy. No need to re-mesh the original geometry — simply copy the mesh from the original Component into the new one.

Note that, for the time being, this can only be done when there are no intersections between the geometry objects.

There are a few applications that come to mind when introducing this modeling technique. The surrounding domain could be the fluid surrounding a solid object or the air surrounding an electromagnetic or acoustics device. For the electromagetic and acoustic examples, this comes in handy when using Infinite Elements (AC/DC Module) and Perfectly Matched Layers (RF, Wave Optics, Acoustics Modules). When modeling these applications, there needs to be a domain between the geometry and the Infinite Elements/Perfectly Matched Layer domains.

Here is a short list of the possible applications and associated physical phenomena involved:

- CFD — Fluid-structure interactions
- Electromagnetics — E-field and B-field in the surrounding media
- Acoustics — Sound pressure level and acoustic pressure field in the surrounding media
- Your own application

*In this video, we will show you how to create a geometry from an imported mesh.
So, let’s get started. Here, we have COMSOL Multiphysics open and our mesh already imported, which we want to finalize. And then we go under the* Mesh

Now, we are going to create a block, which will completely surround our imported mesh geometry, as well as lie within the center of the block. Click “Build Selected”, and you’ll see our block has been generated.

*Now, if we turn on the Transparency, we can see our imported mesh geometry lying within the center of the block. And what we’re going to do is subtract this imported mesh geometry from the geometry of the block. To do this, we go back again to the* Geometry *ribbon, and under Booleans and Partitions select “Difference”. Click the block as the object to add and the imported mesh geometry as the object to subtract. Click “Build Selected” and our new geometry has been created.*

*Now, we can go to the* Mesh *ribbon, and selecting “Mesh 2″, we can now click “Build Mesh” to generate the mesh. So, here, the meshing for our finalized geometry has been created.*

*Now, let’s go under the* Results *ribbon and create a Mesh data set for the second mesh. Change the label to reflect the mesh being used, which is Mesh 2, as well as the mesh selected. Now we can turn off the Transparency, and create a 3D Plot Group, which will house our Mesh plot for the second mesh. So, again, we change the label to reflect the mesh being shown, the Level to Volume, the Element color to Gray, and then we enable an Element Filter, to show the elements located in the *x*-direction at a position greater than 25. Now we can click “Plot”, and we can see that we’ve successfully subtracted our imported mesh geometry from the geometry of the block.*

*This concludes our tutorial on how to create a geometry from an imported mesh.*

For many of the different types of physics simulated with COMSOL Multiphysics, a weak formulation, or weak form, is used behind the scenes to construct the mathematical model. Understanding the weak form will help us gain insight into how the COMSOL software works internally as well as enable us to write our own equations when there is no built-in interface available for the particular physics involved in our model.

You may also be interested in reading my colleague Bettina Schieche’s blog post “The Strength of the Weak Form“.

Let’s consider a concrete example of 1D heat transfer at steady state with no heat source. Specifically, we are interested in the temperature, T, as a function of the position x in the domain defined by the interval $1\le x\le 5$. For simplicity, we assume the heat conductivity is unity. Then, the heat flux, q, in the positive *x*-direction is given by the gradient of the temperature T:

(1)

q(x)=-\partial_x T(x)

and the conservation of the heat flux (with no heat source in the domain) simply says

(2)

\partial_x q(x)=0

This is the main equation that we want to solve. Its solution will give us the temperature profile within the domain. Equations of this form appear in many different disciplines. For example, in electrostatics, T is replaced by the electric potential and q by the electric field, while in elasticity, T becomes the displacement and q becomes the stress.

Here, we start to see why COMSOL Multiphysics can solve coupled multiphysics problems in a breeze: No matter what physical mechanisms are involved, they are modeled by equations and once the equations are written down, they can be discretized and solved straightforwardly by the core algorithms of the COMSOL software.

Some readers may ask why we chose this seemingly too simple of an example, whose analytical solution can be easily obtained by very simple math or physical arguments. The reason is two-fold:

- We want to focus on the central idea of the weak form and not be distracted by the math of a complicated physical system.
- In subsequent posts, we will expand the example to more than one domain to demonstrate the coupling between two equation systems through their boundary conditions. Starting with a more complicated example now will almost certainly obscure the central theme later when the example is expanded.

Equation (2) involves the first derivative of the heat flux, q, or the second derivative of the temperature, T, which may cause numerical issues in practical situations where the differentiability of the temperature profile may be limited. For example, at a boundary where the adjacent materials have different values of thermal conductivity, the first derivative of the temperature T becomes discontinuous and the second derivative of T can not be evaluated numerically. The main idea of the weak form is to turn the differential equation into an integral equation, so as to lessen the burden on the numerical algorithm in evaluating derivatives.

To turn the differential equation (2) into an integral equation, a naive first approach may be to integrate it over the entire domain $1\le x\le 5$:

\int_1^5 \partial_x q(x) \,dx = 0

This asks that the *average value* of $\partial_x q(x)$ in the entire domain is zero. Indeed, it seems “too weak” as compared to the original differential equation, which asks that $\partial_x q(x)$ should be zero everywhere in the interval $1\le x\le 5$. To improve upon it, we can ask instead that the average value of $\partial_x q(x)$ in a very narrow domain is zero, say,

\int_{3.49}^{3.51} \partial_x q(x) \,dx = 0

The integral only involves the value of $\partial_x q(x)$ in the vicinity of x=3.5. Thus, the relation above requires it not to be too far away from zero: $\partial_x q(3.5) \approx 0$. Extending the same idea to all locations in the entire domain $1\le x\le 5$, we see that the original differential equation may be approximated by a set of integral equations, like this:

(3)

\int_1^{1.01} \partial_x q(x) \,dx = 0 \mbox{ , }\int_{1.01}^{1.02} \partial_x q(x) \,dx = 0 \mbox{ , }\int_{1.02}^{1.03} \partial_x q(x) \,dx = 0 \mbox{ , . . . }

The higher the number of integral equations in the set, the better the approximation. In the limit of the infinite number of such integral equations, we recover the original differential equation. It is cumbersome or even impossible to write out all the integral equations in the set, but we can apply the same idea in a different way.

The main idea is to sample the value of $\partial_x q(x)$ in a narrow range. This is done by integrating it over a narrow range in Eq. (3) above. The same kind of sampling can be done by multiplying the integrand by a weight function \tilde{T}(x) that is non-trivial only in a narrow range, as shown pictorially below:

Then, we can integrate the product $\partial_x q(x)\tilde{T}(x)$ over the entire domain $1\le x\le 5$ for a variety of weight functions \tilde{T}(x). Each weight function limits the contribution of the integrand to a narrow range centered around a different x value, thus achieving the same effect as the collection of integral equations in Eq. (3). This leads us to the weak formulation, which states that the relation

(4)

\int_1^5 \partial_x q(x) \tilde{T}(x) \,dx = 0

should hold for a set of weight functions \tilde{T}(x), commonly called *test functions*. For every value of x, say x=3.5, we can choose a test function \tilde{T}(x) that is a narrow weight function centered around x=3.5. Plugging this test function into Eq. (4) would sample the value of $\partial_x q(x)$ in the vicinity of x=3.5 and so require it not to be too far away from zero: $\partial_x q(3.5) \approx 0$.

By plugging a large number of narrow weight functions as test functions into Eq. (4), each centered at a different location in the interval $1\le x\le 5$, the value of the function $\partial_x q(x)$ will be clamped down to zero everywhere within the domain.

Footnote: In the picture above, we intentionally plotted $\partial_x q(x)$ as an arbitrary curve, not the final solution to the equation, to emphasize the fact that we haven’t found the solution yet. Later on in the solution process, this arbitrary curve will be pushed up and down by a collection of test functions to reach the shape of the final solution.

Note that the order of differentiation in the integrand of Eq. (4) is still the same as in Eq. (2) (after all, it’s the same function $\partial_x q(x)$), but it can be reduced using the method of integration by parts:

(5)

q(x=5) \tilde{T}(x=5)-q(x=1) \tilde{T}(x=1)-\int_1^5 q(x) \partial_x \tilde{T}(x) \,dx = 0

Now, there is no derivative of the heat flow, q, in the equation, or in terms of the temperature, T, the order of differentiation is reduced from two to one. What about the first derivative of the test function \tilde{T}(x), which just now appeared in the equation?

As we have seen in the previous section, the test function serves as a tool for us to find the solution to the equation. Thus, we have the freedom to choose any conveniently differentiable form for it.

The first two terms of Eq. (5) involve the heat flux and test function at the domain boundaries x=1 and x=5, with the heat flux, q, defined in the positive *x*-direction. We can rewrite them in terms of the flux going out of the domain and move them to the right-hand side:

(6)

\int_1^5 \partial_x T(x) \partial_x \tilde{T}(x) \,dx = -\Lambda_1 \tilde{T}_1 -\Lambda_2 \tilde{T}_2

Here, $\Lambda$ is the outgoing flux, and the subscripts 1 and 2 represent the domain boundaries x=1 and x=5, respectively \Lambda_1\equiv -q(x=1) \mbox{, } \Lambda_2\equiv +q(x=5) \mbox{, } \tilde{T}_1\equiv \tilde{T}(x=1) \mbox{, } \tilde{T}_2\equiv \tilde{T}(x=5).

Also, we have used the heat flux relation (1) to write the integrand in terms of the temperature, T, and its test function, \tilde{T}. The right-hand side of the equation provides a natural way to assign boundary conditions in terms of the heat flux. The simplest is to set both \Lambda_1 and \Lambda_2 to zero to get insulating boundary conditions (no heat flux through the boundaries).

This is exactly the reason why in COMSOL Multiphysics the default boundary condition for heat transfer is “Thermal Insulation”, the one for solid mechanics is “Free (no boundary force)”, and the one for fluid flow is “Wall (zero flow across the boundary)”. This kind of boundary condition, which specifies the flux or force (the first derivative of the variable being solved), is commonly called the *natural boundary condition* or the *Neumann boundary condition*.

Another type of boundary condition, commonly called the *fixed boundary condition* or the *Dirichlet boundary condition*, specifies the value of the variable being solved. In our current example, it specifies the value of the temperature at a point on the boundary. This kind of boundary condition is usually needed to set up a well-posed problem with a unique solution. For example, in fluid flow, we need to specify the pressure somewhere (not just the flow); and in solid mechanics, we need to specify the displacement somewhere (not just the force).

As we have seen in the example, the weak formulation provides a natural way to specify the heat flux at a boundary. How do we specify a fixed temperature at a boundary, then?

The trick is to take advantage of the mathematical structure of the natural boundary condition and apply the same idea of using test functions to clamp down the solution. Conceptually, to maintain a fixed temperature at a boundary point, a certain heat flux coming from the outside of the boundary is needed to compensate for the heat flux inside of the boundary. The weak formulation poses the problem as this: Find the heat flux needed to maintain the fixed temperature at the boundary point.

For example, if we want to specify the outgoing flux \Lambda to be 2 at x=1 and the temperature T to be 9 at x=5, then we introduce a new unknown variable \lambda_2 and its corresponding test function \tilde{\lambda}_2, and write Eq. (6) as:

(7)

\int_1^5 \partial_x T(x) \partial_x \tilde{T}(x) \,dx = -2 \tilde{T}_1 -\lambda_2 \tilde{T}_2 -\tilde{\lambda}_2 (T_2-9)

Here, on the right-hand side, the first term specifies the outgoing flux of 2 at x=1 and the second term specifies the unknown flux at x=5; both terms come directly from the natural boundary condition terms on the right-hand side of Eq. (6).

The new variable \lambda_2 represents the unknown heat flux to be determined at the boundary x=5. The third term is added to the equation to force the solution to be T=9 at x=5 by means of the test function \tilde{\lambda}_2 in the same fashion as in the earlier discussion about the test function \tilde{T}(x).

So far, we have been discussing a very simple one-dimensional example. In higher dimensions, such as a 2D surface domain or a 3D volume domain, the equations become more complicated, but the basic idea remains the same.

The weak formulation turns a differential equation into an integral equation. Integration by parts reduces the order of differentiation to provide numerical advantages, and generates natural boundary conditions for specifying fluxes at the boundaries. In the simple 1D example, the boundary is the two end points and the flux is a single value at each point.

In 2D and 3D, the boundary is the closed curve and the closed surface enclosing the domain, respectively. The right-hand side of Eq. (6) becomes the line or surface integral of the incoming flux density, in other words, the total incoming flux. In essence, the process of integration by parts in 2D and 3D uses the divergence theorem to obtain the line or surface integral of the flux at the boundary of the modeling domain.

In this blog post, we chose the simple 1D example so that the central idea wouldn’t be obscured by the complexity of the math.

Today, we learned about the idea of the weak formulation of using test functions to clamp down the solution. Integrating the weak form by parts provides the numerical benefit of reduced differentiation order. It also provides a natural way to specify boundary conditions in terms of the fluxes or forces (the first derivatives of the variables being solved), the so-called natural boundary condition or the Neumann boundary condition.

When solving a practical problem, it’s often necessary to specify the variable being solved — not just its derivative — via the so-called fixed boundary condition or the Dirichlet boundary condition. We saw that the weak formulation uses the same mechanism of test functions and its natural boundary conditions to construct additional terms for the fixed boundary conditions.

So far, we have left the equations in their original analytical forms without any numerical approximation. In the next blog post, we will implement the weak form equation (7) in COMSOL Multiphysics to solve it numerically. After that, we will discuss how the numerical approximation is done internally, how the same problem can be solved in different ways, and how different boundary conditions can be set up for different types of problems.

]]>

The overall color scheme has changed to structure and organize the information better, as well as to reinforce the COMSOL Multiphysics workflow. Each workflow step has its own color. For example, all the *Geometry* icons are red-orange, all the *Materials* icons are yellow-orange, all the *Physics* icons are blue, and all the *Results* icons are red. The *Results* tab also has different icons for the various dimensions:

3D: , 2D: , 1D: .

*The new color scheme helps to differentiate between the model workflow steps.*

Last year’s introduction of the Multiphysics node really spoke to our product and who we are as a company. Setting up models with *multiple* physical phenomena should be as easy as it is with *one* phenomenon. The Multiphysics node helps realize that notion; you model one physics at a time and the multiphysics nodes automatically couple the different physics together.

With COMSOL Multiphysics 5.0 , we are introducing an additional 15 multiphysics couplings to the Multiphysics node, spanning several application areas (required modules are listed in parentheses):

- Non-Isothermal Flow including Conjugate Heat Transfer (CFD Module or Heat Transfer Module)
- Fluid-Structure Interaction for Fixed Geometry (Structural Mechanics Module or MEMS Module)
- Semiconductor-Electromagnetic Waves Coupling for Optoelectronics (Wave Optics Module and Semiconductor Module)
- Plasma Heat Source (Plasma Module)
- Lorentz Force (Plasma Module)
- Static Current Density Component (Plasma Module)
- Induction Current Density Component (Plasma Module)
- Piezoelectric Effect (Structural Mechanics Module, MEMS Module, or Acoustics Module)
- Acoustic-Structure Boundary (Acoustics Module)
- Thermoacoustic-Structure Boundary (Acoustics Module)
- Aeroacoustic-Structure Boundary (Acoustics Module)
- Acoustic-Porous Boundary for Poroelastic Waves (Acoustics Module)
- Porous-Structure Boundary for Poroelastic Waves (Acoustics Module)
- Background Potential Flow Coupling (Acoustics Module)
- Acoustic-Thermoacoustic Boundary (Acoustics Module)

A few of the more significant UI-related improvements involve materials. The ribbon now contains a *Materials* tab to go along with the other steps in the workflow, and materials can now be created globally for models with the same materials in multiple components. This lends itself to the most significant new addition, which is the new “Switch” feature to power material sweeps and function sweeps.

With the new material sweep feature, you use the available materials with their defined material properties directly in a sweep, avoiding the tedious task of re-entering material properties or material property functions. Previously, you had to manually enter material property values, which was rather time-consuming. Alternatively, if your material properties could only be defined as functions and you wanted to sweep over properties described by different functions, you had to get clever in setting up a parameter sweep. The parameters were abstract values included to control which parts of the function would be active for a particular step in the sweep. This made it difficult to postprocess the results and opened up the possibility for errors.

Now, the definition of a material sweep is much easier to define and it is also easier and more intuitive to process the results as you get the actual material names and values in the plot settings along with derived value evaluations. Functions are generic in COMSOL Multiphysics. Therefore, the function sweep is introduced, in analogy to the material sweeps, to define domain settings, boundary conditions, initial conditions, loads, constraints, etc.

First, you must create a Switch under one of the Materials nodes. If you don’t have materials already, create them from the Switch node. Otherwise, simply drag and drop previously defined materials in the model tree into the Switch node. In the *Study* tab, there is a “Material Sweep” button. After adding the Material Sweep, you will be prompted to add a Switch function and choose which cases in the Switch should be included. After running the simulation, you can switch between the materials that were swept over and examine the varying results. A “Function Sweep” works the same way. As I mentioned earlier, the Switch function can be applied globally or locally.

*A view of the Model Builder window with an added Switch, with two materials and Material Sweep.*

*The results settings, switching between the two materials.*

All of these details and more can be found on our Release Highlights page (including videos!)

]]>