Mass Balance Formula
Transcript of Mass Balance Formula
-
7/25/2019 Mass Balance Formula
1/1
Attribute VB_Name = "Module1"
Function water(tph, solidpercent, N)water = Round((1 - solidpercent) * tph / (solidpercent), N)End Function
Function pulp(tph, spgr, solidpercent, N)pulp = Round((1 - solidpercent) * tph / (solidpercent) + tph / spgr, N)
End FunctionFunction pulpdensity(solidpercent, spgr, N)pulpdensity = Round(1 / ((solidpercent / spgr) + (1 - solidpercent)), N)
End Function
Function InterpolateL(lookup_value, known_xs, known_ys)
Dim pointer As IntegerDim X0 As DoubleDim Y0 As DoubleDim X1 As DoubleDim Y1 As Double
'Following line added to prevent extrapolation
If lookup_value < Application.Min(known_xs) Or lookup_value > Application.Max(known_xs) Then InterpolateL = CVErr(xlErrRef): Exit FunctionEnd If
pointer = Application.Match(lookup_value, known_xs, 1)X0 = known_xs(pointer)Y0 = known_ys(pointer)X1 = known_xs(pointer + 1)Y1 = known_ys(pointer + 1)InterpolateL = Y0 + (lookup_value - X0) * (Y1 - Y0) / (X1 - X0)End Function
Function InterpolateL1(lookup_value)Dim pointer As IntegerDim X0 As DoubleDim Y0 As DoubleDim X1 As DoubleDim Y1 As Double
'Following line added to prevent extrapolationIf lookup_value < Application.Min(known_xs) Or lookup_value > Application.Max(known_xs) Then InterpolateL = CVErr(xlErrRef): Exit FunctionEnd Ifknown_xs = Sheet2!a2: a8
'known_ys = Sheet2!b2: b8
pointer = Application.Match(lookup_value, known_xs, 1)X0 = known_xs(pointer)Y0 = known_ys(pointer)X1 = known_xs(pointer + 1)Y1 = known_ys(pointer + 1)InterpolateL = Y0 + (lookup_value - X0) * (Y1 - Y0) / (X1 - X0)End Function