-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathget_dataset_param_fem.m
141 lines (118 loc) · 6.45 KB
/
get_dataset_param_fem.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
function [file_model, timing, var_type, sweep] = get_dataset_param_fem(model_type, sweep_mode)
% Return the data required for the FEM simulations.
%
% Define the variables and how to generate the samples.
% Get the COMSOL file path and the type of the variables.
%
% Parameters:
% model_type (str): name of the physics to be solved ('mf' or 'ht')
% sweep_mode (str): method for generating the variable combinations ('extrema' or 'random')
%
% Returns:
% file_model (str): path of the COMSOL file to be used for the simulations
% timing (struct): struct controlling simulation time (for batching systems)
% var_type (struct): type of the different variables used in the solver
% sweep (struct): data controlling the samples generation
%
% (c) 2019-2020, ETH Zurich, Power Electronic Systems Laboratory, T. Guillod
% check the input data
assert(any(strcmp(model_type, {'ht', 'mf'})), 'invalid physics type')
% struct controlling the COMSOL license and model loading (for batching systems)
% - diff_trial: time between two COMSOL license trials
% - n_trial: maximum number if COMSOL license trials
% - n_reload: how often the COMSOL model is reloaded (trade-off between speed, license, and memory)
timing.diff_trial = duration('00:30', 'InputFormat', 'mm:ss');
timing.n_trial = 120;
timing.n_reload = 10;
% control the samples generation
switch sweep_mode
case 'extrema'
% regular grid sweep (all combinations)
sweep.type = 'all_combinations';
% maximum sumber of resulting sample
sweep.n_sol_max = 10e3;
% two samples per variables (two samples: only the extreme cases)
n = 2;
% samples generation: linear
span = 'linear';
case 'random'
% regular vector sweep (specified combinations)
sweep.type = 'specified_combinations';
% maximum sumber of resulting sample
sweep.n_sol_max = 10e3;
% number of samples
n = 5000;
% samples generation: linear
span = 'random';
otherwise
error('invalid sweep method')
end
% struct with the description of a variable with a given fixed vector
% - type: type of the variable ('fixed')
% - vec: vector with the values
% struct with the description of a variable with random picks from a given discrete set
% - type: type of the variable ('randset')
% - set: values of the discrete set for the picks
% - n: number of samples to be generated for the variable
% struct with the description of a variable with a regularly spaced span
% - type: type of the variable ('span')
% - var_trf: variable transformation applied to the variable
% - none: no transformation
% - rev: '1/x' transformation
% - log: 'log10(x)' transformation
% - exp: '10^x' transformation
% - square: 'x^2' transformation
% - sqrt: 'sqrt(2)' transformation
% - var_type: variable type
% - int: integer variable
% - float: real variable
% - span: generation method
% - 'linear': linear span (after variable transformation)
% - 'random': uniform random span (after variable transformation)
% - 'normal': normal random span (after variable transformation)
% - lb: variable lower bound
% - ub: variable upper bound
% - n: number of samples to be generated for the variable
sweep.var = struct();
if any(strcmp(model_type, {'ht', 'mf'}))
% ratio between the height and width and the winding window
sweep.var.fact_window = struct('type', 'span', 'var_trf', 'log', 'var_type', 'float', 'span', span, 'lb', 2.0, 'ub', 4.0, 'n', n);
% ratio between the length and width of the core cross section
sweep.var.fact_core = struct('type', 'span', 'var_trf', 'log', 'var_type', 'float', 'span', span, 'lb', 1.0, 'ub', 3.0, 'n', n);
% ratio between the core cross section and the winding window cross section
sweep.var.fact_core_window = struct('type', 'span', 'var_trf', 'log', 'var_type', 'float', 'span', span, 'lb', 0.3, 'ub', 3.0, 'n', n);
% ratio between the air gap length and the square root of the core cross section
sweep.var.fact_gap = struct('type', 'span', 'var_trf', 'log', 'var_type', 'float', 'span', span, 'lb', 0.005, 'ub', 0.3, 'n', n);
% inductor box volume
sweep.var.V_box = struct('type', 'span', 'var_trf', 'log', 'var_type', 'float', 'span', span, 'lb', 10e-6, 'ub', 1000e-6, 'n', n);
end
if strcmp(model_type, 'mf')
% ratio between the inductor current and the saturation current
sweep.var.r_sat = struct('type', 'span', 'var_trf', 'log', 'var_type', 'float', 'span', span, 'lb', 0.001, 'ub', 1.0, 'n', n);
% permeability of the core for the FEM simulation
sweep.var.mu_core = struct('type', 'span', 'var_trf', 'none', 'var_type', 'float', 'span', span, 'lb', 1500.0, 'ub', 3000.0, 'n', n);
% beta (Steinmetz parameter) of the core for the FEM simulation
sweep.var.beta_core = struct('type', 'span', 'var_trf', 'none', 'var_type', 'float', 'span', span, 'lb', 2.0, 'ub', 2.8, 'n', n);
end
if strcmp(model_type, 'ht')
% total losses (core and winding) divided by the area of the boxed inductor
sweep.var.p_surface = struct('type', 'span', 'var_trf', 'log', 'var_type', 'float', 'span', span, 'lb', 0.001e4, 'ub', 1e4, 'n', n);
% ratio between the winding losses and core losses
sweep.var.r_winding_core = struct('type', 'span', 'var_trf', 'log', 'var_type', 'float', 'span', span, 'lb', 0.02, 'ub', 50.0, 'n', n);
% convection coefficient reference value
sweep.var.h_convection = struct('type', 'span', 'var_trf', 'none', 'var_type', 'float', 'span', span, 'lb', 15.0, 'ub', 30.0, 'n', n);
% ambient temperature
sweep.var.T_ambient = struct('type', 'span', 'var_trf', 'none', 'var_type', 'float', 'span', span, 'lb', 25.0, 'ub', 65.0, 'n', n);
end
% COMSOL model path
file_model = ['run_dataset/model/model_' model_type '.mph'];
% type of the different variables used in the solver
% - geom_type: type of the geometry input variables
% - 'rel': boxed volume, geometrical aspect ratio, and relative air gap length
% - 'abs': absolute core, winding, and air gap length
% - excitation_type: type of the excitation input variables
% - 'rel': relative excitation (current density, losses per surface, etc.)
% - 'abs': absolute excitation (current value, loss values, etc.)
var_type.geom_type = 'rel';
var_type.excitation_type = 'rel';
end