global pH

ph = linspace(5,9,50);

for k = 1:length(ph)
   pH = ph(k);
   x = newton('pcpfunk',[1 1 1 1 1 1]'*1e-5,1e-15);
   Bioack(k)  = log10(x(6)/(x(1) + x(3) + x(5)));
   PCP(k)     = x(1);
   HPCPaq(k)  = x(3);
   NaPCP(k)   = x(5);
   HPCPokt(k) = x(6);
end

figure(1)
KA = 10^-4.9; K2 = 10^5.04;
plot(ph,-log10(1/K2+KA/K2./10.^-ph),'r')
xlabel('pH')
ylabel('Bioackumulerbarhet')
title('Analytisk uppskattning av bioackumulerbarheten av PCP')
grid


figure(2)
plot(ph,PCP,ph,HPCPaq,ph,NaPCP,ph,HPCPokt)
xlabel('pH')
ylabel('M')
legend('PCP','HPCPaq','NaPCP','HPCPokt')
grid

figure(3)
hold on
plot(ph,Bioack)
xlabel('pH')
ylabel('Bioackumulerbarhet')

grid


