%% Calculate Average Power Losses for Components of a Block
%
% You can calculate average power losses for the individual components 
% of a block in your model.
% 
% 1. Open the Push-Pull Buck Converter in Continuous Conduction Mode 
% example model. At the MATLAB&reg; command prompt, enter
model = 'ee_push_pull_converter_ccm';
open_system(model)
%% 
% The model has data logging enabled.
%% 
% 2. Add a diode component in the N-Channel MOSFET 1 block using the
% MATLAB&reg; command prompt:
set_param('ee_push_pull_converter_ccm/ N-Channel  MOSFET 1','diode_param','2')
%% 
% Alternatively, you can add the component in the Simulink(R) Editor:
%%
% a. Open the Property Inspector pane. In the model window, in the menu 
% bar, click *View* > *Property Inspector* 
%%
% b. Click the N-Channel MOSFET1 block to access the block parameters.
%%
% c. In the Property Inspector pane, expand the Integral Diode setting and 
% change the value for the *Integral protection* from |None| to 
% |Protection diode with no dynamics|. 
%%
% 3. Run the simulation, create a simulation log variable, and open 
% the simlog in the Simscape Results Explorer using the |sscexplore| 
% function.
%%
sim(model)
sscexplore(simlog_ee_push_pull_converter_ccm)
%%
% 4. View the power loss data for the two N-Channel MOSFET blocks, 
% expand these nodes and CTRL + click the |power_dissipated| nodes:
%%
% * |N_Channel_MOSFET_1 > diode > power_dissipated|
% * |N_Channel_MOSFET_1 > mosfet_equation > power_dissipated|
% * |N_Channel_MOSFET_2 > mosfet_equation > power_dissipated|
%%
% <<../ee_getpowerlosssummary_ssc_push_pull_ccm.png>>

%%
% The N-Channel MOSFET 2 block has only one |power_dissipated| variable. 
% The N-Channel MOSFET 1 block has one power_dissipated variable for each 
% of the two components (MOSFET and diode) that the block contains.
%%
% 5. Calculate power losses for both components of the N-Channel MOSFET 1 
% block and display the results in a table
%%
tabulatedLosses = ee_getPowerLossSummary(simlog_ee_push_pull_converter_ccm.N_Channel_MOSFET_1)
%%
% The table shows the combined dissipated power losses for both the diode 
% and the MOSFET components of the N-Channel MOSFET 1 block, averaged over 
% the total simulation time.
%%
% 6. Calculate power losses for only the diode component of the NChannel 
% MOSFET 1 block and display the results in a table.
%%
tabulatedLosses = ee_getPowerLossSummary(simlog_ee_push_pull_converter_ccm.N_Channel_MOSFET_1.diode)
%%
% The table shows dissipated power losses only for the diode component of 
% the block, averaged over the total simulation time.



%% 
% Copyright 2012 The MathWorks, Inc.