-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_prop.m
87 lines (62 loc) · 2.44 KB
/
get_prop.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
% GET_PROP Formats property struct for input to other functions.
% This sets up the proper format for the property struct used in
% evaluating functions. Units can be altered from those given, but must
% be consistent to proper non-dimensional quantities (that is, the units
% must candel out).
%
% The default properties are those for Carbon following the work by
% Sipkens et al. [1].
%
% ------------------------------------------------------------------------
%
% REFERENCES:
% [1] T. A. Sipkens and K. J. Daun, “Defining regimes and analytical
% expressions for fluence curves in pulsed laser heating of
% aerosolized nanoparticles,” Optics Express, 25(5), 5684-5696
% (2017).
%
% AUTHOR: Timothy Sipkens
function prop = get_prop(fn)
if ~exist('fn', 'var'); fn = []; end
if isempty(fn); fn = 'carbon'; end
prop = read_json(['data', filesep, fn, '.json']);
%-- Vaporization properties ------------------%
prop.kb = 1.38064852e-23; % Boltzmann constant, m^2*kg/(s^2*K)
prop.R = 8.3144598; % unviersal gas constant, kg*?m^2/(s^2*K*?mol)
prop.mv = prop.M * 1.660538782e-24; % mass of the vapor, kg
prop.Rs = prop.R / prop.M; % specific gas constant, ?m^2/(s^2*K)
prop.hvb = prop.hvb0 ./ prop.M;
% latent heat of vaporization at boiling point, J/kg
%-- Clausius-Clapeyron (C-C) equation --------%
prop.A = exp(log(prop.Pb)+prop.hvb/prop.Rs/prop.Tb); % constant for C-C equation, Pa
prop.pv = @(T) prop.A.*exp(-prop.hvref/prop.Rs./T); % C-C equation, Pa
prop.C1 = prop.kb*pi/(9*prop.Rs*prop.hvb*prop.mv)*...
(prop.rho*prop.cp/prop.A)^2;
% parameter C1, as defined in Ref. [1]
end
%== READ_JSON ============================================================%
% Read JSON structured configuration files.
% Allows for C++ or Javscript style commenting.
% AUTHOR: Timothy Sipkens, 2021-04-20
function results = read_json(file)
fid = fopen(file);
raw = fread(fid, inf); % raw file contents
str = char(raw'); % transform to char
fclose(fid);
% Remove comments.
str = erase(erase(eraseBetween( ...
erase(eraseBetween(str, "//", newline), "//"), ...
"/*", "*/"), "/*"), "*/");
results = jsondecode(str);
% Attempt to interpret Matlab expressions.
f_results = fields(results);
for ii=1:length(f_results)
t0 = results.(f_results{ii});
if isa(t0, 'char')
[converted, success] = str2num(t0);
if success
results.(f_results{ii}) = converted;
end
end
end
end