%[Flow,HP] = TongEq(radius in NM, porosity in PERCENT, Pressure in PSI,thickness in NM)
function [Flow,HP] = TongEq(radiusNM, porPER, PPSI,thickness)
%Write the Tong equation as a quadratic with flow as the independent
%variable
porosity = porPER/100; % enter porosity as % and convert
r = radiusNM*1e-9; %enter average pore radius in nanometers and convert to m
rho = 1000; %kg/m2
t = thickness*1e-9; %enter thickness in nanometers and convert to m
viscosity = 1e-3; %Pa s
P = 6895*PPSI; %Enter pressure in PSI and convert to Pascal
A = rho/(4*pi^2*r^4);
B = (1+0.85*t/r)*(1-0.34*porosity^1.5)*3*viscosity/r^3;
C = -P;
Rts = roots([A B C]);
Flow = Rts(2);
Flow2 = P/(3*viscosity/r^3); % this assumes only the Sampson flow
%Equation calculates flow though a single pore in units of m3/s
HP = Flow*porosity/(pi*r^2)*1000*1e6*60/100^2/PPSI;
%I'm converting to a permeability in ul/cm2-min-PSI
end