% Calculates the Eurocode 3 mechanical strain of a section
%   T = temperatre
%   P = axial load
%   Ac = area of column
%   E0 = ambient modulus
%   fy0 = ambient yield stress

function [em] = Get_Strain(T,P,Ac,E0,fy0)
    fp = Get_EC3_value(T, "fp", fy0);
    fy = Get_EC3_value(T, "fy", fy0);
    Ea = Get_EC3_value(T, "Ea", E0);
    sig = P / Ac;
    ey = 0.02;
    ept = fp / Ea;
    c = (fy - fp) ^ 2 / ((ey - ept) * Ea - 2 * (fy - fp));
    a = sqrt((ey - ept) * (ey - ept + c / Ea));
    b = sqrt(c * (ey - ept) * Ea + c ^ 2);
    
    if sig < fp 
        em = P / (Ac * Ea);
    elseif sig < fy 
        em = ey - a / b * sqrt(b ^ 2 - (sig + c - fp) ^ 2);
    else
        em = 1/0;
    end
end