1 | function pass = ivptest |
---|
2 | |
---|
3 | % Rodrigo Platte Jan 2009 |
---|
4 | % This routine tests IVP solver: ode45, ode113, ode15s |
---|
5 | |
---|
6 | % Test ode113 Using default tolerances (RelTol = 1e-3) |
---|
7 | y = ode113(@vdp1,domain(0,20),[2;0]); % chebfun solution |
---|
8 | [tm,ym] = ode113(@vdp1,[0,20],[2;0]); % Matlab's solution |
---|
9 | |
---|
10 | pass1 = max(max(abs(ym - feval(y,tm)))) < 2e-2; |
---|
11 | |
---|
12 | % Test ode45 Using default tolerances (RelTol = 1e-3) |
---|
13 | %y = ode45(@vdp1,domain(0,20),[2;0]); % chebfun solution |
---|
14 | %[tm,ym] = ode45(@vdp1,[0,20],[2;0]); % Matlab's solution |
---|
15 | %pass2 = max(max(abs(ym - feval(y,tm)))) < 1e-2; |
---|
16 | pass2 = 1; % commented out to save time -- but |
---|
17 | % ode45 is still tested in ivp_ty_test.m |
---|
18 | |
---|
19 | |
---|
20 | % Test with different tolerance |
---|
21 | opts = odeset('RelTol', 1e-6); |
---|
22 | |
---|
23 | % Test ode113 |
---|
24 | %y = ode113(@vdp1,domain(0,20),[2;0],opts); % chebfun solution |
---|
25 | %[tm,ym] = ode113(@vdp1,[0,20],[2;0],opts); % Matlab's solution |
---|
26 | % |
---|
27 | %pass3 = max(max(abs(ym - feval(y,tm)))) < 1e-5; |
---|
28 | pass3 = 1; % above commented out to save time |
---|
29 | |
---|
30 | % Test ode45 |
---|
31 | %y = ode45(@vdp1,domain(0,20),[2;0],opts); % chebfun solution |
---|
32 | %[tm,ym] = ode45(@vdp1,[0,20],[2;0],opts); % Matlab's solution |
---|
33 | %pass4 = max(max(abs(ym - feval(y,tm)))) < 1e-5; |
---|
34 | pass4 = 1; % above commented out to save time |
---|
35 | |
---|
36 | % Test ode45 |
---|
37 | %y = ode15s(@vdp1,domain(0,20),[2;0],opts); % chebfun solution |
---|
38 | %[tm,ym] = ode15s(@vdp1,[0,20],[2;0],opts); % Matlab's solution |
---|
39 | %pass5 = max(max(abs(ym - feval(y,tm)))) < 1e-5; |
---|
40 | pass5 = 1; % above commented out to save time |
---|
41 | |
---|
42 | pass = pass1 && pass2 && pass3 && pass4 && pass5; |
---|
43 | |
---|
44 | |
---|