Skip to content

Commit

Permalink
Small change with the new dataset
Browse files Browse the repository at this point in the history
Split the compute and plot for a single design.
  • Loading branch information
otvam committed May 3, 2020
1 parent 62917a6 commit d88ca91
Show file tree
Hide file tree
Showing 14 changed files with 181 additions and 77 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ The following code structure is considered:
* [run_2_assemble.m](run_2_assemble.m) - Assemble the FEM simulations results, add the analytical solutions
* [run_3_train.m](run_3_train.m) - Train the regressions with ANNs with simulation results
* [run_4_export.m](run_4_export.m) - Export the ANNs in prevision of the evaluation of inductor designs
* [run_5_compute.m](run_5_compute.m) - Simulate many inductor designs with the help of the ANNs
* [run_6_plot.m](run_6_plot.m) - Plot the results in a GUI
* [run_7_single.m](run_7_single.m) - Run and plot a single design
* [run_5_compute_all.m](run_5_compute_all.m) - Simulate many inductor designs (ANN or ana. approx.)
* [run_6_compute_single.m](run_6_compute_single.m) - Simulate a single inductor design (ANN or FEM or ana. approx)
* [run_7_plot_all.m](run_7_plot_all.m) - Plot the optimization results (Pareto fronts) in a GUI
* [run_8_plot_single.m](run_8_plot_single.m) - Display a single design in a GUI
* [run_ann_server.py](run_ann_server.py) - Python ANN server for using Keras and TensorFlow from MATLAB
* Shell script (Linux) and (batch) script (MS Windows) for starting the Python ANN server
* Shell script (Linux) and (batch) script (MS Windows) for starting the COMSOL MATLAB Livelink
Expand Down Expand Up @@ -133,13 +134,13 @@ The releases are available at GitHub and contains:
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
MATLAB 99 1618 4709 4500
MATLAB 101 1644 4767 4542
Python 8 365 446 450
Markdown 4 75 0 275
Markdown 4 74 0 277
DOS Batch 3 9 0 34
Bourne Shell 3 9 9 21
-------------------------------------------------------------------------------
SUM: 117 2076 5164 5280
SUM: 119 2101 5222 5324
-------------------------------------------------------------------------------
```

Expand Down
2 changes: 1 addition & 1 deletion run_2_assemble.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function run_sub(model_type)
file_assemble = ['data/' model_type '_assemble.mat'];

% make a zip file and remove the folder (or not)
make_zip = false;
make_zip = true;

% assemble the data
master_assemble(file_assemble, folder_fem, make_zip)
Expand Down
8 changes: 4 additions & 4 deletions run_5_compute.m → run_5_compute_all.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function run_5_compute()
function run_5_compute_all()
% Compute many inductor inductor designs (properties, thermal, losses, etc.).
%
% Load the ANN/regression obtained with the FEM/ANN workflow.
Expand Down Expand Up @@ -43,12 +43,12 @@ function run_sub(eval_type)
file_export = 'data/export.mat';

% path of the file to be written with the computed designs
file_compute = ['data/compute_' eval_type '.mat'];
file_compute = ['data/compute_all_' eval_type '.mat'];

% get the design parameters for the inductors
[sweep, n_split, fct, eval_ann, data_compute] = get_design_data_compute(eval_type);
[sweep, n_split, fct, eval_ann, data_compute] = get_design_data_compute_all(eval_type);

% compute the inductor designs
master_compute(file_compute, file_export, sweep, n_split, fct, eval_ann, data_compute)
master_compute_all(file_compute, file_export, sweep, n_split, fct, eval_ann, data_compute)

end
11 changes: 5 additions & 6 deletions run_7_single.m → run_6_compute_single.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
function run_7_single()
% Compute and plot a single inductor design.
function run_6_compute_single()
% Compute a single inductor design.
%
% Load the ANN/regression obtained with the FEM/ANN workflow.
% Compute the specified design.
% Show the design with a GUI.
%
% Use the ANN/regression (or FEM or analytical approximation) is used for predicting:
% - the thermal model (hotspot and average temperatures)
Expand Down Expand Up @@ -39,12 +38,12 @@ function run_sub(eval_type)
file_export = 'data/export.mat';

% path of the file to be written with the computed single design
file_single = ['data/single_' eval_type '.mat'];
file_single = ['data/compute_single_' eval_type '.mat'];

% get the design parameters for the inductor
[eval_ann, data_compute] = get_design_data_single(eval_type);
[eval_ann, data_compute] = get_design_data_compute_single(eval_type);

% compute and plot the inductor design
master_single(file_single, file_export, eval_ann, data_compute)
master_compute_single(file_single, file_export, eval_ann, data_compute)

end
10 changes: 5 additions & 5 deletions run_6_plot.m → run_7_plot_all.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function run_6_plot()
% Display inductors design in a GUI.
function run_7_plot_all()
% Display many inductors design in a GUI.
%
% Start a GUI with several Pareto fronts.
% Plots can be customized.
Expand All @@ -26,12 +26,12 @@ function run_sub(eval_type)
% eval_type (str): type of the evaluation ('ann', or approx')

% path of the file contained the computed designs
file_compute = ['data/compute_' eval_type '.mat'];
file_compute = ['data/compute_all_' eval_type '.mat'];

% get the GUI parameters
[fct_data, plot_param, text_param] = get_design_data_plot();
[fct_data, plot_param, text_param] = get_design_data_plot_all();

% start the GUI
master_plot(file_compute, fct_data, plot_param, text_param)
master_plot_all(file_compute, fct_data, plot_param, text_param)

end
36 changes: 36 additions & 0 deletions run_8_plot_single.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
function run_8_plot_single()
% Plot a single inductor design in a GUI.
%
% Start a GUI with the design.
% Show the geometry.
% Show the figures of merit.
% Show the operating points.
%
% (c) 2019-2020, ETH Zurich, Power Electronic Systems Laboratory, T. Guillod

init_toolbox();

% run model with ANN/regression
run_sub('ann')

% run model with analytical approximation
run_sub('approx')

% run model with FEM simulation
run_sub('fem')

end

function run_sub(eval_type)
% Run the FEM % Compute and plot a single inductor design (with different evaluation methods).
%
% Parameters:
% eval_type (str): type of the evaluation ('fem', 'ann', or approx')

% path of the file to be written with the computed single design
file_single = ['data/compute_single_' eval_type '.mat'];

% compute and plot the inductor design
master_plot_single(file_single)

end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function master_compute(file_compute, file_export, sweep, n_split, fct, eval_ann, data_compute)
function master_compute_all(file_compute_all, file_export, sweep, n_split, fct, eval_ann, data_compute)
% Compute many inductor inductor designs (properties, thermal, losses, etc.).
%
% Load the ANN/regression obtained with the FEM/ANN workflow.
Expand All @@ -22,7 +22,7 @@ function master_compute(file_compute, file_export, sweep, n_split, fct, eval_ann
% - use 'start_python_ann_server.sh' on Linux
%
% Parameters:
% file_compute (str): path of the file to be written with the computed designs
% file_compute_all (str): path of the file to be written with the computed designs
% file_export (str): path of the file containing the exported data from the FEM/ANN
% sweep (cell): data controlling the generation of the design combinations
% n_split (int): number of vectorized designs per computation
Expand All @@ -33,7 +33,7 @@ function master_compute(file_compute, file_export, sweep, n_split, fct, eval_ann
% (c) 2019-2020, ETH Zurich, Power Electronic Systems Laboratory, T. Guillod

% init
fprintf('################## master_compute\n')
fprintf('################## master_compute_all\n')

% load the FEM/ANN data
fprintf('load\n')
Expand Down Expand Up @@ -82,9 +82,9 @@ function master_compute(file_compute, file_export, sweep, n_split, fct, eval_ann

% save data
fprintf('save\n')
save(file_compute, '-v7.3', 'diff', 'n_tot', 'n_compute', 'n_sol', 'id_design', 'fom', 'operating')
save(file_compute_all, '-v7.3', 'diff', 'n_tot', 'n_compute', 'n_sol', 'id_design', 'fom', 'operating')

fprintf('################## master_compute\n')
fprintf('################## master_compute_all\n')

end

Expand All @@ -96,7 +96,10 @@ function master_compute(file_compute, file_export, sweep, n_split, fct, eval_ann
% - filter the designs
% - then, the figures of merit and the of the operating points are extracted
% - filter the designs
% - with this workflow, it is possible to avoid the computation of operating points of rubbish designs
%
% With this workflow, it is possible:
% - to avoid the computation of operating points of rubbish designs
% - to avoid the saving of invalid designs
%
% Parameters:
% var (struct): struct of vectors with the samples with all the combinations
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
function master_single(file_single, file_export, eval_ann, data_compute)
% Compute and plot a single inductor design.
function master_compute_single(file_compute_single, file_export, eval_ann, data_compute)
% Compute a single inductor design.
%
% Load the ANN/regression obtained with the FEM/ANN workflow.
% Compute the specified design.
% Show the design with a GUI.
%
% Use the ANN/regression are used for predicting:
% - the thermal model (hotspot and average temperatures)
Expand All @@ -15,15 +14,15 @@ function master_single(file_single, file_export, eval_ann, data_compute)
% - use 'start_python_ann_server.sh' on Linux
%
% Parameters:
% file_single (str): path of the file to be written with the computed single design
% file_compute_single (str): path of the file to be written with the computed single design
% file_export (str): path of the file containing the exported data from the FEM/ANN
% eval_ann (struct): data for controlling the evaluation of the ANN/regression
% data_compute (struct): data for the inductor design
%
% (c) 2019-2020, ETH Zurich, Power Electronic Systems Laboratory, T. Guillod

% init
fprintf('################## master_single\n')
fprintf('################## master_compute_single\n')

% load the FEM/ANN data
fprintf('load\n')
Expand Down Expand Up @@ -51,13 +50,9 @@ function master_single(file_single, file_export, eval_ann, data_compute)

% save data
fprintf('save\n')
save(file_single, '-v7.3', 'fom', 'operating')
save(file_compute_single, '-v7.3', 'fom', 'operating')

% gui
fprintf('gui\n')
plot_design(fom, operating)

fprintf('################## master_single\n')
fprintf('################## master_compute_single\n')

end

Expand Down Expand Up @@ -88,24 +83,3 @@ function master_single(file_single, file_export, eval_ann, data_compute)
operating = inductor_compute_obj.get_operating(excitation);

end

function plot_design(fom, operating)
% Display the computed design with a GUI.
%
% Parameters:
% fom (struct): computed figures of merit
% operating (struct): computed operating points

% single design is required
id_design = 1;

% create GUI object
inductor_gui = design_display.InductorGui(id_design, fom, operating);

% set design
inductor_gui.set_id_select(id_design)

% launch gui
inductor_gui.open_gui()

end
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function master_plot(file_compute, fct_data, plot_param, text_param)
% Display inductors design in a GUI.
function master_plot_all(file_compute_all, fct_data, plot_param, text_param)
% Display many inductors design in a GUI.
%
% Start a GUI with several Pareto fronts.
% Plots can be customized.
Expand All @@ -8,19 +8,19 @@ function master_plot(file_compute, fct_data, plot_param, text_param)
% Details on a specific design (geometry, operating points, etc.).
%
% Parameters:
% file_compute (str): path of the file contained the computed designs
% file_compute_all (str): path of the file contained the computed designs
% fct_data (fct): function for getting the designs be plotted and getting the user defined custom figures of merit
% plot_param (struct): definition of the different plots
% text_param (struct): definition of variable to be shown in the text field
%
% (c) 2019-2020, ETH Zurich, Power Electronic Systems Laboratory, T. Guillod

% init
fprintf('################## master_plot\n')
fprintf('################## master_plot_all\n')

% load the designs
fprintf('load\n')
data_compute = load(file_compute);
data_compute = load(file_compute_all);
id_design = data_compute.id_design;
fom = data_compute.fom;
operating = data_compute.operating;
Expand All @@ -30,6 +30,6 @@ function master_plot(file_compute, fct_data, plot_param, text_param)
design_display.ParetoGui(id_design, fom, operating, fct_data, plot_param, text_param);

% teardown
fprintf('################## master_plot\n')
fprintf('################## master_plot_all\n')

end
50 changes: 50 additions & 0 deletions source_inductor/inductor_design/master_plot_single.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
function master_plot_single(file_compute_single)
% Plot a single inductor design in a GUI.
%
% Start a GUI with the design.
% Show the geometry.
% Show the figures of merit.
% Show the operating points.
%
% Parameters:
% file_compute_single (str): path of the file to be written with the computed single design
%
% (c) 2019-2020, ETH Zurich, Power Electronic Systems Laboratory, T. Guillod

% init
fprintf('################## master_plot_single\n')

% load the FEM/ANN data
fprintf('load\n')
data_tmp = load(file_compute_single);
fom = data_tmp.fom;
operating = data_tmp.operating;

% gui
fprintf('gui\n')
plot_design(fom, operating)

fprintf('################## master_plot_single\n')

end

function plot_design(fom, operating)
% Display the computed design with a GUI.
%
% Parameters:
% fom (struct): computed figures of merit
% operating (struct): computed operating points

% single design is required
id_design = 1;

% create GUI object
inductor_gui = design_display.InductorGui(id_design, fom, operating);

% set design
inductor_gui.set_id_select(id_design)

% launch gui
inductor_gui.open_gui()

end
2 changes: 1 addition & 1 deletion source_input/design/get_design_data_vec.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function data_vec = get_design_data_vec(geom, f)
% Function for getting the inductor data (struct of scalars)
% Function for getting the inductor data (struct of scalars).
%
% Parameters:
% geom (struct): inductor geomtry information
Expand Down
Loading

0 comments on commit d88ca91

Please sign in to comment.