www.bu.edu pasi files 2011 01 luisdelacruz1!11!1700

Upload: tsarphilip2010

Post on 03-Jun-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    1/61

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    Computational Methods for Oil RecoveryPASI: Scientific Computing in the Americas

    The Challenge of Massive Parallelism

    Luis M. de la Cruz Salas

    Instituto de Geofsica

    Universidad Nacional Autonoma de Mexico

    January 2011

    Valparaso, Chile

    Comp EOR LMCS 1 / 43

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    2/61

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    Mathematical and Computational Group (GMMC)

    Natural Resources Dept.Dr. Ismael Herrera Revilla

    Dra. Graciela Herrera Zamarron

    Dr. Luis M. de la Cruz Salas

    Dr. Guillermo Hernandez Garca

    Dr. Norberto Vera Guzman

    Students

    Esther Leyva

    Antonio Carrillo

    Ivan Contreras

    Alberto Rosas

    Emilio Zavala

    Ricardo Flores

    Computational Group

    Daniel A. Cervantes Cabrera

    Alejandro Salazar SanchezDaniel Monsivais Velazquez

    Renato Leriche Vazquez

    Hector U. Barron Garca

    Ismael Herrera Zamarron

    Eduardo Murrieta Leon

    http://www.mmc.geofisica.unam.mx

    Comp EOR LMCS 2 / 43

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    3/61

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    Table of contents

    1 Oil Reservoir SimulationMotivation

    2 General Math & Num Models

    Axiomatic FormulationNumerical MethodsFinite Volume Method

    3 Computational Approach

    TUNA

    4 References

    Comp EOR LMCS 3 / 43

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    4/61

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    Motivation

    Table of contents

    1 Oil Reservoir SimulationMotivation

    2 General Math & Num Models

    Axiomatic FormulationNumerical MethodsFinite Volume Method

    3 Computational Approach

    TUNA

    4 References

    Comp EOR LMCS 4 / 43

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    5/61

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    Motivation

    Oil Reservoir Projects

    Funded by PEMEX

    Comp EOR LMCS 5 / 43

    O l R S l G l M h & N M d l C l A h R f

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    6/61

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    Motivation

    Oil Reservoir Projects

    Funded by PEMEX

    Collaboration with IMP and CIMAT.

    Comp EOR LMCS 5 / 43

    Oil R i Si l ti G l M th & N M d l C t ti l A h R f

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    7/61

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    Motivation

    Oil Reservoir Projects

    Funded by PEMEX

    Collaboration with IMP and CIMAT.

    1 WAG injection.

    Comp EOR LMCS 5 / 43

    Oil R s i Sim l ti G l M th & N m M d ls C m t ti l A h R f s

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    8/61

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    Motivation

    Oil Reservoir Projects

    Funded by PEMEX

    Collaboration with IMP and CIMAT.

    1 WAG injection. 2 AIR injection.

    Comp EOR LMCS 5 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    9/61

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    Motivation

    Oil Reservoir Projects

    Funded by PEMEX

    Collaboration with IMP and CIMAT.

    1 WAG injection. 2 AIR injection. 3 SLS method.

    Comp EOR LMCS 5 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    10/61

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    Motivation

    Oil Reservoir Projects

    Funded by PEMEX

    Collaboration with IMP and CIMAT.

    1 WAG injection. 2 AIR injection. 3 SLS method.

    Oil reservoir simulation is a grand challenge.

    Comp EOR LMCS 5 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    11/61

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    Motivation

    The major goal of reservoir simulation is to predict futureperformance of reservoir and find ways and means of optimizing

    the recovery of some of the hydrocarbons under various operatingconditions.

    Comp EOR LMCS 6 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    12/61

    O Rese vo S u at o Ge e a at & u ode s Co putat o a pp oac Re e e ces

    Motivation

    The major goal of reservoir simulation is to predict futureperformance of reservoir and find ways and means of optimizing

    the recovery of some of the hydrocarbons under various operatingconditions.It involves four main interrelated modeling stages:

    Comp EOR LMCS 6 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    13/61

    p pp

    Motivation

    The major goal of reservoir simulation is to predict futureperformance of reservoir and find ways and means of optimizing

    the recovery of some of the hydrocarbons under various operatingconditions.It involves four main interrelated modeling stages:

    And requires a combination of skills of physicists, mathematicians,

    reservoir engineers, and computer scientists.Comp EOR LMCS 6 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    14/61

    Motivation

    Software Engineering (IEEE Comput Societys Software Eng. Body of Knowledge)

    Application of a systematic, disciplined, quantifiable approach to the development,operation, and maintenance of software, and the study of these approaches; that is, theapplication of engineering to software.

    Unified Process (UP, Boochet al. [2])

    Comp EOR LMCS 7 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    15/61

    Motivation

    Software Engineering (IEEE Comput Societys Software Eng. Body of Knowledge)

    Application of a systematic, disciplined, quantifiable approach to the development,operation, and maintenance of software, and the study of these approaches; that is, theapplication of engineering to software.

    Unified Process (UP, Boochet al. [2])

    Comp EOR LMCS 8 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    16/61

    Motivation

    Software Engineering (IEEE Comput Societys Software Eng. Body of Knowledge)

    Application of a systematic, disciplined, quantifiable approach to the development,operation, and maintenance of software, and the study of these approaches; that is, theapplication of engineering to software.

    Unified Process (UP, Boochet al. [2])

    Requirements

    EfficiencyAccuracyAbstraction

    Comp EOR LMCS 8 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    17/61

    Motivation

    Software Engineering (IEEE Comput Societys Software Eng. Body of Knowledge)

    Application of a systematic, disciplined, quantifiable approach to the development,operation, and maintenance of software, and the study of these approaches; that is, theapplication of engineering to software.

    Unified Process (UP, Boochet al. [2])

    Requirements

    EfficiencyAccuracyAbstraction

    We get a software:

    ModularMantainableReliableEfficientProductive

    Comp EOR LMCS 8 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    18/61

    Motivation

    Oil production stages

    First stage of oil reservoir production, primary recovery, the oilis extracted by natural drive mechanism.

    Comp EOR LMCS 9 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    19/61

    Motivation

    Oil production stages

    First stage of oil reservoir production, primary recovery, the oilis extracted by natural drive mechanism.

    The reservoir pressure can be maintained, using techniques such asgas or water injection. This is known as secondary recovery.

    Comp EOR LMCS 9 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    20/61

    Motivation

    Oil production stages

    First stage of oil reservoir production, primary recovery, the oilis extracted by natural drive mechanism.

    The reservoir pressure can be maintained, using techniques such asgas or water injection. This is known as secondary recovery.

    Tertiary or Enhanced Oil Recovery (EOR) is a generic term

    that embraces several techniques used to increase the amount ofcrude oil that can be extracted from an oil field.

    These techniques are based on the injection of materials notnormally present in the reservoir, and is the most advanced stage of

    the exploitation of a reservoir.

    Comp EOR LMCS 9 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    21/61

    Motivation

    Oil production stages

    First stage of oil reservoir production, primary recovery, the oilis extracted by natural drive mechanism.

    The reservoir pressure can be maintained, using techniques such asgas or water injection. This is known as secondary recovery.

    Tertiary or Enhanced Oil Recovery (EOR) is a generic term

    that embraces several techniques used to increase the amount ofcrude oil that can be extracted from an oil field.

    These techniques are based on the injection of materials notnormally present in the reservoir, and is the most advanced stage of

    the exploitation of a reservoir.Primary recovery techniques produce 10 15 % of the reservoirsoil content. Combining the processes of secondary andtertiary recovery techniques, it is possible to produce 30

    60 % of the reservoirs total oil content.

    Comp EOR LMCS 9 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    22/61

    Axiomatic Formulation

    Table of contents

    1 Oil Reservoir SimulationMotivation

    2 General Math & Num Models

    Axiomatic FormulationNumerical MethodsFinite Volume Method

    3 Computational Approach

    TUNA

    4 References

    Comp EOR LMCS 10 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    23/61

    Axiomatic Formulation

    Extensive and Intensive Properties

    In the physical sciences, intensive property(also called a bulkproperty, intensive quantity, or intensive variable), is a physicalproperty of a system that does not depend on the system size or

    the amount of material in the system: it is scale invariant.Density

    By contrast, an extensive property(also extensive quantity,extensive variable, or extensive parameter) of a system is directlyproportional to the system size or the amount of material in the

    system.Mass

    Comp EOR LMCS 11 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    24/61

    Axiomatic Formulation

    Axiomatic Formulation, (Herrera et al. [3, 4]) I

    1 To find extensive Eand intensive properties :

    E(t) =

    B(t)

    (x, t)dx

    2 To establish balances:

    dE

    dt

    = d

    dt

    B(t)

    (x, t)dx= B(t)

    q(x, t)dx+ B(t)

    (x, t) ndS (1)

    where q(x, t)y (x, t)are the source term in B(t)and the fluxvector through the boundary B(t), respectively

    Comp EOR LMCS 12 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    25/61

    Axiomatic Formulation

    Axiomatic Formulation, (Herrera et al. [3, 4]) II

    Global balance

    B(t)

    t + (v)

    dx=

    B(t)

    qdx+

    B(t)

    dx (2)

    Local balance

    t + (v) =q+ (3)

    Comp EOR LMCS 13 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    26/61

    Axiomatic Formulation

    Conservative form

    Defining a flux function (see [5]) as f=v we get:

    t

    B(t)

    dx+

    B(t)

    fdx=

    B(t)

    qdx (4)

    and therefore

    t + f=q (5)

    Equivalently (4) can be written as follows

    t

    B(t)

    dx+

    B(t)

    f ndS=

    B(t)

    qdx (6)

    Comp EOR LMCS 14 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    27/61

    Numerical Methods

    Table of contents

    1 Oil Reservoir SimulationMotivation

    2 General Math & Num Models

    Axiomatic FormulationNumerical MethodsFinite Volume Method

    3 Computational Approach

    TUNA

    4 References

    Comp EOR LMCS 15 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    N i l M th d

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    28/61

    Numerical Methods

    In general, the equations governing a mathematical model of areservoir cannot be solved by analytical methods.

    Comp EOR LMCS 16 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    N i l M th d

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    29/61

    Numerical Methods

    In general, the equations governing a mathematical model of areservoir cannot be solved by analytical methods.

    Instead, a numerical model can be produced in a form that isamenable to solution by digital computers.

    Comp EOR LMCS 16 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    Numerical Methods

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    30/61

    Numerical Methods

    In general, the equations governing a mathematical model of areservoir cannot be solved by analytical methods.

    Instead, a numerical model can be produced in a form that isamenable to solution by digital computers.

    Since the 1950s, numerical models have been used to predict,understand, and optimize complex physical fluid flow processes inpetroleum reservoirs.

    Comp EOR LMCS 16 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    Numerical Methods

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    31/61

    Numerical Methods

    In general, the equations governing a mathematical model of areservoir cannot be solved by analytical methods.

    Instead, a numerical model can be produced in a form that isamenable to solution by digital computers.

    Since the 1950s, numerical models have been used to predict,understand, and optimize complex physical fluid flow processes inpetroleum reservoirs.

    Recent advances in computational capabilities have greatlyexpanded the potential for solving larger problems and hence

    permitting the incorporation of more physics into the differentialequations.

    Comp EOR LMCS 16 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    Numerical Methods

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    32/61

    Numerical Methods

    1 Finite Diferences Method (FDM)

    The FDM can be very easy to implement.Faster than FEM.High accuracy difference schemes can be constructed.In its basic form is restricted to handle only rectangular shapes.Introduce considerable geometrical error and grid orientation effects.Curvilinear coordinates can be used.

    Comp EOR LMCS 17 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    Numerical Methods

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    33/61

    Numerical Methods

    1 Finite Diferences Method (FDM)

    The FDM can be very easy to implement.Faster than FEM.High accuracy difference schemes can be constructed.In its basic form is restricted to handle only rectangular shapes.Introduce considerable geometrical error and grid orientation effects.Curvilinear coordinates can be used.

    2 Finite Element Method (FEM)The FEM cand handle complicated geometries.Reduce the grid orientation effects.Solid theoretical foundations.Can manage local grid refinement.

    The quality of a FEM approximation is often higher than in thecorresponding FDM approach.FEM is the method of choice in structural mechanics.It is not easy to implement and is slower than FDM.

    Comp EOR LMCS 17 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    Numerical Methods

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    34/61

    3 Finite Volume Method (FVM)

    Values are calculated at control volumes.

    Conservative method: the flux entering a given volume is identicalto that leaving the adjacent volume.Can easily be formulated to allow for unstructured meshes.Used in many computational fluid dynamics packages.FVM is in between FDM and FEM: faster and easier to implementthan FEM; and more accurate and versatile than FDM.

    Comp EOR LMCS 18 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    Numerical Methods

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    35/61

    3 Finite Volume Method (FVM)

    Values are calculated at control volumes.

    Conservative method: the flux entering a given volume is identicalto that leaving the adjacent volume.Can easily be formulated to allow for unstructured meshes.Used in many computational fluid dynamics packages.FVM is in between FDM and FEM: faster and easier to implementthan FEM; and more accurate and versatile than FDM.

    In oil-reservoir problems we usually require a large number of cells(105 106), therefore cost of the solution favors simpler and lowerorder approximation within each cell.

    Comp EOR LMCS 18 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    Numerical Methods

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    36/61

    3 Finite Volume Method (FVM)

    Values are calculated at control volumes.

    Conservative method: the flux entering a given volume is identicalto that leaving the adjacent volume.Can easily be formulated to allow for unstructured meshes.Used in many computational fluid dynamics packages.FVM is in between FDM and FEM: faster and easier to implementthan FEM; and more accurate and versatile than FDM.

    In oil-reservoir problems we usually require a large number of cells(105 106), therefore cost of the solution favors simpler and lowerorder approximation within each cell.

    About 80% 90% of the total simulation time is spent on thesolution of linear systems.

    Fast linear solvers are crucial to solve sparse, highly nonsymmetric,and illconditioned systems.Krylov subspace (preconditioned) algorithms are preferred.

    Comp EOR LMCS 18 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    Finite Volume Method

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    37/61

    Table of contents

    1 Oil Reservoir SimulationMotivation

    2 General Math & Num Models

    Axiomatic FormulationNumerical MethodsFinite Volume Method

    3 Computational Approach

    TUNA

    4 References

    Comp EOR LMCS 19 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    Finite Volume Method

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    38/61

    Finite volume methods are derived on the basis of the conservativeform of the balance equations [3, 4, 5].

    t

    B(t)

    dx+

    B(t)

    f dx=

    B(t)

    qdx or

    t

    B(t)

    dx+

    B(t)

    f ndS=

    B(t)

    qdx

    FVM is conservative.

    Comp EOR LMCS 20 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    Finite Volume Method

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    39/61

    Conservative formof general balance equation:

    t

    B(t)

    dx+

    B(t)

    f dx=

    B(t)

    qdx

    Integrating ont and taking B(t) V:

    t

    t

    V

    dV dt+ t

    V

    fdV dt= t

    V

    qdV dt

    xz

    y

    E

    W

    N

    S

    F

    B

    Pee

    ww

    nn

    ss

    ff

    bb

    V = xyz

    Notation:

    NB id

    P i ,j,kE i+ 1, j , k

    W i 1, j , kN i, j+ 1, kS i, j 1, kF i ,j,k+ 1B i ,j,k 1

    nb id

    e i+ 12 , j , kw i 1

    2, j , k

    n i, j+ 12

    , k

    s i, j 12

    , k

    f i ,j,k+ 12

    b i ,j,k 12

    t n; t+ t n+ 1

    t

    g dt

    n+1n

    g dt

    V

    g dV

    f

    b

    ns

    ew

    g dx dy dz

    Comp EOR LMCS 21 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    Finite Volume Method

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    40/61

    Approximation of the integrals:

    n+1

    n

    t

    V

    dV dt

    n+1P n

    P

    V

    n+1n

    V

    f dV dt

    n+1n

    F( fnb

    )dt

    t

    V

    qdV dt

    n+1n

    QV dt

    xz

    y

    E

    W

    N

    S

    F

    B

    Pee

    ww

    nn

    ss

    ff

    bb

    V = xyz

    Theta scheme:

    n+1

    n

    Fdt=

    Fn+1

    + (1 )Fn

    t, 0 1

    Explicit (ForwardEuler) = 0 Fnt.Implicit (BackwardEuler) = 1 Fn+1t.CrankNicolson = 1/2 (Fn + Fn+1)t/2.

    Comp EOR LMCS 22 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    Finite Volume Method

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    41/61

    Recall that f =v :

    F( fnb)

    V

    f dV =

    ew

    ns

    f

    b

    (vx x)x

    +(vy y)

    y +

    (vz z)

    z

    dxdydz

    xz

    y

    E

    W

    N

    S

    F

    B

    Pee

    ww

    nn

    ss

    ff

    bb

    V = xyz

    Discretized flux function:

    F( fnb

    ) = (vx x)e (vx x)wAx+(vy y)n (vy y)s

    Ay+

    (vz z)f (vz z)b

    Az

    where Ax = y z, Ay = x z, Az = x y, represents the area ofthe faces.

    Advectivev and Diffusive terms need to be approximated on the faces.

    Comp EOR LMCS 23 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    Finite Volume Method

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    42/61

    Diffusive terms

    Central differences: e.g. (x)e=D

    x

    e

    =D

    P

    E

    xeAdvective terms

    Average : (vx)e= (vx)e(E+ (1 )P), where = xexP

    xe

    Upstream:

    Upwind

    if ((vx)e >0) thene =P

    else

    e =Eend if

    QUICK (second order

    upstream)

    if ((vx)e >0) thene =h(W, P, E)

    else

    e =h(P, E, EE)end if

    Comp EOR LMCS 24 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    Finite Volume Method

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    43/61

    Implicit, non-linear:

    an

    +1P n

    +1P =an

    +1E n

    +1E +an

    +1W n

    +1W +an

    +1N n

    +1N +an

    +1S n

    +1S +

    an+1F

    n+1F

    +an+1B

    n+1B

    +qnP

    Implicit linear:

    anP

    n+1P

    = anE

    n+1E

    +anW

    n+1W

    +anN

    n+1N

    +anS

    n+1S

    +anF

    n+1F

    +anB

    n+1B

    +qnP

    Explicit:an

    Pn+1

    P =an

    En

    E +a

    Wn

    W+an

    Nn

    N+an

    Sn

    S +an

    Fn

    F +an

    Bn

    B +qn

    P

    Comp EOR LMCS 25 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    Finite Volume Method

    S

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    44/61

    Linear Systems

    Comp EOR LMCS 26 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    TUNA

    T bl f

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    45/61

    Table of contents

    1 Oil Reservoir SimulationMotivation

    2 General Math & Num Models

    Axiomatic FormulationNumerical MethodsFinite Volume Method

    3 Computational Approach

    TUNA

    4 References

    Comp EOR LMCS 27 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    TUNA

    T l t U it f N i l A li ti

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    46/61

    Template Units for Numerical Applications

    Natural convection in box-shaped containers

    Comp EOR LMCS 28 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    TUNA

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    47/61

    f1(t) =

    0.5sin2(4t) for 0 t < /81 for /8 t

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    48/61

    Navier-Stokes equations

    Mass balance:

    ujxj = 0

    Momentum balance (Navier-Stokes):

    0 ui

    t

    +ujui

    xj =

    p

    xi+

    2ui

    xjxj+bi

    Energy balance:T

    t +uj

    T

    xj=

    2T

    xjxj

    Equations of state:

    = 0[1 (T T0)] , = 1

    0

    T

    T=T0

    Comp EOR LMCS 30 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    TUNA

    Template Units for Numerical Applications I

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    49/61

    Template Units for Numerical Applications I

    TUNA use several C++ template techniques (Blitz++).

    Comp EOR LMCS 31 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    TUNA

    Template Units for Numerical Applications II

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    50/61

    Template Units for Numerical Applications II

    http://mmc.geofisica.unam.mx/(then go to my homepage).

    Examples : programs that use TUNA

    |--- tuna-cfd-rules.in => rules to compile the examples

    |--- 01StructMesh => uniform structured meshes

    |--- 02NonUniformMesh => non uniform structured meshes

    |--- 03Laplace => Solution of Laplace equation

    |--- 04HeatDiffusion => Solution of heat conduction problems

    |--- 05ConvDiffForced => Solution of forced convection

    |--- 06ConvDiff => Solution of natural convection problems

    |--- 07ConvDiffLES => Solution of turbulent natural convection

    |--- README.pdf => Explanation of the examples of each directory

    1) Unpack TUNA and change to the TUNA dir:

    % tar zxvf TUNA.tar.gz% cd TUNA

    2) Blitz++: http://www.oonumerics.org/blitz/

    Comp EOR LMCS 32 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    TUNA

    Template Units for Numerical Applications III

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    51/61

    Template Units for Numerical Applications III

    - Unpack with: tar zxvf blitz-09.tar.gz

    - Change to blitz-0.9 with: cd blitz-0.9- Config blitz with: ./configure --prefix=$PWD/../BLITZ

    - Compile and install blitz with: make install

    These instruction will install Blitz in the TUNA/BLITZ directory

    3) Run the examples

    - Change to the Examples directory: cd Examples

    - Edit the files tuna-cfd-rules.in

    Change the environment variable BASE according to your paths.

    (e.g. BASE = /home/luiggi/TUNA)

    - Then, e.g. change to the 06ConvDiff dir:

    % cd 06ConvDiff% make

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    52/61

    Example: Natural Convection I

    #include "Meshes/Uniform.hpp"#include "Storage/DiagonalMatrix.hpp"

    #include "Equations/ScalarEquation.hpp"

    #include "Schemes/CDS_CoDi.hpp"

    #include "Equations/Momentum_XCoDi.hpp"

    #include "Schemes/CDS_XCoDi.hpp"

    #include "Equations/Momentum_YCoDi.hpp"

    #include "Schemes/CDS_YCoDi.hpp"

    #include "Equations/Momentum_ZCoDi.hpp"

    #include "Schemes/CDS_ZCoDi.hpp"

    #include "Equations/PressureCorrection.hpp"

    #include "Schemes/Simplec.hpp"

    #include "Solvers/TDMA.hpp"

    #include "Utils/inout.hpp"#include "Utils/num_utils.hpp"

    #include "Utils/GNUplot.hpp"

    using namespace Tuna;

    typedef TunaArray::huge ScalarField3D;

    Comp EOR LMCS 34 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    TUNA

    Example: Natural Convection II

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    53/61

    Example: Natural Convection II

    DiagonalMatrix A(num_nodes_x, num_nodes_y, num_nodes_z);

    ScalarField3D b(num_nodes_x, num_nodes_y, num_nodes_z);

    StructuredMesh > mesh(length_x, num_nodes_x,

    length_y, num_nodes_y,

    length_z, num_nodes_z);

    ScalarField3D T(mesh.getExtentVolumes());

    ScalarField3D p(mesh.getExtentVolumes());

    ScalarField3D u(mesh.getExtentVolumes()); // u-velocity

    ScalarField3D v(mesh.getExtentVolumes()); // v-velocity

    ScalarField3D w(mesh.getExtentVolumes()); // w-velocity

    Range all = Range::all();T(T.lbound(firstDim), all, all) = left_wall; // Left

    T(T.ubound(firstDim), all, all) = right_wall; // Rigth

    Comp EOR LMCS 35 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    TUNA

    Example: Natural Convection III

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    54/61

    Example: Natural Convection III

    ScalarEquation energy(T, A, b, mesh.getDeltas());

    energy.setDeltaTime(dt);

    energy.setNeumann(TOP_WALL);

    energy.setNeumann(BOTTOM_WALL);

    energy.setDirichlet(LEFT_WALL, left_wall);

    energy.setDirichlet(RIGHT_WALL, right_wall);

    energy.setNeumann(FRONT_WALL);

    energy.setNeumann(BACK_WALL);

    energy.setUvelocity(us);energy.setVvelocity(vs);

    energy.setWvelocity(ws);

    energy.print();

    Momentum_XCoDi mom_x(us, A, b, mesh.getDeltas());

    Momentum_YCoDi mom_y(vs, A, b, mesh.getDeltas());

    Momentum_ZCoDi mom_z(ws, A, b, mesh.getDeltas());

    PressureCorrection press(pp, A, b, mesh.getDeltas());

    Comp EOR LMCS 36 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    TUNA

    Example: Natural Convection IV

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    55/61

    a p e Natu a Co vect o V

    template

    class CDS_CoDi : public ScalarEquation< CDS_CoDi< Tprec, Dim > >{

    public:

    typedef Tprec prec_t;

    typedef typename TunaArray::huge ScalarField;

    CDS_CoDi() : ScalarEquation() { }

    ~CDS_CoDi() { };

    inline void calcCoefficients1D();

    inline void calcCoefficients2D();

    inline void calcCoefficients3D();

    inline void printInfo() { std::cout

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    56/61

    p

    template

    inline void CDS_CoDi::calcCoefficients2D() {

    prec_t Gdy_dx = Gamma * dy / dx, Gdx_dy = Gamma * dx / dy;

    prec_t dxy_dt = dx * dy / dt;

    aE = 0.0; aW = 0.0; aN = 0.0; aS = 0.0; aP = 0.0; sp = 0.0;

    for (int i = bi; i

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    57/61

    p

    for(iteration = 1; iteration tol_simplec) && (counter < 20) ) {

    energy.calcCoefficients();

    Solver::TDMA3D(energy, tolerance, max_iter);

    errorT = energy.calcErrorL2();

    energy.update();

    mom_x.calcCoefficients();

    Solver::TDMA3D(mom_x, tolerance, max_iter);

    errorX = mom_x.calcErrorL2();

    mom_x.update();

    Comp EOR LMCS 39 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    TUNA

    Example: Natural Convection VII

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    58/61

    p

    mom_y.calcCoefficients();Solver::TDMA3D(mom_y, tolerance, max_iter);

    errorY = mom_y.calcErrorL2();

    mom_y.update();

    mom_z.calcCoefficients();

    Solver::TDMA3D(mom_z, tolerance, max_iter);

    errorZ = mom_z.calcErrorL2();mom_z.update();

    press.calcCoefficients();

    Solver::TDMA3D(press, tolerance, max_iter);

    press.correction();

    sorsum = fabs( press.calcSorsum() );

    ++counter;

    }

    return sorsum;

    }

    Comp EOR LMCS 40 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    TUNA

    Example: Natural Convection VIII

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    59/61

    Comp EOR LMCS 41 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    References I

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    60/61

    [1] R.A. Tapia and C. Lanius,Computational Science: Tools for a Changing World

    http://ceee.rice.edu/Books/CS/chapter1/intro52.html, 2001.

    [2] I. Jacobson and G. Booch and J. RumbaughPrimer,The Unified Software Development Process,Addison Wesley, 1999.

    [3] I. Herrera and M. B. Allen and G. F. Pinder,Numerical modeling in science and engineering,John Wiley & Sons., USA, 1988.

    [4] I. Herrera and G. F. Pinder,General principles of mathematical computational modeling,John Wiley, in press.

    Comp EOR LMCS 42 / 43

    Oil Reservoir Simulation General Math & Num Models Computational Approach References

    References II

  • 8/12/2019 Www.bu.Edu Pasi Files 2011 01 LuisdelaCruz1!11!1700

    61/61

    [5] R.J. Leveque,

    Finite Volume Method for Hyperbolic Problems,Cambridge University Press, 2004.

    Comp EOR LMCS 43 / 43