Skip to content

Commit

Permalink
Switch to YAML files for PMA props
Browse files Browse the repository at this point in the history
+ Refactoring of prop_pma function.
  • Loading branch information
tsipkens committed Apr 19, 2021
1 parent 0a16d38 commit 8ebe360
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 73 deletions.
12 changes: 12 additions & 0 deletions prop/buckley.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# APM parameters from Buckley et al.

name: buckley
r2: 0.025 # outer electrode radius [m]
r1: 0.024 # inner electrode radius [m]
L: 0.1 # length of APM [m]
RPM: 13350 # rotational speed [rpm]
omega: RPM*2*pi/60 # rotational speed [rad/s]
omega_hat: 1 # APM, so rotational speed is the same
Q: 1.02e-3/60 # aerosol flowrate [m^3/s]
T: 298 # system temperature [K]
p: 1 # system pressure [atm]
10 changes: 10 additions & 0 deletions prop/ehara.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# APM parameters from Ehara et al.

name: ehara
r2: 0.103 # outer electrode radius [m]
r1: 0.1 # inner electrode radius [m]
L: 0.2 # length of APM [m]
omega_hat: 1 # APM, so rotational speed is the same
Q: 0.5/1000/60 # aerosol flowrate [m^3/s], assumed
T: 298 # system temperature [K]
p: 1 # system pressure [atm]
9 changes: 9 additions & 0 deletions prop/kuwata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Properties from Kuwata

r2: 0.052 # outer electrode radius [m]
r1: 0.05 # inner electrode radius [m]
L: 0.25 # classifier length [m]
omega_hat: 1 # APM conditions
Q: 1.67e-5 # aerosol flowrate [m^3/s]
T: 295 # system temperature [K]
p: 1 # system pressure [atm]
13 changes: 13 additions & 0 deletions prop/olfert-collings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Parameters from Olfert and Collings
# Nearly identical to the Ehara et al. case

name: olfert-collings
r2: 0.103 # outer electrode radius [m]
r1: 0.1 # inner electrode radius [m]
L: 0.2
omega_hat: 0.945
Q: 0.5/1000/60 # aerosol flowrate [m^3/s]
T: 295 # system temperature [K]
p: 1 # system pressure [atm]
m0: 900 * pi / 6 * 1e-27 # copy mass-mobility relation info (only used to find Rm)
Dm: 3
10 changes: 10 additions & 0 deletions prop/olfert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Default CPMA parameters from Olfert lab

name: olfert
r1: 0.06 # inner electrode radius [m]
r2: 0.061 # outer electrode radius [m]
L: 0.2 # length of chamber [m]
p: 1 # pressure [atm]
T: 293 # system temperature [K]
Q: 3/1000/60 # volume flow rate [m^3/s]
omega_hat: 32/33 # ratio of angular speeds
160 changes: 87 additions & 73 deletions prop_pma.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,101 +10,115 @@

function [prop] = prop_pma(spec)

if ~exist('spec', 'var') % if type of property set is not specified
spec = 'olfert';
elseif isempty(spec)
spec = 'olfert';
end
% if type of property specification is not given, use 'olfert'.
if ~exist('spec', 'var'); spec = []; end
if isempty(spec); spec = 'olfert'; end

%-- Default mass-mobility information -------------%
% Default, Dm = 3 corresponds to spheres (no change in effective density).
prop.Dm = 3; % mass-mobility exponent
prop.m0 = 4.7124e-25; % mass-mobility pre-factor

% Universal relation (Olfert and Rogak)
% prop.Dm = 2.48;
% prop.m0 = 2.9280e-24;

switch spec

%-- CPMA parameters from Olfert lab ----------------------------------%
case 'olfert'
prop.r1 = 0.06; % inner electrode radius [m]
prop.r2 = 0.061; % outer electrode radius [m]
prop.L = 0.2; % length of chamber [m]
prop.p = 1; % pressure [atm]
prop.T = 293; % system temperature [K]
prop.Q = 3/1000/60;%0.3/1000/60;%1.5/1000/60; % volume flow rate (m^3/s) (prev: ~1 lpm)
prop.omega_hat = 32/33; % ratio of angular speeds

%-- CPMA/APM parameters from Buckley et al. --------------------------%
case 'buckley'
prop.r2 = 0.025; % outer electrode radius [m]
prop.r1 = 0.024; % inner electrode radius [m]
prop.L = 0.1; % length of APM [m]
RPM = 13350; % rotational speed [rpm]
prop.omega = RPM*2*pi/60; % rotational speed [rad/s]
prop.omega_hat = 1; % APM, so rotational speed is the same
prop.Q = 1.02e-3/60; % aerosol flowrate [m^3/s]
prop.T = 298; % system temperature [K]
prop.p = 1; % system pressure [atm]

%-- APM parameters from Ehara et al. -------------%
case 'ehara'
prop.r2 = 0.103; % outer electrode radius [m]
prop.r1 = 0.1; % inner electrode radius [m]
prop.L = 0.2; % length of APM [m]
prop.omega_hat = 1; % APM, so rotational speed is the same
prop.Q = 0.5/1000/60; % aerosol flowrate [m^3/s], assumed
prop.T = 298; % system temperature [K]
prop.p = 1; % system pressure [atm]

%-- Parameters from Olfert and Collings -------------%
% Nearly identical to the Ehara et al. case
case 'olfert-collings'
prop.r2 = 0.103; % outer electrode radius [m]
prop.r1 = 0.1; % inner electrode radius [m]
prop.L = 0.2;
prop.omega_hat = 0.945;
prop.Q = 0.5/1000/60; % aerosol flowrate [m^3/s]
prop.T = 295; % system temperature [K]
prop.p = 1; % system pressure [atm]

prop.m0 = 900 * pi / 6 * 1e-27; % copy mass-mobility relation info (only used to find Rm)
prop.Dm = 3;

%-- Parameters from Kuwata --------------------------%
case 'kuwata'
prop.r2 = 0.052; % outer electrode radius [m]
prop.r1 = 0.05; % inner electrode radius [m]
prop.L = 0.25;
prop.omega_hat = 1;
prop.Q = 1.67e-5; % aerosol flowrate [m^3/s]
prop.T = 295; % system temperature [K]
prop.p = 1; % system pressure [atm]

otherwise
error(['PMA properties not available for provided case. ',...
'Try a different string in the `prop_pma(str)` call.']);

end
% Read case-specific properties from YAML file.
% Uses read_yaml(...) method given as a subfunction in this file.
prop = read_yaml(['prop', filesep, spec, '.yaml'], prop);


%-- Parameters related to CPMA geometry ----------------------------------%
prop.rc = (prop.r2+prop.r1)/2;
prop.r_hat = prop.r1/prop.r2;
prop.del = (prop.r2-prop.r1)/2; % half gap width
prop.rc = (prop.r2 + prop.r1) / 2;
prop.r_hat = prop.r1 / prop.r2;
prop.del = (prop.r2 - prop.r1) / 2; % half gap width

prop.A = pi*(prop.r2^2-prop.r1^2); % cross sectional area of APM
prop.v_bar = prop.Q/prop.A; % average flow velocity
prop.A = pi * (prop.r2 ^ 2 - prop.r1 ^ 2); % cross sectional area of APM
prop.v_bar = prop.Q / prop.A; % average flow velocity


%-- For diffusion --------------------------------------------------------%
kB = 1.3806488e-23; % Boltzmann's constant
prop.D = @(B) kB.*prop.T.*B; % diffusion coefficient
prop.D = @(B) kB .* prop.T .* B; % diffusion coefficient


% Fill mass-mobility relation equivalents.
prop = prop_massmob(prop);

end




% READ_YAML Simple utility to read simple YAML files.
%
% AUTHOR: Lloyd Russell, 2017
% REPO: https://github.com/llerussell/ReadYAML
% MODIFIED: Timothy Sipkens, 2021-04-19
function prop = read_yaml(file_path, prop)

% Parse inputs (currently never invoked).
if ~exist('prop', 'var'); prop = []; end
if isempty(prop); prop = struct(); end

% If file of presets does not exist.
if ~isfile(file_path)
error(['PMA properties not available for provided case. ',...
'Try a different string in the `prop_pma(str)` call.']);
end


% Read file line by line.
fid = fopen(file_path, 'r');
data = textscan(fid, '%s', 'delimiter', '\n', 'whitespace', '');
fclose(fid);

% Remove empty lines.
data = deblank(data{1});
data(cellfun('isempty', data)) = [];

% Prepare final results structure.
results = [];

% Parse the contents (line by line).
for i = 1:numel(data)

% extract this line
thisLine = data{i};

% ignore if this line is a comment
if strcmpi(thisLine(1), '#')
continue
end

% find the seperator between key and value
sepIndex = find(thisLine==':', 1, 'first');

% get the key name (remove whitespace)
key = strtrim(thisLine(1:sepIndex-1));

% get the value, ignoring any comments (remove whitespace)
value = strsplit(thisLine(sepIndex+1:end), '#');
value = strtrim(value{1});

% attempt to convert value to numeric type
[convertedValue, success] = str2num(value);
if success
value = convertedValue;
end

% store the key and value in the results
results.(key) = value;
end

% Append to supplied structure.
% Overwrite duplicate fields.
f_results = fields(results);
for ii = 1:length(f_results)
prop.(f_results{ii}) = results.(f_results{ii});
end

end


0 comments on commit 8ebe360

Please sign in to comment.