-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSetup_single_variable_scan.m
200 lines (194 loc) · 6.33 KB
/
Setup_single_variable_scan.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
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
%%Code for setting up a single variable scan
%%Messy - but handles most of the behind-the-scenes as a script to ensure that the workspace is transparent
%%Check that the Controller object has been initialised correctly (i.e. with the GlobalModel script)
fprintf('Called Setup_single_variable_scan.m\nSetting parameters for a single variable scan\n')
if ~exist('GUI_ready_marker')
fprintf('GUI_ready_marker not in workspace\nLikely need to initialise Controller\n\n')
InitGUI = input('Initialise Controller (y/n)?','s');
switch InitGUI
case 'y'
GUI_ready_marker = false;
GlobalModel;
if ~GUI_ready_marker
clear GUI_ready_marker
return
end
case 'n'
warning('continuing without initialisation')
otherwise
clear InitGUI
fprintf('Not recognised - run GlobalModel to initialise, then rerun Run_single_variable_scan\n\n')
return
end
clear InitGUI
end
if ~exist('Scan_parameter')
fprintf('Select variable to scan\n(1) -> Power\n(2) -> Pressure\n(3) -> Composition\n(4) -> Total flow\n')
SelectVariable = input('Which test (#): ','s');
switch SelectVariable
case '1'
Scan_parameter = 'Power';
Power = NaN;
if ~exist('Pressure')
Pressure = input('Set constant pressure (mTorr): ');
elseif isnan(Pressure)
Pressure = input('Set constant pressure (mTorr): ');
else
fprintf('Pressure = %g mTorr\n',Pressure)
end
if ~exist('Composition')
Composition = input('Set constant composition (0 < prop.H2 < 1): ');
elseif isnan(Composition)
Composition = input('Set constant composition (0 < prop.H2 < 1): ');
else
fprintf('Composition = %g H2\n',Composition)
end
if ~exist('Total_flow')
Total_flow = input('Set constant total flow (sccm): ');
elseif isnan(Total_flow)
Total_flow = input('Set constant total flow (sccm): ');
else
fprintf('Total_flow = %g sccm\n',Total_flow)
end
case '2'
Scan_parameter = 'Pressure';
Pressure = NaN;
if ~exist('Power')
Power = input('Set constant power (W): ');
elseif isnan(Power)
Power = input('Set constant power (W): ');
else
fprintf('Power = %g W\n',Power)
end
if ~exist('Composition')
Composition = input('Set constant composition (0 < prop.H2 < 1): ');
elseif isnan(Composition)
Composition = input('Set constant composition (0 < prop.H2 < 1): ');
else
fprintf('Composition = %g H2\n',Composition)
end
if ~exist('Total_flow')
Total_flow = input('Set constant total flow (sccm): ');
elseif isnan(Total_flow)
Total_flow = input('Set constant total flow (sccm): ');
else
fprintf('Total_flow = %g sccm\n',Total_flow)
end
case '3'
Scan_parameter = 'Composition';
Composition = NaN;
if ~exist('Power')
Power = input('Set constant power (W): ');
elseif isnan(Power)
Power = input('Set constant power (W): ');
else
fprintf('Power = %g W\n',Power)
end
if ~exist('Pressure')
Pressure = input('Set constant pressure (mTorr): ');
elseif isnan(Pressure)
Pressure = input('Set constant pressure (mTorr): ');
else
fprintf('Pressure = %g mTorr\n',Pressure)
end
if ~exist('Total_flow')
Total_flow = input('Set constant total flow (sccm): ');
elseif isnan(Total_flow)
Total_flow = input('Set constant total flow (sccm): ');
else
fprintf('Total_flow = %g sccm\n',Total_flow)
end
case '4'
Scan_parameter = 'Total_flow';
Total_flow = NaN;
if ~exist('Power')
Power = input('Set constant power (W): ');
elseif isnan(Power)
Power = input('Set constant power (W): ');
else
fprintf('Power = %g W\n',Power)
end
if ~exist('Pressure')
Pressure = input('Set constant pressure (mTorr): ');
elseif isnan(Pressure)
Pressure = input('Set constant pressure (mTorr): ');
else
fprintf('Pressure = %g mTorr\n',Pressure)
end
if ~exist('Composition')
Composition = input('Set constant composition (0 < prop.H2 < 1): ');
elseif isnan(Composition)
Composition = input('Set constant composition (0 < prop.H2 < 1): ');
else
fprintf('Composition = %g H2\n',Composition)
end
otherwise
fprintf('Not recognised. ')
end
clear SelectVariable
end
fprintf('\nConstant values for scan set\n\n')
fprintf('Scan_parameter: ''%s''\n',Scan_parameter)
if length(Power) > 1 || length(Pressure) > 1 || length(Composition) > 1 || length(Total_flow) > 1
error('Can only scan one parameter at a time (look for parameter which has printed multiple times above, clear this)')
end
% fprintf('Power = %gW \n',Power)
% fprintf('Pressure = %g mTorr\n',Pressure)
% fprintf('Composition = %g H2\n',Composition)
% fprintf('Total_flow = %g sccm\n',Total_flow)
% fprintf('To scan another variable, clear Scan_parameter and rerun\n\n')
if ~exist('Scan_values')
fprintf('Scan_values unititialised\nSet Scan_values in command window then rerun script\n\n')
return
else
fprintf('Using Scan_values; \n')
ScanLength = length(Scan_values);
for iter = 1:ScanLength
fprintf('%d -> %g \n',iter, Scan_values(iter));
end
clear iter
fprintf('\n')
Use_prev_scan_values = input('Use these values (y/n)?','s');
switch Use_prev_scan_values
case 'y'
%Do nothing, continue
otherwise
clear ScanLength
clear Scan_values
clear Use_prev_scan_values
fprintf('Scan_values cleared\nSet Scan_values in command window then rerun script\n\n')
return
end
clear Use_prev_scan_values
end
switch Scan_parameter
case 'Power'
Power = Scan_values;
H2Supply = Total_flow.*Composition;
N2Supply = Total_flow.*(1-Composition);
case 'Pressure'
Pressure = Scan_values;
H2Supply = Total_flow.*Composition;
N2Supply = Total_flow.*(1-Composition);
case 'Composition'
H2Supply = Total_flow.*Scan_values;
N2Supply = Total_flow.*(1-Scan_values);
case 'Total_flow'
H2Supply = Scan_values.*Composition;
N2Supply = Scan_values.*(1-Composition);
otherwise
error('Oops - something went wrong')
end
Global_UpdateMode(Controller,'Matrix');
Controller.H.ExpPowerAbsorbed.String = num2str(Power);
Controller.H.ExpStartingPressure.String = num2str(Pressure);
Controller.Experiment.GasSupply = containers.Map({'H2','N2'},{H2Supply,N2Supply});
Controller.Solver.PowerAbsorbedIndex = 1;
Controller.Solver.StartingPressureIndex = 1;
Controller.Solver.GasSupplyIndex = 1;
GasSupply_UpdatePanel(Controller);
EvaluateTab_Experiment(Controller);
fprintf('Setting these values to GUI (improves compatibility with previous code)\nNote that scanned parameter may print oddly, but seems functional\n\n')
Single_variable_setup_marker = true;
fprintf('System ready to run evaluation\n\n')
clear ans