Solar Cell Parameter Extraction from Data
This example shows optimization of the Solar Cell block's parameters to fit data defined over a range of different temperatures. It uses the MATLAB® optimization function fminsearch
. Other products available for performing this type of parameter fitting with Simscape™ Electrical™ models are the Optimization Toolbox™ and Simulink® Design Optimization™. These products provide predefined functions to manipulate and analyze blocks using GUIs or a command line approach.
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
The MATLAB data file, ee_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, the VPulse block's Pulse value, V2, and to generate simulation output currents at prescribed voltages. The prescribed voltages are set by outputting simulation results at prescribed output times. To set the output times, on the Modeling tab, click Model Settings; in the Configuration Parameters, in the Data Import/Export category, click Additional parameters and specify the Output times. Scopes save the output voltage and current responses as structure data, Io.signal.values and Vo.signal.values.
% Load Solar Cell data load ee_solar_iv_data.mat % Display the Solar Cell model Model = 'ee_solar'; open_system(Model)
close_system(Model, 0);
Initial Parameter Specification
Starting values for fminsearch
can be estimated using a combination of Solar Cell block defaults, data sheet values and the following equations:
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 ];
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
Load 8 parameter Solar Cell model and set parameters
load_system(Model); set_param([Model '/Solar Cell'], 'prm', '3') 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
ee_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.
Optimize Main Tab Dialog Parameters at Room Temperature (Step 1)
% Find room temperature data index idx_data = find([iv_data.temperature]==25);%#ok % Optimize parameters in main dialog tab of Solar Cell ParsList = ParsListMain; OptParsMain = fminsearch(@ee_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.14978e-07 Iph = 3.80137 ec = 1.39989 Rs = 0.00415132 Rp = 10.1093
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(@ee_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.00080492 EG = 1.1384 TXIS1 = 3.3842
Display Optimized Curves
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');
bdclose(Model)