Lab #4

Lab #4
LAB 4: Introduction to MATLAB PDE Toolbox and SolidWorks Simulation
Objective:
The objective of this laboratory is to introduce how to use MATLAB PDE toolbox and
SolidWorks Simulation to solve two-dimensional steady-state and transient conduction heat
transfer problems.
Background for MATLAB PDE Toolbox:
This document provides some simple instructions for getting started with the partial differentialequation (PDE) toolbox in MATLAB. The PDE toolbox uses the finite element method (FEM)
to solve a wide variety of elliptic, parabolic, and hyperbolic PDEs that are two-dimensional in
space. We have been solving steady state conduction problems governed by the elliptic equation
−∇ ⋅ ( k ∇T ) = Q˙ + [ h (Text − T )] w
(1)
where T(x, y) is the two-dimensional temperature distribution, k is thermal conductivity, Q˙ is
internal heat generation, h is convection coefficient, Text is external temperature, and w is width.
The last term is for the€special case of heat transfer from the faces of the domain at z = 0 and w
as shown for a rectangular geometry in Figure 1. We have not previously used this term. We will
€
set h = 0 to indicate either insulated faces or w much larger than the x and y dimensions.
For
transient problems the PDE toolbox uses the implicit finite difference method. We have been
solving transient conduction problems governed by the parabolic equation
ρC
∂T
− ∇ ⋅ ( k ∇T ) = Q˙ + [ h (Text − T )] w
∂t
(2)
where T(x, y, t) is now the transient two-dimensional temperature distribution, ρ is density, C is
specific heat, and t is time.
€
y
w
x
z
Figure 1. Schematic of rectangular domain.
There are several steps involved in correctly specifying and solving any PDE problem. The
typical order in which these steps are handled for FEM is as follows:
Pre-processor:
1. Define the domain of the problem in space (i.e. the geometry)
2. Define the boundary conditions
3. Define the “mesh”
4. Set the proper PDE for solution and the material properties for the system
5. Define the initial condition for transient problems and the time step
Processor: Solve the equations
Post-processor: Analyze the results
The graphical user-interface (GUI) for the PDE toolbox in MATLAB has all of these functions
written out in this order along the top menu bar. You can also save everything you do to a
MATLAB script file so that you will not have to repeat all the steps every time you solve a
problem. Finally, you can export your results into the MATLAB environment to solve PDEs
programmatically and to complete more flexible post-processing.
Background for SolidWorks Simulation:
This document also provides some simple instructions for getting started with performing a
thermal analysis using the Simulation software in SolidWorks. Similar to the PDE toolbox in
MATLAB, the SolidWorks Simulation software also uses FEM and the implicit finite difference
method for time to solve a variety of mechanics problems. In addition, simulations can also be
performed that are three dimensional in space, include radiation boundary conditions, and
account for contact resistance. The steps for performing an analysis are similar to those above for
the PDE toolbox, but with some slight variations in the order in which they are performed. In
addition, the terminology is a little different. For example, the boundary conditions are referred
to as thermal loads. Finally, the post-processing will involve additional steps to bring the data
into a spreadsheet or the MATLAB environment.
2
Laboratory:
Getting started with MATLAB PDE Toolbox
To get started, launch MATLAB by double-clicking the icon on the desktop. Once there, you can
type "pdetool" at the prompt. In a few seconds, MATLAB will open up a graphical user-interface
(GUI) for you to work in. You will notice that there is an empty grid in front of you. If you want
to change any characteristics of the grid (such as the minimum or maximum values, increments,
the number of gridlines, or the “snap” characteristics of the drawing tools) go to the Options
heading on the toolbox menu. To set the PDE toolbox to work with parameters for heat transfer
problems change the pull-down menu in the toolbar menu from “Generic Scalar” to “Heat
Transfer.” Notice that there are a variety of other problems that you can solve.
set this to
heat transfer
Geometry
To define the geometry on which you want to solve your PDE, go to the Draw menu. There are
some simple shapes to choose from such as circles and squares. Making shapes on the grid
should be similar to many other drawing programs you have used previously. For more precise
drawings you can use the “snap” characteristics or double-click on an object after it has been
drawn to set its dimensions in the pop-up window.
For more complex geometries you can add and subtract simple geometric shapes. For example,
3
starting with an empty window first draw a rectangle that should be indicated as “R1” (or
rectangle one) in the Set formula window. Next, draw an elipse overlapping the rectangle that
will be indicated as “E1” (or elipse one) in the Set formula window. Note that the combination of
the two objects is indicated by “R1 + E1” and the domain will be the union of the two shapes. If
you change this to “R1 - E1” in the Set formula window the domain will be what is left of the
square after the intersection of the square and the ellipse is removed. This becomes apparent if
you go to the Boundary menu and select the Boundary Mode. Return now to the draw mode by
going to the Draw menu and selecting the Draw Mode. Erase whatever objects you have created
so far by going to the Edit menu, selecting Select All, and hitting the delete key.
For this laboratory, stick with the simple geometry of a square domain that is 1 m on each side.
Note that the PDE toolbox does not make you specify units, thus you need to make sure you use
consistent units throughout your problem. The easiest way to do this is to either nondimensionalize your problem or use a consistent set of units throughout such as SI.
Boundary conditions
To set the boundary conditions for your geometry, go to the Boundary menu and select Boundary
Mode. Gray edge segments are subdomain borders introduced by intersections of solid objects.
Borders that do not represent real borders (for example borders between areas with differing
material properties) can be removed. From the Boundary menu, select the Remove All
Subdomain Borders option. All borders are then removed from the decomposed geometry.
To specify a boundary condition double-click on the desired boundary. Boundaries turn black
when selected, and you can select multiple boundaries using the shift key when selecting if they
are all to have the same boundary condition. For conduction heat transfer problems there are
three types of boundary conditions: specified temperature (Dirichlet), specified heat flux
(Neumann), and convection (mixed) boundary conditions. In the PDE toolbox, the boundary
conditions are specified as follows:
1. Dirichlet Condition: Select the Dirichlet condition type in the Boundary Condition pop-up
window. Set h (weighting function) equal to unity and r to desired temperature in the following:
hT=r
(3)
2. Neumann Condition: Select the Neumann condition type in the Boundary Condition pop-up
window. Set q to zero and g to the negative of the desired heat flux (or zero if adiabatic) in the
€
following equation:
!
n ⋅ ( k ∇T ) + q T = g
where k is the thermal conductivity of the material and will be specified later.
€
3. Mixed Condition or Convection:
Select the Neumann condition type in the Boundary
Condition pop-up window. For Equation (4) with convection, set q to the desired convection
coefficient and g to the temperature of the environment times the convection coefficient.
4
(4)
When you are done you should see Dirichlet boundary conditions colored red and Neumann and
mixed boundary conditions colored blue. For this laboratory, make the bottom and side borders a
fixed temperature of 0 ˚C and the top border a fixed temperature of 100 ˚C.
When you have completed the geometry and boundary conditions export them to the MATLAB
environment by going to the Boundary menu item and selecting Export Decomposed Geometry,
Bound. Cond’s. Accept the default variables for export which are g for the decomposed geometry
matrix and b for the boundary condition matrix. If you now switch over to the MATLAB
environment you will find g and b in your workspace as matrices. To get more information for
each of these matrices refer to the online help for the function decsg for g and function assemb
for b. Unfortunately, the exporting process is one command that MATLAB does not save to a
script file, so you will have to do this manually every time you run a problem from the GUI.
PDE specification
To define the governing equation, go to PDE on the menu bar and select PDE mode. Then
double-click on the domain for which you wish to specify the PDE. If there are multiple domains
with different properties you can select each one separately. For heat transfer, an elliptic equation
describes steady state conduction while a parabolic equation describes transient conduction. For
a steady state problem, specify the thermal conductivity of the medium (referred to in the PDE
Specification window as Coeff. of heat conduction). Q represents internal heat generation per
unit volume. h and Text represent convection heat transfer on the faces of the domain parallel to
the display. They are set to 0 for insulated faces or for a domain that is long in the z-direction.
For a transient problem the density, ρ, and the specific heat, C, must also be specified. For this
laboratory, specify an elliptic equation, k = 1 W/m•K, Q = 0, h = 0, and Text = 0 ˚C.
Mesh
The next step is to define the mesh that divides the geometry into discrete elements. The PDE
toolbox does this automatically for you. Go to the Mesh menu item and select Initialize Mesh.
This creates an unstructured mesh with triangular elements. You can further refine the mesh by
going to the Mesh menu item and selecting Refine Mesh. The mesh should be refined to the point
that a regular array of mesh elements covers the irregularities in the geometry (with “good
resolution") but not to the point that there are so many elements that you get marginally better
answers for increased solution time (“point of diminishing returns”). You can also jiggle the
mesh to knock the triangular elements into better arrangement by going to the Mesh menu item
and selecting Jiggle Mesh. You can start over by selecting Initialize Mesh from the Mesh menu
item at any time. To control the mesh size more select Parameters from the Mesh menu item and
set the maximum edge size to 0.05 m and select OK. Now select Initialize Mesh from the Mesh
menu item and observe the changes. Note that you can also use the mesh growth rate in the Mesh
Parameters window to control the Refine mesh step away from small features in the geometry.
When you have completed the mesh, export the mesh to the MATLAB environment by going to
the Mesh menu item and selecting Export Mesh, so that you can post-process your results.
Accept the default variables for export which are p, e, and t. If you now switch over to the
5
MATLAB environment you will find p, e, and t in your workspace as matrices. To get more
information on how each of these variables contain mesh data refer to the online help for the
function initmesh. In particular, note that the t matrix contains information for each of the
triangles in the mesh and its second dimension can be used to determine how many elements are
in the mesh.
Solution
To solve the problem go to the Solve menu and select Solve PDE. After the PDE toolbox gives
you a plot of the temperature solution, export this solution for post-processing by going to the
Solve menu and selecting Export Solution. This will export the solution into the MATLAB
environment as the variable u that will be a vector whose length will be the same as the number
of nodes in the domain. For this problem, it will give the temperature at each node. Again, the
export step is not saved in your script file, so you will have to do it manually every time.
At this point you should save your file as a “.m” file. After it has been saved exit the PDE
toolbox and open up the file in the MATLAB editor. Notice that it is a list of all the functions
called in MATLAB by the PDE toolbox GUI to obtain the solution thus far. It is called a “script
file” simply indicating that it is a list of instructions. You can get back to where you exited the
PDE toolbox by typing the name of the file without the “.m” in the MATLAB Command
Window. Note that there are many comment lines and that all the functions called are described
in the help menu. Thus, you can edit the “.m” file to run different cases such as for different
boundary conditions or levels of mesh refinement.
Post-processing
Under the Plot menu, you can change the type and appearance of the plots displayed. For
example, when you go to the Plot menu and select Parameters, a color contour plot of
temperature is the default. Try changing the Colormap (I prefer ‘jet’) and updating the display by
selecting Plot from the Plot Selection dialog box. Also, try plotting heat flux vectors by selecting
Arrows from the Plot type: (note that you can leave Color selected to have the plots displayed
together) and heat flux from the Property: selections and again select Plot to redisplay.
The exported mesh and temperature data can now be manipulated from within the MATLAB
environment. Here is a list of some of the most useful functions along with a short description:
pdemesh(p, e, t) plots the mesh specified by the mesh data p, e, and t
pdeplot(p, e, t, ‘xydata’, u, ’colormap’, ’jet’, ’contour’, ’on’) displays the PDE solution u(x,y)
uxy = tri2grid(p, t, u, x, y) computes the values of u at the grid points defined by the vectors x
and y which you must define with increasing values. The result is a matrix of u values with
dimensions equal to the x-vector length by the y-vector length. Values are computed using
linear interpolation in the triangle containing the grid point. This is useful for comparing your
FEM results on an unstructured mesh to your finite difference results on a structured mesh.
6
Use each of these at least once to manipulate and visualize the data.
Nonlinear Solver
We will now consider how to handle variable properties which makes the governing PDE
nonlinear. First, return to PDE on the menu bar and select PDE mode. Then double-click on your
square domain. Change the thermal conductivity (referred to in the PDE Specification window as
Coeff. of heat conduction) of the medium to the following in W/m•K:
1.0+0.01*u+0.001*u.^2
(5)
where u is the solution vector for temperature in ˚C (thus, the coefficients in this equation must
have units). Do NOT put spaces into this equation. The “.^” is required for the last term because
u is a vector and this will allow each term in the vector to be squared separately. Second, return
to Solve on the menu bar and select Parameters. Check Use nonlinear solver, enter 100 for
Initial solution, full for the Jacobian, and keep the remaining default values. Finally, go to Solve
on the menu bar and select Solve PDE to again obtain a solution and note the significant changes.
Transient Problems
Now that you have completed the steady state solution, we will go back and solve a transient
problem. From the PDE toolbox and your original steady state problem go back to PDE on the
menu bar and select PDE mode. Then double-click on the domain for which you wish to specify
the PDE. Specify a Parabolic equation, ρ (or rho) = 1 kg/m3, C = 1 J/kg•K, k = 1 W/m•K, Q = 0,
h = 0, and Text = 0 ˚C. Next, go to the Solve menu and choose Parameters. Here, you can specify
the time domain (duration and increments for the solution) and the variable u(t0) which
represents the temperature on the entire geometry at the initial time, t = 0, or the initial condition.
Note that the PDE toolbox uses an implicit method for time and is unconditionally stable. Select
0:0.1:1 s for the time domain (which sets the duration to 1 s and the increment to 0.1 s) and
u(t0) = 0 ˚C. Again, to solve the problem, go to the Solve menu and select Solve PDE. The
temperature distribution at the final time will be displayed. To see the temperature distribution at
other times go to the Plot menu and select Parameters. In the Plot Selection dialog box select
another Time for plot and again select Plot to redisplay. Finally, to see a movie of the transient
results select Animation for the Plot type. You can change the number of times the movie will
play and its speed in the Options dialog box. Select Plot to view the movie.
If you now export the solution into the MATLAB environment note that the solution u will now
be a matrix. The first index indicates node number and the second index indicates time step.
Thus, u(:, 1) will give the solution at the initial time step. To plot the data at the nth time step use
the following:
pdeplot(p, e, t, ’xydata’, u(:, n))
where n = 1 for the initial time step, n = 2 for the second time step, and so on.
7
Solving PDEs Programatically
Although the PDE Toolbox GUI is a useful way to solve PDEs, the flexibility of using
command-line functions is sometimes useful for automating calculations, such as for
convergence studies. The easiest way to do this is to still use the PDE Toolbox GUI to define the
geometry and boundary conditions and export the decomposed geometry and boundary condition
matrices to the MATLAB environment as described above. Then, from the MATLAB
environment (or a script file) use the following functions
fid = wgeom(g, 'file_g');
% create geometry file from matrix g
fid = wbound(b, 'file_b');
% create boundary condition file from matrix b
Next, to create, refine, and jiggle a mesh use the following functions
[p, e, t] = initmesh('file_g', 'Hmax', Hm);
[p, e, t] = refinemesh('file_g', p, e, t);
p = jigglemesh(p, e, t);
One option for the initmesh function is shown that sets the minimum size, Hm, for the edge
spacing for the mesh. Use the online help to see additional options for each of these functions.
To solve an elliptic PDE defined as
−∇⋅ (c ∇u) + a u = f
(6)
where the values of the coefficients c, a, and f must be set as string variables, use the following
function for a linear equation
€
u = assempde('file_b', p, e, t, c, a, f);
Alternatively, use the following function to solve a nonlinear elliptic PDE equation
[u, res] = pdenonlin('file_b', p, e, t, c, a, f, 'Jacobian', 'full', 'U0', 100);
where the options to use the full Jacobian and to specify an initial guess are set. To solve the
parabolic PDE defined as
d
∂u
− ∇⋅ (c ∇u) + a u = f
∂t
where the values of the coefficients d, c, a, and f must again be set as string variables and the
initial condition and number of time steps must also be set using
€
u0 = T0*ones(size(p, 2), 1); % initial condition, T0 is the initial temperature
8
(7)
tlist = linspace(0, tf, nt);
% time, tf is final time, nt is number of time steps
use the following function for a linear equation
u1 = parabolic(u0, tlist, file_b', p, e, t, c, a, f, d);
Note that for heat transfer for Equations (6) and (7), c corresponds to thermal conductivity, a and
f can be used to account for a heat source, and d corresponds to the density times the specific
heat capacity which can be seen by comparing to Equations (1) and (2).
References
In addition to this document there is help available online from within MATLAB. Under the
Contents tab within the help browser window there is a section titled Partial Differential
Equation Toolbox that contains many resources. In particular, there are several tutorials and a
manual available in PDF format called the Partial Differential Equation Toolbox User’s Guide.
The manual contains all the details about the GUI, functions, and the PDE toolbox’s
implementation of the finite element method.
Getting Started with SolidWorks Simulation
To get started, launch SolidWorks by double-clicking the icon on the desktop. For the following
instructions, a basic working knowledge of the steps necessary to create simple geometry in
SolidWorks is assumed. Please consult with the instructor if you are not familiar with this solids
modeling software package and need assistance.
To create a new file, from the toolbar at the top use the File pull-down menu to select New, then
Part, and then click OK. Next, from the same toolbar use the Tools pull-down menu to select
Add-Ins and insure that SolidWorks Simulation is selected as one of the Active Add-ins and then
click OK. Finally, use the same Tools pull-down menu to select Options and then under the
Document Properties tab select Units and set the Unit System to MKS and then click OK.
Geometry and Material Properties
To create the geometry, from the Features tab select Extruded Boss/Base. In the drawing
window select the Front Plane. From the Sketch tab select the Corner Rectangle button and draw
a rectangle with the lower left hand corner starting at the origin. Use the Smart Dimension button
to make the rectangle dimensions 1 m by 1 m. Use the Exit Sketch button to close the sketch, set
the depth or D1 to 0.1 m, and click the green check mark to finish creating the part. Finally,
change the part name from Boss-Extrude1 to “brick” in the Feature Manager Design Tree.
To set the material properties for your brick, in the Feature Manager Design Tree right click on
Material and select Edit Material from the pop-up menu. In the Material window right click on
Custom Materials, select New Category, and name it ME 554 Materials. Right click on your new
category and select New Material, change the name to “ceramic,” set density to 1 kg/m3, thermal
conductivity to 1 W/m•K, specific heat to 1 J/kg•K, and then click Save, Apply and Close.
9
To save the brick as a part, from the toolbar at the top of the window use the File pull-down
menu to save the Part as “brick”. To also save the brick as an assembly, use the File pull-down
menu to select New, then Assembly, and then click OK. From the Begin Assembly section in the
Part/Assembly to Insert window select the name of the part you just created and click the green
check mark to insert the brick into the assembly at the origin. Finally, use the File pull-down
menu to save the Assembly as “brick_assembly”. Note you must work from an Assembly file
instead of a Part file for a simulation if you need to set internal power generation or an initial
condition for an entire part.
Simulation Setup
To create a simulation tab, from the toolbar at the top of the window use the Simulation pulldown menu to select Study. In the Type window select the Thermal button, for Name enter
Steady 2D, under Options select Use 2D Simplification, and then click the green check mark.
New windows will open that allow you to specify the parameters for the 2D simplification. In the
Study Type window insure that Extruded is selected. In the Section Definition window for the
Section Plane select the front face of the brick (that is normal to the z-axis), set the Section depth
to 0.10 m, and then click the green check mark. Note that if internal heat generation is specified,
the volume of the part will be based on the Section depth. Also, note that a new tab has been
created at the bottom called Steady 2D and just the front face of the brick is now displayed in the
drawing window.
PDE Specification and Units Selection
To specify the PDE to solve, on the lower left in the new Simulation Tree right click on Steady
2D and select Properties from the pop-up menu. In the Thermal window under the Options tab
insure that Steady state is selected. Note that the system of linear algebraic equations can be
solved using either direct matrix inversion (Gaussian elimination or Direct Sparse) or iteration
(Gauss-Seidel or FFE Plus). For meshes up to about 100,000 elements direct matrix inversion
should be faster. Select Automatic which chooses the method that is fastest for the current
problem. Click the Advanced Options button and set the Convergence tolerance to 0.0001%,
insure the Under-relaxation factor for the iteration is set to Automatic, and click OK.
To set the default unit system, in the Simulation Tree right click on Parts and select Options
from the pop-up menu. In the System Option window under the Default Options tab set the Unit
system to SI (MKS).
Boundary Conditions
To set constant temperature boundary conditions on all the edges, in the Simulation Tree right
click on Thermal Loads and select Temperature from the pop-up menu. In the Type window for
the Faces, Edges or Vertices select the bottom three edges. In the Temperature window set the
temperature to 0 ˚C and then click the green check mark. Repeat this process to set the
temperature to 100 ˚C for the top edge.
Mesh
10
To create the unstructured mesh, in the Simulation Tree right click on Mesh and select Create
Mesh from the pop-up menu. In the Mesh Parameters window select Standard Mesh and set the
Global size to 0.05 m. Verify that the Tolerance is now set to 0.0025 m and then click the green
check mark. In the Simulation Tree right click on Mesh and select Details from the pop-up menu.
Verify that the fairy regular planar 2D mesh has 800 triangular elements and 1,681 nodes.
Solution
To solve the problem, in the Simulation Tree right click on Steady 2D and select Run from the
pop-up menu. A Solution window will pop-up to indicate your progress. When it is finished
solving the system of equations, a contour plot of temperature will appear in drawing window.
Save your results to your file.
Post-Processing
To calculate heat transfer rates, in the Simulation Tree right click on the Results folder and select
List Heat Power from the pop-up menu. In the Selection window for the units select Watt from
the pull-down menu and for Faces, Edges, or Vertices select the four bounding edges for the
brick in the drawing window and click Update. Note that for the bottom edge at y = 0, the heat
transfer rate can be calculated from the analytical solution from Lab 1 to be
Lx
# ∂T &
4
qy ( x = 0 ) = −k Lz ∫ % ( dx = −k Lz (T2 − T1 )
π
x=0 $ ∂y ' y=0
∞
∑
n=1
(−1)
n+1
n
+1
1
sinh ( n π Ly Lx )
(8)
where Lz is the length in the z-direction that was set to 0.1 m above as part of the 2D
simplification process. For the parameters for this problem this corresponds to 2.206 W. Verify
that the calculated power out of the bottom surface is 2.22 W corresponding to an error of
approximately 0.6%. (Note that because of the top two corner singularities, the analytical
solution for the heat transfer rate is +∞ on the top is and -∞ for the left and right sides). Also,
check in the Summary window that the Net power for the Entire Model is relatively small
indicting global energy conservation. Click the green check mark to close the window.
To change the settings for the temperature contour plot, in the Simulation Tree right click on
Thermal1 in the Results folder and select Chart Options from the pop-up menu. In the Display
Options window select Defined for the scale and set the minimum to 0 ˚C and the maximum to
100 ˚C. In the Position/Format window select floating from the pull-down menu and set the
number of decimal places to 0. In the Color Options window set the number of chart colors to
10. Finally, click the green check mark to close the windows.
To create a heat flux contour plot, in the Simulation Tree right click on the Results folder and
select Define Thermal Plot from the pop-up menu. In the Display window select HFLUXN:
Resultant Heat Flux from the pull-down menu and for the Units select W/m2 from the pull-down
menu. Under the Chart Options tab, in the Display Options window select Defined for the scale
and set the minimum to 0 W/m2 and the maximum to 1000 W/m2. In the Position/Format
11
window select floating from the pull-down menu and set the number of decimal places to 0. In
the Color Options window set the number of chart colors to 10. Finally, click the green check
mark to close the windows and generate the plot. Note that the heat flux is extremely high in the
upper corners where the temperature jumps from 0 ˚C to 100 ˚C as expected.
To create a report that documents the settings for your simulation and your results, from the
toolbar at the top of the window use the Simulation pull-down menu to select Report. In the
Report Options window for the Report sections select the following: Model Information, Study
Properties, Material Properties, Thermal Loads, Mesh Information, and Study Results. Also, in
the Report Options window enter a Report path and Document name and click Publish. A
Generating Report window will open to indicate progress. When finished Microsoft Word will
open a document that includes the requested simulation setting information and results. Note that
in the Simulation Tree there is now a Report folder. You can right click on the report you just
created and select Define from the pull-down menu to change your options.
To export the data for post processing in MATLAB, in the Simulation Tree in the Results folder
right click on Thermal1 and select Show and then Probe from the pop-up menu. In the Options
window select On selected entities. In the Results window for Faces, Edges, or Vertices select
the front face of the brick in the drawing window and click Update. Note that for all nodes the
temperature and location are listed in the Results window and the statistics are listed in the
Summary window. In the Report Options window click the Save button and save the file as
“Steady2D.csv” (comma separated text data file). Next, use a MATLAB script (saved in the
same folder as the data file) with the following lines to import the temperature and location data
into vectors named T, x, and y and to then plot the nodal data on a regular mesh:
fileID = fopen('Steady2D.csv');
% open data file
% scan text file: specify format, skip header lines, specify delimiter
C = textscan(fileID, '%d %f %f %f %f %s', 'HeaderLines', 9, 'Delimiter', ',');
fclose(fileID);
% close data file
[N, T, x, y, z, Comp] = C{1, :};
% define variables stored in cell array
Nx = 20; Ny = 20;
xmax = max(x); ymax = max(y);
xgv = 0:xmax/Nx:xmax;
ygv = 0:ymax/Ny:ymax;
[xq, yq] = meshgrid(xgv, ygv);
% number of points in x and y directions
% maximum values for for x and y directions
% regular mesh vector in x-direction
% regular mesh vector in y-direction
% create regular mesh arrays
Tq = griddata(x, y, T, xq, yq);
% interpolate nodal data onto regular mesh
contourf(xq, yq, Tq);
% contour plot of data
12
Nonlinear Solver
To make this problem non-linear the thermal conductivity will once again be made temperature
dependent. To create a new simulation tab for this case, from the toolbar at the top of the window
use the Simulation pull-down menu to select Study. In the Type window select the Thermal
button, for Name enter Steady 2D Nonlinear, under Options select Use 2D Simplification, and
then click the green check mark. In the Study Type window insure that Extruded is selected. In
the Section Definition window for the Section Plane select the front face of the brick (that is
normal to the z-axis), set the Section depth to 0.10 m, and then click the green check mark.
Similar to before to specify the PDE to solve, in the Simulation Tree right click on Steady 2D
Nonlinear and select Properties from the pop-up menu. In the Thermal window under the
Options tab insure that Steady state is selected. Click the Advanced Options button and set the
Convergence tolerance to 0.0001%, insure the Under-relaxation factor for the iteration is set to
Automatic, and click OK. Note that if the problem is highly non-linear you may need to set the
under-relaxation factor to a value much less than one to get convergence.
To change the material properties for your brick, in the Simulation Tree expand the Part folder
and right click on brick and select Apply/Edit Material from the pop-up menu. In the Material
window right click on the Custom Materials\ME 554 Materials folder and select New Material
from the pop-up menu. In the Material window change the name to “ceramic variable” and set
the density to 1 kg/m3 and specific heat to 1 J/kg•K as before. Next, click the box where the value
for Thermal Conductivity is set and select Temperature Dependent from the pull-down menu.
This should switch you to the Tables & Curves tab. Use Equation (5) to set the thermal
conductivity at 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, and 100 ˚C. When finished click Apply and
Close. Note that if you switch back to Steady 2D the original properties for “ceramic” are still
being used and have not been changed in the database.
To set the same constant temperature boundary conditions on all the edges used previously,
select the Steady 2D tab from the bottom. In the Simulation Tree left click on Thermal Loads,
then while holding down the button drag the thermal loads icon on top of the Steady 2D
Nonlinear tab on the bottom and release the button. You should be switched into the new
simulation and the constant boundary temperature conditions should have been copied. To use
the same mesh, copy the mesh from Steady 2D over to your new simulation in a similar way.
Once again to solve the problem, in the Simulation Tree right click on Steady 2D Nonlinear and
select Run from the pop-up menu. Notice that it will take a little longer to solve and that the
solution will change significantly. Save your results to your file.
Transient Problems
We will now solve the same two-dimensional transient problem from the PDE Toolbox tutorial.
To create a new simulation tab for this case, from the toolbar at the top of the window use the
Simulation pull-down menu to select Study. In the Type window select the Thermal button, for
Name enter Transient 2D, under Options select Use 2D Simplification, and then click the green
check mark. In the Study Type window insure that Extruded is selected. In the Section Definition
13
window for the Section Plane select the front face of the brick (that is normal to the z-axis), set
the Section depth to 0.10 m, and then click the green check mark.
To specify the PDE to solve, in the Simulation Tree right click on Transient 2D and select
Properties from the pop-up menu. In the Thermal window under the Options tab select Transient
and verify that the Total time is set to 1 sec and the Time increment is set to 0.1 sec. Click the
Advanced Options button and set the Convergence tolerance to 0.0001%, insure the Underrelaxation factor for the iteration is set to Automatic, and click OK. Copy the constant
temperature boundary conditions and mesh from the Steady 2D tab using the same method that
was used above for the Nonlinear Solver section.
In addition to the fixed temperature boundary conditions we now need to add an initial condition
for the temperature for the entire domain. To do this in the Simulation Tree right click on
Thermal Loads and select Temperature from the pop-up menu. In the Type window select Initial
temperature and for the Faces, Edges or Vertices select the front face in the drawing window. In
the Temperature window set the temperature to 0 ˚C and then click the green check mark.
To solve the problem, in the Simulation Tree right click on Transient 2D and select Run from the
pop-up menu. Notice that it will once again take a little longer to solve. When finished a contour
plot of temperature at the final time will be displayed in the drawing window. To see the solution
at a different time, in the Simulation Tree in the Results folder right click on Thermal1 and select
Edit Definition from the pop-up menu. In the Plot Step window enter either a new Time or Plot
step for the plot and click the green check mark.
To extract data at several locations, in the Simulation Tree in the Results folder right click on
Thermal1 and select Show and then Probe from the pop-up menu. In the Options window select
At location and click on the front face in five location starting near the top in middle and going
downwards. To remove a probe at a particular location, in the Results window right click on a
node and select Delete from the pull-down menu. To save these probe locations, in the Report
Options window click the Save as Sensor button. In the Options window if you now select From
sensors you should see that your sensors have been saved as Workflow Sensitive1. To plot out
your data as a function of time, in the Report Options window click the Response button. When
finished verifying the data makes sense, close the Response Graph window and click the green
check mark. Note that in the Feature Manager Design Tree in the Sensors folder you will now
find Workflow Sensitive1 that can be edited from this location. Save your results to your file.
Three-Dimensional Problems
We will now solve the same two-dimensional transient problem from above, but use the threedimensional brick geometry. To create a new simulation tab for this case, from the toolbar at the
top of the window use the Simulation pull-down menu to select Study. In the Type window select
the Thermal button, for Name enter Transient 3D, under Options insure that Use 2D
Simplification is NOT selected, and then click the green check mark. In the drawing window you
should now see the 3D brick geometry.
To specify the PDE to solve, in the Simulation Tree right click on Transient 3D and select
14
Properties from the pop-up menu. In the Thermal window under the Options tab select Transient
and verify that the Total time is set to 1 sec and the Time increment is set to 0.1 sec. Click the
Advanced Options button and set the Convergence tolerance to 0.0001%, insure the Underrelaxation factor for the iteration is set to Automatic, and click OK.
Because the geometry is different for the two and three-dimensional cases you will need to create
new boundary and initial conditions instead of just copying them. To set the boundary
conditions, in the Simulation Tree right click on Thermal Loads and select Temperature from the
pop-up menu. In the Type window for the Faces, Edges, Vertices, or Components for
Temperature select the bottom three faces. In the Temperature window set the temperature to
0 ˚C, in the Variation with Time window insure that the button is NOT selected, and then click
the green check mark. Repeat this process to set the temperature to 100 ˚C for the top face. For
the front and back face boundary conditions, either set the heat flux to 0 W or do not set anything
(because the default is zero heat flux when nothing has been specified). Note that these boundary
conditions correspond to two-dimensional heat transfer in the x-y plane.
To set the initial condition, in the Simulation Tree right click on Thermal Loads and select
Temperature from the pop-up menu. In the Type window select Initial temperature and for the
Faces, Edges or Vertices select the entire part by expanding the Part Tree in the upper left-hand
side of the drawing window and selecting the part called “brick”. In the Temperature window set
the temperature to 0 ˚C and then click the green check mark.
Once again, because the geometry is different for the two and three-dimensional cases you will
need to create a new mesh instead of just copying the previous one. To create the unstructured
mesh, in the Simulation Tree right click on Mesh and select Create Mesh from the pop-up menu.
In the Mesh Parameters window select Standard Mesh and set the Global size to 0.05 m. Verify
that the Tolerance is now set to 0.0025 m and then click the green check mark. In the Simulation
Tree right click on Mesh and select Details from the pop-up menu. Verify that the fairy regular
3D mesh has 6,586 tetrahedral elements and 10,771 nodes.
Once again to solve the problem, in the Simulation Tree right click on Transient 3D and select
Run from the pop-up menu. Notice that it will again take a little longer to solve. These results
should be exactly the same as your results for the two-dimensional case above. You can verify
this by using the probes save in Workflow Sensitive1 to compare temperatures at the same
locations for your two and three-dimensional simulations.
To consider a case that is three dimensional, in the Simulation Tree right click on Thermal Loads
and select Convection from the pop-up menu. In the Select Entities window for the Faces for
Convection select the front face. In the Convection Coefficient window set the value to
100 W/m2•C, in the Bulk Ambient Temperature window set the value to 273 K, then click the
green check mark and re-run the simulation. To verify that the results are now three dimensional,
in the Simulation Tree in the Results folder right click on Thermal1 and select Section Clipping
from the pop-up menu. In the Section 1 window, for Reference Entity choose the Right Plane
from the Part Tree in the drawing window and for the Distance enter 0.5 m. In the Options
window, de-select Show section plane and click the green check mark. You should be able to
clearly see from the contour plot on the mid-plane of the brick that the front is now cooler (with
15
convection) than the back (with zero hero heat flux). You can also verify the difference in
temperature from the front to the back using temperature probes. Save your results to your file.
References
As a final note, in addition to this document there is help available online from within
SolidWorks on all of the Simulation tools used above. From the toolbar at the top use the Help
pull-down menu to select SolidWorks Simulation and then select either Help Topics, Tutorials, or
Validation.
When Help Topics is selected, the SolidWorks Help window is opened to the Simulation section
from the complete Users Manual for SolidWorks. In the Simulation section, under Analysis
Background and Thermal Analysis is a topic called Performing a Thermal Analysis that contains
a basic list of all the main steps required for performing an analysis. Use this checklist when
working on your lab assignments.
Under Solidworks Tutorials, in the Solidworks Tutorials window click Advanced Simulation and
then SolidWorks Simulation Professional and then scroll down to the Thermal section. From
there you can choose from cases that cover basic thermal analysis, thermal stress analysis, setting
a thermostat, radiation boundary conditions, and thermal contact resistance.
Under Validation there are Verification Problems (use these to verify correct software
implementation), NAFEMS Benchmarks, and a Theoretical Manual in PDF format that contains
all the details about the FEM implementation in SolidWorks.
16
Assignment:
For this assignment, you will mainly reproduce the results obtained in Lab 3 for Parts 1, 2, 4, and
5 (we cannot easily control the relaxation parameter for the iteration so we will skip Part 3). You
should be able to get the same answers within the limit of machine precision. For Parts 1, 2, 4
and 5 include a PDE toolbox script file and for Part 3 include an automatically generated
SolidWorks Simulation Report. For all five parts write 2-3 sentences to describe if the results are
consistent with your expectations.
For your comparisons complete the following:
1. Using the PDE toolbox solve for the temperature distribution using the appropriate boundary
condition for the thermal symmetry line at x = Lx/2 for the case given in Lab 3, Part 1. Include a
figure of the PDE toolbox solution. Also, include a figure plotting temperature at x = y = 0.4 m
versus total number of elements for both the PDE toolbox solution and FD method. On the figure
add the analytical solution from Lab 1. This figure is similar to the one from Lab 2, Part 2 except
for the addition of the FEM solution and using the number of elements for the x-axis. For the
PDE toolbox solution, use the tri2grid function referred to in the Post-Processing section to
find the temperature at the indicated location and use the t matrix referred to in the Mesh section
to determine the number of triangles (or elements). For both methods obtain data for at least 4
different meshes. Determine the number of elements required by both methods to get within
0.01% of the analytical solution.
2. Using the PDE toolbox solve for the temperature distribution for the fin from Lab 3, Part 2,
but only for the case of k = 50 W/m•K. Include a figure of the PDE toolbox solution. Include a
figure plotting temperature at x = y = 0.01 m versus total number of elements for both the PDE
toolbox solution and FD method. For both methods obtain data for at least 4 different meshes.
Determine the number of elements required by both methods to get agreement within 0.01% of
the converged solution of 181.09 ˚C. NOTE: h for the fin sides in the x-y plane is different than
for the front and back faces in the z-dimension, where h = 0 for wide fins, as noted on page 1.
3. Using SolidWorks Simulation solve for the two-dimensional temperature distribution for the
fin from Lab 3, Part 2, again only for the case of k = 50 W/m•K, and with a Global mesh size of
5 mm. Verify that the temperature at x = y = 0.01 m is 181.1 ˚C using either a probe or by
exporting the data into MATLAB for post-processing.
Next, solve for the three-dimensional temperature distribution for a fin width of w = Ly = 0.20 m
in the z-direction. Use the same convection boundary condition from the two-dimensional case
for both ends (at z = 0 and z = w) as for the sides and tip. Once again, make sure to take
advantage of thermal symmetry for your simulation (HINT: your simulation fin width will be
w/2 in the z-direction with a convection boundary condition on one end and zero heat flux on the
other end for the thermal symmetry plane). Verify that the temperature at x = y = 0.01 m drops to
180.9 ˚C at the center (corresponding to the thermal symmetry plane) and 171.9 ˚C at the ends
due to 3D effects. Include figures of both the two and three-dimensional SolidWorks Simulation
solutions.
17
4. Using the PDE toolbox solve for the temperature distribution with variable thermal
conductivity (make sure to change your function for k to the polynomial fit given for steel in the
function k_SS) for the case given in Lab 3, Part 4. Include a figure of the PDE toolbox solution.
Include a figure plotting temperature at x = 0.5 m and y = 0.9 m versus total number of elements
for both the PDE toolbox solution and FD method. For both methods obtain data for at least 4
different meshes. Determine the number of elements required by both methods to get agreement
within 0.01% of the converged solution of 1299.3 K.
5. Using the PDE toolbox solve for the temperature distribution as a function of space and time
for the case given in Lab 3, Part 5. Include a figure of the PDE toolbox solution at time
t = 90,000 s (25 hours). Include a figure plotting temperature at x = 0.5 m and y = 0.9 m versus
total number of elements for both the PDE toolbox solution and FD method. For the PDE
toolbox solution use 10 time steps of 9,000 s. For the FD method, use a time step of 50 s (check
that this is a stable time step for your node spacing). Determine the number of elements required
by both methods to get agreement within 0.01% of the converged solution of 71.576 ˚C.
18
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement