function [Kbarr] = KModulbar(Kf,K0,theta,Kst,betai,betac)

if Kf==0 && theta~=0
    Kbarr = (betai/theta^-1)+theta*betac;
elseif theta==0
    Kbarr = 0;
else
    Kbarr = (((1/Kf-1/K0)*betai)/(1+theta^-1*(1/Kf-1/Kst)))+theta*betac;
end

if isnan(Kbarr) || isinf(Kbarr)
    disp('K_BAR IS NAN OR INF -> SETTING TO ZERO!')
    Kbarr = 0;
end