Jump to content

Finite elements/Solution of heat equation

From Wikiversity

Finite element solution for the Heat equation

[edit | edit source]

Let us now try to create a finite element approximation for the variational initial boundary value problem for the heat equation . This problem can be stated as

𝖵𝖺𝗋𝗂𝖺𝗍𝗂𝗈𝗇𝖺𝗅 𝖨𝖡𝖵𝖯 𝖿𝗈𝗋 𝗍𝗁𝖾 𝖧𝖾𝖺𝗍 𝖤𝗊𝗎𝖺𝗍𝗂𝗈𝗇Find a function T(t)∈𝒮t,t∈[0,τ] such that for all w∈𝒱∫Ω(ρ Cv ∂T∂t) w dV+∫Ω(𝜵w)∙(𝜿∙𝜵T) dV=∫Ωs w dV−∫Γqw q‾ dA∫Ωw ρ Cv T(0) dV=∫Ωw ρ Cv T0 dV .

Let 𝒱h be a finite dimensional approximation to 𝒱 and let 𝒮h be a finite dimensional approximation to 𝒮. Let the weighting functions wh∈𝒱h be such that wh=0 on ΓT. Similarly, any other function vh∈𝒱h also goes to zero on the boundary ΓT.

Assume that the trial solutions Th∈𝒮h can be represented as

Th=vh+T‾h     where vh∈𝒱h .

The additional quantity T‾h results in the satisfaction of the boundary condition T=T‾ on ΓT.

If we substitute these quantities into the variational initial boundary value problem, we get the Galerkin formulation. The steps in this process are shown below.

Approximate IBVP

[edit | edit source]

The approximate form of the variational IBVP is

∫Ω(ρ Cv ∂Th∂t) wh dV+∫Ω(𝜵wh)∙(𝜿∙𝜵Th) dV=∫Ωs wh dV−∫Γqwh q‾ dA .

Replacing Th with (vh+T‾h) we get

∫Ω(ρ Cv ∂(vh+T‾h)∂t) wh dV+∫Ω(𝜵wh)∙(𝜿∙𝜵(vh+T‾h)) dV=∫Ωs wh dV−∫Γqwh q‾ dA .

After expanding and rearranging terms, we get

∫Ωwh ρ Cv ∂vh∂t dV+∫Ω(𝜵wh)∙(𝜿∙𝜵vh) dV=∫Ωwh s dV−∫Γqwh q‾ dA−∫Ωwh ρ Cv ∂T‾h∂t dV−∫Ω(𝜵wh)∙(𝜿∙𝜵T‾h) dV .

In compact notation

⟨wh, ρ Cv v˙⟩h+a(wh, vh)=⟨wh, s⟩−⟨wh, q‾⟩Γ−⟨wh, ρ Cv T‾˙⟩h−a(wh, T‾h) .

Similarly, the initial condition can be written as

∫Ωwh ρ Cv Th(0) dV=∫Ωwh ρ Cv T0 dV .

Substituting for Th and expanding out terms, we have

∫Ωwh ρ Cv vh(0) dV=∫Ωwh ρ Cv T0 dV−∫Ωwh ρ Cv T‾h(0) dV .

In compact form,

⟨wh, ρ Cv vh(0)⟩=⟨wh, ρ Cv T0⟩−⟨wh, ρ Cv T‾h(0)⟩ .

Therefore the approximate form of the variational BVP can be written as

(40)𝖠𝗉𝗉𝗋𝗈𝗑𝗂𝗆𝖺𝗍𝖾 𝖵𝖺𝗋𝗂𝖺𝗍𝗂𝗈𝗇𝖺𝗅 𝖨𝖡𝖵𝖯 𝖿𝗈𝗋 𝗍𝗁𝖾 𝖧𝖾𝖺𝗍 𝖤𝗊𝗎𝖺𝗍𝗂𝗈𝗇Find a function Th(t)=vh+T‾h∈𝒮h,t∈[0,τ] such that for all wh∈𝒱h∫Ωwh ρ Cv ∂vh∂t dV+∫Ω(𝜵wh)∙(𝜿∙𝜵vh) dV=∫Ωwh s dV−∫Γqwh q‾ dA−∫Ωwh ρ Cv ∂T‾h∂t dV−∫Ω(𝜵wh)∙(𝜿∙𝜵T‾h) dV .∫Ωwh ρ Cv vh(0) dV=∫Ωwh ρ Cv T0 dV−∫Ωwh ρ Cv T‾h(0) dV .

Note that the derivatives with respect to time are still continuous in this approximate variational BVP.

Finite element approximation

[edit | edit source]

We now discretize our domain into elements Ωe where 1<e<E and E is the total number of elements. Nodes may exist anywhere within the element domains. But the most common locations are at the element vertices and along the interelement boundaries.

Let the set of global node numbers be

η={1,2,…,N} .

Let the set nodes at which a temperature (essential BC) is prescribed be

ηT⊂η .

Then the set of nodes at which a temperature is to be determined is the complement

η−ηT .

Let n be the number of nodes in η−ηT. Then the number of equations to be solved is also n. See Figure 1 to get an idea about what these sets of nodes refer to.

Figure 1. FEM discretization for the heat conduction problem.

As we have seen before, a typical weighting function wh∈𝒱h is assumed to have the form

(42)wh(𝐱)=∑i=1nbiNi(𝐱)≡∑i∈η−ηTbiNi(𝐱) .

Note that wh=0 only if bi=0 for every i∈η−ηT. On the other hand wh=0 for every node in ηT.

Similarly, a typical trial solution vh∈𝒱h can be written as

(43)vh(𝐱,t)=∑i∈η−ηTTi(t)Ni(𝐱)

where Ti(t) is the unknown temperature at node i at time t.

We also often represent the approximate form of the essential BCs in a similar way, i.e.,

(44)T‾h(𝐱,t)=∑i∈ηTT‾i(t)Ni(𝐱),T‾i(t)=T‾(𝐱i,t) .

Substitute equations (42), (43), and (44) into the first of equations (40). You will get

∫Ω(∑jbjNj) ρ Cv (∑i∂Ti∂tNi) dV+∫Ω(∑jbj𝜵Nj)∙[∑iTi(𝜿∙𝜵Ni)] dV=∫Ω(∑jbjNj) s dV−∫Γq(∑jbjNj) q‾ dA−∫Ω(∑jbjNj) ρ Cv (∑k∂T‾k∂tNk) dV−∫Ω(∑jbj𝜵Nj)∙[∑kT‾k(𝜿∙𝜵Nk)] dV,i,j∈η−ηT,k∈ηT .

Assuming that Ω does not change with time, we can take the constants and time-dependent parameters outside the integrals to get

∑jbj[∑i∂Ti∂t(∫Ωρ Cv Ni Nj dV)+∑iTi(∫Ω𝜵Nj∙(𝜿∙𝜵Ni) dV)]=∑jbj[∫ΩNj s dV−∫ΓqNj q‾ dA−∑k∂T‾k∂t(∫Ωρ Cv Nj Nk dV)−∑kT‾k(∫Ω𝜵Nj∙(𝜿∙𝜵Nk) dV)],i,j∈η−ηT,k∈ηT .

Using the usual argument about the arbitrary nature of bj, we get

∑i∂Ti∂t(∫Ωρ Cv Ni Nj dV)+∑iTi(∫Ω𝜵Nj∙(𝜿∙𝜵Ni) dV)=∫ΩNj s dV−∫ΓqNj q‾ dA−∑k∂T‾k∂t(∫Ωρ Cv Nj Nk dV)−∑kT‾k(∫Ω𝜵Nj∙(𝜿∙𝜵Nk) dV),i,j∈η−ηT,k∈ηT .

In compact notation,

∑i⟨Nj, ρCvNi⟩ Ti˙+∑ia(Nj,Ni) Ti=⟨Nj, s⟩−⟨Nj, q‾⟩Γ−∑k⟨Nj, ρCvNk⟩ T‾˙k−∑ka(Nj,Nk) T‾k

where i,j∈η−ηT, and k∈ηT.

Let us rename parts of the above equation as follows:

Mij:=⟨Ni, ρCvNj⟩Kij:=a(Ni,Nj)fj:=⟨Nj, s⟩−⟨Nj, q‾⟩Γ−∑k⟨Nj, ρCvNk⟩ T‾˙k−∑ka(Nj,Nk) T‾k .

Then we get

∑iMji Ti˙+∑iKji Ti=fj .

In matrix form,

(45)𝐌 𝐓˙+𝐊 𝐓=𝐟 .

As before, we can break up the global matrices into sums over elements. Thus,

𝐌=∑e=1E𝐌e𝐊=∑e=1E𝐊e𝐟=∑e=1E𝐟e

where

Mije=∫Ωeρ Cv Ni Nj dV ,Kije=∫Ωe𝜵Ni∙(𝜿∙𝜵Nj) dV≡∫Ωe𝐁iT 𝐃 𝐁j dV ,fje=∫ΩeNj s dV−∫ΓqeNj q‾ dA−∑k=1ne[MjkeT‾˙k−KjkeT‾k]

and ne is the number of nodes in an element.

We can do the same for the initial conditions. However, a more common approach is to specify the values of 𝐓0 directly at the nodes instead of going through an assembly process.

Computing M, K, f

[edit | edit source]

The finite element system of equations at time t:

Mije=∫Ωeρ Cv Ni Nj dV ,Kije=∫Ωe𝜵Ni∙(𝜿∙𝜵Nj) dV≡∫Ωe𝐁iT 𝐃 𝐁j dV ,fje=∫ΩeNj s dV−∫ΓqeNj q‾ dA−∑k=1ne[MjkeT‾˙k−KjkeT‾k]

Isoparametric Map

[edit | edit source]
Isoparametric map.

Coordinate Transformation

[edit | edit source]
x=x1e N1e(ξ,η)+x2e N2e(ξ,η)+x3e N3e(ξ,η)+x4e N4e(ξ,η)y=y1e N1e(ξ,η)+y2e N2e(ξ,η)+y3e N3e(ξ,η)+y4e N4e(ξ,η)

Integrating Stiffness Matrix

[edit | edit source]

Stiffness matrix terms:

Kije=∫Ωe𝜵Ni∙(𝜿∙𝜵Nj) dV

Index notation:

Kije=∫ΩeNi,m κmn Nj,n dV

Expanded out (in 2D) (assume κ12=0):

Kije=∫Ωe(∂Ni∂xκ11∂Nj∂y+∂Ni∂xκ22∂Nj∂y) dx dy

Transformation

[edit | edit source]

Chain Rule:

∂Ni∂ξ=∂Ni∂x∂x∂ξ+∂Ni∂y∂y∂ξ∂Ni∂η=∂Ni∂x∂x∂η+∂Ni∂y∂y∂η

Matrix notation:

[∂Ni∂ξ∂Ni∂η]=[∂x∂ξ∂y∂ξ∂x∂η∂y∂η][∂Ni∂x∂Ni∂y]=𝐉e[∂Ni∂x∂Ni∂y]

Inverse Transformation

[edit | edit source]
[∂Ni∂x∂Ni∂y]=(𝐉e)−1[∂Ni∂ξ∂Ni∂η] ;  𝐉∗=(𝐉e)−1 exists if det⁡(𝐉e)≠0 .

with

∂x∂ξ=x1e ∂N1e∂ξ+x2e ∂N2e∂ξ+x3e ∂N3e∂ξ+x4e ∂N4e∂ξ∂y∂ξ=y1e ∂N1e∂ξ+y2e ∂N2e∂ξ+y3e ∂N3e∂ξ+y4e ∂N4e∂ξ∂x∂η=x1e ∂N1e∂η+x2e ∂N2e∂η+x3e ∂N3e∂η+x4e ∂N4e∂η∂y∂η=y1e ∂N1e∂η+y2e ∂N2e∂η+y3e ∂N3e∂η+y4e ∂N4e∂η

Returning to the integration of the stiffness matrix terms:

Kije=∫Ωe(∂Ni∂xκ11∂Nj∂y+∂Ni∂xκ22∂Nj∂y) dx dy

In parent element coordinates:

Kije=∫−11(κ11(J11∗∂Ni∂ξ+J12∗∂Ni∂η)+(J11∗∂Nj∂ξ+J12∗∂Nj∂η)+κ22(J21∗∂Ni∂ξ+J22∗∂Ni∂η)+(J21∗∂Nj∂ξ+J22∗∂Nj∂η)) dξ dη

Gaussian Quadrature

[edit | edit source]
∫−11Fij(ξ,η) dξ dη=∑I=1M∑J=1NFIJ(ξI,ηJ) WI WJ

Gaussian Quadrature Example

[edit | edit source]

Find the constants Co, C1, and X so that the quadrature formula

∫01f(x)dx=Cof(0)+C1f(x1).

This has the highest possible degree of precision.

Solution.

Since there are three unknowns, Co, C1 and X1, we will expect the formula to be exact for

f(x)=1,x,and x2

Thus

f(x)=1, ∫01f(x)dx=1=C0+C1  Equation1,f(x)=x, ∫01f(x)dx=12=C1x1  Equation2.f(x)=x2, ∫01f(x)dx=13=C1x12.

Equation 2 and 3 will yield.

c1x1c1x12=x1=23.c1=34.c0=14.

Hence

∫01f(x)dx=14f(0)+34f(23)

Now,

f(x)=x3.∫01x3dx=14

And

14(0)3+34(23)3=29.

Thus the degree of the precision is 2

Robin boundary conditions

[edit | edit source]

A similar approach can be used when w:Robin boundary conditions are needed to be applied. Let us assume that the Robin boundary conditions take the form

α T+β (𝜵T⋅𝐧)=hon Γ .

Recall from the previous section that the boundary term in the weak form of the heat equation is

∫Γw q‾ dA

where

q‾=(𝜿⋅𝜵T)⋅𝐧 ..

Let us assume, for simplicity, that the material is isotropic. In that case 𝜿 becomes a scalar quantity κ and we can write

q‾=κ (𝜵T⋅𝐧) .

Now, we can write the Robin boundary condition as

𝜵T⋅𝐧=hβ−αβ T≡ĥ−α̂ Ton Γ .

Using this expression we can get of the flux term in q‾ to get

q‾=κ (ĥ−α̂ T) .

Then the boundary term takes the form

∫Γw q‾ dA=∫Γw κ (ĥ−α̂ T) dA .

If we ignore the contributions to the trial function from the Dirichlet boundary conditions we can write

wh(𝐱)=∑j=1nbjNj(𝐱) ;  Th=vh(𝐱,t)=∑i=1nTi(t)Ni(𝐱)

Plugging these expressions into the boundary term leads to

∑jbj∫ΓNj q‾ dA=∑jbj∫ΓNj κ (ĥ−α̂ ∑iTiNi) dA=∑jbj(∫Γκ ĥ Nj dA−∑iTi ∫Γκ α̂ Ni Nj dA)

Now recall that spatially discretized equation for transient heat conduction can be expressed as (in simplified form; after getting rid of contributions due to Dirichlet boundary conditions and with a scalar κ)

∑jbj[∑i∂Ti∂t(∫Ωρ Cv Ni Nj dV)+∑iκ Ti(∫Ω𝜵Nj∙𝜵Ni dV)]=∑jbj[∫ΩNj s dV−∫ΓNj q‾ dA]

Substituting the last term on the right hand side with the new expression for the boundary term, we have

∑jbj[∑i∂Ti∂t(∫Ωρ Cv Ni Nj dV)+∑iκ Ti(∫Ω𝜵Nj∙𝜵Ni dV)]=∑jbj[∫ΩNj s dV−κ ∫Γĥ Nj dA+∑iκ Ti ∫Γα̂ Ni Nj dA]

Invoking the arbitrariness of bj and rearranging, we get

∑i∂Ti∂t(∫Ωρ Cv Ni Nj dV)+∑iκ Ti(∫Ω𝜵Nj∙𝜵Ni dV−∫Γα̂ Ni Nj dA)=∫Ωs Nj dV−∫Γκ ĥ Nj dA .

Define

Mji:=∫Ωρ Cv Nj Ni dVKji:=∫Ω𝜵Nj∙𝜵Ni dV−∫Γα̂ Nj Ni dAfj:=∫Ωs Nj dV−∫Γκ ĥ Nj dA .

Then the finite element system of equations is

∑iMji T˙i+∑iKji Ti=fj .

or, in matrix form

𝐌 𝐓˙+𝐊 𝐓=𝐟 .

Note that the 𝐊 matrix and the 𝐟 vector are different from the case where there are no Robin boundary conditions. The boundary terms in the discretized system of equations can be computed in the usual manner and will add terms to the diagonal of the 𝐊 matrix.