ASE 311 HW #12 - tS enErrS 2.) dT/dx = q dq/dx = .15 * T...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
ASE 311 HW #12 1.) mass = 1; kspring = 1; y0 = [1,0]; tspan = [0, 50*pi]; nsteps = 2000; [tR,yR,en,enErrR] = rk4ODE(@massSpring1, @massSpring1en, tspan, y0, nsteps, kspring, mass); [tS,yS,en,enErrS] = stormerODE(@massSpring1, @massSpring1en, tspan, y0,4*nsteps, kspring, mass); yExactS = cos(tS); yExactR = cos(tR); figure(1) plot(tS,yExactS-yS(:,1)') figure(2) plot(tR,yExactR-yR(:,1)'); figure(3) plot(tS,enErrS) figure(4) plot(tR,enErrR) If we were to run each method for a much larger ending time, by observing the graphs of the methods, we can see that the Runge-Kutta would give us a better trajectory, while the Stormer-Verlet method better conserve energy.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
0 20 40 60 80 100 120 140 160 -5 -4 -3 -2 -1 0 1 2 3 4 5 x 10 -5 Trajectory Error Runge-Kutta tR yExactR-yR
Background image of page 2
0 20 40 60 80 100 120 140 160 -2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5 x 10 -3 Trajectory Error Stormer-Verlet tS yExact-yS
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
0 20 40 60 80 100 120 140 160 -7 -6 -5 -4 -3 -2 -1 0 x 10 -6 Energy Error Runge-Kutta tR enErrR
Background image of page 4
0 20 40 60 80 100 120 140 160 -1 -0.9 -0.8 -0.7 -0.6 -0.5 -0.4 -0.3 -0.2 -0.1 0 x 10 -4 Energy Error Stormer-Verlet
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 6
Background image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: tS enErrS 2.) dT/dx = q dq/dx = .15 * T function df = heat(x,y) df=[ y(2); .15*(y(1))]; function b = bal(qp) [x,y]=ode45(@heat,[0 10], [240 qp]); b = y(length(x),1) - 150; >> fzero(@bal , -90) ans =-86.5858 >> [x,y] = ode45(@heat, [0 10], [240 fzero(@bal,-90)]); >> plot(x, y(:,1)) >> fzero(@bal,-90) ans =-90.6147 >> [x,y] = ode45(@heat,[0 10],[240 fzero(@bal, -90)]); 1 2 3 4 5 6 7 8 9 10 40 60 80 100 120 140 160 180 200 220 240 >> plot(x,y(:,1)) >> v = [2.15 -1 0 0 0 0 0 0 0; -1 2.15 -1 0 0 0 0 0 0; 0 -1 2.15 -1 0 0 0 0 0; 0 0 -1 2.15 -1 0 0 0 0; 0 0 0 -1 2.15 -1 0 0 0; 0 0 0 0 -1 2.15 -1 0 0; 0 0 0 0 0 -1 2.15 -1 0; 0 0 0 0 0 0 -1 2.15 -1; 0 0 0 0 0 0 0 -1 2.15]; >> w = [240 0 0 0 0 0 0 0 150]'; >> T = v \ w T = 165.7573 116.3782 84.4558 65.2018 55.7281 54.6136 61.6911 78.0223 106.0569 T(0) = 240 T(10) = 150 1 2 3 4 5 6 7 8 9 10 40 60 80 100 120 140 160 180 200 220 240...
View Full Document

This note was uploaded on 02/13/2010 for the course ASE 311 taught by Professor Kraczek during the Spring '08 term at University of Texas at Austin.

Page1 / 7

ASE 311 HW #12 - tS enErrS 2.) dT/dx = q dq/dx = .15 * T...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online