проект. Моделирование электрических полей. Содержание введение 3 глава основы теории и вопросы моделирования
Скачать 1.02 Mb.
|
R := SQRT ( SQR( DX ) + SQR ( DY ) ); P := P + Z[ I ] / R; END ; } P := POT ( X, Y, Z, XZ, YZ ); OSHP := P - PB; K := 0.15; WHILE ( ABS( OSHP ) > 0 ) AND ( K*STEP > MIN_STEP ) DO BEGIN 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; IF OSHP> 0 THEN ZNAK := 1 ZNAK := -1 ELSE ; DX := ZNAK * K * STEP * CX; DY := ZNAK * K * STEP * CY ; X := X + DX; Y := Y + DY; { P := 0; FOR I := 1 TO NZ DO BEGIN DX := X - XZ[ I ]; DY := Y - YZ[ I ]; R := SQRT ( SQR( DX ) + SQR ( DY ) ); P := P + Z[ I ] / R; END ; } P := POT ( X, Y, Z, XZ, YZ ); OSH_OLD := OSHP; OSHP := P - PB; IF OSHP * OSH_OLD < 0 THEN K := 0.8 * K END ; DX := X - X_PRED; IF PERVYJ AND ( DX<> 0 ) THEN BEGIN DXB := DX; PERVYJ := FALSE END ; X_PRED := X; IF DXB * DX < 0 THEN BEGIN XN := X; YN := Y; FLAG_PROD := TRUE; BREAK END ; IF ( ABS ( X ) < X_MAX ) AND ( ABS ( Y ) < Y_MAX ) THEN BEGIN INC(NT); XT[NT] := X; YT[NT] := Y END ; IF ( ABS ( X ) > 200 * X_MAX ) OR ( ABS ( Y ) > 200 * Y_MAX ) THEN FLAG_ALL := TRUE UNTIL FLAG_ALL ; LP1 := FLAG_PROD END ; end. unit MLINS; interface USES MAINFM ; FUNCTION LS1 (ZNAK : INTEGER; XB, YB : DOUBLE; Z, XZ, YZ : M8; VAR NT : WORD; VAR XN, YN : DOUBLE ) : BOOLEAN; implementation FUNCTION LS1 (ZNAK : INTEGER; XB, YB : DOUBLE; Z, XZ, YZ : M8; VAR NT : WORD; VAR XN, YN : DOUBLE ) : BOOLEAN; VAR FLAG_ALL, FLAG_PROD : BOOLEAN; X, Y, CX, CY, DX , DY, R, R2, E, STEP, DXB : DOUBLE; I : INTEGER ; 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; FLAG_PROD := FALSE; 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 := 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 ; IF X = XB THEN DXB := DX ; IF DXB * DX < 0 THEN BEGIN XN := X; YN := Y; FLAG_PROD := TRUE; BREAK END ; X := X + DX; Y := Y + DY; IF ( ABS ( X ) <= 1.005 * X_MAX ) AND ( ABS ( Y ) <= 1.005 * Y_MAX ) THEN BEGIN INC(NT); XT[NT] := X; YT[NT] := Y END ; IF ( ABS ( X ) > 200 * X_MAX ) OR ( ABS ( Y ) > 200 * Y_MAX ) THEN FLAG_ALL := TRUE ; FOR I := 1 TO NZ DO IF ( SQR ( X - XZ[I] ) + SQR ( Y - YZ[I] ) ) FLAG_ALL := TRUE UNTIL FLAG_ALL ; LS1 := FLAG_PROD END ; end. unit POT_MAXMIN; interface USES MAINFM ; FUNCTION POT ( X, Y : DOUBLE; Z, XZ, YZ : M8 ) : DOUBLE; // PROCEDURE P_MAXMIN ( Z, XZ, YZ : M8 ); implementation FUNCTION POT ( X, Y : DOUBLE; Z, XZ, YZ : M8 ) : DOUBLE; VAR I : INTEGER; DX, DY, P, R : DOUBLE ; BEGIN P := 0; FOR I := 1 TO NZ DO BEGIN DX := X - XZ[ I ]; DY := Y - YZ[ I ]; R := SQRT ( SQR( DX ) + SQR ( DY ) ); P := P + Z[ I ] / R END ; POT := P END; end. |