PO.FL.QC.YFunction


Description

Checks and smooths the relative volumes of a constant-composition expansion (CCE) below the bubble point. Standing's Y-function, Y = (pb − p)/(p·(Vrel − 1)), is close to a straight line in pressure for a black oil, while the relative volumes themselves curve steeply and carry the lab's reading errors near the bubble point, where Vrel − 1 is small. A point well off the line is a misread volume or a wrong bubble point; a line that bends near pb says the bubble point itself is off. The function returns Y at each point below pb, the least-squares line Y = a + b·p and its R², and the relative volumes smoothed back from the line, for the report's table or a simulator deck. Points at or above pb are left out of the fit and passed through unchanged in the smoothed column.

Formula

=LAMBDA(p, vrel, pb, output, LET( msk, (p<pb)*(vrel>1), den, p*(vrel-1)*msk+1-msk, y, (pb-p)*msk/den, nn, SUM(msk), idx, (output="Y")*1+(output="Fit")*2+(output="Vrel")*3+(output="a")*4+(output="b")*5+(output="R2")*6, IF(OR(pb<=0, ROWS(p)<>ROWS(vrel), nn<2, idx=0), NA(), LET( xa, SUM(msk*p)/nn, ya, SUM(y)/nn, sxx, SUM(msk*(p-xa)^2), sxy, SUM(msk*(p-xa)*(y-ya)), syy, SUM(msk*(y-ya)^2), sl, sxy/sxx, ic, ya-sl*xa, fit, ic+sl*p, CHOOSE(idx, MAP(msk, y, LAMBDA(mk, yv, IF(mk=1, yv, NA()))), fit, msk*(1+(pb-p)/(p*fit))+(1-msk)*vrel, ic, sl, 1-(syy-sxy^2/sxx)/(syy+(syy=0)))))))

Parameters

Parameter Unit Description
p psia CCE pressures, a column; points at or above pb are allowed and left out of the fit
vrel — Relative volume V/Vsat at each pressure, a column the same size (1 at pb)
pb psia Bubble point pressure the volumes are relative to; above 0
output text "Y" Y-function (column, #N/A at or above pb), "Fit" the line's Y at each pressure (column), "Vrel" smoothed relative volume (column; measured at or above pb), "a" intercept, "b" slope [1/psi] or "R2"

Examples

Invocation Expected
=PO.FL.QC.YFunction({2400;2000;1600;1200;800}, {1.0302;1.1107;1.249;1.5101;2.0938}, 2620, "Y") [3.035320088, 2.800361337, 2.560240964, 2.319806574, 2.079904919]
=PO.FL.QC.YFunction({2400;2000;1600;1200;800}, {1.0302;1.1107;1.249;1.5101;2.0938}, 2620, "a") 1.602572735
=PO.FL.QC.YFunction({2400;2000;1600;1200;800}, {1.0302;1.1107;1.249;1.5101;2.0938}, 2620, "b") 0.0005978462756
=PO.FL.QC.YFunction({2400;2000;1600;1200;800}, {1.0302;1.1107;1.249;1.5101;2.0938}, 2620, "R2") 0.9999809359
=PO.FL.QC.YFunction({2400;2000;1600;1200;800}, {1.0302;1.1107;1.249;1.5101;2.0938}, 2620, "Fit") [3.037403796, 2.798265286, 2.559126776, 2.319988266, 2.080849755]
=PO.FL.QC.YFunction({3500;2620;2400;2000;1600;1200;800}, {0.98689;1;1.0302;1.1107;1.16;1.5101;2.0938}, 2620, "Vrel") [0.98689, 1, 1.027591904, 1.100548407, 1.224159777, 1.454286888, 1.961669924]
=PO.FL.QC.YFunction({3500;2620;2400;2000;1600;1200;800}, {0.98689;1;1.0302;1.1107;1.16;1.5101;2.0938}, 2620, "R2") 0.2602278512
=PO.FL.QC.YFunction({3500;2620;2400;2000;1600;1200;800}, {0.98689;1;1.0302;1.1107;1.16;1.5101;2.0938}, 2620, "a") 1.887399543
=IF(ISNA(PO.FL.QC.YFunction({3500;2620;2400}, {0.98689;1;1.0302}, 2620, "a")), 1, 0) 1

Need a custom LAMBDA? Suggest a New Lambda