example model - institutionen för tillämpad fysik och ... ii/practice...femlab | 1-3 model library...

20
FEMLAB © VISIT WWW.COMSOL.COM FOR INTERACTIVE DEMOS AND TUTORIALS © COPYRIGHT 2002 by COMSOL AB. All right reserved. No part of this documentation may be photocopied or reproduced in any form without prior written consent from COMSOL AB. FEMLAB is a registered trademark of COMSOL AB. MATLAB and Simulink are registered trademarks of The MathWorks,Inc. Other product or brand names are trademarks or registered trademarks of their respective holders. EXAMPLE MODEL solved with FEMLAB Multiphysics in MATLAB ©

Upload: tranquynh

Post on 02-May-2018

216 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: EXAMPLE MODEL - Institutionen för tillämpad fysik och ... II/Practice...FEMLAB | 1-3 Model Library FEMLAB/Multiphysics/electrical_heating Model Navigator • Start FEMLAB from the

FEMLAB©

VISIT WW

W.COMSOL.COM FOR INTERACTIVE DEMOS AND TUTORIALS

© COPYRIGHT 2002 by COMSOL AB. All right reserved. No part of this documentation may be photocopied or reproduced in any form without prior written consent from COMSOL AB.

FEMLAB is a registered trademark of COMSOL AB. MATLAB and Simulink are registered trademarks of The MathWorks,Inc. Other product or brand names are trademarks or registered trademarks of their respective holders.

EXAMPLE MODELsolved with FEMLAB

M u l t i p h y s i c s i n M A T L A B©

Page 2: EXAMPLE MODEL - Institutionen för tillämpad fysik och ... II/Practice...FEMLAB | 1-3 Model Library FEMLAB/Multiphysics/electrical_heating Model Navigator • Start FEMLAB from the

FEMLAB

Thermo-Electric Effects

This example models thermo-electric heating in a copper plate. The material heats up when an electric current passes through it due to electrical resistance. The coupling also works in the opposite direction the material’s resistance varies with temperature and increases as the material heats up. This example first sets up the electric portion of the model using FEMLAB’s Conductive media DC application mode; then the discussion adds the Heat transfer application mode to model the thermo-electric multiphysics phenomena.

C O N D U C T I V E M E D I A D C

Imagine a copper plate measuring 1 x 1 m that also contains a small hole. The plate’s arbitrary thickness t has no effect on the model. Suppose you subject the plate to an electric potential difference across two opposite sides (all other sides are insulated). The potential difference induces a current that heats the plate.

In the 2D model you view the plate from above. To start making a stationary model of the electric effects, use the Conductive media DC application mode.

0.1 V

Copper Plate

0 V

Current

1 m

1-2 | F E M L A B

Page 3: EXAMPLE MODEL - Institutionen för tillämpad fysik och ... II/Practice...FEMLAB | 1-3 Model Library FEMLAB/Multiphysics/electrical_heating Model Navigator • Start FEMLAB from the

Model Library FEMLAB/Multiphysics/electrical_heating

Model Navigator • Start FEMLAB from the MATLAB Command Window with the command:

femlab

Issuing that command invokes the Model Navigator.

• On the New page, check the 2D radio button, double-click on Physics modes, then select Conductive media DC and press OK to close the Model Navigator. The element type is set to Lagrange - Quadratic by default. The problem is linear and stationary.

The Conductive media DC application mode is applicable to problems such as electrolysis modeling and computation of grounding plates.

Options • Choose Axes/Grid Settings from the Options menu to open the Axes/Grid Settings

dialog box.

F E M L A B | 1-3

Page 4: EXAMPLE MODEL - Institutionen för tillämpad fysik och ... II/Practice...FEMLAB | 1-3 Model Library FEMLAB/Multiphysics/electrical_heating Model Navigator • Start FEMLAB from the

• On the Axis page, enter -0.2, 1.2, -0.1, and 1.1 as X min, X max, Y min, and Y max, respectively. Press Apply and notice how the software automatically modifies the

x-axis settings to obtain the correct aspect ratio for the geometry. Press OK to close the dialog box.

• To define constants that set parameters for the model, select Add/Edit Constants… from the Options menu.

1-4 | F E M L A B

Page 5: EXAMPLE MODEL - Institutionen för tillämpad fysik och ... II/Practice...FEMLAB | 1-3 Model Library FEMLAB/Multiphysics/electrical_heating Model Navigator • Start FEMLAB from the

• Enter the following constant names and expressions:

To add a constant, enter its name in the Name of constant edit field and the place its value in the Expression edit field. Then press the Set button and continue adding constants. When done, press Apply to evaluate all expressions.

In this model, the expressions are all numeric and all values are identical to the corresponding expressions. However, you can also evaluate a sequence of MATLAB expressions in the Add/Edit Constants dialog box, where each expression can depend on constants already defined.

• Press OK to close the dialog box.

Draw ModeStart defining the model geometry.

• Using the right mouse button, draw a square with corners at (0,0) and (1,1). Use the Draw Rectangle toolbar button located on the draw toolbar to the left in the GUI window.

• You must now draw a circle centered at the origin. That task becomes easier if you add some grid lines to assist you in drawing it. Open the Axes/Grid Settings dialog box and select the Grid page. Deselect automatic grid lines by clicking on the Auto check box. Set the x- and y-axis grid spacing to 0.2, and add extra x- and y-tick-marks at x = 0.5 and y = 0.5.

NAME OF CONSTANT EXPRESSION

r0 1.754e-8

T0 293

alpha 0.0039

T 293

F E M L A B | 1-5

Page 6: EXAMPLE MODEL - Institutionen för tillämpad fysik och ... II/Practice...FEMLAB | 1-3 Model Library FEMLAB/Multiphysics/electrical_heating Model Navigator • Start FEMLAB from the

• Draw a small circle centered at (0.5,0.5) by first pressing the Centered Ellipse toolbar button. Click at (0.5,0.5) and hold the right mouse button down while dragging the pointer up to the right until you have a circle with radius of 0.1.

• To create a hole, first select both geometry objects with the Ctrl-a keyboard combination. You can also select multiple objects by holding the Ctrl key while clicking on the label of each one.

• Press the Difference button on the draw toolbar. This action subtracts the object with smaller area, (here, the circle) from the object with the largest area (here, the square).

1-6 | F E M L A B

Page 7: EXAMPLE MODEL - Institutionen för tillämpad fysik och ... II/Practice...FEMLAB | 1-3 Model Library FEMLAB/Multiphysics/electrical_heating Model Navigator • Start FEMLAB from the

Boundary Mode • Open the Boundary Settings dialog box by selecting Boundary Settings… from the

Boundary menu. Doing so automatically puts the GUI in boundary mode where you can select boundaries and enter expressions for boundary conditions.

The boundary conditions for the Conductive media DC mode in this example are:

• Select all boundaries by first selecting the number 1 in the Boundary selection list box. Then drag the pointer down the list to mark all numerals (1 through 8). Press the radio button for Insulation/symmetry to make all boundaries insulated.

• You must change the conditions of boundaries 1 and 4. In the list box, select boundary 1, the left most boundary on the square. Press the radio button for Electric potential and enter 0.1 in the edit field to the right of the radio button.

• Select boundary 4 in the list box. Press the radio button for Antisymmetry/ground.

• Press OK to close the dialog box.

Subdomain Mode • Open the Subdomain Settings dialog box by selecting Subdomain Settings… from

the Subdomain menu. The interface switches automatically to subdomain mode,

BOUNDARY 1 4 2,3,5-8

Type Electric potential Electric potential Insulation

V 0.1 0

F E M L A B | 1-7

Page 8: EXAMPLE MODEL - Institutionen för tillämpad fysik och ... II/Practice...FEMLAB | 1-3 Model Library FEMLAB/Multiphysics/electrical_heating Model Navigator • Start FEMLAB from the

where you select subdomains and enter expressions for domain parameters (PDE coefficients).

The domain parameters in this example are given in the following table:

In the Conductive media DC application mode, you specify the electrical conductivity, σ, rather than electrical resistivity, ρ. Recall the relation between these quantities is σ = 1/ρ.

Over a range of temperatures conductivity σ is a function of temperature T according to

where ρ0 is the resistivity at the reference temperature T0. Because you earlier set T = T0 = 293 in the Add/Edit Constants dialog box, the actual relation in this first part of the coupled model is

and the modeling process uses the full temperature-dependent expression later.

• Select subdomain 1 from the Subdomain selection list box.

SUBDOMAIN 1

σ 1/(r0*(1+alpha*(T-T0)))

Q 0

σ 1ρ0 1 α T T0–( )+( )[ ]

---------------------------------------------------=

σ 1ρ0------=

1-8 | F E M L A B

Page 9: EXAMPLE MODEL - Institutionen för tillämpad fysik och ... II/Practice...FEMLAB | 1-3 Model Library FEMLAB/Multiphysics/electrical_heating Model Navigator • Start FEMLAB from the

• Enter the expression 1/(r0*(1+alpha*(T-T0))) in the edit field for Conductivity.

• Enter 0 in the edit field for Current source because there is none. The Current source option serves to specify the distribution of a current source in a subdomain.

• Press OK to close the dialog box.

Mesh Mode• Create a mesh by pressing the Initialize Mesh button on the main toolbar.

Solve Problem• To start the solution process press the Solve Problem button. (Time to solve: 5 s)

• Press the Zoom Extents button to adjust the axes with respect to the size of the geometry.

F E M L A B | 1-9

Page 10: EXAMPLE MODEL - Institutionen för tillämpad fysik och ... II/Practice...FEMLAB | 1-3 Model Library FEMLAB/Multiphysics/electrical_heating Model Navigator • Start FEMLAB from the

Plot ModeAfter solving the problem, the software displays a surface plot of the electric potential (V).

H E A T TR A N S F E R A N D C O N D U C T I V E M E D I A D C C O U P L I N G

As mentioned earlier, an electric current generates heat in the copper plate, so let’s model this effect in the Heat transfer application mode, thereby introducing the multiphysics capabilities of FEMLAB.

1-10 | F E M L A B

Page 11: EXAMPLE MODEL - Institutionen för tillämpad fysik och ... II/Practice...FEMLAB | 1-3 Model Library FEMLAB/Multiphysics/electrical_heating Model Navigator • Start FEMLAB from the

An air stream at 300 K (27° C) cools the plate except on its thermally insulated upper and lower edges.

To set up the multiphysics model you need to know how electric current affects the temperature. Recall that the electric potential V is the solution variable in the Conductive media DC application mode. The generated heat Q is proportional to the square of the magnitude of the electric current J in the material. The current, in turn, is proportional to the electric field, which equals the negative of the gradient of the potential V.

The coefficient of proportionality is the electrical resistivity ρ= 1/σ, which is also the reciprocal of the temperature-dependent electric conductivity σ = σ(T). Combining these facts gives the fully coupled relation

using the vector differential operator symbol ∇ for the gradient. For more information on the vector differential operator, see the section “The FEMLAB PDE Language” on page 1-336.

300 K

Copper Plate

300 K

300 K

Thermal Insulation

Thermal Insulation

Q J 2∝

Q 1σ--- J

2 1σ--- σE

2σ V∇ 2

= = =

F E M L A B | 1-11

Page 12: EXAMPLE MODEL - Institutionen för tillämpad fysik och ... II/Practice...FEMLAB | 1-3 Model Library FEMLAB/Multiphysics/electrical_heating Model Navigator • Start FEMLAB from the

Note that quantities other than σ vary with temperature. For example, the thermal conductivity is temperature dependent, as well, and a refined model would take this into account.

Options To add thermal coupling, you must invoke the Heat transfer application mode. That mode comes with a solution component preassigned with the name T, but the model you just created already has a model parameter with that name. Therefore the first step is to delete the constant T from the Add/Edit Constants dialog box.

• Choose Add/Edit Constants… from the Options menu.

• When the dialog box opens, select the constant T and press the Delete button to remove it.

Model Navigator Now add the Heat transfer application mode.

• Choose Add/Edit Modes from the Multiphysics menu, which opens the Model

Navigator on the Multiphysics page.

• Select Heat transfer from the list of application modes on the left.

• Copy the Heat transfer application mode to the right application mode list for multiphysics combinations by clicking on the right arrow symbol in between the two lists.

• The multiphysics part of this particular model is time dependent. Change the Solver type to Time dependent in the Solver type menu at the upper right.

• Press OK to close the dialog box.

1-12 | F E M L A B

Page 13: EXAMPLE MODEL - Institutionen för tillämpad fysik och ... II/Practice...FEMLAB | 1-3 Model Library FEMLAB/Multiphysics/electrical_heating Model Navigator • Start FEMLAB from the

The current application mode (Heat transfer) now appears in the FEMLAB window bar.

Boundary Mode• To set the heat transfer boundary conditions, open the Boundary Settings dialog

box from the Boundary menu again.

The boundary conditions for this model are:

• Select all boundaries and press the radio button for Temperature (T). Enter 300 in the Temperature edit field. This value corresponds to holding all boundaries at 300 K, such as by positioning them in an air stream at room temperature.

• Select boundaries 2 and 3 and press the radio button for Insulation/symmetry. This action insulates these two boundaries so that no heat flux enters or leaves through them.

• Press OK to close the dialog box.

BOUNDARY 1,4-8 2,3

Type Temperature Insulation

T 300

F E M L A B | 1-13

Page 14: EXAMPLE MODEL - Institutionen för tillämpad fysik och ... II/Practice...FEMLAB | 1-3 Model Library FEMLAB/Multiphysics/electrical_heating Model Navigator • Start FEMLAB from the

Subdomain ModeThe material properties (PDE coefficients) for Heat transfer in this example are:

• Open the Subdomain Settings dialog box from the Subdomain menu. Notice that the headline of the dialog box contains the suffix /ht to indicate that the Subdomain

Settings dialog box is opened in the Heat transfer application mode.

• Select subdomain 1 from the Subdomain selection list box.

• In the Density edit field, enter 8930, the density in kg/m3 for copper.

• Enter 340 in the Heat capacity edit field. The unit for heat capacity is Ws/kgK. Recall that heat capacity represents the energy required to heat 1 kg of material 1 K. Heat capacity and density together control the time scale of temperature variations in a heat-transfer model. A dense material heats up more slowly, as does a material with a large heat capacity.

• Enter 384 for Thermal conductivity in the edit field. This coefficient has the unit W/mK and represents the ability of the material to conduct heat per unit time.

• Finally, enter 1/(r0*(1+alpha*(T-T0)))*(Vx^2+Vy^2) for Heat source in the edit field. This expression makes this a nonlinear multiphysics model because the

SUBDOMAIN 1

ρ 8930

C 340

k 384

Q 1/(r0*(1+alpha*(T-T0)))*(Vx^2+Vy^2)

1-14 | F E M L A B

Page 15: EXAMPLE MODEL - Institutionen för tillämpad fysik och ... II/Practice...FEMLAB | 1-3 Model Library FEMLAB/Multiphysics/electrical_heating Model Navigator • Start FEMLAB from the

square of the magnitude of the gradient of the electric potential (Vx^2+Vy^2) occurs as a factor.

Enter the following initial values.

• Press the Init tab in the Subdomain Settings dialog box.

SUBDOMAIN 1

V 0.1*(1-x)

T 300

F E M L A B | 1-15

Page 16: EXAMPLE MODEL - Institutionen för tillämpad fysik och ... II/Practice...FEMLAB | 1-3 Model Library FEMLAB/Multiphysics/electrical_heating Model Navigator • Start FEMLAB from the

• Enter 300 as initial value in the edit field for T(t0) and press Apply.

• Switch to the Conductive media DC application mode, selecting from the Multiphysics menu.

• Go to the Init page of the Subdomain Settings dialog box and enter 01*(1-x) in the edit field for V(t0). This term corresponds to a linearly varying potential distribution from 0.1 V at the left boundary (x = 0) to 0 V at the right boundary (x = 1).

• Press OK to close the dialog box.

Solve Problem This model is time-dependent, so you must specify the time interval of the simulation, as well as for which points in time the solution vector will be available for visualization and post processing.

• To specify the simulation’s time scale, open the Solver Parameters dialog box from the Solve menu and select the Timestepping page.

• Enter linspace(0,2000,41) in the Output times edit field after deleting any previous contents. The MATLAB command produces a vector of 41 output times, linearly distributed, ranging from 0 to 2000 seconds, for which the solution is

1-16 | F E M L A B

Page 17: EXAMPLE MODEL - Institutionen för tillämpad fysik och ... II/Practice...FEMLAB | 1-3 Model Library FEMLAB/Multiphysics/electrical_heating Model Navigator • Start FEMLAB from the

accessible for post processing. (This vector doesn’t control the internal time stepping of the ODE solver).

• Press OK to close the dialog box.

Everything is ready to start the simulation.

• Press the Solve Problem button on the main toolbar. (Time to solve: 50 s)

The Solution Progress window appears. A wait bar gives an estimate of the solution time, and a Cancel and Stop button allow you to terminate the solution process. Pressing the Cancel button interrupts the simulation and the user interface returns to its state prior to starting the simulation. The Stop button also interrupts the simulation but also returns the solution up to the current time step.

F E M L A B | 1-17

Page 18: EXAMPLE MODEL - Institutionen för tillämpad fysik och ... II/Practice...FEMLAB | 1-3 Model Library FEMLAB/Multiphysics/electrical_heating Model Navigator • Start FEMLAB from the

After a while, when the ODE solver has determined the appropriate step length, the output times start to appear in the message log. When it reaches the final value 2000 s, the software automatically visualizes the final state in post mode.

Post Mode• With this dynamic simulation you can animate the results by pressing the

Animation button on the plot toolbar. The software starts by recording a sequence of solutions, and it then plays the resulting movie repeatedly.

Another quantity that is interesting to animate is the temperature gradient. If this model were to include the plane stress or plane strain application modes it would represent the thermo-mechanical coupling by a body force proportional to the temperature gradient. For more information on thermo-mechanical multiphysics, see the model “Stresses in Cracked Heat Exchanger Tubes” on page 2-296 in the Model Library.

• Open the Plot Parameters dialog box from the Post menu by choosing Plot

Parameters.

• Select the Surface page and change the Surface expression to temp. gradient (gradT_ht).

• Verify that the Smooth check box is checked, which creates an interpolated plot of the gradient field. This is necessary to get a smooth plot, because for the default

1-18 | F E M L A B

Page 19: EXAMPLE MODEL - Institutionen för tillämpad fysik och ... II/Practice...FEMLAB | 1-3 Model Library FEMLAB/Multiphysics/electrical_heating Model Navigator • Start FEMLAB from the

Lagrange type elements, the gradient isn’t necessarily continuous over the element boundaries.

• Press OK to close the dialog box and to view the gradient plot.

• Press the Animation button on the plot toolbar again to start a new animation.

F E M L A B | 1-19

Page 20: EXAMPLE MODEL - Institutionen för tillämpad fysik och ... II/Practice...FEMLAB | 1-3 Model Library FEMLAB/Multiphysics/electrical_heating Model Navigator • Start FEMLAB from the

You can also create a 3D plot of the temperature gradient and simultaneously use an overlaid 2D surface plot of the current density.

• In the Plot Parameters dialog box, go to the Surface page. Select current density (J) as Surface expression and temp. gradient (gradT_ht) as Height expression.

• Press OK to view the visualization.

You can now rotate the 3D graph by clicking and dragging an enclosing 3D box in the user interface. Also try some of the other quick plots from the plot toolbar. Notice that for each plot option there is a corresponding page in the Plot Parameters dialog box. The Smooth check box in the Height data is checked by default to create a smooth plot.

For a description on how to do this simulation using the FEMLAB Programming Language, see “Resistive Heating in a Copper Plate” on page 1-319 in the User’s Guide.

1-20 | F E M L A B