Python Presets

Part 12, The Rock Physics Lab

Learning objectives

  • Read five of the book's models as complete Python programs, and say which constants each takes from the kernel and which from its settings
  • Reproduce the book's numbers from code: the Gassmann sand's three velocities and its exact inverse, the soft-sand pack, Thomsen's parameters of a sand-shale stack, the anchor fluids and the carbonate pore-type spread
  • Trust a program by the kernel: a printed number is sound when it agrees with the kernel's own value to its last digit
  • Name where each program stops: the brine lines of Greenberg and Castagna, the oil that must keep its gas in solution, Gassmann's band, and the pore shape that is an assumption

The Same Physics, in Real Code

The figures of this book run its models in the browser, one setting at a time. This section gives five of them as complete Python programs, numpy for the physics and matplotlib for the closing figure, written to be copied, run and changed. The figure below shows one program at a time: (a) is its source, (b) is what it prints, (c) is the figure it draws, and (d) sets the program's key numbers against the kernel the rest of the book computes with. A button copies the program, downloads it, or opens it in the Python Playground under Tools, which loads numpy and matplotlib.

The programs carry the book's numbers, not private ones. The minerals are those of Figure 1.5; the grain pack is the book's one pack, critical porosity 0.36, 9 contacts a grain and 20 MPa (Section 5.2); the pore fluids are the reservoir anchor, Batzle and Wang (1992) at 50 °C and 25 MPa, with brine K=3.024K = 3.024 GPa, live oil 1.068 GPa and gas 0.061 GPa; and the Backus sand is the cemented sand of Figure 7.4. The anchor fluids and that frame are typed into the code to five decimals, as a reader would carry them. Python cannot run on this page, so the figure runs the same equations in JavaScript and prints what each program prints. The audit that checks this book runs every program under Python and holds each printed line, and each curve the program plots, to the figure's.

Gassmann fluid substitution at 25 % porosity: the dry frame, 30 % of theHashin-Shtrikman upper frame, is K = 7.145 GPa and μ = 7.938 GPa. Saturated withbrine, oil and gas it prints VP​ = 3.286 km/s, 3.053 and 2.963 km/s, and the inversetakes the brine rock back to K = 7.145 GPa. With half gas and half brine it prints3.100 km/s in patches against 2.899 mixed evenly. Against the kernel, the program'sarithmetic differs by at most 0.011 of the last printed digit, over 28 printednumbers.(a) The program, ogbon_rp_gassmann.py, 118 lines: the head, the porosity line markedimport numpy as np# --- Settings: the porosity control of the figure sets PHI -------------PHI = 0.25FRAME = 0.30 # share of the Hashin-Shtrikman upper frame (Figure 4.2)# --- Inputs ------------------------------------------------------------K_MIN, MU_MIN, RHO_MIN = 36.6, 45.0, 2.65 # quartzFLUIDS = [ # anchor fluids: name, K (GPa), density (g/cc) ("brine", 3.02439, 1.06820), ("oil", 1.06850, 0.77545), ("gas", 0.06061, 0.20162),]... and 91 more lines: the functions, the dry frame, the saturated rocks, the inverse, the two mixtures and the figure.(b) What it prints, 16 linesGassmann fluid substitution (phi = 0.25, frame = 30% of the HS upper)dry frame: K = 7.145 GPa, mu = 7.938 GPa----------------------------------------------------------fluid Ksat rho Vp Vs Ipbrine 13.766 2.255 3.286 1.876 7.409oil 9.745 2.181 3.053 1.908 6.659gas 7.302 2.038 2.963 1.974 6.037----------------------------------------------------------inverse: brine Ksat = 13.766 -> Kdry = 7.145 (the frame was 7.145)----------------------------------------------------------gas and brine mixed, Vp in km/s Sw uniform patchy 0.20 2.935 3.013 0.50 2.899 3.100 0.80 2.888 3.205 0.90 2.919 3.244(c) The figure it draws: VP​ against the water saturation, gas and brine in one sand0.00.20.40.60.81.02.82.93.03.13.23.33.4uniform: Wood's fluidpatchy: Gassmann-HillWater saturation Sw​VP​ (km/s)(d) Against the kernel: the number as printed, the kernel's value, the difference in last digitsPrinted numberProgram printsKernelLast digit offdry frame K, GPa7.1457.1453360dry frame mu, GPa7.9387.9383320brine Vp, km/s3.2863.2864460gas Vp, km/s2.9632.9625620inverse Kdry, GPa7.1457.1453360uniform Vp at Sw 0.50, km/s2.8992.8988500patchy Vp at Sw 0.50, km/s3.1003.0998910Largest gap 0.011 of a last digit; 0 of 28 printed numbers are off by a digit.The programs are run under Python in the audit; this page runs the same equations in JavaScript.

Five Programs

The first is GASSMANN FLUID SUBSTITUTION, the workflow of Section 4.2 forward and back (Gassmann, 1951). It takes the quartz sand of Figure 4.2, whose dry frame keeps 30% of the stiffest frame the porosity allows, the Hashin-Shtrikman upper bound of Section 2.4. At 25% porosity that frame is K=7.145K = 7.145 and μ=7.938\mu = 7.938 GPa. Saturated in turn with the anchor brine, oil and gas it prints VPV_P of 3.286, 3.053 and 2.963 km/s, and the exact inverse takes the brine rock back to Kdry=7.145K_{dry} = 7.145 GPa. The last table mixes gas and brine the two ways of Sections 3.5 and 3.6. Evenly mixed, Wood's fluid goes into Gassmann and VPV_P runs 2.935, 2.899, 2.888 and 2.919 km/s at 20, 50, 80 and 90% water, all below the 2.963 km/s of the gas-filled rock; in patches, the Gassmann-Hill average of the P-wave moduli gives 3.013, 3.100, 3.205 and 3.244 km/s.

The second is the SOFT-SAND LINE of Sections 5.2 and 5.3. Hertz-Mindlin gives the dry pack at the critical porosity, K=2.051K = 2.051 and μ=3.016\mu = 3.016 GPa, and the modified Hashin-Shtrikman lower bound carries it up to solid quartz. At 25% porosity with the brine in the pores the program prints Ksat=12.026K_{sat} = 12.026 GPa, VP=2.890V_P = 2.890 and VS=1.504V_S = 1.504 km/s, and its table of dry moduli runs from K=5.742K = 5.742 GPa at 20% porosity to the pack's 2.051 at 36%.

The third is the BACKUS AVERAGE AND THOMSEN of Section 9.2: Figure 7.4's cemented brine sand (Ksat=16.702K_{sat} = 16.702 and μ=12.286\mu = 12.286 GPa) laminated with Figure 0.3's shale (K=13.029K = 13.029 and μ=3.471\mu = 3.471 GPa) and averaged the exact long-wavelength way. At half sand it prints ϵ=0.0499\epsilon = 0.0499, γ=0.2278\gamma = 0.2278 and δ=−0.0916\delta = -0.0916, although both layers are isotropic. The table shows a symmetry worth knowing before you trust a plot: for two layers ϵ\epsilon and γ\gamma are proportional to the product of the layers' shares, so the 10% and 90% rows print the same ϵ=0.0180\epsilon = 0.0180 and γ=0.0820\gamma = 0.0820, while δ\delta, which is −0.0240-0.0240 at 10% and −0.0607-0.0607 at 90%, is not symmetric.

The fourth is BATZLE-WANG FLUIDS AND VS PREDICTION, Part 3 and Section 7.2 in one program. At 50 °C and 25 MPa it prints the brine K=3.024K = 3.024 GPa, the live oil 1.068 and the gas 0.061 GPa, the gas falling to 0.008 GPa at 5 MPa. It then prints the Greenberg and Castagna (1992) lines at VP=3.5V_P = 3.5 km/s, 1.959 km/s for sandstone, 1.853 for limestone and 1.963 for dolomite, beside the mudrock line of Castagna, Batzle and Eastwood (1985) at 1.845. These are lines for brine-saturated rock, and the program says so: in a hydrocarbon zone the shear velocity is read on the brine leg, after the gas has been taken out with the first program, not on the gas sand's VPV_P.

The fifth is INCLUSION MODELS, the machinery of Part 6. Berryman's spheroids go into the differential effective medium of Section 6.3, which grows the pores a little at a time; for pores of aspect ratio 0.15 in calcite it prints the dry KK of 54.00, 38.79, 20.57 and 10.87 GPa at 5, 10, 20 and 30% porosity. Gassmann puts the brine in, and for the three pore shapes of Section 6.6 at 25% porosity it prints VPV_P of 4.05 km/s for interparticle pores, 5.27 for moldic pores and 2.18 for cracks: one calcite, one brine, and velocities from 2.18 to 5.27 km/s. The last table is Xu-White (Section 6.5), 3.42, 2.80 and 2.38 km/s at 5, 20 and 40% clay.

Trusting a Program's Numbers

A program is trusted when it reproduces a number you already trust. Here that number is the kernel's: panel (d) sets key printed numbers beside the kernel's own values and counts the difference in units of the last printed digit. The two can differ for one reason, the five-decimal constants typed into the code. At the default settings the largest gap in any of the five programs is 0.011 of the last printed digit, and none of the printed numbers is off by a digit. That is what makes a change yours: when a number moves, the arithmetic you changed moved it, not the typing of a constant.

Where the Programs Stop

A program inherits the edges of its model. The Greenberg and Castagna lines are lines for brine-saturated rock (Section 7.2). The live oil of the fourth program holds its 80 L/L of gas in solution only above about 12.5 MPa at 50 °C, by Batzle and Wang's equation 21 (Section 3.3); the pressure control starts at 15 MPa for that reason, and below 12.5 MPa the oil row would describe an oil that is not there. Gassmann's equation has the edges of Section 4.5, the Backus average needs layers far thinner than the wavelength (Section 9.2), and in the inclusion program the aspect ratio is an assumption about the pores, not a measurement of them. For an open-source Python library of rock-physics models, see rockphypy (Yu, Mukerji, & Avseth, 2023).

When the problem grows, a loop over a well's samples or over a thousand draws of an aspect ratio is the same arithmetic run more often, and that is the step a browser slider cannot take. The next section looks up from the code to what the skills you now hold let you do in research.

References

  • Batzle, M., & Wang, Z. (1992). Seismic properties of pore fluids. Geophysics, 57(11), 1396-1408.
  • Castagna, J. P., Batzle, M. L., & Eastwood, R. L. (1985). Relationships between compressional-wave and shear-wave velocities in clastic silicate rocks. Geophysics, 50(4), 571-581.
  • Gassmann, F. (1951). Über die Elastizität poröser Medien. Vierteljahrsschrift der Naturforschenden Gesellschaft in Zürich, 96, 1-23.
  • Greenberg, M. L., & Castagna, J. P. (1992). Shear-wave velocity estimation in porous rocks: Theoretical formulation, preliminary verification and applications. Geophysical Prospecting, 40(2), 195-209.
  • Yu, J., Mukerji, T., & Avseth, P. (2023). rockphypy: An extensive Python library for rock physics modeling. SoftwareX, 24, 101567.

This page is prerendered for SEO and accessibility. The interactive widgets above hydrate on JavaScript load.