-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprepDynamic.m
More file actions
143 lines (110 loc) · 3.52 KB
/
prepDynamic.m
File metadata and controls
143 lines (110 loc) · 3.52 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
%% Prepare Dynamic Test Analysis
%GNU General Public License v3.0
%By Stefan Thanheiser: https://orcid.org/0000-0003-2765-1156
%
%Part of the paper:
%
%Thanheiser, S.; Haider, M.
%Dispersion Model for Level Control of Bubbling Fluidized Beds with
%Particle Cross-Flow
%Chemical Engineering Research and Design 2025
%
%All data, along with methodology reports and supplementary documentation,
%is published in the data repository:
%https://doi.org/10.5281/zenodo.7924693
%
%All required files for this script can be found in the software
%repository:
%https://doi.org/10.5281/zenodo.7948224
%
%
%
%This script prepares the data of the dynamic tests for further analysis
%by the "calcDynamic" script.
%
%
%Requires all dynamic test data files ("dynRaw_Run...") in the folder
%configured below and the file "stat_SumPrep.csv" that summarizes the
%particle dispersion measurements, which gets created by the script
%"prepStatic" and stored in the dirStationary folder ("../DataStationary"
%by default). All auxiliary classes and functions must be on the MATLAB
%path.
%
%Required products, version 24.1:
% - MATLAB
% - Simulink
% - Requirements Toolbox
% - Simulink Real-Time
% - Stateflow
%Necessary files, classes, functions, and scripts:
% - @DryAir
% - @FluBed
% - @implExp
% - @Sinter
% - @Orifice
% - baffleCalib.m
% - getBCF.m
% - getBIC.m
% - getConstants.m
% - getProp.m
% - mdlPostLoadFx.m
% - loadGeometry.m
% - getMdotSstatic.m
% - dynamicModel.slx
% - dynRaw_Run...
% - stat_SumPrep.csv
%% Set data directories
dirStationary='../DataStationary'; %Path to directory where stationary simulation data should be stored
dirData='../DataDynamic'; %Path to directory containing the data
dirFigures='../Figures'; %Path to directory where figures should be stored
%Create storage folder if it does not exist
if ~isfolder(dirFigures)
mkdir(dirFigures);
end
%% Load dynamic model and activate fast restart
mdl='dynamicModel';
sys=load_system(mdl);
mdlPostLoadFx;
set_param(mdl,"FastRestart","on");
cleanup=onCleanup(@() set_param(mdl,"FastRestart","off"));
%% Prepare analysis
%Get constants
const=getConstants();
%Retrieve filenames
dirCont=dir(dirData); %Content of directory containing the data
files={dirCont(~[dirCont.isdir]).name}';
files=files(contains(files,'dynRaw_'));
%Retain natural order of runs
idx=str2double(extract(files,digitsPattern));
[~,idx]=sort(idx);
files=files(idx);
%Set up table for mean values
flow=readtable([dirStationary,filesep,'stat_SumPrep.csv']);
flow{:,2:end}=0;
flow(length(files)+1:end,:)=[];
names=flow.Properties.VariableNames(2:end);
chambers=1:6;
%% Read individual files and do calculations
%Variables whose stationary value in the beginning is needed
idxStat=[compose('AC%d',1:2),compose('AC%dset',1:2),...
compose('h%d',1:6),compose('Phi%d',1:6)];
for i=1:length(files)
%Read file
tab=readtable([dirData,filesep,files{i}]);
%Get properties
dyn=getProp(tab,const,names,chambers);
%Record table for future analysis
writetable(dyn,[dirData,filesep,'dyn_Run',num2str(i),'.csv']);
%Get means
flow{i,2:end}=mean(dyn{:,2:end},1,'omitnan');
flow.Run(i)=i;
stat=dyn.AC1set==dyn.AC1set(1); %Identify stationary beginning
flow{i,idxStat}=mean(dyn{stat,idxStat},1,'omitnan');
end
%Add persistent bed levels
hNames=compose('h%d',chambers);
flow{:,hNames}=flow{:,hNames}+const.hBed;
%% Do baffle calibration
baffleCalib;
%Record table for future analysis
writetable(flow,[dirData,filesep,'dyn_Sum.csv']);