Entries for 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.
-
Vectorial Finite Elements
$ \newcommand{\BAhat}{\hat{\boldsymbol{A}}} \newcommand{\Buhat}{\hat{\boldsymbol{u}}} \newcommand{\Bbhat}{\hat{\boldsymbol{b}}} $Many initial boundary value problems require solving for unknown vector fields, such as solving for displacements in a mechanical problem. Discretization of weak forms of such problems leads to higher-order linear systems which need to be reshaped to be solved by regular linear solvers. There are also more indices involved than a scalar problem, which can be confusing. In this post, I’ll try to elucidate the procedure by deriving for a basic higher-order system and giving an example.
The weak formulation of a linear vectorial problem reads
Find u∈V such that
a(u,v)=b(v)(1)for all v∈V.
Discretizations of vectorial problems requires the expansion of vectorial quantities as linear combinations of the basis vectors ei:
u=i=1∑nduiei(2)where {ui}i=1nd are the components corresponding to the basis vectors and nd=dimV. Here, we chose Cartesian basis vectors for simplicity.
We can therefore express its discretization as
uh=I=1∑nnuINI=I=1∑nni=1∑nduiIeiNI.(3)Substituting discretized functions in the weak formulation, we obtain
a(uh,vh)=i=1∑ndj=1∑nda(uh,jej,vh,iei)=I=1∑nnJ=1∑nni=1∑ndj=1∑ndujJviIa(ejNJ,eiNI)(4)and
b(vh)=i=1∑ndb(vh,iei)=I=1∑nni=1∑ndviIb(eiNI).(5)We define the following arrays
AijIJbiI=a(ejNJ,eiNI)=b(eiNI).(6)Hence we can express the linear system
a(uh,vh)=b(vh)(7)as
I=1∑nnJ=1∑nni=1∑ndj=1∑ndujJviIAijIJ=I=1∑nni=1∑ndviIbiI.(8)For arbitrary vh, this yields the following system of equations
J=1∑nnj=1∑ndAijIJujJ=biI(9)for i=1,…,nd and I=1,…,nn.
We reshape this higher-order system as shown in the previous post Reshaping Higher Order Linear Systems:
A^u^=b^(10)by defining a map id that maps original indices to the reshaped indices
id:={[1,nn]×[1,nd](I,i)→[1,nnnd]↦nd(I−1)+i(11)where we used 1-based indexing of the arrays. We set
αβ:=id(I,i):=id(J,j)=nd(I−1)+i=nd(J−1)+j(12)and write
A^αβ=AijIJ,u^β=ujJandb^α=biI(13)The inverse index mapping can be obtained as shown in the previous post.
Example: Linear Elasticity
Our initial-boundary value problem is
−divσut=ργ=uˉ=tˉinononΩ∂Ωu∂Ωt(14)The weak formulation reads
Find u∈V such that
−∫Ωdivσ⋅vdv=∫Ωργ⋅vdv(15)for all v∈V where V=H1(Ω).
We apply integration by parts on the left-hand side
∫Ωdivσ⋅vdv=∫Ωdiv(σv)dv−∫Ωσ:∇vdv(16)and apply the divergence theorem to the first resulting term:
∫Ωdiv(σv)dv=∫∂Ωttˉ⋅vda(17)Substituting the linear stress σ=C:ε=C:∇u, we obtain the following variational forms:
a(u,v)b(v)=∫Ω∇v:C:∇udv=∫Ωργ⋅vdv+∫∂Ωttˉ⋅vda(18)(19)We have the following discretizations of the unknown function and test function
uh=J=1∑nnuJNJandvh=I=1∑nnvINI.(20)With the given discretizations, the matrix corresponding to (18) can be calculated as
AijIJ=a(ejNJ,eiNI)=∫Ω∇(eiNI):C:∇(ejNJ)dv=∫Ω(ei⊗∇NI):C:(ej⊗∇NJ)dv=∫Ω∂xk∂NICikjl∂xl∂NJdv,(21)and finally obtain
AijIJ=∫ΩBkICikjlBlJdv.(22)The vector corresponding to (19) is calculated as
biI=b(eiNI)=∫∂Ωttˉ⋅(eiNI)da+∫Ωργ⋅(eiNI)dv(23)which yields
biI=∫∂ΩttˉiNIda+∫ΩργiNIdv(24) -
Reshaping Higher Order Linear Systems
$ \newcommand{\BAhat}{\hat{\boldsymbol{A}}} \newcommand{\Buhat}{\hat{\boldsymbol{u}}} \newcommand{\Bbhat}{\hat{\boldsymbol{b}}} $In vectorial problems, we end up with linear systems of higher order, such as
k=1∑Nl=1∑MAijklukl=bij(1)for i=1,…,N and j=1,…,M.
These systems cannot be solved readily with existing software. In order to be able to solve them with existing software, we need to reshape them by defining a matrix of matrices A^ and vector of vectors u^ and b^:
A^A1111⋮A1M11AN111⋮ANM11⋯⋱⋯⋮⋯⋱⋯A111M⋮A1M1MAN11M⋮ANM1M⋯⋱⋯A11N1⋮A1MN1AN1N1⋮ANMN1⋯⋱⋯⋮⋯⋱⋯A11NM⋮A1MNMAN1NM⋮ANMNMu^u11⋮u1M⋮uN1⋮uNM=b^b11⋮b1M⋮bN1⋮bNM(2)This allows us to express the linear system as
A^u^=b^(3)Here, we reshape the system by defining a map id that maps original indices to the reshaped indices
id:={[1,N]×[1,M](i,j)→[1,NM]↦M(i−1)+j(4)where we used 1-based indexing of the arrays. We set
αβ:=id(i,j):=id(k,l)=M(i−1)+j=M(k−1)+l(5)and write
A^αβ=Aijkl,u^β=uklandb^α=bij(6)For reference, the inverse of the index mapping reads
id−1:={[1,NM]α→[1,N]×[1,M]↦(1+(α−mod(α,M))/M,mod(α,M))(7)Thus, we have for our reshaped indices,
ji=mod(α,M)=1+(α−j)/Mandlk=mod(β,M)=1+(β−l)/M(8)Expressed as a regular linear system (3), the higher-order system (1) can be solved with a linear solver such as LAPACK.
-
Linear Finite Elements
Beginning with this post, I’ll be publishing about the basics of finite element formulations, from personal notes that accumulated over the years. This one is about linear and scalar problems which came to be the “Hello World” for FE. Details regarding spaces and discretization are omitted for the sake of brevity. For those who want to delve into theory, I recommend “The Finite Element Method: Theory, Implementation, and Applications” by Larson and Bengzon.
The weak formulation of a canonical linear problem reads
Find u∈V such that
a(u,v)=b(v)(1)for all v∈V where a(⋅,⋅) is a bilinear form and b(⋅) is a linear form.
We define the discretization of u as
uh:=J=1∑nnuJNJ,uh∈VhwhereVh⊂V(2)The discretization uh is a linear combination of basis functions NJ and corresponding scalars uJ, J=1,…,nn so that Vh is a subset of V. The discretization of (1) then reads
a(uh,vh)=b(vh)∀vh∈Vh.(3)We then have
a(J=1∑nnuJNJ,I=1∑nnvINI)=b(I=1∑nnvINI)(4)Using the linearity properties,
a(αu,βv)=αβa(u,v)andb(αv)=αb(v)(5)we obtain
I=1∑nnJ=1∑nnuJvIa(NJ,NI)=I=1∑nnvIb(NI).(6)For arbitrary test function values vI, we can express (6) as a system of nn equations
J=1∑nnuJa(NJ,NI)=b(NI)(7)for I=1,2,…,nn. If we expand the summations as
a(N1,N1)u1a(N1,N2)u1⋮a(N1,Nnn)u1+a(N2,N1)u2+a(N2,N2)u2⋮+a(N2,Nnn)u2+⋯+⋯⋮+⋯+a(Nnn,N1)unn+a(Nnn,N2)unn⋮+a(Nnn,Nnn)unn=b(N1)=b(N2)⋮=b(Nnn)we can see that the terms with a constitute a matrix A and the terms with b constitute a vector b, allowing us to write
Au=b(8)where we chose to express the unknown coefficients uI as a vector u=[u1,u2,…,unn]T.
\It can be seen that the components of the A and b are defined as
AIJ=a(NJ,NI)andbI=b(NI),(9)we can express the linear system as
A11u1A21u1⋮Ann1u1+A12u2+A22u2⋮+Ann2u2+⋯+⋯⋮+⋯+A1nnunn+A2nnunn⋮+Annnnunn=b1=b2⋮=bnnNote that with the given definitions, (7) becomes
J=1∑nnAIJuJ=bIforI=1,2,…nn.(10)Example: Poisson’s Equation
In the weak form of Poisson’s equation
−Δuu=f=0inonΩ∂Ω(11)The weak formulation reads
Find u∈V such that
−∫ΩΔ(u)vdv=∫Ωfvdv(12)for all v∈V where V=H01(Ω).
Applying integration by parts and divergence theorem on the left-hand side
∫ΩΔ(u)vdv=∫Ω∇⋅(∇(u)v)dv−∫Ω∇u⋅∇vdv=v=0 on ∂Ω∫∂Ωv(∇u⋅n)da−∫Ω∇u⋅∇vdv(13)We have the following variational forms:
a(u,v)b(v)=∫Ω∇u⋅∇vdv=∫Ωfvdv(14)Following (7), we can calculate the stiffness matrix A as
AIJ=a(NJ,NI)=∫Ω∇NJ⋅∇NIdv=∫ΩBJ⋅BIdv(15)where we have defined the gradient of the basis functions as
BI:=∇NI.(16)Similarly, we integrate the force term into a vector b as
bI=∫ΩfNIdv(17) -
Balance Laws
Calculus is all about relating the change in one quantity to another quantity.
ΔA=BImagine it this way: You have a box full of marbles, and you decide to put some more in. A is the variable representing the amount of marbles, while B is the variable representing the amount of marbles that you put in. If you had A1 marbles at the beginning, you have
A2=A1+ΔA=A1+Bmarbles following your action. This is the most fundamental algebraic pattern that characterizes balance laws.
Take the first law of thermodynamics for example—a.k.a. balance of energy. We have
ΔU=Q+Wwhere U is the internal energy of a closed system, Q is the amount of heat supplied to the system, and W is the amount of work done on the system on its surroundings. Here, A≡U and B≡Q+W. Despite having three quantities, it is the combined effect of two which is related to the remaining quantity. Balance laws derived by physicists and chemists can get quite complex and hard to understand.
It’s always that the change in one quantity is related to the combined effect of remaining quantities. Keeping separate track of your main variable A and affecting variables that compose B gives you a mental model which helps you remember and even build your own balance laws.
Introducing Time
Let A:t→A(t) be a function of time. We can rewrite the equation in terms of the change in A in a time period Δt:
ΔtΔA=Cwhere the new variable C represents the change in quantity in Δt amount of time. In our previous analogy, C is the amount of marbles put in, say, a minute. As Δt→0, we have
dtdA=C(t).This prototypical balance law allows us to relate the rates of change of quantities.
Let’s introduce time into the balance of energy. The equation becomes
dtdU=PT(t)+PM(t)where the new quantities PT and PM are called thermal power and mechanical power, representing the thermal and mechanical work done on the system per unit time, respectively. Given power functions and initial conditions, integrating them would give us the evolution of the internal energy through time.
Introducing Space
Let’s say we are not satisfied with an abstract box where the amount of stuff that goes in is measured automatically. We want to write a balance law over different shapes of bodies and we need to specify exactly where the stuff goes in and out.
To do that, we need to rephrase our laws to work over a continuous domain. The branch of physics that focuses on such problems is called continuum mechanics.
We introduce our spatial domain Ω and its boundary ∂Ω. Our quantities now vary over both space and time, so we need to integrate them over the whole domain in order to relate them:
dtd∫Ωadx=∫Ωbdx+∫∂Ωc⋅ndswhere
- a(x,t) is the variable representing the main continuous quantity,
- b(x,t) is the variable representing the rate of change of the quantity inside the domain,
- and c(x,t) is the variable representing the negative rate of change of the quantity on the boundary of the domain—negative due to surface normals n having outward direction by definition.
Notice that when we introduce space, our prototypical balance law needs an additional vectorial quantity, c. In physical laws, one needs to differentiate actions inside a body from actions on the surface of the body. That’s because one is over a volume and the other over an area, and they have to be integrated separately.
The area integral is actually a flux where the vectorial quantity c is penetrating the surface with a given direction. Given that it’s positive when stuff exits the domain, it’s called the efflux of the underlying quantity. Similarly, we name the rate of change field b as the supply of the underlying quantity, because it being positive results in an increase.
The idea is to get rid of the integrals by a process called “localization”. In order to localize, we have to convert the surface integral into a volume integral using the divergence theorem:
∫∂Ωc⋅nds=∫Ω∇⋅cdxAssuming Ω doesn’t move, we can also write
dtd∫Ωadx=∫ΩdtdadxCollecting the results, we have
∫Ωdtdadx=∫Ωbdx+∫Ω∇⋅cdxNotice that all integrals are over Ω now. This allows us to make the balance law more strict by enforcing it point-wise:
dtda=b+∇⋅c∀x∈ΩThis is the localized version of the prototypical balance law that is used everywhere in continuum mechanics. Unfortunately, I can’t give the energy balance example, because it would require too many additional definitions. For that, I recommend the excellent Mathematical Foundations of Elasticity by Marsden and Hughes.
Conclusion
In physics and chemistry, one shouldn’t blindly memorize formulas, but try to see the underlying logic. In this case, I tried to elucidate balance laws, which all build upon the same algebraic and geometrical concepts. I went from discrete to continuous by introducing time and space to the equations, which became more complex but retained the same idea: putting things in a box and trying to calculate how that changes the contents.
-
Taylor and Volterra Series
In the theory of computational mechanics, there are a few operations used that are not taught in Calculus 101, which can be confusing without taking a lecture in calculus of variations. One of them is taking variations (a.k.a. Gateaux derivatives), akin to taking directional derivatives, but with functions of functions called functionals.
You need to take variations when you are linearizing a nonlinear problem for the purpose of solving with a numerical scheme. Linearization is the process of expanding a function or functional into a series, and discarding terms that are of order higher than linear—i.e. quadratic, cubic, quartic, etc. These expansions are called Taylor for functions, and Volterra for functionals.
Taylor Series
A function f:R→R can be expanded about a point xˉ as a power series:
f(x)=f(xˉ)+dxdfxˉ1!(x−xˉ)+dx2d2fxˉ2!(x−xˉ)2+dx3d3fxˉ3!(x−xˉ)3+⋯=n=0∑∞dxndnfxˉn!(x−xˉ)n(1)Letting x be a perturbation δx from the expansion point xˉ, that is x→xˉ+δx, the series can also be phrased as follows
f(xˉ+δx)=f(xˉ)+dxdfxˉ1!δx+dx2d2fxˉ2!δx2+dx3d3fxˉ3!δx3+⋯=n=0∑∞dxndnfxˉn!δxn(2)This is what is taught in Calculus 101 and everyone knows. Now for the part that you may have missed:
Variation
Let X be the space of functions R→R. The variation of a functional F∈X is defined as
DuF(u)⋅v:=ϵ→0limϵF(u+ϵv)−F(u)≡dϵdF(u+ϵv)ϵ=0(3)where v∈X is called the perturbation of the variation. This operation is analogous to taking the directional derivative of a function.
Shorthand notation
When working with variational formulations, writing out variations can be a bit of a hassle if there are many symbols involved. Therefore we use the following shorthand for variations:
ΔF:=DuF(u)⋅v(4)Here, we assume that there is no chance of confusing the varied function or perturbation. We use this shorthand in contexts where the perturbation does not play an important role.
The shorthand for evaluation is
Fˉ:=F(uˉ)andΔˉF:=DuF(u)⋅vuˉ(5)where there is no risk of confusion for uˉ∈X.
Volterra Series
Let X be the space of functions R→R. Analogous to the Taylor series, a functional F∈X can be expanded about a point uˉ as a power series:
F(uˉ+v)=F(uˉ)+1!1DuF(u)⋅vuˉ+2!1Du2F(u)⋅v2uˉ+3!1Du3F(u)⋅v3uˉ+⋯=n=0∑∞n!1DunF(u)⋅vnuˉ(6)where v∈X is the perturbation of the expansion. This is called the Volterra series expansion of F. Verbally, the Volterra series expansion of a functional about a function is the infinite sum of the variations of the functional with increasing degree, evaluated at that function, each divided by the factorial of the degree.
In shorthand notation, the expansion is rendered
F=Fˉ+1!ΔˉF+2!Δˉ2F+3!Δˉ3F+⋯(7)To me, there is an elegance in (7) that is not reflected in (2) or (6).
-
Isomorphisms in Linear Mappings between Vector Spaces
Equipping a vector space with an inner product results in a natural isomorphism V→V∗, where the metric tensor can be interpreted as the linear mapping g:V→V∗ and its inverse g−1:V∗→V.
Notation: Given two real vector spaces V and W, we denote their inner products as ⟨⟨⋅,⋅⟩⟩V and ⟨⟨⋅,⋅⟩⟩W respectively. Given vectors v∈V and w∈W, we define their lengths as
∥v∥V=⟨⟨v,v⟩⟩Vand∥w∥W=⟨⟨w,w⟩⟩W.(1)Regarding V and W,
- their bases are denoted {EA} and {ea},
- their dual bases are denoted {EA} and {ea},
- their metrics are denoted G and g with the components GAB=⟨⟨EA,EB⟩⟩V and gab=⟨⟨ea,eb⟩⟩W,
respectively. Here, the indices pertaining to V are uppercase (ABC…) and the indices pertaining to W are lowercase (abc…).
Definition: Let P:V→W be a linear mapping. Then the transpose, or adjoint of P, written PT, is the linear mapping
PT:W→Vsuch that⟨⟨v,PTw⟩⟩V=⟨⟨Pv,w⟩⟩W(2)for all v∈V and w∈W. Carrying out the products,
GBAvB(PT)Adwd=gabPbCvCwa.(3)For arbitrary v and w,
GBA(PT)Aa=gabPbA(4)from which we can obtain the components of the transpose as
(PT)Aa=gabPbBGABandPT=(PT)AaEA⊗ea.(5)If B:V→V is a linear mapping, it is called symmetric if B=BT.
Definition: Let P:V→W be a linear mapping. Then the dual of P is a metric independent mapping
P∗:W∗→V∗such that⟨v,P∗β⟩V=⟨Pv,β⟩W(6)defined through natural pairings for all v∈V and β∈W∗. Carrying out the products,
vA(P∗)Aaβa=PbBvBβb.(7)For arbitrary v and β, we obtain the components of the dual mapping as
(P∗)Aa=PaAandP∗=(P∗)AaEA⊗ea=PaAEA⊗ea.(8)To fully appreciate the symmetry that originates from the duality, we can think of not just the mappings between V and W, but also between their dual spaces. To this end we can enumerate four mappings corresponding to {V,V∗}→{W,W∗} and their duals, corresponding to {W,W∗}→{V,V∗}. Their definitions can be found in the table below.
Mappings P∈W⊗V∗
PAa=P(ea,EA)
P=PAaea⊗EAQ∈W∗⊗V∗
QaA=Q(ea,EA)
Q=QaAea⊗EAR∈W⊗V
RaA=R(ea,EA)
R=RaAea⊗EAS∈W∗⊗V
SaA=S(ea,EA)
S=SaAea⊗EAP:V→W
vvAEA↦P(ea,v)ea=Pv↦PAavAeaQ:V→W∗
vvAEA↦Q(ea,v)ea=Qv↦QaAvAeaR:V∗→W
ααAEA↦R(ea,α)ea=RαT↦RaAαAeaS:V∗→W∗
ααAEA↦S(ea,α)ea=SαT↦SaAαAeaP:W∗×V→R
(β,v)↦P(β,v)=βPv=βaPAavAQ:W×V→R
(w,v)↦Q(w,v)=wTQv=waQaAvAR:W∗×V∗→R
(β,α)↦R(β,α)=βRαT=βaRaAαAS:W×V∗→R
(w,α)↦S(w,α)=wTSαT=waSaAαADuals P∗∈V∗⊗W
PA∗a=P∗(EA,ea)
P∗=PA∗aEA⊗eaQ∗∈V∗⊗W∗
QAa∗=Q∗(EA,ea)
Q∗=QAa∗EA⊗eaR∗∈V⊗W
R∗Aa=R∗(EA,ea)
R∗=R∗AaEA⊗eaS∗∈V⊗W∗
S∗Aa=S∗(EA,ea)
S∗=S∗AaEA⊗eaP∗:W∗→V∗
ββaea↦P∗(EA,β)EA=P∗βT↦PA∗aβaEAQ∗:W→V∗
wwaea↦Q∗(EA,w)EA=Q∗w↦QAa∗waEAR∗:W∗→V
ββaea↦R∗(EA,β)EA=R∗βT↦R∗AawaEAS∗:W→V
wwaea↦S∗(EA,w)EA=S∗w↦S∗AawaEAP∗:V×W∗→R
(v,β)↦P∗(v,β)=vTP∗βT=vAPA∗aβaQ∗:V×W→R
(v,w)↦R∗(v,w)=vTQ∗w=vAQAa∗waR∗:V∗×W∗→R
(α,β)↦S∗(α,β)=αR∗βT=αAR∗AaβaS∗:V∗×W→R
(α,w)↦S∗(α,w)=αS∗w=αAS∗AawaTensors P, Q, R and S as linear mappings (top), and their duals P∗, Q∗, R∗ and S∗ (bottom). In the respective tables, the first row displays the tensor spaces, basis vectors and components of the subsequent mappings, and the second and third row display the representations of the tensor as linear and bilinear mappings respectively. The results of the mappings are given in the mapping, matrix and index representations respectively. The mappings are over vectors v∈V, w∈W and one-forms α∈V∗, β∈W∗. The commutative diagrams pertaining to these mappings can be found in the figure below
Commutative diagrams involving the linear mappings P,Q,R,S and their dual P∗,Q∗,R∗,S∗ based on the metrics G and g of V and W.
-
Metrics and Natural Isomorphisms
The assignment of an inner product to a non-degenerate and finite-dimensional vector space V, results in emergence of the natural isomorphism to its dual V→V∗, which means that the morphisms V→V∗ and V∗→V are of the same structure and one is the inverse of the other. The notion of naturality (of an isomorphism) becomes most clear in the context of category theory; however it should be sufficient for now to say that a natural isomorphism between a vector space an its dual is one that is basis-independent. As the origin of the isomorphism, the inner product is encapsulated in an object called the metric, defined below, in order to make the resulting symmetry of the mappings more obvious.
In the context of differential geometry, the metric object is used synonymously with the inner product of a vector space. More specifically, the metric tensor
g:={V×V(v,w)→R↦⟨⟨v,w⟩⟩(1)of a real vector space V is an object whose components contain the information necessary to linearly transform a vector to its covector. This operation is denoted by the symbol ♭ and reads
♭:=⎩⎨⎧(V∗→R)orVv(⋅)→(V→R)→V∗↦g(v,⋅).(2)We simply define the one-form v♭ as
v♭(w)≡g(v,w)=⟨⟨v,w⟩⟩.(3)We input the basis vectors ea
v♭(ea)=⟨⟨vbeb,ea⟩⟩=⟨⟨eb,ea⟩⟩vb=⟨⟨ea,eb⟩⟩vb(4)and define the components of the metric tensor as
gab=⟨⟨ea,eb⟩⟩andg=gabea⊗eb.(5)We then simply say that the operator ♭ denotes an index lowering1 through
v♭=gvand component-wise va=gabvb.(6)Moreover, we can define the inverse of the metric tensor as
g−1:={V∗×V∗(α,β)→R↦⟨⟨α,β⟩⟩(7)The operation of transforming a covector to its corresponding vector is denoted by the symbol ♯ and reads
♯:=⎩⎨⎧(V→R)orV∗α(⋅)→(V∗→R)→V↦g−1(⋅,α).(8)Here, the vector corresponding to the covector α is denoted α♯ and reads
α♯(β)=g−1(β,α)=⟨⟨β,α⟩⟩(9)We input the dual basis vectors ea
α♯(ea)=⟨⟨ea,αbeb⟩⟩=⟨⟨ea,eb⟩⟩αb(10)and define the components of the inverse metric g−1 as
gab=⟨⟨ea,eb⟩⟩andg−1=gabea⊗eb.(11)Then the operator ♯ denotes an index raising through
α♯=g−1αand component-wise αa=gabαb.(12)In some literature, the natural isomorphism V→V∗ is called the musical isomorphism—which is also the origin of the notation introduced above—because the process of transforming a vector to its dual space and a covector to the original space is analogous to lowering and raising notes.
With the given definition of the metric, we can elaborate on the advantage of denoting inner products of different objects with different symbols. Whereas ⟨⋅,⋅⟩ always denotes a natural pairing between a vector space and its dual, one can write ⟨⟨⋅,⋅⟩⟩V:V×V→R to denote an inner product of vectors and ⟨⟨⋅,⋅⟩⟩V∗:V∗×V∗→R to denote an inner product of covectors. Using the metric, we can link these notations as
⟨⟨v,w⟩⟩V⟨⟨α,β⟩⟩V∗=⟨v,w♭⟩=⟨α,β♯⟩=⟨v♭,w⟩=⟨α♯,β⟩=gabvawb=gabαaβb(13)for all v,w∈V and α,β∈V∗. Similarly,
⟨v,α⟩=⟨⟨v♭,α⟩⟩V∗=⟨⟨v,α♯⟩⟩V.(14)Despite the symmetricity of the inner product, we choose to think of the first operand as a vector and the second as a covector in a natural pairing, as a convention.
The metric tensor has the following properties:
- For orthonormal bases, the metric tensor equals the identity tensor, that is, gij=δij.
- The diagonal terms equal to the square of the lengths of the basis vectors, that is, gii=∥ei∥2 (no summation).
- The off-diagonal terms are zero if the basis vectors are orthogonal. Specifically, gij=0 iff ei and ej are orthogonal.
-
In musical notation, the flat symbol ♭ is used to lower a note by one semitone, whereas the sharp symbol ♯ is used to raise a note by one semitone. It is recommended to pronounce v♭ as v-flat and α♯ alpha-sharp. ↩
-
Duality of Vector Spaces
$ \newcommand{\veciup}[1]{#1^1,\ldots,#1^n} \newcommand{\setveci}[1]{\cbrn{\veci{#1}}} \newcommand{\setveciup}[1]{\cbrn{\veciup{#1}}} \newcommand{\tang}{T} $When I was learning about Continuum Mechanics for the first time, the covariance and contravariance of vectors confused the hell out of me. The concepts gain meaning in the context of Riemannian Geometry, but it was surprising to find that one doesn’t need to learn an entire subject to grasp the logic behind co-/contravariance. An intermediate knowledge of linear algebra is enough—that is, one has to be acquainted with the concept of vector spaces and one-forms.
The duality of co-/contravariance arises when one has to define vectors in terms of a non-orthonormal basis. The reason such terminology doesn’t show up in engineering education is that Cartesian coordinates are enough for most engineering problems. But every now and then, a complex problem with funky geometrical requirements show up, like one that requires measuring distances and areas on non-flat surfaces. Then you end up with dual vector spaces. I’ll try to give the basics of duality below.
Definition: Let V be a finite-dimensional real vector space. The space V∗=L(V,R), defined as the the space of all one-forms α:V→R, is called the dual space to V.
Let B={e1,…,en} be a basis of V. Any vector v∈V can be written in terms of B as
v=a1e1+⋯+anen(1)with the components a1,…,an∈R. For any i=1,…,n, we can define the i-th component ai by a one-form as
ei:={Vv→R↦ei(v)=ai(2)These elements are linear and thus are in the space L(V,R)1. Given any basis B={e1,…,en}, we call B∗={e1,…,en} the basis of V∗ dual to B. The fact that B∗ really is a basis of V∗ can be proved by showing that ei are linearly independent. Then v has the following representation
v=e1(v)e1+⋯+en(v)en.(3)Instead of ai, it is practical to denote the components of v as vi, lightface of the same symbol with a raised index corresponding to the raised index of the dual basis:
v=v1e1+⋯+vnenandvi=ei(v).(4)In fact, this convention is more compatible with the symmetry caused by the duality. This point will be more clear after the introduction of dual basis representation of one-forms.
Proposition: Each ei∈L(V,R) can be identified by its action on the basis B:
ei(ej)={10if i=jotherwise.(5)Proof: For any v∈V, ei(v) must give vi, the i-th component of v. Setting v=ej, one sees that ei(v)=vi=1 when i=j, and is zero otherwise.
Geometrically, (5) implies that a basis vector is perpendicular to all the dual basis vectors, except its own dual.
Dual Basis Representation of One-Forms
Let α be a one form in V∗ with the corresponding dual basis {e1,…,en}. Then similar to a vector, α has the following representation
α(⋅)=α(e1)e1(⋅)+⋯+α(en)en(⋅)=α1e1(⋅)+⋯+αnen(⋅)(6)where the components of the one-form α are defined as
αi=α(ei).(7)Proof: We substitute (3) and obtain
α(v)=α(i=1∑nei(v)ei)=i=1∑nα(ei)ei(v)(8)using α‘s linearity.
Notation: Let V be a finite-dimensional real vector space. For v∈V and α∈V∗
⟨⋅,⋅⟩:={V×V∗(v,α)→R↦α(v)(9)denotes the action of α on v, and is called a natural pairing or dual pairing between a vector space and its dual. It is of the essence to understand that ⟨⋅,⋅⟩ does not denote an inner product in V; that is, ⟨v,α⟩ means α(v).
With this notation, (3) can be written as
v=⟨v,e1⟩e1+⋯+⟨v,en⟩en.(10)and (5) as
⟨ei,ej⟩=δij.(11)Using the convention that ei are column vectors and ei are row vectors, (11) can be rearranged in the following manner
[e1e2⋯en]−1=e1e2⋮en(12)which can be used to compute a dual basis.
Example: Given a two-dimensional vector space V with a basis e1=[2,−0.5]T, e2=[1,1]T, we use (12) to compute
[2−0.511]−1=[0.40.2−0.40.8](13)and obtain the dual basis vectors as e1=[0.4,−0.4] and e2=[0.2,0.8]. The result is given in the following figure,
where one can see that e1⊥e2, e1⊥e2.
A body B embedded in R2 with curvilinear coordinates. Every point P at X has an associated two-dimensional vector space, called B's tangent space at X, denoted TXB. The basis ei corresponding to coordinates θi are not necessarily orthogonal and can admit corresponding duals ei, due to curvilinearity. The coordinates appear to be affine at the point's immediate vicinity, and thus in the tangent space.
The introduction of the dual space allows us to reinterpret a one-form α as an object residing in the dual space. In fact, the canonical duality V∗∗=V states that every vector v can be interpreted as a functional on the space V∗ via
v:={V∗α→R↦v(α) or ⟨v,α⟩(14)-
Despite being denoted with bold letters, one-forms should not be confused with vectors. ↩
-