From d88ca91728d239d338683e17c900fd6c5cc93119 Mon Sep 17 00:00:00 2001 From: Thomas Guillod Date: Sun, 3 May 2020 22:10:57 +0200 Subject: [PATCH] Small change with the new dataset Split the compute and plot for a single design. --- README.md | 13 ++--- run_2_assemble.m | 2 +- run_5_compute.m => run_5_compute_all.m | 8 +-- run_7_single.m => run_6_compute_single.m | 11 ++-- run_6_plot.m => run_7_plot_all.m | 10 ++-- run_8_plot_single.m | 36 +++++++++++++ ...{master_compute.m => master_compute_all.m} | 15 +++--- ...aster_single.m => master_compute_single.m} | 38 +++---------- .../{master_plot.m => master_plot_all.m} | 12 ++--- .../inductor_design/master_plot_single.m | 50 +++++++++++++++++ source_input/design/get_design_data_vec.m | 2 +- ...ompute.m => get_design_data_compute_all.m} | 53 ++++++++++++++++--- ...gle.m => get_design_data_compute_single.m} | 6 +-- ...data_plot.m => get_design_data_plot_all.m} | 2 +- 14 files changed, 181 insertions(+), 77 deletions(-) rename run_5_compute.m => run_5_compute_all.m (89%) rename run_7_single.m => run_6_compute_single.m (82%) rename run_6_plot.m => run_7_plot_all.m (74%) create mode 100644 run_8_plot_single.m rename source_inductor/inductor_design/{master_compute.m => master_compute_all.m} (92%) rename source_inductor/inductor_design/{master_single.m => master_compute_single.m} (73%) rename source_inductor/inductor_design/{master_plot.m => master_plot_all.m} (72%) create mode 100644 source_inductor/inductor_design/master_plot_single.m rename source_input/{get_design_data_compute.m => get_design_data_compute_all.m} (82%) rename source_input/{get_design_data_single.m => get_design_data_compute_single.m} (95%) rename source_input/{get_design_data_plot.m => get_design_data_plot_all.m} (99%) diff --git a/README.md b/README.md index 96ece8b..b9b507e 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 ------------------------------------------------------------------------------- ``` diff --git a/run_2_assemble.m b/run_2_assemble.m index a4cf5ce..223bf1e 100644 --- a/run_2_assemble.m +++ b/run_2_assemble.m @@ -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) diff --git a/run_5_compute.m b/run_5_compute_all.m similarity index 89% rename from run_5_compute.m rename to run_5_compute_all.m index e9c475f..2361875 100644 --- a/run_5_compute.m +++ b/run_5_compute_all.m @@ -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. @@ -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 diff --git a/run_7_single.m b/run_6_compute_single.m similarity index 82% rename from run_7_single.m rename to run_6_compute_single.m index 1a44184..f21bf4b 100644 --- a/run_7_single.m +++ b/run_6_compute_single.m @@ -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) @@ -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 diff --git a/run_6_plot.m b/run_7_plot_all.m similarity index 74% rename from run_6_plot.m rename to run_7_plot_all.m index e61a2d8..8f8d966 100644 --- a/run_6_plot.m +++ b/run_7_plot_all.m @@ -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. @@ -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 diff --git a/run_8_plot_single.m b/run_8_plot_single.m new file mode 100644 index 0000000..1785c4d --- /dev/null +++ b/run_8_plot_single.m @@ -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 diff --git a/source_inductor/inductor_design/master_compute.m b/source_inductor/inductor_design/master_compute_all.m similarity index 92% rename from source_inductor/inductor_design/master_compute.m rename to source_inductor/inductor_design/master_compute_all.m index 312da45..bec8932 100644 --- a/source_inductor/inductor_design/master_compute.m +++ b/source_inductor/inductor_design/master_compute_all.m @@ -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. @@ -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 @@ -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') @@ -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 @@ -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 diff --git a/source_inductor/inductor_design/master_single.m b/source_inductor/inductor_design/master_compute_single.m similarity index 73% rename from source_inductor/inductor_design/master_single.m rename to source_inductor/inductor_design/master_compute_single.m index 07c5501..7e1f23d 100644 --- a/source_inductor/inductor_design/master_single.m +++ b/source_inductor/inductor_design/master_compute_single.m @@ -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) @@ -15,7 +14,7 @@ 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 @@ -23,7 +22,7 @@ function master_single(file_single, file_export, eval_ann, data_compute) % (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') @@ -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 @@ -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 diff --git a/source_inductor/inductor_design/master_plot.m b/source_inductor/inductor_design/master_plot_all.m similarity index 72% rename from source_inductor/inductor_design/master_plot.m rename to source_inductor/inductor_design/master_plot_all.m index 5ed2a06..307a0b9 100644 --- a/source_inductor/inductor_design/master_plot.m +++ b/source_inductor/inductor_design/master_plot_all.m @@ -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. @@ -8,7 +8,7 @@ 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 @@ -16,11 +16,11 @@ function master_plot(file_compute, fct_data, plot_param, text_param) % (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; @@ -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 \ No newline at end of file diff --git a/source_inductor/inductor_design/master_plot_single.m b/source_inductor/inductor_design/master_plot_single.m new file mode 100644 index 0000000..2d33b38 --- /dev/null +++ b/source_inductor/inductor_design/master_plot_single.m @@ -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 diff --git a/source_input/design/get_design_data_vec.m b/source_input/design/get_design_data_vec.m index e949b05..b83effc 100644 --- a/source_input/design/get_design_data_vec.m +++ b/source_input/design/get_design_data_vec.m @@ -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 diff --git a/source_input/get_design_data_compute.m b/source_input/get_design_data_compute_all.m similarity index 82% rename from source_input/get_design_data_compute.m rename to source_input/get_design_data_compute_all.m index c7b90d8..6d17c17 100644 --- a/source_input/get_design_data_compute.m +++ b/source_input/get_design_data_compute_all.m @@ -1,4 +1,4 @@ -function [sweep, n_split, fct, eval_ann, data_compute] = get_design_data_compute(eval_type) +function [sweep, n_split, fct, eval_ann, data_compute] = get_design_data_compute_all(eval_type) % Return the data required for the computation of inductor designs. % % Define the variables and how to generate the samples. @@ -28,8 +28,8 @@ % struct with custom functions for filtering invalid designs: % - fct_filter_compute: filter the valid designs from the figure of merit (without the operating points) % - fct_filter_save: filter the valid designs from the figure of merit and the operating points -fct.fct_filter_compute = @(fom, n_sol) fom.is_valid; -fct.fct_filter_save = @(fom, operating, n_sol) operating.partial_load.is_valid&operating.full_load.is_valid; +fct.fct_filter_compute = @(fom, n_sol) fct_filter_compute(fom, n_sol); +fct.fct_filter_save = @(fom, operating, n_sol) fct_filter_save(fom, operating, n_sol); % data for controlling the evaluation of the ANN/regression: % - geom_type: type of the geometry input variables @@ -40,7 +40,7 @@ % - 'fem': get the FEM solution without the ANN/regression % - 'approx': get the analytical solution without the ANN/regression eval_ann.geom_type = 'rel'; -eval_ann.eval_type = 'ann'; +eval_ann.eval_type = eval_type; % inductor data (data which are not only numeric and common for all the sample) data_compute.data_const = get_design_data_const(); @@ -116,7 +116,7 @@ end function data_vec = get_data_vec(var, n_sol) -% Function for getting the inductor data (struct of vectors with one value per sample) +% Function for getting the inductor data (struct of vectors with one value per sample). % % Parameters: % var (struct): struct of vectors with the samples with all the combinations @@ -150,7 +150,7 @@ end function excitation = get_excitation(var, fom, n_sol) -% Function for getting the operating points data (struct of struct of vectors with one value per sample) +% Function for getting the operating points data (struct of struct of vectors with one value per sample). % % Parameters: % var (struct): struct of vectors with the samples with all the combinations @@ -182,3 +182,44 @@ excitation.partial_load = get_design_excitation(L, T_ambient, f, load_partial_load, type); end + +function is_filter = fct_filter_compute(fom, n_sol) +% Filter the design to be kept for the computation of the operating points. +% +% Parameters: +% fom (struct): figures of merit of the designs +% n_sol (int): number of provided designs +% +% Returns: +% is_filter (vector): vector of logical with the design to be kept + +% check size +assert(isnumeric(n_sol), 'invalid number of samples') + +% select the designs +is_filter = fom.is_valid; + +end + +function is_filter = fct_filter_save(fom, operating, n_sol) +% Filter the design to be saved. +% +% Parameters: +% fom (struct): figures of merit of the designs +% operating (struct): operating points of the designs +% n_sol (int): number of provided designs +% +% Returns: +% is_filter (vector): vector of logical with the design to be saved + +% check size +assert(isnumeric(n_sol), 'invalid number of samples') + +% select the designs +is_filter = fom.is_valid; +is_filter = is_filter&operating.partial_load.is_valid; +is_filter = is_filter&operating.full_load.is_valid; +is_filter = is_filter&(operating.partial_load.losses.P_tot<=4.0); +is_filter = is_filter&(operating.full_load.losses.P_tot<=6.0); + +end \ No newline at end of file diff --git a/source_input/get_design_data_single.m b/source_input/get_design_data_compute_single.m similarity index 95% rename from source_input/get_design_data_single.m rename to source_input/get_design_data_compute_single.m index fe9b027..7c9b48f 100644 --- a/source_input/get_design_data_single.m +++ b/source_input/get_design_data_compute_single.m @@ -1,4 +1,4 @@ -function [eval_ann, data_compute] = get_design_data_single(eval_type) +function [eval_ann, data_compute] = get_design_data_compute_single(eval_type) % Return the data required for the computation of a single inductor design. % % How to evaluate the ANN/regression. @@ -36,7 +36,7 @@ end function data_vec = get_data_vec() -% Function for getting the inductor data (struct of scalars) +% Function for getting the inductor data (struct of scalars). % % Returns: % data_vec (struct:) struct of scalars @@ -63,7 +63,7 @@ end function excitation = get_excitation(fom) -% Function for getting the operating points data (struct of struct of scalars) +% Function for getting the operating points data (struct of struct of scalars). % % Parameters: % fom (struct): computed inductor figures of merit diff --git a/source_input/get_design_data_plot.m b/source_input/get_design_data_plot_all.m similarity index 99% rename from source_input/get_design_data_plot.m rename to source_input/get_design_data_plot_all.m index 0c9cd0d..4c0d866 100644 --- a/source_input/get_design_data_plot.m +++ b/source_input/get_design_data_plot_all.m @@ -1,4 +1,4 @@ -function [fct_data, plot_param, text_param] = get_design_data_plot() +function [fct_data, plot_param, text_param] = get_design_data_plot_all() % Return the data required for the Pareto plots of the inductor designs. % % Define the variables.