• Non ci sono risultati.

Finite element method in 1D

N/A
N/A
Protected

Academic year: 2022

Condividi "Finite element method in 1D"

Copied!
15
0
0

Testo completo

(1)

Finite element method in 1D

Non homogeneous Dirichlet boundary conditions Neumann boundary conditions

Advection diffusion equation

Lucia Gastaldi

DICATAM - Sez. di Matematica, http://lucia-gastaldi.unibs.it

(2)

Outline

1 Non homogeneous Dirichlet boundary conditions

2 Neumann boundary conditions

3 Problemi ellittici completi

(3)

Non homogeneous Dirichlet boundary conditions

ProblemFind u such that

−µu00+ σu = f in ]a, b[ u(a) = α, u(b) = β Let us considerRg ∈ H1 such that Rg (a) = αandRg (b) = β (e.g. Rg (x ) = αb − x

b − a + βx − a

b − a) andu0 = u − Rg. Hence u0 ∈ H01(a, b) solves:

− µu000+ cu0 = −µu00+ cu + µRg00− cRg = f + µRg00+ cRg u0(a) = u0(b) = 0.

Weak formulation

Findu0∈ H01(a, b)such that

a(u, v ) = F (v ) − a(Rg , v ) ∀v ∈ H01(a, b),

where a(u, v ) = Z b

a

(µu0v0+ σuv ) dx , F (v ) = Z b

a

fv dx

(4)

Non homogeneous Dirichlet boundary conditions (in practice)

We considerRgh such thatRgh(a) = αandRgh(b) = β.

E.g.: Rgh(x ) = αϕa(x ) + βϕb(x )with ϕa andϕb basis functions associated to the end pointsa andb, respectively.

a(Rgh, ϕi) = αa(ϕa, ϕi) + βa(ϕb, ϕi) = B ~Rg . HereB ∈ Rndof ×2 with elements

Bij = µ Z b

a

ϕ0jϕ0idx + σ Z b

a

ϕjϕidx j = a, b e i = 1, . . . , ndof . We computeu0h∈ Vh as follows:

A ~u0= b − B ~Rg , u = ~~ u0+ ~Rg .

Notice that the vector−B ~Rg has only the first and the last components different from zero with values

−B ~Rg1= α(µ/h + hσ), −B ~Rgndof = β(µ/h + hσ).

page 3

(5)

Exercize 5

Consider the following differential equation

−u00+ 2u = 4exsin(x ) x ∈ (0, 2π) u(0) = 1, u(2π) = e.

I The function femP1is a simplified version of fem1dand computes the solution only with linear piecewise polynomials.

Modify the function femP1in order to take into account non homogeneous boundary conditions.

I Solve the differential equation by means of the modified functionfemP1 with N=[10 20 40 80 160 320].

I Compute the relative error in theL2-norm of the function and of its derivative using the function errore.

I Plot the error in a bilogarithmic scale.

(6)

Neumann boundary conditions

Let us consider the following differential equation

− µu00+ σu = f in [a, b]

u0(a) = α, u0(b) = β

We multiply the equation byv ∈ H1(a, b)and integrate on(a, b) Z b

a

(−µu00+ σu)vdx = [−µu0v ]ba+ Z b

a

(µu0v0+ σuv )dx

= −µu0(b)v (b) + µu0(a)v (a) + Z b

a

(µu0v0+ σuv )dx

= −µβv (b) + µαv (a) + Z b

a

(µu0v0+ σuv )dx = Z b

a

fvdx

Weak formulation

Findu ∈ H1(a, b) such that

a(u, v ) = F (v ) + µβv (b) − µαv (a) ∀v ∈ H1(a, b).

page 5

(7)

Discretizzazione con elementi finiti lineari

We subdivide[a, b]intoN intervals with sizeh = (b − a)/N Vh= {v ∈ H1(a, b) : v |Ii ∈ P1}

hence we haveN + 1basis functions ϕi including those associated to the end points. The matrix are:

K = 1 h

1 −1 . . . . . . . . . . . . 0

−1 2 −1 . . . . . . . . . 0 . . . . . . . . . . . . . . . . . . . . .

0 . . . −1 2 −1 . . . 0

. . . . . . . . . . . . . . . . . . . . . 0 . . . . . . . . . −1 2 −1 0 . . . . . . . . . . . . −1 1

M = h 6

2 1 . . . . . . . . . . . . 0 1 4 1 . . . . . . . . . 0 . . . . . . . . . . . . . . . . . . . . .

0 . . . 1 4 1 . . . 0

. . . . . . . . . . . . . . . . . . . . . 0 . . . . . . . . . 1 4 1 0 . . . . . . . . . . . . 1 2

(8)

I Ifσ > 0 we find the solution by solving the linear system (µK + σM)u = F.

I Ifσ = 0 the following compatinility condition is necessary for the solvability of the system

Z b a

fdx + µβ − µα = 0 and we compute a solution with zero mean value.

In practice we assign the value ofu in an internal node of the mesh and then we correct the mean value.

page 7

(9)

Esercizio 6

σ > 0

Si considerino le equazioni differenziali:

−u00(x ) + 2u(x ) = ex per x ∈ [0, 1]

u0(0) = 1, u0(1) = e u(x ) = ex.

−u00(x ) + u(x ) = −2 + 12x − 12x2+ x2(x − 1)2 per x ∈ [0, 1]

u0(0) = 0, u0(1) = 0 u(x ) = x2(x − 1)2.

Risolvere le equazioni date con i seguenti valori di N=[8 16 32 64 128 256 512]

usando la functionfemP1N.

Calcolare l’errore usando la functionerrore.nframe

(10)

Esercizio 7

σ = 0

Si considerino le equazioni differenziali:

−u00(x ) = −ex per x ∈ [0, 1]

u0(0) = 1, u0(1) = e u(x ) = ex − e + 1.

−u00(x ) = −2 + 12x − 12x2 per x ∈ [0, 1]

u0(0) = 0, u0(1) = 0 u(x ) = x2(x − 1)2− 1/30.

Risolvere le equazioni date con i seguenti valori di N=[8 16 32 64 128 256 512]

usando la functionfemP1N.

Calcolare l’errore usando la functionerrore.

page 9

(11)

Equazione di diffusione, trasporto e reazione

Equazione differenziale completa

− µu00+ βu0+ cu = f in (a, b) u(a) = ua, u(b) = ub

Problema debole

Trovareu ∈ H01(a, b) tale che Z b

a

(µu0v0+ βu0v + cuv ) dx = Z b

a

fv dx ∀v ∈ H01(a, b)

(12)

Costruzione delle matrici

Resta da calcolare la matrice associata al termine del primo ordine.

Suddiviso l’intervallo[a, b]in N parti uguali di ampiezza

h = (b − a)/N, la matrice non simmetrica associata al termine del primo ordine `e

B = 1 2

0 1 . . . 0

−1 0 1 . . . 0 . . . .

0 . . . −1 0 1 . . . 0 . . . .

0 . . . −1 0 1 0 . . . −1 0

page 11

(13)

Esercizio 8

Si consideri l’equazione differenziale

−u00+ 2u0 = f x ∈ (0, 1) u(0) = ua, u(1) = ub con i seguenti dati:

f1(x ) = 4 − 4x , ua = ub= 0

f2(x ) = −2(1 − x )2− 2x2+ 4 + 4x (1 − x )(3 − 2x ), ua= 0, ub= 2 f3(x ) = (4π2− 4π) sin(2πx) + (4π2+ 4π) cos(2πx ) ua= ub= 1 f4(x ) = ex(1 − x ) ua = 1, ub= 0

Risolvere l’equazione differenziale con elementi finiti lineari e quadratici usando la functionfem1d al variare diN=[10 20 40 80 160 320].

Calcolare l’errore relativo in normaL2 sia della funzione che della derivata usando la functionerrore.

Riportare opportunamente i risultati in scala bilogaritmica.

(14)

Soluzioni dell’esercizio 8

La soluzione esatta dell’equazione differenziale dell’esercizio 1 ha la seguente espressione analitica:

u1(x ) = x (1 − x ) u2(x ) = x2(1 − x )2+ 2x u3(x ) = sin(2πx ) + cos(2πx ) u4(x ) = ex(1 − x )

page 13

(15)

Problemi con trasporto dominante

Si consideri l’equazione differenziale:

−εu00(x ) + u0(x ) = 0 per x ∈ [0, 1]

u(0) = 0, u(1) = 1.

Risolvere l’equazione data con i seguenti valori diN=[10 20 40 80 160], mediante il metodo degli elementi finiti, per i seguenti valoriε = 1,ε = 0.1 e ε = 0.01.

Riferimenti

Documenti correlati

By means of the previous considerations it follows immediately that each input queue may be modeled as a discrete M/G/l queueing system with the service time

This paper seeks to add to the existing literature on water utility management by investigating whether the corporate go- vernance of water utilities (i.e. their ownership, board

Advanced models with different types of finite elements – which are most commonly used in real-life bridge engineering – are still analysed by these SFEM variants which are based on

BabyLux device: a diffuse optical system integrating diffuse correlation spectroscopy and time-resolved near-infrared spectroscopy for the neuromonitoring of the premature

Finally in the Chapter 5, a technique, based on a combination of the Mode Matching-Finite Element Method, Spectral Decomposition (MM-FEM-SD) and Method of Moments (MoM), to

The aim of this study was to assess the serological sta- tus of HAV among nursing students, which potentially could be exposed to HAV infection, and compliance of healthcare staff

The application of the postprocessing technique to get a posteriori error estimates for Navier–Stokes equations using the results obtained in this paper will be the subject of

The thermal and structural response of the three-layer fire door exposed to high temperature was modelled using finite element software and the accuracy of the model