<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>COMSOL Blog &#187; Walter Frei</title>
	<atom:link href="http://www.comsol.de/blogs/author/walter-frei/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.comsol.de/blogs</link>
	<description></description>
	<lastBuildDate>Thu, 22 Nov 2018 09:33:42 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.9.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>	<item>
		<title>Using Discontinuous Meshes for Conjugate Heat Transfer Modeling</title>
		<link>https://www.comsol.de/blogs/using-discontinuous-meshes-for-conjugate-heat-transfer-modeling/</link>
		<comments>https://www.comsol.de/blogs/using-discontinuous-meshes-for-conjugate-heat-transfer-modeling/#comments</comments>
		<pubDate>Wed, 21 Nov 2018 09:35:35 +0000</pubDate>
		<dc:creator><![CDATA[Walter Frei]]></dc:creator>
				<category><![CDATA[Fluid]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Heat Transfer & Phase Change]]></category>
		<category><![CDATA[Mesh]]></category>
		<category><![CDATA[Technical Content]]></category>

		<guid isPermaLink="false">http://com.staging.comsol.com/blogs?p=287471</guid>
		<description><![CDATA[Did you know that the COMSOL Multiphysics® software allows you to have different discontinuous meshes in neighboring domains? Although the usual default behavior of the software is to use aligned meshes, there are times when we might like to have discontinuous meshes, such as for modeling conjugate heat transfer. Let’s delve deeper into this topic and see how these meshes can save us time and memory in our initial model development with just a little bit more effort. Maintaining the [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Did you know that the COMSOL Multiphysics® software allows you to have different discontinuous meshes in neighboring domains? Although the usual default behavior of the software is to use aligned meshes, there are times when we might like to have discontinuous meshes, such as for modeling conjugate heat transfer. Let’s delve deeper into this topic and see how these meshes can save us time and memory in our initial model development with just a little bit more effort.</p>
<p><span id="more-287471"></span></p>
<h3>Maintaining the Continuity of the Fields and Balancing the Fluxes Between Aligned Elements</h3>
<p>The basic theory behind the <a href="/multiphysics/finite-element-method">finite element method</a> (FEM) has been covered several times (such as in this <a href="/blogs/brief-introduction-weak-form/">blog post on the weak form</a>), so we won’t go over it all here. Instead, we will review one key point: What happens at the interface between different finite elements? In short: When the standard FEM is used, adjacent aligned elements share the same node points (the node points are the points at which the solution to the problem is computed). Since these elements share nodes, the fields being solved for (such as temperature, solid displacement, fluid velocity, etc.) are automatically continuous.</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/11/aligned-mesh-element-flux.png" title="" alt="A schematic showing the flux between two aligned mesh elements." width="400" height="350" class="alignnone size-full wp-image-287491" /><br />
<em>Fluxes are automatically balanced between elements of different domains and these elements share the same nodes, so the fields are continuous.</em></p>
<p>Furthermore, the fluxes are naturally enforced to be equal (although this requires a bit more thorough understanding of the derivation of the FEM). Now, the term <em>flux</em> can refer to different quantities, depending upon the physics we are working with. For brevity, we will just consider heat transfer, where we naturally speak of the <em>heat flux</em>, which is the thermal conductivity times the negative of the gradient of the temperature field, or <img class="latexImg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGIAAAAWCAMAAAAMyLnrAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAADNQTFRF////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////8T5qHgAAAA90Uk5TACKZu3eIRBFm3e6qVcwzzZGFywAAAAFiS0dEAIgFHUgAAAAJcEhZcwAAAHgAAAB4AJ31WmAAAAE9SURBVEjH5ZTbdoQgDEXDJSCo5P//tgEFgp2ZJXX1pc1TNMph5xAA/nUobeyR4RAOwIvH5ZEInb9rCqZFVAB2dR42QgCn9SMMUjUx7aXndWHNmS1lhU8kllAzTa6myOuqQreWsnPzC/foPegYBWLxOY2l7FQt7Pu6wTqnGHiz9rCzYaCq1UTS6BRjyptquMn1SO8U2AqPHqPE8L3zlpT42FCphCYxHMIPVlg+N5t0o0OcVrTtHHVDHxvlL2g8Fl6sYUaI04oz3D0JJcjy1oNG3TUKhoC4WPFNwt5oVJ4KNOLRDBCjFWxCUdxf2v2OLE/Fxl7XzTKGgBit4C8pMPFCNHNo81RYA1tdljEkcLxcHM4E1GimJPJUqN31juvemgV3Cq9aPCdR5sWLqblzG81J/Ch+XSLly/7RzfvH4wt4Lwoa2Ez5uAAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxOC0xMS0yMVQyMzowNzozNSswMTowMNGYP7wAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTgtMTEtMjFUMjM6MDc6MzUrMDE6MDCgxYcAAAAAIXRFWHRwczpIaVJlc0JvdW5kaW5nQm94ADU5eDEzKzI3Nis2MzZDWo8LAAAAJ3RFWHRwczpMZXZlbABBZG9iZUZvbnQtMS4wOiBDTUJYMTIgMDAzLjAwMgqB2uIdAAAASXRFWHRwczpTcG90Q29sb3ItMAAvZGV2L3NobS96ZjItY2FjaGUvNTg0ZDVhNDBhYjZiZTBiN2U4MGI4NTIwZTQwMzFhMzcuZHZpIC1vMJ0MxQAAAEV0RVh0cHM6U3BvdENvbG9yLTEAL2Rldi9zaG0vemYyLWNhY2hlLzU4NGQ1YTQwYWI2YmUwYjdlODBiODUyMGU0MDMxYTM3LnBzDdStEwAAAABJRU5ErkJggg==" />. At boundaries between elements, the FEM automatically (that is, without needing any user input or additional internal equations) enforces the condition that <img class="latexImg" src="data:image/png;base64,iVBOR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WMxOTAzOGZmZDc2MTE0MjcwMzExOS5wc+Ri/h4AAAAASUVORK5CYII=" />, where <img class="latexImg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAMBAMAAAB2C0uMAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAACpQTFRF////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////5u1vmAAAAAx0Uk5TADO7zERVmd2IEWbusNYXgAAAAAFiS0dEAIgFHUgAAAAJcEhZcwAAAHgAAAB4AJ31WmAAAAAsSURBVAjXY2DABoRsXJMrwCxOmy4GmwAwUyeBQacBwmogkSW0p4JpTxGyDQCpcw0wMWfv8AAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxOC0xMS0yMVQyMzowNzozNSswMTowMNGYP7wAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTgtMTEtMjFUMjM6MDc6MzUrMDE6MDCgxYcAAAAAIHRFWHRwczpIaVJlc0JvdW5kaW5nQm94ADEweDcrMzAwKzYzORj1Sh4AAAAndEVYdHBzOkxldmVsAEFkb2JlRm9udC0xLjA6IENNQlgxMiAwMDMuMDAyCoHa4h0AAABJdEVYdHBzOlNwb3RDb2xvci0wAC9kZXYvc2htL3pmMi1jYWNoZS9lMTVjMDJhNDlmY2MxN2EwZjI5ODYyYzQ0OWJmM2NlMC5kdmkgLW9qeB9lAAAARXRFWHRwczpTcG90Q29sb3ItMQAvZGV2L3NobS96ZjItY2FjaGUvZTE1YzAyYTQ5ZmNjMTdhMGYyOTg2MmM0NDliZjNjZTAucHO12OD0AAAAAElFTkSuQmCC" /> is the normal vector to the boundary between elements. That is, the standard FEM naturally enforces the continuity of the fields and balances fluxes. Do keep in mind that, regardless of this, you will always need to do a <a href="/multiphysics/mesh-refinement">mesh refinement study</a> to gain confidence in the overall accuracy of your model.</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/11/heat-exchanger-submodel.png" title="" alt="A schematic of a cross-flow heat exchanger submodel." width="450" height="250" class="alignnone size-full wp-image-287501" /><br />
<em>Schematic of a submodel of a cross-flow heat exchanger.</em></p>
<p>Let’s now take a look at a sample model from the Application Gallery, the <a href="/model/cross-flow-heat-exchanger-173">Cross-Flow Heat Exchanger</a>, which is schematically pictured above. This is a submodel of a larger heat exchanger consisting of straight rectangular channels. The fluid flow through the channels is modeled, as is the temperature field in the fluid and the surrounding solid. The temperature field is plotted below. The temperature is also plotted along a representative line along the length of the flow channel. Observe from these plots that the temperature variation along the flow channel is varying quite slowly along the length, quickly over the cross section of the flow channel, and in a quite complicated way through the metal part.</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/11/temperature-plots-heat-exchanger.png" title="" alt="Results plots showing the temperature field in different parts of a cross-flow heat exchanger." width="450" height="575" class="alignnone size-full wp-image-287511" /><br />
<em>Temperature field at the walls and isosurfaces of temperature in the solid (top) and the plots of temperature along the flow channel directions (bottom).</em></p>
<p>The mesh is plotted below, and we can see that it is continuous between the fluid domain and the solid domain. The mesh is composed primarily of tetrahedral elements, with a boundary layer mesh applied on the fluid side of the channel walls to resolve the high velocity and thermal gradients near the wall.</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/11/heat-exchanger-model-default-mesh.png" title="" alt="An image showing the default mesh of a heat exchanger model in COMSOL Multiphysics." width="525" height="325" class="alignnone size-full wp-image-287521" /><br />
<em>Default mesh of the cross-flow heat exchanger that is continuous between the fluid and solid.</em> </p>
<p>Now, this default mesh is generated with no user interaction at all. But what if we wanted to manually build the mesh, and what if we allowed the mesh to be discontinuous &mdash; what could we do then? Before we get to how to implement that, let’s take a look at what the software will need to do.</p>
<h3>Maintaining the Continuity of the Fields and Balancing the Fluxes Between Nonaligned Elements</h3>
<p>Suppose we have a set of elements on two adjacent domains, as shown in the image below. The elements have adjacent boundaries, but the nodes are nonaligned. This kind of mesh is automatically generated when the <a href="/support/knowledgebase/1216/"><em> Form Assembly</em> geometry finalization</a> step is used. The meshes of separate objects will not be connected, so as a consequence, the fields across this boundary will be as discontinuous, with no flux between the domains.</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/11/nonaligned-mesh-equations.png" title="" alt="A schematic of the equations required for COMSOL to handle nonaligned meshes." width="400" height="390" class="alignnone size-full wp-image-287531" /><br />
<em>For nonaligned meshes, additional equations must be introduced to approximately balance fluxes and fields.</em></p>
<p>However, the <em>Form Assembly</em> operation can also automatically create so-called <em>Identity pairs</em> at the adjacent boundaries between objects. Within each physics, you can then apply boundary conditions to these pair boundaries. Depending upon the physics interface, different boundary conditions will be available, but in all cases, the <em>Pair Continuity</em> condition will be available. This condition enforces the continuity of the fields, and the fluxes, across the boundary in an element-averaged sense. It does so by adding an additional set of equations behind the scenes, which we won&#8217;t go into here. Since the elements are not exactly aligned, the fields and fluxes cannot be pointwise continuous, which is a drawback; however, we can now have different meshes in adjacent domains, which has advantages. Let’s look at how this benefits us in the case of this cross-flow heat exchanger.</p>
<p>As we saw earlier, the temperature variation along the flow channel is quite gradual. Since the flow is laminar and the channels are uniform in cross section, we also know that the flow field is nearly invariant along the flow directions. Therefore, we can apply a swept mesh in the channels along the direction of the flow, as shown in the image below. Observe that far fewer elements are used in the flow direction, thereby reducing the problem size with only a small loss in accuracy as compared to the previous mesh.</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/11/assembly-meshing-heat-exchanger-model.png" title="" alt="An image of a heat exchanger model meshed with assembly meshing." width="450" height="300" class="alignnone size-full wp-image-287541" /><br />
<em>With assembly meshing, a swept mesh in the fluid channels allows for an elongated mesh with fewer elements.</em></p>
<p>Now, there are a few additional manual steps that we have to take to set up this mesh. First, within the <em>Geometry</em> sequence, we have to define two different objects. The first object is the metal part, the solid through which the fluid flows. The second object is the combination of all of the fluid flow domains; that is, a single object that is composed of several different domains, which are created via Boolean <em>Union</em> operations in the geometry sequence. We do need to ensure that these domains are nonoverlapping for the <em>Form Assembly</em> finalization operation to be valid, and then the software will automatically recognize all mating faces between these objects as identity pairs.</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/11/form-assembly-settings-window.png" title="" alt="A screenshot of the settings for a feature with discontinuous meshes." width="530" height="419" class="alignnone size-full wp-image-287551" /><br />
<em>The</em> Form Assembly <em>geometry finalization that automatically creates</em> Identity pairs<em>.</em></p>
<p>Next, within the <em>Heat Transfer in Solids and Fluids</em> interface, we need to add a <em>Pair Continuity</em> boundary condition. Since we only have two adjacent objects (the solid and all of the fluid domains), this condition needs to be applied just to a single <em>Identity Boundary Pair</em>. No other changes to the physics are necessary.</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/11/pair-continuity-boundary-condition.png" title="" alt="A screenshot of the Pair Continuity boundary condition settings." width="480" height="471" class="alignnone size-full wp-image-287561" /><br />
<em>The</em> Pair Continuity <em>boundary condition that enforces continuity of fields and balances fluxes.</em></p>
<p>Finally, the <em>Mesh</em> sequence has to be manually modified. The default meshing sequence will copy the elements on the mating faces of the pair boundary, but we will want to disable this and apply a swept mesh that is elongated along the length of the flow channels. Since we know the solution varies quite gradually in this direction, the modification is justified. No other significant changes are made to the mesh, as compared to the automatically generated mesh shown earlier.</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/11/meshing-sequence-settings-comsol.png" title="" alt="A screenshot of the meshing sequence for the heat exchanger model." width="529" height="458" class="alignnone size-full wp-image-287571" /><br />
<em>The meshing sequence used to control the number of elements along the flow directions in the channels.</em></p>
<p>The temperature field and the difference in the temperature field are plotted below. The model using the swept mesh is, of course, going to be different. In this case, the temperature field differs by about 2°C in some regions compared to the previous case. This difference is primarily due to the difference in the mesh across the interface. It is not due to the additional pair continuity equations. In the limit of mesh refinement, both approaches will converge to the same solution. The primary advantage of using assembly meshing is that you can begin with a relatively coarser mesh that will still give reasonable results, thereby saving time and computational resources in your initial model development.</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/11/temperature-field-result-differences.png" title="" alt="Results plots comparing the temperature field found via assembly and default meshing." width="450" height="550" class="alignnone size-full wp-image-287581" /><br />
<em>Temperature field (top) using assembly meshing and the difference in this temperature field (bottom) as compared to the default mesh.</em></p>
<p>In the case of this geometry, we could also divide our geometry in a different way. We could split our model up into two objects along the plane between the flow channels, as shown in the image below. Now, we can lower the element count even more. Although not all geometries lend themselves to this subdivision, this approach can even further reduce the element count.</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/11/identity-pair-within-solid.png" title="" alt="A conjugate heat transfer model meshed using identity pairs within the solid." width="400" height="250" class="alignnone size-full wp-image-287591" /><br />
<em>An alternative meshing strategy would introduce the identity pair within the solid rather than at the fluid-solid boundary.</em> </p>
<h3>Closing Remarks</h3>
<p>We have shown here that assembly meshing is a useful technique for reducing the number of mesh elements. This is particularly applicable for conjugate heat transfer problems, since these often contain relatively uniform flow channels that lend themselves to swept meshing. Although here we have considered a model involving laminar flow, this approach will also work for turbulent flow problems. Keep in mind, though, that this technique has its place in preliminary model development: You’ll usually want to verify these models against a model with a congruent mesh and, of course, always do a mesh refinement study. The key advantage is that you can more quickly do preliminary analyses.</p>
<p>The model using the assembly meshing capability is available for download here: </p>
<ul>
<li><a href="/model/using-assembly-meshing-for-conjugate-heat-transfer-modeling-69901">Using Assembly Meshing for Conjugate Heat Transfer Modeling</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>https://www.comsol.de/blogs/using-discontinuous-meshes-for-conjugate-heat-transfer-modeling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>3 Approaches to Modeling Moving Loads and Constraints in COMSOL®</title>
		<link>https://www.comsol.de/blogs/3-approaches-to-modeling-moving-loads-and-constraints-in-comsol/</link>
		<comments>https://www.comsol.de/blogs/3-approaches-to-modeling-moving-loads-and-constraints-in-comsol/#comments</comments>
		<pubDate>Mon, 22 Oct 2018 08:24:04 +0000</pubDate>
		<dc:creator><![CDATA[Walter Frei]]></dc:creator>
				<category><![CDATA[CAD Import & LiveLink for CAD Products]]></category>
		<category><![CDATA[Electrical]]></category>
		<category><![CDATA[Electromagnetic Heating]]></category>
		<category><![CDATA[Equation-Based Modeling]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Interfacing]]></category>
		<category><![CDATA[Technical Content]]></category>

		<guid isPermaLink="false">http://com.staging.comsol.com/blogs?p=281621</guid>
		<description><![CDATA[One of the core strengths of the COMSOL Multiphysics® software is the ability to easily define loads and constraints that move over time. There are actually several different ways in which this can be done, all within the core functionality of the software. In today&#8217;s blog post, we will guide you through three of these approaches. The Example: Laser Heating of a Flat Plate Let’s consider the case of a flat plate of material that is being heated by a [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>One of the core strengths of the COMSOL Multiphysics® software is the ability to easily define loads and constraints that move over time. There are actually several different ways in which this can be done, all within the core functionality of the software. In today&#8217;s blog post, we will guide you through three of these approaches.</p>
<p><span id="more-281621"></span></p>
<h3>The Example: Laser Heating of a Flat Plate</h3>
<p>Let’s consider the case of a flat plate of material that is being heated by a laser heat source. The plate is centered at the origin, as shown in the figure below, and we want to heat its surface at varying locations over time. Suppose that the laser (or the workpiece) is mounted on a stage that provides positional control of the focus point. Let’s also assume that there are some optics that shape the beam profile of the laser, so the heat source is spread over a small area around the focus. </p>
<p><img src="https://cdn.comsol.com/wordpress/2018/10/laser-heat-source-schematic.png" title="" alt="A schematic showing a laser heat source heating a flat workpiece." width="571" height="400" class="alignnone size-full wp-image-281641" /><br />
<em>Schematic of a laser heat source traversing over a workpiece.</em></p>
<p>Now, let&#8217;s look at several different ways in which we can define the moving focus point to follow a known tool path.</p>
<h3>Method 1: Using Variables</h3>
<p>The simplest approach is to use a set of variables to define the position of the focus and distribution of the heat load over time. Let’s say that we want to have a 1-kW total heat load moving in a 40-cm radius circular path every 10 s. Furthermore, the heat load has a Gaussian intensity distribution with a 5-cm waist radius. We can define this information using variables, as shown in the screenshot below.</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/10/variable-definitions-settings-window.png" title="" alt="A screenshot of the Settings window for variable definitions in COMSOL Multiphysics." width="629" height="432" class="alignnone size-full wp-image-281651" /></p>
<p>The first four definitions, <code>Rb</code>, <code>P0</code>, <code>Rp</code>, and <code > T0</code>, are actually just constants. If we would like to alter any of these definitions via a parametric sweep later on, we could also define them as <em>Global Parameters</em>. For now, it is simplest to just show them all in one place.</p>
<p>The next two variables, <code>x_focus</code> and <code>y_focus</code>, are not constant: They vary as a function of time, the built-in variable <code > t</code>. We can see that these variables describe a point moving on a circular path about the origin as:</p>
<pre>Rp*cos(2*pi*t/T0)</pre>
<pre>Rp*sin(2*pi*t/T0)</pre>
<p>The next variable, <code>R</code>, is a function of time and space. It makes use of the coordinate variables <em><code>x</code></em> and <em><code>y</code></em>, as well as <code>x_focus</code> and <code > y_focus</code>, which we just saw are functions of time. So at each instant in time and at every point in space, this variable tells us the distance (in the <em>xy</em>-plane) from the laser focal point.</p>
<p>The last variable, <code>HeatFlux</code>, is a function of <code>R</code> and the constants. It defines a Gaussian intensity profile about the focal point such that the total heat flux equals the defined power. It is this variable, <code > HeatFlux</code>, that we enter as a boundary condition, as shown in the screenshot below.</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/10/heat-flux-boundary-settings.png" title="" alt="A screenshot of the boundary heat flux Settings window." width="629" height="294" class="alignnone size-full wp-image-281661" /></p>
<p>This prescribed heat flux expression then gives the heating profile path visualized below.</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/10/circular-heating-profile.png" title="" alt="An image showing a circular heating profile in the COMSOL software." width="646" height="370" class="alignnone size-full wp-image-281671" /><br />
<em>A circular heating profile set up via the</em> Variables <em>node.</em></p>
<h3>Method 2: Using Interpolation Functions</h3>
<p>So far, this isn’t very complicated; just a few expressions. But we can replace the simple expressions for <code>x_focus</code> and <code > y_focus</code> with something more general. COMSOL Multiphysics provides a variety of built-in functions in the software. For our discussion here, the most useful is the <em>Interpolation</em> function, which lets us read in data from a text file. Let’s suppose we have a text file containing rows of data of time and the <em>x</em>- and <em>y</em>-locations of the laser focus at that time. A sample of such a file is shown below:</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/10/laser-data-text-file.png" title="" alt="A screenshot of a text file containing data for the laser focus model." width="299" height="207" class="alignnone size-full wp-image-281681" /></p>
<p>Such data can be read in to the <em>Interpolation</em> function using the settings shown below. Note that there is just a single argument here, time, and the two columns of data after that represent the <em>x</em>-focus and <em>y</em>-focus, respectively, in units of centimeters. Between the specified points in time, we want the laser to move linearly. We specify the function names as <code>x_f</code> and <code > y_f</code>, respectively, and make sure to set the arguments correctly.</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/10/interpolation-function-settings-window.png" title="" alt="A screenshot of the settings for the interpolation function." width="549" height="677" class="alignnone size-full wp-image-281691" /></p>
<p>We can then just alter our previous expressions for the focus to be <code>x_focus = x_f(t)</code> and <code > y_focus = y_f(t)</code> and get the moving load pictured below.</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/10/heating-profile-from-text-file.png" title="" alt="An image showing the heating profile found using the interpolation function method." width="625" height="348" class="alignnone size-full wp-image-281701" /><br />
<em>A heating profile read in from a text file.</em></p>
<p>We can see that this <em>Interpolation</em> function quickly lets us read in some very complicated profile patterns, we just need a way to generate these profiles and the text files. For example, the text file format used here is not too different from the <a href="https://en.wikipedia.org/wiki/G-code" target="_blank">G-code</a> format, so if you have a heating path defined in such a format, it can be pretty simple to convert it to a COMSOL®-friendly input. On the other hand, maybe we would like to import a profile created in the ubiquitous 2D DXF file format. Let’s look at that next…</p>
<h3>Method 3: Using Paths Imported from CAD Geometries</h3>
<p>Suppose we want the load to move along a path we read in from an external file, as shown in the image below. We would like the laser to move smoothly along this path from one end to the other. Now, we need to do a bit more work.</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/10/laser-profile-and-dxf-settings.png" title="" alt="Side-by-side images showing the import settings for a DXF file and an S-shaped laser profile." width="882" height="275" class="alignnone size-full wp-image-281711" /><br />
<em>The S-shaped profile of the laser path is read in from a DXF file as a geometry.</em></p>
<p>The file that we’ve read in doesn’t have any information about time within it: It is just a path that we expect the laser to follow at a constant speed. Now, each edge of this imported path (and there may be thousands of edges) does have parameters <code>s1</code> and <code > s2</code> that vary linearly along the length, but if there are many edges, we probably wouldn&#8217;t want to work with these parameters. So instead, how do we compute where the laser is at every point in time along the entire set of lines? One way in which we can do this is by introducing another partial differential equation (PDE) to solve, along the desired set of lines. The PDE we want to solve is:</p>
<div class="latex">\nabla_t \cdot \left( c \nabla_t u \right) = 0</div>
<p>where <img class="latexImg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAUBAMAAABscEDKAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAC1QTFRF////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////wISVsgAAAA10Uk5TAIhEmd277iIRVWbMd+OkNx0AAAABYktHRACIBR1IAAAACXBIWXMAAAB4AAAAeACd9VpgAAAAc0lEQVQY02NgwA8YBcFACMplvhIKAulQLvtVEMkhAFNtqwDSUgDj1gYAiUa4WcyXgIQ4nAvSjNAK1ozQCtYM0spRANcM0sooANMM1sqqANOsCFTHKQtzZ20giFSF23wdRArCbQYbEoTq0wtVKNydBzDCAgAN8RMLAfzeEQAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxOC0xMS0yMlQwMDowMjo1MyswMTowMOdi1NQAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTgtMTEtMjJUMDA6MDI6NTMrMDE6MDCWP2xoAAAAIXRFWHRwczpIaVJlc0JvdW5kaW5nQm94ADE3eDEyKzI5Nys2MzcNxFqWAAAAJ3RFWHRwczpMZXZlbABBZG9iZUZvbnQtMS4wOiBDTVNZMTAgMDAzLjAwMgp3GwEQAAAASXRFWHRwczpTcG90Q29sb3ItMAAvZGV2L3NobS96ZjItY2FjaGUvNzA5ODcxOTY4NTY2ZmVkZWI0Yjk5ZDI4ODZlNGIyNjguZHZpIC1vYN+G+wAAAEV0RVh0cHM6U3BvdENvbG9yLTEAL2Rldi9zaG0vemYyLWNhY2hlLzcwOTg3MTk2ODU2NmZlZGViNGI5OWQyODg2ZTRiMjY4LnBzlLMmdQAAAABJRU5ErkJggg==" /> refers to the tangential direction to the curve.</p>
<p>This PDE, along with the boundary conditions of <code>u = 0</code> at one end of the path and <code>u = 1</code> at the other end, will give us a field along the path that varies linearly from 0 to 1, which will be proportional to the total arc length of all of the edges. We can set this up using the <em>Coefficient Form Edge PDE</em> interface, as shown in the screenshots below. All coefficient terms other than the <em>Diffusion Coefficient</em>, <em><code > c</code></em>, are set to zero. </p>
<div class="row">
<div class="col-sm-6">
<a href="https://cdn.comsol.com/wordpress/2018/10/coefficient-form-edge-pde-interface.png" target="blank"><img src="https://cdn.comsol.com/wordpress/2018/10/coefficient-form-edge-pde-interface.png" title="Coefficient Form Edge PDE" alt="A screenshot of the Coefficient Form Edge PDE interface Settings window." class="alignnone size-full wp-image-281721" /></a>
</div>
<div class="col-sm-6">
<a href="https://cdn.comsol.com/wordpress/2018/10/diffusion-coefficient-term-settings.png" target="blank"><img src="https://cdn.comsol.com/wordpress/2018/10/diffusion-coefficient-term-settings.png" title="Diffusion Coefficient settings" alt="A screenshot of the Diffusion Coefficient settings in COMSOL Multiphysics." class="alignnone size-full wp-image-281731" /></a>
</div>
</div>
<p><em>Left: Settings of the</em> Coefficient Form Edge PDE <em>interface needed to compute the path. Right: The diffusion coefficient term,</em> c<em>, is a constant; all other coefficients are set to zero.</em> </p>
<p>Then, two <em>Dirichlet</em> boundary conditions set the field, <code>u</code>, at either ends, and we solve this PDE in a stationary step, prior to solving the heat transfer problem but still within the same study.</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/10/dirichlet-boundary-condition-settings.png" title="" alt="A screenshot of Dirichlet boundary condition settings used to model moving loads and constraints." width="545" height="299" class="alignnone size-full wp-image-281751" /><br />
<em>Two</em> Dirichlet <em>boundary conditions are used at the start and end of the profile path to constrain the field.</em></p>
<p>Next, we introduce a single minimum component coupling operator into the model, with the source selected as the edges to follow. This minimum operator is used to define the focal point coordinates, e.g.:</p>
<pre>x_focus = minop1(abs(u-t/T0),x)</pre>
<pre>y_focus = minop1(abs(u-t/T0),y)</pre>
<p>Note that the minimum operator is given two arguments. When we call the operator with two arguments, it will return the value of the second argument where the first argument is at a minimum. Thus, at each time, <code>t</code>, it will return the <em>x</em>- and <em>y</em>-locations of a point on the edge that is <code > t/T0</code> fraction of the way from one end to the other.</p>
<div class="row">
<div class="col-sm-6">
<a href="https://cdn.comsol.com/wordpress/2018/10/minimum-operator-settings-COMSOL.png" target="blank"><img src="https://cdn.comsol.com/wordpress/2018/10/minimum-operator-settings-COMSOL.png" title="Minimum operator settings" alt="A screenshot of the Settings window for the minimum operator." class="alignnone size-full wp-image-281771" /></a>
</div>
<div class="col-sm-6">
<a href="https://cdn.comsol.com/wordpress/2018/10/laser-heat-source-from-dxf-file.png" target="blank"><img src="https://cdn.comsol.com/wordpress/2018/10/laser-heat-source-from-dxf-file.png" title="Laser heat source" alt="An image of the laser heat source results for the imported DXF file method." class="alignnone size-full wp-image-281781" /></a>
</div>
</div>
<p><em>Left: The minimum operator is defined over the path that the heat source follows. Right: The laser heat source following the path defined by an imported DXF file.</em></p>
<p>And what if we would like the laser to traverse different parts of the path at different speeds? We would just need to adjust the coefficient, <em><code>c</code></em>, along those sets of edges. Suppose we want the laser to move three times faster along the curved boundaries than along the straight lines: just make <code > c</code> three times larger. Note that the absolute value doesn’t matter, it is just the ratio of the coefficient magnitudes that matters. The one drawback to this approach arises when the path crosses itself. In that situation, you would need to subdivide the path into two, or more, groups of paths; solve a PDE on each; and do a bit more bookkeeping for the variables.</p>
<h3>Closing Remarks on Modeling Moving Loads and Constraints</h3>
<p>In this blog post, we have looked at three different approaches of modeling a moving load. To try them yourself, click the button below to head to the Application Gallery. There, you can download the MPH-files for the models featured above (must have a COMSOL Access account and valid software license).</p>
<div class="flex-center">
<a href="/model/modeling-of-moving-loads-69831" class="btn-solid btn-md btn-red">Try It Yourself</a>
</div>
<p>Several other examples within the Application Gallery also make use of these techniques, including:</p>
<ul>
<li><a href="/model/laser-heating-of-a-silicon-wafer-1383">Laser Heating of a Silicon Wafer</a></li>
<li><a href="/model/traveling-load-20401">Traveling Load</a></li>
</ul>
<p>Although in this blog post we only considered loads, note that we can also apply these techniques to constraints, as described in <a href="/blogs/how-to-make-boundary-conditions-conditional-in-your-simulation/">How to Make Boundary Conditions Conditional in Your Simulation</a>.</p>
<p>Do you have further questions about using COMSOL Multiphysics for your modeling applications? Please let us know!</p>
]]></content:encoded>
			<wfw:commentRss>https://www.comsol.de/blogs/3-approaches-to-modeling-moving-loads-and-constraints-in-comsol/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Model Conductors in Time-Varying Magnetic Fields</title>
		<link>https://www.comsol.de/blogs/how-to-model-conductors-in-time-varying-magnetic-fields/</link>
		<comments>https://www.comsol.de/blogs/how-to-model-conductors-in-time-varying-magnetic-fields/#comments</comments>
		<pubDate>Fri, 25 May 2018 08:37:13 +0000</pubDate>
		<dc:creator><![CDATA[Walter Frei]]></dc:creator>
				<category><![CDATA[AC/DC & Electromagnetics]]></category>
		<category><![CDATA[Electrical]]></category>
		<category><![CDATA[AC/DC Module]]></category>
		<category><![CDATA[Technical Content]]></category>

		<guid isPermaLink="false">http://com.staging.comsol.com/blogs?p=260901</guid>
		<description><![CDATA[One of the more common uses of the AC/DC Module, an add-on to the COMSOL Multiphysics® software, is for modeling conductors and other lossy materials in time-varying magnetic fields when there are significant induced currents. The appropriate modeling approach depends upon how quickly the magnetic fields vary over time. Here, we review the basics and describe various modeling techniques to use. Describing the Skin Effect Using the AC/DC Module Whenever a lossy material, such as a conductor, is exposed to [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>One of the more common uses of the AC/DC Module, an add-on to the COMSOL Multiphysics® software, is for modeling conductors and other lossy materials in time-varying magnetic fields when there are significant induced currents. The appropriate modeling approach depends upon how quickly the magnetic fields vary over time. Here, we review the basics and describe various modeling techniques to use.</p>
<p><span id="more-260901"></span></p>
<h3>Describing the Skin Effect Using the AC/DC Module</h3>
<p>Whenever a lossy material, such as a conductor, is exposed to a time-varying electromagnetic field, there will be currents induced in that material. These currents then produce a magnetic field that alters the current distribution within the material, with the net result being that the induced currents will preferentially flow at the surfaces of any lossy material. This is known as the <a href="https://en.wikipedia.org/wiki/Skin_effect" target="_blank">skin effect</a>.</p>
<p>We can model this effect using the <a href="/acdc-module">AC/DC Module</a> and any of the physics interfaces that solve for the magnetic fields and currents, such as the:</p>
<ul>
<li><em>Magnetic Fields</em> interface</li>
<li><em>Magnetic and Electric Fields</em> interface</li>
<li><em>Magnetic Field Formulation</em> interface</li>
<li><em>Rotating Machinery Magnetic</em> interface</li>
</ul>
<p>All of these physics interfaces support modeling in the frequency domain under the assumption that the magnetic fields, and all other fields, are varying sinusoidally in time. The <em>Magnetic Fields</em> interface &mdash; as well as the <em>Rotating Machinery Magnetic</em> and the <em>Magnetic Field Formulation</em> interfaces &mdash; support full time-domain analysis, where the fields can vary nonsinusoidally over time.</p>
<h3>Frequency-Domain Simulations for Conductors in Time-Varying Magnetic Fields</h3>
<p>To start off, we focus on the frequency domain, a very reasonable thing to do, since most electric devices operate at a known frequency or range of frequencies. Based upon the operating frequency, we can then compute the skin depth, <em>δ</em>, in the material:</p>
<div class="latex">\delta=\left[ \Re \left (\sqrt{j \omega \mu_0 \mu_r(\sigma + j \omega \epsilon_0 \epsilon_r )} \right) \right]^{-1}</div>
<p>where <img class="latexImg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAMBAMAAACdPPCPAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAADBQTFRF////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////L2OG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AxMng5KzI5OSs2Mzfjiz1HAAAAJ3RFWHRwczpMZXZlbABBZG9iZUZvbnQtMS4wOiBDTU1JMTIgMDAzLjAwMgoxF5a7AAAASXRFWHRwczpTcG90Q29sb3ItMAAvZGV2L3NobS96ZjItY2FjaGUvZmI2YTE2NzViOWQ5YTJkOWJhMmE1MzMxN2ZjY2YwOTkuZHZpIC1vNTBccgAAAEV0RVh0cHM6U3BvdENvbG9yLTEAL2Rldi9zaG0vemYyLWNhY2hlL2ZiNmExNjc1YjlkOWEyZDliYTJhNTMzMTdmY2NmMDk5LnBzC22b1wAAAABJRU5ErkJggg==" /> are the relative permeability and permittivity of the material, and <img class="latexImg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAMCAMAAACz+6aNAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAADNQTFRF////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////8T5qHgAAAA90Uk5TAFWIEcy7d2bd7kQzIpmqssagbgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAAAHgAAAB4AJ31WmAAAABMSURBVAjXjY5BDoAwCATpItJSlf//ttqDYE/uYZOdZAJEf1Mw827eBOLAHkDvrhoK5GkJh1pZiPlUvS9EJZ1uTNTrkYidphd/H7S8B2uuAUKA+Ng8AAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE4LTExLTIyVDAwOjAyOjU3KzAxOjAwEy3wxwAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxOC0xMS0yMlQwMDowMjo1NyswMTowMGJwSHsAAAAgdEVYdHBzOkhpUmVzQm91bmRpbmdCb3gAMTB4NyszMDErNjM5JZVjrgAAACd0RVh0cHM6TGV2ZWwAQWRvYmVGb250LTEuMDogQ01NSTEyIDAwMy4wMDIKMReWuwAAAEl0RVh0cHM6U3BvdENvbG9yLTAAL2Rldi9zaG0vemYyLWNhY2hlL2EyYWI3ZDcxYTBmMDdmMzg4ZmY4MjMyOTNjMTQ3ZDIxLmR2aSAtb5+VokQAAABFdEVYdHBzOlNwb3RDb2xvci0xAC9kZXYvc2htL3pmMi1jYWNoZS9hMmFiN2Q3MWEwZjA3ZjM4OGZmODIzMjkzYzE0N2QyMS5wczZeNeEAAAAASUVORK5CYII=" /> is the material electrical conductivity.</p>
<p>For conductors, this equation can be simplified to:</p>
<div class="latex">\delta=\sqrt{\frac{2}{\omega \mu_0 \mu_r \sigma}}</div>
<p>Strictly speaking, the skin depth is defined in terms of the exponential decrease in the induced currents within a planar, semi-infinite conductor, but it is still a useful measure regardless of the shape of the geometry. First, we always estimate the skin depth of all of the materials in the simulation, since this value governs how we will model them. To understand this key point, let’s look at a simple case of a closed loop of wire (with a wire radius of 1 cm and loop radius of 10 cm) exposed to a uniform background magnetic field at different frequencies, as shown schematically below.</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/05/copper-wire-loop-magnetic-field.png" title="" alt="A schematic showing a copper loop exposed to a time-varying magnetic field." width="320" height="300" class="alignnone size-full wp-image-260951" /><br />
<em>A loop of copper wire exposed to a sinusoidally time-varying magnetic field.</em></p>
<p>The above illustrated problem can be modeled using a 2D axisymmetric model, as seen below. The infinite element domain is used to truncate the modeling space for the reasons outlined in this <a href="/blogs/how-to-choose-between-boundary-conditions-for-coil-modeling/">previous blog post</a>.</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/05/coil-model-schematic.png" title="" alt="Schematic showing the model of the coil." width="255" height="475" class="alignnone size-full wp-image-260961" /><br />
<em>A schematic of the coil model.</em></p>
<p>Let’s look at the results at several different frequencies. The image below shows the magnitude of the current flow in the coil. At higher frequencies, we can observe how the current primarily flows near the surface of the coil. In fact, at the highest frequency, the current in the center of the coil is, for all practical purposes, zero. That is, the skin effect has shielded the inside of the conductor.</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/05/current-flow-3-frequencies-simulation.png" title="" alt="Image showing current flow in a coil at different frequencies." width="600" height="250" class="alignnone size-full wp-image-260971" /><br />
<em>The current flow within the coil cross section at different frequencies.</em></p>
<p>To appropriately model these various cases, we also need to be aware of the finite element mesh used. At higher frequencies, as the current is being driven closer and closer to the boundaries, we need to have a finer mesh to resolve the spatial variation of the fields. However, the fields are only varying strongly in the direction normal to the boundary and varying quite gradually along the perimeter of the coil.</p>
<p>In these cases, it is appropriate to use the boundary layer meshing functionality, which will insert thin elements normal to the boundary, as shown in the image below. Depending upon how accurately you want to resolve the current distribution in the coil, you can adjust the thickness of the boundary layer elements to be between one half to one skin depth and use as few as two or as many as eight or more boundary layer elements. On the other hand, at frequencies that are low enough, the boundary layer meshing is not needed at all.</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/05/wire-mesh-varying-frequencies.png" title="" alt="3 side-by-side plots showing mesh within a coil at different frequencies." width="600" height="250" class="alignnone size-full wp-image-260981" /><br />
<em>The mesh within the wire at varying frequencies, corresponding to the previous plots of current distribution.</em></p>
<h4>Equivalent Boundary Conditions</h4>
<p>Now, we can also see from the image above that at higher frequencies, the current distributions extend very negligibly into the coil interior. Therefore, for all practical purposes, we can say that at frequencies that are high enough, the currents flow <em>on</em> the surface. In these cases, we can use the <em>Impedance</em> boundary condition and not model <em>any</em> of the coil interior at all, as shown in the image below.</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/05/impedance-boundary-condition-schematic-model.png" title="" alt="An image demonstrating the Impedance boundary condition, which used to model conductors." width="600" height="500" class="alignnone size-full wp-image-260991" /><br />
<em>Schematic and mesh of a model using the</em> Impedance <em>boundary condition.</em></p>
<p>This approach saves us a significant amount of computational effort, since we now only need to mesh the air domain and apply the <em>Impedance</em> boundary condition. Obviously, we do lose some information here: the current distribution within the conductor. But if we do not care about that, then this approach can be a superior alternative to meshing the conductor interior. The first plot below shows the losses in the coil versus frequency, computed via the <em>Impedance</em> boundary condition and via a domain model of the coil with a boundary layer mesh.</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/05/conductor-model-computed-losses-plot.png" title="" alt="A COMSOL Multiphysics® plot comparing the losses in a conductor computed using 2 methods." width="550" height="400" class="alignnone size-full wp-image-261001" /><br />
<em>Plot of the computed losses via a domain model and the</em> Impedance <em>boundary condition.</em></p>
<p>The next figure plots the ratio of the losses computed by using the <em>Impedance</em> boundary condition to the losses computed by explicitly modeling the domains, and this ratio is plotted against the ratio of the wire radius to the skin depth. As the characteristic dimension of the parts (in this case, the radius) approaches ten times the skin depth, the losses computed via these two approaches are similar.</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/05/conductor-model-ratio-comparision-plot.png" title="" alt="A plot comparing ratios of computed losses as well as object size and skin depth." width="599" height="449" class="alignnone size-full wp-image-261011" /><br />
<em>Plot of the ratio of computed losses versus the ratio of object size to skin depth.</em></p>
<p>We can conclude from the plot above that the <em>Impedance</em> boundary condition gives us an accurate prediction of total losses as long as the skin depth is relatively small compared to the dimensions of the conductors that we want to model. This is an important result, as it can significantly simplify a lot of our frequency-domain modeling within the AC/DC Module.</p>
<h3>Time-Domain Simulations for Conductors in Time-Varying Magnetic Fields</h3>
<p>Let’s finish up this topic by addressing time-domain simulations. The <em>Impedance</em> boundary condition is not available in this case, since this boundary condition is formulated based upon the frequency-domain form of Maxwell’s equations. For time-domain simulations, we must model and mesh the interior of all conductors. Boundary layer meshing is still appropriate, but you will want to adjust the thicknesses of the elements based on both the average and maximum expected frequency content of your time-domain excitations. This can sometimes lead to a much more computationally expensive model, of course, so try to model in the frequency domain as much as possible.</p>
<p>And what if you have materials that are nonlinear with respect to field strength or materials that you might think you have to model in the time domain? What do you do then? If you’re imagining a ferromagnetic material with a nonlinear magnetic permeability, you can still <a href="/blogs/model-magnetic-materials-in-the-frequency-domain-with-an-app/">model the magnetic material in the frequency domain</a> using the effective H-B curve functionality.</p>
<h3>Closing Remarks</h3>
<p>Having a good understanding of how to model conductive, lossy materials interacting with time-varying magnetic fields is important for effective use of the AC/DC Module. You can either explicitly model the conductive domains or model the conductors via the <em>Impedance</em> boundary condition at higher frequencies. If you do model the domains explicitly, you will need to use a boundary layer mesh to give a good resolution of the currents at higher frequencies, which does increase the computational requirements. If you use the <em>Impedance</em> boundary condition, you introduce an approximation, but you will not need to model the interior of the conductor domains at all, saving you significant computational resources. </p>
<h3>Next Steps</h3>
<p>To learn more about the specialized features and functionality for electromagnetics modeling available in the AC/DC Module, click the button below. </p>
<div class="flex-center">
<a href="/acdc-module" class="btn-solid btn-md btn-green">Show Me the AC/DC Module</a>
</div>
<h4>Additional Resources</h4>
<p>To work through a set of supplemental exercises on this topic, see the following tutorials:</p>
<ul>
<li><a href="/model/iron-sphere-in-a-60-hz-magnetic-field-12841">Iron Sphere in a 60 Hz Magnetic Field</a></li>
<li><a href="/model/iron-sphere-in-a-20-khz-magnetic-field-12831">Iron Sphere in a 20 kHz Magnetic Field</a></li>
<li><a href="/model/iron-sphere-in-a-13-56-mhz-magnetic-field-12835">Iron Sphere in a 13.56 MHz Magnetic Field</a></li>
<li><a href="/model/mutual-inductance-and-induced-currents-between-single-turn-coils-12653">Mutual Inductance and Induced Currents Between Single-Turn Coils</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>https://www.comsol.de/blogs/how-to-model-conductors-in-time-varying-magnetic-fields/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Common Pitfalls in Electrothermal Analysis</title>
		<link>https://www.comsol.de/blogs/common-pitfalls-in-electrothermal-analysis/</link>
		<comments>https://www.comsol.de/blogs/common-pitfalls-in-electrothermal-analysis/#comments</comments>
		<pubDate>Tue, 17 Apr 2018 08:18:04 +0000</pubDate>
		<dc:creator><![CDATA[Walter Frei]]></dc:creator>
				<category><![CDATA[AC/DC & Electromagnetics]]></category>
		<category><![CDATA[Electrical]]></category>
		<category><![CDATA[Electromagnetic Heating]]></category>
		<category><![CDATA[AC/DC Module]]></category>
		<category><![CDATA[Heat Transfer Module]]></category>
		<category><![CDATA[Technical Content]]></category>

		<guid isPermaLink="false">http://com.staging.comsol.com/blogs?p=256531</guid>
		<description><![CDATA[In applications such as power transfer and consumer electronics, it may be critical to model electromagnetic heating of materials that are nonlinear in temperature; that is, the material&#8217;s electrical conductivity and thermal conductivity vary with temperature. When modeling these nonlinearities, even an experienced analyst can sometimes get quite unexpected results due to the combination of the nonlinear material properties, boundary conditions, and geometry. Let’s find out why this is in terms of a very simple example. Understanding Ohm&#8217;s Law and [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>In applications such as power transfer and consumer electronics, it may be critical to model electromagnetic heating of materials that are nonlinear in temperature; that is, the material&#8217;s electrical conductivity and thermal conductivity vary with temperature. When modeling these nonlinearities, even an experienced analyst can sometimes get quite unexpected results due to the combination of the nonlinear material properties, boundary conditions, and geometry. Let’s find out why this is in terms of a very simple example.</p>
<p><span id="more-256531"></span></p>
<h3>Understanding Ohm&#8217;s Law and Resistive Heating</h3>
<p>One of the first physical laws that we learn as engineers is Ohm’s law: The current through a device equals the applied voltage difference divided by the device electrical resistance, or <em>I</em> = <em>V/R<sub>e</sub></em>, where the electrical resistance, <em>R<sub>e</sub></em>, is a function of the device geometry and material&#8217;s electrical conductivity.</p>
<p>Shortly after learning that law, we probably also learned about the dissipated power within the device, which equals the current times the voltage difference, or <em>Q</em> = <em>IV</em>, which we could also write as <em>Q</em> = <em>I<sup>2</sup>R<sub>e</sub></em> or <em>Q</em> = <em>V<sup>2</sup>/R<sub>e</sub></em>. Maybe a little bit later in our studies, we also learned about thermal conductivity and equivalent device thermal resistance, <em>R<sub>t</sub></em>, which let us compute, in a lumped sense, the rise in temperature of a device via Δ<em>T</em> = <em>QR<sub>t</sub></em> relative to ambient conditions. We can then determine the absolute device temperature using <img class="latexImg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKgAAAAWCAMAAABjVSeDAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLp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MlQxMTo1MzowMiswMTowMKakljcAAAAidEVYdHBzOkhpUmVzQm91bmRpbmdCb3gAMTAxeDEzKzI1NSs2Mza2dQG5AAAAJ3RFWHRwczpMZXZlbABBZG9iZUZvbnQtMS4wOiBDTU1JMTIgMDAzLjAwMgoxF5a7AAAASXRFWHRwczpTcG90Q29sb3ItMAAvZGV2L3NobS96ZjItY2FjaGUvODIwMmY1MzdlMGU5YTI5MDcxYmQ2MWYxMDkyNDY3OGEuZHZpIC1vB6S4OQAAAEV0RVh0cHM6U3BvdENvbG9yLTEAL2Rldi9zaG0vemYyLWNhY2hlLzgyMDJmNTM3ZTBlOWEyOTA3MWJkNjFmMTA5MjQ2NzhhLnBzh3nt6AAAAABJRU5ErkJggg==" />.</p>
<p>We start our discussion from this point and consider a completely lumped model of a device. (Yes, we’re starting so simple that we don’t even need to use the COMSOL Multiphysics® software for this part!) Let’s consider a lumped device with electrical resistance of <em>R<sub>e</sub></em> = 1 Ω and thermal resistance of <em>R<sub>t</sub></em> = 1 K/W. We can drive this device with either a constant voltage and compute the temperature as <img class="latexImg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAAAZCAMAAADwrLk8AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAADlQTFRF////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////AuJdXgAAABF0Uk5TADOImSIRd0TuZlWq3cy7P0611ilbAAAAAWJLR0QAiAUdSAAAAAlwSFlzAAAAeAAAAHgAnfVaYAAAAyNJREFUWMPtWImS2yAM5caAoeX/f7YCgQMYE6eT3cx2qpld2zwZHeiBHEL+y8eEMsbFp534SpGKEL3JT7vxhaIj/Iv60268TQw9hwjrGI9hYa5eVc/XWbKHmDfo/YVoKMk8b3563PBDg1nMBJpXDUHloTQBSxKclsRGmFR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TM1eDE1KzIzOCs2MzZVagguAAAAJ3RFWHRwczpMZXZlbABBZG9iZUZvbnQtMS4wOiBDTU1JMTIgMDAzLjAwMgoxF5a7AAAASXRFWHRwczpTcG90Q29sb3ItMAAvZGV2L3NobS96ZjItY2FjaGUvYzUyOWUzZDBiMmZjNGE5NDY4MzdlYWI1ZWVmNDcyMjAuZHZpIC1v8EZeVQAAAEV0RVh0cHM6U3BvdENvbG9yLTEAL2Rldi9zaG0vemYyLWNhY2hlL2M1MjllM2QwYjJmYzRhOTQ2ODM3ZWFiNWVlZjQ3MjIwLnBzUI2uaAAAAABJRU5ErkJggg==" /> or drive it via constant current where the peak temperature is <img class="latexImg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMEAAAAXCAMAAACF+9ucAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAADNQTFRF////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////8T5qHgAAAA90Uk5TADOImSIRd0TuZqpV3bvMj0JExgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAAAHgAAAB4AJ31WmAAAAJdSURBVFjD7VbbkqsgEOSOAyL//7c7M5g1gBLcpCrn4XRVYtKMzVxRIf7jk5BKafNtJ96BdUL4xX7bjTfgM35l/2033goB65Dl/fusOgAfMbwNluTkK10YKNu4eizOWeGCtyJmhTnQerTPtOF9eFKlqz4YSlJcXGN3xgb2LlNcRo22mTZ8hdgxUJpHomfmwfCPWM/FKWu4IcLKIY7GaNrwJVLH6IUDwNDiPgea9/ktjhiwwMfXwuXzo9N42vAPEaxUX7NkxIMp/aTqyT5nOfo8OZrThrciMJ3qzsgFXrOM0t1PjvoDcmT4mQigU2XGQvATLKN09wH1jJFhFfbs47SLQK89gxvrZGdYxjJ7Og4M9/PEhH7JPlJcqrqVy7G+dqqF0WnA2ue6fWQMzFKE+7NS/NbRcVHX8lw67rwaA5UHbNUcXXe7iy4ajQGEy6VUN27bRRdjgIbLgK1Eu+5+nuRTQwDnjAVtXXQSHOVGB1BG0AdPdRUjrhpcpT9ZVSG0EZyNAV9ysSS1lm1Eb48BFsZmCzZhgai0lJUVhA9gqDuobgpX0Zoq7huX2wiuxoB9VUWtY59EQW15VROvCYehyVbITViBb/MGE+O3MgY+FSorFfFkQoZWRSteRWBUQtWqjVTYmbQJZ4pay4oZjwexJBoVLCVeARNDefeB3yxpGvb0xN2qHYOTZ/IVIrrq0xnbid6MAL1OETgPGptoNU54bKzNiBDBSNpT8uomgTrJVIdNvLXZrtaiFb0HG7zSzomEwui12GjSkMO/AbAeOnoXeTXRyhbd3/d6qLV4U/TfwQ+hYxQuAm7YnQAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxOC0xMS0yMlQxMTo1MzowMiswMTowMNf5LosAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTgtMTEtMjJUMTE6NTM6MDIrMDE6MDCmpJY3AAAAInRFWHRwczpIaVJlc0JvdW5kaW5nQm94ADExNngxNCsyNDcrNjM3vYHsKQAAACd0RVh0cHM6TGV2ZWwAQWRvYmVGb250LTEuMDogQ01NSTEyIDAwMy4wMDIKMReWuwAAAEl0RVh0cHM6U3BvdENvbG9yLTAAL2Rldi9zaG0vemYyLWNhY2hlL2M1ZWQ4NDlkNjFkZmQ5YzEwN2VmNjA4YTA2ZGIxNWM5LmR2aSAtb5N4PnYAAABFdEVYdHBzOlNwb3RDb2xvci0xAC9kZXYvc2htL3pmMi1jYWNoZS9jNWVkODQ5ZDYxZGZkOWMxMDdlZjYwOGEwNmRiMTVjOS5wc2pICn8AAAAASUVORK5CYII=" />. </p>
<p>We choose an ambient temperature of 300 K, or 27°C, which is about room temperature. Let’s now plot out the device lumped temperature as a function of increasing voltage (from 0 to 10 V) and current (from 0 to 10 A), as shown in the image below. Unsurprisingly, we see a quadratic increase in temperature.</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/04/device-temperature-vs-applied-voltage-current-plots-.png" title="" alt="Side-by-side plots showing temperature as a function of applied voltage and current." width="727" height="300" class="alignnone size-full wp-image-256581" /><br />
<em>Device temperature as a function of applied voltage (left) and applied current (right), assuming constant properties.</em></p>
<p>We might think that we can use the curve to predict a wider range of operating conditions. Suppose we want to drive the device up to its failure temperature, where the material melts or vaporizes. Let’s say that this material will vaporize when its temperature gets up to 700 K (427°C). Based on this curve, some simple math would indicate that the maximum voltage is 20 V and the maximum current is 20 A, but this is quite wrong!</p>
<h3>Introducing Material Nonlinearities into the Simple Lumped Model</h3>
<p>At this point, you’re probably ready to point out the simple mistake that we’ve made: Electrical resistance is not constant with temperature. For most metals, the electrical conductivity goes down with an increasing temperature and since resistivity is the inverse of conductivity, the device resistivity goes up. So, let’s introduce a temperature dependence for the resistivity:</p>
<div class="latex">R_e = \rho_0(1+\alpha_e(T-T^e_0))</div>
<p>This is known as a <a href="https://en.wikipedia.org/wiki/Electrical_resistivity_and_conductivity#Linear_approximation" target="_blank">linearized resistivity model</a>, where <em>ρ</em><sub>0</sub> is the reference resistivity at <img class="latexImg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAWCAMAAAACYceEAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAADNQTFRF////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////8T5qHgAAAA90Uk5TAFWIEWZ3qkSZIjO73e7MUspd1wAAAAFiS0dEAIgFHUgAAAAJcEhZcwAAAHgAAAB4AJ31WmAAAACPSURBVCjPnZDBEsMgCERhMUHUxv//20Z0kh7ItNM9MOobXBai38VgXkfBrUQAERbZdhXifl41Z+sAl0V2x93OatB6/2vJcRtVtQyyepKM+spOjDLrxh8DlZ4eRp02kaZNpGkT6LuNQCGhTTWSI7LxmLVczwlHb2ORtDlBYIc/CDuJAsgYsYV7SjA8ZDa9Ot7/OQNvEhkGLQAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxOC0xMS0yMlQxMTo1MzowMiswMTowMNf5LosAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTgtMTEtMjJUMTE6NTM6MDIrMDE6MDCmpJY3AAAAIXRFWHRwczpIaVJlc0JvdW5kaW5nQm94ADE1eDEzKzI5OCs2MzYD03cNAAAAJ3RFWHRwczpMZXZlbABBZG9iZUZvbnQtMS4wOiBDTU1JMTIgMDAzLjAwMgoxF5a7AAAASXRFWHRwczpTcG90Q29sb3ItMAAvZGV2L3NobS96ZjItY2FjaGUvZWIyNTEwYTNiY2NlMDQwNDMyZTg1MjM5MzdkZTE5MWUuZHZpIC1vcjKxKQAAAEV0RVh0cHM6U3BvdENvbG9yLTEAL2Rldi9zaG0vemYyLWNhY2hlL2ViMjUxMGEzYmNjZTA0MDQzMmU4NTIzOTM3ZGUxOTFlLnBzfMcNOgAAAABJRU5ErkJggg==" />, the reference temperature, and <em>α<sub>e</sub></em> is the temperature coefficient of electrical resistivity.</p>
<p>Let’s choose <em>ρ</em><sub>0</sub> = 1 Ω, <img class="latexImg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAWCAMAAAACYceEAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAADNQTFRF////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////8T5qHgAAAA90Uk5TAFWIEWZ3qkSZIjO73e7MUspd1wAAAAFiS0dEAIgFHUgAAAAJcEhZcwAAAHgAAAB4AJ31WmAAAACPSURBVCjPnZDBEsMgCERhMUHUxv//20Z0kh7ItNM9MOobXBai38VgXkfBrUQAERbZdhXifl41Z+sAl0V2x93OatB6/2vJcRtVtQyyepKM+spOjDLrxh8DlZ4eRp02kaZNpGkT6LuNQCGhTTWSI7LxmLVczwlHb2ORtDlBYIc/CDuJAsgYsYV7SjA8ZDa9Ot7/OQNvEhkGLQAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxOC0xMS0yMlQxMTo1MzowMiswMTowMNf5LosAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTgtMTEtMjJUMTE6NTM6MDIrMDE6MDCmpJY3AAAAIXRFWHRwczpIaVJlc0JvdW5kaW5nQm94ADE1eDEzKzI5OCs2MzYD03cNAAAAJ3RFWHRwczpMZXZlbABBZG9iZUZvbnQtMS4wOiBDTU1JMTIgMDAzLjAwMgoxF5a7AAAASXRFWHRwczpTcG90Q29sb3ItMAAvZGV2L3NobS96ZjItY2FjaGUvZWIyNTEwYTNiY2NlMDQwNDMyZTg1MjM5MzdkZTE5MWUuZHZpIC1vcjKxKQAAAEV0RVh0cHM6U3BvdENvbG9yLTEAL2Rldi9zaG0vemYyLWNhY2hlL2ViMjUxMGEzYmNjZTA0MDQzMmU4NTIzOTM3ZGUxOTFlLnBzfMcNOgAAAABJRU5ErkJggg==" /> = 300 K, and <em>α<sub>e</sub></em> = 1/200 K. Now, the resistance is 1 Ω at a device temperature of 300 K and 2 Ω at a temperature rise of 200 K above the set temperature. The equations for lumped temperature as a function of voltage and current now become:</p>
<div class="latex">T = T_{ambient} + (V^2 /\rho_0(1+\alpha_e(T-T^e_0))) R_t</div>
<p>and</p>
<div class="latex">T = T_{ambient} + I^2 \rho_0(1+\alpha_e(T-T^e_0)) R_t</div>
<p>These equations are a bit more complicated (the first is a quadratic equation in terms of <em>T</em>) but still possible to solve by hand. The plots of temperature as a function of increasing voltage and current are displayed below.</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/04/simulation-results-temperature-applied-voltage-current.png" title="" alt="Side-by-side graphs plotting temperature and resistivity for an electrothermal analysis." width="728" height="300" class="alignnone size-full wp-image-256591" /><br />
<em>Device temperature as a function of applied voltage (left) and applied current (right) with the electrical resistivity as a function of temperature.</em></p>
<p>For the voltage-driven problem, as the temperature rises, the resistance rises. Since the resistance occurs in the denominator of the temperature expression, higher resistance lowers the temperature and we see that the temperature will be <em>lower</em> than that for the constant resistivity case. If we drive the device with constant current, the temperature-dependent resistance appears in the numerator. As we increase the current, the resistive heating will be <em>higher</em> than that for the linear material case.</p>
<p>We might be tempted at this point to compute the maximum voltage or current that this device can sustain, but you are probably already realizing the second mistake we’ve made: We also need to incorporate the temperature dependence of the thermal resistance. For metals, it’s reasonable to assume that the electrical and thermal conductivity will show the same trends. Thus, let’s use a nonlinear expression that is similar to what we used before:</p>
<div class="latex">R_t = r_0(1+\alpha_t(T-T^t_0)) </div>
<p>Now, our voltage-driven and current-driven equations for temperature become:</p>
<div class="latex">T = T_{ambient} + V^2 r_0(1+\alpha_t(T-T^t_0))/\rho_0(1+\alpha_e(T-T^e_0))</div>
<p>and</p>
<div class="latex">T = T_{ambient} + I^2 \rho_0(1+\alpha_e(T-T^e_0))/r_0(1+\alpha_t(T-T^t_0))</div>
<p>Although only slightly different from before, these nonlinear equations are now quite a bit more difficult to solve. Simulation software is starting to look more attractive! Once we do solve these equations (let&#8217;s set <em>r</em><sub>0</sub> = 1 K/W, <em>α<sub>t</sub></em> = 1/400 K, and <img class="latexImg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAMAAADzN3VRAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAADNQTFRF////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////8T5qHgAAAA90Uk5TABEiiLtEVWZ3qpnd7swzTsr24AAAAAFiS0dEAIgFHUgAAAAJcEhZcwAAAHgAAAB4AJ31WmAAAACTSURBVCjPnZHLEsMgCEV5iBit4f//thHbpJnB6bR34YKjHkSAH4K0IswrkiSuZzY+EfIVBUnXtrIJQrbjeqn1ptkc22iJ+FND6riNVQTsVTiiONZHdULQc7m1tJtCnKmJMjVRpibIdw2yMIaaRIA90uxjZmk/y8rdmo+rOIn+h/8g2Un0ABwttnBOysSLN5O8TzwB/fgDKC7LAV8AAAAldEVYdGRhdGU6Y3JlYXRlADIwMTgtMTEtMjJUMDk6MTA6NDArMDE6MDBYzsvCAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE4LTExLTIyVDA5OjEwOjQwKzAxOjAwKZNzfgAAACF0RVh0cHM6SGlSZXNCb3VuZGluZ0JveAAxNXgxNSsyOTgrNjM2cMkOhwAAACd0RVh0cHM6TGV2ZWwAQWRvYmVGb250LTEuMDogQ01NSTEyIDAwMy4wMDIKMReWuwAAAEl0RVh0cHM6U3BvdENvbG9yLTAAL2Rldi9zaG0vemYyLWNhY2hlLzkxYzE4OWNiMGMzOWE1YzllOWU1MzIwODFlMGMwNWIxLmR2aSAtb8kaYk8AAABFdEVYdHBzOlNwb3RDb2xvci0xAC9kZXYvc2htL3pmMi1jYWNoZS85MWMxODljYjBjMzlhNWM5ZTllNTMyMDgxZTBjMDViMS5wc8fwT0AAAAAASUVORK5CYII=" /> = 300 K), we can plot the device temperature, as shown below.</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/04/device-temperature-electrothermal-analysis.png" title="" alt="Two graphs showing electrical and thermal resistivity as a function of temperature, which is a function of voltage and current." width="729" height="300" class="alignnone size-full wp-image-256601" /><br />
<em>Device temperature as a function of applied voltage (left) and applied current (right) with the electrical and thermal resistivity as a function of temperature.</em></p>
<p>Observe that for the current-driven case, the temperature rises asymptotically. Since both the electrical and the thermal resistance increase with an increasing temperature, the device temperature rises very sharply as the current is increased. As the temperature rises to infinity, the problem becomes unsolvable. This is actually entirely expected; in fact, this is how your basic car fuse works. Now, if we were solving this problem in COMSOL Multiphysics, we could also solve this as a transient model (incorporating the thermal mass due to the device density and specific heat) and predict the time that it takes for the device temperature to rise to its failure point.</p>
<p>Things are luckily a bit simpler for the voltage-driven case. Here, we also see a predictable behavior: The rising thermal resistivity drives the temperature higher than when we only considered a temperature-dependent electrical conductivity. Now, the interesting point here is the temperature is still lower than for the constant resistivity case. This also sometimes confuses people, but just keep in mind that one of these nonlinearities is driving the temperature <em>down</em> while the other is driving the temperature <em>up</em>. In general, for a more complicated model (such as one you would build in COMSOL Multiphysics), you don&#8217;t know which nonlinearity will predominate.</p>
<p>What other mistake might we have made here? We have used a <em>positive</em> temperature coefficient of thermal resistivity. This is certainly true for most metals, but it turns out that the opposite is true for some insulators, glass being a common example. Usually, the total device thermal resistance is mostly a function of the insulators rather than the electrically conductive domains. In addition, the device&#8217;s thermal resistance should incorporate the effects of the cooling to the surrounding ambient environment. So, the effects of free convection (which increases with the temperature difference) and radiation (which has a fourth-order dependence on temperature difference) could also be lumped into this single thermal resistance. For now, though, let’s keep the problem (relatively) simple and just switch the sign of the temperature coefficient of thermal resistivity, <em>α<sub>t</sub></em> = -1/400 K, and directly compare the voltage- and current-driven cases for driving voltage up to 100 V and current up to 100 A.</p>
<p><img src="https://cdn.comsol.com/wordpress/2018/04/device-temperature-comsol-multiphysics-plot.png" title="" alt="A COMSOL Multiphysics® plot of device temperature under different conditions." width="600" height="300" class="alignnone size-full wp-image-256611" /><br />
<em>Device temperature as a function of applied voltage (pink) and applied current (blue) with a negative temperature coefficient of thermal resistivity.</em></p>
<p>We now see some results that are quite different. Observe that for both the voltage- and current-driven cases, the temperature increases approximately quadratically at low loads, but at higher loads, the temperature increase starts to flatten out due to the decreasing thermal resistivity. The slope, although always positive, decreases in magnitude. The current-driven case starts to asymptotically approach <em>T</em> = 700 K, but the voltage-driven case stays significantly below the failure temperature.</p>
<p>This is an important result and highlights another common mistake. The nonlinear material models we used here for electrical and thermal resistivity are <em>approximations</em> that start to become invalid if we get too close to 700 K. If we anticipate operating in this regime, we should go back to the literature and find a more sophisticated material model. Although our existing nonlinear material models did solve, we always need to check that they are still valid at the computed operating temperature. Of course, if we are not close to these operating conditions, we can use the linearized resistivity model (one of the built-in material models within COMSOL Multiphysics). Then, our model will be valid.</p>
<p>We can hopefully now see from all of this data that the temperature has a very complicated relationship with respect to the driving voltage or current. When nonlinear materials are considered, the temperature might be higher or lower than when using constant properties, and the slope of the temperature response can switch from quite steep to quite shallow just based on the operating conditions.</p>
<p>Have these results thoroughly confused you yet? What if we went back and changed one of the coefficients in the resistance expressions? Certain materials have negative temperature coefficients of electrical and thermal resistivity. What if we used an even more complicated nonlinearity? Would you feel confident in saying anything about the expected temperature variations in even this simple lumped device case, or would you rather check it against a rigorous calculation?</p>
<h3>Concluding Thoughts on Common Pitfalls in Electrothermal Analysis</h3>
<p>What about the case of a real-world device? One that has a combination of many different materials, different electrical and thermal conductivities as a function of temperature, and complex shapes? Would you model this under steady-state conditions only or in the time domain, to find out how long it takes for the temperature to rise? Maybe &mdash; in fact, most likely &mdash; there will also be nonlinear boundary conditions such as <a href="blogs/thermal-modeling-surfaces-wavelength-dependent-emissivity/">radiation</a> and <a href="/blogs/modeling-natural-and-forced-convection-in-comsol-multiphysics/">free convection</a> that we don&#8217;t want to approximate via a single lumped thermal resistance. What can you expect then? Almost anything! And how do you analyze it? Well, with COMSOL Multiphysics, of course!</p>
<h3>Next Step</h3>
<p>Evaluate how COMSOL Multiphysics can help you meet your multiphysics modeling and analysis goals. Contact us via the button below.</p>
<div class="flex-center">
<a href="/contact" class="btn-solid btn-md btn-orange">Contact COMSOL</a>
</div>
]]></content:encoded>
			<wfw:commentRss>https://www.comsol.de/blogs/common-pitfalls-in-electrothermal-analysis/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Should I Fillet the Geometry in My Electromagnetic Heating Analysis?</title>
		<link>https://www.comsol.de/blogs/should-i-fillet-the-geometry-in-my-electromagnetic-heating-analysis/</link>
		<comments>https://www.comsol.de/blogs/should-i-fillet-the-geometry-in-my-electromagnetic-heating-analysis/#comments</comments>
		<pubDate>Thu, 30 Nov 2017 16:50:32 +0000</pubDate>
		<dc:creator><![CDATA[Walter Frei]]></dc:creator>
				<category><![CDATA[AC/DC & Electromagnetics]]></category>
		<category><![CDATA[Electrical]]></category>
		<category><![CDATA[Electromagnetic Heating]]></category>
		<category><![CDATA[AC/DC Module]]></category>
		<category><![CDATA[Technical Content]]></category>

		<guid isPermaLink="false">http://com.staging.comsol.com/blogs?p=240901</guid>
		<description><![CDATA[To fillet or not to fillet, that is the question (that can bedevil the multiphysics analyst). When building finite element models, sharp edges can lead to local singularities and fields that are nonconvergent with mesh refinement. Rounding off these sharp edges by adding a fillet avoids this singularity. As it turns out, in many multiphysics models, these sharp edges and the resultant singularities do not necessarily negatively affect the results. Let’s find out more. Electromagnetic Heating Around Sharp Corners One [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>To fillet or not to fillet, that is the question (that can bedevil the multiphysics analyst). When building finite element models, sharp edges can lead to local singularities and fields that are nonconvergent with mesh refinement. Rounding off these sharp edges by adding a fillet avoids this singularity. As it turns out, in many multiphysics models, these sharp edges and the resultant singularities do not necessarily negatively affect the results. Let’s find out more.</p>
<p><span id="more-240901"></span></p>
<h3>Electromagnetic Heating Around Sharp Corners</h3>
<p>One of the most common problems solved with the <a href="/comsol-multiphysics">COMSOL Multiphysics® software</a> is that of electromagnetic heating, combining the solution to Maxwell’s equations, which solves for the current flow and resultant losses, and the solution to the heat transfer equation, which solves for the temperature distribution.</p>
<p>As mentioned in a <a href="/blogs/fillet-away-your-electromagnetic-field-singularities/">previous blog post</a>, when solving for the electromagnetic fields, sharp reentrant corners lead to locally nonconvergent electric fields and current density. Electromagnetic losses are the product of the electric field and current density, so the peak losses at a sharp corner will similarly go to infinity with mesh refinement.</p>
<p>However, the integral over the losses around the sharp corner will be convergent with respect to mesh refinement. This is one of the strengths of the <a href="/multiphysics/finite-element-method">finite element method</a>, which solves the governing equation in the so-called “weak form”, which satisfies the governing partial differential equations in an integral sense: minimizing the total error in the model, but allowing (possibly infinite!) local errors.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/11/Fillet-Electromagnetic-Heating-Problem-schematic1.png" title="" alt="A diagram showing a simple EM heating problem with a sharp corner." width="358" height="566" class="alignnone size-full wp-image-240991" /><br />
<em>A schematic of a simple electromagnetic heating problem with a singularity at the inside sharp corner.</em></p>
<p>Let’s review this concept with a simple example, as shown in the image above. A rectangular domain with a sharp notch has an electric potential difference applied, leading to current flow and resistive losses in the material.</p>
<p>Below, we see a color plot of the resistive losses and the mesh used for different levels of mesh refinement at the sharp inside corner. At the highest level of mesh refinement, the losses appear very localized around the sharp corner.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/11/electromagnetic-losses-in-three-meshes-in-COMSOL-Multiphysics.png" title="" alt="Three meshes of varying refinement showing the electromagnetic losses." width="447" height="240" class="alignnone size-full wp-image-240941" /><br />
<em>The electromagnetic losses on several different meshes.</em></p>
<p>At this sharp inside corner, the electric fields are actually theoretically infinitely large, since this geometry and the boundary conditions imply that the current must instantaneously change direction at a point. Also note that the sharp outside corners do not lead to singularities. As a consequence of the geometry and boundary conditions, the electric currents are not forced to change direction instantaneously at these points.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/11/Simulation-plot-EM-losses-for-different-meshes.png" title="" alt="A plot of the EM losses for three different meshes." width="445" height="316" class="alignnone size-full wp-image-240961" /><br />
<em>The resistive losses in log scale, plotted along a cut line, and a table of the integral of the losses for different meshes.</em></p>
<p>If we plot the losses at a cross-sectional line, as shown above, we can observe that the losses at the sharp point get larger and larger as the mesh is refined. However, the integral of the losses over the domain (roughly speaking, the area underneath the plotted curves) converges very quickly with mesh refinement.</p>
<p>Now let&#8217;s make this a multiphysics problem by additionally solving the heat transfer equation for the temperature distribution under steady-state conditions. These temperature fields are plotted below for several levels of mesh refinement, as well as the temperature at the sharp point.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/11/Temperature-fields-for-three-different-meshes-in-COMSOL-Multiphysics.png" title="" alt="A model with temperature fields for three different meshes." width="479" height="395" class="alignnone size-full wp-image-241001" /><br />
<em>The temperature field and a table of the temperature evaluated at the sharp corner for different levels of mesh refinement.</em></p>
<p>We can see from these results that the temperature at the singular point &mdash; and, of course, everywhere else &mdash; is also very insensitive to the mesh refinement. This is for two reasons. First, as we just saw, the total resistive losses are quite insensitive to the mesh. Second, the diffusive nature of the steady-state heat transfer governing equation will return very similar temperature solutions as long as the total heat loads are similar. The transient temperature solution, on the other hand, can predict very high local temperatures if the heat load is very high, but this is also a local and relative effect, albeit in time. That is, spikes in the heat load distribution in space will be smoothed out over time, and in the limit of very long simulation times, the transient solution will approach the steady state solution.  </p>
<h3>Closing Remarks</h3>
<p>What can we conclude from all of this information? If you are solving an electromagnetic heating problem and are only interested in computing the total electromagnetic losses and temperature distribution, you can usually avoid adding fillets to your model.</p>
<p>The advantages here are twofold. You do not need to go through the CAD modeling effort of adding any fillets to your geometry and you do not need an overly refined mesh in the sharp corners, which can save you the most valuable resource: time!</p>
<div class="flex-center">
<a href="/contact" class="btn-solid btn-md btn-red">Contact COMSOL for a Software Demonstration</a>
</div>
]]></content:encoded>
			<wfw:commentRss>https://www.comsol.de/blogs/should-i-fillet-the-geometry-in-my-electromagnetic-heating-analysis/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Which Turbulence Model Should I Choose for My CFD Application?</title>
		<link>https://www.comsol.de/blogs/which-turbulence-model-should-choose-cfd-application/</link>
		<comments>https://www.comsol.de/blogs/which-turbulence-model-should-choose-cfd-application/#comments</comments>
		<pubDate>Thu, 06 Jul 2017 12:00:03 +0000</pubDate>
		<dc:creator><![CDATA[Walter Frei]]></dc:creator>
				<category><![CDATA[Computational Fluid Dynamics (CFD)]]></category>
		<category><![CDATA[Fluid]]></category>
		<category><![CDATA[CFD Module]]></category>
		<category><![CDATA[Technical Content]]></category>

		<guid isPermaLink="false">http://com.dev.comsol.com/blogs/?p=17549</guid>
		<description><![CDATA[The COMSOL Multiphysics® software offers several different formulations for solving turbulent flow problems: the L-VEL, algebraic yPlus, Spalart-Allmaras, k-ε, k-ω, low Reynolds number k-ε, SST, and v2-f turbulence models. These formulations are available in the CFD Module, and the L-VEL, algebraic yPlus, k-ε, and low Reynolds number k-ε models are also available in the Heat Transfer Module. In this blog post, learn why to use these various turbulence models, how to choose between them, and how to use them efficiently. [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>The COMSOL Multiphysics® software offers several different formulations for solving turbulent flow problems: the L-VEL, algebraic yPlus, Spalart-Allmaras, k-ε, k-ω, low Reynolds number k-ε, SST, and v2-f turbulence models. These formulations are available in the CFD Module, and the L-VEL, algebraic yPlus, k-ε, and low Reynolds number k-ε models are also available in the Heat Transfer Module. In this blog post, learn why to use these various turbulence models, how to choose between them, and how to use them efficiently.</p>
<p><span id="more-17549"></span><br />
<em>This post was originally published in 2013. It has since been updated to include all of the turbulence models currently available with the CFD Module as of version 5.3 of the COMSOL® software.</em></p>
<h3>Introduction to Turbulence Modeling</h3>
<p>Let&#8217;s start by considering the fluid flow over a flat plate, as shown in the figure below. The uniform velocity profile hits the leading edge of the flat plate, and a laminar boundary layer begins to develop. The flow in this region is very predictable. After some distance, small chaotic oscillations begin to develop in the boundary layer and the flow begins to transition to turbulence, eventually becoming fully turbulent.</p>
<p><img src="https://cdn.comsol.com/wordpress/2013/09/Flow-of-a-fluid-over-a-flat-plate.png" title="" alt="Fluid flow over a flat plate." width="750" height="282" class="alignnone size-full wp-image-17557" /></p>
<p>The transition between these three regions can be defined in terms of the <a href="http://en.wikipedia.org/wiki/Reynolds_number" target="_blank">Reynolds number</a>, <img class="latexImg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAG4AAAAXCAMAAADdqIrAAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAADNQTFRF////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////8T5qHgAAA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/> is the fluid density; <img class="latexImg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAMBAMAAABPbPrXAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAC1QTFRF////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////wISVsgAAAA10Uk5TABF3iCJVqplmM0TMu4jOSYoAAAABYktHRACIBR1IAAAACXBIWXMAAAB4AAAAeACd9VpgAAAAQ0lEQVQI12NgwARCJgxhYIaBOUMviOZckMzADWJwsVxhYAZLMW2AMngMGFaCGbwBDA1gBncA1wIwg/VUKNRELgEQCQCMUghH/oaoXQAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxOC0xMS0yMVQyMzowNzo0MiswMTowMB76CCsAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTgtMTEtMjFUMjM6MDc6NDIrMDE6MDBvp7CXAAAAH3RFWHRwczpIaVJlc0JvdW5kaW5nQm94ADl4NyszMDErNjM5sXcjOgAAACd0RVh0cHM6TGV2ZWwAQWRvYmVGb250LTEuMDogQ01NSTEyIDAwMy4wMDIKMReWuwAAAEl0RVh0cHM6U3BvdENvbG9yLTAAL2Rldi9zaG0vemYyLWNhY2hlLzllMzY2OWQxOWI2NzViZDU3MDU4ZmQ0NjY0MjA1ZDJhLmR2aSAtbxwkkTcAAABFdEVYdHBzOlNwb3RDb2xvci0xAC9kZXYvc2htL3pmMi1jYWNoZS85ZTM2NjlkMTliNjc1YmQ1NzA1OGZkNDY2NDIwNWQyYS5wc3gJwl0AAAAASUVORK5CYII=" /> is the velocity; <img class="latexImg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAARCAMAAADqmnyMAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAADNQTFRF////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////8T5qHgAAAA90Uk5TAGaIRDOZ7t2qIncRzFW7cExCXQAAAAFiS0dEAIgFHUgAAAAJcEhZcwAAAHgAAAB4AJ31WmAAAABGSURBVBjTY2AgETAygQC6KDM/Exal/CyYgqxsWAxl58AU4+TnopWR3IxYjGTixjSSmxXTSE4eXoQQEx8/HzA4+PixOQEOAMccAY/0WU+nAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE4LTExLTIxVDIzOjU5OjM4KzAxOjAw39HCjQAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxOC0xMS0yMVQyMzo1OTozOCswMTowMK6MejEAAAAhdEVYdHBzOkhpUmVzQm91bmRpbmdCb3gAMTJ4MTArMzAwKzYzOW9xrmsAAAAndEVYdHBzOkxldmVsAEFkb2JlRm9udC0xLjA6IENNTUkxMiAwMDMuMDAyCjEXlrsAAABJdEVYdHBzOlNwb3RDb2xvci0wAC9kZXYvc2htL3pmMi1jYWNoZS9kMjBjYWVjM2I0OGExZWVmMTY0Y2I0Y2E4MWJhMjU4Ny5kdmkgLW/qcgAvAAAARXRFWHRwczpTcG90Q29sb3ItMQAvZGV2L3NobS96ZjItY2FjaGUvZDIwY2FlYzNiNDhhMWVlZjE2NGNiNGNhODFiYTI1ODcucHMkemfAAAAAAElFTkSuQmCC" /> is the characteristic length (in this case, the distance from the leading edge); and <img class="latexImg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAARBAMAAAAidOHKAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAACpQTFRF////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////5u1vmAAAAAx0Uk5TAFWIdxGZRN1muyKq/nLKGQAAAAFiS0dEAIgFHUgAAAAJcEhZcwAAAHgAAAB4AJ31WmAAAABZSURBVAjXY2DADoQYGEwgrFAGtgMQVgUD0wQwg+sUA6cCmMVRwMAjAGaxBjDkQJSxKzBocoBZaxRYipjArPZpEtKGEOPYFnAtgBoHBUDjoIC5AMZiWYDuIgC52gvjlo+D2AAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxOC0xMS0yMVQyMzoyOToyNCswMTowMP3gveQAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTgtMTEtMjFUMjM6Mjk6MjQrMDE6MDCMvQVYAAAAIXRFWHRwczpIaVJlc0JvdW5kaW5nQm94ADExeDEwKzMwMCs2MzaIUGEKAAAAJ3RFWHRwczpMZXZlbABBZG9iZUZvbnQtMS4wOiBDTU1JMTIgMDAzLjAwMgoxF5a7AAAASXRFWHRwczpTcG90Q29sb3ItMAAvZGV2L3NobS96ZjItY2FjaGUvYzlmYWY2ZWFkMmNkMmMyMTg3YmQ5NDM0ODhkZTFkMGEuZHZpIC1vNdoejQAAAEV0RVh0cHM6U3BvdENvbG9yLTEAL2Rldi9zaG0vemYyLWNhY2hlL2M5ZmFmNmVhZDJjZDJjMjE4N2JkOTQzNDg4ZGUxZDBhLnBzW0FixgAAAABJRU5ErkJggg==" /> is the fluid&#8217;s dynamic viscosity. We will assume that the fluid is <em>Newtonian</em>, meaning that the viscous stress is directly proportional, with the dynamic viscosity as the constant of proportionality, to the shear rate. This is true, or very nearly so, for a wide range of fluids of engineering importance, such as air or water. Density can vary with respect to pressure, although it is here assumed that the fluid is only weakly compressible, meaning that the <a href="http://en.wikipedia.org/wiki/Mach_number" target="_blank">Mach number</a> is less than about 0.3. The weakly compressible flow option for the fluid flow interfaces in COMSOL Multiphysics neglects the influence of pressure waves on the flow and pressure fields.</p>
<p>In the laminar regime, the fluid flow can be completely predicted by solving <a href="/multiphysics/navier-stokes-equations">Navier-Stokes equations</a>, which gives the velocity and the pressure fields. Let us first assume that the velocity field does not vary with time. An example of this is outlined in <a href="/model/the-blasius-boundary-layer-13911">The Blasius Boundary Layer</a> tutorial model. As the flow begins to transition to turbulence, oscillations appear in the flow, despite the fact that the inlet flow rate does not vary with time. It is then no longer possible to assume that the flow is invariant with time. In this case, it is necessary to solve the time-dependent Navier-Stokes equations, and the mesh used must be fine enough to resolve the size of the smallest eddies in the flow. Such a situation is demonstrated in the <a href="/model/flow-past-a-cylinder-97">Flow Past a Cylinder</a> tutorial model. Note that the flow is unsteady, but still laminar in this model. Steady-state and time-dependent laminar flow problems do not require any modules and can be solved with COMSOL Multiphysics alone.</p>
<p><img src="https://cdn.comsol.com/wordpress/2013/09/Using-a-Reynolds-Averaged-Navier-Stokes-formulation.png" title="" alt="Modeling fluid flow with a Reynolds-averaged Navier-Stokes (RANS) formulation." width="750" height="254" class="alignnone size-full wp-image-17561" /></p>
<p>As the flow rate &mdash; and thus also the Reynolds number &mdash; increases, the flow field exhibits small eddies and the spatial and temporal scales of the oscillations become so small that it is computationally unfeasible to resolve them using the Navier-Stokes equations, at least for most practical cases. In this flow regime, we can use a Reynolds-averaged Navier-Stokes (RANS) formulation, which is based on the observation that the flow field (u) over time contains small, local oscillations (u&#8217;) and can be treated in a time-averaged sense (U). For one- and two-equation models, additional transport equations are introduced for turbulence variables, such as the turbulence kinetic energy (k in k-ε and k-ω).</p>
<p>In algebraic models, algebraic equations that depend on the velocity field &mdash; and, in some cases, on the distance from the walls &mdash; are introduced in order to describe the turbulence intensity. From the estimates for the turbulence variables, an eddy viscosity that adds to the molecular viscosity of the fluid is calculated. The momentum that would be transferred by the small eddies is instead translated to a viscous transport. Turbulence dissipation usually dominates over viscous dissipation everywhere, except for in the viscous sublayer close to solid walls. Here, the turbulence model has to continuously reduce the turbulence level, such as in low Reynolds number models. Or, new boundary conditions have to be computed using wall functions.</p>
<h3>Low Reynolds Number Models</h3>
<p>The term &#8220;low Reynolds number model&#8221; sounds like a contradiction, since flows can only be turbulent if the Reynolds number is high enough. The notation “low Reynolds number” does not refer to the flow on a global scale, but to the region close to the wall where viscous effects dominate; i.e., the viscous sublayer in the figure above. A low Reynolds number model is a model that correctly reproduces the limiting behaviors of various flow quantities as the distance to the wall approaches zero. So, a low Reynolds number model must, for example, predict that <em>k</em>~<em>y</em><sup>2</sup> as <em>y</em>→0. Correct limiting behavior means that the turbulence model can be used to model the whole boundary layer, including the viscous sublayer and the buffer layer.</p>
<p>Most ω-based models are low Reynolds number models by construction. But the standard k-ε model and other commonly encountered k-ε models are <em>not</em> low Reynolds number models. Some of them can, however, be supplemented with so-called damping functions that give the correct limiting behavior. They are then known as low Reynolds number k-ε models.</p>
<p>Low Reynolds number models often give a very accurate description of the boundary layer. The sharp gradients close to walls do, however, require very high mesh resolutions and that, in turn, means that the high accuracy comes at a high computational cost. This is why alternative methods to model the flow close to walls are often employed for industrial applications.</p>
<h3>Wall Functions</h3>
<p>The turbulent flow near a flat wall can be divided into four regions. At the wall, the fluid velocity is zero, and in a thin layer above this, the flow velocity is linear with distance from the wall. This region is called the <em>viscous sublayer</em>, or <a href="http://en.wikipedia.org/wiki/Laminar_sublayer" target="_blank">laminar sublayer</a>. Further away from the wall is a region called the <em>buffer layer</em>. In the buffer region, turbulence stresses begin to dominate over viscous stresses and it eventually connects to a region where the flow is fully turbulent and the average flow velocity is related to the log of the distance to the wall. This is known as the <a href="http://en.wikipedia.org/wiki/Law_of_the_wall" target="_blank"><em>log-law region</em></a>. Even further away from the wall, the flow transitions to the <em>free-stream region</em>. The viscous and buffer layers are very thin and if the distance to the end of the buffer layer is <img class="latexImg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAMAAAAMs7fIAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAADNQTFRF////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////8T5qHgAAAA90Uk5TAFW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FsMgCADBH/iL979tUWPUmi7LavCNgijAXwMHqBfSxhbzmMaNVdKMOwGIR3QfYHzoLsaaho0k4taC6y63SkGvJGH9i5ua4XglCUrqdAuNZBJA9jEeLnVDLjpJumakcv1yy0KQozQQ7C83LgTMo8DmYtF3MglSJXOcC/11nF2ISgN/uLZP1S+kqpsTHi7V2WDKK0XR/PMbwHBKbOpWzxldG/xDytE11e2/+St/E40GPk+yBkCe4/opAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE4LTExLTIyVDA1OjM2OjU0KzAxOjAwr+OfMgAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxOC0xMS0yMlQwNTozNjo1NCswMTowMN6+J44AAAAhdEVYdHBzOkhpUmVzQm91bmRpbmdCb3gAMjZ4MTArMjkzKzYzORdl2XYAAAAmdEVYdHBzOkxldmVsAEFkb2JlRm9udC0xLjA6IENNUjEyIDAwMy4wMDIK7bPeSwAAAEl0RVh0cHM6U3BvdENvbG9yLTAAL2Rldi9zaG0vemYyLWNhY2hlLzY4MGQ3MWI3YjE0ZWIxY2I3NzhkOTc5YmQ5MTYwNjI3LmR2aSAtb9qVecgAAABFdEVYdHBzOlNwb3RDb2xvci0xAC9kZXYvc2htL3pmMi1jYWNoZS82ODBkNzFiN2IxNGViMWNiNzc4ZDk3OWJkOTE2MDYyNy5wcySfcQkAAAAASUVORK5CYII=" /> away from the wall.</p>
<p><img src="https://cdn.comsol.com/wordpress/2013/09/Four-regimes-of-tubulent-flow.png" title="" alt="The four regions of turbulent flow: the viscous sublayer, buffer layer, log-law region, and free-stream flow region." width="700" height="326" class="alignnone size-full wp-image-17577" /></p>
<p>It is possible to use a RANS model to compute the flow field in all four of these regions. However, since the thickness of the buffer layer is so small, it can be advantageous to use an approximation in this region. Wall functions ignore the flow field in the buffer region and analytically compute a nonzero fluid velocity at the wall. By using a wall function formulation, you assume an analytic solution for the flow in the viscous layer and the resultant models will have significantly lower computational requirements. This is a very useful approach for many practical engineering applications.</p>
<p><img src="https://cdn.comsol.com/wordpress/2013/09/Implementing-a-wall-function-formulation.png" title="" alt="Using a wall function formulation in a turbulence model." width="650" height="320" class="alignnone size-full wp-image-17559" /></p>
<p>If you need a level of accuracy beyond what the wall function formulations provide, then you will want to consider a turbulence model that solves the entire flow regime as described for the low Reynolds number models above. For example, you may want to compute <a href="/blogs/how-do-i-compute-lift-and-drag/">lift and drag</a> on an object or compute the heat transfer between the fluid and the wall.</p>
<h3>Automatic Wall Treatment</h3>
<p>The <a href="/blogs/why-should-i-use-automatic-wall-treatment-for-my-cfd-modeling/">automatic wall treatment functionality</a>, which is new in COMSOL Multiphysics version 5.3, combines benefits from both wall functions and low Reynolds number models. Automatic wall treatment adapts the formulation to the mesh available in the model so that you get both robustness and accuracy. For instance, for a coarse boundary layer mesh, the feature will utilize a robust wall function formulation. However, for a dense boundary layer mesh, the automatic wall treatment will use a low Reynolds number formulation to resolve the velocity profile completely to the wall.</p>
<p>Going from a low Reynolds number formulation to a wall function formulation is a smooth transition. The software blends the two formulations in the boundary elements. Then, the software calculates the wall distance of the boundary elements&#8217; grid points (this is in viscous units given by a liftoff). The combined formulations are then used for the boundary conditions.</p>
<p>All turbulence models in COMSOL Multiphysics, except the k-ε model, support automatic wall treatment. This means that the low Reynolds number models can be used for industrial applications and that their low Reynolds number modeling capability is only invoked when the mesh is fine enough.</p>
<h3>About the Various Turbulence Models</h3>
<p>The eight RANS turbulence models differ in how they model the flow close to walls, the number of additional variables solved for, and what these variables represent. All of these models augment the Navier-Stokes equations with an additional turbulence eddy viscosity term, but they differ in how it is computed.</p>
<h4>L-VEL and yPlus</h4>
<p>The L-VEL and algebraic yPlus turbulence models compute the eddy viscosity using algebraic expressions based only on the local fluid velocity and the distance to the closest wall. They do not solve any additional transport equations. These models solve for the flow everywhere and are the most robust and least computationally intensive of the eight turbulence models. While they are generally the least accurate models, they do provide good approximations for internal flow, especially in electronic cooling applications.</p>
<h4>Spalart-Allmaras</h4>
<p>The Spalart-Allmaras model adds a single additional variable for an undamped kinematic eddy viscosity. It is a low Reynolds number model and can resolve the entire flow field down to the solid wall. The model was originally developed for aerodynamics applications and is advantageous in that it is relatively robust and has moderate resolution requirements. Experience shows that this model does not accurately compute fields that exhibit shear flow, separated flow, or decaying turbulence. Its advantage is that it is quite stable and shows good convergence.</p>
<h4>k-ε</h4>
<p>The k-ε model solves for two variables: k, the turbulence kinetic energy; and ε (epsilon), the rate of dissipation of turbulence kinetic energy. Wall functions are used in this model, so the flow in the buffer region is not simulated. The k-ε model has historically been very popular for industrial applications due to its good convergence rate and relatively low memory requirements. It does not very accurately compute flow fields that exhibit adverse pressure gradients, strong curvature to the flow, or jet flow. It does perform well for external flow problems around complex geometries. For example, the k-ε model can be used to solve for the <a href="/model/airflow-over-an-ahmed-body-8565">airflow around a bluff body</a>.</p>
<p>The turbulence models listed below are all more nonlinear than the k-ε model and they can often be difficult to converge unless a good initial guess is provided. The  k-ε model can be used to provide a good initial guess. Just solve the model using the k-ε model and then use the new <em>Generate New Turbulence Interface</em> functionality, available in the <a href="/release/5.3/cfd-module">CFD Module with COMSOL Multiphysics version 5.3</a>.</p>
<h4>k-ω</h4>
<p>The k-ω model is similar to the k-ε model, but it solves for ω (omega) &mdash; the specific rate of dissipation of kinetic energy. It is a low Reynolds number model, but it can also be used in conjunction with wall functions. It is more nonlinear, and thereby more difficult to converge than the k-ε model, and it is quite sensitive to the initial guess of the solution. The k-ω model is useful in many cases where the k-ε model is not accurate, such as internal flows, flows that exhibit strong curvature, separated flows, and jets. A good example of internal flow is <a href="/model/flow-in-a-pipe-elbow-12221">flow through a pipe bend</a>.</p>
<h4>Low Reynolds Number k-ε</h4>
<p>The low Reynolds number k-ε model is similar to the k-ε model, but does not need wall functions: it can solve for the flow everywhere. It is a logical extension of the k-ε model and shares many of its advantages, but generally requires a denser mesh; not only at walls, but everywhere its low Reynolds number properties kick in and dampen the turbulence. It can sometimes be useful to use the k-ε model to first compute a good initial condition for solving the low Reynolds number k-ε model. An alternative way is to use the automatic wall treatment and start with a coarse boundary layer mesh to get wall functions and then refine the boundary layer at the interesting walls to get the low Reynolds number models.</p>
<p>The low Reynolds number k-ε model can compute lift and drag forces and heat fluxes can be modeled with higher accuracy compared to the k-ε model. It has also shown to predict separation and reattachment quite well for a number of cases.</p>
<h4>SST</h4>
<p>The SST model is a combination of the k-ε model in the free stream and the k-ω model near the walls. It is a low Reynolds number model and kind of the &#8220;go to&#8221; model for industrial applications. It has similar resolution requirements to the k-ω model and the low Reynolds number k-ε model, but its formulation eliminates some weaknesses displayed by pure k-ω and k-ε models. In a tutorial model example, the SST model solves for flow over a <a href="/model/naca-0012-airfoil-14629">NACA 0012 Airfoil</a>. The results are shown to compare well with experimental data.</p>
<h4>v2-f</h4>
<p>Close to wall boundaries, the fluctuations of the velocity are usually much larger in the parallel directions to the wall in comparison with the direction perpendicular to the wall. The velocity fluctuations are said to be anisotropic. Further away from the wall, the fluctuations are of the same magnitude in all directions. The velocity fluctuations become isotropic.</p>
<p>The v2-f turbulence model describes the anisotropy of the turbulence intensity in the turbulent boundary layer using two new equations, in addition to the two equations for turbulence kinetic energy (k) and dissipation rate (ε). The first equation describes the transport of turbulent velocity fluctuations normal to the streamlines. The second equation accounts for nonlocal effects such as the wall-induced damping of the redistribution of turbulence kinetic energy between the normal and parallel directions. </p>
<p>You should use this model for enclosed flows over curved surfaces, for example, to <a href="/blogs/how-to-use-the-v2-f-turbulence-model-in-the-cfd-module/">model cyclones</a>.</p>
<h3>Meshing Considerations for CFD Problems</h3>
<p>Solving for any kind of fluid flow problem &mdash; laminar or turbulent &mdash; is computationally intensive. Relatively fine meshes are required and there are many variables to solve for. Ideally, you would have a very fast computer with many gigabytes of RAM to solve such problems, but simulations can still take hours or days for larger 3D models. Therefore, we want to use as simple a mesh as possible, while still capturing all of the details of the flow.</p>
<p>Referring back to the figure at the top of this blog post, we can observe that for the flat plate (and for most flow problems), the velocity field changes quite slowly in the direction tangential to the wall, but quite rapidly in the normal direction, especially if we consider the buffer layer region. This observation motivates the use of a boundary layer mesh. Boundary layer meshes (which are the default mesh type on walls when using our physics-based meshing) insert thin rectangles in 2D or triangular prisms in 3D at the walls. These high-aspect-ratio elements will do a good job of resolving the variations in the flow speed normal to the boundary, while reducing the number of calculation points in the direction tangential to the boundary.</p>
<p><img src="https://cdn.comsol.com/wordpress/2013/09/Boundary-layer-mesh.png" title="" alt="Boundary layer mesh in a 2D mesh." width="650" height="393" class="alignnone size-full wp-image-17581" /><br />
<em>The boundary layer mesh (magenta) around an airfoil and the surrounding triangular mesh (cyan) for a 2D mesh.</em></p>
<p><img src="https://cdn.comsol.com/wordpress/2013/09/Tetrahedral-boundary-layer-mesh.png" title="" alt="Tetrahedral boundary layer mesh for a 3D volumetric mesh." width="550" height="412" class="alignnone size-full wp-image-17583" /><br />
<em>The boundary layer mesh (magenta) around a bluff body and the surrounding tetrahedral mesh (cyan) for a 3D volumetric mesh.</em></p>
<h3>Evaluating the Results of Your Turbulence Model</h3>
<p>Once you&#8217;ve used one of these turbulence models to solve your flow simulation, you will want to verify that the solution is accurate. Of course, as you do with any finite element model, you can simply run it with finer and finer meshes and observe how the solution changes with increasing mesh refinement. Once the solution does not change to within a value you find acceptable, your simulation can be considered converged with respect to the mesh. However, there are additional values you need to check when modeling turbulence.</p>
<p>When using wall function formulations, you will want to check the <em>wall resolution viscous units</em> (this plot is generated by default). This value tells you how far into the boundary layer your computational domain starts and should not be too large. You should consider refining your mesh in the wall normal direction if there are regions where the wall resolution exceeds several hundred. The second variable that you should check when using wall functions is the <em>wall liftoff</em> (in length units). This variable is related to the assumed thickness of the viscous layer and should be small relative to the surrounding dimensions of the geometry. If it is not, then you should refine the mesh in these regions as well.</p>
<p><img src="https://cdn.comsol.com/wordpress/2013/09/wall-function-formulations.png" title="" alt="Using wall function formulations to evaluate the results of a turbulence model." width="600" height="449" class="alignnone size-full wp-image-17597" /><br />
<em>The maximum wall liftoff in viscous units is less than 100, so there is no need to refine the boundary layer mesh.</em></p>
<p>When solving a model using low Reynolds number wall treatment, check the <em>dimensionless distance to cell center</em> (also generated by default). This value should be of order unity everywhere for the algebraic models and less than 0.5 for all two-equation models and the v2-f model. If it is not, then refine the mesh in these regions.</p>
<h3>Concluding Thoughts</h3>
<p>In this blog post, we have discussed the various turbulence models available in COMSOL Multiphysics, highlighting when and why you should use each one of them. The real strength of the COMSOL® software is when you want to combine your fluid flow simulations with other physics, such as finding stresses on a solar panel in high winds, <a href="/model/shell-and-tube-heat-exchanger-12685">forced convection modeling in a heat exchanger</a>, or <a href="/model/turbulent-mixing-of-a-trace-species-12727">mass transfer in a mixer</a>, among other possibilities.</p>
<div class="flex-center"> <a href="/contact" class="btn-solid btn-md btn-orange">Contact COMSOL to Evaluate the Software</a> </div>
<p>If you are interested in using the COMSOL® software for your CFD and multiphysics simulations, or if you have a question that isn&#8217;t addressed here, please contact us.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.comsol.de/blogs/which-turbulence-model-should-choose-cfd-application/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>How to Use Model Methods to Accelerate Your COMSOL® Workflow</title>
		<link>https://www.comsol.de/blogs/how-to-use-model-methods-to-accelerate-your-comsol-workflow/</link>
		<comments>https://www.comsol.de/blogs/how-to-use-model-methods-to-accelerate-your-comsol-workflow/#comments</comments>
		<pubDate>Thu, 22 Jun 2017 08:02:51 +0000</pubDate>
		<dc:creator><![CDATA[Walter Frei]]></dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Modeling Tools]]></category>
		<category><![CDATA[Technical Content]]></category>

		<guid isPermaLink="false">http://com.staging.comsol.com/blogs?p=224461</guid>
		<description><![CDATA[Do you ever find yourself performing the same modeling operations over and over again in each new model file that you work with? Or do you work with colleagues who send you model files that you have to manually add physics and features to? If so, you can greatly accelerate your workflow by using model methods, new in version 5.3 of the COMSOL Multiphysics® software. Let’s find out how. Manually Creating a Model Method in COMSOL Multiphysics® As we saw [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Do you ever find yourself performing the same modeling operations over and over again in each new model file that you work with? Or do you work with colleagues who send you model files that you have to manually add physics and features to? If so, you can greatly accelerate your workflow by using model methods, new in version 5.3 of the COMSOL Multiphysics® software. Let’s find out how.</p>
<p><span id="more-224461"></span></p>
<h3>Manually Creating a Model Method in COMSOL Multiphysics®</h3>
<p>As we saw in a previous blog post on <a href="/blogs/how-to-create-a-randomized-geometry-using-model-methods/">creating randomized geometries</a>, you can use the <em>Record Method</em> functionality to record a series of operations that you’re performing within the COMSOL Multiphysics graphical user interface (GUI) and then replay that method to reproduce those same steps. Of course, this doesn’t do us any good if we have already created the file &mdash; we don’t want to go back and rerecord the entire file. As it turns out, though, COMSOL Multiphysics automatically keeps a history of everything that you’ve done in a model file as Java® code. We can just extract the relevant operations directly from this code and insert them into a new model method.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/06/Compact-History-option-in-COMSOL-Multiphysics.png" title="" alt="A screenshot of the COMSOL Multiphysics GUI with the Compact History option highlighted." width="301" height="425" class="alignnone size-full wp-image-224501" /><br />
<em>The</em> Compact History <em>option.</em></p>
<p>To extract all of the history of all operations within a file, there are a few steps you need to take. First, go to the <em>File</em> menu and choose the <em>Compact History</em> option. We do this because COMSOL Multiphysics keeps a history of all commands, but we only want the minimum set of commands that were used to generate the existing model. Next, go to <em>File Menu</em> &gt; <em>Save As</em> and save to a <em>Model File for Java</em> file type. You now have a text file that contains Java® code. Try this out yourself and open the resulting file in a text editor. This file always has lines of code at the beginning and end that are similar to what is shown below:</p>
<pre>/*example_model.java */
import com.comsol.model.*;
import com.comsol.model.util.*;
public class example_model {
  public static Model run() {
    Model model = ModelUtil.create("Model");
    model.modelPath("C:\\Temp");
    model.label("example_model.mph");
    model.comments("This is an example model");
         ...
         ... /* Lines of code describing the model contents */
         ...
     return model;
 }
 public static void main(String[] args) { run();}
}</pre>
<p>The above code snippet shows us what we can remove. Only the code between the <code>Model model = ModelUtil.create("Model");</code> and <code>return model;</code> is used to define all of the features within the model. In fact, we can also remove the <code>model.modelPath();</code>, <code>model.label();</code>, and <code > model.comments();</code> lines. Go ahead and remove all of these lines of code in your text editor and you are left with just the set of commands needed to reproduce the model in a model method. </p>
<p>Next, open a new blank model file, go to the Application Builder, and create a new model method. Copy all of the lines from your edited Java® file into this new model method. Then, switch back to the Model Builder, go to the <em>Developer</em> tab, and choose <em>Run Model Method</em> to run this code. Running this model method reproduces all of the steps from your original file, including solving the model. Solving the model may take a long time, so we often want to trim our model method.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/06/model-method-in-the-Application-Builder.png" title="" alt="A zoomed-in screenshot of the Application Builder showing a model method." width="600" height="230" class="alignnone size-full wp-image-224511" /><br />
<em>A model method within the Application Builder.</em></p>
<h3>Trimming the Model Method</h3>
<p>There are two approaches that you can take for trimming down the code. The first is to manually edit the Java® code itself, pruning out any code that you don’t want to rerun. It’s helpful to have the <em>COMSOL Programming Reference Manual</em> handy if you’re going to do this, because you may need to know what every line does before you delete it. The second, simpler approach is to delete the features directly within the COMSOL Multiphysics GUI. Start with a copy of your original model file and delete everything that you don’t want to appear within the method. You can delete the geometry sequence, mesh, study steps, results visualizations, and anything else that you don’t want to reproduce.</p>
<p>Let’s take a look at a quick example of this. Suppose that you’ve built a model that simulates thermal curing and you want to include this thermal curing simulation in other existing models that already have the heat transfer simulations set up.</p>
<p>As we saw in a previous blog post, <a href="/blogs/modeling-the-thermal-curing-process/">modeling thermal curing</a> in addition to heat transfer requires three steps:</p>
<ol>
<li>Defining a set of material parameters</li>
<li>Adding a <em>Domain ODE</em> interface to model the evolution of the cure over time</li>
<li>Coupling the heat of reaction from the curing into the thermal problem</li>
</ol>
<p>We can build a model in the GUI that contains just these steps and then write out the Java® file. Of course, we still need to do some manual editing, and it’s also helpful to go through the <em>Application Programming Guide</em> to get an introduction to the basics. But once you’re comfortable with all of the syntax, you’ll see that the above three steps within the GUI can be written in the model method shown here:</p>
<pre>model.param().set("H_r", "500[kJ/kg]", "Total Heat of Reaction");
model.param().set("A", "200e3[1/s]", "Frequency Factor");
model.param().set("E_a", "150[kJ/mol]", "Activation Energy");
model.param().set("n", "1.4", "Order of Reaction");
model.component("comp1").physics("ht").create("hsNEW", "HeatSource");
model.component("comp1").physics("ht").feature("hsNEW").selection().all();
model.component("comp1").physics("ht").feature("hsNEW").set("Q0", "-ht.rho*H_r*d(alpha,t)");
model.component("comp1").physics().create("dode", "DomainODE", "geom1");
model.component("comp1").physics("dode").field("dimensionless").field("alpha");
model.component("comp1").physics("dode").field("dimensionless").component(new String[]{"alpha"});
model.component("comp1").physics("dode").prop("Units").set("SourceTermQuantity", "frequency");
model.component("comp1").physics("dode").feature("dode1").set("f", "A*exp(-E_a/R_const/T)*(1-alpha)^n");</pre>
<p>The first four lines of this code snippet define an additional set of global parameters. The next three lines add a <em>Heat Source</em> domain feature to an existing <em>Heat Transfer</em> interface (with the tag <em>ht</em>), define the heat source term, and apply the heat source to all domains. The last five lines set up a <em>Domain ODE</em> interface that is applied by default to all domains in the model and sets the variable name, the units, as well as the equation to solve.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/06/how-to-run-a-model-method.png" title="" alt="A screenshot demonstrating how to run a model method from the Developer tab in COMSOL Multiphysics." width="677" height="152" class="alignnone size-full wp-image-224521" /><br />
<em>Running the model method from the</em> Developer <em>tab.</em></p>
<p>We can run the above model method in a file that already has a heat transfer analysis set up. For example, try adding and running this model method in the <a href="/model/axisymmetric-transient-heat-transfer-267">Axisymmetric Transient Heat Transfer</a> tutorial, available in the Application Library in COMSOL Multiphysics. Then, just re-solve the model to solve for both temperature and degree of cure.</p>
<p>Now, there are a few assumptions in the above code snippet:</p>
<ul>
<li>We want to model curing in all of the domains in our model</li>
<li>There is already a component with the tag <em>comp1</em> to which we can add physics interfaces</li>
<li>There is not already a <em>Domain ODE</em> interface with the tag <em>dode</em> in that component</li>
<li>The temperature variable is defined as <em>T</em>, which we can use in the <em>Domain ODE</em> interface</li>
<li>A heat transfer physics interface with tag <em>ht</em> already exists and that we can add a feature with tag <em>hsNEW</em> to it</li>
</ul>
<p>Of course, as you develop your own model methods, you need to be able to recognize and address these kinds of general logical issues.</p>
<h3>Closing Remarks on Model Methods</h3>
<p>From this simple example, you can also see that you can create a model method that acts as a reusable template for any part of the modeling process in COMSOL Multiphysics. You might want to run such a template model method in every new file you create, possibly to load in a set of custom material properties, set up a complicated physics interface, or define a complicated set of expressions. You might also want to reuse the same model method in an existing file to set up a particular customized study type, modify solver settings, or define a results visualization that you plan to reuse over and over again.</p>
<p>Once you get comfortable with the basics of this workflow, you&#8217;ll find yourself saving lots of time, which we hope you&#8217;ll appreciate!</p>
<h3>Learn About Other Ways to Use Model Methods</h3>
<ul>
<li><a href="/blogs/how-to-generate-random-surfaces-in-comsol-multiphysics/">How to Generate Random Surfaces in COMSOL Multiphysics®</a></li>
<li><a href="/blogs/how-to-model-gearbox-vibration-and-noise-in-comsol-multiphysics/">How to Model Gearbox Vibration and Noise in COMSOL Multiphysics®</a></li>
<li><a href="/blogs/how-to-create-a-randomized-geometry-using-model-methods/">How to Create a Randomized Geometry Using Model Methods</a></li>
</ul>
<p><em>Oracle and Java are registered trademarks of Oracle and/or its affiliates.</em></p>
]]></content:encoded>
			<wfw:commentRss>https://www.comsol.de/blogs/how-to-use-model-methods-to-accelerate-your-comsol-workflow/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to Model the Optical Properties of Rough Surfaces</title>
		<link>https://www.comsol.de/blogs/how-to-model-the-optical-properties-of-rough-surfaces/</link>
		<comments>https://www.comsol.de/blogs/how-to-model-the-optical-properties-of-rough-surfaces/#comments</comments>
		<pubDate>Tue, 06 Jun 2017 12:19:02 +0000</pubDate>
		<dc:creator><![CDATA[Walter Frei]]></dc:creator>
				<category><![CDATA[Electrical]]></category>
		<category><![CDATA[Wave Optics]]></category>
		<category><![CDATA[Technical Content]]></category>
		<category><![CDATA[Wave Optics Module]]></category>

		<guid isPermaLink="false">http://com.staging.comsol.com/blogs?p=220781</guid>
		<description><![CDATA[Whenever light is incident on a dielectric material, like glass, part of the light is transmitted while another part is reflected. Sometimes, we add a metal coating, such as gold, which alters the transmittance and reflectance as well as leads to some absorption of light. The dielectric surface and the metal coating also often have some random variations in height and thickness. In this blog post, we will introduce and develop a computational model for this situation. Starting Simple: An [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Whenever light is incident on a dielectric material, like glass, part of the light is transmitted while another part is reflected. Sometimes, we add a metal coating, such as gold, which alters the transmittance and reflectance as well as leads to some absorption of light. The dielectric surface and the metal coating also often have some random variations in height and thickness. In this blog post, we will introduce and develop a computational model for this situation.</p>
<p><span id="more-220781"></span></p>
<h3>Starting Simple: An Optically Flat Surface</h3>
<p>Before we get to the rough surface, let&#8217;s start with something simple: a thin uniform layer of gold coating on top of <a href="https://en.wikipedia.org/wiki/Optical_flat" target="_blank">optically flat</a> glass, as shown in the image below. Such a model exhibits negligible structural variation in the plane of glass. In addition, it can be modeled quite simply in the COMSOL Multiphysics® software by considering a small two-dimensional unit cell that has a width much smaller than the wavelength.</p>
<p>This computational model is based on the <a href="/model/fresnel-equations-wave-optics-14713">Fresnel equation example</a>, one of the verification models in the Application Gallery, but is modified to include a layer of gold with a wavelength-dependent refractive index. This type of index requires that we manually adjust the mesh size based on the minimum wavelength in each material as well as the skin depth, as described in a <a href="/blogs/modeling-of-materials-in-wave-electromagnetics-problems/">previous blog post</a>.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/06/light-incident-schematic.png" title="" alt="A schematic showing light incident on a metal coating on top of a glass substrate." width="440" height="340" class="alignnone size-full wp-image-220981" /><br />
<em>Light incident on a metal coating on top of a glass substrate is reflected, transmitted, and absorbed.</em></p>
<p>The model includes Floquet periodic boundary conditions on the left and right sides of the modeling domain and a Port boundary condition at the top and bottom. The Port boundary condition at the top launches a plane wave at a specified angle of incidence and computes the reflected light, while the one at the bottom calculates the transmitted light. We can <a href="/blogs/overview-integration-methods-space-time/">integrate the losses</a> within the metal layer to compute the absorbance within the gold layer.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/06/optical-properties-of-metal-film-on-glass.png" title="" alt="An image showing a model for the optical properties of a metal film on glass." width="350" height="450" class="alignnone size-full wp-image-220801" /><br />
<em>The computational model that calculates the optical properties of a metal film on glass.</em></p>
<p>If we are interested in computing incident light at off-normal incident angles, then we also have to concern ourselves with the height of the modeling domain &mdash; the distance between the material interfaces and the Port boundary conditions. This distance must be large enough such that any evanescent field drops off to approximately zero within the modeling domain.</p>
<p>The reason for this has to do with the Port boundary conditions, which can only consider the propagating component of the electromagnetic field. Any evanescent component of the field that reaches the Port boundary condition is artificially reflected, so we must place the port boundary far enough away from the material interfaces. In the most general cases, it is difficult to determine how far the evanescent field extends. A simple rule of thumb is to place the Port boundary conditions at least half a wavelength away from the material interfaces and to check if making the domain larger alters the results.</p>
<p>The sample results below show the transmitted, reflected, and absorbed light as well as their total &mdash; which should always add up to one. If these do not add up to one, then we must carefully check our model setup. </p>
<p><img src="https://cdn.comsol.com/wordpress/2017/06/flat-glass-surface-plot.png" title="" alt="A plot of the transmittance, reflectance, and absorbance of light as a function of wavelength for a flat glass surface with a metal coating." width="600" height="300" class="alignnone size-full wp-image-220821" /><br />
<em>The transmittance, reflectance, and absorbance of light normally incident on a flat glass surface with a metal coating as a function of wavelength.</em></p>
<p><img src="https://cdn.comsol.com/wordpress/2017/06/various-angles-of-incidence-for-flat-glass-surface.png" title="" alt="A schematic showing the three properties of 550-nm light at various angles of incidence." width="600" height="300" class="alignnone size-full wp-image-220831" /><br />
<em>The transmittance, reflectance, and absorbance of 550-nm light at various angles of incidence.</em></p>
<h3>Adding Complexity: A Surface with Periodic Variations</h3>
<p>Let&#8217;s now make things a little bit more complicated and introduce a periodic structural variation: a sinusoidal ripple. Clearly, we now need to consider a larger unit cell that considers a single ripple. </p>
<p><img src="https://cdn.comsol.com/wordpress/2017/06/rough-surface-schematic.png" title="" alt="A graphic showing periodic variations on a surface that reflect and transmit light." width="550" height="400" class="alignnone size-full wp-image-220841" /><br />
<em>A surface with periodic variations reflects and transmits light into several different diffraction orders.</em></p>
<p>We can still apply the same domain properties and all of the same boundary conditions. However, if spacing is large enough, then we can have higher-order diffraction. In other words, light can be reflected and transmitted into several different directions. To properly compute the reflection and transmission, we need to add several diffraction order ports. The software computes the appropriate number of ports based on the domain width, material properties, and specified incident angle. If we are studying a range of incident angles, we must make sure to compute all of the diffraction orders present at the limits of the angular sweep. </p>
<p><img src="https://cdn.comsol.com/wordpress/2017/06/multiple-diffraction-orders.png" title="" alt="Side-by-side images showing multiple diffraction orders for the model." width="375" height="361" class="alignnone size-full wp-image-220851" /><br />
<em>There can be multiple diffraction orders present, depending on the ratio of wavelength to domain width, refractive index, and incident angles.</em></p>
<p>The conditions under which higher-order diffraction appears and the appropriate modeling procedure is presented in depth in the example of a <a href="/model/plasmonic-wire-grating-analyzer-wave-optics-14705">plasmonic wire grating</a>, so let&#8217;s not go into it at length here. In short, the wider the computational domain relative to the wavelengths in the materials above and below, the more diffraction orders can be present (the number of diffraction orders varies with the incident angle). The results shown below plot the total transmittance and reflectance; i.e., all of the light reflected into the different diffraction orders is added up, as is all of the transmitted light.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/06/rippled-surface-plot.png" title="" alt="A plot of the transmittance, reflectance, and absorbance of light incident on a rippled surface." width="600" height="300" class="alignnone size-full wp-image-220861" /><br />
<em>The transmittance, reflectance, and absorbance of light normally incident on a rippled glass surface with a metal coating.</em></p>
<p><img src="https://cdn.comsol.com/wordpress/2017/06/various-angles-of-incidence-for-rippled-surface.png" alt="A graph plotting the three properties of 550-nm light at various angles of incidence for the rippled surface." width="600" height="300" class="alignnone size-full wp-image-220871" title="various angles of incidence for rippled surface" /><br />
<em>The transmittance, reflectance, and absorbance of 550-nm light at various angles of incidence.</em></p>
<h3>Solving a More Difficult Case: A Surface with Random Roughness</h3>
<p>Let&#8217;s now move on to the most computationally difficult case: a surface with many random variations in the surface height. To model the randomness, we must model several different domains of increasing widths and different subsets of the rough profile. As the domain width increases &mdash; and as different subsets of the surface are sampled &mdash; the average behavior computed from these different models converges. That is, we generate a set of statistics by sampling the rough surface. Rather than going into detail on how to calculate these statistics, let&#8217;s focus on how to model one domain that approximates a rough surface by defining the height variation as the sum of different sinusoids with random height and phase, <a href="/blogs/how-to-generate-random-surfaces-in-comsol-multiphysics/">as described here</a>.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/06/random-variations-for-rough-surface.png" title="" alt="A schematic of a rough surface with random variations that transmit light in random directions." width="550" height="400" class="alignnone size-full wp-image-220881" /><br />
<em>A rough surface with random variations reflects and transmits light in random directions. The computational model must sample a statistically significant subset of the roughness profile.</em></p>
<p>Our computational domain must now be very wide, many times longer than the wavelength. As we still want to model a plane wave incident at various angles on the structure, we use the Floquet periodic boundary conditions, which require that we have an identical mesh on the periodic boundaries. Practically speaking, this means that we may need to slightly alter the geometry of our domain to ensure that the boundaries on the left and right side are identical. If we do use a sum of sine functions, <a href="/blogs/how-to-generate-random-surfaces-in-comsol-multiphysics/">as described here</a>, then the profile will automatically be periodic.</p>
<p>We still want to launch the wave with a Port boundary condition. However, it is no longer practical to use diffraction order ports to monitor the reflected and transmitted light, as this can result in hundreds (or thousands) of diffraction orders. Furthermore, since this model represents a statistical sampling, the relative fraction of light scattered into these different orders is not of interest; we&#8217;re only interested in the sum of the total reflected and transmitted light. That is, this modeling approach computes the total integrated scatter plus the specular reflection and transmission of the surface. </p>
<p><img src="https://cdn.comsol.com/wordpress/2017/06/rough-surface-computational-domain.png" title="" alt="A schematic of the computational domain for a model of a rough surface." width="600" height="400" class="alignnone size-full wp-image-220891" /><br />
<em>The computational domain for a model of a rough surface. Light is launched from the interior port toward the material interface. Light reflected back toward this port passes though it and is absorbed in the PML, as is the transmitted light. Two additional boundaries are introduced to monitor the total reflectance and transmittance.</em> </p>
<p>Thus, we introduce an alternative modeling strategy that does not use ports to compute reflection and transmission. Instead, we use a perfectly matched layer (PML) above and below to absorb all reflected and transmitted light as well as probes to compute reflection and transmission. PMLs absorb any fields incident upon them, as described in this blog post on <a href="/blogs/using-perfectly-matched-layers-and-scattering-boundary-conditions-for-wave-electromagnetics-problems/">using PMLs for wave electromagnetics problems</a>.</p>
<p>The PML absorbs both propagating and evanescent components of the field, but we only want it to absorb the propagating component. Thus, we again need to ensure that we place the PMLs far enough away from the material interfaces. We use the same rule of thumb as before, placing the PML at least half a wavelength away from the material interfaces.</p>
<p>As we approach grazing angles of incidence, even the PML domain does not, by default, absorb all of the light. At nearly grazing angles, the effective wavelength in the absorbing direction is very long, and we need to modify the default wavelength in the PML settings (shown below). This change to the settings is only necessary if we are interested in angles of incidence greater than ~75°.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/06/Settings-for-modeling-optical-properties-of-rough-surfaces.png" title="" alt="A screenshot of the settings for modeling the optical properties of rough surfaces in COMSOL Multiphysics®." width="507" height="536" class="alignnone size-full wp-image-220901" /><br />
<em>The PML settings modified to account for grazing angles of incidence.</em></p>
<p>Since our domain is now bounded by PMLs above and below, the port that launches the wave must now be placed within the modeling domain. To do this, we use the <em>Slit Condition</em> option to define an interior port that is backed by a domain. This means that the port now launches a wave in one direction, emanating from this interior boundary. Any light reflected back toward the boundary passes through unimpeded and then gets absorbed by the PML.</p>
<p>Although this is a good way to launch the wave, we will no longer use the Port boundary condition to compute how much light is reflected, since we would have to add hundreds of diffraction ports, and similarly, we&#8217;d need hundreds of ports to compute the total transmittance. </p>
<p>To monitor the total transmitted and reflected light, we instead introduce two additional interior boundaries to the model, placed just in front of the PML domains (shown in the schematic above). At these two boundaries, we integrate the power flux in the upward and downward directions, normalized by the incident power, which gives us the total reflectance and transmittance. To more accurately determine the integral of the power flux at these boundaries, we also introduce a boundary layer mesh composed of a single layer of elements much smaller than the wavelength.</p>
<p>On the incident side, we place this monitoring boundary above the interior port. The launching port introduces a plane wave propagating toward the material interface. The light reflected at the interface passes through this interior port, then moves through the boundary at which we monitor reflectance, and is absorbed in the PML.</p>
<p>The plots below show sample results of the transmittance, reflectance, and absorbance. They are notably different from the smooth surface and periodically varying surface results. Note that the sweep over the angle of incidence terminates at 85° off normal. Of course these plots will look slightly different for each different random geometry case that we run.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/06/rough-surface-plot.png" title="" alt="A plot of the transmittance, reflectance, and absorbance of light incident on a rough surface." width="600" height="300" class="alignnone size-full wp-image-220911" /><br />
<em>The transmittance, reflectance, and absorbance of light normally incident on a rough glass surface.</em></p>
<p><img src="https://cdn.comsol.com/wordpress/2017/06/various-angles-of-incidence-for-rough-surface.png" title="" alt="A graph plotting three properties of 550-nm light at large angles of incidence." width="600" height="300" class="alignnone size-full wp-image-220921" /><br />
<em>The transmittance, reflectance, and absorbance of 550-nm light at angles of incidence up to 85° off normal.</em></p>
<h3>Concluding Thoughts on Calculating the Optical Properties of Rough Surfaces</h3>
<p>Here, we have introduced a modeling approach that is appropriate for computing the optical transmission and reflection from a rough surface. This method contrasts with the approach for modeling a uniform optically flat surface as well as the one for modeling surfaces with periodic variations. The modeling method for rough surfaces can also be used for the modeling of periodic structures that have a very long period, such as when the scattering into different diffraction orders is not of interest.</p>
<p>Modeling truly random surfaces does require some care, as the geometry needs to be altered to ensure that it is periodic. Furthermore, the domain size and number of different random geometries studied must be large enough to give statistically meaningful results. Since this requires solving many different variations of the same model and postprocessing the results, it is helpful to use the Application Builder, LiveLink™ <em>for</em> MATLAB®, or LiveLink™ <em>for</em> Excel® in our modeling workflow.</p>
<div class="flex-center">
<a href="/model/computing-the-scattering-of-light-from-a-rough-surface-with-a-metal-coating-49891" class="btn-solid btn-md btn-red">Get the Model Files</a>
</div>
<h3>Further Resources</h3>
<ul>
<li>See how to <a href="/blogs/how-to-generate-random-surfaces-in-comsol-multiphysics/">create a rough surface as a sum of sine functions</a></li>
<li>See how to <a href="/blogs/how-to-create-a-randomized-geometry-using-model-methods/">create a random geometry using model methods</a></li>
<li>Check out other blog posts related to simulating wave optics:
<ul>
<li><a href="/blogs/modeling-of-materials-in-wave-electromagnetics-problems/">Modeling of Materials in Wave Electromagnetics Problems</a></li>
<li><a href="/blogs/modeling-metallic-objects-in-wave-electromagnetics-problems/">Modeling of Metallic Objects in Wave Electromagnetics</a></li>
</ul>
</li>
</ul>
<p><em>MATLAB is a registered trademark of The MathWorks, Inc. Microsoft and Excel are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.</em></p>
]]></content:encoded>
			<wfw:commentRss>https://www.comsol.de/blogs/how-to-model-the-optical-properties-of-rough-surfaces/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>How to Create a Randomized Geometry Using Model Methods</title>
		<link>https://www.comsol.de/blogs/how-to-create-a-randomized-geometry-using-model-methods/</link>
		<comments>https://www.comsol.de/blogs/how-to-create-a-randomized-geometry-using-model-methods/#comments</comments>
		<pubDate>Mon, 05 Jun 2017 14:50:21 +0000</pubDate>
		<dc:creator><![CDATA[Walter Frei]]></dc:creator>
				<category><![CDATA[Application Builder]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Geometry]]></category>
		<category><![CDATA[Technical Content]]></category>

		<guid isPermaLink="false">http://com.staging.comsol.com/blogs?p=220611</guid>
		<description><![CDATA[Have you ever wanted to include a randomly created geometry in your model? Perhaps you want to simulate a natural material or an arrangement of parts that has some known statistical distribution of dimensional variations. In such cases, we may want to create a random geometry in the COMSOL Multiphysics® software. With the release of version 5.3, we can now create random geometries using a model method. Let&#8217;s take a look at how to do so with a tasty example. [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Have you ever wanted to include a randomly created geometry in your model? Perhaps you want to simulate a natural material or an arrangement of parts that has some known statistical distribution of dimensional variations. In such cases, we may want to create a random geometry in the COMSOL Multiphysics® software. With the release of version 5.3, we can now create random geometries using a model method. Let&#8217;s take a look at how to do so with a tasty example.</p>
<p><span id="more-220611"></span></p>
<h3>Building a Model of Swiss Cheese</h3>
<p>Determining the <a href="http://www.worldchampioncheese.org/" target="_blank">best cheese in the world</a> is a hotly contested task, but I&#8217;ll go ahead and add my opinion: a good <a href="https://en.wikipedia.org/wiki/Emmental_cheese" target="_blank">Emmentaler cheese</a> is hard to beat. A <a href="https://www.cdr.wisc.edu/mastercheesemaker/about" target="_blank">master cheesemaker</a> might joke that it&#8217;s really the holes that add the flavor, so if we&#8217;re going to build a good COMSOL Multiphysics model of a wheel of cheese, we need to include the holes.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/06/Emmentaler-cheese-model.png" title="" alt="An image showing a model of cheese with randomized holes." width="600" height="300" class="alignnone size-full wp-image-220721" /><br />
<em>A model of Emmentaler cheese, with randomly positioned and sized holes.</em></p>
<p>It turns out that the <a href="http://www.newyorker.com/tech/elements/how-does-swiss-cheese-get-its-holes" target="_blank">reasons for the holes in Swiss cheese</a> are quite complicated, so we aren&#8217;t going to try to model the hole formation itself. Instead, we will simply set up a model of the cheese, as shown in the image above. We want to include a randomly distributed set of holes within the cheese, with a random hole radius between some upper and lower limit on the radius. We can build this randomized geometry in COMSOL Multiphysics version 5.3 using the new <em>Model Method</em> functionality. Let&#8217;s find out how&#8230;</p>
<h3>Introducing Model Methods in COMSOL Multiphysics®</h3>
<p>When you&#8217;re running COMSOL Multiphysics® version 5.3 on the Windows® platform and working with the Model Builder, you will now see a <em>Developer</em> tab in the ribbon, as shown in the screenshot below. One of the options is <em>Record Method</em>. When clicked, this option prompts you to enter a new method <em>Name</em> and <em>Method type</em>. You can enter any string for the method name, while the method type can either be <em>Application method</em> or <em>Model method</em>.</p>
<p>An <em>Application method</em> can be used within a COMSOL app &mdash; a process introduced in this <a href="/video/create-methods-improve-simulation-apps">tutorial video</a>. A <em>Model method</em> can be used within the underlying COMSOL Multiphysics model and can operate on (and add information to) the existing model data.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/06/Developer-tab-COMSOL-Multiphysics®-version-5.3.png" title="" alt="A screenshot showing the new Developer tab in COMSOL Multiphysics® version 5.3." width="683" height="379" class="alignnone size-full wp-image-220731" /><br />
<em>The</em> Developer <em>tab, showing the</em> Record Method <em>and</em> Run Model Method <em>buttons.</em></p>
<p>After you click the <em>OK</em> button in the <em>Record Method</em> dialog box, you can see a red highlight around the entire graphical user interface. All operations performed are recorded in this method until you click the <em>Stop Recording</em> button. You can then switch to the Application Builder and view your recorded method. The screenshot below shows the Application Builder and the method after we record the creation of a single geometry object. The object is a cylinder with the tag <code>cyl1</code>, a radius of 40 cm, and a height of 20 cm &mdash; a good starting approximation for a wheel of cheese.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/06/COMSOL-Multiphysics-Application-Builder-Model-Methods.png" title="" alt="A screenshot of the code for a model method in the Application Builder." width="830" height="342" class="alignnone size-full wp-image-220741" /><br />
<em>The Application Builder showing code for a model method used to create a geometry.</em></p>
<p>When we&#8217;re working with the Model Builder, we can call this model method within any other model file (as long as it doesn&#8217;t already have an existing object with tag <code>cyl1</code> within the geometry sequence) via the <em>Run Model Method</em> button in the <em>Developer</em> tab. Of course, this simple model method just creates a cylinder. If we want to model the holes, we need to introduce a bit of randomness into our method. Let&#8217;s look at that next.</p>
<h3>Creating a Random Set of Geometry Features</h3>
<p>Within a model method, you can call standard Java® classes, such as the <a href="https://docs.oracle.com/javase/7/docs/api/java/lang/Math.html#random" target="_blank">Math.random class</a>, which returns a double-precision number greater than or equal to 0.0 and less than 1.0. We want to use this class, along with a little bit of extra code, to set up a specified number of randomly positioned and sized holes within the model of the wheel of cheese.</p>
<p>Let&#8217;s say that we want 1000 holes randomly distributed throughout the cheese that each have a random radius between 0.1 cm and 1 cm. We also need to keep in mind that Emmentaler cheese has a <a href="http://cheeseunderground.blogspot.com/2011/01/cheese-rinds-to-eat-or-not-to-eat.html" target="_blank">natural rind</a> within which no holes form. So, we need to add a bit of logic to make sure that our 1000 holes are actually inside the cheese. The complete model method below (with line numbers added and text strings in red) shows how to do this.</p>
<pre>
1  int NUMBER_OF_HOLES = 1000;
2  int ind = 0;
3  double hx, hy, hz, hr = 0.0;
4  double CHEESE_HEIGHT = 20.0;
5  double CHEESE_RADIUS = 40.0;
6  double RIND_THICKNESS = 0.2;
7  double HOLE_MIN_RADIUS = 0.1;
8  double HOLE_MAX_RADIUS = 1.0;
9  model.component(<span style="color:#FF0000">"comp1"</span>).geom(<span style="color:#FF0000">"geom1"</span>).lengthUnit(<span style="color:#FF0000">"cm"</span>);
10 model.component(<span style="color:#FF0000">"comp1"</span>).geom(<span style="color:#FF0000">"geom1"</span>).selection().create(<span style="color:#FF0000">"csel1"</span>, <span style="color:#FF0000">"CumulativeSelection"</span>);
11 while (ind  CHEESE_RADIUS-RIND_THICKNESS) {continue; }
17   if (((hz-hr)  CHEESE_HEIGHT-RIND_THICKNESS)) {continue; }
18   model.component(<span style="color:#FF0000">"comp1"</span>).geom(<span style="color:#FF0000">"geom1"</span>).create(<span style="color:#FF0000">"sph"</span>+ind, <span style="color:#FF0000">"Sphere"</span>);
19   model.component(<span style="color:#FF0000">"comp1"</span>).geom(<span style="color:#FF0000">"geom1"</span>).feature(<span style="color:#FF0000">"sph"</span>+ind).set(<span style="color:#FF0000">"r"</span>, hr);
20   model.component(<span style="color:#FF0000">"comp1"</span>).geom(<span style="color:#FF0000">"geom1"</span>).feature(<span style="color:#FF0000">"sph"</span>+ind).set(<span style="color:#FF0000">"pos"</span>, new double[]{hx, hy, hz});
21   model.component(<span style="color:#FF0000">"comp1"</span>).geom(<span style="color:#FF0000">"geom1"</span>).feature(<span style="color:#FF0000">"sph"</span>+ind).set(<span style="color:#FF0000">"contributeto"</span>, <span style="color:#FF0000">"csel1"</span>);
22   ind++;
23 }
24 model.component(<span style="color:#FF0000">"comp1"</span>).geom(<span style="color:#FF0000">"geom1"</span>).create(<span style="color:#FF0000">"cyl1"</span>, <span style="color:#FF0000">"Cylinder"</span>);
25 model.component(<span style="color:#FF0000">"comp1"</span>).geom(<span style="color:#FF0000">"geom1"</span>).feature(<span style="color:#FF0000">"cyl1"</span>).set(<span style="color:#FF0000">"r"</span>, CHEESE_RADIUS);
26 model.component(<span style="color:#FF0000">"comp1"</span>).geom(<span style="color:#FF0000">"geom1"</span>).feature(<span style="color:#FF0000">"cyl1"</span>).set(<span style="color:#FF0000">"h"</span>, CHEESE_HEIGHT);
27 model.component(<span style="color:#FF0000">"comp1"</span>).geom(<span style="color:#FF0000">"geom1"</span>).create(<span style="color:#FF0000">"dif1"</span>, <span style="color:#FF0000">"Difference"</span>);
28 model.component(<span style="color:#FF0000">"comp1"</span>).geom(<span style="color:#FF0000">"geom1"</span>).feature(<span style="color:#FF0000">"dif1"</span>).selection(<span style="color:#FF0000">"input"</span>).set(<span style="color:#FF0000">"cyl1"</span>);
29 model.component(<span style="color:#FF0000">"comp1"</span>).geom(<span style="color:#FF0000">"geom1"</span>).feature(<span style="color:#FF0000">"dif1"</span>).selection(<span style="color:#FF0000">"input2"</span>).named(<span style="color:#FF0000">"csel1"</span>);
30 model.component(<span style="color:#FF0000">"comp1"</span>).geom(<span style="color:#FF0000">"geom1"</span>).run();
</pre>
<p>Let&#8217;s go through this model method line by line:</p>
<p style="margin-left: 20px">1. Initialize and define the total number of holes that we want to put in the cheese.<br />
2. Initialize and define an index counter to use later.<br />
3. Initialize a set of double-precision numbers that holds the <em>xyz</em>-position and radius of each hole.<br />
4&ndash;8. Initialize and define a set of numbers that defines the cheese height, radius, ring thickness, and maximum and minimum possible hole radius in centimeters.<br />
9. Set the length unit of the geometry to centimeters.<br />
10. Create a new selection set, with tag <code>csel</code> and name <code > CumulativeSelection</code>. Note that if such a selection set already exists, the method fails at this point. You could also modify the method to account for this, if you want to run the method repeatedly in the same file.<br />
11. Initialize a while loop to create the specified number of holes.<br />
12&ndash;14. Define the <em>xyz</em>-position of the holes by calling the random method and scaling the output such that the <em>xyz</em>-position of the holes lies within the outer Cartesian bounds of the cheese.<br />
15. Define the hole radius to lie between the specified limits.<br />
16&ndash;17. Check if the hole position and size are such that the hole is actually outside of the cheese. If so, continue to the next iteration of the while loop without executing any of the remaining code in the loop. This check can be done in a single line or split into three lines, depending on your preference of programming style.<br />
18. Create a sphere with a name based on the current index value.<br />
19&ndash;20. Set the radius and position of the newly created sphere. Although the radius can be passed in directly as a double, the position must be specified as an array of doubles.<br />
21. Specify that this sphere feature is part of (contributes to) the selection set named <code>csel1</code>.<br />
22&ndash;23. Iterate the index, indicating that a sphere has been created, and close the while loop.<br />
24&ndash;26. Create a cylinder primitive that represents the wheel of cheese.<br />
27&ndash;29. Set up a Boolean difference operation. The object to add is the cylinder primitive, while the object to subtract is the selection of all of the spheres.<br />
30. Run the entire geometry sequence, which cuts all of the spheres out of the cylinder, forming the wheel of cheese.</p>
<p>We can run this method in a new (and empty) model file to create a model of a wheel of cheese. Each time we rerun the method, we will get a different model. The geometry sequence in the model file contains all of the spheres and the cylinder primitives as well as the Boolean operation.</p>
<p>If we want to, we could also add some additional code to our model method to write out a geometry file of just the final geometry: the cheese. This geometry file can be written in the COMSOL Multiphysics native or STL file format. We could also write out to Parasolid® software or ACIS® software file formats with any of the <a href="/blogs/which-module-should-i-choose-for-working-with-my-cad-data/">optional modules</a> that include the Parasolid® software kernel. Working with just the final geometry after it has been exported and reimported is faster than working with the complete geometry sequence.</p>
<p>We can see the final results of our efforts below. Delicious!</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/06/COMSOL-Multiphysics-model-of-Emmentaler-cheese-with-mouse.png" title="" alt="An image showing a model of a wheel of Emmentaler cheese, an example of a randomized geometry." width="600" height="300" class="alignnone size-full wp-image-220751" /><br />
<em>A model of a wheel of Emmentaler cheese, ready to be eaten.</em></p>
<h3>Closing Remarks on Creating a Randomized Geometry via Model Methods</h3>
<p>We&#8217;ve looked at a simple example of how to use model methods to create a geometry with randomly placed and sized features. There are some questions that we haven&#8217;t addressed here, such as how to ensure that the holes are not overlapping and how to come up with a <a href="https://en.wikipedia.org/wiki/Random_close_pack" target="_blank">close-packed arrangement</a>, but these turn out to be difficult mathematical questions that are fields in their own right.</p>
<p>Of course, there is a lot more that you can do with model methods, which we will save for another day. There are also other ways to create a random geometry, such as by <a href="/blogs/how-to-generate-random-surfaces-in-comsol-multiphysics/">parametrically defining a surface</a>.</p>
<div class="flex-center">
<a href="/model/creating-a-random-geometry-49881" class="btn-solid btn-md btn-red">GET THE MODEL FILE</a>
</div>
<h3>Related Resources</h3>
<ul>
<li>Read about another use of model methods: generating <a href="/blogs/how-to-model-gearbox-vibration-and-noise-in-comsol-multiphysics/">simulation results that you can see and hear</a></li>
<li>Check out the new features in COMSOL Multiphysics® version 5.3 on the <a href="/release/5.3">Release Highlights page</a></li>
</ul>
<p><em>ACIS is a registered trademark of Spatial Corporation. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Parasolid is a trademark or registered trademark of Siemens Product Lifecycle Management Software Inc. or its subsidiaries in the United States and in other countries. Microsoft and Windows are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.</em></p>
]]></content:encoded>
			<wfw:commentRss>https://www.comsol.de/blogs/how-to-create-a-randomized-geometry-using-model-methods/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Modeling Natural and Forced Convection in COMSOL Multiphysics®</title>
		<link>https://www.comsol.de/blogs/modeling-natural-and-forced-convection-in-comsol-multiphysics/</link>
		<comments>https://www.comsol.de/blogs/modeling-natural-and-forced-convection-in-comsol-multiphysics/#comments</comments>
		<pubDate>Fri, 28 Apr 2017 08:02:48 +0000</pubDate>
		<dc:creator><![CDATA[Walter Frei]]></dc:creator>
				<category><![CDATA[Computational Fluid Dynamics (CFD)]]></category>
		<category><![CDATA[Fluid]]></category>
		<category><![CDATA[Heat Transfer & Phase Change]]></category>
		<category><![CDATA[Mechanical]]></category>
		<category><![CDATA[CFD Module]]></category>
		<category><![CDATA[Heat Transfer Module]]></category>
		<category><![CDATA[Technical Content]]></category>

		<guid isPermaLink="false">http://com.staging.comsol.com/blogs?p=215271</guid>
		<description><![CDATA[Whenever we have a heated or cooled part exposed to air, there is some transfer of heat from the part to the air via convection. The movement of the air can be either forced, via a fan, or free, as a result of the natural buoyancy variations due to changes in the air temperature. Today, we will look at several different ways of modeling these types of convection in the COMSOL Multiphysics® software. Starting Simple: The Heat Transfer Coefficient Let’s [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Whenever we have a heated or cooled part exposed to air, there is some transfer of heat from the part to the air via convection. The movement of the air can be either forced, via a fan, or free, as a result of the natural buoyancy variations due to changes in the air temperature. Today, we will look at several different ways of modeling these types of convection in the COMSOL Multiphysics® software.</p>
<p><span id="more-215271"></span></p>
<h3>Starting Simple: The Heat Transfer Coefficient</h3>
<p>Let’s start by considering a model of the electrical heating of a busbar, shown below. You may recognize this as an introductory example to COMSOL Multiphysics, but if you haven&#8217;t already modeled it, we encourage you to review this model by going through the <a href="/documentation/IntroductionToCOMSOLMultiphysics.pdf"><em>Introduction to COMSOL Multiphysics</em> PDF booklet</a>.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/04/electric-currents-in-busbar.png" title="" alt="An image showing simulation results for an electric current flowing through a metal busbar." width="468" height="545" class="alignnone size-full wp-image-215301" /><br />
<em>Electric currents (arrow plot) flowing through a metal busbar lead to resistive heating that raises the temperature (color surface plot).</em></p>
<p>In this example, we model electric current flowing through a busbar. This leads to resistive heating, which in turn causes the temperature of the busbar to rise. We assume that there is only heat transfer to the surrounding air, neglecting any conductive heat transfer through the bolts and radiative heat transfer. The example also initially assumes that there isn’t any fan forcing air over the busbar. Thus, the transfer of heat to the air is via natural, or free, convection.</p>
<p>As the part heats the surrounding air, the air gets hotter. As the air gets hotter, its density decreases, causing the hot air to rise relative to the cooler surrounding air. These free convective air currents increase the rate of heat transfer from the part to the surrounding air. The air currents depend on the temperature variations as well as the geometry of the part and its surroundings. Convection can, of course, also happen in any other gas or liquid, such as water or transformer oil, but we will center this discussion primarily around convection in air.</p>
<p>We can classify the surrounding airspace into one of two categories: <em>Internal</em> or <em>External</em>. Internal means that there is a finite-sized cavity (such as an electrical junction box) around the part within which the air is reasonably well contained, although it might have known air inlets and outlets to an external space. We then assume that the thermal boundary conditions on the outside of the cavity and at the inlets and outlets are known. On the other hand, External implies that the object is surrounded by what is essentially an infinitely large volume of air. We then assume that the air temperature far away from the object is a constant, known value.  </p>
<p><img src="https://cdn.comsol.com/wordpress/2017/04/constant-heat-transfer-coefficient.png" title="" alt="A screenshot showing the constant heat transfer coefficient, used for modeling natural and forced convection in COMSOL Multiphysics®." width="525" height="625" class="alignnone size-full wp-image-215311" /><br />
<em>The settings for a constant heat transfer coefficient.</em></p>
<p>The introductory busbar example assumes free convective heat transfer to an external airspace. This is modeled using the following boundary condition for the heat flux:</p>
<div class="latex">q=h \left(T_{ext}-T \right)</div>
<p>where the external air temperature is <em>T<sub>ext</sub></em> = 25°C and <img class="latexImg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAH0AAAAZCAMAAAArO9FbAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAADNQTFRF////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////8T5qHgAAAA90Uk5TADOImSIRd0TuZrtVzN2qWFA7/wAAAAFiS0dEAIgFHUgAAAAJcEhZcwAAAHgAAAB4AJ31WmAAAAIwSURBVEjH3VbZkuMgDARxGTDm//92dHD42nhqUjOpWj3YToLUqLuRo9R/HRrA2E+BO69UWNyH0EPFSw1/gGTjHTz2X/XLNJP8c3GmDyUEDMQJdLdyF2Eh3yeCkXukDKJhpkjUqB6jJoBEhUB6CVWqxrVVWu/zghlPFdrKA7it37BlWWviTUJlGlyr5ZunNNymac+M8T5l284f0WJ5BlejuBcXZUF3nTa4VVejHLn9YkrfziGMUc8x0AOjuyjo4+tb4u1SMTp7BBMu7igxg/mHZya6C8FN9Ohqok76acq8DTQUNocXhx47kWHJXVeGbAWHMo6ZoMOMuXjz1ibN6CRlVintW5eJ5lWhA7EBuiGf9IzVOnN1WFzoqzkTYB9jFXGjaSXbDSEIPY9iiddoxXqYVbVJs9e3aG/rRWSW/bz2PqhtAgi41VSo194BP4VWptAnf3JCKZhkLmO3kG1he40rTbLWiE4Zpo7Thly3J6AFMt224xFk2XF3p9Eip73Mb/0d88s20JfEhOO5Hzmu7z1RQl7UdcBGkbyc3UCfNZqu07h33TBDyoP5tLapM5uLfR/sHuYRy9r9OZLTjps4vnNYdmQsvxx4QNRGVi0Vptnv6qRGvMi+emHB7zUuQo87+Y45D2t+Pesd5BBXJlMGrgppitcrinuY42z8rnVItdB0t6bWw98Nkcc+jvoArdd222UMHNffhHT9qz8V6/slfh76O++JXwvQ79f4eWzvl/hAfAHBvA6GpeepXgAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxOC0xMS0yMlQxMDowMTo0OCswMTowMF/32sUAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTgtMTEtMjJUMTA6MDE6NDgrMDE6MDAuqmJ5AAAAIXRFWHRwczpIaVJlc0JvdW5kaW5nQm94ADc1eDE1KzI2OCs2MzYhemOPAAAAJ3RFWHRwczpMZXZlbABBZG9iZUZvbnQtMS4wOiBDTU1JMTIgMDAzLjAwMgoxF5a7AAAASXRFWHRwczpTcG90Q29sb3ItMAAvZGV2L3NobS96ZjItY2FjaGUvNzJjOTZiY2E0NGRiMWIwZDY2YTQ3Y2MwNjRjYWJhYjguZHZpIC1vygvwLwAAAEV0RVh0cHM6U3BvdENvbG9yLTEAL2Rldi9zaG0vemYyLWNhY2hlLzcyYzk2YmNhNDRkYjFiMGQ2NmE0N2NjMDY0Y2FiYWI4LnBz+K6rWgAAAABJRU5ErkJggg==" /> is the heat transfer coefficient.</p>
<p>This single-valued heat transfer coefficient represents an approximate and average of all of the local variations in air currents. Even for this simple system, any value between <img class="latexImg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKgAAAAZCAMAAACSA5VWAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAADNQTFRF////A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ijt77v41fYHJFUTR8h6oEYAAAAldEVYdGRhdGU6Y3JlYXRlADIwMTgtMTEtMjJUMTE6NTM6NTMrMDE6MDA5bitbAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE4LTExLTIyVDExOjUzOjUzKzAxOjAwSDOT5wAAACJ0RVh0cHM6SGlSZXNCb3VuZGluZ0JveAAxMDF4MTUrMjU1KzYzNsVveDMAAAAndEVYdHBzOkxldmVsAEFkb2JlRm9udC0xLjA6IENNTUkxMiAwMDMuMDAyCjEXlrsAAABJdEVYdHBzOlNwb3RDb2xvci0wAC9kZXYvc2htL3pmMi1jYWNoZS8xZjc4NDEzY2Y3MWVhYzYxYTlhZjg1MDVlNTEyYjgxNC5kdmkgLW9Io7W/AAAARXRFWHRwczpTcG90Q29sb3ItMQAvZGV2L3NobS96ZjItY2FjaGUvMWY3ODQxM2NmNzFlYWM2MWE5YWY4NTA1ZTUxMmI4MTQucHMs6BFtAAAAAElFTkSuQmCC" /> could be an appropriate heat transfer coefficient, and it&#8217;s worth trying out the bounding cases and comparing results.</p>
<p>If we instead know that there is a fan blowing air over this structure, then due to the faster air currents, we use a heat transfer coefficient of <img class="latexImg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALwAAAAZCAMAAAC8RrTEAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAADNQTFRF////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////8T5qHgAAAA90Uk5TADOImSIRd0TuZrtVzN2qWFA7/wAAAAFiS0dEAIgFHUgAAAAJcEhZcwAAAHgAAAB4AJ31WmAAAAMbSURBVFjD7VfbkuQgCFW83+L//+0iqNF0T3p2ura6pmp5SGIieIADGiH+y78TCaD0p0H8UIwVwnnzaRg/E1fxUt2nYbwWHZ6hx+hXeaelov2e+fEgX9HQuD7DnHpd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wLqpieQAAACJ0RVh0cHM6SGlSZXNCb3VuZGluZ0JveAAxMTN4MTUrMjQ5KzYzNvpuAY0AAAAndEVYdHBzOkxldmVsAEFkb2JlRm9udC0xLjA6IENNTUkxMiAwMDMuMDAyCjEXlrsAAABJdEVYdHBzOlNwb3RDb2xvci0wAC9kZXYvc2htL3pmMi1jYWNoZS9iMDhiNjliYTgzMmQ5Y2EyNTUwYTU4ZWFmMDgyY2U2OC5kdmkgLW+xS7MVAAAARXRFWHRwczpTcG90Q29sb3ItMQAvZGV2L3NobS96ZjItY2FjaGUvYjA4YjY5YmE4MzJkOWNhMjU1MGE1OGVhZjA4MmNlNjgucHMpH0DAAAAAAElFTkSuQmCC" /> to represent the enhanced heat transfer.</p>
<p>If the surrounding fluid is a liquid such as water, then the range of free and forced heat transfer coefficients are much wider. For free convection in a liquid, <img class="latexImg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAM8AAAAZCAMAAAChOIpfAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAADNQTFRF////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////8T5qHgAAAA90Uk5TADOImSIRd0TuZrtVzN2qWFA7/wAAAAFiS0dEAIgFHUgAAAAJcEhZcwAAAHgAAAB4AJ31WmAAAAMqSURBVFjD7VfZstsgDMVC7GD+/28rEAYv1M5N7510OtVDojgcoaMNLMR/+awsABI/7cT3idJCGKs+7ca3icn0kc2n3XhP0E0IUY7ycouSXj/briluhbs8F/BlxcBcNCAhz035Rv5uf4SpbZD87QqgpGogWLITj5I9gK+GApjw0JII/vhgYGYacMBNZkddbNbj1LiRXcvQFh7oYH5hYKSYfaWNqUQ23ixdQMcjn4GZacSnZl8197Ta7Eyt6559x3FQ+ui/S890RLctqxbD7Wp/5DMwM01obvDAfNRWLTBrk4UAof0h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Yvc2htL3pmMi1jYWNoZS9kZDYwYTI3ODY1ZDYxZjhjNDE3ZjUxMjA0MmUzMGU3MS5kdmkgLW9HhMTRAAAARXRFWHRwczpTcG90Q29sb3ItMQAvZGV2L3NobS96ZjItY2FjaGUvZGQ2MGEyNzg2NWQ2MWY4YzQxN2Y1MTIwNDJlMzBlNzEucHO3CbdgAAAAAElFTkSuQmCC" />  is the typical range. For forced convection, the range is even wider: <img class="latexImg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANkAAAAZCAMAAACLiHvwAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAADNQTFRF////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////8T5qHgAAAA90Uk5TADOImSIRd0TuZrtVzN2qWFA7/wAAAAFiS0dEAIgFHUgAAAAJcEhZcwAAAHgAAAB4AJ31WmAAAANXSURBVFjD7VfZkuwgCFXc4hb//28HwSXp2Ompnpqlbl0eOoQGZTmgEeI//T2SAEr/thPfQcYK4Tbz2258A7mCP8X9thtfJe0XoWHdiry1UsG+XpvK3mAtX8HbuKFx1ZX6KQdIGIOrT83P9kdc7gOKn74a1PJNC6bixUsqASDQQhFcvG9di72d5Fp3SlYccBFcYZd9arZpuY9TgyvQFE+B6fKJEZNTCZQAnWuO042qrd7Bple6U7LiMDLChmmO2jYgJKz2kXagyHNGjD1H4vPrwMRYWxGX4nPVoLtzV90pWXHC8kiIHJnpWIJVO0k0iO0PlXuoJ1Lq/G4s9GTpkYMR2UZcUOIpldB/r7pTsuIQVY4i4sjGniuE6K0gtZdMxpdsZx9BTancFOwbhx/HVAXjHIXLWQ3heWRsVFvlqjslK65F5g0lR/bNYw0RhwMWBX8MzouHGuo6Ka6F1QUMgmeceXvV0CHgui5PqdU6yL63gJvI2BvUu+pOyYqr/9feiRzmbICKHCt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TJlZDUwNTBiYWFkNjBjZjgxNTgzNjI3OGMucHNU1U2EAAAAAElFTkSuQmCC" />.</p>
<p>Clearly, entering a single-valued heat transfer coefficient for free or forced convection is an oversimplification, so why do we do it? First, it is simple to implement and easy to compare the best and worst cases. Also, this boundary condition can be applied with the core COMSOL Multiphysics package. However, there are some more sophisticated approaches available within the <a href="/heat-transfer-module">Heat Transfer Module</a> and <a href="/cfd-module">CFD Module</a>, so let’s look at those next.</p>
<h3>Using a Convective Correlation</h3>
<p>A <em>convective correlation</em> is an empirical relationship that has been developed for common geometries. When using the Heat Transfer Module or CFD Module, these correlations are available within the Heat Flux boundary condition, shown in the screenshot below.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/04/Heat-Flux-boundary-condition-settings.png" title="" alt="A screenshot showing the Heat Flux boundary condition settings." width="525" height="716" class="alignnone size-full wp-image-215321" /><br />
<em>The Heat Flux boundary condition with the external natural convection correlation for a vertical wall.</em> </p>
<p>Using these correlations requires that you enter the part&#8217;s characteristic dimensions. For example, with our busbar model, we use the <em>External natural convection, Vertical wall</em> correlation and choose a wall height of 10 cm to model the free convective heat flux off of the busbar&#8217;s vertical faces. We also need to specify the external air temperature and pressure. These values can be loaded from the ASHRAE database, a process we describe in a <a href="/blogs/thermal-modeling-of-the-air-flow-inside-and-around-your-house/">previous blog post</a>.</p>
<p>The table below shows schematics for all of the available correlations. They take the information about the surface geometry and use a <a href="https://en.wikipedia.org/wiki/Nusselt_number" target="_blank">Nusselt number correlation</a> to compute a heat transfer coefficient. For the horizontally aligned faces of the busbar, for example, we use the <em>Horizontal plate, Upside</em> and <em>Horizontal plate, Downside</em> correlations.</p>
<p>When using the Forced Convection correlations, you must also enter the air velocity. These convective correlations have the advantage of being a more accurate representation of reality, since they are based on well-established experimental data. These correlations lead to a nonlinear boundary condition, but this usually results in only slightly longer computation times than when using a constant heat transfer coefficient. The disadvantage is that they are only appropriate to use when there is an empirical relationship that is reasonable for the part geometry.</p>
<table class="table-blog">
<tr>
<th>
</th>
<th>
Free Convection
</th>
<th>
Forced Convection
</th>
</tr>
<tr>
<th>
External
</th>
<td>
<a href="https://cdn.comsol.com/wordpress/2017/04/External-Free-Convection-correlations.png" target="_blank"><img src="https://cdn.comsol.com/wordpress/2017/04/External-Free-Convection-correlations.png" title="External, Free Convection" alt="A group of images showing the schematics of External, Free Convection correlations." width="450" height="525" class="alignnone size-full wp-image-215331" /></a>
</td>
<td>
<a href="https://cdn.comsol.com/wordpress/2017/04/External-Forced-Convection-correlations.png" target="_blank"><img src="https://cdn.comsol.com/wordpress/2017/04/External-Forced-Convection-correlations.png" title="External, Forced Convection" alt="A group of images showing the schematics of External, Forced Convection correlations." width="400" height="500" class="alignnone size-full wp-image-215341" /></a>
</td>
</tr>
<tr>
<th>
Internal
</th>
<td>
<a href="https://cdn.comsol.com/wordpress/2017/04/Internal-Free-Convection-correlations.png" target="_blank"><img src="https://cdn.comsol.com/wordpress/2017/04/Internal-Free-Convection-correlations.png" title="Internal, Free Convection" alt="A group of images showing the schematics of Internal, Free Convection correlations." width="392" height="301" class="alignnone size-full wp-image-215351" /></a>
</td>
<td>
<a href="https://cdn.comsol.com/wordpress/2017/04/Internal-Forced-Convection-correlation.png" target="_blank"><img src="https://cdn.comsol.com/wordpress/2017/04/Internal-Forced-Convection-correlation.png" title="Internal, Forced Convection" alt="A schematic of an Internal, Forced Convection correlation." width="325" height="216" class="alignnone size-full wp-image-215361" /></a>
</td>
</tr>
</table>
<p><em>The available</em> Convective Correlation <em>boundary conditions.</em></p>
<p>Note that all of the above convective correlations, even those classified as Internal, assume the presence of an infinite external reservoir of fluid; e.g., the ambient airspace. The heat carried away from the surfaces goes into this ambient airspace without changing its temperature, and the ambient air coming in is at a known temperature. If, however, we are dealing with convection in a completely enclosed container, then none of these correlations are appropriate and we must move to a different modeling approach.</p>
<h3>Approximating Free Convection in an Enclosure Using an Enhanced Thermal Conductivity</h3>
<p>Let&#8217;s consider a rectangular air-filled cavity. If this cavity is heated on one of the vertical sides and cooled on the other, then there will be a regular circulation of the air. Similarly, there will be air circulation if the cavity is heated from below and cooled from above. These cases are shown in the images below, which were generated by solving for both the temperature distribution and the air flow.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/04/free-convective-currents-in-cavities.png" title="" alt="Side-by-side images showing free convective currents in vertically and horizontally aligned cavities." width="500" height="280" class="alignnone size-full wp-image-215371" /><br />
<em>Free convective currents in vertically and horizontally aligned rectangular cavities.</em></p>
<p>Solving for the free convective currents is fairly involved. See, for example, this blog post on <a href="/blogs/introduction-to-modeling-natural-convection-in-comsol-multiphysics/">modeling natural convection</a>. Therefore, we might like to find a simpler alternative. Within the Heat Transfer Module, there is the option to use the <em>Equivalent conductivity for convection</em> feature. When using this feature, the effective thermal conductivity of the air is increased based upon correlations for the horizontal and vertical rectangular cavity cases, as shown in the screenshot below.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/04/Equivalent-conductivity-for-convection-feature.png" title="" alt="The Settings window for the Equivalent conductivity for convection feature in COMSOL Multiphysics® 5.3." width="507" height="567" class="alignnone size-full wp-image-215381" /><br />
<em>The Equivalent conductivity for convection feature and settings.</em></p>
<p>The air domain is still explicitly modeled using the <em>Fluid</em> domain feature within the <em>Heat Transfer</em> interface, but the air flow fields are not computed and the velocity term is simply neglected. The thermal conductivity is increased by an empirical correlation factor that depends on the cavity dimensions and the temperature variation across the cavity. The dimensions of the cavity must be entered, but the software can automatically determine and update the temperature difference across the cavity.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/04/temperature-distribution-in-cavities.png" title="" alt="Side-by-side images showing the temperature distribution in vertically and horizontally aligned cavities." width="500" height="275" class="alignnone size-full wp-image-215391" /><br />
<em>Temperature distribution in vertically and horizontally aligned cavities using the Equivalent conductivity for convection feature. The free convective air currents are not computed. Instead, the thermal conductivity of the air is increased.</em></p>
<p>This approach for approximating free convection in a completely closed cavity requires us to mesh the air domain and solve for the temperature field in the air, but this usually adds only a small computational cost. The disadvantage of this approach is that it is not very applicable for nonrectangular geometries.</p>
<h3>Approximating Forced Convection in an Enclosure Using Isothermal Domains</h3>
<p>Next, let&#8217;s consider a completely sealed enclosure, but with a fan or blower inside that actively mixes the air. We can reasonably assume that well-mixed air is at a constant temperature throughout the cavity. In this case, it is appropriate to use the <em>Isothermal Domain</em> feature, which is available with the Heat Transfer Module when the <em>Isothermal domain</em> option is selected in the Settings window.</p>
<p><a href="https://cdn.comsol.com/wordpress/2017/04/Isothermal-Domain-interface-settings-windows.png" target="_blank"><img src="https://cdn.comsol.com/wordpress/2017/04/Isothermal-Domain-interface-settings-windows.png" title="Isothermal Domain settings" alt="A screenshot showing the different Settings windows for the Isothermal Domain interface." width="966" height="501" class="alignnone size-full wp-image-215401" /></a><br />
<em>The settings associated with using the Isothermal Domain interface.</em></p>
<p>A well-mixed air domain can be explicitly modeled using the Isothermal Domain feature. In the model, the temperature of the entire domain is a constant value. The temperature of the air is computed based upon the balance of heat entering and leaving the domain via the boundaries. The Isothermal Domain boundaries can be set as one of the following options:</p>
<ul>
<li><em>Thermally Insulated</em>: no heat transfer across the boundary</li>
<li><em>Continuity</em>: continuity of temperature across the boundary</li>
<li><em>Ventilation</em>: a known mass flow of fluid, of known temperature, into or out of the isothermal domain</li>
<li><em>Convective Heat Flux</em>: a user-specified heat transfer coefficient, as described earlier</li>
<li><em>Thermal Contact</em>: a specific thermal resistance</li>
</ul>
<p>Of all of these boundary condition options, the <em>Convective Heat Flux</em> is the most appropriate for well-mixed air in an enclosed cavity.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/04/Isothermal-Domain-feature-results.png" title="" alt="An image of simulation results found with the Isothermal Domain feature." width="375" height="375" class="alignnone size-full wp-image-215411" /><br />
<em>Representative results when using an Isothermal Domain feature. The well-mixed air domain is a constant temperature and there is heat transfer to the surrounding solid domains via a specified heat transfer coefficient.</em> </p>
<h3>Modeling the Airflow Explicitly</h3>
<p>The most computationally expensive approach, but also the most general, is to explicitly model the airflow. We can model both forced and free convection as well as simulate an internal or external flow. This type of modeling can be done with either the Heat Transfer Module or CFD Module.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/04/electronic-enclosure-cooling.png" title="" alt="An image showing the simulation results for air flow and temperature within an electronics enclosure." width="769" height="531" class="alignnone size-full wp-image-215771" /><br />
<em>An example of <a href="/model/forced-convection-cooling-of-an-enclosure-with-fan-and-grille-6222">computing air flow and temperature within an enclosure</a>.</em> </p>
<p>If you finished the <em>Introduction to COMSOL Multiphysics</em> booklet, you have already solved one example of an internal forced convection model. You can learn more about explicitly modeling airflow in the resources mentioned at the end of this post. </p>
<h3>When Can We Ignore Free Convection Entirely?</h3>
<p>We will finish up this topic by addressing the question: When can free convection in air be ignored and how can we model these cases? When a cavity&#8217;s dimensions are very small, such as a thin gap between parts or a very thin tube, we run into the possibility that the viscous damping will exceed any buoyancy forces. This balance of viscous to buoyancy forces is characterized by the <a href="https://en.wikipedia.org/wiki/Rayleigh%E2%80%93B%C3%A9nard_convection" target="_blank">nondimensional Rayleigh number</a>. The onset of free convection can be quite varied depending on boundary conditions and geometry. A good rule of thumb is that for dimensions less than 1mm, there will likely not be any free convection, but once the dimensions of the cavity get larger than 1cm, there likely will be free convective currents. </p>
<p>So how can we model heat transfer through these small gaps? If there is no air flow, then these air-filled regions can simply be modeled as either a solid or a fluid with no convective term. This is demonstrated in the <a href="/model/window-and-glazing-thermal-performances-16075">Window and Glazing Thermal Performances</a> tutorial. It is also appropriate to model the air as a solid within any microscale enclosed structure.</p>
<p>If these thin gaps are very small compared to the other dimensions of the system being analyzed, you can further simplify the gaps by modeling them via the Thin Layer boundary condition with a <em>Thermally thick approximation</em> layer type. This boundary condition introduces a jump in temperature across interior boundaries based on the specified thickness and thermal conductivity.  </p>
<p><img src="https://cdn.comsol.com/wordpress/2017/04/Thin-Layer-boundary-condition-settings.png" title="" alt="A screenshot of the settings for the Thin Layer boundary condition." width="450" height="507" class="alignnone size-full wp-image-215431" /><br />
<em>The Thin Layer boundary condition can model a thin air gap between parts.</em></p>
<p>We can use the previous two approaches within the core COMSOL Multiphysics package. In the Heat Transfer Module, there are additional options for the Thin Layer condition to consider more general and multilayer boundaries, which can be composed of several layers of materials.</p>
<h3>Closing Remarks on Modeling Natural and Forced Convection in COMSOL Multiphysics®</h3>
<p>Before closing out this discussion, we should also quickly address the question of radiative heat transfer. Although we haven&#8217;t discussed radiation here, an engineer must always take it into consideration. Surfaces exposed to ambient conditions will radiate heat to the surroundings and be heated by the Sun. The magnitude of radiative heating from the Sun is significant &mdash; about 1000 watts per square meter &mdash; and should not be neglected. For details on modeling radiative heat transfer to ambient conditions, read this <a href="/blogs/thermal-modeling-surfaces-wavelength-dependent-emissivity/">previous blog post</a>.</p>
<p>There will also be <a href="https://en.wikipedia.org/wiki/Thermal_radiation#Radiative_heat_transfer" target="_blank">radiative heat transfer</a> between interior surfaces. Radiative heat flux between surfaces is a function of the difference of temperature to the fourth power. Keep in mind that radiative heat transfer between two surfaces at 20°C and 50°C will be 200 watts per square meter at most, but rises to 1000 watts per square meter for surfaces at 20°C and 125°C. To correctly compute the radiative heat transfer between surfaces, it is also important to <a href="/blogs/computing-view-factors-with-the-heat-transfer-module/">compute the view factors</a> with the Heat Transfer Module.</p>
<p>Today we looked at several approaches for modeling convection, starting from the simplest approach of using a constant convective heat transfer coefficient. We then discussed using an Empirical Convective Correlation boundary condition before going over how to use an effective thermal conductivity within a domain and an isothermal domain feature, approaches with higher accuracy and only a slightly greater computational cost. The most computationally intensive approach &mdash; explicitly computing the flow field &mdash; is, of course, the most general. We also touched on when it is appropriate to neglect free convection entirely and how to model such situations. You should now have a greater understanding of the available options and trade-offs for modeling free and forced convection. Happy modeling! </p>
<div class="flex-center">
<a href="/contact" class="btn-solid btn-md btn-orange">Contact COMSOL for a Software Evaluation</a>
</div>
<h3>Additional Resources</h3>
<ul>
<li>Learn about explicitly modeling air flow and heat transfer on the COMSOL Blog
<ul>
<li><a href="/blogs/conjugate-heat-transfer/">Conjugate Heat Transfer</a></li>
<li><a href="/blogs/introduction-to-modeling-natural-convection-in-comsol-multiphysics/">Introduction to Modeling Natural Convection in COMSOL Multiphysics®</a></li>
<li><a href="/blogs/compressibility-options-and-buoyancy-forces-for-flow-simulations/">Compressibility Options and Buoyancy Forces for Flow Simulations</a></li>
<li><a href="/blogs/which-turbulence-model-should-choose-cfd-application/">Which Turbulence Model Should I Choose for My CFD Application?</a></li>
</ul>
</li>
<li>Get an introduction to simulating heat transfer in an <a href="/video/intro-to-modeling-heat-transfer-with-comsol-multiphysics">archived webinar</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>https://www.comsol.de/blogs/modeling-natural-and-forced-convection-in-comsol-multiphysics/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to Optimize the Spacing of Electromagnetic Coils</title>
		<link>https://www.comsol.de/blogs/how-to-optimize-the-spacing-of-electromagnetic-coils/</link>
		<comments>https://www.comsol.de/blogs/how-to-optimize-the-spacing-of-electromagnetic-coils/#comments</comments>
		<pubDate>Thu, 20 Apr 2017 15:20:06 +0000</pubDate>
		<dc:creator><![CDATA[Walter Frei]]></dc:creator>
				<category><![CDATA[AC/DC & Electromagnetics]]></category>
		<category><![CDATA[Electrical]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Optimization & Inverse Methods]]></category>
		<category><![CDATA[AC/DC Module]]></category>
		<category><![CDATA[Optimization Module]]></category>
		<category><![CDATA[Technical Content]]></category>

		<guid isPermaLink="false">http://com.staging.comsol.com/blogs?p=213861</guid>
		<description><![CDATA[When designing electromagnetic coils, we may want to adjust the position of the coils to achieve a desired magnetic field strength within a particular region of space. This is possible to do within the COMSOL Multiphysics® software by using the add-on AC/DC Module and Optimization Module to combine parameter and shape optimization. Let&#8217;s find out how. The Initial Coil Design and Optimization Problem Let&#8217;s suppose that we are tasked with designing a coil such that the magnetic field along part [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>When designing electromagnetic coils, we may want to adjust the position of the coils to achieve a desired magnetic field strength within a particular region of space. This is possible to do within the COMSOL Multiphysics® software by using the add-on AC/DC Module and Optimization Module to combine parameter and shape optimization. Let&#8217;s find out how.</p>
<p><span id="more-213861"></span></p>
<h3>The Initial Coil Design and Optimization Problem</h3>
<p>Let&#8217;s suppose that we are tasked with designing a coil such that the magnetic field along part of the centerline is as close to a target value as possible. As we saw in an <a href="/blogs/3-ways-to-optimize-the-current-in-electromagnetic-coils/">earlier blog post</a>, we can achieve this by adjusting the current through each turn of the coil to be different. However, this requires that we include a separate current control for each turn in our physical design. Instead, we can use a single current control for the entire coil and adjust the physical spacing of the coils along the axial direction.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/04/10-turn-axisymmetric-coil-COMSOL-Multiphysics.png" title="" alt="A schematic of a 10-turn axisymmetric coil." width="425" height="420" class="alignnone size-full wp-image-213891" /><br />
<em>A ten-turn axisymmetric coil. The objective is to alter the magnetic field at the centerline (green).</em></p>
<p>The case that we will consider here is shown in the image above. A ten-turn axisymmetric coil is driven by a single current source; that is, the same current flows through each turn. The initial coil design spaces the 1-cm-diameter coil turns a distance of <em>S<sub>0</sub></em> = 4 cm apart. Since the coil is axisymmetric (and we are only interested in solutions that are symmetric about the <em>z</em> = 0 plane), we can use the reduced computational domain shown in the schematic below.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/04/electromagnetic-coil-computational-model-schematic.png" title="" alt="A schematic of the computational model for the electromagnetic coil." width="350" height="375" class="alignnone size-full wp-image-213901" /><br />
<em>The computational model. We want to change the five coil positions and the coil current.</em></p>
<p>Our optimization objective is to get the <em>B<sub>z</sub></em> field as close as possible to a desired value, <em>B<sub>0</sub></em>, along a portion of the centerline by changing the coil current and <em>z</em>-location of the five coils. Each coil can move <img class="latexImg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAE4AAAAUCAMAAAAUYfu+AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAADNQTFR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and there must be a gap of <em>G<sub>0</sub></em> between the adjacent coils, so the first coil offset has a different lower bound. We also need to include a constraint on the peak current as well as constrain the current to be greater than zero. Although physically speaking, it isn&#8217;t necessary to constrain the current to be greater than zero, it&#8217;s a good optimization modeling practice to do so, since this keeps the constrained design space small.</p>
<p>More formally, these statements can be written as:</p>
<div class="latex">\begin{aligned}<br />
&amp; \underset{I, \Delta Z_1, \ldots ,\Delta Z_5}{\text{minimize:}}<br />
&amp; &amp; \frac{1}{L_0} \int_0^{L_0} \left( \frac{B_z}{B_0} -1 \right) ^2 d l  \\<br />
&amp; \text{subject to:}<br />
&amp; &amp; -(S_0-G_0)/2 \le \Delta Z_1 \leq \Delta Z_{max}\\<br />
&amp; &amp; &amp; -\Delta Z_{max} \leq \Delta Z_2, \ldots ,\Delta Z_5 \leq \Delta Z_{max}\\<br />
&amp; &amp; &amp; G_0 \le (Z_5-Z_4) \\<br />
&amp; &amp; &amp; G_0 \le (Z_4-Z_3) \\<br />
&amp; &amp; &amp; G_0 \le (Z_3-Z_2) \\<br />
&amp; &amp; &amp; G_0 \le (Z_2-Z_1) \\<br />
&amp; &amp; &amp; 0 \leq I \leq I_{max}\\<br />
\end{aligned}</div>
<p>We solve this problem with a combination of parameter and shape optimization by using the <em>Optimization</em> and <em>Deformed Geometry</em> interfaces in COMSOL Multiphysics. </p>
<h3>Setting Up and Solving the Optimization Problem in COMSOL Multiphysics®</h3>
<p>We can begin our implementation by reviewing the <a href="/blogs/3-ways-to-optimize-the-current-in-electromagnetic-coils/">model developed here</a>, which optimizes for a particular field value. We start with the same <em>Optimization</em> interface and <em>Integral Objective</em> feature introduced in the previous blog post. Two <em>Global Control Variable</em> features are then used. The first sets up the displacements of the five coils, using <em>Control Variables Scaling</em> to scale the optimization variables close to unity. The second <em>Global Control Variables</em> feature similarly defines and constrains the current.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/04/variable-definitions-for-the-five-coil-positions-in-COMSOL-Multiphysics.png" title="" alt="A screenshot of the variable definitions for the five coil positions in COMSOL Multiphysics®." width="598" height="647" class="alignnone size-full wp-image-213921" /><br />
<em>The definitions of the variables that control the five coils&#8217; positions.</em></p>
<p>The five <em>Control Variables</em> shown in the screenshot above define the displacements of the coils, as well as a small square region of space around each coil, which is shown as the green domains in the illustration below. As these green domains move up and down, the surrounding yellow domains must stretch and shrink to accommodate, while the surrounding blue domain is fixed. Since we know the displacements of the green domains, we can specify a linear variation of displacement along all of the red edges. This linear displacement variation is computed using a <em>Coefficient Form Boundary PDE</em> interface, as described in an earlier blog post on <a href="/blogs/model-translational-motion-with-the-deformed-mesh-interfaces/">modeling translational motion</a>. </p>
<p><img src="https://cdn.comsol.com/wordpress/2017/04/model-domains-deformation-definitions.png" title="" alt="A schematic of the deformation definitions for the model domains." width="500" height="460" class="alignnone size-full wp-image-213931" /><br />
<em>The definitions of the deformations for the various domains in the model.</em></p>
<p>This information about the specified displacements of the various domains is set up using the <em>Deformed Geometry</em> interface, as shown in the screenshot below. The <em>Prescribed Deformation</em> domain features move the green domains and the yellow domains are allowed to deform due to the <em>Free Deformation</em> domains. The <em>Prescribed Mesh Displacement</em> boundary features apply to the black and red edges and completely define the deformations of the yellow domains.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/04/Prescribed-Deformation-feature-in-the-Deformed-Geometry-interface-in-COMSOL-Multiphysics.png" title="" alt="A screenshot of the settings for the Prescribed Deformation feature in the Deformed Geometry interface." width="531" height="443" class="alignnone size-full wp-image-213941" /><br />
<em>The control over the coil turn displacement via the Prescribed Deformation feature in the</em> Deformed Geometry <em>interface.</em></p>
<p>As a consequence of setting up the <em>Deformed Geometry</em> interface in this way, the five control variables for the positions of the coils now represent a shape optimization problem. Previously, we have discussed <a href="/blogs/designing-new-structures-with-shape-optimization/">shape optimization</a> in a more general case from structural mechanics. Shape optimization takes advantage of the ability of COMSOL Multiphysics to <a href="/blogs/computing-design-sensitivities-in-comsol-multiphysics/">compute design sensitivities</a> with respect to changes in the shape of the geometry.</p>
<p>We also need to define a set of <em>Global Inequality Constraints</em> to prevent the green domains surrounding the coils from getting too close to each other and intersecting. The screenshot below shows this implementation. Note that the constraint is scaled with respect to the gap size <em>G<sub>0</sub></em> so that the constraint equation is also close to one in magnitude.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/04/model-builder-constraint-expression-in-an-input-field.png" title="" alt="A screenshot showing a constraint expression in an input field." width="596" height="402" class="alignnone size-full wp-image-213951" /><br />
<em>One of the four constraints that keep the coils from getting too close to each other.</em></p>
<p>Due to the large deformations that can occur in the domains around the coils that stretch and contract, it is also helpful to use a mapped mesh.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/04/mapped-mesh-for-deforming-domains-around-electromagnetic-coils.png" title="" alt="A screen capture showing the mapped mesh used for the deforming domains around the electromagnetic coils." width="500" height="500" class="alignnone size-full wp-image-213961" /><br />
<em>A mapped mesh is used in the deforming domains around the coils. The infinite element domain also has a mapped mesh.</em> </p>
<p>We can then solve this problem using a gradient-based optimization solver (SNOPT), taking advantage of the analytically computed gradients. The current through the coil and the coil positions are adjusted to minimize the above objective function. The results of the optimization are shown in the figure below.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/04/magnetic-flux-density-plot.png" title="" alt="A graph plotting the z-component of the magnetic flux density along the centerline for the optimized coil." width="600" height="300" class="alignnone size-full wp-image-213971" /><br />
<em>The magnetic flux density&#8217;s</em> z<em>-component along the centerline for the optimized coil.</em></p>
<p><img src="https://cdn.comsol.com/wordpress/2017/04/optimized-electromagnetic-coil-positions.png" title="" alt="A graphic showing the optimized coil positions." width="435" height="435" class="alignnone size-full wp-image-213981" /><br />
<em>The optimized coil positions.</em></p>
<h3>Concluding Thoughts on Optimizing the Spacing of Electromagnetic Coils</h3>
<p>We have introduced a model that uses a combination of shape and parameter optimization to adjust the coil current and spacing between the coils in a 2D axisymmetric coil. By taking advantage of the <em>Optimization</em> and <em>Deformed Geometry</em> interfaces, we are able to analytically compute the derivatives for this problem and converge to an optimum very quickly. </p>
<div class="flex-center">
<a href="/model/optimizing-coils-48041" class="btn-solid btn-md btn-red">Get the Model Files</a>
</div>
<h3>Further Resources</h3>
<ul>
<li>Read a blog post on <a href="/blogs/part-1-how-to-model-a-linear-electromagnetic-plunger/">modeling a linear electromagnetic plunger</a></li>
<li>Browse the <a href="/blogs/category/all/optimization/">Optimization category</a> on the COMSOL Blog</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>https://www.comsol.de/blogs/how-to-optimize-the-spacing-of-electromagnetic-coils/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
