Examples of Custom Physics > Thermoelectric Effect Implementation > Thermoelectric Effect Interface — Creating It Step by Step

Thermoelectric Effect Interface — Creating It Step by Step
The following steps show how to define the Thermoelectric Effect physics interface using the implementation defined in the previous section.
Creating the Basics
1
2
From the File menu (Windows) or the Options menu (the cross-platform version), choose Preferences. In the Preferences dialog box, select Physics Builder in the list and then select the Enable Physics Builder check box if not selected already.
3
From the File menu, choose New (). On the New page, click the Physics Builder button (). The Physics Builder window replaces the Model Builder window on the COMSOL Desktop.
4
On the Home toolbar, click Add Physics Interface () (or right-click the root node (Untitled.mphphb) and select Physics Interface). This adds a Physics Interface node.
5
Go to the Settings window for Physics Interface. In the Identifiers section:
-
In the Description field enter Thermoelectric Effect. Click the Rename node using this text button () to update the node in the Physics Builder.
-
The Type field defaults to ThermoelectricEffect.
-
In the Default name and tag field enter tee.
-
If you have a custom Icon for the interface, click the Browse button to locate the icon file. The default is to use the physics.png icon ().
6
The Thermoelectric Effect interface should support all space dimensions except 0D, so under Restrictions, leave the Allowed space dimensions list with the default contents, which includes all space dimensions except 0D.
7
Under Restrictions in the Allowed study types list, select the default Time Dependent study type and click the Delete button () underneath the list. For this example only the Stationary study type is used.
8
In the Settings section, verify that Domain is selected in the Top geometric entity level list. This means that the equations in the physics interface apply to the domains in the geometry, which is the case for most physics interfaces. Leave the setting in the Default frame list at the default value (Material).
9
It is good practice to save the physics interface after completing some steps. From the File menu, choose Save and create a physics builder file, ThermoelectricEffect.mphphb in the default location. Click Save.
This concludes the initial steps that set up the fundamentals for the physics interface. The next steps adds equations, boundary conditions, and variables.
Adding the Dependent Variables
First declare the dependent variables T and V:
1
On the Physics Interface toolbar click Dependent Variable Declaration (). Or right-click Thermoelectric Effect (Physics Interface 1) node and from the Variables menu select Dependent Variable Declaration.
2
In the Settings window for Dependent Variable Declaration locate the Declaration section:
-
Keep the default setting in the Dependent variable reference list as Use physical quantity.
-
From the Physical quantity list select Temperature (K), which makes suitable default values appear for the variable name and description.
-
In the Symbol (LaTeX encoded) field enter T.
-
Keep the default Dimension as Scalar because T is a scalar field.
3
Keep the default Preferences settings that make the dependent variable available for plotting (Show in plot menu) and for use as an input in other physics interfaces (Announce variable to feature inputs).
4
Keep the default Discretization settings (for default second-order Lagrange elements).
5
Add another Dependent Variable Declaration () node.
6
In the Settings window locate the Declaration section.
-
Keep the default setting in the Dependent variable reference list as Use physical quantity.
-
From the Physical quantity list select Electric potential (V), which makes suitable default values appear for the variable name and description.
-
In the Symbol (LaTeX encoded) field enter V.
-
Keep the default Size setting as Scalar because V is a scalar field.
7
Keep the default Discretization and Preferences sections settings.
Adding the Heat Transfer Model
Next add the Heat Transfer Model as a domain feature:
1
Right-click the Thermoelectric Effect node and from the Features menu select Domain Feature ().
2
In the Settings window locate the Identifiers section.
-
In the Description field enter Heat transfer model. Click the Rename node using this text button () to update the node in the Physics Builder.
-
The Type field updates automatically to HeatTransferModel.
-
In the Default name and tag field enter htm.
3
Under Restrictions keep the default setting Same as parent for both the Allowed space dimensions and Allow study types lists. If you select Customized you can restrict the feature to a subset of the allowed space dimensions or study types for the physics interface.
4
5
Right-click the Heat Transfer Model node and from the Variables menu select Dependent Variable Definition ().
6
In the Settings window locate the Definition section. From the Physical quantity list select Temperature (K).
7
Keep the default settings for the rest of the Dependent Variable Definition node.
8
Right-click the Heat Transfer Model node and from the Inputs menu select User Input ().
9
In the Settings window locate the Declaration section.
-
In the Input name field enter k.
-
In the Description field enter Thermal conductivity.
-
In the Symbol (LaTeX encoded) field enter k.
-
From the Physical quantity list select Thermal conductivity (W/(m*K))
-
Keep the default settings for the Array type (Single) and Dimension (Scalar) lists for a basic scalar quantity. Also keep the default Allowed values to Any for an entry of a general scalar number.
-
In the Default value field enter 1.6[W/(m*K)] (typical value for bismuth telluride).
10
11
Right-click the User Input node and select Variable Definition (). Or click the same button on the toolbar.
This user input then declares a variable with the name k and the expression par.k, which evaluates to the value entered for the user input. You can also refer to k directly in the weak form equation. A user of this physics interface refers to this variable as tee.k in the predefined expressions for results evaluation, for example.
12
Keep all other default values for the Variable Definition subnode.
13
Right-click the Heat Transfer Model node and from the Equations menu select Weak Form Equation (). Or click the same button on the toolbar.
This adds a Weak Form Equation node where you specify an equation for the domains in the physics interface.
14
In the Settings window, locate the Integrand section. In the Expression field enter -k·∇Τ·test(T). This expression implements the heat equation formulation for this interface.
Press Ctrl+Space to get a list of the supported operations that includes any special characters. See Tensor Parser for the keyboard entries to create the del operator () and the dot product (·).
15
So far your Physics Builder tree should match the figure:
Adding the Thermoelectric Model
Next add the Thermoelectric Model as a domain feature:
1
Right-click the Thermoelectric Effect node and from the Features menu select Domain Feature ().
2
In the Settings window for Domain Feature locate the Identifiers section.
-
In the Description field enter Thermoelectric model. Click the Rename node using this text button () to update the node in the Physics Builder.
-
The Type field updates automatically to ThermoelectricModel.
-
In the Default name and tag field enter tem.
3
In the Preferences section select the Add as default feature check box. Keep the setting in the Default entity types list to make this a default physics model in all domains.
4
5
Right-click the Thermoelectric Model node and from the Variables menu select Dependent Variable Definition ().
6
In the Settings window locate the Definition section. From the Physical quantity list select Temperature (K). Keep the other default settings.
7
Right-click the Thermoelectric Model node and from the Variables menu select Dependent Variable Definition ().
8
In the Settings window locate the Definition section. From the Physical quantity list select Electric potential (V). Keep the other default settings.
Adding Three User Inputs and Variable Definitions
1
Right-click the Thermoelectric Model node and from the Inputs menu select User Input ().
2
In the Settings window, locate the Declaration section.
-
In the Input name field enter k
-
In the Description field enter Thermal conductivity.
-
In the Symbol (LaTeX encoded) field enter k.
-
From the Physical quantity list select Thermal conductivity (W/(m*K)).
-
Keep the default settings in the Array type (Single) and Dimension (Scalar) lists for a basic scalar quantity. Also leave the Allowed values setting to Any for an entry of a general scalar number.
-
In the Default value field enter 1.6[W/(m*K)] (typical value for bismuth telluride).
3
4
Right-click the User Input 1 node and select Variable Definition ().
You can then refer to k directly in the weak form equation. A user of this interface refers to this variable as tee.k in the predefined expressions for results evaluation, for example.
5
Keep all other default settings for the Variable Definition subnode.
6
Right-click the Thermoelectric Model node and from the Inputs menu select User Input ().
7
In the Settings window locate the Declaration section.
-
In the Input name field enter sigma.
-
In the Description field enter Electric conductivity.
-
In the Symbol (LaTeX encoded) field enter \sigma to create a Greek σ symbol.
-
From the Physical quantity list select Electrical conductivity (S/m).
-
Keep the default settings in the Array type (Single) and Dimension (Scalar) lists for a basic scalar quantity. Also leave the Allowed values setting to Any for an entry of a general scalar number.
-
In the Default value field enter 1.1e5[S/m] (typical value for bismuth telluride).
8
9
Right click User Input 2 and select Variable Definition () from the context menu.
You can then refer to sigma directly in the weak form equation. A user of this interface refers to this variable as tee.sigma in the predefined expressions for results evaluation, for example.
10
Keep all other default settings for the Variable Definition subnode.
11
Add a User Input () node to the Thermoelectric Model node.
12
In the Settings window locate the Declaration section.
-
In the Input name field enter S.
-
In the Description field enter Seebeck coefficient.
-
In the Symbol (LaTeX encoded) field enter S.
-
From the Physical quantity list select Seebeck coefficient (V/K).
-
Keep the default settings in the Array type (Single) and Dimension (Scalar) lists for a basic scalar quantity. Also leave the Allowed values setting to Any for an entry of a general scalar number.
-
In the Default value field enter 200e-6[V/K] (typical value for p-type bismuth telluride).
13
14
Right click User Input 3 and select Variable Definition () from the context menu.
You can then refer to S directly in the weak form equation. A user of this interface refers to this variable as tee.S in the predefined expressions for results evaluation, for example.
15
Keep all other default settings for the Variable Definition subnode.
The Physics Builder tree for the Thermoelectric Model User Inputs and Variable Definitions should match the figure so far:
Adding Five Variable Declarations and Definitions
1
Right-click the Thermoelectric Model node and from the Variables menu select Variable Declaration ().
2
In the Settings window, locate the Declaration section.
-
In the Variable name field enter q.
-
In the Description field enter Heat flux.
-
In the Symbol (LaTeX encoded) field enter q.
-
As Dimension, select Vector (3x1).
-
From the Physical quantity list select Inward heat flux (W/m2).
3
Right-click the Variable Declaration 1 node and select Variable Definition ().
4
In the Settings window locate the Definition section. In the Expression field, enter P*J-k·T.
Press Ctrl+Space to get a list of the supported operations that includes any special characters. See Tensor Parser for the keyboard entries to create the del operator () and the dot product (·).
5
Keep all other default settings for the Variable Definition 1 subnode.
6
Right-click the Thermoelectric Model node and from the Variables menu select Variable Declaration ().
7
In the Settings window, locate the Declaration section.
-
In the Variable name field enter J.
-
In the Description field enter Current density.
-
In the Symbol (LaTeX encoded) field enter J.
-
As Dimension, select Vector (3x1).
-
From the Physical quantity list select Current density (A/m2).
8
Right-click the Variable Declaration 2 node and select Variable Definition ().
9
In the Settings window locate the Definition section. In the Expression field, enter -sigma·(V+S*T). Keep all other default settings for the Variable Definition 1 subnode.
10
Right-click the Thermoelectric Model node and from the Variables menu select Variable Declaration ().
11
In the Settings window locate the Declaration section.
-
In the Variable name field enter P.
-
In the Description field enter Peltier coefficient.
-
In the Symbol (LaTeX encoded) field enter P.
-
Keep the default Dimension as Scalar.
-
From the Physical quantity list select Electric potential (V).
12
Right-click the Variable Declaration 3 node and select Variable Definition ().
13
In the Settings window locate the Definition section. In the Expression field enter S*T. Keep all other default settings for the Variable Definition 1 subnode.
14
Right-click the Thermoelectric Model node and from the Variables menu select Variable Declaration ().
15
In the Settings window locate the Declaration section.
-
In the Variable name field enter E.
-
In the Description field enter Electric field.
-
In the Symbol (LaTeX encoded) field enter E.
-
As Dimension, select Vector (3x1).
-
From the Physical quantity list select Electric field (V/m).
16
Right-click the Variable Declaration 4 node and select Variable Definition ().
17
In the Settings window locate the Definition section. In the Expression field enter −∇V. Keep all other default settings for the Variable Definition 1 subnode.
18
Right-click the Thermoelectric Model node and from the Variables menu select Variable Declaration ().
19
In the Settings window, locate the Declaration section.
-
In the Variable name field enter Q.
-
In the Description field enter Joule heating.
-
In the Symbol (LaTeX encoded) field enter Q.
-
Keep the default Dimension as Scalar.
-
From the Physical quantity list select Heat source (W/m3).
20
Right-click the Variable Declaration 5 node and select Variable Definition ().
21
In the Settings window locate the Definition section. In the Expression field, enter J·E. Keep all other default settings for the Variable Definition 1 subnode.
The Variable Declaration and Variable Definitions subnodes should match the figure so far:
Adding Two Weak Form Equations
1
Right-click the Thermoelectric Model node and from the Equations menu select Weak Form Equation (). Or click the Weak Form Equation button on the toolbar.
2
In the Settings window locate the Integrand section. In the Expression field, enter q·test(T)+Q*test(T). Press Ctrl+Space to enter the del operator () and the dot product (·).
3
Right-click the Thermoelectric Model node and from the Equations menu select Weak Form Equation ().
4
In the Settings window, locate the Integrand section. In the Expression field, enter -J·test(E). Note that -E is used instead of V. Either syntax would work.
Adding Boundary Conditions
Boundary conditions are defined in a way that is similar to domain features. Boundary conditions can have their own user inputs and equations. This physics interface requires a special rule for overriding the temperature boundary condition and the electric potential boundary condition.
Override Rule for Boundary Conditions
1
Under Definitions Library () right-click Auxiliary Definitions () and select Override Rule ().
2
Click the Add button () twice to add two rows and two columns.
3
In the third row of the Type column, enter exclusiveT (replace type_id_0).
4
In the forth row of the Type column, enter exclusiveV (replace type_id_1).
5
Click to set the Overrides exclusive and Overrides contributing columns for exclusiveT and exclusiveV to a green check mark.
6
Click in column Overrides exclusiveT across from exclusiveT to set to a green check mark.
7
Click in column Overrides exclusiveV across from exclusiveV to set to a green check mark. The Settings window should match the figure.
The Temperature Boundary Condition
1
Right-click the Thermoelectric Effect node and from the Features menu select Boundary Condition ().
2
In the Settings window for Boundary Condition locate the Identifiers section.
-
In the Description field enter Temperature. Click the Rename node using this text button () to update the node in the Physics Builder.
-
The Type field defaults to Temperature.
-
In the Default name and tag field enter tp.
3
In the Restrictions section, keep the default setting (Same as parent) for the Allowed space dimensions and Allow study types lists.
4
In the Selection Settings section keep Exterior and Interior.
-
Click the Add button  underneath the list. Select Pair and click OK. It is added to the list under Applicable entities. This makes the boundary condition available for all those boundary types.
-
From the Override rule list choose Locally defined. Keep the default Override Rule 1 in the Link list.
-
From the Override type list choose exclusiveT.
1
Right-click the Temperature node and from the Inputs menu select User Input ().
2
In the Settings window locate the Declaration section.
-
In the Input name field enter T0.
-
In the Description field enter Temperature.
-
In the Symbol (LaTeX encoded) field enter T.
-
From the Physical quantity list select Temperature (K).
-
Keep the default settings in the Array type (Single) and Dimension (Scalar) lists for a basic scalar quantity. Also leave the Allowed values setting to Any for an entry of a general scalar number.
-
In the Default value field enter 293.15[K] corresponding to a room temperature of 20 degrees Celsius.
3
4
Right-click the User Input 1 node and select Variable Definition ().
You can then refer to T0 directly in the constraint equation. A user of this interface refers to this variable as tee.T0 in the predefined expressions for results evaluation, for example.
5
Keep all other defaults for the Variable Definition 1 subnode.
Now define a section in the Settings window for the boundary condition:
6
Right-click the Temperature node and from the Inputs menu select Section ().
7
In the Settings window, locate the Declaration section.
-
In the Group name field enter TemperatureSection.
-
In the Description field enter Temperature.
-
Click the Add () button and choose User Input1 (par.T0). Click OK and it is added the Group members list.
Now define the constraint equation that constrains the temperature to the specified value on the boundary:
8
Right-click the Temperature node and from the Equations menu select Constraint (). Or click the same button on the toolbar.
9
In the Settings window locate the Declaration section. In the Expression field enter T0-T to make the temperature T equal to T0 on the boundary (the constraint makes the expression equal to zero).
10
Locate the Shape Declaration section and from the Physical quantity list select Temperature (K).
11
The Electric Potential Boundary Condition
1
Right-click the Thermoelectric Effect node and from the Features menu select Boundary Condition ().
2
In the Settings window locate the Identifiers section.
-
In the Description field enter ElectricPotential. Click the Rename node using this text button () to update the node in the Physics Builder.
-
The Type field defaults to ElectricPotential.
-
In the Default name and tag field enter ep.
3
In the Selection Settings section:
-
From the Override rule list choose Locally defined. Keep the default Override Rule 1 in the Link list.
-
From the Override type list choose exclusiveV.
4
Right-click the Electric Potential node and from the Inputs menu select User Input ().
5
In the Settings window locate the Declaration section.
-
In the Input name field enter V0.
-
In the Description field enter Electric potential.
-
In the Symbol (LaTeX encoded) field enter V.
-
From the Physical quantity list select Electric potential (V).
-
Keep the default settings in the Array type (Single) and Dimension (Scalar) lists for a basic scalar quantity. Also leave the Allowed values setting to Any for an entry of a general scalar number.
-
Keep the Default value at 0.
6
7
Right-click the User Input 1 node and select Variable Definition ().
You can then refer to V0 directly in the constraint equation. A user of this interface refers to this variable as tee.V0 in the predefined expressions for results evaluation, for example.
8
Keep all other defaults for the Variable Definition 1 subnode.
Now define a section in the Settings window for the boundary condition:
9
Right-click the Electric Potential node and from the Inputs menu select Section ().
10
In the Settings window locate the Declaration section.
-
In the Group name field enter ElectricPotentialSection.
-
In the Description field enter Electric potential.
-
Click the Add () button and choose User Input1 (par.V0). Click OK and it is added the Group members list.
Now define the constraint equation for constraining the potential at the boundary to a specified potential.
11
Right-click the Electric Potential node and from the Equations menu select Constraint ().
12
In the Settings window locate the Declaration section. In the Expression field, enter V0-V, which constrains the value of the potential V to V0.
13
Locate the Shape Declaration section and from the Physical quantity list select Electric potential (V).
The Temperature and Electric Potential boundary conditions in the Physics Builder tree should match the figure:
The Heat Flux Boundary Condition
1
Right-click the Thermoelectric Effect node and from the Features menu select Boundary Condition ().
2
In the Settings window locate the Identifiers section.
-
In the Description field enter Heat flux. Click the Rename node using this text button () to update the node in the Physics Builder.
-
The Type field updates automatically to HeatFlux.
-
In the Default name and tag field enter hf.
3
In the Selection Settings section from the Override type list choose Contributing (that is, more than one heat flux can contribute to the total heat flux across a boundary).
4
Right-click the Heat Flux node and from the Inputs menu select User Input ().
5
In the Settings window locate the Declaration section.
-
In the Input name field enter qin.
-
In the Description field enter Normal heat flux.
-
In the Symbol (LaTeX encoded) field enter q_{in} (for displaying qin).
-
From the Physical quantity list select Inward heat flux (W/m^2).
-
Keep the default settings in the Array type (Single) and Dimension (Scalar) lists for a basic scalar quantity. Also leave the Allowed values setting to Any for an entry of a general scalar number.
-
Keep the Default value at 0.
6
Right-click the User Input 1 node and select Variable Definition ().
You can then refer to qin directly in the weak form equation. A user of this interface refers to this variable as tee.qin in the predefined expressions for results evaluation, for example.
7
Leave all other default settings for the Variable Definition 1 subnode.
Now define a section in the Settings window for the boundary condition:
8
Right-click the Heat Flux node and from the Inputs menu select Section ().
9
In the Settings window locate the Declaration section.
-
In the Group name field enter HeatFluxSection.
-
In the Description field enter Heat flux.
-
Click the Add () button and choose User Input1 (par.qin). Click OK and it is added the Group members list.
Now define the weak form equation for the heat flux:
10
Right-click the Heat Flux node and from the Equations menu select Weak Form Equation ().
11
In the Settings window locate the Integrand section. In the Expression field, enter qin*test(T). For a theoretical explanation of this expression, see the earlier theory section.
The Insulation Condition
1
Right-click the Thermoelectric Effect node and from the Features menu select Boundary Condition ().
2
In the Settings window locate the Identifiers section.
-
In the Description field enter Insulation. Click the Rename node using this text button () to update the node in the Physics Builder.
-
The Type field updates automatically to Insulation.
-
In the Default name and tag field enter in.
3
In the Selection Settings section keep the default Override type (Exclusive).
4
In the Preferences section, select the Add as default feature check box. Keep the default setting in the Default entity types list to make this a default boundary condition on Exterior boundaries only.
5
The Physics Builder tree should match this figure so far:
Defining Default Plots and Default Plot Quantities
Define a default 3D plot group for plotting the temperature and make the temperature the default scalar quantity for user-defined plots:
1
Right-click Thermoelectric Effect and select Result Defaults ().
2
Right-click Result Defaults () and select 3D Plot Group ().
3
Right-click the 3D Plot Group () node and select Surface ().
4
In the Settings window for Surface () under the Expression section:
-
In the Expression field enter T.
-
In the Unit field enter K.
-
Click the Description check box and enter Temperature in the text field.
5
6
Right-click the Surface () node and select Rename (or click Surface and press F2) In the Rename Surface dialog box, in the New label field enter Temperature. Click OK.
7
Right-click Result Defaults 1 () and select Plot Defaults ().
8
Right-click the Plot Defaults 1 () node and select Default Scalar Plot ().
-
In the Expression field enter T.
-
In the Description field enter Temperature. This makes temperature the default for all scalar plots.
Making a Thermoelectric Devices Physics Area
To add the Thermoelectric Effect interface to a new physics area for Thermoelectric Devices under the Heat Transfer branch:
1
Under Definitions Library right-click Physics Areas () and select Physics Area ().
2
In the Settings window for Physics Area under Parent Area, expand the Root>Heat Transfer folder (). Right-click Heat Transfer and select Set as Parent () to sort this physics area under the Heat Transfer branch in the Model Wizard and Add Physics windows.
3
In the Physics Area Settings section:
-
In the Name field enter ThermoelectricDevices.
-
In the Description field enter Thermoelectric Devices.
-
The default Icon is physics.png (), which is appropriate for this physics. Otherwise, click Browse to use another icon.
-
In the Weight field enter 10 to make the Thermoelectric Devices area appear last in the list under Heat Transfer (the higher the weight, the lower position the physics area gets in the tree of physics interfaces).
4
Click the Thermoelectric Effect node. In the Settings window for Physics Interface, expand the Physics Area section.
5
Expand the Heat Transfer folder. Right-click Thermoelectric Devices () and select Set as Parent (). This sorts the physics interface under the selected physics area.
6
This completes the definition of the Thermoelectric Effect interface. The next section tests the physics interface.