1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
| uses crt,cpl;
const limit=15;
var Yuz:array[1..limit,1..limit] of complex;
luz,Uuz,koef,indepU,indepi,Siemens,helpcpi,divvv:array
[1..limit]of complex;
n,k,fr,numvet:integer;
a:array[1..limit,1..limit] of integer;
values:array[1..200] of complex;
currentelm,vetc: array[1..limit]of integer;
currentvalue: array[1..limit]of real;
managedsourse: array[1..limit]of complex;
manline: array[1..2,l..limit]of integer;
napr,tok,temp3: complex;
i,j,j1,p,vetp,kmg,Img,number,currentnumber:integer;
kO,kl:l..5;
r,indue,cap,arnpl,phase,piphase,num,amplmod,cur:real;
wmin,wmax,finale,step: longint;
procedure elinput(f:real) ;
var y_cpl:complex; io,jo:integer;
j,im,jm,km,pm:integer;
w:real;
begin{elinput} w:=2*Pi*f;
for j:=1 to k do begin
if a[j,i]=l then im:=j;
if a[j,i]=-l then jm:=j;
end;
if currentelm[i]=1 then begin
km:=im;
pm:=jm;
y_cpl.re:=l/currentvalue[i] ;
y_cpl. im:=0;
Siemens[i]:=y_cpl;
end;
if currentelm[i]=2 then begin
km:=im;
pm:=jm;
y_cpl.re:=0;
y_cpl.im:=-l/(w*currentvalue[i]);
Siemens[i]:=y_cpl;
end;
if currentelm[i]=3 then begin
km:=im;
pm:=jm;
y_cpl.re:=0;
y_cpl.im:=w*currentvalue[i]/1000000;
Siemens[i]:=y_cpl;
end;
if currentelm[i]=4 then begin
km:=manline[1,i];
lm:=manline[2,i] ;
y_cpl:=koef[i] ;
Siemens[i]:=y_cpl;
end;
if currente1m[i]=5 then begin
km:=im;
pm:=jm;
resetcpl(y_cpl);
siemens[i]:=y_cpl;
end;
addcpl (Yuz [im, km] , y_cpl, Yuz [im, km] );
addcpl(Yuz[jm,pm],y_cpl,Yuz[jm,pm]);
subcpl(Yuz[im,pm],y_cpl,Yuz[im,pm]);
subcpl(Yuz[jm,km],y_cpl,Yuz[jm,km]) end;{elinput}
procedure incarray;
var i,j:integer;
begin{incarray} cirscr;
for j :=1 to n do begin
write ('Введите начальный узел' , j , '-Й ВЕТВИ: ');
readin(i);
a[i,j]:=1;
write (' Введите конечный узел ', j , ' -Й ВЕТВИ:');
readin (i) ;
a[i,j]:=1;
end;
end;{incarray}
procedure formiuz;
var j,im,jm,p:integer;
proizv,pos:complex;
begin{formiuz}
for i:=l to n do begin
for j:=1 to k do begin
if a[j,i]=l then im:=j;
if a[j,i]=1 then jm:=j;
end;
if currentelm[i]<>4 then p:=i;
if currentelm[i]=4 then p:=vetc[i] ;
mulcpl(Siemens[i],indepU[p],proizv) ;
subcpl(indepi[i],proizv,pos) ;
addcpl(luz[im],pos,luz[im]) ;
subcpl(luz[jm],pos,luz[jm]) ;
end;
end;{formiuz}
procedure acform(uzel:complex;num:integer) ;
var g,h:integer;
begin{acform}
values[num]:=uzel;
end;{acform}
procedure acplot;
var driver,mode,q,w:integer;
forig,logarifm:real;
forplot: array[1..200]of real;
begin
for q:=l to finale do begin
divcpl(values[q],temp3,values[q]);
abscpl(values[q],forig) ;
logarifm:=ln (forig)/ln (10) ;
forplot[q]:=logarifm*20;
end;
cirscr;
for w:=l to finale do begin
write (' частота: ' ) ;write(wmin+w*step-step:3,' ');
write ( ' db v(',number,'): ') ;
writein(forplot[w]:3:3); end;
readkey;
end;
procedure outy;
var io,jo:integer;
begin
for io:=l to k do begin
for jo:=l to k do begin
outcpl(Yuz[io,jo] ) ;
write ( ' ' ) ;
end;
writein end;
readkey end;
begin{main}
textbackground(black) ;
textcolor(green) ;
cirscr;
writein ( 'ПРОВЕДЕНИЕ РАСЧЕТА ЦЕПЕЙ ПЕРЕМЕННОГО TOKA');
writein;writein;
textcolor(black) ;
writein ('нажмите клавишу');
readkey;
textcolor(red) ;
textbackground(black) ;
cirscr;
write ('Введите кол-во ветвей: ');
readin(n) ;
write ('Введите кол-во узлов: ');
readin(k) ;
incarray;
cirscr;
for i:=l to limit do
begin
for j:=l to limit do
resetcpl(Yuz[i,j]) ;
resetcpl(Uuz[j]);
resetcpl(koef[j]);
resetcpl(Siemens[j]);
currentelm[j]:=0;
currentvalue[j]:=0;
end;
write ('Ввод частоты в Гц : ');
readin(fr) ;
for i:=l to n do begin
cirscr;
writein ('Выберете сопротивление',i,'-й ветви') ;writeln;
writein('1- активное') ;
writein('2- индуктивность') ;
writein('3- ёмкость') ;
writein('4- бесконечное');
readln(kO); writein;
if k0=l then begin
currentelm[i]:=k0;
write ( ' Сопротивление (OM) : ' ) ;
readin(r) ;
currentvalue[i]:=r;
end;
if k0=2 then begin
currentelm[i]:=k0;
write ('Индуктивность катушки (FH) : ');
readin(indue);
currentvalue[i]:=induc;
end;
if k0=3 then begin
currentelm[i]:=k0;
write('EMKOCTЬ KOHД (MKФ) : ');
readin(cap) ;
currentvalue[i]:=cap;
end;
if k0=5 then begin
currentelm[i]:=k0;
currentvalue[i]:=0;
end;
for j:=1 to k do begin
if a[j,vetc[i]]=1 then kmg:=j;
if a[j,vetc[i]]=-1 then lmg:=j;
end;
manline[l,i]:=kmg;
manline[2,i]:=lmg;
elinput(fr) ;
end;
cirscr;
writein ('Матрица проводимостей:');writeln;
outy;
for i:=l to k do begin
resetcpl(indepU[i]) ;
resetcpl(indepi[i]) ;
resetcpl(luz [i]) ;
end;
cirscr;
for i:=l to n do begin
writein ( ' Источник напряжения B ',i,'-й ветви: ');
writein('1 - Ecть') ;
writeln('2 - Heт') ;
readin(kl) ;
if kl=2 then esetcpl(indepU[i]);
if kl=l then begin
write ('Амплитуда (B) : ');
readin(anpl) ;
write (' <I>a3a (a flOJinx Pi): Pi*');
readin(phase) ;
piphase:=pi*phase;
exptoalg(napr,ampi,piphase) ;
equcpl(indepU[i],napr) ;
end;
end;
cirscr;
for i:=l to n do begin
writein ('Источник тока B ',i,'-й ветви: ');
writein('1 - EcTb');
writein('2 - Heт') ;
readin(kl);
if kl=2 then resetcpl(indepi[i]);
if kl=l then begin
write ( 'Амплитуда (A) : ' ) ;
readin(arnpl) ;
write ('(t>a3a (B flOJiax Pi): Pi*');
readin(phase) ;
piphase:=pi*phase;
exptoalg(tok,arnpl,piphase) ;
equcpl(indepi[i],tok) ;
end;
end;
formluz;
for i:=l to k do begin
outcpl(luz[i] ) ;
writein;
end;
readkey;
cirscr;
for i:=l to k do equcpl (Yuz [i, k] , luz [i] ) ;
for i:=l to k-1 do begin
abscpl(Yuz[i,i],max) ;
for j:=i+l to k-1 do begin
abscpl(Yuz[j,i],tempi) ;
if templ>max then begin
max:=templ;
kl:=j ;
end;
end;
if kloi then begin
for j:=1 to k do begin
helpcpl[j]:=Yuz[kl,j];
Yuz[kl,j]:=Yuz[i,j] ;
Yuz[i,j]:=helpcpl[i] ;
end;
numeric[i]:=kl;
numeric [kl]:=i
end;
for j:=k downto i do begin
divcpl(Yuz[i,j],Yuz[i,i],divvv[j]) ;
Yuz[i,j]:=divvv[j] ;
end;
for j:=i+l to k-1 do begin
for jl:=k downto i do
begin
mulcpl(Yuz[j,i],Yuz[i,j1],helpcpl[jl]);
subcpl(Yuz[j,jl],helpcpl[jl],Yuz[j,jl]) ;
end; end; end;
Uuz[k-l]:=Yuz[k-l,k] ;
fluz[i]:=Yuz[i,k] ;
for j:=k-l downto i+1 do
begin
{Iuz[i]:=Iuz[i]-Yuz[i,j]*Uuz[j]}
mulcpl(Yuz[i,j],Uuz[j],temp3);
subcpl(luz[i],temp3,luz[i]) ;
Uuz[i]:=Iuz[i] ;
end;
cirscr;
writein ( ' ,вывод1: ' ) ;
write (i,'-n ysen: ');
outcpl(Uuz[i]) ;
abscpl(Uuz[i],amplmod) ;
write (' вывод2: ' , amplmod: 3 : 3) ;
readkey;
cirscr;
writeln('проводим анализ по переменному току '); writein;
writein('Задание источника: ');
writein;
write('ветвь, B KOTOPOM OH находится: ');
if jonumvet then
resetcpl(indepU[j]);
if j=numvet then
temp3:=indepU[j] ;
cirscr;
writeln('проводим анализ по переменному току' );writeln;
writein;
writein('Fмин');
write (' Fмах: ');
readin(wmin);
readin(wmax) ;
write('BBOfl mara: ');
readin(step) ;
write ('Номер узла, где снимается АЧХ : ');
readin(number) ;
finale:=((wmax-wmin) div step)+l;
currentnumber:=1 ;
cur:=wmin;
while cur <= wmax do begin
for i:=l to k do
begin
for j:=1 to k do
resetcpl(Yuz[i,j]) ;
end;
for i:=l to n do elinput(cur) ;
for i:=l to n do resetcpl(luz[i]) ;
for i:=l to k do equcpl(Yuz[i,k],luz [i]);
{**************}
for i:=l to k-1 do
begin abscpl(Yuz[i,i],max) ;
for j:=i+l to k-1 do begin
abscpl(Yuz[j,i],tempi) ;
if templ>max then begin
max:=templ;
kl:=j ;
end;
end;
if kloi then begin
for j:=1 to i do
begin
helpcpl[j]:=Yuz[kl,j];
Yuz[kl,j]:=Yuz[i,j] ;
Yuz[i,j]:=helpcpl[i] ;
end;
numeric[i]:=kl;
numeric[kl]:=i end;
for j:=k downto i do begin
divcpl(Yuz[i,j],Yuz[i,i],divvv[j]);
Yuz[i,j]:=divvv[j] ;
end;
formiuz;
for j:=i+l to k-1 do begin
for jl:=k downto i do begin
mulcpl(Yuz[j,i],Yuz[i,jl],helpcpl[jl]) ;
subcpl(Yuz[j,jl],helpcpl[jl],Yuz[j,jl]);
end; end; end;
;
Uuz[k-l]:=Yuz[k-l,k] ;
for i:=k-2 downto 1 do
begin
Iuz[i]:=Yuz[i,k] ;
for j:=k-l downto i+1 do begin
{Iuz[i]:=Iuz[i]-Yuz[i,j]*Uuz[j]} mulcpl(Yuz[i,j],Uuz[j],temp3) ;
subcpl(luz[i],temp3,luz[i]) ;
end;
Uuz[i]:=Iuz[i] ;
end;
acform(Uuz[number],currentnumber) ;
inc(currentnumber);
cur:=cur+step;
end;
{=============================}
acplot;
end.{main} |