Prob 5.47, 5.57 Tutorial Engr/Math/Physics 25 Bruce Mayer, PE

advertisement
Engr/Math/Physics 25
Prob 5.47, 5.57
Tutorial
Bruce Mayer, PE
Registered Electrical & Mechanical Engineer
BMayer@ChabotCollege.edu
Engineering/Math/Physics 25: Computational Methods
1
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Programming-1.ppt
Problem 5.47  Chemical Rcn Order
 1st Order Rate Eqn is Expontnential
C t   C 0 e
 kt
 y  be
mx
• By SemiLog Linearization we can “Discover”
parameters [m & b]  [C(0) & −k]
1
1
 2nd Order Eqn can
 kt 
be LINEARIZED as C t 
C 0
• Thus ANOTHER
Linearizable Fcn
1 y  mx  1 b
Engineering/Math/Physics 25: Computational Methods
2
Y2  mX 2  B2
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Programming-1.ppt
Prob Solve 1st Step → PLOT it
 Advice for Every Engineer and Applied
Mathematician or Physicist:
 Rule-1: When in Doubt
PLOT IT!
 Rule-2: If you don’t KNOW
when to DOUBT, then PLOT
EVERYTHING
Engineering/Math/Physics 25: Computational Methods
3
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Programming-1.ppt
Prob 5.47
 When in Doubt PLOT (use SubPlot)
1st Ord => ln(C)
-4.6
 Some
CURVATURE
-4.8
-5
-5.2
-5.4
-5.6
0
50
100
150
t
200
250
300
2nd Ord =>1/C
300
 Straight
250
• Better Model
• t X
• 1/C Y
200
150
100
0
50
100
150
t
Engineering/Math/Physics 25: Computational Methods
4
200
250
300
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Programming-1.ppt
Linear Xform of 2nd Order Reaction
 Now that the plot
has identified the
Rcn as 2nd Order,
Make Linear Xform
 The 2nd Order Eqn
1
1
 kt 
C t 
C 0
Y2  mX 2  B2
Engineering/Math/Physics 25: Computational Methods
5
 Use polyfit of
order-1 to generate
fitting parameters
contained in vector
k_1overC0
 That is: k_1overC0
= [m, B2]; or
• k_1overC0(1)
=m=k
• k_1overC0(2)
= B2 = 1/C(0)
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Programming-1.ppt
Engineering/Math/Physics 25: Computational Methods
6
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Programming-1.ppt
The 2nd Order Model
% Bruce Mayer, PE * 04Nov06
% ENGR25
% file = Prob5_47_Chem_Concentration_0611.m
% Find the Order of the chemical reaction
%
% CLEAR out any previous runs
clear
%
% The Data Vectors
t = [0,50,100,200,300];
C = [0.01,0.0079,0.0065,0.0048,0.0038];
%
% WHEN IN DOUBT => PLOT
%% in this plot vs t to reveal Rcn Order: ln(C) & 1/C
%%% the Xformed DataVectors for RCN ORDER
Cfirst = log(C);
Csecond = 1./C;
%
% Check which one gives straight line
subplot(2,1,1)
plot(t,Cfirst,t,Cfirst,'*'), xlabel('t'), ylabel('1st Ord => ln(C)'), grid
subplot(2,1,2)
plot(t,Csecond,t,Csecond,'o'), xlabel('t'), ylabel('2nd Ord =>1/C'), grid
%
% After Comparing two curves, 2nd order gives much straighter li ne
%% use PolyFit to fit to 1/C(t)= k*t + 1/C0 => Y = mX + B
%% Xform to Line => 1/C => Y, t => X, k => m, 1/C0 => B
% Calc k & C0 showing in scientific notation
format short e
k_1overC0 = polyfit(t,Csecond,1)
k = k_1overC0(1)
C0 = 1/k_1overC0(2)
P 5.47 Answer
 k_1overC0 = [m B2] = [k 1/C0] =
[5.4445e-001 9.9605e+001]
 k = 5.4445e-001
280
260
240
• k = 0.54445
• C(0) = 0.01004
Engineering/Math/Physics 25: Computational Methods
7
220
2nd Ord =>1/C
 C0 =
1/9.9605e+001
 1.0040e-002
1/C = 0.5445*t + 99.61
200
180
160
140
120
data Line
PolyFit
data Pts
100
80
0
50
100
150
t
200
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Programming-1.ppt
250
300
P5.57 Geometry
 E-Field Governing
Equation
y
1  q1 q2 
  
V
40  r1 r2 
Point at (x,y)
r1
r2
dy
x
dx1
x-0.3
dx2
x-(-0.3) = x+0.3
Engineering/Math/Physics 25: Computational Methods
8
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Programming-1.ppt
The Distance Calcs
 Using Pythagorean Theorem
x  0.3
r1  dx  dy 
2
1
2
2
x   0.3
r2  dx  dy 
2
2
r2 
x  0.3
Engineering/Math/Physics 25: Computational Methods
9
2
2
2
y
y
2
y
2
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Programming-1.ppt
2
The MeshGrid 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 runs
clear
% The Constant Parameters
q1 = 2e-10; q2 = 4e-10; % in Coulombs
epsilon = 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-ops
r1 = sqrt((X-0.3).^2 +Y.^2); % note dots used with array operation
r2 = sqrt((X-(-0.3)).^2 +Y.^2); % note dots used with array operation
% use vectors r1 & r2, and array ops to find V
V = (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
Engineering/Math/Physics 25: Computational Methods
10
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Programming-1.ppt
Meshc Plot MeshGrid
2 Point-Charges Electical Field
Elect. Potential (V)
80
60
40
20
0
0.4
0.2
0.4
0.2
0
0
-0.2
Y-distance
-0.2
-0.4
Engineering/Math/Physics 25: Computational Methods
11
-0.4
X-distance
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Programming-1.ppt
surf Plot by MeshGrid
2 Point-Charges Electical Field
80
Elect. Potential (V)
70
60
50
40
30
20
10
0.4
0.2
0.4
0.2
0
0
-0.2
Y-distance
-0.2
-0.4
Engineering/Math/Physics 25: Computational Methods
12
-0.4
X-distance
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Programming-1.ppt
The Loop Plot
% Bruce Mayer, PE * 04Nov06 * ENGR25
% file = Prob5_57_Point_Charges_Loop_Plot_0611.m
% Surface Plot eField from two Point Charges
Clear % CLEAR out any previous runs
% The Constant Parameters
q1 = 2e-10; q2 = 4e-10; % in Coulombs
epsilon = 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 pythagorus
r1 = 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 r1
V(k,m) = (1/(4*pi*epsilon))*(q1/r1 +q2/r2);
% Note that V is a 2D array using the x & y indices
end
end
X = x;
Y = y;
% 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'),...
Bruce Mayer, PE
Engineering/Math/Physics 25: Computational Methods
grid on
13
BMayer@ChabotCollege.edu • ENGR-25_Programming-1.ppt
meshc Plot by Loop
2 Point-Charges Electical Field
80
Elect. Potential (V)
70
60
50
40
30
20
10
0.4
0.2
Note that plot
is TURNED
0.4
0.2
0
Y-distance
Engineering/Math/Physics 25: Computational Methods
14
0
-0.2
-0.2
-0.4
-0.4
X-distance
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Programming-1.ppt
surf Plot by Loop
2 Point-Charges Electical Field
80
Elect. Potential (V)
70
60
50
40
30
20
10
0.4
0.2
Note that plot
is TURNED
0.4
0.2
0
Y-distance
0
-0.2
-0.2
-0.4
Engineering/Math/Physics 25: Computational Methods
15
-0.4
X-distance
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Programming-1.ppt
Download