function massflow_error = massflow_ffid(p2_adj)
global R mu1 mu2 mu3 p1 p2 p3 D1 D2 D3 T1 T2 T3 L1 L2 L3
q1 = 0.001;
q2 = 0.001;
q3 = 0.001;
for i = 1:10
    Re1 = 4*q1/(pi*mu1(1)*D1(1));
    Re2 = 4*q2/(pi*mu2(1)*D2(1));
    Re3 = 4*q3/(pi*mu3(1)*D3(1));
    f1 = 0.316/4*Re1^(0.25);
    f2 = 0.316/4*Re2^(0.25);
    f3 = 0.316/4*Re3^(0.25);
    q1 = pi*D1(1)^2/4*sqrt((p1(1)^2-p2_adj^2)/(2*R*T1(1)*(2*f1*L1(1)/D1(1)+log(p1(1)/p2_adj))));
    q2 = pi*D2(1)^2/4*sqrt((p2_adj^2-p2(1)^2)/(2*R*T2(1)*(2*f2*L2(1)/D2(1)+log(p2_adj/p2(1)))));
    q3 = pi*D3(1)^2/4*sqrt((p2(1)^2-p3(1)^2)/(2*R*T3(1)*(2*L3(1)*f3/D3(1)+log(p2(1)/p3(1)))));
end;
massflow_error = abs(q1-q2);