ComputationalScienceLaboratory / ODE-Test-Problems

A MATLAB suite of initial value problems
https://computationalsciencelaboratory.github.io/ODE-Test-Problems/
MIT License
9 stars 3 forks source link

Ode15s as default solver doesn't adhere to error tolerances #20

Closed elswit closed 3 years ago

elswit commented 3 years ago

A simple test on Dahlquist:.

model = otp.linear.presets.Dahlquist(-1);
sol = model.solve('Reltol',1e-10, 'Abstol', 1e-10, 'Method', @ode15s);
sol.y(end)-exp(-1)

4.162909795304426e-04

if we switch to ode45

sol = model.solve('Reltol',1e-10, 'Abstol', 1e-10, 'Method', @ode45); sol.y(end)-exp(-1)


1.209031486038015e-09

Steven-Roberts commented 3 years ago

The issue is that the name value pairs are case sensitive. You need to switch to RelTol and AbsTol. I'll see if we can ignore case and give warnings for unused parameters. Most of this is deferred to odeset though.

Steven-Roberts commented 3 years ago

The issue boils down to how odeset handles struct arguments vs name value pairs. A simple fix would involve using the function namedargs2cell, but this requires MATLAB 2019b. I guess that's not too new of a version.

elswit commented 3 years ago

Ok. It was strange that one integrator worked fine with the lowercase string and the other didn't. I don't think relying on 2019> version is unreasonable.

Steven-Roberts commented 3 years ago

None of the integrators were passed the tolerances since the capitalization was wrong. ode45 just happen to have a very small global error using default tolerances.

AndreyAPopov commented 3 years ago

Yeah, silently ignoring options is wrong. We need to warnings everywhere when an option is ignored.