Entries for December 2017
-
Nonlinear Finite Elements
This post builds on the formulations I showed in my previous posts by introducing their nonlinear versions.
In a typical nonlinear problem, the variational setting leads to the weak formulation
Find u∈V such that
F(u,v)=0(1)for all v∈V where the semilinear form F is nonlinear in terms of u and linear in terms of v.
We linearize F:
Lin[F(u,v)]u=uˉ=F(uˉ,v)+DuF(u,v)⋅Δuu=uˉ(2)Equating (2) to zero yields a linear system in terms of Δu
a(Δu,v)=b(v)(3)where
a(Δu,v)b(v)=DuF(u,v)⋅Δuu=uˉ=−F(uˉ,v).(4)We can compute the components of the matrices and vectors according to (3)
AIJbI=a(NJ,NI)=b(NI)=DuF(u,NI)⋅NJu=uˉ=−F(uˉ,NI).(5)Then the update vector Δu=[Δu1,Δu2,…,Δunn]T is obtained by solving
AΔu=b(6)Letting Δu be the difference between consequent iterates, we obtain the update equation as
u←uˉ+Δu(7)Example: Nonlinear Poisson’s Equation
Consider the following nonlinear Poisson’s equation
−∇⋅(g(u)∇u)u=f=0inonΩ∂Ω(8)The weak formulation reads
Find u∈V such that
−∫Ω∇⋅(g(u)∇u)vdv=∫Ωfvdv(9)for all v∈V where V=H01(Ω).
Applying integration by parts and divergence theorem on the left-hand side
∫Ω∇⋅(g(u)∇u)vdv=∫Ω∇⋅(g(u)∇(u)v)dv−∫Ωg(u)∇u⋅∇vdv=v=0 on ∂Ω∫∂Ωg(u)v(∇u⋅n)da−∫Ωg(u)∇u⋅∇vdv(10)Thus we have the semilinear form
F(u,v)=∫Ωg(u)∇u⋅∇vdv−∫Ωfvdv=0(11)The linearized version of this problem is then with (4)
a(Δu,v)b(v)=∫Ω(dudguˉΔu∇uˉ+g(uˉ)∇(Δu))⋅∇vdv=∫Ω[fv−g(uˉ)∇uˉ⋅∇v]dv(12)and the matrix and vector components are with (5)
AIJbI=∫Ω(dudguˉNJ∇uˉ+g(uˉ)BJ)⋅BIdv=∫Ω[fNI−g(uˉ)∇uˉ⋅BI]dv(13)where the previous solution and its gradient are computed as
uˉ=I=1∑nnuˉINIand∇uˉ=I=1∑nnuˉIBI.(14)Nonlinear Time-Dependent Problems
In the case of a nonlinear time-dependent problem, we have the following weak form:
Find u∈V such that
m(u˙,v;t)+F(u,v;t)=0(15)for all v∈V and t∈[0,∞) where F is a semilinear form.
Discretization yields the following nonlinear system of equations
M(t)u+f(u;t)=0(16)where
MIJ(t)fI(u;t)=m(NJ,NI;t)=F(u,NI;t).(17)Explicit Euler Scheme
We discretize in time with the finite difference u˙≈[un+1−un]/Δt and linearity allows us to write
\begin{equation} \boxed{ m(\dot{u}, v; t) \approx \frac{1}{\Delta t} [m(u_{n+1}, v; t_{n+1}) - m(u_n, v; t_n)] } \label{eq:discretetimedependent1} \end{equation}
We discretize the variational forms in time according to \eqref{eq:discretetimedependent1}, and evaluate the remaining terms at tn:
Δt1[m(un+1,v;tn+1)−m(un,v;tn)]+F(un,v;tn)=0(18)The corresponding system of equations is
Δt1[Mn+1un+1−Mnun]+fn=0(19)where fn=f(un,tn). This yields the following update equation
un+1=Mn+1−1[Mnun−Δtfn](20)For a time-independent m, this becomes
un+1=un−ΔtM−1fn(21)Implicit Euler Scheme
For the implicit scheme, we evaluate the remaining terms at tn+1 and let the result be equal to
G(un+1,v):=Δt1[m(un+1,v;tn+1)−m(un,v;tn)]+F(un+1,v;tn+1)=0(22)We will hereon replace un+1 with u for brevity. The update of this nonlinear system requires the linearization of G(u,v):
Lin[G(u,v)]u=uˉ=G(uˉ,v)+DuG⋅Δuu=uˉ=0(23)We thus have the following linear setting for the Newton update Δu:
a(Δu,v)=b(v)(24)where
a(Δu,v)b(v):=DuG⋅Δuu=uˉ=Δt1m(Δu,v;tn+1)+DuF(u,v;tn+1)⋅Δuu=uˉ:=−G(uˉ,v)=−F(uˉ,v;tn+1)−Δt1[m(uˉ,v;tn+1)−m(un,v;tn)](25)Discretization yields
(Δt1Mn+1+A~)Δu=b(26)where
A~IJ:=DuF(u,NI;tn+1)⋅NJu=uˉandbI:=b(NI)(27)The Newton update is rendered
u←uˉ+ΔuandΔu=[Δt1Mn+1+A~]−1b(28)which is repeated until the solution for the next timestep u converges to a satisfactory value.
Nonlinear Coupled Problems
For a nonlinear coupled problem, the weak formulation is as follows
Find u∈V1, y∈V2 such that
F(u,y,v)G(u,y,w)=0=0(29)for all v∈V1, w∈V2 where F(⋅,⋅,⋅), G(⋅,⋅,⋅) are nonlinear in terms of u and y and linear in terms of v and w.
We linearize the semilinear forms about the nonlinear terms:
Lin[F(u,y,v)]uˉ,yˉLin[G(u,y,w)]uˉ,yˉ=F(uˉ,yˉ,v)=G(uˉ,yˉ,w)+DuF(u,y,v)⋅Δuuˉ,yˉ+DuG(u,y,w)⋅Δuuˉ,yˉ+DyF(u,y,v)⋅Δyuˉ,yˉ+DyG(u,y,w)⋅Δyuˉ,yˉ(30)where the evaluations take place at u=uˉ and y=yˉ.
Equating the linearized residuals to zero, we obtain a linear system of the form
a(u,v)d(u,w)+b(y,v)+e(y,w)=c(v)=f(w)(31)with the bilinear forms a, b, d, e and the linear forms c, f which are defined as
a(Δu,v)d(Δu,w):=DuF(u,y,v)⋅Δuuˉ,yˉ:=DuG(u,y,w)⋅Δuuˉ,yˉb(Δy,v)e(Δy,w):=DyF(u,y,v)⋅Δyuˉ,yˉ:=DyG(u,y,w)⋅Δyuˉ,yˉandc(v)f(w):=−F(uˉ,yˉ,v):=−G(uˉ,yˉ,w)(32)Discretizing as done in the previous section, we obtain the following linear system of equations
[ADBE][ΔuΔy]=[cf](33)whose solution yields the update values Δu and Δy. Thus the Newton update equations are
uy←uˉ←yˉ+Δu+Δy.(34)Example: Cahn-Hilliard Equation
The Cahn-Hilliard equation describes the process of phase separation, by which the two components of a binary fluid spontaneously separate and form domains pure in each component. The problem is nonlinear, coupled and time-dependent. The IBVP reads
∂t∂c∇c⋅n∇μ⋅ncμ=∇⋅(M∇μ)=0=0=c0=0inononininΩ×I∂Ω×I∂Ω×IΩ,t=0Ω,t=0(35)where
μ=dcdf−∇⋅(Λ∇c)(36)and t∈I=[0,∞). Here,
- c is the scalar variable for concentration,
- μ is the scalar variable for the chemical potential,
- f:c↦f(c) is the function representing chemical free energy,
- M is a second-order tensor describing the mobility of the chemical,
- Λ is a second-order tensor describing both the interface thickness and direction of phase transition.
The fourth-order PDE governing the problem can be formulated as a coupled system of two second-order PDEs with the variables c and μ, as demonstrated in (35) and (36).
The weak formulation then reads
Find c∈V1, μ∈V2 such that
∫Ω∂t∂cvdx−∫Ω∇⋅(M∇μ)vdx∫Ω[μ−dcdf]wdx+∫Ω∇⋅(Λ∇c)wdx=0=0(37)for all v∈V1, w∈V2 and t∈I.
We discretize in time implicitly with ∂c/∂t≈(cn+1−cn)/Δt. We also denote the values for the next timestep cn+1 and μn+1 as c and μ for brevity. Using integration-by-parts, the divergence theorem, and the given boundary conditions, we arrive at the following nonlinear forms
F(c,μ,v)G(c,μ,w)=∫ΩΔt1(c−cn)vdx+∫Ω(M∇μ)⋅∇vdx=∫Ω[μ−dcdf]wdx−∫Ω(Λ∇c)⋅∇wdx=0=0(38)which is a nonlinear coupled system of the form (29).
We linearize the forms according to (30) and obtain the following variations
DcF⋅ΔcDμF⋅ΔμDcG⋅ΔcDμG⋅Δμ=∫ΩΔt1Δcvdx=∫Ω(M∇(Δμ))⋅∇vdx=−∫Ωdc2d2fΔcwdx−∫Ω(Λ∇(Δc))⋅∇wdx=∫ΩΔμwdxWe substitute basis functions and obtain our system matrix and vectors
PIJQILrISKJTKLuK=∫ΩΔt1NJNIdx=∫Ω(MBL)⋅BIdx=∫ΩΔt1(cˉ−cn)NIdx+∫Ω(M∇μˉ)⋅BIdx=−∫Ωdc2d2fc=cˉNJNKdx−∫Ω(ΛBJ)⋅BKdx=∫ΩNLNKdx=∫Ω[μˉ−dcdfc=cˉ]NKdx−∫Ω(Λ∇cˉ)⋅BKdxwhich constitute the system
[PSQT][ΔcΔμ]=[ru](39)Solution yields the update values Δc and Δμ. The Newton update equations are then
cμ←cˉ←μˉ+Δc+Δμ.(40)The system is solved for cn+1 and μn+1 at each t=tn to obtain the evolutions of the concentration and chemical potential.
-
Coupled Finite Elements
In this post, I’ll introduce the FE formulation of a generalized linear and coupled weak form. Said weak formulation has the form
Find u∈V1, y∈V2 such that
a(u,v)d(u,w)+b(y,v)+e(y,w)=c(v)=f(w)(1)for all v∈V1, w∈V2 where a(⋅,⋅):V1×V1→R, b(⋅,⋅):V2×V1→R, d(⋅,⋅):V1×V2→R, e(⋅,⋅):V2×V2→R are bilinear forms and c(⋅):V1→R, f(⋅):V2→R are linear forms.
Here, the objective is to solve for the two unknown functions u and y. One can also imagine an arbitrary degree of coupling between n variables with n equations.
We introduce the following discretizations
uhyh=J=1∑nn1uJNJ=L=1∑nn2uLNLvhwh=I=1∑nn1uINI=K=1∑nn2uKNKuh,vh∈Vh1yh,wh∈Vh2(2)where the corresponding number of shape functions are nn1 and nn2, respectively.
Substituting the discretizations in (1), we obtain two linear systems of equations
J=1∑nn1a(NJ,NI)uJJ=1∑nn1d(NJ,NK)uJ+L=1∑nn2b(NL,NI)yL+L=1∑nn2e(NL,NK)yL=c(NI)=f(NK)(3)for I=1,…,nn1 and K=1,…,nn2.
We write this system as
AuDu+By+Ey=c=for[ADBE][uy]=[cf](4)where the components of given matrices and vectors are defined as
AIJDKJ:=a(NJ,NI):=d(NJ,NK)BILEKL:=b(NL,NI):=e(NL,NK)cIfK:=c(NI):=f(NK)(5)Solution of (4) yields the unknown vectors u and y.
-
Time-Dependent Finite Elements
Time dependent problems are commonplace in physics, chemistry and many other disciplines. In this post, I’ll introduce the FE formulation of linear time-dependent problems and derive formulas for explicit and implicit Euler integration.
The weak formulation of a first order time-dependent problem reads:
Find u∈V such that
m(u˙,v;t)+a(u,v;t)=b(v;t)(1)for all v∈V and t∈[0,∞).
We can convert (1) into a system of equations
M(t)u˙+A(t)u=b(t)(2)where the components of the matrices and vectors involved are calculated as
MIJ(t)AIJ(t)bI(t)=m(NJ,NI;t)=a(NJ,NI;t)=b(NI;t).(3)If we further discretize in time with the finite difference u˙≈[un+1−un]/Δt, linearity allows us to write
m(u˙,v;t)≈Δt1[m(un+1,v;tn+1)−m(un,v;tn)](4)This reflects on the system as
M(t)u˙≈Δt1[Mn+1un+1−Mnun](5)Here, un+1:=u(x,tn+1), Mn+1=M(tn+1) and vice versa for un and Mn.
Explicit Euler Scheme
For the explicit Euler scheme, we substitute evaluate the remaining terms at tn
Δt1[m(un+1,v;tn+1)−m(un,v;tn)]+a(un,v;tn)=b(v;tn)∀v∈V.(6)The corresponding system is
Δt1[Mn+1un+1−Mnun]+Anun=bn(7)The update equation becomes
un+1=Mn+1−1[Mnun+Δt(bn−Anun)](8)If m is time-independent, that is m(u˙,v;t)=m(u˙,v), we have
un+1=un+ΔtM−1(bn−Anun)(9)Implicit Euler Scheme
For the implicit Euler scheme, we substitute evaluate the remaining terms at tn+1
Δt1[m(un+1,v;tn+1)−m(un,v;tn)]+a(un,v;tn+1)=b(v;tn+1)∀v∈V.(10)The corresponding system is
Δt1[Mn+1un+1−Mnun]+An+1un+1=bn+1(11)The update equation becomes
un+1=[Mn+1+ΔtAn+1]−1[Mnun+Δtbn+1](12)If m is time-independent, one can just substitute M=Mn+1=Mn.
Example: Reaction-Advection-Diffusion Equation
The IBVP of a linear reaction-advection-diffusion problem reads
∂t∂uuu=∇⋅(D∇u)−∇⋅(cu)+ru+f=uˉ=u0inoninΩ×I∂Ω×IΩ,t=0(13)where t∈I=[0,∞),
- D is a second-order tensor describing the diffusivity of u,
- c is a vector describing the velocity of advection,
- r is a scalar describing the rate of reaction,
- and f is a source term for u.
The weak formulation is then
Find u∈V such that
∫Ωu˙vdv=∫Ω[∇⋅(D∇u)−∇⋅(cu)+ru+f]vdv(14)for all v∈V and t∈I.
We have the following integration by parts relationships:
∫Ω∇⋅(D∇u)vdv=∫Ω∇⋅(vD∇u)dv−∫Ω(D∇u)⋅∇vdvfor the diffusive part and
∫Ω∇⋅(cu)vdv=∫Ω∇⋅(cuv)dv−∫Ωuc⋅∇vdv(15)for the advective part. The canceled terms are due to divergence theorem and the fact that v=0 on the boundary. Then our variational formulation is of the form (1) where
m(u˙,v)a(u,v)b(v)=∫Ωu˙vdv=∫Ω(D∇u)⋅∇vdv−∫Ωuc⋅∇vdv−∫Ωruvdv=∫ΩfvdvFrom these forms, we obtain the following system matrices and vector
MIJAIJbI=∫ΩNJNIdv=∫Ω(DBJ)⋅BIdv−∫ΩNJc⋅BIdv−∫ΩrNJNIdv=∫ΩfNIdvwhere M is constant through time.