Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

SOLAR CELL PARAMETER EXTRACTION FROM DATA elec_solar_opt_m.

m (1/12) This demo extracts block parameters to model Solar Cell current-voltage data at different temperatures using the MATLAB(R) optimization function |fminsearch|. Other products available for performing this analysis with SimElectronics(TM) models are Optimization Toolbox(TM) and Simulink(R) Design Optimization(TM). These products provide predefined functions to manipulate and analyze blocks using GUIs or a command line approach. --------------------------------------------------------------------------elec_solar_opt_m.m (2/12) --------------------------------------------------------------------------STRATEGY Fit I-V output curves for an 8 Parameter Solar Cell to data using a 2 step procedure: # Optimize parameters in the Solar Cell Main dialog tab to match output curves to data at room temperature. # Optimize parameters in the Solar Cell Temperature dialog tab to match output curves to data at non-room temperatures. --------------------------------------------------------------------------DATA AND BLOCK SETUP elec_solar_opt_m.m (3/12) The MATLAB data file, _elec_solar_iv_data.mat_, stores Solar Cell data as an array of structures. Each structure contains 3 fields: _temperature_ , _i_ (current) and _v_ (voltage). The Solar Cell block references a data structure to set the device operating temperature with the _SPICE Environment Parameters block_, to set the _VPulse_ block's pulse value and to generate simulation output currents at prescribed voltages specified in the _Configuration Parameters Data Import/Export Pane Output times option_ under the Simulation menu. Scopes save the output voltage and current responses as structure data, Io.signal.values and Vo.signal.values. --------------------------------------------------------------------------% Load Solar Cell data load elec_solar_iv_data.mat % Display the Solar Cell model Model = 'elec_solar'; open_system(Model) elec_solar_opt_m.m (4/12) --------------------------------------------------------------------------close_system(Model, 0); --------------------------------------------------------------------------INITIAL PARAMETER SPECIFICATION elec_solar_opt_m.m (5/12) Starting values for |fminsearch| can be estimated using a combination of Solar Cell block defaults, data sheet values and the following equations: $$I_{ph} = I_{sc}$$ $$I_s = {I_{ph} \over (exp(V_{oc} / (.025*ec)) - 1)}$$ $$R_s = {-dV \over dI} @V_{oc}$$ $$R_p = {-dV \over dI} @I_{sc}$$ List of parameters and initial values prior to optimization --------------------------------------------------------------------------ParsListMain = {'Is', 'Iph', 'ec', 'Rs', 'Rp'}; InitGuessMain = [ 3e-7 3.8 1.5 .004 10 ]; ParsListTemp = {'TIPH1', 'EG', 'TXIS1'}; InitGuessTemp = [ .001 1.11 3 ];

elec_solar_opt_m.m (6/12) --------------------------------------------------------------------------Since |fminsearch| is an unconstrained nonlinear optimizer that locates a local minimum of a function, varying the initial estimate will result in a different solution set. --------------------------------------------------------------------------PLOT DATA VERSUS SOLAR CELL OUTPUT USING INITIAL PARAMETERS elec_solar_opt_m.m (7/12) Load 8 parameter Solar Cell model and set parameters --------------------------------------------------------------------------load_system(Model); set_param([Model '/Solar Cell'], 'prm', '3', 'TOFFSET', '0') Pars = reshape([ParsListMain; cellstr(num2str(InitGuessMain'))'],1,[]); set_param([Model '/Solar Cell'], Pars{:}) Pars = reshape([ParsListTemp; cellstr(num2str(InitGuessTemp'))'],1,[]); set_param([Model '/Solar Cell'], Pars{:}) % Generate preliminary model curves and plot against data num_lines = length(iv_data); v_model = cell(1, num_lines); i_model = cell(1, num_lines); legend_info_data = cell(1, num_lines); legend_info_model = cell(1, num_lines); for idx_data = 1:num_lines sim(Model); v_model{idx_data} = Vo.signals.values; i_model{idx_data} = Io.signals.values; legend_info_data{idx_data} = [ 'Temp = ' ... num2str(iv_data(idx_data).temperature) '\circC, Data']; legend_info_model{idx_data} = [ 'Temp = ' ... num2str(iv_data(idx_data).temperature) '\circC, Model']; end plot([iv_data.v], [iv_data.i], 'd', [v_model{:}], [i_model{:}]) xlabel('Solar cell output voltage (V)'); ylabel('Solar cell output current (A)'); legend([legend_info_data legend_info_model], 'Location', 'Best'); title('Model with Initial Parameter Values'); --------------------------------------------------------------------------SUM OF SQUARES OF ERROR CALCULATION elec_solar_opt_m.m (8/12) |elec_solar_lse| is the function to be minimized by |fminsearch|. This function returns a sum of squares of error for the difference between the solar cell output current and the data. If an invalid parameter value is supplied by |fminsearch|, the |catch| statement returns a large value for the error. It is possible to pass data into this function as an additional argument, removing the need for |evalin| functions. However, if a nested function is used to calculate the sum of squares of error the Simulink destination workspace needs to be set with the |simset| command. Display file elec_solar_lse.m --------------------------------------------------------------------------type elec_solar_lse.m function lse = elec_solar_lse(params) % % Copyright 2008 The MathWorks, Inc. %

% Calculate and return sum of squares of the differences ParsList = evalin('base', 'ParsList'); Pars = reshape([ParsList; cellstr(num2str(params'))'],1,[]); iv_data = evalin('base', 'iv_data'); idx_data = evalin('base', 'idx_data'); Model = evalin('base', 'Model'); lse = 0; for idx = idx_data assignin('base', 'idx_data', idx); set_param([Model '/Solar Cell'], Pars{:}) % Catch invalid parameters supplied by fminsearch try sim(Model); % Difference between block current output and data data_diff = Io.signals.values-iv_data(idx).i; lse = lse + (data_diff'*data_diff); catch % For invalid parameters return a large function error lse = 100; end end end --------------------------------------------------------------------------OPTIMIZE MAIN TAB DIALOG PARAMETERS AT ROOM TEMPERATURE (STEP 1) % Find room temperature data index idx_data = find([iv_data.temperature]==25); % Optimize parameters in main dialog tab of Solar Cell ParsList = ParsListMain; OptParsMain = fminsearch(@elec_solar_lse, InitGuessMain, optimset('TolX', 1e-3)); % Update Solar Cell block with optimized parameters Pars = reshape([ParsList; cellstr(num2str(OptParsMain'))'],1,[]); set_param([Model '/Solar Cell'], Pars{:}); % Display optimized parameters display(sprintf(['Optimized parameters for the solar cell main ' 'dialog tab are:\n'])); display(sprintf('\t%5s = %s\n', Pars{:})); Optimized parameters for the solar cell main dialog tab are: Is = 3.14991e-007 Iph = 3.80143 ec = 1.39989 Rs = 0.00415127 Rp = 10.1088

elec_solar_opt_m.m (9/12)

...

...

---------------------------------------------------------------------------

OPTIMIZE PARAMETERS CONTROLLING TEMPERATURE DEPENDENCE (STEP 2) % Find index into data for non-room temperatures idx_data = find([iv_data.temperature]~=25); % Optimize parameters in temperature dialog tab of Solar Cell ParsList = ParsListTemp; OptParsTemp = fminsearch(@elec_solar_lse, InitGuessTemp, optimset('TolX', 1e-3)); % Update Solar Cell block with optimized temperature parameters Pars = reshape([ParsList; cellstr(num2str(OptParsTemp'))'],1,[]); set_param([Model '/Solar Cell'], Pars{:}); % Display optimized parameters display(sprintf(['Optimized parameters for the solar cell ' ... 'temperature dialog tab are:\n'])); display(sprintf('\t%5s = %s\n', Pars{:})); Optimized parameters for the solar cell temperature dialog tab are: TIPH1 = 0.00080491 EG = 1.1385 TXIS1 = 3.3812 --------------------------------------------------------------------------DISPLAY OPTIMIZED CURVES elec_solar_opt_m.m (11/12) for idx_data = 1:num_lines sim(Model); v_model{idx_data} = Vo.signals.values; i_model{idx_data} = Io.signals.values; end plot([iv_data.v], [iv_data.i], 'd', [v_model{:}], [i_model{:}]) xlabel('Solar cell output voltage (V)'); ylabel('Solar cell output current (A)'); legend([legend_info_data legend_info_model], 'Location', 'Best'); title('Model with Optimized Parameter Values'); elec_solar_opt_m.m (12/12) --------------------------------------------------------------------------bdclose(Model)

elec_solar_opt_m.m (10/12)

...

You might also like