Run a complete nodal analysis from the fluid to the operating point

The whole PVT → IPR → VFP chain for one oil well: the bubble point, Bo and viscosity from black-oil correlations, a Darcy productivity index from them, a generalized Vogel inflow, a Hagedorn & Brown outflow at three wellhead pressures, and the operating point at each.

Open in the workbench

Engineering use case UC-MULTI-001 (Complete Nodal Analysis), all four of its steps in one script.

  1. PVT. BlackOilFluid works the bubble point out of the solution GOR, then gives Bo and the oil viscosity at the reservoir pressure, above the bubble point, where they set the productivity index.
  2. IPR. PseudosteadyState.ProductivityIndex turns k, h, the drainage area and the skin into J with those properties, and InflowPerformanceCurve.GeneralizedVogel bends it below the bubble point.
  3. VFP. Hagedorn & Brown carries the live oil's density and viscosity at the bubble point, the producing GOR equal to the solution GOR: no free gas in the reservoir yet.
  4. Integration. OperatingPointSolver.Solve finds the stable crossing at each wellhead pressure.

What an engineer learns: every input upstream reaches the rate. The fluid sets Pb, which decides whether the well flows with free gas at the sandface, and Bo and μ, which set J. Here the oil's bubble point comes out at about 2,110 psia, Bo at 1.27 rb/STB and the viscosity at 0.61 cP, which make J 1.18 STB/d/psi and the AOF about 3,020 STB/d. The wellhead rows show what the surface asks of the well: from 100 to 500 psia at the wellhead the rate falls from about 2,660 to 2,220 STB/d, a sixth of the well, as the flowing pressure rises from about 970 to 1,560 psia. The Sandface column says whether the well flows below the bubble point, on the Vogel part of its inflow curve, or still on the straight line above it.

Units are field throughout: °API, °F, psia, scf/STB, rb/STB, cP, mD, ft, inches for the tubing and STB/d. The tubing fluid is taken at one condition, the bubble point, which is the simplification a hand calculation makes too; the script vfp-nodal-operating-point is the shorter IPR-against-VLP form, and the nodal-operating-point dashboard moves every input with sliders.

Source

using System;
using System.Collections.Generic;
using System.Linq;
using Team76.Engineering.Core.Measures;
using Team76.Engineering.IPR;
using Team76.Engineering.Orchestration.Nodal;
using Team76.Engineering.PVT.Facades;
using Team76.Engineering.VFP.Builders;
using Team76.Engineering.VFP.Models;
using Team76.Engineering.VFP.Providers;

public class S : ICalcScript
{
    public ScriptResult Run(ICalcContext ctx)
    {
        // 1. PVT: a 35 °API oil with 500 scf/STB in solution, 0.75 separator gas, 180 °F. The bubble point and the oil's
        //    properties at reservoir pressure come from one correlation set (Standing).
        const double reservoirPressure = 3500, rsb = 500, temperatureF = 180;
        var fluid = new BlackOilFluid(apiGravity: 35, gasGravity: 0.75, temperature: temperatureF);
        var pb = fluid.CalculateBubblePoint(rsb).Psi;
        var bo = fluid.Bo(reservoirPressure).BblPerStb;
        var muo = fluid.Viscosity(reservoirPressure).CP;

        // 2. IPR: Darcy's pseudosteady-state J for 30 mD over 40 ft on 80 acres, skin 2, with that oil, then generalized
        //    Vogel below the bubble point.
        var j = PseudosteadyState.ProductivityIndex(K: 30, h: 40, Bl: bo, Ul: muo,
            Re: ProductionCommon.DrainageRadius(80), Rw: 0.354, S: 2);
        var inflow = InflowPerformanceCurve.GeneralizedVogel(j, Pressure.FromPsi(reservoirPressure), Pressure.FromPsi(pb));

        // 3. VFP: Hagedorn & Brown up 7,000 ft of 2.992" tubing, the liquid's density and viscosity from the same oil at
        //    its bubble point, the producing GOR its solution GOR.
        var tubing = FlowModelBuilder.HagedornAndBrown(
            new Pipe(Length.FromFeet(7000), Angle.FromDegrees(90), Roughness.From(0.0006), Length.FromInches(2.992)),
            new TraverseFluidProvider(GasSpecificGravity.From(0.75),
                fluid.Density(pb), fluid.Viscosity(pb),
                InterfacialTension.FromDynesPerCm(30), Temperature.FromDegF(temperatureF)));
        MultiPhaseLiftCurve Lift(double wellhead) =>
            new(tubing, Pressure.FromPsi(wellhead), SolutionRelation.FromScfPerStb(rsb));

        // 4. The operating point at three wellhead pressures: what the separator or the choke asks of the well.
        double[] wellheads = [100, 250, 500];
        var points = wellheads.Select(p => OperatingPointSolver.Solve(inflow, Lift(p))).ToArray();

        var rows = wellheads.Select((whp, i) =>
        {
            var point = points[i].HasOperatingPoint ? points[i].OperatingPoint : null;
            return new object[]
            {
                whp,
                point is null ? double.NaN : Math.Round(point.Rate.BblPerD),
                point is null ? double.NaN : Math.Round(point.FlowingPressure.Psi),
                point is null ? double.NaN : Math.Round(reservoirPressure - point.FlowingPressure.Psi),
                point is null ? "no stable crossing" : point.FlowingPressure.Psi < pb ? "below Pb: free gas at the sandface" : "above Pb",
            };
        }).ToList();

        // The curves: the inflow over the whole pressure range, an outflow curve per wellhead pressure.
        var pressures = Enumerable.Range(0, 25).Select(i => reservoirPressure * i / 24).ToArray();
        var series = new List<ScriptSeries>
        {
            new("Inflow (generalized Vogel)", [.. pressures.Select(p => inflow.RateAt(Pressure.FromPsi(p)).BblPerD)], pressures),
        };
        foreach (var whp in wellheads)
        {
            var lift = Lift(whp);
            var (rates, needed) = (new List<double>(), new List<double>());
            foreach (var rate in Enumerable.Range(1, 30).Select(i => inflow.MaximumRate.BblPerD * i * i / 900))
            {
                try
                {
                    needed.Add(lift.RequiredInletPressure(FlowRate.FromBblPerD(rate)).Psi);
                    rates.Add(rate);
                }
                catch (ArgumentOutOfRangeException)
                {
                    // A rate the correlation refuses; the solver skips it too.
                }
            }

            series.Add(new ScriptSeries($"Outflow, {whp:F0} psia at the wellhead", [.. rates], [.. needed]));
        }

        return ctx.Result()
            .Set("Bubble point (psia)", Math.Round(pb))
            .Set("Bo at reservoir pressure (rb/STB)", Math.Round(bo, 3))
            .Set("Oil viscosity at reservoir pressure (cP)", Math.Round(muo, 3))
            .Set("J (STB/d/psi)", Math.Round(j, 3))
            .Set("AOF (STB/d)", Math.Round(inflow.MaximumRate.BblPerD))
            .Set("Operating points", new ScriptTable(
                ["Wellhead (psia)", "Rate (STB/d)", "Pwf (psia)", "Drawdown (psi)", "Sandface"], rows,
                title: "Operating point against wellhead pressure"))
            .Set("Nodal plot", new ScriptChart(series,
                title: "Inflow against outflow", xLabel: "Oil rate (STB/d)", yLabel: "Flowing bottom-hole pressure (psia)"));
    }
}