function [B] = B(flag,Kf,Ku,poisu,kappa,mueu)

if flag==1
    B = 0;
elseif flag==2
    B = ((2/15)*(1+poisu)+(2/15)*(1-poisu)* ...
        (((2+kappa)^2+2)/((2+kappa)^2-2))+ ...
        (8/5)*((3/2)-poisu)*...
        ((2+kappa)^2/((2+kappa)^2-2)))*(1/mueu);
    if isnan(B) || isinf(B)
        disp('B2 IS NAN OR INF -> SETTING TO ZERO!')
        B = 0;
    end
elseif flag==3
    B = Kf/(3*Ku);
    if isnan(B) || isinf(B)
        disp('B3 IS NAN OR INF -> SETTING TO ZERO!')
        B = 0;
    end
end