FEM 2D Node Equations: Setting Up & Examples

  • Context: Undergrad 
  • Thread starter Thread starter bob012345
  • Start date Start date
  • Tags Tags
    2d Fem Method
Click For Summary

Discussion Overview

The discussion focuses on setting up node equations for a 2D finite element method (FEM) problem involving a heated plate with specified boundary conditions. Participants explore the transition from 1D to 2D formulations, including challenges in deriving element equations and the application of various mathematical principles.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant expresses difficulty in adapting 1D node equations for a 2D heated plate and seeks examples or guidance.
  • Another participant suggests using FreeFEM++ for 2D examples, indicating it may be helpful for the problem at hand.
  • A participant notes that there is no unique answer to the problem and emphasizes the importance of choosing a suitable finite element basis and grid type for the 2D problem.
  • Discussion includes the need to generalize the 1D equations to 2D by replacing the second derivative with the Laplacian operator and defining the 2D region.
  • One participant clarifies that the problem involves a simple 2D plate with specified temperatures at the edges and no additional heat sources, seeking to understand the FEM approach compared to a previous finite difference method.
  • Another participant proposes a method based on minimizing a Lagrangian, leading to the heat equation and discussing the representation of temperature as a sum of basis functions.
  • There is a mention of different types of elements, including triangular and quadrilateral, and their respective node configurations.
  • A participant references external resources, such as Schaum's outline on Finite Element Methods, for additional worked examples in 2D.

Areas of Agreement / Disagreement

Participants do not reach a consensus on a specific method for setting up the 2D node equations, and multiple competing views and approaches remain throughout the discussion.

Contextual Notes

Limitations include the need for clarity on the choice of finite element basis functions and grid types, as well as the specific mathematical steps required to transition from 1D to 2D formulations.

bob012345
Gold Member
Messages
2,323
Reaction score
1,041
TL;DR
I wish to set up the node equations for a 2D heated plate with boundary conditions.
I wish to set up the node equations for a 2D heated plate with boundary conditions. I understand how to do this in 1D but have not found a suitable example problem worked out in 2D and examples I have seen are very involved and complex. @pasmith showed me you to set up the 1D problem as follows;

##N_i## are test functions with T approximated by ##T_1N_1(x) + T_2N_2(x)##. If so, then ##\frac{d^2T}{dx^2} + kT(x) = -f(x)##where ##f(x)## is a known source term gives ;
$$\begin{multline}
\int_{x_1}^{x_2} N_i(x)\frac{d^2T}{dx^2} + kN_i(x)T(x) + N_i(x)f(x)\,dx \\=
\left[ N_i(x)\frac{dT}{dx}\right]_{x_1}^{x_2}
+\int_{x_1}^{x_2} -\frac{dN_i}{dx}\frac{dT}{dx} + kN_i(x)T(x) + N_i(x)f(x)\,dx
\end{multline}$$which results in ;
$$\begin{multline}
\begin{pmatrix}
\int_{x_1}^{x_2} \left(\frac{dN_1}{dx}\right)^2\,dx & \int_{x_1}^{x_2} \frac{dN_1}{dx}\frac{dN_2}{dx} \,dx \\
\int_{x_1}^{x_2} \frac{dN_1}{dx}\frac{dN_2}{dx} \,dx & \int_{x_1}^{x_2} \left(\frac{dN_2}{dx}\right)^2\,dx
\end{pmatrix}
\begin{pmatrix} T_1 \\ T_2 \end{pmatrix} \\
- k\begin{pmatrix} \int_{x_1}^{x_2} N_1^2(x)\,dx & \int_{x_1}^{x_2} N_1(x)N_2(x)\,dx \\
\int_{x_1}^{x_2} N_1(x)N_2(x)\,dx & \int_{x_1}^{x_2} N_2^2(x)\,dx \end{pmatrix}
\begin{pmatrix} T_1 \\ T_2 \end{pmatrix} \\
=
\begin{pmatrix}
N_1(x_2) \frac{dT}{dx}(x_2) - N_1(x_1) \frac{dT}{dx}(x_1) \\
N_2(x_2) \frac{dT}{dx}(x_2) - N_2(x_1) \frac{dT}{dx}(x_1) \end{pmatrix} +
\begin{pmatrix}
\int_{x_1}^{x_2} N_1(x)f(x)\,dx \\
\int_{x_1}^{x_2} N_2(x)f(x)\,dx
\end{pmatrix}.\end{multline}$$

I wish to amend this for a 2D problem. My book starts with an element equation ##u(x, y) = a_0 + a_{1,1}x + a_{1,2} y## and test functions like this ##N_1 = 1/ 2Ae [(x_2 y_3 − x_3 y_2) + (y_2 − y_3)x + (x_3 − x_2)y]## but I can't seem to put things together.
 
Last edited:
Physics news on Phys.org
Have you looked at FreeFEM++ ? The docs may give useful 2D examples and the software itself is quite nice for 2D problems.
 
  • Like
Likes   Reactions: bob012345
Paul Colby said:
Have you looked at FreeFEM++ ? The docs may give useful 2D examples and the software itself is quite nice for 2D problems.
Thanks. Looks like that will be useful but I still need help figuring the element equations for my simple 2D case so I can work out a limited example by hand for teaching purposes. Basically this thing in two dimensions;
$$\begin{multline}
\int_{x_1}^{x_2} N_i(x)\frac{d^2T}{dx^2} + N_i(x)f(x)\,dx \\=
\left[ N_i(x)\frac{dT}{dx}\right]_{x_1}^{x_2}
+\int_{x_1}^{x_2} -\frac{dN_i}{dx}\frac{dT}{dx} + N_i(x)f(x)\,dx
\end{multline}$$
 
There is no unique answer to your question. But first I would write the integral on the left as integral over the 2D domain. This will contain a ##\nabla^2 T## term. Integration by parts, see Green’s theorem, will leave you with a line integral over the boundary plus a ##\nabla N\cdot \nabla T## term. Both sides of the equation are zero. This means the boundary line integral which involves your boundary condition will become the drive vector of the ensuing matrix equation while the area integral becomes the system matrix times the vector of unknowns.

So, one must chose a 2D finite element basis for the ##N_i## and the ##T_i##. Now I notice while typing that your setting the problem up as a weak form of the heat equation. Typically people start by writing a Lagrangian form and then apply the galarkin (sp) approach.

[second thoughts] okay, the ##f(x)## term is the source or drive term in your heat flow problem. I think the line integral may vanish but I can’t tell just by staring at it.
 
Last edited:
  • Like
Likes   Reactions: bob012345
Thanks, By not unique I assume you mean what hat functions and what kind of grid I choose, triangle ect. I really should have said I was starting with this;

$$\begin{multline}
\begin{pmatrix}
\int_{x_1}^{x_2} \left(\frac{dN_1}{dx}\right)^2\,dx & \int_{x_1}^{x_2} \frac{dN_1}{dx}\frac{dN_2}{dx} \,dx \\
\int_{x_1}^{x_2} \frac{dN_1}{dx}\frac{dN_2}{dx} \,dx & \int_{x_1}^{x_2} \left(\frac{dN_2}{dx}\right)^2\,dx
\end{pmatrix}
\begin{pmatrix} T_1 \\ T_2 \end{pmatrix} \\

=
\begin{pmatrix}
N_1(x_2) \frac{dT}{dx}(x_2) - N_1(x_1) \frac{dT}{dx}(x_1) \\
N_2(x_2) \frac{dT}{dx}(x_2) - N_2(x_1) \frac{dT}{dx}(x_1) \end{pmatrix} +
\begin{pmatrix}
\int_{x_1}^{x_2} N_1(x)f(x)\,dx \\
\int_{x_1}^{x_2} N_2(x)f(x)\,dx
\end{pmatrix}.\end{multline}$$
 
This is the one dimensional problem. The surface terms ##\frac{dT}{dx}## are the heat flow at the boundary points. These are determined by the physical properties of the problem what ever that may be.

Generalization to 2 dimensions means replacing ##\frac{dT^2}{d^2x}## with ##\nabla^2T## and defining the 2D region etc. What is your problem statement?

l might add that you are subdivided the problem into just two finite elements. In general people will use more. Also you must choose the form of your 2D elements.
 
Paul Colby said:
This is the one dimensional problem. The surface terms ##\frac{dT}{dx}## are the heat flow at the boundary points. These are determined by the physical properties of the problem what ever that may be.

Generalization to 2 dimensions means replacing ##\frac{dT^2}{d^2x}## with ##\nabla^2T## and defining the 2D region etc. What is your problem statement?

l might add that you are subdivided the problem into just two finite elements. In general people will use more. Also you must choose the form of your 2D elements.
The problem I am trying to develop as an example is a simple 2D plate with one edge 100C, opposite edge 0C, then the other edges 75C and 50C. No other heat source. I am looking at the equilibrium situation. I did it with the student using finite difference but now the student wants to see it done with the FEM. We previously did a 1D rod using FEM. The equations I showed above were the element equations for the 1D rod element with two nodes. We used 5 elements and thus assembled a stiffness matrix. I was just showing that as a reference meaning I am looking for a 2D analog. I assume if it a triangular element it will have three nodes? Thanks.
 
Okay, let's try an approach based on minimizing a Lagrangian.

##L = \int_{x_1=0}^{x^2=1}\int_{y_1=0}^{y_2=1} \left[(\frac{\partial T}{\partial x})^2+(\frac{\partial T}{\partial y})^2\right]dxdy##

Variation of this functional yields the heat equation,

##\nabla^2 T = 0##

which is the equation you wish to solve subject to fixed temperatures on the boundary. We introduce a square grid of points or nodes on the unit square. We represent ##T##, our solution, as a sum of basis functions where each basis element is zero on all nodes but one where it is one,

## T(x,y) = \sum_k c_kN_k(x,y) + \sum_m d_m N_m(x,y)##

Clearly all we need to do is find the temperature at the interior nodes points. The temperature at all the other points are interpolated by our basis. The basis element at node, ##k=(i,j)##, is one and ramps down linearly to zero at ##(i+1,j), (i-1,j), (i,j+1), (i,j-1)##. I've split the above basis expansion into a sum over nodes interior to the region, ##c_k## which are our unknowns, and those on the boundary, ##d_m##, which are known.

If you plug ##T(x,y)## into ##L## and integrate you get a quadratic form in the ##c_k## and ##d_m##. The coefficients of this form are integrals over overlapping basis elements. Variation with respect to the ##c_k## will yield the matrix equation,

##A_{k'k}c_k = B_{k'm}d_m##

which one solves for the ##c_k##.
 
  • Like
Likes   Reactions: bob012345
bob012345 said:
I assume if it a triangular element it will have three nodes? Thanks.
Well, here you have many possibilities. The elements I use in the previous post have 4 corner nodes and one central node (a pyramid). The reason for this choice is simplicity of the mesh or grid. Your problem domain is rectangular which make this choice very simple.
 
  • Like
Likes   Reactions: bob012345
  • #10
Schaum's outline on Finite Element Methods has some worked out 2D problems. I think it is a good starting point when writing a simple 2D FEM:
https://www.amazon.com/dp/0070087148/?tag=pfamazon01-20
There's also 'FEM in 50 lines of matlab' : https://www.math.hu-berlin.de/~cc/cc_homepage/download/1999-AJ_CC_FS-50_Lines_of_Matlab.pdf
and the online programming examples database of John Burkhardt:
https://people.sc.fsu.edu/~jburkardt/
Check for instance the matlab, python, c++ or fortran section and in the alphabetical list go to FEM2Dxxxx.
 
  • Like
Likes   Reactions: bob012345

Similar threads

  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
1K
  • · Replies 3 ·
Replies
3
Views
2K