-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsystem_variables.m
74 lines (61 loc) · 1.87 KB
/
system_variables.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
classdef system_variables
% Runtime variables that evolve over time.
%% Configuration
% Cache dependent computation
properties
useCache = true
end
%% State variables governed by the solver
properties
concentration
csd
end
%% Input variables
properties
temperatureC
inletConcentration
inletCsd
residenceTime
end
%% Dependent properties
% Do not reuse the system_variable object because the cache will be
% invalid, unless the useCache has been disabled
methods
function M = moment(obj, order, dim)
% Take the first argument as moment order and the second one as
% integral dimension
% TODO: multi-dimension
M = memoize(@obj.moment_internal, 'Enabled', obj.useCache);
end
function vf = volFrac(obj)
vf = obj.moment(3, 0) / 1e18 * obj.props.kShape;
end
end
methods (Access=private)
function M = moment_internal(obj, order, dim)
dL = obj.prop.sizeGrids.interval;
L = obj.prop.sizeGrids.to_array();
M = dL * trapz(obj.csd * L^order);
end
end
properties(Access=private)
props system_properties
end
%% Constructor
% Take the current property object as argument
methods
function obj = system_variables(props)
obj.props = props;
end
end
%% Object creation methods
methods (Static)
function obj = create_empty_state(props, initTC)
% create a system operating at the initial temperature
obj = system_variables(props);
obj.temperatureC = initTC;
obj.concentration = props.solubility(initTC);
obj.csd = zeros(size(size_grid));
end
end
end