Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
МІНІСТЕРСТВО ОСВІТИ І НАУКИ УКРАЇНИ.doc
Скачиваний:
2
Добавлен:
04.11.2018
Размер:
2.01 Mб
Скачать

Verification of results of calculation

As it is told above, the system may fix logic mistakes only in the indirect form, but also it happens far from being always. The most inconvenient case for the programmer is when results of calculation are similar to the truth. Therefore, the problem of the proof of correctness of the solution should be put and realized at a development cycle of the program.

Make it with the help of example of the program of calculation of currents in a circuit realized by M – file by name Circuit 3_debug.

At a stage of a development of the program we have carried out check according to 2nd Kirchhoff’s law along the contour that has been not included in system of the equations for a finding of branches currents. The check up is necessary for such electric circuits. Now we shall check up, whether it is sufficient. For this purpose, execute the following actions:

 Let's enter a logic mistake into the program. At filling M matrix we shall replace M (1,2) =-1 by M (1,2)= 1. Now the matrix should look as follows:

M = [1 1 -1;

Z1 0 Z3;

0 Z2 -Z3];

 Save the program and run it for calculation. Results of calculation are:

I1 =-17.5739-76.7793i

I2=16.5153+79.355i

I3 =-1.0586+2.5757i

error calculation eps=0

I1M=78.7649 phI1 =-102.8923

I2M=81.0554 phI2=78.2435

I3M=2.7848 phI3=112.3428

Thus we see, that curves of currents on the diagram are similar to real ones, and a mistake of calculation eps=0. Hence, it is not enough carried out check for revealing the given logic mistake.

 For the electric circuit it is recommended to do check up also according to 1st Kirchhoff’s rule for the unit that has been not included to the system of equations for definition unknowns. We shall organize account of check according to 1st and 2nd Kirchhoff’s rules as follows:

% Check up according to 1-st Kirchhoff’s rule

eps1=I (1,1)-I (2,1)-I (3,1);

% Check up according to 2-nd Kirchhoff’s rule

eps2=E1-E2-Z1*I (1,1)-Z2*I (2,1);

disp ([' error calculation eps1 = ', num2str (eps1)]);

disp ([' error calculation eps2 = ', num2str (eps2)]);

Also shall carry out the appropriate replacements into the program.

 Save the program and start it to the account. The results exceeded as follows:

I1 =-17.5739-76.7793i

I2=16.5153+79.355i

I3 =-1.0586+2.5757i

error calculation eps1 =-33.0306-158.71i

error calculation eps2=0

I1M=78.7649 phI1 =-102.8923

I2M=81.0554 phI2=78.2435

I3M=2.7848 phI3=112.3428

Thus, check up according to 1st Kirchhoff’s rule gives an error

eps1 =-33.0306-158.71i. Obviously, as 1st Kirchhoff’s rule do not fulfil so results of calculation are incorrect.

 Correct the mistake and start the program again. The following values of errors will be received:

eror calculation eps1=0

error calculation eps2=3.5527e-015+7.1054e-015i

The values of errors testify to correctness of calculation.

3 LAboratory work # 3

TOPIC: Modeling of steady-state electric processes in MATLAB environment. Part 2.

PURPOSE OF THE WORK: Development and debugging of the program of calculation of currents and voltages in the given electrical circuit and proof of correctness of account.