Bruce Mayer, PE Registered Electrical & Mechanical Engineer BMayer@ChabotCollege

9
[email protected] • ENGR-25_Programming-1.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Registered Electrical & Mechanical Engineer [email protected] Engr/Math/Physics 25 Prob 5.36 Tutorial

description

Engr/Math/Physics 25. Prob 5.36 Tutorial. Bruce Mayer, PE Registered Electrical & Mechanical Engineer [email protected]. P5.36 Geometry. E-Field Governing Equation. The Distance Calcs. Using Pythagorean Theorem. The MeshGrid Plot. Meshc Plot MeshGrid. surf Plot by MeshGrid. - PowerPoint PPT Presentation

Transcript of Bruce Mayer, PE Registered Electrical & Mechanical Engineer BMayer@ChabotCollege

Page 1: Bruce Mayer, PE Registered Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] • ENGR-25_Programming-1.ppt1

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Bruce Mayer, PERegistered Electrical & Mechanical Engineer

[email protected]

Engr/Math/Physics 25

Prob 5.36Tutorial

Page 2: Bruce Mayer, PE Registered Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] • ENGR-25_Programming-1.ppt2

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

P5.36 Geometry

x

y

r2r2r1 dy

dx1

dx2

Point at (x,y)

x-0.3

x-(-0.3) = x+0.3

2

2

1

1

041

rq

rqV

E-Field Governing Equation

Page 3: Bruce Mayer, PE Registered Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] • ENGR-25_Programming-1.ppt3

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

The Distance Calcs Using Pythagorean Theorem

222211 3.0 yxdydxr

22

2

222222

3.0

3.0

yxr

yxdydxr

Page 4: Bruce Mayer, PE Registered Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] • ENGR-25_Programming-1.ppt4

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

The MeshG

rid Plot% Bruce Mayer, PE * 04Nov06% ENGR25 % file = Prob5_57_Point_Charges_meshgrid_Plot_0611.m% Surface Plot eField from two Point Charges%% CLEAR out any previous runsclear% The Constant Parametersq1 = 2e-10; q2 = 4e-10; % in Coulombsepsilon = 8.854e-12; % in Farad/m%% Note the distances, r1 & r2, to any point(x,y) in the field by pythagorus% * r1 = sqrt((x-0.3)^2 + y^2)% * r2 = sqrt((x+0.3)^2 + y^2)%% Construct a 25x25 mesh[X Y] = meshgrid(-0.25:0.010:0.25);%% find r1 & r2 by pythagorus and array-opsr1 = sqrt((X-0.3).^2 +Y.^2); % note dots used with array operationr2 = sqrt((X-(-0.3)).^2 +Y.^2); % note dots used with array operation% use vectors r1 & r2, and array ops to find VV = (1/(4*pi*epsilon))*(q1./r1 + q2./r2);%% use %-Comment to toggle between SURF & MESHC plots% surf(X,Y,V), xlabel('X-distance'), ylabel('Y-distance'),...

zlabel('Elect. Potential (V)'), title('2 Point-Charges Electical Field'),...grid on

meshc(X,Y,V), , xlabel('X-distance'), ylabel('Y-distance'),...zlabel('Elect. Potential (V)'), title('2 Point-Charges Electical Field'),...grid on

Page 5: Bruce Mayer, PE Registered Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] • ENGR-25_Programming-1.ppt5

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Meshc Plot MeshGrid

-0.4-0.2

00.2

0.4

-0.4

-0.2

0

0.2

0.40

20

40

60

80

X-distance

2 Point-Charges Electical Field

Y-distance

Ele

ct. P

oten

tial (

V)

Page 6: Bruce Mayer, PE Registered Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] • ENGR-25_Programming-1.ppt6

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

surf Plot by MeshGrid

-0.4-0.2

00.2

0.4

-0.4

-0.2

0

0.2

0.410

20

30

40

50

60

70

80

X-distance

2 Point-Charges Electical Field

Y-distance

Ele

ct. P

oten

tial (

V)

Page 7: Bruce Mayer, PE Registered Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] • ENGR-25_Programming-1.ppt7

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

The Loop Plot% Bruce Mayer, PE * 04Nov06 * ENGR25 % file = Prob5_57_Point_Charges_Loop_Plot_0611.m% Surface Plot eField from two Point ChargesClear % CLEAR out any previous runs% The Constant Parametersq1 = 2e-10; q2 = 4e-10; % in Coulombsepsilon = 8.854e-12; % in Farad/m% Note the distances, r1 & r2, to any point(x,y) in the field by pythagorus% * r1 = sqrt((x-0.3)^2 + y^2)% * r2 = sqrt((x+0.3)^2 + y^2)% Build up From Square XY Plane%% r1 goes to q1 at (0.3,0)%% r2 goes to q2 at (-0.3,0)x = linspace(-.25, .25, 50); %50 pts over x-range y = linspace(-.25, .25, 50); %50 pts over y-range for k = 1:length(x)

for m = 1:length(y)% calc r1 & r2 using pythagorusr1 = sqrt((x(k)-0.3)^2 + y(m)^2);r2 = sqrt((x(k)-(-0.3))^2 + y(m)^2);% Find V based on r1 and r1V(k,m) = (1/(4*pi*epsilon))*(q1/r1 +q2/r2);% Note that V is a 2D array using the x & y indices

endendX = x;Y = y;% use %-Comment to toggle between SURF & MESHC plotssurf(X,Y,V), xlabel('X-distance'), ylabel('Y-distance'),...

zlabel('Elect. Potential (V)'), title('2 Point-Charges Electical Field'),...grid on

%meshc(X,Y,V), , xlabel('X-distance'), ylabel('Y-distance'),...zlabel('Elect. Potential (V)'), title('2 Point-Charges Electical Field'),...grid on

Page 8: Bruce Mayer, PE Registered Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] • ENGR-25_Programming-1.ppt8

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

meshc Plot by Loop

-0.4-0.2

00.2

0.4

-0.4

-0.2

0

0.2

0.410

20

30

40

50

60

70

80

X-distance

2 Point-Charges Electical Field

Y-distance

Ele

ct. P

oten

tial (

V)

Note that plot is TURNED

Page 9: Bruce Mayer, PE Registered Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] • ENGR-25_Programming-1.ppt9

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

surf Plot by Loop

-0.4-0.2

00.2

0.4

-0.4

-0.2

0

0.2

0.410

20

30

40

50

60

70

80

X-distance

2 Point-Charges Electical Field

Y-distance

Ele

ct. P

oten

tial (

V)

Note that plot is TURNED