% Calculates the adjusted end fixity of an end connection, given:
%   tau = adjustment factor accounting for 3 segments in member
%   r0 = ambient end fixity factor of the connection

% Updated December 19, 2018 to account for reduction in rotational rigidity
% at elevated temperatures
%   R0 = R of connection at ambient temperature (Nm)
%   m = slope reduction parameter (Nm/°C)
%   T = temperature of connection (°C)
function [r] = Get_r_adj_181219(r0,tau,R0,m,T) 
    % Verify input
    if (length(r0) ~= 1 || length(tau) ~= 1 || length(R0) ~= 1 || length(m) ~= 1|| length(T) ~=1)
        r = -100;
        return;
    end
    
    if (r0 == 0) %pinned
        r = 0;
    elseif (r0 == 1) %fixed
        r = 1;
    else %semi-rigid
        kr = max(0,1 - m*T/R0);
        r = kr*tau*r0/(1-r0*(1-kr*tau));
        %r = 1/ (1 + (1-r0)/r0/tau); % old, but applies if kr = 1
    end
end