function d = equilibrium_3_springs(k0, D, T0, l, m, L, T)
% Equilibrium deformation of 3 springs connected with 2 masses
% under the gravitational force, as shown in figure 2, at a given
% temperature T
%   Input:
%      k0(3) : T=0 spring elastic constant matrix (N/m)
%      D(3)  : elastic constant parameter matrix (N/m)
%      T0(2) : spring Temperature parameter matrix (K)
%      l(3)  : spring equilibrium lengths matrix (m)
%      m(2)  : hanging masses (kg)
%      L     : Supports distance (m)
%      T     : Temperature (K)
%   Output:
%      d(3)  : spring deformations (m)
% J.M.Soler, Apr.2018

% Solve as A*d=b the equations 
%   F(i)=k(i)*d(i)-k(i+1)*d(i+1)-m(i)*g=0,  i=1:2
%   sum_i(l0(i)+d(i))=L
g = 9.8;
k = k0-D./(exp(T0/T)-1);   % spring constant at temperature T
A = [k(1),-k(2),0
     0,k(2),-k(3)
     1,1,1];
b = [g*m(1);g*m(2);L-sum(l)];
d = A\b;

end
