Foam fingering paper computations

This is the final notebook for the regeneration of the simulation results for our SPE RSS paper, which is now submitted to the journal of natural gas (or sth like that). I have not included the gravity effect in the code, so only the results from cases 1 to 4 can be regenerated here.

Load the foam functions and run


In [ ]:
using JFVM, Roots, PyPlot, ProgressMeter, DataFrames, Dierckx, JLD


INFO: Recompiling stale cache file C:\Users\aliak\.julia\lib\v0.4\PyCall.ji for module PyCall.
INFO: Recompiling stale cache file C:\Users\aliak\.julia\lib\v0.4\PyPlot.ji for module PyPlot.
INFO: Recompiling stale cache file C:\Users\aliak\.julia\lib\v0.4\SHA.ji for module SHA.
INFO: Recompiling stale cache file C:\Users\aliak\.julia\lib\v0.4\BinDeps.ji for module BinDeps.
INFO: Recompiling stale cache file C:\Users\aliak\.julia\lib\v0.4\Conda.ji for module Conda.
INFO: Recompiling stale cache file C:\Users\aliak\.julia\lib\v0.4\LaTeXStrings.ji for module LaTeXStrings.
INFO: Recompiling stale cache file C:\Users\aliak\.julia\lib\v0.4\Roots.ji for module Roots.
INFO: Recompiling stale cache file C:\Users\aliak\.julia\lib\v0.4\Polynomials.ji for module Polynomials.
INFO: Recompiling stale cache file C:\Users\aliak\.julia\lib\v0.4\Calculus.ji for module Calculus.
INFO: Recompiling stale cache file C:\Users\aliak\.julia\lib\v0.4\ForwardDiff.ji for module ForwardDiff.
INFO: Recompiling stale cache file C:\Users\aliak\.julia\lib\v0.4\ProgressMeter.ji for module ProgressMeter.
INFO: Recompiling stale cache file C:\Users\aliak\.julia\lib\v0.4\DataArrays.ji for module DataArrays.

In [2]:
include("frac_flow_funcs.jl")
include("foam_flow_two_phase.jl")


Out[2]:
foam_stars (generic function with 1 method)

Read our paper foam model data

I've modified two cases to match them with the description in the paper. Perhaps Rouhi can explain it.


In [3]:
data1=readtable("TableA1.csv")


Out[3]:
parameterfmmobfmdryepdrykrw0krg0swcsgcnwngmuwmugrhowrhog
1case180000.2681000000.20.940.10.052.01.80.000655.0e-5985100
2case2130000.2681000000.20.940.10.052.01.80.000655.0e-5985100
3case3250000.29100000.20.940.10.054.21.30.0012.0e-5985100
4case4250000.291000.20.940.10.054.21.30.0012.0e-5985100

How to use this notebook

Change the case_no variable to between 1 to 4 and run the notebook to obtain the results of the paper.


In [84]:
case_no=1
fmmob=data1[:fmmob][case_no]
epdry=data1[:epdry][case_no]
fmdry=data1[:fmdry][case_no]
krw0=data1[:krw0][case_no]
krg0=data1[:krg0][case_no]
swc=data1[:swc][case_no]
sgc=data1[:sgc][case_no]
nw=data1[:nw][case_no]
ng=data1[:ng][case_no]
muw=data1[:muw][case_no]
mug=data1[:mug][case_no]


Out[84]:
5.0e-5

In [85]:
# load Corey-type and foam relperms
(krw, krg, dkrwdsw, dkrgdsw, krgf, dkrgfdsw)=corey_rel_perms(
    swc=swc, sgr=sgc, krg0=krg0, ng=ng, krw0=krw0,
    nw=nw, fmmob=fmmob, epdry=epdry, fmdry=fmdry)
# Define the fractional flow functions
fw(sw)=(krg(sw)/mug)./(krg(sw)/mug+krw(sw)/muw)
fw_foam(sw)=(krgf(sw)/mug)./(krgf(sw)/mug+krw(sw)/muw)
# define the mobility function
labda_tot(sw)=krg(sw)/mug+krw(sw)/muw
labda_tot_foam(sw)=krgf(sw)/mug+krw(sw)/muw


Out[85]:
labda_tot_foam (generic function with 1 method)

In [86]:
(xt_shock, sw_shock, xt_prf, sw_prf, t, p_inj)=frac_flow_wag(muw=muw, 
  mug=mug, ut=1e-5, phi=0.2,
k=1e-12, swc=swc, sgr=sgc, krg0=krg0, ng=ng, krw0=krw0,
  nw=nw, sw0=1.0, sw_inj=0.0, L=1, pv_inj=5)


Out[86]:
(0.00020944152293314092,0.8395715957203321,[0.0,2.15964e-9,6.01464e-9,9.91109e-9,1.38495e-8,1.78302e-8,2.18538e-8,2.59207e-8,3.00314e-8,3.41864e-8  …  0.00017715,0.000181456,0.000185864,0.000190374,0.000194986,0.000199701,0.00020452,0.000209442,0.000209442,0.000418883],[0.0,0.10095,0.102633,0.104316,0.105998,0.107681,0.109363,0.111046,0.112728,0.114411  …  0.827794,0.829477,0.831159,0.832842,0.834524,0.836207,0.837889,0.839572,1.0,1.0],[2.22045e-16,1010.1,2020.2,3030.3,4040.4,5050.51,6060.61,7070.71,8080.81,9090.91  …  90909.1,91919.2,92929.3,93939.4,94949.5,95959.6,96969.7,97979.8,98989.9,100000.0],[6500.0,6931.75,7359.79,7795.41,8223.42,8231.0,7330.18,6659.67,6136.78,5715.08  …  1662.16,1653.68,1645.35,1637.17,1629.13,1621.23,1613.46,1605.82,1598.32,1590.93])

In [87]:
L=1.0
sw_int = Spline1D(xt_prf, sw_prf, k=1);
sw_int(0.0003)


Out[87]:
1.0

In [88]:
plot(t, p_inj)
xlabel("time [s]")
ylabel("Injection pressure [Pa]")


Out[88]:
PyObject <matplotlib.text.Text object at 0x0000000054C295C0>

In [90]:
plot(xt_prf, sw_prf, "o--")
ylabel("Water saturation")
xlabel("x/t [m/s]")
title("WAG", fontsize=18)


Out[90]:
PyObject <matplotlib.text.Text object at 0x0000000054F97198>

Analytical solution for SAG


In [91]:
(xt_shock, sw_shock, xt_prf, sw_prf, t, p_inj)=frac_flow_sag(
fmmob=fmmob, epdry=epdry, fmdry=fmdry,
muw=muw, mug=mug, ut=1e-5, phi=0.2,
k=1e-12, swc=swc, sgr=sgc, krg0=krg0, ng=ng, krw0=krw0,
  nw=nw, sw0=1.0, sw_inj=0.0, L=1, pv_inj=5)


Out[91]:
(6.749042437709616e-5,0.2637743148356661,[0.0,1.1372e-9,2.52457e-9,3.91838e-9,5.31865e-9,6.72545e-9,8.13882e-9,9.55881e-9,1.09855e-8,1.24188e-8  …  1.9675e-5,2.24992e-5,2.5997e-5,3.04012e-5,3.60548e-5,4.34797e-5,5.35016e-5,6.74904e-5,6.74904e-5,0.000134981],[0.0,0.100435,0.100964,0.101492,0.102021,0.10255,0.103078,0.103607,0.104135,0.104664  …  0.260074,0.260603,0.261131,0.26166,0.262188,0.262717,0.263246,0.263774,1.0,1.0],[2.22045e-16,1010.1,2020.2,3030.3,4040.4,5050.51,6060.61,7070.71,8080.81,9090.91  …  90909.1,91919.2,92929.3,93939.4,94949.5,95959.6,96969.7,97979.8,98989.9,100000.0],[6500.0,6318.54,6137.71,5956.87,5776.02,5595.17,5414.32,5233.46,5052.61,4871.76  …  1903.62,1896.1,1888.7,1881.42,1874.25,1867.18,1860.21,1853.35,1846.6,1839.94])

In [93]:
plot(xt_prf, sw_prf, "o--")
ylabel("Water saturation")
xlabel("x/t [m/s]")
title("SAG", fontsize=18)


Out[93]:
PyObject <matplotlib.text.Text object at 0x0000000055221668>

In [94]:
plot(xt_prf, labda_tot_foam(sw_prf), "o--")
xlabel("x/t [m/s]")
ylabel("Total relative mobility [1/(Pa.s)]")


Out[94]:
PyObject <matplotlib.text.Text object at 0x00000000553C38D0>

In [95]:
plot(t, p_inj)
xlabel("time [s]")
ylabel("Injection pressure [Pa]")


Out[95]:
PyObject <matplotlib.text.Text object at 0x000000005554E400>

Numerical models


In [66]:
include("foam_flow_two_phase.jl")


Out[66]:
foam_stars (generic function with 1 method)

2D model inputs and results

Initial saturation = shock saturation


In [72]:
Nx = 80 # number of cells in x direction
Ny = 80 # number of cells in y direction
W = 1 # width
H = 1 # height
x=[linspace(0,0.5,70); linspace(0.51, 1.0, 10)]
y=collect(linspace(0,H,Ny))
m = createMesh1D(x)
m2=createMesh2D(Nx,Ny, W, H);
perm_ave=1e-12
perm_field=permfieldlogrnde(Nx, Ny, perm_ave, 0.1, 0.1, 0.1);

In [109]:
sw2=foam_stars(m2, perm_ave=perm_field, poros_ave=0.2, sw_init=sw_shock, 
fmmob=fmmob, epdry=epdry, fmdry=fmdry,
muw=muw, mug=mug, swc=swc, sgr=sgc, krg0=krg0, ng=ng, krw0=krw0, nw=nw,
t_final=50, dt0=50.0/100);


Time loop:100%|██████████████████████████████████████████████████| Time: 0:00:14

In [111]:
#save("case1_shocksat_2d.jld", "sw", sw2)
visualizeCells(sw2)
colorbar()
title("water saturation, sw0=sw_shock")


Out[111]:
PyObject <matplotlib.text.Text object at 0x0000000071CA79B0>

In [105]:
#save("case1_shocksat_2d.jld", "sw", sw2)
pcolor(labda_tot_foam(sw2.value[2:end-1,2:end-1]'), vmax=4000)
colorbar()
title("total relative mobility, sw0=sw_shock")


Out[105]:
PyObject <matplotlib.text.Text object at 0x000000005F61E7B8>

Initial saturation = fully liquid saturated


In [ ]:
sw2_sat=foam_stars(m2, perm_ave=perm_field, poros_ave=0.2, sw_init=1.0, 
fmmob=fmmob, epdry=epdry, fmdry=fmdry,
muw=muw, mug=mug, swc=swc, sgr=sgc, krg0=krg0, ng=ng, krw0=krw0, nw=nw,
t_final=50, dt0=50.0/500);

In [108]:
#save("case1_fullsat_2d.jld", "sw", sw2_sat)
visualizeCells(sw2_sat)
colorbar()
title("water saturation, sw0=1.0")


Out[108]:
PyObject <matplotlib.text.Text object at 0x000000006A3EB9E8>

In [107]:
# plot total relative mobility
pcolor(labda_tot_foam(sw2_sat.value[2:end-1,2:end-1]'))
colorbar()
title("total relative mobility, sw0=1.0")


Out[107]:
PyObject <matplotlib.text.Text object at 0x000000006416AEF0>

1D model results


In [112]:
sw1=foam_stars(m, perm_ave=1e-12, poros_ave=0.2, sw_init=1.0, 
    fmmob=fmmob, epdry=epdry, fmdry=fmdry,
    muw=muw, mug=mug, swc=swc, sgr=sgc, krg0=krg0, ng=ng, krw0=krw0,
    nw=nw, t_final=50, dt0=50.0/100);
visualizeCells(sw1)
xlabel("x [m]")
ylabel("water saturation [-]")


Time loop:100%|██████████████████████████████████████████████████| Time: 0:00:18
Time loop:100%|██████████████████████████████████████████████████| Time: 0:00:18
Time loop:100%|██████████████████████████████████████████████████| Time: 0:00:18
Time loop:100%|██████████████████████████████████████████████████| Time: 0:00:18
Time loop:100%|██████████████████████████████████████████████████| Time: 0:00:18
Time loop:100%|██████████████████████████████████████████████████| Time: 0:00:18
Time loop:100%|██████████████████████████████████████████████████| Time: 0:00:18
Time loop:100%|██████████████████████████████████████████████████| Time: 0:00:18
Time loop:100%|██████████████████████████████████████████████████| Time: 0:00:18
Time loop:100%|██████████████████████████████████████████████████| Time: 0:00:18
Time loop:100%|██████████████████████████████████████████████████| Time: 0:00:18
Time loop:100%|██████████████████████████████████████████████████| Time: 0:00:18
Time loop:100%|██████████████████████████████████████████████████| Time: 0:00:18
Time loop:100%|██████████████████████████████████████████████████| Time: 0:00:18
Time loop:100%|██████████████████████████████████████████████████| Time: 0:00:18
Time loop:100%|██████████████████████████████████████████████████| Time: 0:00:18
Time loop:100%|██████████████████████████████████████████████████| Time: 0:00:18
Out[112]:
PyObject <matplotlib.text.Text object at 0x0000000072020470>
Time loop:100%|██████████████████████████████████████████████████| Time: 0:00:18
Time loop:100%|██████████████████████████████████████████████████| Time: 0:00:18
Time loop:100%|██████████████████████████████████████████████████| Time: 0:00:18
Time loop:100%|██████████████████████████████████████████████████| Time: 0:00:18
Time loop:100%|██████████████████████████████████████████████████| Time: 0:00:18
Time loop:100%|██████████████████████████████████████████████████| Time: 0:00:18
Time loop:100%|██████████████████████████████████████████████████| Time: 0:00:18