1% res = LevelDependentFluidStationaryMean (masses, iniF, KF, cloF, iniB, KB, cloB, T)
2% Calculates
the stationary mean fluid level of first order and second order
3% level dependent (multi-regime) fluid models, from
the matrix-exponential
4% building blocks returned by SecondOrderLevelDependentFluidSolve.
6% * masses: list of point-mass vectors (K+1 vectors located at levels
7% T(1)=0, T(2), ..., T(K+1)=top threshold)
8% * iniF, KF, cloF: initial vector, matrix exponent and closing matrix
for
9%
the forward direction
for each regime (a list of size K)
10% * iniB, KB, cloB: initial vector, matrix exponent and closing matrix
for
11%
the backward direction
for each regime (a list of size K)
12% * T: vector of regime thresholds (length K)
14% res
is the scalar mean fluid level E[X].
16% Note:
the level-dependent stationary density in regime k over
the interval
18% pi_k(x) = iniF{k}*expm(KF{k}*(x-T(k)))*cloF{k}
19% + iniB{k}*expm(KB{k}*(T(k+1)-x))*cloB{k}
20% and E[X]
is obtained in closed form by integrating x*pi_k(x) over each
21% regime plus
the contribution T(j)*sum(masses{j}) of
the point masses.
22function res = LevelDependentFluidStationaryMean (masses, iniF, KF, cloF, iniB, KB, cloB, T)
26 N = length(masses{1});
29 % integrals of a matrix exponential over [0,L] via nilpotent block
30 % augmentation (robust even
if M
is singular, i.e. has a zero eigenvalue):
31 % J0 = int_0^L expm(M u) du, J1 = int_0^L u*expm(M u) du
32 function [J0, J1] = expIntMoments(M, L)
36 A = [M, In, Zn; Zn, Zn, In; Zn, Zn, Zn];
39 W13 = W(1:n, 2*n+1:3*n);
44 % contribution of
the point masses (located at levels T(1..K+1))
46 res = res + T(j) * sum(masses{j});
48 % contribution of
the continuous density in each regime
51 [J0F, J1F] = expIntMoments(KF{k}, Tk);
52 [J0B, J1B] = expIntMoments(KB{k}, Tk);
53 res = res + iniF{k} * (T(k)*J0F + J1F) * cloF{k} * h;
54 res = res + iniB{k} * (T(k+1)*J0B - J1B) * cloB{k} * h;