33
MATHS in ENHANCED OIL RECOVERY How to rev up an explicit time solver Margot Gerritsen Energy Resources Engineering Stanford

MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

Embed Size (px)

Citation preview

Page 1: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

MATHS !

in !

ENHANCED OIL RECOVERY!

How to rev up an explicit time solver !

Margot Gerritsen!

Energy Resources Engineering!

Stanford!

Page 2: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

Motivated by reservoir processes!Particular interest in Enhanced Oil Recovery processes

Maintains pressure Swells oil phase Reduces oil viscosity

$$$ Components transfer between phases

Burns low percentage of oil Sets up steam flood, gas drive Upgrades oil in-situ

$$$ kinetics

Gas injection

In-situ combustion

Page 3: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

1. Global sweep, mainly controlled by heterogeneity & gravity

Low viscosity gas finds high perm flow paths Gravity segregates gas and oil phases

Effectiveness of injection process!

2. Local displacement efficiency, governed by phase behavior

Candidate for adaptivity, tailored computational methods:

tremendously fun area to be for a computational mathematician

Strong nonlinear coupling (e.g. phase behavior) High sensitivity to modeling as well as numerical errors

Page 4: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

T So

Burned zone

Vapor zone

Oil bank

Rx. zone

300

700

1100

0 1 2 Distance [ft]

•  Upscaled models show large grid dependency

•  Stiff reactions require specialized time-stepping

•  Implicit methods, though industry standard, are out of the question

Explicit methods desirable!

Page 5: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

Need efficient explicit methods!

Not one, but O(100) realizations

*and*

High grid density required for accuracy because of strong sensitivities

Studies performed: •  Monte Carlo simulations •  History matching •  Sensitivities to input parameters •  Optimization (eg. well placement)

Page 6: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

Governing system of nonlinear DAEs!

Multi-phase extension Darcy’s law

Mass balance equations (transport equations)

Equation of state give mole fractions and densities

φ∂Ci∂t

+∇⋅U i = qi , i = 1,..., Nc .

Ci = xijρ j S j, U i = xijρ ju jj=1

N p∑ , i = 1,..., Nc ,j=1N p∑

u j = −kλ j (∇p + ρmj g), λ j = krj µ j , j = 1,..., N p ,

ct∂p∂t+

∂Vt∂ni

∇⋅U i =∂Vt∂ni

qii=1Nc∑ .i=1

Nc∑

Pressure equation (flow equation)

Page 7: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

Asynchronous time stepping (FATI)!

Standard approach

All cells updated for same time step

Asynchronous

Cells have their own update time

Ideal for localized time scales

t

x

Page 8: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

Previous work!

Localized time stepping

Adaptive mesh refinement

Iterative Mortar/domain decomposition methods

Streamline methods

Kirby and Dawson

Y. Omelchenko and H. Karimabadi (San Diego)

Self-adaptive flux conservative equations with sources. JCP, 2006.

Page 9: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

Using fluxes ensures conservation!

Target update time

Current cell time

Flux between cells

Page 10: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

Move cell with smallest update time!

minimum target cell

Page 11: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

Update fluxes!

To update fluxes bring neighbors to same time level (partially)

Page 12: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

But, are remaining time steps safe?!

Page 13: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

If not, synchronize and reschedule!

Synchronization is recursive

Page 14: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

Simplified example: mathematics!

1 2 3 4 x t

1 2 3 4 x t

1 2 3 4 x t

1 2 3 4 x t

1 2 3 4 x t

1 2 3 4 x t

)( 5.15.2221

2nnnnn FFSS −−=+ λ

)(

)(

5.35.4441

4

5.25.3331

3nnnnn

nnnnn

FFSSFFSS

−−=

−−=+

+

λ

λ

)(

)(

)(

15.2

15.3

13

13

23

5.115.2

12

12

22

5.05.1112

1

+++++

++++

+

−−=

−−=

−−=

nnnnn

nnnnn

nnnnn

FFSSFFSSFFSS

λ

λ

λ

)(

)(

)(

25.1

25.2

22

22

32

15.3

15.4

14

14

34

25.2

15.3

23

23

33

+++++

+++++

+++++

−−=

−−=

−−=

nnnnn

nnnnn

nnnnn

FFSSFFSSFFSS

λ

λ

λ

i

nin

i xtΔ

Δ=λ

Cell updates

Face synchronization

Page 15: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

Patterns can be irregular, but.. !

1 2 3 4 5 6 7 8

x

t

Cells with similar update times

can be projected onto same

time level

Efficiency improves when fast

time scales are localized,

e.g. around fronts/near wells 1 2 3 4 5 6 7 8

1 2 3 4 5 6 7 8

Page 16: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

Euler-based scheme is inconsistent!

Linear advection

Single interface where time step jumps

Single point upwind flux

k-1 k k+1 k+2

pn 1+

n

1+n

pn 2+

Skn+1 = Sk

n −ΔtΔx

Gk+ 12−Gk− 12( ),

Gk− 12= Sk−1

n , Gk+ 12= (1− β)Sk

n + β Sk−1n

β =1p

λ

p + λ

1− −

λ

p

p−1

.

Page 17: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

First test – linear advection!

Log N

Log

e Lo

g e

p=2

p=4

L2 Error Sync dt Sync dt/p Async

Page 18: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

Exaggerate effect inconsistency!

Log N

Log

e

Log N

L2 Error Linf Error

p=2

Sync dt Sync dt/p Async

Page 19: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

Two-phase, incompressible flow!

= 27 (0.1 PVI), 13 (1.0 PVI)

= 2.5 (0.1 PVI), 1.0 (1.0 PVI)

Porosity Sync Async

Sync Updates Async Updates

Sync Updates Async Updates

For uniform porosity…

Page 20: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

Red is asynchronous Blue is synchronous End time = 2/3 PVI

CH4

C02 C4 C10

K-Values 2.5 1.4 0.5 0.05

Cinj 1.0 0.0 0.0 0.0

Cinit 0.1 0.1809 0.3766 0.3425

x

x

x

x

x

Page 21: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

100 Grid Cells

Flash Calculations Flux Calculations

Number Time Number Time

Synchronous 19261 2.8 186000 0.8

Asynchronous 8367 2.1 7157 0.5

500 Grid Cells

Flash Calculations Flux Calculations

Number Time Number Time

Synchronous 466281 58.9 463000 14.0

Asynchronous 149657 33.7 138677 9.1

Asynchronous tends to do about half the flash calculations of synchronous

Page 22: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

Turning off recursions seems to have little effect on the solution However, stability analysis still must be performed (ongoing work)

Page 23: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

An initial 2D Algorithm!

Miscible and immiscible two phase flow

Incompressible, no gravity or capillarity

Compare sequential algorithms

Polygonal grids with L-method, upstream weighting

dt chosen so that CFL satisfied for 95% of cells

Synchronous vs. Asynchronous

P Solve

P Solve

Page 24: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

2D Results !Immiscible Miscible

Saturation

0.4

PVI

Sync updates

Async updates

Sync flux

Async flux

Immiscible 17 20

Misible 12 13

Page 25: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

FATI requires a priority queue!

At each iteration, update cell with nearest scheduled final time

(Discrete Event Simulation)

Cells must be kept ordered by scheduled final time time

But must also modify neighbours, which may be anywhere

The priority queue drives FATI and is classically implemented as a minheap

Bottleneck? Parallelization?

Page 26: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

Flat Profile (2D code) !‏

_min_heapify

_swap

_synch

fl_bucklev_f

_residual

mh_set

fl_bucklev_df

_dfds

_flup

fati

_sched

main

0 5 10 15 20 25 30

FATI functions Heap operations

Other simulation Setup

Page 27: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

Priority Queue!

Minheap seems expensive

Heap operations are ~50% runtime

But

1D/2D runtimes are only 20-35% of synchronous equivalent

Cell calculations are currently trivial

Heap cost is log(number of cells) ‏

No bottleneck with large domains / more realistic problems

Parallelization (needed) is a different story!

Page 28: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

The devil is in the implementation!

So optimistic…..

$$$$ 1970 1980 1990 2000 2010 2020 2030

Multi-core Era: A new paradigm in computing

Vector Era • USA, Japan

Massively Parallel Era •  USA, Japan, Europe

1 TF

.001 TF

1,000 TF

1,000,000 TF

1,000,000,000 TF

IAA (Sandia/ORNL)

Page 29: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

Silicon valley moves to CMPs!

Flops are free. In most cases we can now compute on the data as fast as we can move them. Doug Miles, Portland Group

Power/cooling limits constrain clock speed

Industry moves to chip-level multiprocessors: •  Two or more cores in single package •  Cores may share cache (e.g. L2) •  Cores share interconnect to rest system

Designed for specific workloads (mail, encryptions, database)

Page 30: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

1. Commercial simulators

Eclipse - Schlumberger, GEM/STARS - CMG

Commercial simulators & homebrew!

3. Academic home brews

Commercial codes drivers for first vector machines (eg Cray) Commercial codes are legacy codes, parallelized, Fortran core code

“Next generation” software under development (90s technology) Implemented on large distributed clusters (MPI based mostly)

Academic homebrew heavily rely on MATLAB, C++ Some parallelized (usually MPI, some openMP)

2. Petroleum companies in house codes

Page 31: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes
Page 32: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

•  Analyze the nonlinear algorithm

–  Monotonicity & stability

•  Understand difference between CFL and recursion

–  What happens if recursion is limited?

–  How “safe” do we need to be?

–  Can we break one (or both) methods?

•  More complex physics & flux calculation

–  Counter current flow

–  Higher-order methods

–  More phase behavior

•  Parallelization

Page 33: MATHS in ENHANCED OIL RECOVERY - Stanford Universityweb.stanford.edu/group/siam/SIAM-margot.pdf · Motivated by reservoir processes! Particular interest in Enhanced Oil Recovery processes

Parallelization strategy FATI?!

Queue-driven boss-worker (or master-slave)‏

Fixed sub-domain size (at first)‏

Statically determined extents

Dynamically determined extents

Can experiment with optimum work-unit size to suit cache/comms

Bring sub-domain up to end-time of smallest member cell cheaply?

Workers have their own

minheap whose root is heaped by the boss's heap, distributing heap cost