% Compare lognormal fit with measured data
% Convert Sw vs Pc data into format for gaussf
clear all
clf reset
[fid, message]=fopen('lime.dat','r')
load lime.dat;
status=fclose(fid);
Sw=lime(:,1);
Pc=lime(:,2);
v=[logspace(-2,0.5)];
u=-v(50:-1:1);
u=[u 0 v]';
% Sinf is extrapolated nonwetting phase saturation at infinite Pc
Sinf=input('Sinf = ? ')
mu=input('mu = ? ');
sig=input('sig = ? ');
y=mu+sig*u;
P=cumpd(u);
Sfit=1-P*Sinf;
Pcfit=exp(y);
semilogy(Sw,Pc,'kx',Sfit,Pcfit,'k-')
xlabel('Water Saturation')
ylabel('Capillary Pressure')
title('Lognormal Fit of Capillary Pressure')
S=[0 1]';
Pmean=[exp(mu) exp(mu)]';
Psp=[exp(mu+sig) exp(mu+sig)]';
Psm=[exp(mu-sig) exp(mu-sig)]';
hold
semilogy(S,Pmean,'k-',S,Psp,'k--',S,Psm,'k--')
%print fig1 -dbitmap
