Математическое моделирование физических задач на ЭВМ

End;

15:Begin

Vetv1(Nodes[Ii,1],Nodes[Ii,2],0);

Vetv1(Nodes[Ii,1],Nodes[Ii,2],1);

End;

16:Begin

Vetv1(Nodes[Ii,1],Nodes[Ii,2],0);

Vetv1(Nodes[Ii,1],Nodes[Ii,2],1);

End;

17:Begin

Vetv1(Nodes[Ii,1],Nodes[Ii,2],1);

Vetv1(Nodes[Ii,1],Nodes[Ii,2],2);

End;

18:Begin

Vetv1(Nodes[Ii,1],Nodes[Ii,2],0);

Vetv1(Nodes[Ii,1],Nodes[Ii,2],2);

End;

End;

End;

Sizex:=Index-1;

{Оставляет нужные ветви}

i:=1;

While i0

Then i:=j

Else i:=Sizex+1;

End;

{Считаем сколько узлов с учётом соединений}

NCount:=NoDecount;

For i:=1 To NoDecount Do

If NNum[i]<>i

Then Dec(NCount);

If NCount<>NoDecount

Then

For i:=1 To NoDecount Do

Begin

j:=0;

For k:=1 To NoDecount Do

If NNum[k]=i

Then j:=1;

If j=0

Then

For k:=1 To NoDecount Do

If NNum[k]>i

Then Dec(NNum[k]);

End;

i:=1;

j:=0;

Repeat

Inc(j);

k:=NextDiv(i);

With Brunches[j] Do

Begin

AEDS:=0;

ARes:=0;

For l:=i To k Do

With A[l] Do

Case Typ Of

3..6: If Dir

Then EDS:=AEDS+EDS[Str,Col]

Else EDS:=AEDS-EDS[Str,Col];

7..8: ARes:=ARes+abs(Res[Str,Col]);

End;

FromN:=NNum[A[i].Num];

If k<>0

Then

Begin

ToN:=NNum[A[k-1].Num];

i:=k+1;

End

Else

Begin

ToN:=NNum[A[Sizex-1].Num];

i:=Sizex+1;

End;

End;

Until i>Sizex;

BrunchCount:=j;

{Заполняем систему}

For i:=1 To BrunchCount Do

With Brunches[i] Do

Begin

Equals[FromN,FromN]:=Equals[FromN,FromN]+1/ARes;

Equals[ToN,NCount+1]:=Equals[ToN,NCount+1]+AEDS/ARes;

End;

{Решаем систему}

For i:=2 To NCount Do

Begin

Ratio:=Equals[i,i];

For j:=2 To NCount+1 Do

Equals[i,j]:=Equals[i,j]/Ratio;

For k:=2 To NCount Do

If k<>i

For i:=1 To NCount+1 Do

Begin

Equals[1,i]:=0;

Equals[i,1]:=0;

End;

{После решения расставляем токи}

For i:=1 To RCount Do

Begin

j:=1;

While (jNil

Then DisposeStr(PString(Item));

End;

BEGIN

MyApp.Init;

MyApp.Run;

MyApp.Done;

END.

2. Модуль с библиотекой элементов

Unit Types2;

Interface

Uses

Crt,

Objects, Drivers, Dialogs, Views, Menus, App, StdDlg,

Fonts, HelpFile, MsgBox, TxtRead, WInDows,

PalObj, Grv16, DemoHlp;

Const

nS=8;

mS=13;

Sx:Integer = 50;

Sy:Integer = 40;

Sx1:Integer=20;

Sy1:Integer=20;

cmMemoViewChange = 1001;

CurrentElement:Byte=0;

IsResist:Boolean=True; {If True - resistOrs, Else - currents}

Type

TSheme=Array [1..nS,1..mS,1..2] Of Byte; {Массив сдержит схему}

TNodes=Array [1..nS*mS,1..2] Of Byte; {Массив содержит координаты всех

узловых элементов (i,j)}

TElems=Array [1..nS,1..mS] Of Real; {Содержит элементы значения}

TCurrents=Array [1..nS*mS] Of Real; {Токи}

TNNum=Array [1..nS*mS] Of Byte; {Номера узлов}

PEl=^TEl; {Элемент}

TEl=recOrd

Str,Col:Byte;{строка, столбец}

Typ:Byte;{тип}

Num:Byte;{номер}

Dir:Boolean;

End;

TBrunch=recOrd {Ветвь}

FromN,ToN:Byte;

ARes,AEDS:Real;

End;

TElAr=Array [1..2*mS*nS] Of TEl; {Элементы}

TBrunches=Array[1..mS*nS] Of TBrunch; {Ветви}

TEquals=Array[1..mS*nS Div 2,1..mS*nS Div 2] Of Real; {Уравнения}

PToolBar = ^TToolBar;

TToolBar = Object(TView)

ConstructOr Init(Var R: TRect);

Procedure Draw; Virtual;

Procedure HAndleEvent(Var Event:TEvent); Virtual; {Реагирование на события}

End;

PMemoView = ^TMemoView;

TMemoView = Object(TView)

ConstructOr Init(Var Bounds: TRect);

Procedure HAndleEvent(Var Event: TEvent); Virtual;

Procedure Draw; Virtual;

End;

{П- указатель, Т - тип}

PShemeView = ^TShemeView;

TShemeView = Object(TView)

ConstructOr Init(Var R: TRect);

Procedure Draw; Virtual;

Procedure HAndleEvent(Var Event:TEvent); Virtual;

End;

PShemeWIn = ^TShemeWIn;

TShemeWIn = Object(TDialog)

ConstructOr Init(Var R:TRect);

Function ElMatter(IsEDS:Boolean):Real; {Окно ввода значений}

DestructOr Done; Virtual;

End;

Var

Sheme:TSheme;

Nodes:TNodes;

EDS,Res:TElems;

Currents:TCurrents; {Токи}

NCount,NoDecount,ECount,RCount:Integer;

{Реално узлов, Узловых эл-тов, Колво ЭДС и Кол-во Рез.}

Changed:Boolean;

Exist:Boolean;

SetPhase:Boolean;

NNum:TNNum;

Brunches:TBrunches;

{Ветви}

BrunchCount:Integer;

{Кол-во}

Equals:TEquals;

Function IntToStr(i:longInt):String;

Procedure ElNumbers(Var ASheme:TSheme);

Procedure InitSheme(Var ASheme:TSheme);

Implementation

Procedure InitSheme(Var ASheme:TSheme);

{Зануляет текущую схему. Вызывается при старте и команде ОЧИСТИТЬ}

Var i,j,k:Integer;

Begin

For i:=1 To nS Do

For j:=1 To mS Do

For k:=1 To 2 Do

Begin

ASheme[i,j,k]:=0;

EDS[i,j]:=0;

Res[i,j]:=0;

End;

End;

ConstructOr TMemoView.Init(Var Bounds: TRect);

Begin

TView.Init(Bounds);

EventMask:= EventMask Or evBroadCast;

Options := OfPreProcess;

End;

Procedure TMemoView.HAndleEvent(Var Event: TEvent);

Begin

Inherited HAndleEvent(Event);

With Event Do

If (What =evBroadCast)And(CommAnd=cmMemoViewChange)

Then DrawView

Else Exit;

ClearEvent(Event);

End;

Procedure TMemoView.Draw;

Var

R: TRect;

S: String;

Begin

SetColOr(7);

FillRect(1, 1, Pred(Size.X), Pred(Size.Y));

GeTextent(R);

With R Do DrawFrame(A, B, OfWhiteRight);

Str(MemAvail:6, S);

SetColOr(0);

WriteStr(5, 3, S + 'b');

End;

ConstructOr TToolBar.Init(Var R: TRect);

Begin

Inherited Init(R);

GrowMode:= GrowMode Or (gfGrowHiX+gfGrowHiY);

End;

Procedure TToolBar.Draw;

Var

i,j: Integer;

Procedure ElDraw(Ax,Ay:Integer; An:Byte);

Procedure _1(x,y:Integer);

Begin

plotlIne (x,y+Sy Div 2,x+Sx,y+Sy Div 2);

End;

Procedure _2(x,y:Integer);

Begin

PlotLIne (x+sx Div 2,y,x+sx Div 2,y+sy);

End;

Procedure _9(x,y:Integer);

Begin

PlotLIne (x,y+sy Div 2,x+sx,y+sy Div 2);

PlotLIne (x+sx Div 2,y,x+sx Div 2,y+sy);

End;

{ Procedure _3(x,y:Integer);

Begin

PlotLIne (x,y+Sy Div 2,x+Sx Div 5,y+Sy Div 2);

PlotLIne (x+Sx*4 Div 5,y+Sy Div 2,x+Sx,y+Sy Div 2);

ThickCircle(x+Sx Div 2,y+Sy Div 2,sx*2 Div 6,1);

PlotLIne (x+Sx Div 4,y+Sy Div 2,x+Sx*3 Div 4,y+Sy Div 2);

PlotLIne (x+Sx*3 Div 4,y+Sy Div 2,x+Sx Div 2,y+Sy*13 Div 20);

PlotLIne (x+Sx*3 Div 4,y+Sy Div 2,x+Sx Div 2,y+Sy*7 Div 20);

End;

Procedure _4(x,y:Integer);

Begin

PlotLIne (x,y+sy Div 2,x+sx Div 5,y+sy Div 2);

PlotLIne (x+sx*4 Div 5,y+sy Div 2,x+sx,y+sy Div 2);

ThickCircle(x+sx Div 2,y+sy Div 2,sx*2 Div 6,1);

PlotLIne (x+sx Div 4,y+sy Div 2,x+sx*3 Div 4,y+sy Div 2);

PlotLIne (x+sx Div 4,y+sy Div 2,x+sx Div 2,y+sy*13 Div 20);

PlotLIne (x+sx Div 4,y+sy Div 2,x+sx Div 2,y+sy*7 Div 20);

End;

Procedure _5(x,y:Integer);

Begin

PlotLIne (x+sx Div 2,y,x+sx Div 2,y+sy*2 Div 10);

PlotLIne (x+sx Div 2,y+sy*8 Div 10,x+sx Div 2,y+sy);

ThickCircle(x+sx Div 2,y+sy Div 2,sx*2 Div 6,1);

PlotLIne (x+sx Div 2,y+sy Div 4,x+sx Div 2,y+sy*3 Div 4);

PlotLIne (x+sx Div 2,y+sy Div 4,x+sx*13 Div 20,y+sy Div 2);

PlotLIne (x+sx Div 2,y+sy Div 4,x+sx*7 Div 20,y+sy Div 2);

End;

Procedure _6(x,y:Integer);

Begin

PlotLIne (x+sx Div 2,y,x+sx Div 2,y+sy*2 Div 10);

PlotLIne (x+sx Div 2,y+sy*8 Div 10,x+sx Div 2,y+sy);

ThickCircle(x+sx Div 2,y+sy Div 2,sx*2 Div 6,1);

PlotLIne (x+sx Div 2,y+sy Div 4,x+sx Div 2,y+sy*3 Div 4);

PlotLIne (x+sx Div 2,y+sy*3 Div 4,x+sx*13 Div 20,y+sy Div 2);

PlotLIne (x+sx Div 2,y+sy*3 Div 4,x+sx*7 Div 20,y+sy Div 2);

End;}

Procedure _3(x,y:Integer);

Begin

PlotLIne (x,y+Sy Div 2,x+Sx*2 Div 5,y+Sy Div 2);

PlotLIne (x+Sx*3 Div 5,y+Sy Div 2,x+Sx,y+Sy Div 2);

PlotLIne (x+Sx*3 Div 5,y+Sy Div 8,x+Sx*3 Div 5,y+Sy*7 Div 8);

PlotLIne (x+Sx*2 Div 5,y+Sy Div 3,x+Sx*2 Div 5,y+Sy*2 Div 3);

End;

Procedure _4(x,y:Integer);

Begin

PlotLIne (x,y+Sy Div 2,x+Sx*2 Div 5,y+Sy Div 2);

PlotLIne (x+Sx*3 Div 5,y+Sy Div 2,x+Sx,y+Sy Div 2);

PlotLIne (x+Sx*2 Div 5,y+Sy Div 8,x+Sx*2 Div 5,y+Sy*7 Div 8);

PlotLIne (x+Sx*3 Div 5,y+Sy Div 3,x+Sx*3 Div 5,y+Sy*2 Div 3);

End;

Procedure _5(x,y:Integer);

Begin

PlotLIne (x+Sx Div 2,y,x+Sx Div 2,y+Sy*2 Div 5);

PlotLIne (x+Sx Div 2,y+Sy*3 Div 5,x+Sx Div 2,y+Sy);

PlotLIne (x+Sx Div 8,y+Sy*2 Div 5,x+Sx*7 Div 8,y+Sy*2 Div 5);

PlotLIne (x+Sx Div 3,y+Sy*3 Div 5,x+Sx*2 Div 3,y+Sy*3 Div 5);

End;

Procedure _6(x,y:Integer);

Begin

PlotLIne (x+Sx Div 2,y,x+Sx Div 2,y+Sy*2 Div 5);

PlotLIne (x+Sx Div 2,y+Sy*3 Div 5,x+Sx Div 2,y+Sy);

PlotLIne (x+Sx Div 8,y+Sy*3 Div 5,x+Sx*7 Div 8,y+Sy*3 Div 5);

PlotLIne (x+Sx Div 3,y+Sy*2 Div 5,x+Sx*2 Div 3,y+Sy*2 Div 5);

End;

Procedure _7(x,y:Integer);

Begin

PlotLIne(x,y+Sy Div 2,x+sx Div 5,y+Sy Div 2);

PlotLIne(x+sx*4 Div 5,y+Sy Div 2,x+sx,y+Sy Div 2);

PlotLIne(x+sx Div 5,y+Sy*12 Div 20,x+sx*4 Div 5,y+Sy*12 Div 20);

PlotLIne(x+sx*4 Div 5,y+Sy*12 Div 20,x+sx*4 Div 5,y+Sy*8 Div 20);

PlotLIne(x+sx*4 Div 5,y+Sy*8 Div 20,x+sx Div 5,y+Sy*8 Div 20);

PlotLIne(x+sx Div 5,y+Sy*8 Div 20,x+sx Div 5,y+Sy*12 Div 20);

Страницы: 1, 2, 3, 4, 5, 6, 7



Реклама
В соцсетях
скачать рефераты скачать рефераты скачать рефераты скачать рефераты скачать рефераты скачать рефераты скачать рефераты