Главная страница

проект. Моделирование электрических полей. Содержание введение 3 глава основы теории и вопросы моделирования


Скачать 1.02 Mb.
НазваниеСодержание введение 3 глава основы теории и вопросы моделирования
Анкорпроект
Дата25.05.2023
Размер1.02 Mb.
Формат файлаdocx
Имя файлаМоделирование электрических полей.docx
ТипРеферат
#1158642
страница11 из 12
1   ...   4   5   6   7   8   9   10   11   12

ПРИЛОЖЕНИЕ


Текст программы моделирования линий напряженности и потенциальных линий. Линии магнитной индукции.

unitmainFM; interface uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Con- trols, Forms,

Dialogs, TeEngine, Series, BubbleCh, ExtCtrls, TeeProcs, Chart, StdCtrls,

Grids;
type

TfmMain = class(TForm) ris: TChart;

bubl: TBubbleSeries; kn: TButton;

tabl: TStringGrid; POLE_NZ: TEdit;

bub2: TBubbleSeries; Mem: TMemo;

S1: TLineSeries; tab_xyp: TStringGrid;

POLE_NP: TEdit;

Label1: TLabel;

Label2: TLabel;

procedureknClick(Sender: TObject); procedureFormCreate(Sender: TObject); private

{ Private declarations } public

{ Public declarations } end;
var

fmMain: TfmMain;
const

GRAD_RAD = PI / 180; MAX_N = 8;

MAX_NT = 5700;



x_max = 5;

raz_x = 2 * x_max; y_max = 3;

raz_y = 2 * y_max; r_zar = y_max*0.022; otst = 0.3;

TYPE

M8 = ARRAY [ 1 .. MAX_N ] OF DOUBLE;
MT = ARRAY [ 1 .. MAX_NT ] OF DOUBLE

; VAR

MIN_STEP : DOUBLE; NZ : WORD ;

XT, YT, XTP, YTP : MT

;

implementation
{$R *.dfm}

USES MLINS, POT_MAXMIN, MLINP; VAR

Z, XZ, YZ : M8;

NEWseries :TLineSeries;
procedureTfmMain.knClick(Sender: TObject); VAR

POVTOR, ZAMKNULI : BOOLEAN;

XP, YP, X2, Y2, DOB_X, DOB_Y, UG, PB : DOUBLE; I, JG, J_CHET, J_NCHET : INTEGER;

NP, IP, IZ, NT, N_KUSKOV : WORD; CVETSIL, CVETPOT, CVETPLUS : TCOLOR;
begin
NZ := STRTOINT ( POLE_NZ.Text );
// x_beg := raz_x * otst - x_max; bubl.Clear;

bubl.AddBubble( -x_max - 0.05, -y_max - 0.05, 0.001 );

bubl.AddBubble(x_max + 0.05, -y_max - 0.05, 0.001 );

bubl.AddBubble( -x_max - 0.05, y_max + 0.05, 0.001 );

bubl.AddBubble(x_max + 0.05, y_max + 0.05, 0.001 );
// TABL.Cells[ 0, 0 ] := ' N ЗАР '; TABL.Cells [ 1, 0 ] := '

    1. (mkKu) ';

// TABL.Cells[ 2, 0 ] := ' x (m) '; TABL.Cells [ 3, 0 ] := '

y (m) ';
CVETPLUS :=clRED;

bubl.ColorEachPoint := FALSE; bubl.AreaColor := CVETPLUS;

bub2.Clear; bub2.ColorEachPoint := FALSE; bub2.AreaColor := clBLUE; BUB2.LinePen.Width := 3; bub2.LinePen.Color := clBLUE;
FOR I := 1 TO NZ DO BEGIN

TABL.Cells[ 0, I ] := INTTOSTR ( I );

Z [ I ] := STRTOFLOAT ( TABL.Cells [ 1, I ] ); xZ [ I ] := STRTOFLOAT( TABL.Cells [ 2, I ]);

YZ [ I ] := STRTOFLOAT( TABL.Cells [ 3, I ]);

IF Z [ I ] > 0 THEN

bubl.AddBubble(xZ[ I ], YZ[I], r_zar ) ELSE

bub2.AddBubble(xZ[ I ], YZ[I], r_zar ) END

;

FOR JG := 3 TO RIS.SeriesCount - 1 DO RIS.Series[ JG ].Clear;
CVETPOT := CLGREEN; J_NCHET := 1;

NP := STRTOINT ( POLE_NP.Text ); FOR IP := 1 TO NP DO

BEGIN
XP := STRTOFLOAT ( TAB_XYP.Cells [ 1, IP ] ); YP := STRTOFLOAT ( TAB_XYP.Cells [ 2, IP ] );
PB := POT ( XP, YP, Z, XZ, YZ ); TAB_XYP.Cells[ 3, IP ] := FLOATTOSTR ( PB );

INC ( J_NCHET, 2 );
ZAMKNULI := FALSE;

POVTOR := LP1 ( 1, PB, XP, YP, Z, XZ, YZ,

NT, X2, Y2 );
TLineSeries(RIS.Series [ J_NCHET ]).LinePen.Color := CVETPOT; FOR I := 1 TO NT DO

IF ( ABS ( XT[I] ) <= X_MAX ) AND ( ABS ( YT[I] ) <= Y_MAX ) THEN

RIS.Series[ J_NCHET ].AddXY( XT[I], YT[I], '', CVETPOT )

;
IF POVTOR THEN

ZAMKNULI := ( ABS( X2 - XP ) < (X_MAX * 0.008) ) AND ( ABS( Y2 - YP ) < (Y_MAX * 0.008) )

;

N_KUSKOV := 1;

WHILE POVTOR AND ( NOT ZAMKNULI ) DO BEGIN
POVTOR := LP1 ( 1, PB, X2, Y2, Z, XZ, YZ,

NT, X2, Y2 );

INC ( J_NCHET, 2 );
TLineSeries(RIS.Series [ J_NCHET ]).LinePen.Color := CVETPOT; FOR I := 1 TO NT DO

IF ( ABS ( XT[I] ) <= X_MAX ) AND ( ABS ( YT[I] ) <= Y_MAX ) THEN

RIS.Series[ J_NCHET ].AddXY( XT[I], YT[I], '', CVETPOT )

;

INC ( N_KUSKOV ); IF N_KUSKOV > 5 THEN

BREAK;
IF POVTOR THEN

ZAMKNULI := ( ABS( X2 - XP ) < (X_MAX * 0.008) ) AND ( ABS( Y2 - YP ) < (Y_MAX * 0.008) )

END END

;

CVETSIL :=clBlue;
J_CHET := 2;
FOR IZ:= 1 TO NZ DO IF Z [ IZ ] > 0 THEN

BEGIN

FOR JG := 8 TO 26 DO BEGIN

UG := ( -10 + JG * 20 ) * GRAD_RAD;

DOB_X := 1.4 * r_zar * COS ( UG ); DOB_Y := 1.4 * r_zar * SIN ( UG );
INC ( J_CHET, 2 );
POVTOR := LS1 (1, XZ[IZ] + DOB_X, YZ[IZ] + DOB_Y, Z, XZ, YZ,

NT, X2, Y2 );

TLineSeries(RIS.Series [ J_CHET ]).LinePen.Color := CVETSIL; FOR I := 1 TO NT DO

IF ( ABS ( XT[I] ) <= X_MAX ) AND ( ABS ( YT[I] ) <= Y_MAX ) THEN

RIS.Series[ J_CHET ].AddXY( XT[I], YT[I], '', CVETSIL )

;

WHILE POVTOR DO BEGIN
INC ( J_CHET, 2 );

TLineSeries(RIS.Series [ J_CHET ]).LinePen.Color := CVETSIL;
POVTOR := LS1 (1, X2, Y2, Z, XZ, YZ,

NT, X2, Y2 ); FOR I := 1 TO NT DO

IF ( ABS ( XT[I] ) <= X_MAX ) AND ( ABS ( YT[I] ) <= Y_MAX ) THEN

RIS.Series[ J_CHET ].AddXY( XT[I], YT[I], '', CVETSIL ) END

;

INC ( J_CHET, 2 );
POVTOR := LS1 (-1, XZ[IZ] + DOB_X, YZ[IZ] + DOB_Y , Z, XZ, YZ,

NT, X2, Y2 );

TLineSeries(RIS.Series [ J_CHET ]).LinePen.Color := CVETSIL; FOR I := 1 TO NT DO

IF ( ABS ( XT[I] ) <= X_MAX ) AND ( ABS ( YT[I] ) <= Y_MAX ) THEN

RIS.Series[ J_CHET ].AddXY( XT[I], YT[I], '', CVETSIL )

;
WHILE POVTOR DO BEGIN

INC ( J_CHET, 2 );

TLineSeries(RIS.Series [ J_CHET ]).LinePen.Color := CVETSIL;
POVTOR := LS1 (-1, X2, Y2, Z, XZ, YZ,

NT, X2, Y2 ); FOR I := 1 TO NT DO

IF ( ABS ( XT[I] ) <= X_MAX ) AND ( ABS ( YT[I] ) <= Y_MAX ) THEN

RIS.Series[ J_CHET ].AddXY( XT[I], YT[I], '', CVETSIL ) END

END END

;

FOR I := 1 TO NZ DO BEGIN

IF Z [ I ] > 0 THEN

bubl.AddBubble(xZ[ I ], YZ[I], r_zar, '', CVETPLUS )

END

end;
procedureTfmMain.FormCreate(Sender: TObject); VAR

I, JG : WORD;

x_beg, dx, x : double

;

begin
MIN_STEP := 0.00002 *

SQRT ( SQR( RAZ_X ) + SQR( RAZ_Y ) );
s1.ColorEachPoint := false; s1.LinePen.Color := clGreen;
FOR JG :=RIS.SeriesCount TO 1500 DO BEGIN

NEWseries:=TLineSeries.Create( RIS ); RIS.AddSeries(NEWseries);

// RIS.Series [ JG ].Style := S1.Style; TLineSeries(RIS.Series [ JG ]).LinePen.COLOR := CLGREEN

END

;
NZ := STRTOINT ( POLE_NZ.Text );
dx := (raz_x * ( 1 - 2*otst) ) / ( NZ - 1 );
FOR JG := 0 TO RIS.SeriesCount - 1 DO mem.Lines.Append( 's[ '+

INTTOSTR ( JG ) + ' ] - ' + ris.Series [ JG

].Name);

{ mem.Lines.Append( 's[1] - ' + ris.Series [ 1 ].Name);

mem.Lines.Append( 's[2] - ' + ris.Series [ 2 ].Name);

mem.Lines.Append( 's[3] - ' + ris.Series [ 3 ].Name);

}
TAB_XYP.Cells[ 1, 0 ] := ' X ';

TAB_XYP.Cells[ 2, 0 ] := ' Y '; TAB_XYP.Cells[ 3, 0 ] := ' ПОТЕНЦИАЛ ';
TAB_xyp.Cells[ 1, 1 ] := floatTOSTR ( -2.2 );

TAB_xyp.Cells[ 1, 2 ] := floatTOSTR ( -1.5 );
TAB_xyp.Cells[ 2, 1 ] := floatTOSTR ( 1.0 );

TAB_xyp.Cells[ 2, 2 ] := floatTOSTR ( -1.5 );
x_beg := raz_x * otst - x_max;

TABL.Cells[ 0, 0 ] := ' N ЗАР '; TABL.Cells [ 1, 0 ] := ' Q

(mkKu) ';

TABL.Cells[ 2, 0 ] := ' x (m) '; TABL.Cells [ 3, 0 ] := ' y (m) ';

FOR I := 1 TO NZ DO BEGIN

TABL.Cells[ 0, I ] := INTTOSTR ( I ); TABL.Cells[ 1, I ] := floatTOSTR ( 1 );
x := x_beg + ( i - 1 ) * dx; TABL.Cells[ 2, I ] := floatTOSTr ( x );
TABL.Cells[ 3, I ] := floatTOSTR ( 0 ) END

;

TABL.Cells[ 1, 2 ] := floatTOSTR ( -1 );

knClick ( SENDER ) end;
end.


unit MLIN; interface

USES MAINFM

;

FUNCTION LS1 (ZNAK : INTEGER; XB, YB : DOUBLE; Z, XZ, YZ : M8 ) : WORD;
implementation

FUNCTION LS1 (ZNAK : INTEGER; XB, YB : DOUBLE; Z, XZ, YZ : M8 ) : WORD;

VAR

FLAG_ALL : BOOLEAN;

X, Y, CX, CY, DX , DY, R, R2, E, STEP : DOUBLE; I : INTEGER;

NT : WORD

; BEGIN
X := XB; Y := YB;

XT[ 1 ] := X; YT[ 1 ] := Y; NT := 1

;

STEP := SQRT( SQR( X_MAX ) + SQR ( Y_MAX ) ) * 0.02

;

FLAG_ALL := FALSE;

REPEAT

CX := 0; CY := 0;

FOR I := 1 TO N DO BEGIN

DX := X - XZ[ I ]; DY := Y - YZ[ I ];
R2 := SQR( DX ) + SQR ( DY );

    1. := SQRT ( R2 ); E := ZNAK * Z[ I ] / R2;


CX := CX + E * DX / R; CY := CY + E * DY / R

END

;

R := SQRT ( SQR ( CX ) + SQR ( CY ) );

DX := STEP * CX / R; DY := STEP * CY / R

;

X := X + DX; Y := Y + DY;
IF ( ABS ( X ) < X_MAX ) AND ( ABS ( Y ) < Y_MAX ) THEN

BEGIN

INC(NT); XT[NT] := X; YT[NT] := Y END

;

IF ( ABS ( X ) > 4* X_MAX ) OR ( ABS ( Y ) > 4* Y_MAX ) THEN

FLAG_ALL := TRUE

;

FOR I := 1 TO N DO

IF ( SQR ( X - XZ[I] ) + SQR ( Y - YZ[I] ) )



FLAG_ALL := TRUE
UNTIL FLAG_ALL

; LS1 := NT
END

;

end.





unit MLINP; interface

USES MAINFM

;

FUNCTION LP1 ( NAPR: INTEGER; PB, XB, YB : DOUBLE; Z, XZ, YZ : M8; VAR NT : WORD; VAR XN, YN : DOUBLE ) : BOOLEAN;

implementation uses POT_MAXMIN

;
FUNCTION LP1 ( NAPR: INTEGER; PB, XB, YB : DOUBLE; Z, XZ, YZ : M8; VAR NT : WORD; VAR XN, YN : DOUBLE ) : BOOLEAN;

VAR

FLAG_ALL, FLAG_PROD, PERVYJ : BOOLEAN;

X, Y, CX, CY, DX , DY, R, R2, E, STEP, DXB, X_PRED, K, P, OSHP, OSH_OLD : DOUBLE;

I, ZNAK : INTEGER

// NT, NTP : WORD
; BEGIN
X := XB; Y := YB;

X_PRED := X;

// XTP[ 1 ] := X; YTP[ 1 ] := Y; NTP := 1;

XT[ 1 ] := X; YT[ 1 ] := Y; NT := 1

;

STEP := SQRT( SQR( X_MAX ) + SQR ( Y_MAX ) ) * 0.008;
K := 1.0

;

FLAG_ALL := FALSE; FLAG_PROD := FALSE; PERVYJ := TRUE

; REPEAT
CX := 0; CY := 0;

FOR I := 1 TO NZ DO BEGIN

DX := X - XZ[ I ]; DY := Y - YZ[ I ];
R2 := SQR( DX ) + SQR ( DY );

R := SQRT ( R2 ); E := Z[ I ] / R2;
CX := CX + E * DX / R; CY := CY + E * DY / R

END

;

R := SQRT ( SQR ( CX ) + SQR ( CY ) ); CY := CY / R; CX := CX / R;

DX := NAPR * STEP * CY; DY := - NAPR * STEP * CX

;
X := X + DX; Y := Y + DY;

{

P := 0;
FOR I := 1 TO NZ DO BEGIN

DX := X - XZ[ I ]; DY := Y - YZ[ I ];
1   ...   4   5   6   7   8   9   10   11   12


написать администратору сайта