bruce mayer, pe registered electrical & mechanical engineer bmayer@chabotcollege
DESCRIPTION
Engr/Math/Physics 25. Prob 5.47, 5.57 Tutorial. Bruce Mayer, PE Registered Electrical & Mechanical Engineer [email protected]. Problem 5.47 Chemical Rcn Order. 1 st Order Rate Eqn is Expontnential. By SemiLog Linearization we can “Discover” parameters [m & b] [C(0) & −k] - PowerPoint PPT PresentationTRANSCRIPT
[email protected] • ENGR-25_Programming-1.ppt1
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Bruce Mayer, PERegistered Electrical & Mechanical Engineer
Engr/Math/Physics 25
Prob 5.47, Prob 5.47, 5.575.57
TutorialTutorial
[email protected] • ENGR-25_Programming-1.ppt2
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Problem 5.47 Problem 5.47 Chemical Rcn Order Chemical Rcn Order
1st Order Rate Eqn is Expontnential
mxkt beyeCtC 0
• By SemiLog Linearization we can “Discover” parameters [m & b] [C(0) & −k]
2nd Order Eqn can be LINEARIZED as 0
11
Ckt
tC
222 BmXY
• Thus ANOTHERLinearizable Fcn
bmxy 11
[email protected] • ENGR-25_Programming-1.ppt3
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Prob Solve 1Prob Solve 1stst Step → PLOT it 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
[email protected] • ENGR-25_Programming-1.ppt4
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Prob 5.47Prob 5.47 When in Doubt PLOT (use SubPlot)
0 50 100 150 200 250 300-5.6
-5.4
-5.2
-5
-4.8
-4.6
t
1st
Ord
=>
ln
(C)
0 50 100 150 200 250 300100
150
200
250
300
t
2nd
Ord
=>
1/C
Some CURVATURE
Straight• Better Model
• t X
• 1/C Y
[email protected] • ENGR-25_Programming-1.ppt5
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Linear Xform of 2Linear Xform of 2ndnd Order Reaction Order Reaction
Now that the plot has identified the Rcn as 2nd Order, Make Linear Xform
The 2nd Order Eqn
011
Ckt
tC
222 BmXY
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)
[email protected] • ENGR-25_Programming-1.ppt6
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Th
e 2T
he 2 n
dn
d O
rder M
od
el O
rder M
od
el
% Bruce Mayer, PE * 04Nov06% ENGR25 % file = Prob5_47_Chem_Concentration_0611.m% Find the Order of the chemical reaction%% CLEAR out any previous runsclear%% The Data Vectorst = [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 ORDERCfirst = log(C);Csecond = 1./C;%% Check which one gives straight linesubplot(2,1,1)plot(t,Cfirst,t,Cfirst,'*'), xlabel('t'), ylabel('1st Ord => ln(C)'), gridsubplot(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 line%% 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 notationformat short ek_1overC0 = polyfit(t,Csecond,1)k = k_1overC0(1)C0 = 1/k_1overC0(2)
[email protected] • ENGR-25_Programming-1.ppt7
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
P 5.47 AnswerP 5.47 Answer
k_1overC0 = [m B2] = [k 1/C0] = [5.4445e-001 9.9605e+001]
k = 5.4445e-001• k = 0.54445
C0 =1/9.9605e+001
1.0040e-002• C(0) = 0.01004 0 50 100 150 200 250 300
80
100
120
140
160
180
200
220
240
260
280
t
2nd
Ord
=>
1/C
1/C = 0.5445*t + 99.61
data Line
PolyFitdata Pts
[email protected] • ENGR-25_Programming-1.ppt8
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
P5.57 GeometryP5.57 Geometry
x
y
r2r2r1 dy
dx1
dx2
Point at (x,y)
x-0.3
x-(-0.3) = x+0.3
2
2
1
1
04
1
r
q
r
qV
E-Field Governing Equation
[email protected] • ENGR-25_Programming-1.ppt9
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
The Distance CalcsThe Distance Calcs
Using Pythagorean Theorem
222211 3.0 yxdydxr
22
2
222222
3.0
3.0
yxr
yxdydxr
[email protected] • ENGR-25_Programming-1.ppt10
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Th
e Mesh
Grid
Plo
tT
he M
eshG
rid P
lot
% 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
[email protected] • ENGR-25_Programming-1.ppt11
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Meshc Plot MeshGridMeshc Plot MeshGrid
-0.4
-0.2
0
0.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.
Pot
entia
l (V
)
[email protected] • ENGR-25_Programming-1.ppt12
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
surf Plot by MeshGridsurf Plot by MeshGrid
-0.4
-0.2
0
0.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.
Pot
entia
l (V
)
[email protected] • ENGR-25_Programming-1.ppt13
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Th
e Lo
op
Plo
tT
he L
oo
p P
lot
% 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
[email protected] • ENGR-25_Programming-1.ppt14
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
meshc Plot by Loopmeshc Plot by Loop
-0.4
-0.2
0
0.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.
Pot
entia
l (V
)
Note that plot is TURNED
[email protected] • ENGR-25_Programming-1.ppt15
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
surf Plot by Loopsurf Plot by Loop
-0.4
-0.2
0
0.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.
Pot
entia
l (V
)
Note that plot is TURNED