<?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; LiveLink for Excel</title>
	<atom:link href="http://www.comsol.no/blogs/category/interfacing/livelink-for-excel/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.comsol.no/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>Building COMSOL Multiphysics® Models with Excel® and Visual Basic®</title>
		<link>https://www.comsol.no/blogs/building-comsol-multiphysics-models-with-excel-and-visual-basic/</link>
		<comments>https://www.comsol.no/blogs/building-comsol-multiphysics-models-with-excel-and-visual-basic/#comments</comments>
		<pubDate>Wed, 15 Mar 2017 19:55:48 +0000</pubDate>
		<dc:creator><![CDATA[Kristoffer Raneflod]]></dc:creator>
				<category><![CDATA[Interfacing]]></category>
		<category><![CDATA[LiveLink for Excel]]></category>
		<category><![CDATA[Technical Content]]></category>

		<guid isPermaLink="false">http://com.staging.comsol.com/blogs?p=209241</guid>
		<description><![CDATA[Have you ever thought about customizing or building a model in the COMSOL Multiphysics® software that is based on data from Excel® spreadsheet software? Excel spreadsheets are used to present, collaborate, and store data within many science and engineering applications. Using Microsoft® Visual Basic® for Applications and LiveLink™ for Excel®, we can build and control model settings and parameters within the Excel® spreadsheet software. In this blog post, we illustrate this process and go over a few examples. Using LiveLink™ [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Have you ever thought about customizing or building a model in the COMSOL Multiphysics® software that is based on data from Excel® spreadsheet software? Excel spreadsheets are used to present, collaborate, and store data within many science and engineering applications. Using Microsoft® Visual Basic® for Applications and LiveLink™ <em>for</em> Excel®, we can build and control model settings and parameters within the Excel® spreadsheet software. In this blog post, we illustrate this process and go over a few examples. </p>
<p><span id="more-209241"></span></p>
<h3>Using LiveLink™ <em>for</em> Excel® with Microsoft® Visual Basic® for Applications</h3>
<p>LiveLink™ <em>for</em> Excel® is an interfacing product that enables you to connect your Excel data to COMSOL Multiphysics simulations. If you are a new user of LiveLink™ <em>for</em> Excel®, you can get started by reading the following documentation (accessible after installing the software):</p>
<ul>
<li><em>Introduction to LiveLink™</em> for <em>Excel®</em></li>
<li><em>LiveLink™</em> for <em>Excel® User’s Guide</em></li>
</ul>
<p>The Excel® spreadsheet software also provides the functionality to define and run VBA (Microsoft® Visual Basic® for Applications) from within an Excel workbook. Although we can write the VBA scripts manually, it is also possible to generate them from an existing model using the COMSOL Multiphysics user interface. As we will see with the help of some examples, it is easy to implement the use of VBA with LiveLink™ <em>for</em> Excel®. We will look into a common application to retrieve and update parameters in a COMSOL Multiphysics model.</p>
<p>Although this functionality is useful, VBA and LiveLink™ <em>for</em> Excel® can be used for a lot more. We will, for example, see how it is possible to build a COMSOL Multiphysics model and define the model geometry with some basic shapes inserted in the Excel workbook.</p>
<blockquote><p>Note: The examples discussed here are shown with Excel® version 2010, but the process is the same in other versions.</p></blockquote>
<p>With VBA, it is possible to interface Component Object Model (COM) components. When LiveLink™ <em>for</em> Excel® is installed, it also installs a COM interface component that can be used to interface with COMSOL Multiphysics®. Two essential COM objects for interfacing between the COMSOL Multiphysics Server and COMSOL Multiphysics models are:</p>
<pre>
comsolcom.comsolutil
comsolcom.modelutil
</pre>
<p>By using <code>comsolcom.comsolutil</code>, it is possible to start a COMSOL Multiphysics Server, connect, and disconnect from the server. With <code > comsolcom.modelutil</code>, we can interface with COMSOL Multiphysics models.</p>
<h4>Using the VBA Editor</h4>
<p>We can write and edit VBA scripts in Excel workbooks with the help of the editor that is installed with the Excel® spreadsheet software. The editor window can be accessed in a couple of different ways. For example, the editor is shown if we right-click an Excel worksheet tab and select <em>View Code</em>. The editor is also displayed if we create or edit a macro. It is also possible to enable a <em>Developer</em> tab in the toolbar in Excel® spreadsheet software that contains buttons for accessing the editor and other development-related functionality.</p>
<p><a href="https://cdn.comsol.com/wordpress/2017/03/Developer_tab.png" target="_blank"><img src="https://cdn.comsol.com/wordpress/2017/03/Developer_tab.png" title="Excel sheet" alt="Screenshot of a sheet in Excel." width="977" height="326" class="alignnone size-full wp-image-209391" /></a></p>
<h4>Accessing COM Components in VBA</h4>
<p>We can create dynamic instances of the <code>comsolcom.comsolutil</code> and <code > comsolcom.modelutil</code> objects in VBA with the following declaration.</p>
<pre>
<span style="color:#0000FF">Set</span> comsolutil = CreateObject(<span style="color:#003366">"comsolcom.comsolutil"</span>)
<span style="color:#0000FF">Set</span> modelutil = CreateObject(<span style="color:#003366">"comsolcom.modelutil"</span>)
</pre>
<p><a href="https://cdn.comsol.com/wordpress/2017/03/accessing-COM-components-in-VBA.png" target="_blank"><img src="https://cdn.comsol.com/wordpress/2017/03/accessing-COM-components-in-VBA.png" title="Accessing COM components" alt="Screenshot showing how to access COM components in VBA." width="977" height="475" class="alignnone size-full wp-image-209401" /></a></p>
<p>The advantage with this declaration is version independence. The latest installed versions of <code>comsolcom.comsolutil</code> and <code > comsolcom.modelutil</code> are used at runtime.</p>
<p>It is also possible to declare <code>comsolcom.comsolutil</code> and <code > comsolcom.modelutil</code> with a static COM reference using</p>
<pre>
<span style="color:#0000FF">Dim</span> comsolutil <span style="color:#0000FF">As</span> comsolutil
<span style="color:#0000FF">Set</span> comsolutil = CreateObject(<span style="color:#003366">"comsolcom.comsolutil"</span>)
<span style="color:#0000FF">Dim</span> modelutil <span style="color:#0000FF">As</span>  modelutil
<span style="color:#0000FF">Set</span> modelutil = CreateObject(<span style="color:#003366">"comsolcom.modelutil"</span>)
</pre>
<p><a href="https://cdn.comsol.com/wordpress/2017/03/alternate-method-for-accessing-COM-components-in-VBA.png" target="_blank"><img src="https://cdn.comsol.com/wordpress/2017/03/alternate-method-for-accessing-COM-components-in-VBA.png" title="Alternate way to access COM components" alt="Screenshot showing an alternate way of accessing COM components in VBA." width="977" height="475" class="alignnone size-full wp-image-209411" /></a></p>
<p>An advantage of using this declaration is that help will be available in VBA when using the defined types.</p>
<p><a href="https://cdn.comsol.com/wordpress/2017/03/VBA-help-options-screenshot.png" target="_blank"><img src="https://cdn.comsol.com/wordpress/2017/03/VBA-help-options-screenshot.png" title="Help options in VBA" alt="Screenshot showing the help options in VBA for defined types." width="978" height="588" class="alignnone size-full wp-image-209421" /></a></p>
<p>In order to be able to define static types for <code>comsolutil</code> and <code>modelutil</code>, we must add a COM reference to <code>ComsolCom</code>. We can do so by opening the VBA editor in the Excel® spreadsheet software, selecting the <em>Tools</em> menu, selecting <em>References</em>, and selecting <code > ComsolCom</code> for the installed version.</p>
<p><a href="https://cdn.comsol.com/wordpress/2017/03/adding-a-COM-reference.png" target="_blank"><img src="https://cdn.comsol.com/wordpress/2017/03/adding-a-COM-reference.png" title="Adding a COM reference" alt="Screenshot demonstrating how to add a COM reference." width="977" height="588" class="alignnone size-full wp-image-209431" /></a></p>
<h3>Start a COMSOL Multiphysics Server, Connect, and Disconnect with VBA</h3>
<p>The following short VBA script illustrates how to start a COMSOL Multiphysics Server, connect to the started server, and then disconnect from the server. The line call <code>comsolutil.TimeOutHandle(True)</code> applies a timeout handler that tells Excel® spreadsheet software to wait for long-running commands to return.</p>
<pre>
<span style="color:#0000FF">Set</span> comsolutil = CreateObject(<span style="color:#003366">"comsolcom.comsolutil"</span>)
<span style="color:#0000FF">Set</span> modelutil = CreateObject(<span style="color:#003366">"comsolcom.modelutil"</span>)
<span style="color:#0000FF">Call</span> comsolutil.TimeOuthandler(<span style="color:#0000FF">True</span>)
<span style="color:#0000FF">Call</span> comsolutil.StartComsolServer(<span style="color:#0000FF">True</span>)
<span style="color:#0000FF">Call</span> modelutil.connect
<span style="color:#0000FF">Call</span> modelutil.Disconnect
</pre>
<p><a href="https://cdn.comsol.com/wordpress/2017/03/Visual-Basic-screenshot-showing-how-to-start-a-COMSOL-Server.png" target="_blank"><img src="https://cdn.comsol.com/wordpress/2017/03/Visual-Basic-screenshot-showing-how-to-start-a-COMSOL-Server.png" title="Starting a COMSOL Multiphysics Server" alt="Screenshot of Visual Basic showing how to start a COMSOL Multiphysics Server." width="977" height="460" class="alignnone size-full wp-image-209441" /></a></p>
<h4>Migrating from COMSOL API for Use with Java® and Application Methods</h4>
<p>If you have experience with the COMSOL API for use with Java® or writing code in application methods, there is a syntax difference that is good to know about. When retrieving a list of model features, for example, the syntax is similar for studies in the model. Thus, for retrieving studies in a model, the following syntax works:</p>
<pre>
model.study()
</pre>
<p>However, when accessing a specific study, the syntax is different. For example, when retrieving a study with the study tag <code>std1</code> with the COMSOL API for use with Java® or code in applications, the syntax <code > model.study("std1")</code> works. However, with VBA® and LiveLink™ <em>for</em> Excel®, the following syntax must be used instead:</p>
<pre>
model.get_study(<span style="color:#003366">"std1"</span>)
</pre>
<h4>Interface Parameters in COMSOL Multiphysics® Models</h4>
<p>A common application of VBA and LiveLink™ <em>for</em> Excel® is to retrieve and update parameters in a COMSOL Multiphysics® model. Here, we will see how easily this can be achieved.</p>
<p>The following VBA script starts a COMSOL Multiphysics Server, connects to the started server, loads the <a href="/model/electrical-heating-in-a-busbar-using-the-livelink-8482-for-excel-174-13909">Electrical Heating in a Busbar Using the LiveLink™ <em>for</em> Excel®</a> model from the same directory as the active Excel® workbook, solves the model with an updated length parameter, and saves the updated model with another file name.</p>
<p><a href="https://cdn.comsol.com/wordpress/2017/03/VBA-script-start-and-connect-to-a-COMSOL-Multiphysics-Server.png" target="_blank"><img src="https://cdn.comsol.com/wordpress/2017/03/VBA-script-start-and-connect-to-a-COMSOL-Multiphysics-Server.png" title="Starting and connecting to a COMSOL Multiphysics Server" alt="VBA script for starting and connecting to a COMSOL Multiphysics Server." width="977" height="540" class="alignnone size-full wp-image-209451" /></a></p>
<p>The following VBA script extracts parameter data for parameters in the model and inserts them into the Excel workbook.</p>
<p><a href="https://cdn.comsol.com/wordpress/2017/03/VBA-script-to-extract-COMSOL-Multiphysics-data.png" target="_blank"><img src="https://cdn.comsol.com/wordpress/2017/03/VBA-script-to-extract-COMSOL-Multiphysics-data.png" title="Extracting COMSOL Multiphysics model parameter data" alt="VBA script for extracting COMSOL Multiphysics model parameter data and adding them to Excel." width="977" height="540" class="alignnone size-full wp-image-209461" /></a></p>
<h3>How to Build COMSOL Multiphysics® Models with Excel® and Visual Basic®</h3>
<p>In the next example, we create a COMSOL Multiphysics model and solve a 2D simulation using the <em>Heat Transfer in Solids</em> interface. The process involves defining geometry within Excel® spreadsheet software by adding a text box with some instructions, an outer temperature boundary, an inner temperature boundary, and a button for solving the simulation. When the model is solved, a results plot is inserted in the Excel® workbook. Let&#8217;s go through these steps in detail.</p>
<p>1. First, we create a text box with instructional text and insert it into the Excel workbook.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/03/inserting-a-text-box.png" title="" alt="Inserting a text box into an Excel workbook." width="977" height="725" class="alignnone size-full wp-image-209471" /></p>
<p>2. Then, we define a region for the simulation. We select a freeform shape and insert it in the Excel® workbook. Then, we select <em>SimulationRegion</em> as the name for the shape. We make the polygon editable by right-clicking on the shape and selecting <em>Edit Polygon</em>. Then, we edit the shape as shown below.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/03/Excel-workbook-editing-polygon.png" title="" alt="Editing a polygon in an Excel workbook." width="977" height="725" class="alignnone size-full wp-image-209481" /></p>
<p>3. We create an inner boundary with a higher temperature. To do so, we use an oval shape, create a circle, and insert it inside the freeform. We select <em>HeatSource</em> as the name for the shape. The oval shape must reside inside the <em>SimulationRegion</em> shape.</p>
<p><img src="https://cdn.comsol.com/wordpress/2017/03/creating-an-inner-boundary-in-a-workbook.png" title="" alt="Creating an inner boundary in the polygon in the Excel workbook." width="977" height="725" class="alignnone size-full wp-image-209491" /></p>
<p>4. We then add a text box shape with the text <em>Solve</em> to use as a button. We right-click on the button, select <em>Assign Macro</em>, and create a new macro named <em>Solve_Click</em>.</p>
<p>5. Next, we open the assigned macro in the VBA® editor and replace the content with the following script:</p>
<p><a href="#VBACode">Expand or collapse VBA code&#8230;</a></p>
<div class="collapse" id="VBACode">
<pre>
<span style="color:#0000FF">Option</span> Explicit
 
<span style="color:#0000FF">Sub</span> Solve_Click()
 
<span style="color:#0000FF">Dim</span> node
<span style="color:#0000FF">Dim</span> coordinates
<span style="color:#0000FF">Dim</span> index
<span style="color:#0000FF">Dim</span> newPolygonTable() <span style="color:#0000FF">As Double</span>
<span style="color:#0000FF">Dim</span> newHeatSource(1 <span style="color:#0000FF">To</span> 2) <span style="color:#0000FF">As Double</span>
<span style="color:#0000FF">Dim</span> model <span style="color:#0000FF">As</span> ModelImpl
 
newHeatSource(1) = Sheets(<span style="color:#003366">"Sheet1"</span>).Shapes(<span style="color:#003366">"HeatSource"</span>).DrawingObject.Left + (Sheets(<span style="color:#003366">"Sheet1"</span>).Shapes(<span style="color:#003366">"HeatSource"</span>).DrawingObject.Width / 2)
newHeatSource(2) = Sheets(<span style="color:#003366">"Sheet1"</span>).Application.Height - (Sheets(<span style="color:#003366">"Sheet1"</span>).Shapes(<span style="color:#003366">"HeatSource"</span>).DrawingObject.Top + (Sheets(<span style="color:#003366">"Sheet1"</span>).Shapes(<span style="color:#003366">"HeatSource"</span>).DrawingObject.Height / 2))
 
<span style="color:#0000FF">Dim</span> nNodes <span style="color:#0000FF">As Long</span>
nNodes = Sheets(<span style="color:#003366">"Sheet1"</span>).Shapes(<span style="color:#003366">"SimulationRegion"</span>).Nodes.Count
<span style="color:#0000FF">ReDim Preserve</span> newPolygonTable(1 <span style="color:#0000FF">To</span> nNodes, 1 <span style="color:#0000FF">To</span> 2)
 
<span style="color:#0000FF">For Each</span> node <span style="color:#0000FF">In</span> Sheets(<span style="color:#003366">"Sheet1"</span>).Shapes(<span style="color:#003366">"SimulationRegion"</span>).Nodes
    coordinates = node.points
    index = index + 1
    newPolygonTable(index, 1) = coordinates(1, 1)
    newPolygonTable(index, 2) = Sheets(<span style="color:#003366">"Sheet1"</span>).Application.Height - coordinates(1, 2)
<span style="color:#0000FF">Next</span>
 
<span style="color:#0000FF">Set</span> model = SetModel(newPolygonTable, newHeatSource)
 
<span style="color:#0000FF">Call</span> model.get_study(<span style="color:#003366">"std1"</span>).Run
 
<span style="color:#0000FF">If Not</span> ContainsTag(model.result().tags(), <span style="color:#003366">"pg1"</span>) <span style="color:#0000FF">Then</span>
    <span style="color:#0000FF">Call</span> model.result().Create(<span style="color:#003366">"pg1"</span>, <span style="color:#003366">"PlotGroup2D"</span>)
   <span style="color:#0000FF">Call</span> model.get_result(<span style="color:#003366">"pg1"</span>).feature().Create(<span style="color:#003366">"surf1"</span>, <span style="color:#003366">"Surface"</span>)
    <span style="color:#0000FF">Call</span> model.get_result(<span style="color:#003366">"pg1"</span>).Label(<span style="color:#003366">"Temperature (ht)"</span>)
    <span style="color:#0000FF">Call</span> model.get_result(<span style="color:#003366">"pg1"</span>).set(<span style="color:#003366">"data"</span>, <span style="color:#003366">"dset1"</span>)
   <span style="color:#0000FF">Call</span> model.get_result(<span style="color:#003366">"pg1"</span>).get_feature(<span style="color:#003366">"surf1"</span>).Label(<span style="color:#003366">"Surface"</span>)
    <span style="color:#0000FF">Call</span> model.get_result(<span style="color:#003366">"pg1"</span>).get_feature(<span style="color:#003366">"surf1"</span>).set(<span style="color:#003366">"colortable"</span>, <span style="color:#003366">"ThermalLight"</span>)
    <span style="color:#0000FF">Call</span> model.get_result(<span style="color:#003366">"pg1"</span>).get_feature(<span style="color:#003366">"surf1"</span>).set(<span style="color:#003366">"data"</span>, <span style="color:#003366">"parent"</span>)
    <span style="color:#0000FF">Call</span> model.get_result(<span style="color:#003366">"pg1"</span>).get_feature(<span style="color:#003366">"surf1"</span>).Run
<span style="color:#0000FF">End If</span>
<span style="color:#0000FF">Call</span> model.get_result(<span style="color:#003366">"pg1"</span>).Run
 
<span style="color:#0000FF">Call</span> Range(<span style="color:#003366">"J10"</span>).<span style="color:#0000FF">Select</span>
<span style="color:#0000FF">Dim</span> tempPng <span style="color:#0000FF">As String</span>
tempPng = Environ(<span style="color:#003366">"Temp"</span>) &amp; <span style="color:#003366">"\PolygonHeat"</span> &amp; Format(Now(), <span style="color:#003366">"yyyymmddhhmmss"</span>) &amp; <span style="color:#003366">".png"</span>
 
<span style="color:#0000FF">Dim</span> exportTag <span style="color:#0000FF">As String</span>
exportTag = model.result().Export.uniquetag(<span style="color:#003366">"export"</span>)
<span style="color:#0000FF">Call</span> model.result().Export().Create(exportTag, <span style="color:#003366">"Image2D"</span>)
<span style="color:#0000FF">Call</span> model.result().get_export(exportTag).set(<span style="color:#003366">"plotgroup"</span>, <span style="color:#003366">"pg1"</span>)
<span style="color:#0000FF">Call</span> model.result().get_export(exportTag).set(<span style="color:#003366">"pngfilename"</span>, tempPng)
<span style="color:#0000FF">Call</span> model.result().get_export(exportTag).Run
 
<span style="color:#0000FF">If</span> Dir(tempPng)  <span style="color:#003366">""</span> <span style="color:#0000FF">Then</span>
   <span style="color:#0000FF">Call</span> Application.ActiveSheet.Pictures.Insert(tempPng)
    SetAttr tempPng, vbNormal
    Kill tempPng
<span style="color:#0000FF">End If</span>
 
<span style="color:#0000FF">Call</span> model.result().Export().Remove(exportTag)
 
<span style="color:#0000FF">End Sub</span>
 
<span style="color:#0000FF">Private Function</span> SetModel(<span style="color:#0000FF">ByRef</span> newPolygonTable() <span style="color:#0000FF">As Double</span>, <span style="color:#0000FF">ByRef</span> newHeatSource() <span style="color:#0000FF">As Double</span>) <span style="color:#0000FF">As Variant</span>
 
<span style="color:#0000FF">Dim</span> comsolutil <span style="color:#0000FF">As</span> comsolutil
<span style="color:#0000FF">Set</span> comsolutil = CreateObject(<span style="color:#003366">"comsolcom.comsolutil"</span>)
<span style="color:#0000FF">Dim</span> modelutil <span style="color:#0000FF">As</span> modelutil
<span style="color:#0000FF">Set</span> modelutil = CreateObject(<span style="color:#003366">"comsolcom.modelutil"</span>)
<span style="color:#0000FF">Dim</span> model <span style="color:#0000FF">As</span> ModelImpl
 
<span style="color:#0000FF">If Not</span> IsConnected(modelutil) <span style="color:#0000FF">Then</span>
    <span style="color:#0000FF">Call</span> ConnectServer(comsolutil, modelutil)
<span style="color:#0000FF">End If</span>
 
<span style="color:#0000FF">If Not</span> ContainsTag(modelutil.tags(), <span style="color:#003366">"PolygonHeatModel"</span>) <span style="color:#0000FF">Then</span>
    <span style="color:#0000FF">Set</span> SetModel = CreateModel(modelutil, <span style="color:#003366">"PolygonHeatModel"</span>, newPolygonTable, newHeatSource)
    <span style="color:#0000FF">Exit Function</span>
<span style="color:#0000FF">End If</span>
 
<span style="color:#0000FF">Set</span> model = modelutil.model(<span style="color:#003366">"PolygonHeatModel"</span>)
<span style="color:#0000FF">Call</span> model.get_geom(<span style="color:#003366">"geom1"</span>).get_feature(<span style="color:#003366">"pol1"</span>).set(<span style="color:#003366">"table"</span>, newPolygonTable)
 
<span style="color:#0000FF">Call</span> model.get_geom(<span style="color:#003366">"geom1"</span>).get_feature(<span style="color:#003366">"c1"</span>).set(<span style="color:#003366">"x"</span>, newHeatSource(1))
<span style="color:#0000FF">Call</span> model.get_geom(<span style="color:#003366">"geom1"</span>).get_feature(<span style="color:#003366">"c1"</span>).set(<span style="color:#003366">"y"</span>, newHeatSource(2))
<span style="color:#0000FF">Call</span> model.get_geom(<span style="color:#003366">"geom1"</span>).runAll
 
<span style="color:#0000FF">Set</span> SetModel = model
 
<span style="color:#0000FF">End Function</span>
 
<span style="color:#0000FF">Private Function</span> CreateModel(<span style="color:#0000FF">ByRef</span> modelutil <span style="color:#0000FF">As</span> modelutil, <span style="color:#0000FF">ByRef</span> modelTag <span style="color:#0000FF">As String</span>, <span style="color:#0000FF">ByRef</span> newPolygonTable() <span style="color:#0000FF">As Double</span>, <span style="color:#0000FF">ByRef</span> newHeatSource() <span style="color:#0000FF">As Double</span>) <span style="color:#0000FF">As Variant</span>
<span style="color:#0000FF">Dim</span> model <span style="color:#0000FF">As</span> ModelImpl
<span style="color:#0000FF">Set</span> model = modelutil.Create(modelTag)
 
<span style="color:#0000FF">Call</span> model.ModelNode().Create(<span style="color:#003366">"comp1"</span>)
 
<span style="color:#0000FF">Call</span> model.geom().Create(<span style="color:#003366">"geom1"</span>, 2)
<span style="color:#0000FF">Call</span> model.mesh().Create(<span style="color:#003366">"mesh1"</span>, <span style="color:#003366">"geom1"</span>)
 
<span style="color:#0000FF">Call</span> model.get_geom(<span style="color:#003366">"geom1"</span>).Create(<span style="color:#003366">"pol1"</span>, <span style="color:#003366">"Polygon"</span>)
<span style="color:#0000FF">Call</span> model.get_geom(<span style="color:#003366">"geom1"</span>).get_feature(<span style="color:#003366">"pol1"</span>).set(<span style="color:#003366">"source"</span>, <span style="color:#003366">"table"</span>)
<span style="color:#0000FF">Call</span> model.get_geom(<span style="color:#003366">"geom1"</span>).get_feature(<span style="color:#003366">"pol1"</span>).set(<span style="color:#003366">"table"</span>, newPolygonTable)
<span style="color:#0000FF">Call</span> model.get_geom(<span style="color:#003366">"geom1"</span>).Selection().Create(<span style="color:#003366">"csel1"</span>, <span style="color:#003366">"CumulativeSelection"</span>)
<span style="color:#0000FF">Call</span> model.get_geom(<span style="color:#003366">"geom1"</span>).get_feature(<span style="color:#003366">"pol1"</span>).set(<span style="color:#003366">"contributeto"</span>, <span style="color:#003366">"csel1"</span>)
<span style="color:#0000FF">Call</span> model.get_geom(<span style="color:#003366">"geom1"</span>).get_run(<span style="color:#003366">"pol1"</span>)
 
<span style="color:#0000FF">Call</span> model.get_geom(<span style="color:#003366">"geom1"</span>).Create(<span style="color:#003366">"c1"</span>, <span style="color:#003366">"Circle"</span>)
<span style="color:#0000FF">Call</span> model.get_geom(<span style="color:#003366">"geom1"</span>).get_feature(<span style="color:#003366">"c1"</span>).set(<span style="color:#003366">"r"</span>, 0.01)
<span style="color:#0000FF">Call</span> model.get_geom(<span style="color:#003366">"geom1"</span>).get_feature(<span style="color:#003366">"c1"</span>).set(<span style="color:#003366">"x"</span>, newHeatSource(1))
<span style="color:#0000FF">Call</span> model.get_geom(<span style="color:#003366">"geom1"</span>).get_feature(<span style="color:#003366">"c1"</span>).set(<span style="color:#003366">"y"</span>, newHeatSource(2))
<span style="color:#0000FF">Call</span> model.get_geom(<span style="color:#003366">"geom1"</span>).Selection().Create(<span style="color:#003366">"csel2"</span>, <span style="color:#003366">"CumulativeSelection"</span>)
<span style="color:#0000FF">Call</span> model.get_geom(<span style="color:#003366">"geom1"</span>).get_feature(<span style="color:#003366">"c1"</span>).set(<span style="color:#003366">"contributeto"</span>, <span style="color:#003366">"csel2"</span>)
 
<span style="color:#0000FF">Call</span> model.get_geom(<span style="color:#003366">"geom1"</span>).Run
<span style="color:#0000FF">Call</span> model.get_geom(<span style="color:#003366">"geom1"</span>).get_run(<span style="color:#003366">"fin"</span>)
 
<span style="color:#0000FF">Call</span> model.Material().Create(<span style="color:#003366">"mat1"</span>, <span style="color:#003366">"Common"</span>, <span style="color:#003366">"comp1"</span>)
<span style="color:#0000FF">Call</span> model.get_material(<span style="color:#003366">"mat1"</span>).set(<span style="color:#003366">"family"</span>, <span style="color:#003366">"copper"</span>)
<span style="color:#0000FF">Call</span> model.get_material(<span style="color:#003366">"mat1"</span>).get_propertyGroup(<span style="color:#003366">"def"</span>).set(<span style="color:#003366">"heatcapacity"</span>, <span style="color:#003366">"385[J/(kg*K)]"</span>)
<span style="color:#0000FF">Call</span> model.get_material(<span style="color:#003366">"mat1"</span>).get_propertyGroup(<span style="color:#003366">"def"</span>).set(<span style="color:#003366">"density"</span>, <span style="color:#003366">"8960[kg/m^3]"</span>)
<span style="color:#0000FF">Call</span> model.get_material(<span style="color:#003366">"mat1"</span>).get_propertyGroup(<span style="color:#003366">"def"</span>).set(<span style="color:#003366">"thermalconductivity"</span>, <span style="color:#003366">"400[W/(m*K)]"</span>)
 
<span style="color:#0000FF">Call</span> model.Physics().Create(<span style="color:#003366">"ht"</span>, <span style="color:#003366">"HeatTransfer"</span>, <span style="color:#003366">"geom1"</span>)
<span style="color:#0000FF">Call</span> model.get_physics(<span style="color:#003366">"ht"</span>).Create(<span style="color:#003366">"temp1"</span>, <span style="color:#003366">"TemperatureBoundary"</span>, 1)
<span style="color:#0000FF">Call</span> model.get_physics(<span style="color:#003366">"ht"</span>).Create(<span style="color:#003366">"temp2"</span>, <span style="color:#003366">"TemperatureBoundary"</span>, 1)
<span style="color:#0000FF">Call</span> model.get_physics(<span style="color:#003366">"ht"</span>).get_feature(<span style="color:#003366">"temp2"</span>).set(<span style="color:#003366">"T0"</span>, <span style="color:#003366">"293.15[K]+20"</span>)
<span style="color:#0000FF">Call</span> model.get_physics(<span style="color:#003366">"ht"</span>).get_feature(<span style="color:#003366">"temp1"</span>).Selection().named(<span style="color:#003366">"geom1_csel1_bnd"</span>)
<span style="color:#0000FF">Call</span> model.get_physics(<span style="color:#003366">"ht"</span>).get_feature(<span style="color:#003366">"temp2"</span>).Selection().named(<span style="color:#003366">"geom1_csel2_bnd"</span>)
 
<span style="color:#0000FF">Call</span> model.study().Create(<span style="color:#003366">"std1"</span>)
<span style="color:#0000FF">Call</span> model.get_study(<span style="color:#003366">"std1"</span>).Create(<span style="color:#003366">"stat"</span>, <span style="color:#003366">"Stationary"</span>)
<span style="color:#0000FF">Call</span> model.get_study(<span style="color:#003366">"std1"</span>).Run
 
<span style="color:#0000FF">Call</span> model.result().Create(<span style="color:#003366">"pg1"</span>, <span style="color:#003366">"PlotGroup2D"</span>)
<span style="color:#0000FF">Call</span> model.get_result(<span style="color:#003366">"pg1"</span>).Label(<span style="color:#003366">"Temperature (ht)"</span>)
<span style="color:#0000FF">Call</span> model.get_result(<span style="color:#003366">"pg1"</span>).set("<span style="color:#003366">data"</span>, <span style="color:#003366">"dset1"</span>)
<span style="color:#0000FF">Call</span> model.get_result(<span style="color:#003366">"pg1"</span>).feature().Create(<span style="color:#003366">"surf1"</span>, <span style="color:#003366">"Surface"</span>)
<span style="color:#0000FF">Call</span> model.get_result(<span style="color:#003366">"pg1"</span>).get_feature(<span style="color:#003366">"surf1"</span>).Label(<span style="color:#003366">"Surface"</span>)
<span style="color:#0000FF">Call</span> model.get_result(<span style="color:#003366">"pg1"</span>).get_feature(<span style="color:#003366">"surf1"</span>).set(<span style="color:#003366">"colortable"</span>, <span style="color:#003366">"ThermalLight"</span>)
<span style="color:#0000FF">Call</span> model.get_result(<span style="color:#003366">"pg1"</span>).get_feature(<span style="color:#003366">"surf1"</span>).set(<span style="color:#003366">"data"</span>, <span style="color:#003366">"parent"</span>)
 
<span style="color:#0000FF">Set</span> CreateModel = model
 
<span style="color:#0000FF">End Function</span>
 
<span style="color:#0000FF">Private Function</span> IsConnected(modelutil <span style="color:#0000FF">As</span> modelutil) <span style="color:#0000FF">As Boolean</span>
 
<span style="color:#009900">'Try to access model tags. If not connected to a server this will throw an error.</span>
<span style="color:#0000FF">On Error GoTo</span> ErrorHandler
<span style="color:#0000FF">Call</span> modelutil.tags
IsConnected = <span style="color:#0000FF">True</span>
<span style="color:#0000FF">Exit Function</span>
 
ErrorHandler:
IsConnected = <span style="color:#0000FF">False</span>
 
<span style="color:#0000FF">End Function</span>
 
<span style="color:#0000FF">Private Function</span> ConnectServer(comsolutil <span style="color:#0000FF">As</span> comsolutil, modelutil <span style="color:#0000FF">As</span> modelutil)
 
<span style="color:#0000FF">On Error GoTo</span> ErrorHandler
<span style="color:#0000FF">Call</span> modelutil.connect
<span style="color:#0000FF">If Not</span> comsolutil.isGraphicsServer() <span style="color:#0000FF">Then</span>
    MsgBox prompt:=<span style="color:#003366">"The running COMSOL Multiphysics Server is not a graphics server. Exporting results will not work."</span>, Buttons:=vbOKOnly, Title:=<span style="color:#003366">"COMSOL"</span>
<span style="color:#0000FF">End If</span>
<span style="color:#0000FF">Exit Function</span>
 
ErrorHandler:
 
<span style="color:#0000FF">Call</span> comsolutil.TimeOuthandler(<span style="color:#0000FF">True</span>)
<span style="color:#0000FF">Call</span> comsolutil.StartComsolServer(<span style="color:#0000FF">True</span>)
<span style="color:#0000FF">Call</span> modelutil.connect
 
<span style="color:#0000FF">End Function</span>
 
<span style="color:#0000FF">Private Function</span> ContainsTag(tags() <span style="color:#0000FF">As String</span>, tag <span style="color:#0000FF">As String</span>) <span style="color:#0000FF">As Boolean</span>
 
ContainsTag = <span style="color:#0000FF">False</span>
<span style="color:#0000FF">If</span> (UBound(Filter(tags, tag)) &gt; -1) <span style="color:#0000FF">Then</span>
    ContainsTag = <span style="color:#0000FF">True</span>
<span style="color:#0000FF">End If</span>
 
<span style="color:#0000FF">End Function</span>
</pre>
</div>
<p>6. After inputting the code, we click on the <em>Solve</em> button. This executes the VBA script defined in the macro and creates the model based on the shapes in the Excel workbook. The model is solved and the graphics are inserted into the worksheet. </p>
<p><img src="https://cdn.comsol.com/wordpress/2017/03/insert-a-COMSOL-Multiphysics-model-into-an-Excel-worksheet.png" title="" alt="A COMSOL Multiphysics model is inserted into an Excel worksheet." width="977" height="835" class="alignnone size-full wp-image-209501" /></p>
<p>If the <em>SimulationRegion</em> shape is changed and the <em>HeatSource</em> shape is moved to another location inside the <em>SimulationRegion</em>, the model and results will be different.</p>
<p>It is easy to imagine how we can control and program this model based on other shapes, charts, and data in an Excel workbook. It is also possible to extract numerical results from the COMSOL Multiphysics model and generate Excel workbook content such as for reporting purposes, for example.</p>
<p>This blog post just scratches the surface with regard to what you can do using VBA and Excel® spreadsheet software. As a user, you have access to the entire COMSOL API, which gives access to all model settings and parameters. This makes it possible for you to define any type of model and extracts its data after having solved it using COMSOL Multiphysics.</p>
<div class="flex-center">
<a href="/video/comsol-multiphysics-simulations-excel-spreadsheets" class="btn-solid btn-md btn-green">Watch an Archived Webinar on LiveLink™ <em>for</em> Excel</a>
</div>
<p><em>Microsoft, Excel, and Visual Basic are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.</em></p>
<p><em>Oracle and Java are registered trademarks of Oracle and/or its affiliates.</em></p>
]]></content:encoded>
			<wfw:commentRss>https://www.comsol.no/blogs/building-comsol-multiphysics-models-with-excel-and-visual-basic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Create a Material Database from Spreadsheet Data</title>
		<link>https://www.comsol.no/blogs/create-material-database-spreadsheet-data/</link>
		<comments>https://www.comsol.no/blogs/create-material-database-spreadsheet-data/#comments</comments>
		<pubDate>Mon, 31 Mar 2014 15:20:41 +0000</pubDate>
		<dc:creator><![CDATA[Lars Gregersen]]></dc:creator>
				<category><![CDATA[Interfacing]]></category>
		<category><![CDATA[LiveLink for Excel]]></category>
		<category><![CDATA[Technical Content]]></category>

		<guid isPermaLink="false">http://com.staging.comsol.com/blogs/?p=29155</guid>
		<description><![CDATA[Modeling in COMSOL Multiphysics involves a lot of tasks, such as choosing the right physics, defining the geometry, and setting up boundary conditions and domain settings. Additionally, material properties have to be defined for the materials included in the model. Such material data may come from the Material Library, but it often has to be obtained experimentally or from literature and imported into COMSOL Multiphysics. Using Spreadsheets for Handling and Storing Data We often use spreadsheets to store numerical data [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Modeling in COMSOL Multiphysics involves a lot of tasks, such as choosing the right physics, defining the geometry, and setting up boundary conditions and domain settings. Additionally, material properties have to be defined for the materials included in the model. Such material data may come from the Material Library, but it often has to be obtained experimentally or from literature and imported into COMSOL Multiphysics.</p>
<p><span id="more-29155"></span></p>
<h3>Using Spreadsheets for Handling and Storing Data</h3>
<p>We often use spreadsheets to store numerical data originating from various sources. Since spreadsheet tools, such as Excel®, are used by most everyone in an organization, the data can be collected, stored, and transferred between people and departments without special regard for programs that must be used to process and utilize it. The data may originally have been obtained from online sources, in-house or external databases imported from other file formats, or simply entered directly into the spreadsheet when the measurement was obtained.</p>
<p>Spreadsheets are perfect for handling data, since you can easily sort and filter it. You are also able to validate the data by visualizing it graphically before using it in your models. While spreadsheets are geared more towards handling a variety of data sources, COMSOL Multiphysics® allows you to enter material data either directly in your models or in user-created material libraries that can be used by many models.</p>
<h4>LiveLink™ <em>for</em> Excel®</h4>
<p>When we introduced <a href="http://www.comsol.com/livelink-for-excel">LiveLink™ <em>for</em> Excel®</a>, we opened up the possibilities for collaboration across teams and departments. Now, your own or your colleague&#8217;s model data can be edited immediately in Excel®, and these edits can then be transferred back to COMSOL Multiphysics simply by pressing a button. </p>
<p>LiveLink™ <em>for</em> Excel® also includes a few features for exporting spreadsheet data into COMSOL software material data files, which can be used directly for subsequent modeling. The material data can even depend on field values, such as pressure and temperature.</p>
<h3>Exporting Data</h3>
<p>As mentioned previously, data can come from many sources. Here I&#8217;ll show an example using some data from Wikipedia. It&#8217;s from a table that contains values for the density of water for different temperatures, listed in descending order.<br />
<img src="https://cdn.comsol.com/wordpress/2014/03/Material-properties-for-the-density-of-liquid-water.png" alt="Material properties for the density of liquid water" title="" width="300" height="543" class="alignnone size-full wp-image-29171" /><br />
We copy and paste the data directly into Excel® and it&#8217;s ready for exporting into a COMSOL Material Database file.<br />
<img src="https://cdn.comsol.com/wordpress/2014/03/Exporting-material-properties-into-a-COMSOL-Material-Database.png" alt="Exporting material properties into a COMSOL Material Database" title="" width="339" height="501" class="alignnone size-full wp-image-29185" /><br />
<em>Used with permission from Microsoft.</em></p>
<p>Now, we have to specify both where the field variable (temperature) and the property (density) are defined in the spreadsheet as well as what their units are. In COMSOL Multiphysics, you can define your data in almost any combination of units, but it&#8217;s important to specify which units you are using when you import the data. You do this by first clicking on the Settings button.<br />
<img src="https://cdn.comsol.com/wordpress/2014/03/Settings-button.png" alt="Settings button" title="" width="136" height="97" class="alignnone size-full wp-image-29175" /><br />
<em>Settings button.</em></p>
<p>A large dialog box will open that is used to define the data ranges for the inputs. The field variable and material properties are defined on two different tabs in the dialog box, as you can see below.<br />
<img src="https://cdn.comsol.com/wordpress/2014/03/Field-Dependent-Data-tab-in-the-Settings-window.png" alt="Field Dependent Data tab in the Settings window" title="" width="873" height="685" class="alignnone size-full wp-image-29177" /><br />
<em>Field Dependent Data tab in the Settings window.</em><br />
<img src="https://cdn.comsol.com/wordpress/2014/03/Material-Properties-tab-in-the-Settings-window.png" alt="Material Properties tab in the Settings window" title="" width="873" height="685" class="alignnone size-full wp-image-29179" /><br />
<em>Material Properties tab in the Settings window.</em></p>
<p>Finally, we are ready to export the data and click &#8220;OK&#8221;. We export the data by clicking on the &#8220;New&#8221; or &#8220;Append&#8221; buttons where we can also provide a file name for the Material Library. The next time we start up COMSOL Multiphysics and open the Material Browser, we&#8217;ll see the new library in the list of Material Libraries, ready for use.</p>
<h3>Fitting Expressions to Data</h3>
<p>When you import data using the method shown above, the data is interpolated automatically by COMSOL Multiphysics when solving the model. This is vital when the data varies a lot and an analytical expression cannot be fitted to the data.</p>
<p>Next up, I&#8217;ll show you a simple example using the thermal conductivity of copper&#8217;s dependency on temperature, using <a href="http://www.engineeringtoolbox.com/thermal-conductivity-d_429.html" target="_blank">data from this source</a>. Since there is only a small amount of data, the easiest way to import the values for copper is simply to write them in the spreadsheet. I then plot the data as a scatter plot, which allows me to fit a second order polynomial to the data. Since there are only three data points, I achieve a perfect fit, which looks reasonable in the given data range. Extrapolating outside the range can, however, be very dangerous.<br />
<img src="https://cdn.comsol.com/wordpress/2014/03/Excel-plot-of-the-thermal-conductivity-of-water.png" alt="Excel plot of the thermal conductivity of water" title="" width="843" height="588" class="alignnone size-full wp-image-29187" /><br />
<em>Used with permission from Microsoft.</em></p>
<p>The following fitted polynomial can be used directly from within COMSOL Multiphysics:</p>
<div class="latex">$$ k_c = -5 \cdot 10^{-5} T_c^2 -0.0025 T_c +401.09 $$</div>
<p>where <img class="latexImg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAUBAMAAAB7UtADAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAADBQTFRF////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////L2OGaQAAAA50Uk5TACKZu3dm3YgR7lVEM8xbjOmTAAAAAWJLR0QAiAUdSAAAAAlwSFlzAAAAeAAAAHgAnfVaYAAAAGdJREFUCNdjYMAJhEyQOE8RTMaHCDZrAoLNpIBgswWwlMLYchIVlTB2GEvDKhhb2QOhPqmoAWE8uwHCeK4JrAxbtkKMZzFYyKpwEmI84+0AuQZGEJuHgaGHwRnJqYtBQlDAvtoL1VMA3DgR4A1ndZkAAAAldEVYdGRhdGU6Y3JlYXRlADIwMTgtMTEtMjJUMDk6MTU6MTErMDE6MDBQcAVWAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE4LTExLTIyVDA5OjE1OjExKzAxOjAwIS296gAAACF0RVh0cHM6SGlSZXNCb3VuZGluZ0JveAAxM3gxMisyOTkrNjM3sfLfiAAAACd0RVh0cHM6TGV2ZWwAQWRvYmVGb250LTEuMDogQ01NSTEyIDAwMy4wMDIKMReWuwAAAEl0RVh0cHM6U3BvdENvbG9yLTAAL2Rldi9zaG0vemYyLWNhY2hlL2UyMzI3MWJmMTFiMTY3ODYyMzM2OTQ3ZGJiM2EwNWEzLmR2aSAtb+hzv9gAAABFdEVYdHBzOlNwb3RDb2xvci0xAC9kZXYvc2htL3pmMi1jYWNoZS9lMjMyNzFiZjExYjE2Nzg2MjMzNjk0N2RiYjNhMDVhMy5wc0x+hcQAAAAASUVORK5CYII=" /> is the thermal conductivity of copper and <img class="latexImg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAUCAMAAAC+oj0CAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAADNQTFRF////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////8T5qHgAAAA90Uk5TABGIZneqRFWZIt3uM8y7fOfgQwAAAAFiS0dEAIgFHUgAAAAJcEhZcwAAAHgAAAB4AJ31WmAAAABySURBVBjTnY9LDsAgCAURFURtuf9t66fRNNpFO4sXM4anAHzE4MRO7TwZYEUACmFq3+5USgoOK23Qx5pEQ1tTM7VxkuezWS1s6NULvXohhZ39W02O5uCotgFyuo94aMS2tmjZbe1z5/afXHVePTI5hlcuDXoCXW8dNqYAAAAldEVYdGRhdGU6Y3JlYXRlADIwMTgtMTEtMjJUMDk6MTU6MTErMDE6MDBQcAVWAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE4LTExLTIyVDA5OjE1OjExKzAxOjAwIS296gAAACF0RVh0cHM6SGlSZXNCb3VuZGluZ0JveAAxM3gxMisyOTkrNjM3sfLfiAAAACd0RVh0cHM6TGV2ZWwAQWRvYmVGb250LTEuMDogQ01NSTEyIDAwMy4wMDIKMReWuwAAAEl0RVh0cHM6U3BvdENvbG9yLTAAL2Rldi9zaG0vemYyLWNhY2hlLzAwMzZhYzFlMWFlMDBmZjZhNTlhNzI5ZWNkYjBjYTkxLmR2aSAtbyejV1kAAABFdEVYdHBzOlNwb3RDb2xvci0xAC9kZXYvc2htL3pmMi1jYWNoZS8wMDM2YWMxZTFhZTAwZmY2YTU5YTcyOWVjZGIwY2E5MS5wc1vsWocAAAAASUVORK5CYII=" /> is the temperature in Celsius. The easiest way to use this expression in COMSOL Multiphysics is to define some expressions for these two variables.<br />
<img src="https://cdn.comsol.com/wordpress/2014/03/Defining-expressions-in-COMSOL-Multiphysics.png" alt="Defining expressions in COMSOL Multiphysics" title="" width="251" height="120" class="alignnone size-full wp-image-29181" /><br />
COMSOL Multiphysics will then automatically interpret these expressions and symbolically calculate any derivatives that may be needed during the solution process. The idea of being able to enter expressions anywhere a setting can be defined in the COMSOL user interface is important since it allows you to customize the built-in models and parameter data without having to resort to writing external libraries.</p>
<h3>Additional Resources</h3>
<ul>
<li>Archived Webinar: <a href="http://www.comsol.com/video/livelink-excel-streamlines-simulation">LiveLink™ <em>for</em> Excel® Streamlines Simulation in COMSOL Multiphysics®</a></li>
<li>Video Tutorial: <a href="http://www.comsol.com/video/video-tutorial-importing-excel-data-comsol-model">Importing Excel® Data into a COMSOL® Model</a></li>
<li>Blog posts:
<ul>
<li><a href="http://www.comsol.com/blogs/extend-your-modeling-capacity-with-livelink-for-excel/">Extend Your Modeling Capacity with LiveLink™ for Excel®</a></li>
<li><a href="http://www.comsol.com/blogs/how-spreadsheets-are-used-in-engineering/">How Spreadsheets Are Used in Engineering</a></li>
</ul>
</li>
</ul>
<p><em>Excel is a registered trademark of Microsoft Corporation in the United States and/or other countries.</em></p>
]]></content:encoded>
			<wfw:commentRss>https://www.comsol.no/blogs/create-material-database-spreadsheet-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extend Your Modeling Capacity with LiveLink™ for Excel®</title>
		<link>https://www.comsol.no/blogs/extend-your-modeling-capacity-with-livelink-for-excel/</link>
		<comments>https://www.comsol.no/blogs/extend-your-modeling-capacity-with-livelink-for-excel/#comments</comments>
		<pubDate>Wed, 03 Oct 2012 22:30:24 +0000</pubDate>
		<dc:creator><![CDATA[Phil Kinnane]]></dc:creator>
				<category><![CDATA[Interfacing]]></category>
		<category><![CDATA[LiveLink for Excel]]></category>

		<guid isPermaLink="false">http://com.dev.comsol.com/blogs/?p=7169</guid>
		<description><![CDATA[Recently, Fanny blogged about spreadsheets and how they are used in engineering. She mentioned that they are great for collating material properties and other experimental results, and for then using these in COMSOL models. The simulation results from these models can in turn be compared to the original data, and help calibrate material properties and optimize the design. With the release of COMSOL Multiphysics 4.3a, COMSOL has now made it much easier to perform these tasks and extend your modeling [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Recently, Fanny blogged about <a href="http://www.comsol.com/blogs/how-spreadsheets-are-used-in-engineering/">spreadsheets and how they are used in engineering</a>. She mentioned that they are great for collating material properties and other experimental results, and for then using these in COMSOL models. The simulation results from these models can in turn be compared to the original data, and help calibrate material properties and optimize the design. With the <a href="http://www.comsol.com/blogs/now-online-comsol-multiphysics-version-4-3a-release-highlights/">release of COMSOL Multiphysics 4.3a</a>, COMSOL has now made it much easier to perform these tasks and extend your modeling capacity with the new <a href="http://www.comsol.com/products/livelink-excel/">LiveLink™ <em>for</em> Excel®</a>.</p>
<p><span id="more-7169"></span></p>
<p>And a great piece of news is that all current subscription holders of COMSOL Multiphysics will get it for free!</p>
<p><img src="https://cdn.comsol.com/wordpress/2012/10/lllexce_screenshot1.jpg" alt="LiveLink for Excel toolbar" title="LiveLink for Excel toolbar" width="649" height="88" class="alignnone size-full wp-image-7565" /><br />
<em>The Excel® ribbon contains a COMSOL Multiphysics tab and specialized toolbar for changing parameter values, meshing or running a simulation.</em></p>
<h3>What can LiveLink™ for Excel® do for you?</h3>
<p>LiveLink™ <em>for</em> Excel® will let you immediately access variables and parameter values in Excel that have been previously modeled in COMSOL. Changing them on-the-fly in Excel automatically synchronizes them to your COMSOL model, and you can even run the meshing and solving from the spreadsheet environment.</p>
<p>As noted in the <a href="http://www.comsol.com/blogs/how-spreadsheets-are-used-in-engineering/">previous blog post</a>, one major advantage with making COMSOL “Excel-friendly” is that the COMSOL user can now communicate far more effectively with other engineers and scientists, and operators, in his or her organization. Rather than having to send Excel files back and forth within your organization, and converting them to text files to get them in and out of COMSOL, the workflow is streamlined by the integration provided by <a href="http://www.comsol.com/products/livelink-excel/">LiveLink™ <em>for</em> Excel®</a>.</p>
<h3>No More “Back and Forth”</h3>
<p>One scenario is that the simulations engineer provides a custom model that the Excel user can then utilize to collate by controlling a select and familiar set of input data, calibrate and optimize the material properties they are working with. No need for sending files back and forth anymore. LiveLink™ <em>for</em> Excel® provides an interactive COMSOL graphics window that updates immediately when the “Solve” button is clicked in Excel’s COMSOL toolbar. And when the final report is to be presented, the corresponding COMSOL 3D images can be embedded into the spreadsheet with a single click of the mouse.</p>
<p><em>Excel is a registered trademark of Microsoft Corporation.</em></p>
]]></content:encoded>
			<wfw:commentRss>https://www.comsol.no/blogs/extend-your-modeling-capacity-with-livelink-for-excel/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How Spreadsheets Are Used in Engineering</title>
		<link>https://www.comsol.no/blogs/how-spreadsheets-are-used-in-engineering/</link>
		<comments>https://www.comsol.no/blogs/how-spreadsheets-are-used-in-engineering/#comments</comments>
		<pubDate>Wed, 19 Sep 2012 13:08:11 +0000</pubDate>
		<dc:creator><![CDATA[Fanny Griesmer]]></dc:creator>
				<category><![CDATA[Interfacing]]></category>
		<category><![CDATA[LiveLink for Excel]]></category>

		<guid isPermaLink="false">http://com.dev.comsol.com/blogs/?p=6925</guid>
		<description><![CDATA[We’ve noticed that a lot of our customers use spreadsheets, such as Excel®, as part of the modeling process. They use them for storing material property and other data, such as from experiments or other information about workflow associated with their engineering project, and then import this data into COMSOL Multiphysics®. Spreadsheets are also the forum for taking in results from COMSOL software and using this to compare, optimize and verify these material properties. Let’s delve deeper into how spreadsheets [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>We’ve noticed that a lot of our customers use spreadsheets, such as Excel®, as part of the modeling process. They use them for storing material property and other data, such as from experiments or other information about workflow associated with their engineering project, and then import this data into COMSOL Multiphysics®. Spreadsheets are also the forum for taking in results from COMSOL software and using this to compare, optimize and verify these material properties. Let’s delve deeper into how spreadsheets are used in engineering &#8212; do you recognize your own role in this process, perhaps? </p>
<p><span id="more-6925"></span></p>
<p><img src="https://cdn.comsol.com/wordpress/2012/09/Spreadsheet.jpg" alt="Spreadsheets are used in engineering" title="Spreadsheet" width="227" height="158" class="alignnone size-full wp-image-6933" /></p>
<h3>Using Spreadsheets to Find the Answer</h3>
<p>Take this structural mechanics example of a rubber part. What happens when you pull on it; how much does it stretch, when does it weaken, when does it break&#8230;? What would the physical model for stretching the rubber part be? When utilizing spreadsheets to figure out the answer to this, one would start by running experiments to see how the part reacts to different scenarios. These are then stored in the spreadsheet where they can be analyzed, and maybe parameters like material properties be extracted, often as an averaged value. </p>
<p>But, what is the optimal design of this component? Up until now, we’ve been working within the Excel environment, but in order to find out what the best design would be, each scenario needs to be solved for and compared to the experiment.</p>
<h3>Cue: The Simulations Engineer</h3>
<p>He or she is the go-to person for building a useful model. The engineer receives the Excel file with the material property data from his colleague and imports these into COMSOL Multiphysics. Interpolation functions in the software allow for better and more localized determination of the material property, and these are used to model the different scenarios.</p>
<p>The results from the simulations can then be given in a table, which can be further exported to Excel, and the engineer can now send the file back to his colleague who set up the different scenarios. The COMSOL software results are then compared to the original scenarios in Excel to see how these values compare to the values for the variables in the initial studies.  </p>
<p>As far as we’ve seen, spreadsheets are mostly used for mechanical, magnetic, and chemical applications. Experiment is often required to provide the material data for materials, as well chemical reaction kinetics. But, if you work in another area that uses Excel as part of the simulation process, tell us about it in the comments section below!</p>
<h3>Spreadsheets, a Widely Used Application</h3>
<p>One of the great aspects of incorporating spreadsheets into the world of multiphysics modeling is that someone within the organization can enter data into Excel (a widely used application) and then use that in a simulation. Conversely, that simulations engineer can later export the results data into a spreadsheet format and send that back to the experimentalist &#8212; who can then use the results from the simulation in a familiar environment. The downside is, of course, that because these scenarios are run manually, and the processes are separated across different employees, it can take weeks or months to run through the project workflow. Wouldn’t it be great if at least parts of this process could be automated? Food for thought.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.comsol.no/blogs/how-spreadsheets-are-used-in-engineering/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
