forked from otvam/magnetic_components_toolbox_matlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_sweep_single.m
executable file
·44 lines (35 loc) · 1.23 KB
/
get_sweep_single.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
function data = get_sweep_single(name, flag, sweep, fct_solve)
% Run a simulation for a single parameter combination
% - name - name of the simulation
% - flag - struct with the parameters which are not part of the sweeps
% - sweep - struct with the parameter definition (single combination)
% - fct_solve - function handler for solving the problem
% - data - struct with the simulation data
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% (c) 2021, T. Guillod, BSD License
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% init the simulation
tic = sim_start(name);
% merge data
disp('create parameters')
field = [fieldnames(flag);fieldnames(sweep)];
value = [struct2cell(flag); struct2cell(sweep)];
param = cell2struct(value, field);
% solve the design
disp('solve problem')
[is_valid, res] = fct_solve(param);
assert(is_valid==true, 'invalid data')
n_sweep = 1;
n_valid = 1;
% end the simulation
duration = sim_end(name, tic);
% data
data.name = name;
data.flag = flag;
data.sweep = sweep;
data.n_sweep = n_sweep;
data.n_valid = n_valid;
data.param = param;
data.res = res;
data.duration = duration;
end