Commit 1422b1f4 authored by Angioni's avatar Angioni

inserted some comments in the code

parent e8e84983
......@@ -29,47 +29,26 @@ results_DSSE_WLS2=struct;results_DSSE_WLS2.err_Vmagnitude=[];results_DSSE_WLS2.e
results_DSSE_WLS=struct;results_DSSE_WLS.err_Vmagnitude=[];results_DSSE_WLS.err_Vphase=[];results_DSSE_WLS.Vmagn_status=[];results_DSSE_WLS.Vph_status=[];results_DSSE_WLS.Imagn_status=[];results_DSSE_WLS.Iph_status=[];results_DSSE_WLS.Vreal_status=[];results_DSSE_WLS.Vimag_status=[];results_DSSE_WLS.Ireal_status=[];results_DSSE_WLS.Iimag_status=[];results_DSSE_WLS.Vmagn_true=[];results_DSSE_WLS.Vph_true=[];results_DSSE_WLS.Imagn_true=[];results_DSSE_WLS.Iph_true=[];results_DSSE_WLS.Vreal_true=[];results_DSSE_WLS.Vimag_true=[];results_DSSE_WLS.Ireal_true=[];results_DSSE_WLS.Iimag_true=[];results_DSSE_WLS.err_Imagnitude=[];results_DSSE_WLS.err_Iphase=[];results_DSSE_WLS.err_Ireal=[];results_DSSE_WLS.err_Iimag=[];results_DSSE_WLS.err_Vreal=[];results_DSSE_WLS.err_Vimag=[];results_DSSE_WLS.err_Vmagnitude_in =[];results_DSSE_WLS.err_Vphase_in=[];results_DSSE_WLS.err_Imagnitude_in =[];results_DSSE_WLS.err_Iphase_in =[];results_DSSE_WLS.err_Ireal_in =[];results_DSSE_WLS.err_Iimag_in =[];results_DSSE_WLS.Vmagn_measured =[];results_DSSE_WLS.Vph_measured =[];
%select type of model among 'single_phase' 'three_phase_sequence' 'three_phase_unbalance'
type_of_model = 'three_phase_unbalance';
[GridData] = generate_GridData(type_of_model);
[PowerData] = generate_PowerData(GridData); %in this case we have only one power flow central scenario
[Test_SetUp,Combination_devices,Accuracy] = generate_DSSEConfData(GridData);
[GridData] = generate_GridData(type_of_model);%in this function the static model is generated
[PowerData] = generate_PowerData(GridData); %in this function the power flow is run in order to obtain the reference values to test the state estimator
[Test_SetUp,Combination_devices,Accuracy] = generate_DSSEConfData(GridData);%here the test configuration data are set: measurement devices location and accuracy
[W,GridData,R] = Weight_m(GridData,PowerData,Combination_devices,Accuracy);
[Meas_true_vector] = calc_Mvector_external(GridData,PowerData);
[W,GridData,R] = Weight_m(GridData,PowerData,Combination_devices,Accuracy); %weight and covariance matrix of the state estimator
[Meas_true_vector] = calc_Mvector_external(GridData,PowerData); %vector with reference values of the measurements
for z = 1 : Test_SetUp.N_MC
Number_MC = z
%Meas_vector_external = Meas_true_vector + diag(sqrt(diag(R)))*randn(GridData.MeasNum,1);
Meas_vector_external = mvnrnd(Meas_true_vector, R)';
[Vmagn_status_WLS,Vph_status_WLS] = VRIDSSE(Meas_vector_external,W,GridData,Test_SetUp);
for z = 1 : Test_SetUp.N_MC %in this for loop the Monte Carlo tests are run
%Number_MC = z
[Vmagn_status_WLS2,Vph_status_WLS2,Imagn_status_WLS2,Iph_status_WLS2] = IRIDSSE(Meas_vector_external,W,GridData,Test_SetUp);
% [Meas_vector_external,Meas_true_vector]
%[PowerData.Vmagn,Vmagn_status_WLS2]
%[PowerData.Imagn,Imagn_status_WLS2]
[results_DSSE_WLS] = Data_Output(Vmagn_status_WLS,Vph_status_WLS,results_DSSE_WLS,GridData,PowerData);
Meas_vector_external = mvnrnd(Meas_true_vector, R)'; %the measurements are corrupted following the covariance matrix
[Vmagn_status_WLS,Vph_status_WLS] = VRIDSSE(Meas_vector_external,W,GridData,Test_SetUp); %voltage state estimator
[Vmagn_status_WLS2,Vph_status_WLS2,Imagn_status_WLS2,Iph_status_WLS2] = IRIDSSE(Meas_vector_external,W,GridData,Test_SetUp);%current state estimator
[results_DSSE_WLS] = Data_Output(Vmagn_status_WLS,Vph_status_WLS,results_DSSE_WLS,GridData,PowerData); %collects the metrics of the error
[results_DSSE_WLS2] = Data_Output(Vmagn_status_WLS2,Vph_status_WLS2,results_DSSE_WLS2,GridData,PowerData);
end
[results_DSSE_Uncertainty_WLS] = calc_Unc_DSSE(results_DSSE_WLS,PowerData,GridData,Combination_devices,Accuracy,Test_SetUp);
[results_DSSE_Uncertainty_WLS] = calc_Unc_DSSE(results_DSSE_WLS,PowerData,GridData,Combination_devices,Accuracy,Test_SetUp); %calculate uncertainty of the estimator
[results_DSSE_Uncertainty_WLS2] = calc_Unc_DSSE(results_DSSE_WLS2,PowerData,GridData,Combination_devices,Accuracy,Test_SetUp);
% [H] = Jacobian_m_IRIDSSE(GridData);
% PI = inv(H'*W*H);
% std_status_I = (GridData.base_current)*sqrt(diag(PI));
%
% std_I_real_mat = [results_DSSE_Uncertainty_WLS2.std_err_Ireal_emp,results_DSSE_Uncertainty_WLS2.std_err_Ireal_mat,std_status_I([2:2:2*GridData.Lines_num+1])]
% std_I_imag_mat = [results_DSSE_Uncertainty_WLS2.std_err_Iimag_emp,results_DSSE_Uncertainty_WLS2.std_err_Iimag_mat,std_status_I([3:2:2*GridData.Lines_num+1])]
% std_I_real_mat = [results_DSSE_Uncertainty_WLS.std_err_Ireal_emp,results_DSSE_Uncertainty_WLS.std_err_Ireal_mat,std_status_I([2:2:2*GridData.Lines_num+1])]
% std_I_imag_mat = [results_DSSE_Uncertainty_WLS.std_err_Iimag_emp,results_DSSE_Uncertainty_WLS.std_err_Iimag_mat,std_status_I([3:2:2*GridData.Lines_num+1])]
%
% [H] = Jacobian_m_VRIDSSE(GridData);
% PV = inv(H'*W*H);
% std_status_V = (GridData.base_voltage)*sqrt(diag(PV));
% std_V_real_mat = [results_DSSE_Uncertainty_WLS2.std_err_Vreal_emp,results_DSSE_Uncertainty_WLS2.std_err_Vreal_mat,[std_status_V(1);std_status_V([2:2:2*GridData.Nodes_num-1])]]
% std_V_imag_mat = [results_DSSE_Uncertainty_WLS2.std_err_Vimag_emp,results_DSSE_Uncertainty_WLS2.std_err_Vimag_mat,[0;std_status_V([3:2:2*GridData.Nodes_num-1])]]
% std_V_real_mat = [results_DSSE_Uncertainty_WLS.std_err_Vreal_emp,results_DSSE_Uncertainty_WLS.std_err_Vreal_mat,[std_status_V(1);std_status_V([2:2:2*GridData.Nodes_num-1])]]
% std_V_imag_mat = [results_DSSE_Uncertainty_WLS.std_err_Vimag_emp,results_DSSE_Uncertainty_WLS.std_err_Vimag_mat,[0;std_status_V([3:2:2*GridData.Nodes_num-1])]]
%mean_err_real_imag = [results_DSSE_Uncertainty_WLS.mean_err_Ireal_emp,results_DSSE_Uncertainty_WLS.mean_err_Iimag_emp]
%mean_err_real_imag = [results_DSSE_Uncertainty_WLS2.mean_err_Ireal_emp,results_DSSE_Uncertainty_WLS2.mean_err_Iimag_emp]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment