Текст программы.
unit three;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, StdCtrls, Spin, TeEngine, Series, ExtCtrls, TeeProcs,
Chart, CheckLst, math, ComCtrls, TabNotBk, mxarrays, Menus;
type
arbo=array[1..6]of boolean;
arn=array of integer;
TForm1 = class(TForm)
Label3: TLabel;
Edit1: TEdit;
Label4: TLabel;
Edumax: TEdit;
Cha: TChart;
Series4: TLineSeries;
Series5: TLineSeries;
Series6: TLineSeries;
Shgra: TCheckListBox;
Label5: TLabel;
Edit3: TEdit;
Label6: TLabel;
Series1: TLineSeries;
Series2: TLineSeries;
Series3: TLineSeries;
Label2: TLabel;
Label8: TLabel;
TabbedNotebook1: TTabbedNotebook;
Label1: TLabel;
har: TStringGrid;
Label7: TLabel;
comb: TStringGrid;
Label10: TLabel;
all: TCheckBox;
Label11: TLabel;
numc: TSpinEdit;
cap: TStringGrid;
MainMenu1: TMainMenu;
N1: TMenuItem;
N11: TMenuItem;
N12: TMenuItem;
Open: TOpenDialog;
Save: TSaveDialog;
Label12: TLabel;
koef: TEdit;
Edu: TEdit;
procedure init(Sender: TObject);
procedure fchan(Sender: TObject);
procedure wchan(Sender: TObject);
procedure outgra;
procedure fraccount(sender:tobject);
procedure showhide(Sender: TObject);
procedure voltage(Sender: TObject);
procedure findpsi;
procedure findkit(n:integer;cost,cap:real);
function norel(m,n:integer;cap,hi,lo:real):boolean;
function findr(m:integer):boolean;
function findc(n:integer;kt:arn):boolean;
procedure numcChan(Sender: TObject);
procedure capExit(Sender: TObject);
procedure N11Click(Sender: TObject);
procedure N12Click(Sender: TObject);
procedure EdumaxExit(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
const nhar:array[0..12]of integer=(1,5,7,11,13,17,19,23,25,29,31,35,37);
var f:text; s:string;
Form1: TForm1; v,al,ye:boolean;
i,j,k,n,l,qu:integer;
w,e,g,h,u,u1,r,ca,cp,mn,co,um,i0,ih:real;{частота, сдвиг, точность, тек стоим}
a:array[0..12]of real; {амплитуды гармоник}
x:array[1..6]of real; {сглаживающие отношения емкостей}
c0,p0,c,p:array of real; {ёмкости и стоимости}
kit:array of arn; {таблица наборов емкостей}
b:array of record c,cp:real end;{В пор возр с: c-стоим набора, n-номер, cр-сум ёмк}
cb,cpn,sort:arn; {текущие наборы емкостей, перестановка, обратн сортировке}
nk:array[1..6]of integer; {комбинация номеров полезных наборов}
cd,cdf,nkit:array[1..6]of arn; {наборы емкостей в знаменателях, номера полезн наборов}
psi:array of real;{мин число, которому обязательно соотв >1 набора из емк до № эл-та}
gr:array of array of byte; {группы индексов емкостей с общим делителем}
grn:array of byte; {группа, вкл дан ёмкость}
implementation
{$R *.dfm}
{Это нужно для оптим-и программы}
procedure tform1.findpsi; {Нахожд НОД и условий, при кот рассм набора бессмысленно}
var nod:array of real; {НОД в данной группе}
begin
setlength(nod,numc.Value); setlength(gr,0); k:=0;
for i:=0to numc.Value-1do begin v:=false; {Группировка по общ делителю}
psi[i]:=0;
for l:=0to k-1do begin
for j:=1to 20do begin cp:=nod[gr[l,length(gr[l])-1]];
r:=j*c[i]/cp; {поиск НОД i-й ёмк с l-й группой}
if abs(r-round(r))<10e-14then begin grn[i]:=l; nod[i]:=cp/j;
setlength(gr[l],length(gr[l])+1); gr[l,length(gr[l])-1]:=i;
v:=true; break end end;
if v then break end; {v - НОД найден}
if not(v)then begin inc(k); setlength(gr,k); setlength(gr[k-1],1);
gr[k-1,0]:=i; nod[i]:=c[i]; grn[i]:=k-1 end;
j:=length(gr[grn[i]]); {находим f, помещаем в массив psi}
if j>1then psi[i]:=psi[gr[l,j-2]]+c[i]*(nod[gr[l,j-2]]/nod[i]-1)
end;
for l:=0to length(gr)-1do begin {находим пси}
k:=length(gr[l])-1; psi[gr[l,k]]:=0;
for j:=k-1downto 0do begin i:=gr[l,j+1];
psi[gr[l,j]]:=2*(psi[gr[l,j]]+nod[gr[l,j]]*c[i]/nod[i])-nod[gr[l,j]]
end end
end;
procedure tform1.findkit(n:integer;cost,cap:real);{Поиск полезных наборов стоимстью от g до h}
begin if(n=numc.Value-1)and(cost<=g) {j-номер набора}
then begin cpn[n]:=trunc((g-cost)/p[n])+1;
cost:=cost+p[n]*cpn[n];cap:=cap+c[n]*cpn[n]end else cpn[n]:=0;
while cost<=h do begin
if n=numc.value-1 then begin v:=false; al:=true;
for i:=1to 3do if findr(i)then begin v:=true;
setlength(nkit[i],length(nkit[i])+1);
nkit[i,length(nkit[i])-1]:=j end
else al:=false;
if v then begin {добавл j-го набора}
setlength(kit,j+1); setlength(b,j+1); setlength(kit[j],numc.Value);
for k:=0to numc.Value-1 do kit[j,k]:=cpn[k];
b[j].c:=cost; b[j].cp:=cap;inc(j)end;
if(al)and(all.Checked)and(cost<co)then begin {если подх для всех отн}
ye:=true; three.n:=j-1; co:=cost;
for i:=0to numc.Value-1do
for k:=1to 3do cdf[k,i]:=cd[k,i]end end
else begin r:=0; k:=grn[n];
if psi[n]=0then r:=-1 else
for i:=0to length(gr[k])-2do begin r:=r+c[gr[k,i]]*cpn[gr[k,i]];
if gr[k,i]=n then break end;
if r<psi[n]then findkit(n+1,cost,cap)end;
inc(cpn[n]);cost:=cost+p[n];cap:=cap+c[n]end
end;
function tform1.norel(m,n:integer;cap,hi,lo:real):boolean;
var i:integer; {рекурсивный поиск комбин знам для findr}
begin norel:=true;
if n<numc.Value-1then begin
i:=max(0,trunc(cpn[n]+1+(lo-ca-r)/c[n])); lo:=lo+(cpn[n]-i)*c[n];
while i<=cpn[n]do begin inc(qu);
if ca-r<hi then
if norel(m,n+1,cap,hi,lo)=false
then begin norel:=false; cd[m,n]:=cpn[n]-i end else begin end
else break;
cap:=cap-c[n]; hi:=hi-c[n]; lo:=lo-c[n]; inc(i)end
end
else begin i:=trunc((cap-ca+r)/c[n])+1;
if i>cpn[n]+1then i:=cpn[n]+1; cap:=cap-i*c[n];
repeat dec(i);cap:=cap+c[n]; inc(qu);
if abs(cap-ca)<r then begin norel:=false;
r:=abs(cap-ca); cd[m,n]:=cpn[n]-i end
else break;
until i=0 end
end;
function tform1.findr(m:integer):boolean;
begin cp:=0; {есть ли комбинации из емкостей в срn с отнош x[m]}
for k:=0to numc.Value-1do cp:=cp+cpn[k]*c[k];
ca:=cp/(x[m]+1); r:=ca-cp/(x[m]+1+u);
if norel(m,0,cp,cp,0)then findr:=false
else findr:=true;
end;
function tform1.findc(n:integer;kt:arn):boolean;
var i:integer; cpo:arn;{поиск дешевейшего объединения полезных наборов}
begin findc:=false; setlength(cpo,length(kt)); {kt-набор емкостей}
for i:=0to length(nkit[n])-1do begin r:=0;
for k:=0to length(kt)-1do begin {r - стоимость набора на данном шаге}
cpo[k]:=max(kt[k],kit[nkit[n,i],k]);
r:=r+cpo[k]*p[k]end;
if r<co then if n<3 then
if findc(n+1,cpo)then begin findc:=true; nk[n]:=nkit[n,i]end
else begin end
else begin co:=r; findc:=true; nk[n]:=nkit[n,i];
for k:=0to numc.Value-1 do cb[k]:=cpo[k]end;{помещаем дешевейшее в cb}
end
end;
procedure tform1.fraccount(sender:tobject); {вычисл и представл рац дробью отн емкостей}
begin if not(ye)then begin qu:=0;
for i:=1to numc.Value-1do begin r:=p[i-1]/c[i-1]; {сорт-ка по убыв р/с}
for j:=i to numc.Value-1do
if p[j]/c[j]>r then begin r:=p[j]/c[j];
k:=sort[i-1]; sort[i-1]:=sort[j]; sort[j]:=k;
h:=p[j]; p[j]:=p[i-1]; p[i-1]:=h; h:=c[j]; c[j]:=c[i-1]; c[i-1]:=h end
end;
try u:=strtofloat(edu.Text)except on econverterror do
edu.Text:=floattostrf(u,ffgeneral,5,5)end;
l:=0; mn:=p[0];
for i:=1to numc.Value-1do if p[i]<mn then mn:=p[i];
for i:=1to 3do setlength(nkit[i],0);
FINDPSI; setlength(kit,0);
if all.Checked then begin i:=0; {испольовать ВСЁ, одинак ёмк}
repeat v:=true; inc(i);
for k:=1to 3 do begin r:=round(i/(x[k]+1));
if(r=0)or(abs(x[k]+1-i/r)>u)then v:=false end
until v; l:=i;
for k:=1to 3do begin j:=round(i/(x[k]+1));
har.Cells[3,2*k+1]:=inttostr(i-j)+'/'+inttostr(j)end;
j:=0; g:=0; co:=l*mn+1e-12; {Разные ёмк}
repeat h:=g+20*mn/numc.Value; ye:=false;
findkit(0,0,0); g:=h
until ye; {нашли нужные комбинации}
for i:=0to numc.Value-1do begin
for k:=1to 3do
comb.Cells[sort[i]+1,k]:=inttostr(kit[n,i]-cdf[k,i])+'--'+inttostr(cdf[k,i]);
comb.Cells[sort[i]+1,7]:=inttostr(kit[n,i])end
end
else begin for k:=1to 3do begin i:=0; {испольовать НЕ ВСЁ, одинак ёмк}
repeat
inc(i); j:=round(i*x[k])
until abs(j-i*x[k])/i<=u; l:=max(l,i+j);
if k<3then har.Cells[3,2*k+1]:=inttostr(j)+'/'+inttostr(i)
end;
har.Cells[3,9]:=inttostr(j)+'/'+inttostr(i);
j:=0; g:=0; co:=l*mn+1e-12; {Разные ёмк}
repeat h:=g+20*mn/numc.Value;
findkit(0,0,0); g:=h;
for i:=0to numc.Value-1do cpn[i]:=0;
findc(1,cpn)
until co<=g;
for j:=1to 3do begin for i:=0to numc.Value-1do cpn[i]:=kit[nk[j],i];
if findr(j)then
for i:=0to numc.Value-1do {находим объединяющий набор}
comb.Cells[sort[i]+1,j+j-1]:=inttostr(round(c0[sort[i]]/c[i])*(cpn[i]-cd[j,i]))+'--'+inttostr(round(c0[sort[i]]/c[i])*cd[j,i]);
for i:=0to numc.Value-1do comb.Cells[sort[i]+1,j+j]:=inttostr(round(c0[sort[i]]/c[i])*cpn[i]);
end;
end;
label10.Caption:='Общая стоимость: ';
for j:=1to 3do begin e:=0; {е - стоимость для данной пары гармоник}
for i:=0to numc.Value-1do e:=e+kit[nk[j],i]*p[i];
label10.Caption:=label10.Caption+floattostrf(e,ffgeneral,5,4)+', 'end;
label2.Caption:='В фазе '+inttostr(l)+' конденсатор';
if(l mod 10>4)or(l mod 10=0)then label2.Caption:=label2.Caption+'ов'
else if l mod 10>1then label2.Caption:=label2.Caption+'а';
label2.Caption:=label2.Caption+' :=) '+inttostr(qu)+' проверок';
ye:=false end
end;
procedure tform1.outgra; {вывод графиков напряжений}
begin
for i:=0to 5do cha.SeriesList[i].Clear;
for i:=0to 2 do
for j:=0to 999do begin u:=a[0]*sin(0.01*j+i*pi*2/3);
cha.SeriesList[i].AddXY(0.01*j/w,u);
for k:=1to 6 do begin
u:=u+a[2*k-1]*sin((6*k-1)*(0.01*j+i*pi*2/3));
u:=u+a[2*k]*sin((6*k+1)*(0.01*j+i*pi*2/3))end;
cha.SeriesList[i+3].AddXY(0.01*j/w,u)
end;
end;
procedure TForm1.init(Sender: TObject); {при запуске}
var v:boolean; l:integer;
begin
w:=100*pi; e:=0; u:=0.0005;
edit3.Text:=floattostrf(w,ffgeneral,5,4); har.Cells[0,0]:='№';
har.Cells[1,0]:='Омега'; har.Cells[2,0]:='Umax';
har.Cells[3,0]:='С2/С1'; har.Cells[4,0]:='Umвых';
for i:=1to 13do begin k:=6*(i div 2)+sign(i mod 2-0.5);
a[i-1]:=0; har.Cells[0,i]:=inttostr(k);
har.Cells[1,i]:=floattostrf(k*w,ffgeneral,5,4); har.Cells[2,i]:='0'
end;
for i:=0to 5do shgra.Checked[i]:=true;
cap.Cells[0,0]:='Ёмкость'; cap.Cells[0,1]:='Стоимость';
cap.Cells[0,2]:='Umax'; j:=6;
for i:=1to 3do begin
comb.Cells[0,2*i-1]:=inttostr(j-1)+', '+inttostr(j+1)+'-я'; j:=j+j;
comb.Cells[1,2*i-1]:='1--1';setlength(cd[i],1);setlength(cdf[i],1);
comb.Cells[0,2*i]:='Всего'; comb.Cells[1,2*i]:='2'end;
comb.Cells[0,0]:='Ёмкость'; comb.Cells[1,0]:='1';
setlength(p,1); setlength(c,1); setlength(p0,1); setlength(c0,1);
setlength(cb,1); setlength(cpn,1);
setlength(grn,1); setlength(psi,1); setlength(sort,1);
p0[0]:=1; c0[0]:=1; p[0]:=2; c[0]:=0.5;
cap.Cells[1,0]:='1'; cap.Cells[1,1]:='1'; cap.Cells[1,2]:='500';
um:=1000; outgra;
x[1]:=sin(pi/3-pi/12)/sin(pi/3+pi/12);
x[2]:=sin(pi/3-pi/24)/sin(pi/3+pi/24);
x[3]:=sin(pi/3-pi/48)/sin(pi/3+pi/48);
for k:=1to 3do har.Cells[3,4*k-2]:=floattostrf(x[1],ffgeneral,4,3);
har.Cells[3,4]:=floattostrf(x[2],ffgeneral,4,3);
har.Cells[3,12]:=floattostrf(x[2],ffgeneral,4,3);
har.Cells[3,8]:=floattostrf(x[3],ffgeneral,4,3);
fraccount(sender)
end;
procedure TForm1.fchan(Sender: TObject); {при изменении f}
begin
try w:=2*pi*strtofloat(edit1.Text)except
on econverterror do edit1.Text:=floattostrf(2*pi*w,ffgeneral,5,4)end;
edit3.Text:=floattostrf(w,ffgeneral,5,4);
for i:=1to 13do begin
k:=6*(i div 2)+sign(i mod 2-0.5);
har.Cells[1,i]:=floattostrf(k*w,ffgeneral,5,4)end;
outgra
end;
procedure TForm1.wchan(Sender: TObject); {при изменении w}
begin
try w:=strtofloat(edit3.Text)except
on econverterror do edit3.Text:=floattostrf(w,ffgeneral,5,4)end;
edit1.Text:=floattostrf(0.5*w/pi,ffgeneral,5,4);
for i:=1to 13do begin
k:=6*(i div 2)+sign(i mod 2-0.5);
har.Cells[1,i]:=floattostrf(k*w,ffgeneral,5,4)end;
outgra
end;
procedure TForm1.showhide(Sender: TObject);
begin
for i:=0to 5do
if shgra.Checked[i]then cha.SeriesList[i].Active:=true
else cha.SeriesList[i].Active:=false
end;
procedure TForm1.voltage(Sender: TObject); {после ввода гармоники}
begin g:=0;
for i:=1to 13do begin
try a[i-1]:=strtofloat(har.Cells[2,i])
except on econverterror do har.Cells[2,i]:=floattostrf(a[i-1],ffgeneral,5,5)end;
g:=g+sqr(a[i-1])
end;
try u:=strtofloat(edu.Text)except on econverterror do
edu.Text:=floattostrf(u,ffgeneral,5,5)end;
if g>0 then begin g:=sqrt((g-sqr(a[0]))/g);
koef.Text:=floattostrf(g,ffgeneral,5,5)end
else koef.Text:=''; {+-u - погрешность отн емк}
e:=(1-0.5*(x[1]-u))+(cos(pi/6)*(x[1]-u-0.5)+0.5*sin(pi/6)*sqrt(3));
u1:=0.5*(x[1]-u)*sqrt(3)+(sin(pi/6)*(0.5-x[1]+u)+0.5*cos(pi/6)*sqrt(3));
i0:=u1*u1+e*e;
e:=(1-0.5*(x[1]-u))+(cos(5*pi/6)*(x[1]-u-0.5)-0.5*sin(5*pi/6)*sqrt(3));
u1:=-0.5*(x[1]-u)*sqrt(3)+(sin(5*pi/6)*(0.5-x[1]+u)-0.5*cos(5*pi/6)*sqrt(3));
ih:=sqrt((u1*u1+e*e)/i0);
e:=(1-0.5*(x[1]+u))+(cos(pi/6)*(x[1]+u-0.5)+0.5*sin(pi/6)*sqrt(3));
u1:=0.5*(x[1]+u)*sqrt(3)+(sin(pi/6)*(0.5-x[1]-u)+0.5*cos(pi/6)*sqrt(3));
i0:=u1*u1+e*e;
e:=(1-0.5*(x[1]+u))+(cos(5*pi/6)*(x[1]+u-0.5)-0.5*sin(5*pi/6)*sqrt(3));
u1:=-0.5*(x[1]+u)*sqrt(3)+(sin(5*pi/6)*(0.5-x[1]-u)-0.5*cos(5*pi/6)*sqrt(3));
if sqrt((u1*u1+e*e)/i0)>ih then ih:=sqrt((u1*u1+e*e)/i0);
har.Cells[4,2]:=floattostrf(ih*a[1],ffgeneral,5,5);
har.Cells[4,6]:=floattostrf(ih*a[5],ffgeneral,5,5);
har.Cells[4,10]:=floattostrf(ih*a[9],ffgeneral,5,5);
e:=(1-0.5*(x[1]+u))+(cos(7*pi/6)*(x[1]+u-0.5)+0.5*sin(7*pi/6)*sqrt(3));
u1:=0.5*(x[1]+u)*sqrt(3)+(sin(7*pi/6)*(0.5-x[1]-u)+0.5*cos(7*pi/6)*sqrt(3));
ih:=sqrt((u1*u1+e*e)/i0);
e:=(1-0.5*(x[1]-u))+(cos(pi/6)*(x[1]-u-0.5)+0.5*sin(pi/6)*sqrt(3));
u1:=0.5*(x[1]-u)*sqrt(3)+(sin(pi/6)*(0.5-x[1]+u)+0.5*cos(pi/6)*sqrt(3));
i0:=u1*u1+e*e;
e:=(1-0.5*(x[1]-u))+(cos(7*pi/6)*(x[1]-u-0.5)+0.5*sin(7*pi/6)*sqrt(3));
u1:=0.5*(x[1]-u)*sqrt(3)+(sin(7*pi/6)*(0.5-x[1]+u)+0.5*cos(7*pi/6)*sqrt(3));
if sqrt((u1*u1+e*e)/i0)>ih then ih:=sqrt((u1*u1+e*e)/i0); ih:=ih*a[2];
har.Cells[4,3]:=floattostrf(ih*a[2],ffgeneral,5,5);
har.Cells[4,7]:=floattostrf(ih*a[6],ffgeneral,5,5);
har.Cells[4,11]:=floattostrf(ih*a[10],ffgeneral,5,5);
e:=(1-0.5*(x[2]-u))+(cos(pi/12)*(x[2]-u-0.5)+0.5*sin(pi/12)*sqrt(3));
u1:=0.5*(x[2]-u)*sqrt(3)+(sin(pi/12)*(0.5-x[2]+u)+0.5*cos(pi/12)*sqrt(3));
i0:=u1*u1+e*e;
e:=(1-0.5*(x[2]-u))+(cos(11*pi/12)*(x[2]-u-0.5)-0.5*sin(11*pi/12)*sqrt(3));
u1:=-0.5*(x[2]-u)*sqrt(3)+(sin(11*pi/12)*(0.5-x[2]+u)-0.5*cos(11*pi/12)*sqrt(3));
ih:=sqrt((u1*u1+e*e)/i0);
e:=(1-0.5*(x[2]+u))+(cos(pi/12)*(x[2]+u-0.5)+0.5*sin(pi/12)*sqrt(3));
u1:=0.5*(x[2]+u)*sqrt(3)+(sin(pi/12)*(0.5-x[2]-u)+0.5*cos(pi/12)*sqrt(3));
i0:=u1*u1+e*e;
e:=(1-0.5*(x[2]+u))+(cos(11*pi/12)*(x[2]+u-0.5)-0.5*sin(11*pi/12)*sqrt(3));
u1:=-0.5*(x[2]+u)*sqrt(3)+(sin(11*pi/12)*(0.5-x[2]-u)-0.5*cos(11*pi/12)*sqrt(3));
if sqrt((u1*u1+e*e)/i0)>ih then ih:=sqrt((u1*u1+e*e)/i0);
har.Cells[4,4]:=floattostrf(ih*a[3],ffgeneral,5,5);
har.Cells[4,12]:=floattostrf(ih*a[11],ffgeneral,5,5);
e:=(1-0.5*(x[2]+u))+(cos(13*pi/12)*(x[2]+u-0.5)+0.5*sin(13*pi/12)*sqrt(3));
u1:=0.5*(x[2]+u)*sqrt(3)+(sin(13*pi/12)*(0.5-x[2]-u)+0.5*cos(13*pi/12)*sqrt(3));
ih:=sqrt((u1*u1+e*e)/i0);
e:=(1-0.5*(x[2]-u))+(cos(pi/12)*(x[2]-u-0.5)+0.5*sin(pi/12)*sqrt(3));
u1:=0.5*(x[2]-u)*sqrt(3)+(sin(pi/12)*(0.5-x[2]+u)+0.5*cos(pi/12)*sqrt(3));
i0:=u1*u1+e*e;
e:=(1-0.5*(x[2]-u))+(cos(13*pi/12)*(x[2]-u-0.5)+0.5*sin(13*pi/12)*sqrt(3));
u1:=0.5*(x[2]-u)*sqrt(3)+(sin(13*pi/12)*(0.5-x[2]+u)+0.5*cos(13*pi/12)*sqrt(3));
if sqrt((u1*u1+e*e)/i0)>ih then ih:=sqrt((u1*u1+e*e)/i0); ih:=ih*a[2];
har.Cells[4,5]:=floattostrf(ih*a[4],ffgeneral,5,5);
har.Cells[4,13]:=floattostrf(ih*a[12],ffgeneral,5,5);
e:=(1-0.5*(x[3]-u))+(cos(pi/24)*(x[3]-u-0.5)+0.5*sin(pi/24)*sqrt(3));
u1:=0.5*(x[3]-u)*sqrt(3)+(sin(pi/24)*(0.5-x[3]+u)+0.5*cos(pi/24)*sqrt(3));
i0:=u1*u1+e*e;
e:=(1-0.5*(x[3]-u))+(cos(23*pi/24)*(x[3]-u-0.5)-0.5*sin(23*pi/24)*sqrt(3));
u1:=-0.5*(x[3]-u)*sqrt(3)+(sin(23*pi/24)*(0.5-x[3]+u)-0.5*cos(23*pi/24)*sqrt(3));
ih:=sqrt((u1*u1+e*e)/i0);
e:=(1-0.5*(x[3]+u))+(cos(pi/24)*(x[3]+u-0.5)+0.5*sin(pi/24)*sqrt(3));
u1:=0.5*(x[3]+u)*sqrt(3)+(sin(pi/24)*(0.5-x[3]-u)+0.5*cos(pi/24)*sqrt(3));
i0:=u1*u1+e*e;
e:=(1-0.5*(x[3]+u))+(cos(23*pi/24)*(x[3]+u-0.5)-0.5*sin(23*pi/24)*sqrt(3));
u1:=-0.5*(x[3]+u)*sqrt(3)+(sin(23*pi/24)*(0.5-x[3]-u)-0.5*cos(23*pi/24)*sqrt(3));
if sqrt((u1*u1+e*e)/i0)>ih then ih:=sqrt((u1*u1+e*e)/i0);
har.Cells[4,8]:=floattostrf(ih*a[7],ffgeneral,5,5);
e:=(1-0.5*(x[3]+u))+(cos(25*pi/24)*(x[3]+u-0.5)+0.5*sin(25*pi/24)*sqrt(3));
u1:=0.5*(x[3]+u)*sqrt(3)+(sin(25*pi/24)*(0.5-x[3]-u)+0.5*cos(25*pi/24)*sqrt(3));
ih:=sqrt((u1*u1+e*e)/i0);
e:=(1-0.5*(x[3]-u))+(cos(pi/24)*(x[3]-u-0.5)+0.5*sin(pi/24)*sqrt(3));
u1:=0.5*(x[3]-u)*sqrt(3)+(sin(pi/24)*(0.5-x[3]+u)+0.5*cos(pi/24)*sqrt(3));
i0:=u1*u1+e*e;
e:=(1-0.5*(x[3]-u))+(cos(25*pi/24)*(x[3]-u-0.5)+0.5*sin(25*pi/24)*sqrt(3));
u1:=0.5*(x[3]-u)*sqrt(3)+(sin(25*pi/24)*(0.5-x[3]+u)+0.5*cos(25*pi/24)*sqrt(3));
if sqrt((u1*u1+e*e)/i0)>ih then ih:=sqrt((u1*u1+e*e)/i0); ih:=ih*a[2];
har.Cells[4,9]:=floattostrf(ih*a[8],ffgeneral,5,5);
outgra
end;
procedure TForm1.numcChan(Sender: TObject); {при изменении числа разл емк}
var i:byte;
begin setlength(grn,numc.Value); setlength(psi,numc.Value);
setlength(sort,numc.Value); sort[numc.Value-1]:=numc.Value-1;
setlength(psi,numc.Value);
cap.ColCount:=numc.Value+1; comb.ColCount:=numc.Value+1;
setlength(c0,numc.Value); setlength(p0,numc.Value);
setlength(c,numc.Value); setlength(p,numc.Value);
if length(p)>length(cb)then begin p0[length(cb)]:=1;
c0[length(cb)]:=c0[length(cb)-1]*1.5;
cap.Cells[length(c),0]:=floattostrf(c0[length(cb)],ffgeneral,5,5);
cap.Cells[length(c),1]:='1';
cap.Cells[length(c),2]:='500';
comb.Cells[length(c),0]:=cap.Cells[length(c),0]end;
setlength(cb,numc.Value); setlength(cpn,numc.Value);
for i:=1to 3do begin setlength(cd[i],numc.Value);
setlength(cdf[i],numc.Value)end; capexit(sender)
end;
procedure TForm1.capExit(Sender: TObject);
begin
for i:=1to numc.Value do begin
try c0[i-1]:=strtofloat(cap.Cells[i,0])
except on econverterror do cap.Cells[i,0]:=floattostrf(c0[i-1],ffgeneral,5,5)end;
try p0[i-1]:=strtofloat(cap.Cells[i,1])
except on econverterror do cap.Cells[i,1]:=floattostrf(p0[i-1],ffgeneral,5,5)end;
try e:=um/strtofloat(cap.Cells[i,2])except on econverterror do
begin cap.Cells[i,2]:=floattostrf(um,ffgeneral,5,5); e:=1 end end;
if e<>trunc(e)then e:=trunc(e)+1;
c[i-1]:=c0[i-1]/e; p[i-1]:=p0[i-1]*e;
sort[i-1]:=i-1; comb.Cells[i,0]:=cap.Cells[i,0]end;
fraccount(sender)
end;
procedure TForm1.N11Click(Sender: TObject); {файловый ввод данных}
begin ye:=true;
open.Execute; assignfile(f,open.FileName);
if open.FileName=''then exit; reset(f);
readln(f,s); delete(s,1,29);
try w:=strtofloat(s)except on econverterror do begin
showmessage('Файл некорректен или не найден');exit end end;
edit3.Text:=floattostrf(w,ffgeneral,5,4);
edit1.Text:=floattostrf(0.5*w/pi,ffgeneral,5,4);
readln(f,s); delete(s,1,25); all.Checked:=strtobool(s);
readln(f,s); delete(s,1,25); numc.Value:=strtoint(s);
for i:=0to numc.Value-1do begin
readln(f,s); delete(s,1,8); c[i]:=strtofloat(s);
cap.Cells[i+1,0]:=floattostrf(c[i],ffgeneral,5,5);
readln(f,s); delete(s,1,10); p[i]:=strtofloat(s);
cap.Cells[i+1,1]:=floattostrf(p[i],ffgeneral,5,5);
for j:=1to 7do begin readln(f,s);
if j=7 then delete(s,1,6)
else if j=1then delete(s,1,7)
else delete(s,1,8);
comb.Cells[i+1,j]:=s
end
end; readln(f);
for i:=0to 5 do begin readln(f,s); shgra.Checked[i]:=strtobool(s)end;
readln(f,s); label10.Caption:=s; readln(f);
for i:=1to 13do begin
readln(f,s); har.Cells[2,i]:=s;
if i mod 2=0 then begin readln(f,s); x[i div 2]:=strtofloat(s)end
else readln(f,s); har.Cells[3,i]:=s
end;
closefile(f); voltage(sender); ye:=false
end;
procedure TForm1.N12Click(Sender: TObject); {сохранение данных в файл}
begin
save.Execute; assignfile(f,save.FileName); rewrite(f);
writeln(f,'Частота 1-й гармоники, рад/с '+floattostr(w));
writeln(f,'Сдвиг 1-й гармоники, рад '+floattostr(e));
writeln(f,'Использовать все ёмкости '+booltostr(all.Checked));
writeln(f,'Число различных емкостей '+inttostr(numc.Value));
for i:=0 to numc.Value-1 do begin
writeln(f,'Ёмкость '+floattostr(c[i]));
writeln(f,'Стоимость '+floattostr(p[i]));
for j:=1 to 7 do begin
if j<7 then write(f,'гарм '+inttostr(6*j+1)+' ')
else write(f,'всего ');
s:=comb.Cells[i+1,j]; writeln(f,s)
end;
end;
writeln(f,'Показать графики');
for i:=0to 5 do writeln(f,booltostr(shgra.Checked[i]));
s:=label10.Caption; writeln(f,s);
writeln(f,'Амплитуды и отношения емкостей');
for i:=1 to 13do begin
s:=har.Cells[2,i]; writeln(f,s);
if i mod 2=0 then writeln(f,floattostr(x[i div 2]))
else begin s:=har.Cells[3,i]; writeln(f,s)end
end;
closefile(f)
end;
procedure TForm1.EdumaxExit(Sender: TObject); {задание максимально возм напряж на РКБ}
begin
try um:=strtofloat(edumax.Text)except on econverterror do
edumax.Text:=floattostrf(um,ffgeneral,5,5)end
end;
end.
Теперь оценим устойчивость устранения высших гармоник – для каждого отношения хi(i=1, 2, 3) найдём амплитуды соответствующих гармоник тока на выходе схемы при заданном отклонении отношения емкостей от хi и одинаковых амплитудах гармоник на входе. Схема имеет вид или приводится к виду, как на рис. 1:
Рис.1. Двухмостовой инвертор тока
В рассматриваемом случае Id1=Id2. Ток нагрузки определяется по формуле:
;
Выполнив комплексные преобразования, получим выражения для значений относительных амплитуд гармонических составляющих:
Здесь k – целое положительное число, s=±1;
Далее, Iн(6k+s)/Iн(1) = .
Выполнение программы показывает, что минимальному недопустимому отклонению отношения емкостей Р=0,001 соответствует Iн(6k+s)/Iн(1), равное от 0,0009 до 0,0011 для различных k и s, а для Р=0,01 Iн(6k+s)/Iн(1), находится в диапазоне (0,009; 0,011). Таким образом, относительные амплитуды высших гармоник приблизительно равны отклонениям от соответствующих отношений емкостей.
Рассмотрим случай, когда максимально допустимое напряжение на конденсаторах Umi меньше максимально возможного напряжения Um на РКБ. В этом случае требуется составлять группы последовательно соединённых емкостей. При этом допустимые напряжения и стоимости суммируются, а ёмкости делятся на их количество в группе.
Пусть имеем ёмкости: 1 мкФ, 1руб, Um1=0,5 Um; 2 мкФ, 1руб, Um2=0,25 Um; В этом случае последовательные группы будут иметь одинаковые ёмкости 0,5 мкФ, стоимости 2р и 4р соответственно. Вторая ёмкость новых отношений не даёт, а стоимость имеет большую, поэтому использовать её в таком составе не имеет смысла, что и показывает программа:
Обозн |
Ёмк, мкФ |
Цена, руб |
Umi /Um |
Кол-во посл соед конд |
Кол. емк в “числ”/кол емк в знам для 0,7321/1 |
То же для 0,8587/1 |
То же для 0,9271/1 |
С1 |
1 |
1 |
0,5 |
2 |
60/82 |
98/114 |
76/82 |
С2 |
2 |
1 |
0,25 |
4 |
0/0 |
0/0 |
0/0 |
Стоимость набора, руб |
142 |
212 |
158 |
Табл. 1
Выполнено 674 проверки.
Но добавим избыточность допустимого напряжения, вместо 4 последовательно соединённых конденсаторов с Um2=0,25 Um поставим 5. В окне программы для этого уменьшим Um2 до 0,2 Um. Стали использоваться оба вида емкостей, стоимости наборов уменьшились примерно в 3 раза:
Обозн |
Ёмк, мкФ |
Цена, руб |
Umi /Um |
Кол-во посл соед конд |
Кол. емк в “числ”/кол емк в знам для 0,7321/1 |
То же для 0,8587/1 |
То же для 0,9271/1 |
С1 |
1 |
1 |
0,5 |
2 |
12/10 |
18/18 |
14/22 |
С2 |
2 |
1 |
0,25 |
5 |
0/20 |
5/15 |
20/0 |
Стоимость набора, руб |
42 |
56 |
56 |
Табл. 2
Здесь НОД всех емкостей последовательных соединений равен НОД(0,5; 0,4)=0,1мкФ. Выполнено 4319 проверок.
Поставим теперь 8 последовательно соединённых конденсаторов С2, т.е, ёмкость последовательного соединения С2 вдвое меньше ёмкости последовательного соединения С1. НОД(0,5; 0,25)=0,25мкФ, выполнено 2002 проверки. Наборы стали дороже, но дешевле, чем в первом случае:
Обозн |
Ёмк, мкФ |
Цена, руб |
Umi /Um |
Кол-во посл соед конд |
Кол. емк в “числ”/кол емк в знам для 0,7321/1 |
То же для 0,8587/1 |
То же для 0,9271/1 |
С1 |
1 |
1 |
0,5 |
2 |
30/40 |
48/56 |
38/40 |
С2 |
2 |
1 |
0,25 |
8 |
0/8 |
8/8 |
0/8 |
Стоимость набора, руб |
78 |
120 |
86 |
Табл. 3
Установим снова 5 последовательно соединённых конденсаторов С2, но добавим третий вид конденсаторов:
Обозн |
Ёмк, мкФ |
Цена, руб |
Umi /Um |
Кол-во посл соед конд |
Кол. емк в “числ”/кол емк в знам для 0,7321/1 |
То же для 0,8587/1 |
То же для 0,9271/1 |
С1 |
1 |
1 |
0,5 |
2 |
6/2 |
0/4 |
2/4 |
С2 |
2 |
1 |
0,25 |
5 |
0/10 |
5/5 |
5/0 |
С3 |
0,75 |
0,9 |
0,5 |
2 |
0/4 |
8/0 |
2/2 |
Стоимость набора, руб |
21,6 |
21,2 |
14,6 |
Табл. 4
Видно, что стоимости наборов ещё уменьшились. Выполнено 37 004 проверки. Здесь НОД(0,5; 0,4; 0,375)=0,025мкФ. Сделаем теперь С3=0,6мкФ, НОД(0,5; 0,4; 0,3)=0,1мкФ. Число проверок уменьшится(31 523), наборы станут дороже, но дешевле, чем совсем без С3:
Обозн |
Ёмк, мкФ |
Цена, руб |
Umi /Um |
Кол-во посл соед конд |
Кол. емк в “числ”/кол емк в знам для 0,7321/1 |
То же для 0,8587/1 |
То же для 0,9271/1 |
С1 |
1 |
1 |
0,5 |
2 |
12/14 |
0/0 |
0/4 |
С2 |
2 |
1 |
0,25 |
5 |
16/18 |
0/0 |
6/8 |
С3 |
0,6 |
0,9 |
0,5 |
2 |
14/14 |
0/0 |
2/4 |
Стоимость набора, руб |
29,6 |
46,6 |
33,4 |
Табл. 5