37
POLITECNICO DI MILANO School of Systems Engineering MSc of Mathematical Engineering Project for the course Programmazione avanzata per il calcolo scientifico Numerical modeling of porosity evolution in source rock during kerogen breakdown Advisors: prof. Luca Formaggia Bianca Giovanardi dott. Anna Scotti 783039 Academic Year 2012-2013

Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

POLITECNICO DI MILANOSchool of Systems Engineering

MSc of Mathematical Engineering

Project for the course Programmazione avanzata per il calcolo scientifico

Numerical modeling of porosity evolution

in source rock during kerogen breakdown

Advisors:

prof. Luca Formaggia Bianca Giovanardi

dott. Anna Scotti 783039

Academic Year 2012-2013

Page 2: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

Contents

1 Introduction to the problem 1

2 Numerical approach 52.1 The pressure equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2 The stress equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82.3 The porosity equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92.4 The saturation equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102.5 The concentration equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

3 Implementation 143.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143.2 Given functions and files function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143.3 The classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

3.3.1 Class problemDarcy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173.3.2 Class problemZpde . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203.3.3 Class problemSaturation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213.3.4 Class problemGodunov . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

3.4 The input file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

4 Tests 294.1 Test of Darcy problem and compaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294.2 Test of Saturation problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314.3 Test of the full problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

5 Further developments 34

Page 3: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

1 Introduction to the problem

This work aims at simulating the porosity evolution in the rocks where the generation of hydrocarbons takesplace, due to the breakdown of some organic matter, called kerogen. In these source rocks a complex interplayof mechanical and chemical processes affects on the one hand the balance of the vertical stress, and on the otherthe kerogen concentration field. Both these matters have strong implications concerning porosity. We consider atwo dimensional vertical section of a sedimentary basin and we deal with a simplified model of source rock, whichconsists of rock with no hydrocarbon potential, pure kerogen, and a void part initially filled with water. We alsoconsider a simplified chemical kinetic, where kerogen generates only oil. The solid → fluid conversion of kerogencauses pressure variations, which induce variations in the effective vertical stress that the rock is subject to, that isthe overburden stress less the pressure of the fluids in pores. Moreover these conversions cause an extra porosity,which can be filled by the fluids or can be subject to compaction.

The region where we set the problem is a slice of source rock, which we think to continue outside the domainin the horizontal direction. The space setting of the problem will be crucial when we will discuss the boundaryconditions. Because of the consumption of kerogen and of the compaction of the rock due to the vertical pressure,the sediment matrix is not fixed and the physical domain of the phenomenon moves. In order to avoid thiscomplication and to write the equations on a fixed domain, we introduce the domain Ω, whose coordinates are(x, ξ), that is obtained from the physical domain as its completely compacted configuration, once removed all thedegradable part of the rock (i.e. the kerogen). Thus, Ω represents the material non-degradable volume and isfixed. We assume that compaction leads only to a vertical movement of the solid matrix. Hence both domains havethe same x coordinate. Another assumption is that kerogen can be considered as dispersed in the solid matrix.Hence, at any point x inside the domain and at any time t we can define a field C = C(x, t) that representsthe ratio between the volume of kerogen and the initial solid volume, i.e. the solid volume when no degradationof kerogen has yet occurred Under these assumptions, the map from the fixed domain to the physical domain isϕ : Ω→ Ω(t), ϕ(x, ξ) = (x, z(ξ, t))

ϕ(x, ξ) =

(x, −

∫ ξ∗

ξ

1− C0 + C(ξ′)

(1− C0)(1− φ(ξ′))dξ′

)where ξ∗ is the height of the basin along the ξ-axis and is computed from the porosity at the initial configuration.We define

J := ∇ϕ =

[1 00 ∂z/∂ξ

]and we set

J(x, ξ, t) :=1− C0 + C(x, ξ, t)

(1− C0)(1− φ(x, ξ, t)).

This function is the Jacobian determinant of the map and will often appear in the following, as a consequenceof the change of coordinates in the integrals, while obtaining the equations. The following equations are writtenstraight on the fixed domain Ω and the boundary conditions will be specified later on.

The breakdown of kerogen is modeled with the Arrhenius law:

∂C

∂t= −k C, (1)

where the reaction rate k is given byk = Ae−E/RT .

1

Page 4: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

A is the Arrhenius factor, E is the activation energy, R is the gas constant, and T is the absolute temperature.Equation (1) is supplemented by the initial condition C(x, ξ, t) = C0(x, ξ), where C0 represents the initial kerogenvolume fraction in the rock.

The mass conservation of the fluids, water and oil, can be expressed as:

∂(ρwφSwJ)

∂t+∇ · (ρwUw) = 0 (2)

∂(ρoφSoJ)

∂t+∇ · (ρoUo) = QoJ (3)

where φ = φ(x, ξ, t) is the porosity of the rock, ρw = ρw(x, ξ, t) and ρo = ρo(x, ξ, t) are the densities of water andoil, which may depend on temperature and pressure. Sw = Sw(x, ξ, t) and So = So(x, ξ, t) = 1 − Sw(x, ξ, t) arethe saturations of water and oil, respectively. Finally Qo is a source term that accounts for the generation of oilthrough the breakdown of kerogen. To a first approximation, one can assume that the consumption of kerogen inrock only generates oil. Hence there is no source term in the water equation.

The fluxes Uo and Uw are given by the Darcy law as

Uw = −J kr,wKµw

(∇pw − ρwJTg

)Uo = −J kr,oK

µo

(∇po − ρoJTg

)with g = −gez. kr,w and kr,o are the relative permeabilities of the two phases and are given functions of thesaturations. The relative permeabilities can be modeled by several expressions that can be found in the specializedliterature. In our model, we will employ the Brooks-Corey relative permeability curves, namely

kr,w(Sw) = S3w, (4)

kr,o(So) = S2o (1− (1− So)2). (5)

Notice that if the relative permeability of one phase vanishes, then that phase cannot flow. µw and µo are theviscosities, which may depend on temperature. We have set K := J−1K(φ)J−T , and K is the permeability tensorand depends on the porosity φ, according to the following relation:

K(φ) = K(φ)

[kxx 00 kzz

](6)

where, following [1], K(φ) is a modified Kosney-Carman equation:

K(φ) =

k0φ

3 if φ ≥ 0.1

100 k0φ5

(1− φ)2if φ < 0.1

. (7)

In the two-phase Darcy model the pressures of the fluids fulfill

po − pw = pc.

2

Page 5: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

The capillary pressure pc is a given function of either Sw or So. Following Brooks-Corey, we choose

pc(Sw) = pD S−1/mw ,

where pD is the entry pressure, which depends on the porous medium characteristics, and m depends on the poresize distribution and is large for single-grained materials, small for highly nonuniform materials.

In order to close the formulation of the problem, we need some more information: how the breakdown ofkerogen makes up the source term for equation (3) (i.e. equation Qo = Qo(φ,C)), and how the porosity φ of therock depends on the overload and on the kerogen volume fraction (i.e. φ = φ(σe, C)). It can be proved that, inthis model

Qo(φ,C) = ρk1− φ

1− C0 + Ck C, (8)

and the porosity is given by

φ(x, ξ, t) =

((1 + C(x, ξ, t)− C0)

(φ0 +

∫ t

0

kC(y(τ), τ)eβσe(y(τ),τ)

(1 + C(y(τ), τ)− C0)2dτ

))e−βσe(x,ξ,t).

In this equation, σe = σe(x, t) represents the vertical effective stress, which is the bulk pressure σT minus thefluid pressure pf

σe = σT − pf .

The fluid pressure is defined as a mean over the oil pressure po and the water pressure pw weighted with respectto the the saturations:

pf = Sopo + Swpw,

and the bulk pressure at depth z can be approximated by the pressure due to the weight of sediments and thepore fluids:

σT (x, ξ, t) =

∫ ξtop

ξ[(1− φ)ρs + φρf ]Jg dξ′ + σtop(t)

σtop is the overburden and may be variable in time. ρf is given by

ρf = Soρo + Swρw.

and ρs is given by

ρs =(1− C0)ρr + Cρk

1− C0 + C(9)

where ρr and ρk are the densities of the rock with no hydrocarbon potential and of kerogen, respectively.Under the assumption of uniform and constant densities of water and oil, the mass conservation of the two

fluids, the condition requiring that the two phases completely fill the porous medium, and the compatibilitycondition on the partial pressure of the fluids can be formulated in the following two-phase Darcy model in itsglobal pressure formulation

∇ ·U =QoJ

ρo− ∂

∂t(φJ)

U = −JλK (∇p−G)

3

Page 6: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

∂t(ρoφSoJ) +∇ · (ρoUo) = QoJ

Uo =λoλU− J λwλo

λK(∇pc + (ρw − ρo)JTg

)which introduces two artificial variables, i.e. the total velocity U := Uo + Uw and the the global pressure p suchthat

∇p = ∇po −λwλ∇pc.

λw := kr,w/µw and λo := kr,o/µo are the mobilities, and λ := λw +λo is the total mobility. Finally, G is defined as

G :=λwρw + λoρo

λJTg. (10)

The advantage of writing the equations and solving the problem on a domain that, differently than the physicalone, is fixed is that we do not need to worry about following with the mesh the movement of the domain. Themesh can be built once and for all at the beginning of the simulation, as well as the basis functions of the finiteelement methods. As a consequence, no matter what deformations the domain is subject to, we can solve theproblem at each time step on a regular mesh, without worsening the condition number of the matrices involved.

The equation in Ω(t)× (0, T ] for the solid matrix vertical velocity usz is

∂t((1− φ)ρs) +

∂z((1− φ)ρsusz) = Qs, (11)

where Qs is a sink term that represents the breakdown of kerogen into oil. In our case Qs = −Qo. By solving thisequation at each time step, we can compute the new position of the nodes of the mesh.

Hence, yet solving the whole problem in the fixed domain, we can visualize the solutions on the physical mesh.

4

Page 7: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

2 Numerical approach

2.1 The pressure equation

In this paragraph we analyze the pressure equation and propose a solution strategy based on a finite elementmixed method. Mixed methods have the advantage of approximating the velocity field as a variable of theproblem, while in a classic formulation the velocity has to be computed by numerical differentiation of pressure. Adirect computation of the velocity field is very convenient for the subsequent solution of the saturation equation.Moreover, since in a mixed formulation the continuity equation is not integrated by parts, we can also expect itto be satisfied with higher accuracy with respect to classic methods.

We consider the system ∇ ·U =

QoJ

ρo− ∂

∂t(φJ) in Ω× (0, T ]

1

λJK−1U = − (∇p−G) in Ω× (0, T ]

(12)

completed with the following set of boundary conditions:p = pD on ΓD

U · n = h on ΓN.

The Dirichlet boundary ΓD and the Neumann boundary ΓN are such that ΓD ∩ ΓN = ∅ and ΓD ∪ ΓN = ∂Ω. n isthe normal to ΓN pointing outwards.

Let us derive the weak formulation of this problem. Let us behave formally first and test the equations againsttwo test functions ϕ and τ . We will specify the functional setting later on.

We have ∫Ω∇ ·U ϕ dΩ =

∫Ω

(QoJ

ρo− ∂

∂t(φJ)

)ϕ dΩ∫

Ω

1

λJK−1U · τ dΩ = −

∫Ω

(∇p−G) · τ dΩ

Integrating by parts the right hand side of the second equation, we obtain∫Ω

1

λJK−1U · τ dΩ =

∫Ωp ∇ · τ dΩ−

∫Γp τ · n dγ +

∫ΩG · τ dΩ

If we assume that τ · n = 0 on ΓN , we obtain the following equations:∫Ω∇ ·U ϕ dΩ =

∫Ω

(QoJ

ρo− ∂

∂t(φJ)

)ϕ dΩ∫

Ω

1

λJK−1U · τ dΩ−

∫Ωp ∇ · τ dΩ = −

∫ΓD

pD τ · n dγ +

∫ΩG · τ dΩ

If we approximate the term ∂∂t(φJ) as

∂t(φJ) ≈ ∆(φJ)

∆t,

where we indicate with ∆(φJ) a proper variation of φJ over the time interval ∆t (such as ∆(φJ) = φ∗J∗−φ∗∗J∗∗where ∗ and ∗∗ mean n+1, n, or n−1), the following functional setting guarantees that all the previous integralsmake sense. Concerning the coefficients and the boundary conditions, we require that:

5

Page 8: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

• φ, J, ρw, ρo, µw, µo ∈ L∞(Ω× (0, T ]);

• K ∈ (L∞(Ω× (0, T ]))d×d

(if det(K) 6= 0, this condition implies K−1 ∈ (L∞(Ω× (0, T ]))d×d);

• Qo ∈ L2(Ω× (0, T ]);

• kro(So), krw(Sw) ∈ L∞(0, 1);

• pD, h ∈ L2(0, T ;H1/2(ΓD));

Let us introduce the spaceH(div; Ω) := τ ∈ (L2(Ω))d : ∇ · τ ∈ L2(Ω).

After the time discretization, a proper weak formulation for the pressure problem reads:

Weak formulation:

find Un+1 ∈ H(div; Ω) and pn+1 ∈ L2(Ω) such that Un+1 · n = h, and∫Ω∇ ·Un+1 ϕ dΩ =

∫Ω

(QoJ

ρo− ∆(φJ)

∆t

)ϕ dΩ,

∫Ω

1

λJK−1Un+1 · τ dΩ−

∫Ωpn+1 ∇ · τ dΩ = −

∫ΓD

pD τ · n dγ +

∫ΩG · τ dΩ,

∀ϕ ∈ L2(Ω) and ∀τ ∈ H(div; Ω) ∩ τ : τ · n = 0.

Notice that, while the Dirichlet boundary condition is included in the equations, the Neumann boundarycondition needs to be embedded in the functional space setting.

The finite dimensional spaces chosen for the numerical approximation are then the lowest order RaviartThomas elements Zh = RT0(Ω, Th) ⊂ H(div, Ω) for the velocity, and the space of the piece-wise constant functionVh = IP0(Ω, Th) ⊂ L2(Ω) for the pressure.

The Neumann boundary condition U·n = h on ΓN , which is not included in the equations yet, will be imposedwith a Nitsche penalization technique. Thus, we will add to one side of the equations the term∫

ΓN

γU (U · n)(τ · n) dγ,

and to the other side the term ∫ΓN

γUh(τ · n) dγ.

The full discretization of the system is then

Discrete formulation:find Un+1

h ∈ Zh and pn+1h ∈ Vh such that∫

Ω

1

λhJhK−1h Un+1

h · τ h dΩ−∫

Ωpn+1h ∇ · τ h dΩ +

∫ΓN

γU (Un+1h · n)(τ h · n) dγ

6

Page 9: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

= −∫

ΓD

pD τ h · n dγ +

∫ΩGh · τ h dΩ +

∫ΓN

γUh(τ h · n) dγ,∫Ω∇ ·Un+1

h ϕh dΩ =

∫Ω

(Qo hJhρo h

− ∆(φJ)

∆t

)ϕh dΩ,

∀τ h ∈ Zh and ∀ϕh ∈ Vh.

Proceeding with the usual technique, we write Un+1h and pn+1

h with a proper base of the finite dimensionalspaces Zh and Vh

Un+1h =

∑j

Un+1j τ hj pn+1

h =∑j

pn+1j ϕhj

and require that the first equation holds for each τ hi of the base of Zh and the second one holds for each ϕhi ofthe base of Vh and write∑

j

Un+1j

(∫Ω

1

λhJhK−1h τ hj · τ hi dΩ

)+∑j

pn+1j

(−∫

Ωϕhj ∇ · τ hi dΩ

)

+∑j

Un+1j

(∫ΓN

γU (τ hj · n)(τ hi · n) dγ

)=

∫ΓN

γUh(τ hi · n) dγ −∫

ΓD

pD τ hi · n dγ +

∫ΩGh · τ hi dΩ

∑j

Un+1j

(∫Ω∇ · τ hj ϕhi dΩ

)=

∫Ω

(QohJhρoh

− ∆(φJ)h∆t

)ϕhi dΩ

which can be written in the following algebraic form[A B−BT 0

] [Un+1

pn+1

]=

[EF

]with

Aij =

∫Ω

1

λhJhK−1h τ hj · τ hi dΩ +

∫ΓN

γU (τ hj · n)(τ hi · n) dγ

Bij = −∫

Ωϕhj ∇ · τ hi dΩ

Ei =

∫ΓN

γUh(τ hi · n) dγ −∫

ΓD

pD τ hi · n dγ +

∫ΩGh · τ hi dΩ

Fi =

∫Ω

(QohJhρoh

− ∆(φJ)h∆t

)ϕhi dΩ

We introduce the linear operator P that associates to the functions Ch, φh, Soh, and ∆(φJ)h the solutionsUn+1h and pn+1

h of this problem, where the coefficients are evaluated in Ch, φh, Soh:

(Un+1h , pn+1

h ) = P (Ch, φh, Soh,∆(φJ)h) .

7

Page 10: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

2.2 The stress equation

We now consider equation

σT (x, ξ, t) =

∫ ξtop

ξ[(1− φ)ρs + φρf ]Jg dξ′ + σtop(t)

for the bulk pressure σT . It is convenient to bring this equation back to its differential formulation. For thispurpose, we derive this equation with respect to ξ and obtain the following differential problem:

∂σT∂ξ

= ((1− φ)ρs + φρf )Jg with σT (x, ξtop, t) = σtop(t). (13)

We point out that the right hand side of the equation depends on the kerogen concentration C, on the saturationSo, and on the porosity φ, since ρs = ρs(C), ρf = ρf (So), and J = J(C,C0, φ). Thus, although there is no timederivative, the problem is indeed time dependent.

Multiplying the partial differential equation by a test function v, we have∫Ω

∂σT∂ξ

v dΩ =

∫Ωfv dΩ,

where in our case f = [(1−φ)ρs +φρf ]Jg. For the assumptions made in paragraph 2.1, the right hand side of the

stress differential equation is in L∞(Ω× (0, T ]).The numerical solution of this problem required a stabilization. We have proposed the strongly consistent

SUPG stabilization, which consists of the addition of the term∑K∈Th

δhK

∫K

(∂σT∂ξ− f

)∂v

∂ξdK

to the integral formulation, where hK is the dimension of the K-th element of the triangulation Th.Hence, a stabilized weak formulation of the problem is:

Weak formulation:

find σn+1T ∈ H1(Ω) such that σn+1

T (x, ξtop) = σtop(tn+1) and∫

Ω

∂σn+1T

∂ξv dΩ +

∑K∈Th

δhK

∫K

∂σn+1T

∂ξ

∂v

∂ξdK =

∫Ωfv dΩ +

∑K∈Th

δhK

∫Kf∂v

∂ξdK

∀v ∈ H1(Ω).

The discrete formulation is obtained by choosing the discrete space Sh := IP1(Ω, Th) ⊂ H1(Ω), and, followingthe usual procedure, one can write

σn+1Th =

∑j

σn+1j ϕhj ,

impose that the equation holds for each ϕhi of the base of Sh, and obtain the algebraic system:

Aσn+1 = F

8

Page 11: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

where

Aij =

∫Ω

∂ϕhj∂ξ

ϕhi dΩ +∑K∈Th

δhK

∫K

∂ϕhj∂ξ

∂ϕhi∂ξ

dK (14)

Fi =

∫Ωfϕhi dΩ +

∑K∈Th

δhK

∫Kf∂ϕhi∂ξ

dK (15)

and σn+1 is the vector of the coefficients of σn+1Th with respect to the base chosen.

The Dirichlet boundary condition at ξtop is imposed directly on the assembled matrix and right hand sidevector, by eliminating from A and F the degrees of freedom corresponding to the Dirichlet nodes.

Let us define the linear operator Σ that associates to Ch, φh, and Soh the numerical solution σn+1Th to the stress

problem whose coefficients are evaluated in Ch, φh, and Soh:

σn+1Th = Σ(Ch, φh, Soh)

The discretization explained in this paragraph will also be used to solve numerically equation (11). In thiscase, we will take

f = Qs −∆((1− φ)ρs)

∆t

and the Dirichlet boundary conditions will be imposed at z = 0 and homogeneous.

2.3 The porosity equation

Let us consider the numerical computation of porosity. We recall that, in our model, the porosity is given by thefollowing equation:

φ(x, z, t) =

((1 + C(x, z, t)− C0)

(φ0 +

∫ t

0

kC(y(τ), τ)eβσe(y(τ),τ)

(1 + C(y(τ), τ)− C0)2dτ

))e−βσe(x,z,t).

Let us indicate for the sake of notational convenience

s(t) :=kC(y(t), t)eβσe(y(t),t)

(1 + C(y(t), t)− C0)2.

and let

In+1 :=

∫ tn+1

0s(τ)dτ.

The integral In+1 can be approximated, applying the trapezoid method to each interval (tk, tk+1), by

In+1h =

n∑k=0

tk+1 − tk

2(s(tk+1) + s(tk))

Notice that we can compute In+1h as Inh +

∫ tn+1

tn s(τ)dτ and update the computed integral at each time step withthe new contribution from tn to tn+1.

9

Page 12: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

Thus, one can approximate the porosity at the instant tn+1 with

φn+1h = (1 + Ch − C0)

(φ0 + In+1

h

)e−βσeh .

We will take φn+1h ∈ IP0(Ω, Th). We define the linear operator Φ that associates to Ch and σeh the numerical

computation of porosity φn+1h , evaluated with Ch and σeh:

φn+1h = Φ(Ch, σeh).

2.4 The saturation equation

The saturation equation is a nonlinear advection-diffusion-reaction equation, whose numerical solution is compli-cated by the degeneracy of the diffusion term at So = 0 and So = 1.

The saturation equation will be approximated with an operator splitting approach. Since the equation is likelyto be advection dominated, it is convenient to solve the advection part with a method tailored to hyperbolicproblems, separately from the diffusion part. Let us individuate explicitly the advection, the diffusion and thereaction part of the equation. The saturation equation in Ω× (0, T ] is:

∂t(ρoφSoJ) = −∇ · (ρoUo) +QoJ

Uo =λoλU− J λoλw

λK(∇pc + (ρw − ρo)JTg)

with homogeneous Dirichlet boundary conditions on ∂Ω and a proper initial condition So(x, 0) = S0(x). In fact,if we assume that the velocity of the oil phase outside the source rock is much higher than that inside the domain,we can impose that only water is present at the boundaries (i.e. So = 0).

Substituting the second equation into the first one, we have

∂t(ρoφSoJ) = −∇ ·

(ρoλoλ

U + Jρoλoλwλ

K(ρw − ρo)JTg)

+∇ ·(ρoJ

λoλwλ

K∇pc)

+QoJ.

Let

F(So) =ρoλo(So)

λ(So)U− Jρo

λo(So)λw(So)

λ(So)K(ρw − ρo)JTg

and

D(So) = ρoJλo(So)λw(So)

λ(So)p′c(So)K.

Since ∇pc(So) = p′c(So)∇So, the saturation equation is

∂t(ρoφSoJ) = −∇ · F(So) +∇ · (D(So)∇So) +QoJ. (16)

We propose the following splitting strategy.

Advection:

φ∗J∗Sn+1/2o − φnJnSno

∆tρo = −∇ · F(Sno ),

10

Page 13: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

Diffusion-Reaction:

φ∗J∗Sn+1o − φ∗J∗Sn+1/2

o

∆tρo = ∇ ·

(D(Sn+1/2

o )∇Sn+1o

)+QoJ.

Figure 1: The function t(i, j) associated to the i-th element of the mesh, its j-th neighbor. In 2D, j = 1, 2, 3.

We solve the advection step, by approximating the flux with a Godunov method. On the i-th element, wehave ∫

Ki

∇ · F(Sno ) dK ≈ 1

Ai

3∑j=0

Fij(Sno i, Sno t(i,j))

where t(i, j) is the function that associates to element i its j-th neighbor (see figure 1), and Fij is defined by:

Fij(S1, S2) =

min

S1≤So≤S2

∫jF(zi, So) · nj if S1 < S2

maxS2≤So≤S1

∫jF(zi, So) · nj if S2 < S1

Using the Godunov method to solve the advection step, we have to verify that the mesh and the timestep aresuch that the CFL condition holds. More precisely we define the CFL number on element i as

CFLi = maxj∈t(i,j)

maxx∈Ki

|F′(ψ(x)) · nj |∆thKi

(17)

and we have to make sure that CFL := maxiCFLi < 1.Under this condition, we compute S

n+1/2o , which we approximate with a piece-wise constant, in each element

of the mesh as

Sn+1/2oi =

φnJn

φ∗J∗Snoi −

∆t

Aiρoφ∗J∗

3∑j=0

Fij(Sno i, Sno t(i,j))

11

Page 14: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

Concerning the solution of the diffusion-reaction step, we use a mixed finite element method. This will allowus to approximate So with a piece-wise constant function, and to avoid an interpolation of saturation betweenthis step and the previous one.

Hence, we introduce an auxiliary variable σn+1 = −D(Sn+1/2o )∇Sn+1

o , and the equation becomes

φ∗J∗Sn+1o − φ∗J∗Sn+1/2

o

∆tρo = −∇ · σn+1 +QoJ.

The degeneracy of the the diffusion coefficient forbids to use mixed methods in their standard formulation. Thiscriticality is avoided if we use the following expanded mixed finite element formulation proposed by Chen. Thisformulation adds another auxiliary variable σn+1 = ∇Sn+1

o and approximates the solution of an equivalent system:

∇ · σn+1 +1

∆tρoφ∗J∗Sn+1

o =1

∆tρoφ∗J∗Sn+1/2

o +QoJ

σn+1 −∇Sn+1o = 0

σn+1 + D(Sn+1/2o )σn+1 = 0.

Multiplying these equations by the three test functions ϕ, τ and ν respectively, integrating over Ω, integratingby parts the second equation and applying the boundary condition, we have∫

Ω∇ · σn+1ϕ dΩ +

∫Ω

1

∆tρoφ∗J∗Sn+1

o ϕ dΩ =

∫Ω

(1

∆tρoφ∗J∗Sn+1/2

o +QoJ

)ϕ dΩ∫

Ωσn+1 · τ dΩ +

∫ΩSn+1o ∇ · τ dΩ +

∫ΓN

Sn+1o τ · n dγ = 0∫

Ωσn+1 · ν dΩ +

∫ΩD(Sn+1/2

o )σn+1 · ν dΩ = 0.

Under the assumptions on the regularity of the coefficients made in paragraph 2.1 and if the capillary pressurepc(So) is such that pc ∈W 1,∞(0, 1), we can set the weak problem as follows:

Weak formulation:

find Sn+1o ∈ L2(Ω), σn+1 ∈ H(div; Ω), σn+1 ∈

(L2(Ω)

)dsuch that the previous integral equations hold

∀ ϕ ∈ L2(Ω), ∀ τ ∈ H(div; Ω) and ∀ ν ∈(L2(Ω)

)d.

Using the finite dimensional spaces IP0(Ω, Th) ⊂ L2(Ω), RT0(Ω, Th) ⊂ H(div; Ω), and RT0(Ω, Th) ⊂(L2(Ω)

)d,

choosing the base ϕii of IP0(Ω, Th) and τ ii of RT0(Ω, Th), we can write the discrete problem in the algebraicform BT 0 M

0 A B + C

A A 0

σσS

=

E00

,

12

Page 15: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

where

Aij =

∫Ωτ i · τ j Aij =

∫ΩD(Sn+1/2

o )τ j · τ i

Bij =

∫Ω∇ · τ i ϕj Cij =

∫ΓN

τ i · n ϕj

Mij =

∫Ω

1

∆tρoφ∗J∗ϕiϕj Ei =

∫Ω

(1

∆tρoφ∗J∗Sn+1/2

o +QoJ

)ϕi

and S,σ, and σ are the coefficients of Sn+1oh ,σn+1

h , and σn+1h with respect to the basis chosen. Some rows of

matrix A can vanish when the diffusion term degenerates, yet the system is still invertible.Let us define the linear operator S that associates to Snh , Ch, φh,Uh, φ

∗h, and C∗h the numerical solution Sn+1

oh

to the saturation equation corresponding to Snh , Ch, φh,Uh, φ∗h, and C∗h:

Sn+1oh = S(Snh , Ch, φh,Uh, φ

∗h, C

∗h).

2.5 The concentration equation

The equation for the concentration∂C

∂t= −k C

is solved numerically with an Implicit Euler scheme. We recall that k is time dependent, since it is a function ofthe temperature T , which is a given function that may depend on time. Thus, we have

Cn+1 − Cn

∆t= −k(Tn+1) Cn+1.

The full discretization of the problem is

Cn+1h =

1

1 + ∆t k(Tn+1)Cnh ,

where Cn+1h , Cnh ∈ IP0(Ω, Th).

We introduce the linear operator C that associates to Ch, the solution Cn+1h of the discrete problem.

13

Page 16: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

3 Implementation

3.1 Overview

The whole problem can be approximated by combing in sequence the solution of four problems. problemSaturationis a class designed to solve the saturation equation (16). In particular, the advection step accomplished with theGodunov method is solved with the class problemGodunov. problemZpde is used for both the stress equation (13)and the equation for the solid matrix movement (11). Finally, problemDarcy is a class that solves the pressureequation (18).

The code was implemented with the support of GetFEM++, a C++ finite element library. The library includesthe tools for the import of meshes and for the construction of regular ones, as well as the usual tools for finiteelement such as assembly procedures for PDEs and interpolation methods. GetFEM++ includes a matrix library,Gmm++. Gmm++ is a generic C++ template library for sparse, dense and skyline matrices.

Let us deal with some GetFEM++ terminology. The mesh is an object composed of convexes. Convexescan be simple line segments, prisms, tetrahedrons, curved triangles, and so on. They all have an associatedreference convex. E.g. for segments, this will be the [0, 1] segment, for triangles this will be the canonical triangle(0, 0) − (0, 1) − (1, 0). All convexes of the mesh are constructed from the reference convex through a geometrictransformation. In order to define the geometric transformation, one defines geometrical nodes on the referenceconvex. The geometric transformation maps these nodes to the mesh nodes. On the mesh, one defines a set abasis functions: the FEM. The basis functions are attached to some geometrical points, the degrees of freedom(DOFs). The set of all basis functions on the mesh forms the basis of a vector space, on which the PDE willbe solved. Clearly, one has to define a FEM for both the unknown functions and the data. The finite elementmethods involve evaluation of integrals of composition of these basis functions on convexes (and faces of convexes),approximated using appropriate quadrature formulas. Hence, at each convex is attached an integration methodalong with the FEM. The process of construction of a global linear system from integrals of basis functions oneach convex is the assembly. A mesh with a set of FEM attached to its convexes is called a mesh fem object inGetFEM++, and a mesh with a set of integration methods attached to its convexes is called a mesh im object.

The project is organized as follows. There are four classes whose task is to solve the differential problemsdescribed above. The two files functions.cpp and functions.h contain the constants and the constitutiverelations, as well as some other useful functions. A data file data.param allows to set the technical data, suchas the finite elements funtions, the mesh description, the penalization and stabilization parameters, and the mostimportant information about the source rock, such as the depth, the permeability parameter and the porosity ofthe non-compacted initial configuration. Finally three different test cases are provided.

3.2 Given functions and files function

All the given functions and constants are specified in the files functions. These data are kept separated, in orderto simply the procedure of changing constitutive relation, such as the porosity law or the relative permeabilities.We report file function.h. Most of the functions are implemented twice: once for the scalar variables and oncefor the vectorial ones.

// ---------------------------------------------------------------------------------

// Some given coefficients --------------------------------------------------------

// ---------------------------------------------------------------------------------

// The densities and viscosities

14

Page 17: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

const s c a l a r t y p e w a t e r v i s c o s i t y = 0 . 0 0 1 ; // [Pa s]

const s c a l a r t y p e o i l v i s c o s i t y = 0 . 0 0 2 ; // [Pa s]

const s c a l a r t y p e wate r dens i ty = 1 0 0 0 . ; // [kg/m3]

const s c a l a r t y p e o i l d e n s i t y = 7 5 0 . ; // [kg/m3]

const s c a l a r t y p e ke rogen dens i ty = 1 1 5 0 . ; // [kg/m3]

const s c a l a r t y p e r o c k d e n s i t y = 2 5 0 0 . ; // [kg/m3]

// The coefficients of the arrhenius law

const s c a l a r t y p e ar rhen iusFacto r = 1E12 ; // [1/s]

const s c a l a r t y p e act ivat ionEnergy = 200 .0E3 ; // [J/mol]

const s c a l a r t y p e gasConstant = 8 .314472 ; // [J/ (K mol)]

// The gravity acceleration

const s c a l a r t y p e g = 9 . 8 1 ; // [m/s2]

// The coefficient for the permeability function

const s c a l a r t y p e DarcyTOm2 = 0.987∗1E−12; // conversion factor from Darcy to squared meters

// The coefficients of the permeability tensor

const s c a l a r t y p e k xx = 1 . ; // [-]

const s c a l a r t y p e k xz = 0 . ; // [-]

const s c a l a r t y p e k zz = 1 . ; // [-]

// The coefficients of the capillary pressure function

const s c a l a r t y p e PD = 1E6 ; // [Pa]

const s c a l a r t y p e a c e n t r i c f a c t o r = 0 . 6 6 4 ; // [-]

const s c a l a r t y p e m = 0.48508 + 1.55171∗ a c e n t r i c f a c t o r − 0.151613∗ a c e n t r i c f a c t o r ∗ a c e n t r i c f a c t o r ; //

[-]

// ---------------------------------------------------------------------------------

// Some given functions -----------------------------------------------------------

// ---------------------------------------------------------------------------------

// Arrehnius constant for kerogen breakdown as a function of temperature [C]

inline s c a l a r t y p e arrheniusK ( s c a l a r t y p e T) return ar rhen iusFacto r ∗exp(−act ivat ionEnergy /( gasConstant ∗(T+273.0) ) ) ;

// The capillary pressure function [Pa] and its first derivative wrt Sw [Pa]

s c a l a r t y p e c a p i l l a r y p r e s s u r e ( const s c a l a r t y p e &Sw) ;s c a l a r t y p e c a p i l l a r y p r e s s u r e p r i m e ( const s c a l a r t y p e &Sw) ;

// Functions that compute water mobility [(Pa s)^-1]

std : : vector<s c a l a r t y p e> lambda w ( const std : : vector<s c a l a r t y p e> &S w ) ;

inline s c a l a r t y p e lambda w ( const s c a l a r t y p e &S w ) return S w∗S w∗S w/ w a t e r v i s c o s i t y ;

// Functions that compute the first derivative of water mobility [(Pa s)^-1]

std : : vector<s c a l a r t y p e> lambda prime w ( const std : : vector<s c a l a r t y p e> &S w ) ;

inline s c a l a r t y p e lambda prime w ( const s c a l a r t y p e &S w ) return 3 .∗ S w∗S w/ w a t e r v i s c o s i t y ;

// Functions that compute oil mobility [(Pa s)^-1]

std : : vector<s c a l a r t y p e> lambda o ( const std : : vector<s c a l a r t y p e> &S o ) ;

inline s c a l a r t y p e lambda o ( const s c a l a r t y p e &S o ) return S o∗S o ∗ ( 1 . − ( 1 . − S o ) ∗ ( 1 . − S o ) ) / o i l v i s c o s i t y ;

15

Page 18: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

// Functions that compute the first derivative of oil mobility [(Pa s)^-1]

std : : vector<s c a l a r t y p e> lambda prime o ( const std : : vector<s c a l a r t y p e> &S o ) ;

inline s c a l a r t y p e lambda prime o ( const s c a l a r t y p e &S o ) return 2 .∗ S o ∗ ( 1 . − ( 1 . − S o ) ∗ ( 1 . − S o ) ) / o i l v i s c o s i t y + S o∗S o ∗ ( 2 . ∗ ( 1 . − S o ) ) / o i l v i s c o s i t y ;

// Function that compute the porosity at t^n+1 [-]

std : : vector<s c a l a r t y p e> computeAthyPorosity ( const std : : vector<s c a l a r t y p e> &phi o ld , const std : : vector<s c a l a r t y p e> &C 0 , const s c a l a r t y p e &phi 0 ,

const std : : vector<s c a l a r t y p e> &C new , const std : : vector<s c a l a r t y p e> &sigma new , const std : : vector<s c a l a r t y p e> &sigma old , const s c a l a r t y p e beta ) ;

// Function that computes the density of the solid matrix [kg/m3]

inline s c a l a r t y p e so l idMatr ixDens i ty ( s c a l a r t y p e C, s c a l a r t y p e C 0 ) return ( ( 1 . − C 0 ) ∗ r o c k d e n s i t y + C∗ ke rogen dens i ty ) / ( 1 . − C 0 + C) ;

// Function that computes the fluid density [kg/m3]

std : : vector<s c a l a r t y p e> f l u i d D e n s i t y ( std : : vector<s c a l a r t y p e> S o ) ;

// Function that computes the concentration at t^n+1 [m3_ker/m3_rock]

std : : vector<s c a l a r t y p e> computeConcentration ( const std : : vector<s c a l a r t y p e> &C old , const std : : vector<s c a l a r t y p e> K new , const s c a l a r t y p e d e l t a t ) ;

// Functions that compute the Jacobian determinant of the trasformation from the phyisical domain to the

reference one [-]

inline s c a l a r t y p e J ( const s c a l a r t y p e &C, const s c a l a r t y p e &C 0 , const s c a l a r t y p e &phi ) return ( 1 . − C 0 + C) / ( ( 1 . − C 0 ) ∗ ( 1 . − phi ) ) ;

std : : vector<s c a l a r t y p e> J ( const std : : vector<s c a l a r t y p e> &C, const std : : vector<s c a l a r t y p e> &C 0 , const

std : : vector<s c a l a r t y p e> &phi ) ;

// Functions that compute the scalar permeability (i.e. the function that multiplies the permeability

tensor) [m2]

s c a l a r t y p e s c a l a r P e r m e a b i l i t y ( const s c a l a r t y p e &phi , const s c a l a r t y p e &K0) ;

std : : vector<s c a l a r t y p e> s c a l a r P e r m e a b i l i t y ( const std : : vector<s c a l a r t y p e> &phi , const s c a l a r t y p e &K0) ;

// Function that computes the numerical flux [kg/(m2 s)]

s c a l a r t y p e f l u x f u n c t i o n ( const s c a l a r t y p e &So , const s c a l a r t y p e &un , const s c a l a r t y p e &gn , const

s c a l a r t y p e &phi , const s c a l a r t y p e &K0) ;

// Function that computes the first derivative of the numerical flux wrt So [kg/(m2 s)]

s c a l a r t y p e f l u x f u n c t i o n p r i m e ( const s c a l a r t y p e &So , const s c a l a r t y p e &un , const s c a l a r t y p e &gn ,const s c a l a r t y p e &phi , const s c a l a r t y p e &K0) ;

// ---------------------------------------------------------------------------------

// Some useful functions ----------------------------------------------------------

// ---------------------------------------------------------------------------------

// A function that computes the index of the node of the mesh associated to the i-th dof of the fem mf.

s i z e t y p e do f t o node index ( const s i z e t y p e &i , const getfem : : mesh &mesh , const getfem : : mesh fem &mf) ;

// A function that converts an integer number into a string containing that number

std : : s t r i n g conve r t In t ( s i z e t y p e number ) ;

16

Page 19: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

3.3 The classes

For each differential problem described above, a correspondent class was designed, which implements the solutiondiscussed. All the classes have a very similar structure to each other. The public attributes of the classes, inaddition to the constructor and destructor and to the setter functions, are in most cases the functions assembly,solve, exportMatrix, and exportVtk . Function assembly assemblies the algebraic system associated to thedifferential problem, by using the assembling tools provided by GetFEM++. Each brick of the matrix is built bycalling the associated operator (in the correspondent header file operators), then function assembly organizesthe bricks to compose the full algebraic system. The sparse matrix built by this function can be exported inMatrix Market format, by applying function exportMatrix. Function solve solves the algebraic system with asuper LU technique provided by Gmm++. Finally function exportVtk exports the solution of the problem in theVisualization Toolkit format.

The constructors of the classes create the object problem based on the coefficients specified. The public settersallow to set the finite element methods for the solution and the coefficients, the integration methods that we wantthe assembling functions to use to compute the integrals, the mesh and it type (i.e. the name of the geometrictransformation which maps the reference convex into the convex of the mesh, according to the classificationprovided by GetFEM++), and the time step. The destructor is in all classes the default one.

3.3.1 Class problemDarcy

This class problemDarcy advances by one time step the solution of the following Darcy-like problem ∇ ·U +mp∂p

∂t= rh

K−1U = −(∇p−G). (18)

One of the assumptions of our model was that the densities of both water and oil were constant and uniform. Onthe other hand, if we had assumed that these densities depend on pressure, we should have taken into accounttheir derivatives with respect to the pressure into the term mp. In our model mp = 0. The boundary conditionsconsistent with the physics of the problem are homogeneous Neumann conditions on both sides of the domain- since we assume that the source rock continues outside the domain in the horizontal direction - and Dirichletconditions at the top and bottom, accounting for the hydrostatic pressure. Hence, if we denote with d > 0 thedepth of the top of the domain and with ztop > 0 its z coordinate, we require

p = ρw g d on Γtop

p = ρw g (d+ ztop) on Γbottom

U · n = 0 on ΓN

.

The boundary conditions are integrated in the class, and the user is only allowed to set the depth of the sourcerock. The class will compute the boundary conditions consistent with the depth.

The private attributes of problemDarcy are the following. The square brackets indicate which kind of finiteelement functions the coefficients are expected to be.

private :

// Time step

17

Page 20: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

s c a l a r t y p e d e l t a t ;

// Data (vectors for the finite element functions and scalar for the constants)

std : : vector<s c a l a r t y p e> KKxx , KKxz , KKzz ; // The inverse permeability tensor [mf_coef]

s c a l a r t y p e gammaU ; // Nitsche penalization parameter for Neumann BCs

std : : vector<s c a l a r t y p e> mp ; // Coefficent of the pressure derivative [mf_coef]

std : : vector<s c a l a r t y p e> rh ; // Right hand side of the first equation [mf_coef]

std : : vector<s c a l a r t y p e> G ; // Modified gravity [mf_coef]

std : : vector<s c a l a r t y p e> pn ; // Previous time -step pressure solution [mf_p]

s c a l a r t y p e depth ; // Depth of the bottom of the basin

//(for the computation of Dirichlet BCs)

// Pointers to the integration methods

const getfem : : mesh im ∗ im v = n u l l p t r ; // Integration method for velocity

const getfem : : mesh im ∗ im p = n u l l p t r ; // Integration method for pressure

// Pointers to the finite element methods

const getfem : : mesh fem ∗mf v = n u l l p t r ; // Finite element method for velocity

const getfem : : mesh fem ∗mf p = n u l l p t r ; // Finite element method for pressure

const getfem : : mesh fem ∗mf coe f = n u l l p t r ; // Finite element method for coefficients

// Vectors containing the region flags of Dirichlet boundary and Neumann boundary

std : : vector<s i z e t y p e> Dir ich letBoundary ;std : : vector<s i z e t y p e> NeumannBoundary ;

// Global matrix , rhs , and solution for the algebraic system

spa r s e mat r i x type A;std : : vector<s c a l a r t y p e> B;std : : vector<s c a l a r t y p e> U;

// Pointers to the vectors where the solutions will be stored

std : : vector<s c a l a r t y p e> ∗U v = n u l l p t r ; // Velocity solution

std : : vector<s c a l a r t y p e> ∗U p = n u l l p t r ; // Pressure solution

// Function that selects Neumann and Dirichlet boundaries

void i n i t i a l i z e B o u n d a r y C o n d i t i o n s ( void ) ;

In our problem, we set

rh =QoJ

ρo− ∂

∂t(φJ).

KKxx , KKxz , and KKzz are the elements of the symmetric tensor K−1, which in our case is

K−1 =

[1

λJK(φ)kxx0

0 JλK(φ)kzz

].

Finally, G is the module of the modified gravity of equation (10).The protected attributes of problemDarcy are all the data concerning the mesh. In fact, we need the mesh to

be accessible by the functions provided by GetFEM++.

protected :// The mesh , its type , and the dimension of the domain

getfem : : mesh ∗mesh p = n u l l p t r ; // Pointer to the mesh

std : : s t r i n g MESH TYPE ; // The mesh type

s i z e t y p e N; // The dimension of the domain

Here are the public attributes of problemDarcy.

18

Page 21: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

public :

// The constructor

problemDarcy ( std : : vector<s c a l a r t y p e> &v e l o c i t y ,std : : vector<s c a l a r t y p e> &pressure ,const std : : vector<s c a l a r t y p e> &mp,const std : : vector<s c a l a r t y p e> &pn ,const std : : vector<s c a l a r t y p e> &rh ,const std : : vector<s c a l a r t y p e> &KKxx,const std : : vector<s c a l a r t y p e> &KKxz,const std : : vector<s c a l a r t y p e> &KKzz ,const std : : vector<s c a l a r t y p e> &G,const s c a l a r t y p e &gammaU,const s c a l a r t y p e &depth ) :

U v(& v e l o c i t y ) , U p(& pre s su r e ) ,mp (mp) , pn (pn) , rh ( rh ) ,KKxx (KKxx) , KKxz (KKxz) , KKzz (KKzz) ,G (G) , gammaU (gammaU) , depth ( depth ) ;

// The default destructor

˜problemDarcy ( ) = default ;

// Public setters

// Sets the integration method for velocity

void s e t In teg ra t i onMethodVe loc i ty ( const getfem : : mesh im &im) ;

// Sets the integration method for pressure

void s e t Integrat ionMethodPres sure ( const getfem : : mesh im &im) ;

// Sets the finite element space for velocity

void s e tF in i t eE l ementVe loc i ty ( const getfem : : mesh fem &mf) ;

// Sets the finite element space for pressure

void s e tF in i t eE l ementPre s sure ( const getfem : : mesh fem &mf) ;

// Sets the finite element space for coefficients

void s e t F i n i t e E l e m e n t C o e f f i c i e n t s ( const getfem : : mesh fem &mf) ;

// Sets the type of the mesh and the mesh itself

void setMesh ( const std : : s t r i n g &MESH TYPE, getfem : : mesh &mesh ) ;

// Sets the time step for the time iteration

void setTimeStep ( const s c a l a r t y p e &d e l t a t ) ;

// Assemblies the algebraic system associated to the weak formulation of the problem

void assembly ( void ) ;

// Solves the algebraic system built with function assembly

void s o l v e ( void ) ;

// Exports the matrix associated to the algebraic system built with function assembly

void exportMatrix ( void ) ;

// Exports the pressure solution of the problem in a .vtk file

void exportVtk ( void ) ;

19

Page 22: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

3.3.2 Class problemZpde

Class problemZpde solves a partial differential equation of type∂σ

∂z= f in Ω

σ = σ on ΓD

with Dirichlet boundary conditions either at the top or at the bottom of the domain, using a SUPG stabilizationtechnique. As we have anticipated, this class will be used to solve both the stress problem and the movement ofthe nodes of the mesh. Hence, in order to make the output and the exported files more readable, we store in thestring name variable the name of the variable, which will be used when referring to the solution of the problem.The default value for this variable is name variable = "ZPDE". Since in case of the stress problem the boundaryconditions are imposed at the top, while in the problem for the movement of the mesh they are imposed at thebottom, it was useful to create the variable where bc , that can contain either the string "top" or "bottom".

In the following, we show the private attributes of problemZpde.

private :

// Data (vectors for the finite element functions and scalar for the constants)

std : : vector<s c a l a r t y p e> f ; // Right hand side of the equation

s c a l a r t y p e d e l t a ; // SUPG stabilization parameter

s c a l a r t y p e s igma bc ; // Dirichlet boundary condition

std : : s t r i n g where bc ; // String containing where to impose the BC ("top" or "bottom ")

std : : s t r i n g name var iab l e ; // String containing the name of the variable

// Pointers to the integration method

const getfem : : mesh im ∗ im = n u l l p t r ; // Integration method for the solution

// Pointers to the finite element methods

const getfem : : mesh fem ∗mf = n u l l p t r ; // Finite element method for the solution

const getfem : : mesh fem ∗mf coe f = n u l l p t r ; // Finite element method for coefficients

// Vector containing the DOFs where Dirichlet BC will be imposed

dal : : b i t v e c t o r d i r i c h l e t D o f s ;

// Global matrix and rhs for the algebraic system

spa r s e mat r i x type A;std : : vector<s c a l a r t y p e> B;

// Pointers to the vector where the solution will be stored

std : : vector<s c a l a r t y p e> ∗U = n u l l p t r ;

// Function that selects the Dirichlet boundary

void i n i t i a l i z e B o u n d a r y C o n d i t i o n s ( void ) ;

As in problemDarcy and in problemSaturation and problemGodunov, the protected attributes of problemZpdeonly consist of all the data concerning the mesh.

protected :// The mesh and its type

getfem : : mesh ∗mesh = n u l l p t r ; // Pointer to the mesh

std : : s t r i n g MESH TYPE ; // The mesh type

The public attributes of problemZpde are the following.

20

Page 23: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

public :

// The constructor

problemZpde ( std : : vector<s c a l a r t y p e> &sigma ,const std : : vector<s c a l a r t y p e> &f ,const s c a l a r t y p e &de l ta ,const s c a l a r t y p e &sigma bc ,const std : : s t r i n g &where bc ,const std : : s t r i n g &name var iab le = "ZPDE" ) :

U(&sigma ) , f ( f ) , d e l t a ( de l t a ) ,s igma bc ( sigma bc ) , where bc ( where bc ) ,name var iab l e ( name var iab le )

// The default destructor

˜problemZpde ( ) = default ;

// Public setters

// Sets the integration method

void se t Integrat ionMethod ( const getfem : : mesh im &im) ;

// Sets the finite element space

void s e tF in i t eE lement ( const getfem : : mesh fem &mf) ;

// Sets the finite element space for coefficients

void s e t F i n i t e E l e m e n t C o e f f i c i e n t s ( const getfem : : mesh fem &mf coe f ) ;

// Sets the type of the mesh and the mesh itself

void setMesh ( const std : : s t r i n g &MESH TYPE, getfem : : mesh &mesh ) ;

// Assemblies the algebraic system associated to the weak formulation of the problem

void assembly ( void ) ;

// Solves the algebraic system built with the function assembly

void s o l v e ( void ) ;

// Exports the matrix associated to the algebraic system built with function assembly

void exportMatrix ( void ) ;

// Exports the pressure and velocity solutions of the problem in a .vtk file

void exportVtk ( void ) ;

3.3.3 Class problemSaturation

Class problemSaturation advances by one time step a nonlinear Advection-Diffusion-Reaction problem withhomogeneous Dirichlet boundary conditions with the following splitting strategy: advection problem is solvedwith the Godunov method (by building an object problemGodunov), and the Diffusion-Reaction part is solvedwith Chen’s mixed formulation, in order to avoid the problems caused by the degeneracy of the diffusion coefficient,as explained in section 2.4. In particular, we consider an equation of the following type:

∂t(fS) = −∇ · F(S) +∇ · (D(S)∇S) +Q

where D(S) is a diagonal matrix of coefficients Dxx(S) and Dzz(S).In the case of our interest, we have

f = ρoφJ, Q = QoJ,

21

Page 24: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

F(S) =ρoλo(S)

λ(S)U + ρo

λo(S)λw(S)

λ(S)(ρw − ρo)K(φ)kzzg eξ,

and

Dxx(S) = ρoλo(S)λw(S)

λ(S)JK(φ)kxx p

′c(S),

Dzz(S) = ρoλo(S)λw(S)

λ(S)

K(φ)kzzJ

p′c(S).

With the notation of section 2.4, S old, f star, and f old represent, respectively, Sn, ρoφ∗J∗, and ρoφ

nJn.Notice that function F also depends on U and K(φ) and functions Dxx and Dzz also depend on C, Kφ, and C0.In our solution the finite element functions φ, C, and C0 are constant on each element of the mesh. Exploitingthis fact, we can compute the numerical flux from element i to its j-th neighbor as∫

jF(zi, So) · nj =

ρoλo(S)

λ(S)

∫jU · nj − ρo

λo(S)λw(S)

λ(S)(ρw − ρo)K(φ)kzz

∫jg · nj

In the file functions.h, which contains all the known functions and the coefficients, the flux function signatureis:

s c a l a r t y p e f l u x f u n c t i o n ( const s c a l a r t y p e &So , const s c a l a r t y p e &un , const s c a l a r t y p e &gn ,const s c a l a r t y p e &phi , const s c a l a r t y p e &K0) ;

This function will be called - during the solution of the problemGodunov solved as the first step - on each edgeof each element and computes the integral

∫j F(zi, So) · nj . The input variables un and gn represent, respectively,

the integrals∫j U · nj and

∫j g · nj , phi is the porosity φ and K0 is the permeability parameter obtained in the

input file (i.e. k0 of equation (7)). In order to avoid passing to the class the information about φ and K0 and totry to give to the class a more general shape, we define outside the class - in our case in the main - the functionwrappers fluxes and fluxesPrime , whose i-th element is a pointer to the function that evaluates the fluxes andits derivative, respectively, on the i-th element of the mesh as a function of So, un, and gn. Each element of thesewrappers is obtained by binding the variables φ and k0 of functions flux function and flux function prime tothat computed and available in the main.

In addition to the finite element functions Q , S old, f star, f old, the constructor needs the four wrappersfluxes , fluxesPrime , Dxx , and Dzz . fluxes and fluxesPrime are wrappers whose i-th element is a pointerto the function that evaluates the fluxes and its derivative, respectively, on the i-th element of the mesh as afunction of S, un, gn. In fact, each element of these wrappers is obtained by binding the variables phi and K0 offunctions flux function and flux function prime to that computed and available in the main:

std : : vector< std : : funct ion<s c a l a r t y p e ( const s c a l a r t y p e &, const s c a l a r t y p e &, const s c a l a r t y p e &) > >f l u x e s ;

for ( s i z e t y p e i = 0 ; i < mf sat . nb dof ( ) ; i++) auto f = [= ] ( const s c a l a r t y p e So , const s c a l a r t y p e un , const s c a l a r t y p e gn )

return f l u x f u n c t i o n ( So , un , gn , p h i o l d s a t [ i ] , K0) ; ;f l u x e s . push back ( f ) ;

std : : vector< std : : funct ion<s c a l a r t y p e ( const s c a l a r t y p e &, const s c a l a r t y p e &, const s c a l a r t y p e &) > >f luxesPr ime ;

22

Page 25: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

for ( s i z e t y p e i = 0 ; i < mf sat . nb dof ( ) ; i++) auto f = [= ] ( const s c a l a r t y p e So , const s c a l a r t y p e un , const s c a l a r t y p e gn )

return f l u x f u n c t i o n p r i m e ( So , un , gn , p h i o l d s a t [ i ] , K0) ; ;f luxesPr ime . push back ( f ) ;

Similarly, the wrappers Dxx and Dzz contain the pointers to the functions that evaluate Dxx and Dzz in eachelement of the mesh.

We list the private attributes of problemSaturation:

private :

// Time step

s c a l a r t y p e d e l t a t ;

// Function wrappers whose i-th element is a function of S, un, gn that defines , respectively ,

// the flux and its derivative at the i-th dof from element i to one of its neighbours j.

const std : : vector< std : : funct ion<s c a l a r t y p e ( const s c a l a r t y p e &, const s c a l a r t y p e &, const s c a l a r t y p e &) > > f l u x e s ;

const std : : vector< std : : funct ion<s c a l a r t y p e ( const s c a l a r t y p e &, const s c a l a r t y p e &, const s c a l a r t y p e &) > > f l uxe sPr ime ;

// Function wrappers whose i-th element is a function of S that defines , respectively ,

// the xx and the zz component of the tensor that represents the diffusion part of the PDE

// at the i-th dof.

const std : : vector< std : : funct ion<s c a l a r t y p e ( const s c a l a r t y p e &) > > Dxx ;const std : : vector< std : : funct ion<s c a l a r t y p e ( const s c a l a r t y p e &) > > Dzz ;

// Data (vectors for the finite element functions and scalar for the constants)

std : : vector<s c a l a r t y p e> U v ; // The total velocity at the previous time step [mf_v]

std : : vector<s c a l a r t y p e> S o l d ; // Previous time step saturation solution [mf]

std : : vector<s c a l a r t y p e> f s t a r ; // Guess of function f at the next time step [mf_coef]

std : : vector<s c a l a r t y p e> f o l d ; // Function f at the current time step [mf_coef]

std : : vector<s c a l a r t y p e> Q ; // The reaction part of the RHS [mf_coef]

// Pointers to the integration methods

const getfem : : mesh im ∗ im = n u l l p t r ; // Integration method for the solution

const getfem : : mesh im ∗ im v = n u l l p t r ; // Integration method for the total velocity

// Pointers to the finite element methods

const getfem : : mesh fem ∗mf = n u l l p t r ; // Finite element method for the solution

const getfem : : mesh fem ∗mf v = n u l l p t r ; // Finite element method for the total velocity

const getfem : : mesh fem ∗mf coe f = n u l l p t r ; // Finite element method for the coefficients

// Pointer to the vector where the solution will be stored

std : : vector<s c a l a r t y p e> ∗S new = n u l l p t r ;

// Matrix , rhs and solution for the DIFFUSION STEP

spa r s e mat r i x type globalA ;std : : vector<s c a l a r t y p e> globalR ;std : : vector<s c a l a r t y p e> globalU ;

// Vectors that will store the solutions to the two steps

std : : vector<s c a l a r t y p e> S step1 , S s tep2 ;

// Function that solves the first step (Godunov)

void so lveStep1 ( void ) ;// Function that assemblies the algebraic system for the second step

void assemblyStep2 ( void ) ;

23

Page 26: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

// Function that initializes the boundary conditions for the second step

void i n i t i a l i z e B C S t e p 2 ( void ) ;// Function that solves the algebraic system associated to the second step

void so lveStep2 ( void ) ;

The variable S step1 stores the solution of the first step solveStep1, which builds and solves an objectproblemGodunov. Then functions initializeBCStep2, assemblyStep2, solveStep2 solve the second step. Thesefunctions are private and are called by the public function solve. Concerning the boundary conditions, they areimposed in the second step, that of diffusion and reaction. In this problem too boundary conditions are integratedin the class and cannot be chosen by the user.

As in the other classes, the constructor sets the coefficients; the mesh, the finite elements, and the integrationmethods are set by the public setter functions.

public :// The constructor

problemSaturat ion ( std : : vector<s c a l a r t y p e> &S new ,const std : : vector< std : : funct ion<s c a l a r t y p e ( const s c a l a r t y p e &, const s c a l a r t y p e &,

const s c a l a r t y p e &) > > &f luxe s ,const std : : vector< std : : funct ion<s c a l a r t y p e ( const s c a l a r t y p e &, const s c a l a r t y p e &,

const s c a l a r t y p e &) > > &fluxesPr ime ,const std : : vector<s c a l a r t y p e> &U v ,const std : : vector<s c a l a r t y p e> &S old ,const std : : vector<s c a l a r t y p e> &f s t a r ,const std : : vector<s c a l a r t y p e> &f o l d ,const std : : vector< std : : funct ion<s c a l a r t y p e ( const s c a l a r t y p e &) > > &Dxx ,const std : : vector< std : : funct ion<s c a l a r t y p e ( const s c a l a r t y p e &) > > &Dzz ,const std : : vector<s c a l a r t y p e> &Q)

: S new (&S new ) , f l u x e s ( f l u x e s ) , f l uxe sPr ime ( f luxesPr ime ) ,U v ( U v ) , S o l d ( S o ld ) ,f s t a r ( f s t a r ) , f o l d ( f o l d ) , Dxx (Dxx) , Dzz ( Dzz ) , Q (Q)

// The default destructor.

˜ problemSaturat ion ( ) = default ;

// Public setters

[ . . . ]

// Solves the problem in the two steps described above.

void s o l v e ( void ) ;

// Exporters

[ . . . ]

3.3.4 Class problemGodunov

Class problemGodunov advances by one time step the solution of a generic problem

∂t(fS) = −∇ · F(S)

with the Godunov method. The private attributes of class problemGodunov are the following:

private :

// Time step

s c a l a r t y p e d e l t a t ;

24

Page 27: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

// Function wrappers whose i-th element is a function of S, un, gn that defines , respectively , the

flux and its derivative at the i-th dof from element i to one of its neighbours j.

const std : : vector< std : : funct ion<s c a l a r t y p e ( const s c a l a r t y p e &, const s c a l a r t y p e &, const

s c a l a r t y p e &) > > f l u x e s ;const std : : vector< std : : funct ion<s c a l a r t y p e ( const s c a l a r t y p e &, const s c a l a r t y p e &, const

s c a l a r t y p e &) > > f l uxe sPr ime ;

// Data (vectors for the finite element functions and scalar for the constants)

std : : vector<s c a l a r t y p e> U v ; // The total velocity at the previous time step [mf_v

]

std : : vector<s c a l a r t y p e> S o l d ; // Previous time step saturation solution [mf]

std : : vector<s c a l a r t y p e> f s t a r ; // Guess of function f at the next time step [mf_coef

]

std : : vector<s c a l a r t y p e> f o l d ; // Function f at the current time step [mf_coef]

// Pointers to the integration methods

const getfem : : mesh im ∗ im = n u l l p t r ; // Integration method for the solution

const getfem : : mesh im ∗ im v = n u l l p t r ; // Integration method for the total velocity

// Pointers to the finite elements methods

const getfem : : mesh fem ∗mf = n u l l p t r ; // Finite elements method for the solution

const getfem : : mesh fem ∗mf v = n u l l p t r ; // Finite elements method for the total velocity

// neigh_convex(j, k) = the k-th convex neighbour (k = 0, 1, 2) of convex j

spa r s e mat r i x type ne igh convex ;// neigh_dof(i, k) = the k-th dof neighbour (k = 0, 1, 2) of dof j

spa r s e mat r i x type ne i gh do f ;

// For each convex i, GdotN(i, j) contains the integral of g dot N over the j-th edge

// and UdotN(i, j) contains the integral of u dot N over the j-th edge

spa r s e mat r i x type UdotN ;spa r s e mat r i x type GdotN ;

// Pointer to the vector where the solution will be stored

std : : vector<s c a l a r t y p e> ∗S new = n u l l p t r ;

// Function that solves the Riemann problem associated to each element

s c a l a r t y p e problemRiemann ( const s c a l a r t y p e &S1 , const s c a l a r t y p e &S2 , const s c a l a r t y p e &un , const

s c a l a r t y p e &gn ,const s i z e t y p e &element ) ;

The wrappers and the data have the same meaning as that in problemSaturation. fluxesPrime will beused when verifying whether the CFL condition holds. In addition, there are four sparse matrices: neigh convex,neigh dof, UdotN, GdotN. The two first matrices store, respectively, the near convexes and the near degrees offreedom. For example, element (j, k) of matrix neigh convex contains the index of the k-th convex neighboringconvex number j. The same happens for matrix neigh dof. The information on neighbors is crucial when solvingthe Riemann problem across each edge of each convex. The matrices UdotN and GdotN store in element (i, j) theintegral of U ·n and g ·n, respectively, on the j-th edge of convex i. The private function problemRiemann is calledfor each edge of each convex, and computes, given the index element of the convex considered, the saturation S1

at the previous time step on that convex, the saturation S2 at the previous time step of the neighbor of elementacross the edge considered, and the two integrals of U · n and g · n on the edge considered, returns

Fij(S1, S2) =

min

S1≤So≤S2

∫jF(zi, So) · nj if S1 < S2

maxS2≤So≤S1

∫jF(zi, So) · nj if S2 < S1

.

25

Page 28: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

Again, the protected elements are the information on the mesh. The public elements are the following:

public :// The constructor

problemGodunov ( std : : vector<s c a l a r t y p e> &S new ,const std : : vector< std : : funct ion<s c a l a r t y p e ( const s c a l a r t y p e &, const s c a l a r t y p e &,

const s c a l a r t y p e &) > > &f luxe s ,const std : : vector< std : : funct ion<s c a l a r t y p e ( const s c a l a r t y p e &, const s c a l a r t y p e &,

const s c a l a r t y p e &) > > &fluxesPr ime ,const std : : vector<s c a l a r t y p e> &U v ,const std : : vector<s c a l a r t y p e> &S old ,const std : : vector<s c a l a r t y p e> &f s t a r ,const std : : vector<s c a l a r t y p e> &f o l d )

: S new (&S new ) , f l u x e s ( f l u x e s ) , f l uxe sPr ime ( f luxesPr ime ) ,U v ( U v ) , S o l d ( S o ld ) , f s t a r ( f s t a r ) , f o l d ( f o l d )

// The default destructor

˜problemGodunov ( ) = default ;

//! @name Public setters

[ . . . ]

// Prepares the matrix of neighbors and computes the components of gravity and velocity along the

outwards normal to each element of the mesh

void i n i t i a l i z e ( void ) ;

// Solves the Riemann Problem correspondent to each edge of each element of the mesh

void s o l v e ( void ) ;

// This function checks if the CFL condition holds

void checkCFL ( void ) ;

The public function initialize computes the neighbor matrices neigh convex and neigh dof, and computesthe matrices UdotN and GdotN. Function checkCFL checks if the CFL condition (17) holds.

3.4 The input file

In the input file we allow the user to specify the following parameters:

• The physical dimensions of the domain, and the initial depth of its top. The information on the depth isused when computing the hydrostatic boundary condition for pressure, the boundary condition for stress,the temperature in the source rock, which is used in the Arrhenius law for the quantification of kerogenbreakdown;

• The sedimentation velocity, which is used at each time step to compute the depth of the source rock;

• The geothermal gradient of temperature, which is used at each time step to compute the temperature of thesource rock;

• The permeability coefficient k0 and the initial porosity of the non-compacted configuration. These parametersmay change a lot from source rock to source rock;

• The coefficient in the porosity law β;

• The resolution of the mesh and its type, according to GetFEM++ classification of the geometric transfor-mation from the reference element to the element of the mesh;

26

Page 29: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

• The integration methods and the finite elements (for velocity, pressure, stress, saturation);

• The time step, the number of time iteration, and, if necessary, the maximum number of fixed point iterations;

• How often to export the solution in vtk format (we export the solution each PLOT AT time steps);

• The two parameters for the penalization of boundary conditions and for the stabilization of problemZpde.

Here is an example of input file.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% parameters %

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% The domain

%%

%% - sea level ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

%% |

%% |

%% - -DEPTH ----------- _______________ z ^

%% | (0, LZ) | | (LX , LZ) |

%% | | | |

%% | | | |

%% - (0, 0) |_______________| (LX , 0) -------> x

%% |

%%

LX =100.0; % The length of the domain along x-axis [m]

LZ = 100.0; % The length of the domain along z-axis [m]

DEPTH = 2000.; % Initial depth of the top of the domain [m]

%% Sedimentation velocity

SEDIM_VEL = 1.585E-12; % [m/s]

%% Geothermal gradient of temperature

GRAD_T = 0.035; % [C/m]

%% Permeability coefficient

K0 = 1E-5; % [Darcy]

%% Initial porosity of the non -compacted configuration

PHI0 = 0.7; % [-]

%% Stress coefficient

BETA = 1E-7; % [Pa^-1]

%% The mesh

NX =30.; % Number of triangles along x-axis

NZ =30.; % Number of triangles along z-axis

MESH_TYPE = ’GT_PK (2,1)’;

%% The finite elements methods

POLYNOMIAL_DEGREE = "1";

FEM_TYPE_V = ’FEM_RT0 (2)’;

FEM_TYPE_P = ’FEM_PK (2,0)’;

27

Page 30: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

FEM_TYPE_STR = ’FEM_PK (2,1)’;

FEM_TYPE_SAT = ’FEM_PK (2,0)’;

%% The integration mehods

INTEGRATIONV = ’IM_TRIANGLE (6)’;

INTEGRATIONP = ’IM_TRIANGLE (1)’;

INTEGRATIONSTR = ’IM_TRIANGLE (2)’;

INTEGRATIONSAT = ’IM_TRIANGLE (1)’;

SIMPLEX_INTEGRATION= ’IM_STRUCTURED_COMPOSITE(IM_TRIANGLE (3) ,1)’;

% The timestep and the number of time iterations

deltaT = 1E13; % [s]

N_ITER = 1500; % [-]

N_FIXED_POINT_MAX = 100; % [-]

% Export solution each PLOT_AT iterations

PLOT_AT = 1;

% Nitsche penalization parameter for Darcy problem

GammaU = 5000000.0; % [-]

% SUPG parameter for the stress problem

delta = 50000.; % [-]

28

Page 31: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

4 Tests

The following tests were conducted in a 100 m squared domain initially at the depth of 2000 m, with a 30 × 30regular mesh built with the tools provided by GetFEM++. When necessary (i.e. in the test of Darcy andcompaction and in the full test) the penalization and stabilization parameters were γU = 5 106 and δ = 5 104.Where compaction were considered, a sedimentation velocity of 500 m per 10 My was set. And when the presenceof chemical reactions was assumed, a geothermal gradient of 3.5 C per 100 m was considered.

4.1 Test of Darcy problem and compaction

In this test we consider a rock only filled with water and with no kerogen (C(x, t) = C0 = 0). Thus no oil canbe generated (So(x, t) = S0

o = 0). The initial conditions for pressure consist of an hydrostatic pressure and theinitial conditions for the effective stress and the porosity are obtained with some fixed point iterations, startingfrom a uniform porosity equal to the porosity of the initial non compacted configuration φ0 = 0.5, computingthe overload corresponding to that porosity, and computing the effective stress as the overload less the initialpressure in pores. In this test we consider a progressive sedimentation of the layers above the domain during the50 My simulated. This fact causes a progressive increment of the depth of the domain, which cause the boundaryconditions for both overload and pressure to change.

With the notation of section 2, at each time iteration, known φn, pn, and σne , we solve the stress equation andset

σn+1T = Σ(C0, φn, S0

o).

We can compute the effective stress as σn+1e = σn+1

T − pnf , and the porosity as

φn+1 = Φ(C0, σn+1e ).

Finally we compute the total velocity Un+1 and global pressure pn+1:(Un+1, pn+1

)= P(C0, φn+1, S0

o ,∆(φJ)),

where we choose ∆(φJ) = φn+1J(C0, C0, φn+1)− φnJ(C0, C0, φn).Instability problems were observed with small time steps, i.e. ∆t . 1010s, so in this case, some fixed point

iteration were necessary. These instabilities were observed to worsen with small permeability coefficients k0. Thestop condition used is based on the variations of the Jacobian J(C,C0, φ), which accounts for the movement ofthe physical domain. Thus, set Jn+1

k the vector of the DOFs of the finite element function J(C0, C0, φn+1k ) we

check for each fixed point iteration k < Kmax if

||Jn+1k − Jn+1

k−1 ||2||Jn+1

k ||2< tol,

We take a time step ∆t = 1013 and 150 time iterations.In figure 4.1 we can clearly observe the progressive compaction of the physical domain. This compaction can

also be observed in figure 4.1, as φ increases significantly from the beginning to the end of the simulation in thewhole domain. We can also observe the behavior of porosity which, coherently with the behavior of the effectivestress (see figure 4.1), is much lower at the top of the domain than at the bottom.

29

Page 32: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

Figure 2: The deformation of the physical domain. The three snapshots were taken at t = 0, t = 27 My andt = 50My.

Figure 3: The evolution of porosity φ. The two snapshots were taken at t = 0 and t = 50 My, i.e. at the beginningand at the end of the simulation.

Figure 4: The evolution of the effective stress σe. The two snapshots were taken at t = 0 and t = 50 My, i.e. atthe beginning and at the end of the simulation.

30

Page 33: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

4.2 Test of Saturation problem

In this second test case, we consider a rock with no kerogen (C(x, t) = C0 = 0), initially filled with water, exceptfor a bubble of oil. Porosity is assumed to be constant (φ(x, t) = φ0 = 0.3) and no sedimentation effects areconsidered. Finally, we set U = 0, i.e. the velocity of the water phase has equal module but is opposite to thatof the oil phase. Under these assumptions, we solve the saturation equation, in order to simulate the movementof the oil bubble.

Known Sno , we solve the saturation equation and set

Sn+1o = S(Sno , C

0, φ0,U0, φ0, C0).

The time step used is ∆t = 1012s and 1500 time iteration were performed. Thus 50 My are simulated.In figure 4.2, we can notice that the oil bubble, being oil lighter than water, moves upward and goes out of

the domain, leaving a contrail of intermediate saturation between oil (So = 0) and water (So = 1).

Figure 5: The oil saturation at t = 0, t = 4 My, t = 7 My, t = 14 My, t = 23 My.

4.3 Test of the full problem

This last test is a test of the full problem. Initially the rock is filled with water and the oil saturation is S0o = 0.

The initial condition for pressure is the hydrostatic pressure and the initial conditions for stress and porosityare computed with some fixed point iterations, starting from a uniform porosity equal to the porosity of thenon-compacted configuration, φ0 = 0.5. We consider an initial brick of kerogen and an initial depth of 2000 m.Finally, U0 = 0 and φ−1 = φ0. Notice that we need two initial conditions for porosity.

This test is conducted neglecting the effects of capillary pressure. Hence only the advection and reaction partof the saturation equation is considered.

Known Cn, φn, φn−1, pn, Sno ,Un, and σne , we solve the concentration equation, which is independent of the

other variables. Thus,Cn+1 = C(Cn).

We then solve the saturation equation and set

Sn+1o = S(Cn+1, φn,Un, φ∗, Cn+1),

where we choose φ∗ = 2φn−φn−1. Once obtain Sn+1o , we can compute pn+1

o , pwn+ 1 and pn+1f from pn, and ρn+1

f

and ρs as

ρn+1s =

(1− C0)ρr + Cn+1ρk1− C0 + Cn+1

.

31

Page 34: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

Then, we solve the stress equation and set

σn+1T = Σ(Cn+1, φn, Sn+1

o ).

We can compute the effective stress as σn+1e = σn+1

T − pn, and the porosity as

φn+1 = Φ(Cn+1, σn+1e ).

Finally we compute the total velocity Un+1 and the pressure of fluids pn+1:(Un+1, pn+1

)= P(Cn+1, φn+1, Sn+1

o ,∆(φJ)),

where we choose ∆(φJ) = φn+1J(Cn+1, C0, φn+1)− φnJ(Cn, C0, φn).As in the first test, in this case too some fixed point iterations of the stress-porosity-Darcy problem were

necessary for the sake of stability. In fact, is this case the CFL condition forces a smaller time step than that inthe first test case. 50 My were simulated with 1500 time iteration of 1012s each.

The following figures represent the physical domain. The progressive compaction due to the increasing verticalstress is clear. We can also observe in the sketches correspondent to 50 My that the region of source rock withpositive initial kerogen concentration compacts more than the neighboring regions.

During the simulation, the burial of the domain caused by sedimentation makes the temperature increase until- after about 15 My - kerogen breakdown starts. In figure 4.3 we can observe the consumption of kerogen, whichtotally vanishes before half simulation.

Figure 6: Kerogen concentration at t = 0, t = 17 My, t = 27 My, t = 40 My, and t = 50 My.

In figure 4.3 we can clearly see how the breakdown of kerogen causes an extra porosity, which will then besubject to compaction until, in the end, no trace of the initial kerogen is visible.

Figure 7: Porosity at t = 0, t = 17 My, t = 27 My, t = 40 My, and t = 50 My.

At the same time, as kerogen is consumed, oil saturation increases, until enough oil is present to be able tomove in the source rock. In figure 4.3 an overpressure (i.e. the pressure in pores less hydrostatic pressure) isshown which does not allow the oil phase to reach the top of the source rock and forces it to move down.

32

Page 35: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

Figure 8: The oil saturation at t = 0, t = 17 My, t = 27 My, t = 40 My, and t = 50 My.

Figure 9: Overpressure at t = 0, t = 17 My, t = 27 My, t = 40 My, and t = 50 My.

In order to understand if this overpressure is physical or distorted by the pressure Dirichlet boundary conditionat the bottom, another test with a Neumann boundary condition that imposes the correct variation of pressurewith depth - ∂p

∂z = −ρwg on Γbot - should be done. However, we point out that industrial applications require apreliminary study of the region which provides more accurate boundary data.

33

Page 36: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

5 Further developments

In this work, we have described and implemented a model for porosity evolution in source rock. An importantissue that was always kept in mind is the trade-off between the specificity of the problem and the generality ofthe solving techniques. Most classes, such as problemDarcy and problemSaturation, were clearly thought to beapplied to our specific problem, and the boundary conditions were ’pushed into’ the class itself. Clearly this lackof generality leaves still much work to do. An important further development consists of building more generalstructures, from which inherit the specialized cases of our interest.

Another important further work direction consists of the improvement of the data reading. In fact, the modelhas many constitutive relations and parameters that may change a lot from one geological setting to one another.For this reason it would be very useful to implement a parser able to read input functions, such as the porosityequation, the relative permeabilities, the permeability tensor, as well as the many initial and boundary conditions.This would allow to use the code in many different cases with no need of recompiling it each time we want tochange a datum. The input file can also be improved in order to allow the user to specify which variables have tobe exported.

As we have seen in section 4, a constraining issue that can be overstepped is that of CFL condition. In fact,by tuning a time step adaptivity based on this condition, we can set an initial time step and reduce it runtime incase, at some time iteration, the CFL condition did not hold.

Little modifications could be done in order to remove the hypothesis of constant viscosities, while a little moredemanding would be considering the extension to the case of variable densities with pressure and temperature.

Finally, the most challenging further work is certainly the extension of the whole implementation to the 3Dcase.

34

Page 37: Numerical modeling of porosity evolution in source rock ...forma/Didattica/ProgettiPacs/... · o is a source term that accounts for the generation of oil through the breakdown of

References

[1] Zhangxin Chen, Richard E. Ewing, Hao Lu, Stephen L. Lyons, Serguei Maliassov, Micheal B. Ray, and TongSun. Integrated two-dimensional modeling of fluid flow and compaction in a sedimentary basin. ComputationalGeosciences, 6:545–564, 2002.

[2] Andrew C. Fowler and Xinshe Yang. Fast and slow compaction in sedimentary basins. SIAM Journal onApplied Mathematics, 59(1):365–385, 1998.

[3] Andrew C Fowler and Xinshe Yang. Pressure solution and viscous compaction in sedimentary basins. Journalof geophysical research, 104(B6):12989–12997, 1999.

[4] Marte Gutierrez and Magnus Wangen. Modeling of compaction and overpressuring in sedimentary basins.Marine and Petroleum Geology, 22(3):351–363, March 2005.

[5] X Luo, G Vasseur, and A Pouya. Elastoplastic deformation of porous media applied to the modelling ofcompaction at basin scale. Marine and Petroleum Geology, 15(2), 1998.

[6] Magnus Wangen. Pressure and temperature evolution in sedimentary basins. Geophysical Journal Interna-tional, 110(3):601–613, 1992.

[7] Magnus Wangen. Vertical migration of hydrocarbons modelled with fractional flow theory. GeophysicalJournal International, 115(1993):109–131, 1993.

[8] Magnus Wangen. Two-phase oil migration in compacting sedimentary basins modelled by the finite elementmethod. Int. J. Numer. and Analytical Meth. in Geomechanics, 21(June 1995):91–120, 1997.

[9] Magnus Wangen. Modeling porosity evolution and cementation of sandstones. Marine and petroleum geology,1998.

[10] Xinshe Yang. Mathematical modelling of compaction and diagenesis in sedimentary basins. PhD thesis,Oxford, 1997.

[11] Xinshe Yang. Nonlinear viscoelastic compaction in sedimentary basins. arXiv preprint arXiv:1003.5373, 2010.

35