|
| 1 | +classdef SanzSernaProblem < otp.Problem |
| 2 | + % This test problem comes from |
| 3 | + % Sanz-Serna, J. M., Verwer, J. G., & Hundsdorfer, W. H. (1986). Convergence and order reduction of Runge-Kutta schemes |
| 4 | + % applied to evolutionary problems in partial differential equations. Numerische Mathematik, 50(4), 405–418. |
| 5 | + % https://doi.org/10.1007/BF01396661 |
| 6 | + |
| 7 | + properties (SetAccess = private) |
| 8 | + RhsLinear |
| 9 | + RhsForcing |
| 10 | + end |
| 11 | + |
| 12 | + methods |
| 13 | + function obj = SanzSernaProblem(timeSpan, y0, parameters) |
| 14 | + obj@otp.Problem('Sanz-Serna', [], timeSpan, y0, parameters); |
| 15 | + end |
| 16 | + end |
| 17 | + |
| 18 | + methods (Access=protected) |
| 19 | + |
| 20 | + function onSettingsChanged(obj) |
| 21 | + |
| 22 | + D = spdiags(ones(obj.NumVars, 1) * [obj.NumVars, -obj.NumVars], [-1, 0], obj.NumVars, obj.NumVars); |
| 23 | + |
| 24 | + x = linspace(1/obj.NumVars, 1, obj.NumVars).'; |
| 25 | + |
| 26 | + obj.Rhs = otp.Rhs(@(t, y) otp.sanzserna.f(t, y, D, x), ... |
| 27 | + otp.Rhs.FieldNames.Jacobian, otp.sanzserna.jac(D, x), ... |
| 28 | + otp.Rhs.FieldNames.JacobianVectorProduct, @(t, y, v) otp.sanzserna.jvp(t, y, v, D, x), ... |
| 29 | + otp.Rhs.FieldNames.PartialDerivativeTime, @(t, y) otp.sanzserna.pdt(t, y, D, x)); |
| 30 | + |
| 31 | + obj.RhsLinear = otp.Rhs(@(t, y) otp.sanzserna.flinear(t, y, D, x), ... |
| 32 | + otp.Rhs.FieldNames.Jacobian, otp.sanzserna.jaclinear(D, x)); |
| 33 | + obj.RhsForcing = otp.Rhs(@(t, y) otp.sanzserna.fforcing(t, y, D, x), ... |
| 34 | + otp.Rhs.FieldNames.Jacobian, otp.sanzserna.jacforcing(D, x)); |
| 35 | + end |
| 36 | + |
| 37 | + function sol = internalSolve(obj, varargin) |
| 38 | + sol = internalSolve@otp.Problem(obj, 'Method', @ode45, varargin{:}); |
| 39 | + end |
| 40 | + |
| 41 | + %true solution |
| 42 | + end |
| 43 | +end |
0 commit comments