#### meschackime

##### New Member

- Joined
- Nov 5, 2018

- Messages
- 3

Would you help to write a vba code for following Mass balance & Data Reconciliation[/h]The data reconciliation problem is solved using the method of Lagrange Multipliers.

Let’s denote the vector of measurements as M, whose elements are the measurements of each mass variable. And let’s denote the corresponding vector of percent uncertainties as UP. Then, the vector of absolute uncertainties UA is given by equation 4:

UA = UP⊗M

where the operator “⊗” means an element-wise multiplication.The reconciliation matrix is given by equation 5:

H(Nm + Nc) x (Nm + Nc) = [ DCT

C0 ]

C0 ]

where: D is a

*Nm*×

*Nm*diagonal matrix whose

*k*-th diagonal element is given by:

*d*kk = 2/(UA(

*k*))2. C is the

*Nc*×

*Nm*nodal matrix. 0 is a

*Nc*×

*Nc*null matrix.

The solution is given by equation 6:

S = H-1 x M

where the first *Nm*elements of the vector S are the reconciled measurements given by equation 7:

R(

and the remaining elements in S are the Lagrange multipliers given by equation 8:*k*) = S (*k*) ǀ 1 ˂*k*˂*Nm*L(

*k*) = S(*k*) ǀ*Nm*+ 1 ˂*k*˂*Nm*+*Nc*The vector of reconciliation adjustments, which are the corrections made on the original values, are given by equation 9:

A = R – M

Best regards,Meschac