function [RS,pIIRS,rII,pII,niII] = phiII(T0,n0,V0)

%T0 = 1000.0;
%n0 = 5e10;
%V0 = -2000.0;

RN = 0.004;
kB = 1.3806503e-23; % m2 kg s-2 K-1
e = 1.60217646e-19; % C
eps = 8.85418782e-12; % m-3 kg-1 s4 A2

rhoS = 0.45;

basic = kB*T0/e;
factor = (0.75*basic)^(1/3);
factor2 = (e*n0/eps)^(2/3);
phioffset = -(factor2)*(factor)*RN^(4/3);
RS = 19.7;
RS = ((phioffset + basic*(1/0.45)^2 - V0)/(factor*factor2))^(3/4);
pIIRS = -((1/rhoS)^2)*kB*T0/e;
%pIIRS = (factor2*factor)*RS^(4/3)+V0-phioffset;

rII = zeros(2000,1);
pII = zeros(2000,1);
niII = zeros(2000,1);
for idist =1:length(rII)
    x = idist*1.05*RS/1000.0;
    rII(idist) = x;
    if (x < RS) 
    pII(idist) = (factor2*factor)*x^(4/3)+V0-phioffset;
    niII(idist) = n0/sqrt(1-pII(idist)/basic);
else
    pII(idist) = pIIRS*exp(-x/RS + 1);
    niII(idist) = n0;  
end
end


