Permeability Calculator

%function HP = PermFromResults(results filename – use [] for prompt,Pressure in PSI,thickness in nm)
function HP = PermFromResults(results,PPSI,thickness)

% load results from file if not specified
if nargin<1 || isempty(results)
%Load results from file
[fname,pname] = uigetfile(‘*_r.mat’,’Load Results File’);
r = load([pname fname],’results’);
results = r.results;
end

radiusNM = [results.pores.EquivDiameter]/(2*results.pixpernm);
porPER = [results.nmstats.porosity];
Flowsum = 0;
for j = 1:length([results.pores.EquivDiameter]);
[Flow(j),Perm(j)] = TongEq(radiusNM(j), porPER, PPSI,thickness);
NSFlow(j) = pi*((radiusNM(j)*1e-9)^4)/(8*1e-3)*PPSI*6895/(thickness*1e-9); %Flow prediction of NS
Flowsum = Flowsum + Flow(j);
end
%Flow is calculated in m3/s
HPPore = Flow./[results.nmstats.processed_area]*10^14/PPSI*10^9*60;
%Hydraulic perm contribution per pore in image
%
%Calculations for output
Flowsum = Flowsum*10^9*60; %Flow is calculated in m3/s convert to ul per min
NSFlow = sum(NSFlow)*10^9*60;%NS prediction
HP = Flowsum./[results.nmstats.processed_area]*10^14/PPSI;
%convert to a hydraulic permeability ul/min-PSI-cm2

%Figures used to understand contibutions of individual pores to overall
%permeability Uncomment to generate figures in the post of Jan. 1, 2007

figure;
hist(HPPore,50);
xlabel(‘Hydraulic Permeability ul/min-PSI-cm2’);
ylabel(‘Number of pores in image’);
[Flow1,Perm] = TongEq(results.nmstats.mean_diam/2, porPER, PPSI,thickness);
figure;
CUMHP = length(radiusNM)*Flow1./[results.nmstats.processed_area]*10^14/PPSI*10^9*60.*ones(length(radiusNM),1);
CUMHP2 = sum(HPPore).*ones(length(radiusNM),1);
plot(radiusNM*2,HPPore,’x’);
ylabel(‘Pore Contribution to Hydraulic Permeability ul/min-PSI-cm2’);
xlabel(‘Pore Diameter (nm)’);