|
1 | 1 | classdef OregonatorProblem < otp.Problem |
| 2 | + % A periodic, three-variable model for the Belousov–Zhabotinsky reaction. |
| 3 | + % |
| 4 | + % The Oregonator chemical reaction :cite:p:`FN74` is given by |
| 5 | + % |
| 6 | + % |
| 7 | + % $$ |
| 8 | + % \ce{ |
| 9 | + % A + Y &-> X + P \\ |
| 10 | + % X + Y &-> 2P \\ |
| 11 | + % A + X &-> 2X + 2Z \\ |
| 12 | + % 2X &-> A + P \\ |
| 13 | + % B + Z &-> 1/2 $f$ Y. |
| 14 | + % } |
| 15 | + % $$ |
| 16 | + % |
| 17 | + % Species $\ce{A = BrO3-}$, $\ce{B = CH2(COOH)2}$, and $\ce{P = HOBr}$ or $\ce{BrCH(COOH)2}$ are assumed to be |
| 18 | + % constant. The dynamic concentrations of intermediate species $\ce{X = HBrO2}$, $\ce{Y = Br-}$, and |
| 19 | + % $\ce{Z = Ce(IV)}$ can be modeled by an ODE in three variables. Field and Noyes :cite:p:`FN74` proposed the |
| 20 | + % nondimensionalized form |
| 21 | + % |
| 22 | + % $$ |
| 23 | + % α' &= s(η - η α + α - q α^2), \\ |
| 24 | + % η' &= s^{-1}(-η - η α + f ρ), \\ |
| 25 | + % ρ' &= w (α - ρ), |
| 26 | + % $$ |
| 27 | + % |
| 28 | + % where $α$, $η$, and $ρ$ are scaled concentrations of $\ce{X}$, $\ce{Y}$, and $\ce{Z}$, respectively. |
| 29 | + % |
| 30 | + % Notes |
| 31 | + % ----- |
| 32 | + % +---------------------+------------------------------------------------+ |
| 33 | + % | Type | ODE | |
| 34 | + % +---------------------+------------------------------------------------+ |
| 35 | + % | Number of Variables | 3 | |
| 36 | + % +---------------------+------------------------------------------------+ |
| 37 | + % | Stiff | typically, depending on $f$, $q$, $s$, and $w$ | |
| 38 | + % +---------------------+------------------------------------------------+ |
| 39 | + % |
| 40 | + % Example |
| 41 | + % ------- |
| 42 | + % >>> problem = otp.oregonator.presets.Canonical; |
| 43 | + % >>> sol = problem.solve(); |
| 44 | + % >>> problem.plotPhaseSpace(sol, 'Vars', [2, 3]); |
| 45 | + |
2 | 46 | methods |
3 | 47 | function obj = OregonatorProblem(timeSpan, y0, parameters) |
| 48 | + % Create a Oregonator problem object. |
| 49 | + % |
| 50 | + % Parameters |
| 51 | + % ---------- |
| 52 | + % timeSpan : numeric(1, 2) |
| 53 | + % The start and final time. |
| 54 | + % y0 : numeric(3, 1) |
| 55 | + % The initial conditions. |
| 56 | + % parameters : OregonatorParameters |
| 57 | + % The parameters. |
| 58 | + % |
| 59 | + % Returns |
| 60 | + % ------- |
| 61 | + % obj : OregonatorProblem |
| 62 | + % The constructed problem. |
4 | 63 | obj@otp.Problem('Oregonator', 3, timeSpan, y0, parameters); |
5 | 64 | end |
6 | 65 | end |
7 | 66 |
|
8 | 67 | methods (Access = protected) |
9 | 68 | function onSettingsChanged(obj) |
10 | | - obj.RHS = otp.RHS(@otp.oregonator.f, ... |
11 | | - 'Jacobian', @otp.oregonator.jacobian, ... |
| 69 | + f = obj.Parameters.F; |
| 70 | + q = obj.Parameters.Q; |
| 71 | + s = obj.Parameters.S; |
| 72 | + w = obj.Parameters.W; |
| 73 | + |
| 74 | + obj.RHS = otp.RHS(@(t, y) otp.oregonator.f(t, y, f, q, s, w), ... |
| 75 | + 'Jacobian', @(t, y) otp.oregonator.jacobian(t, y, f, q, s, w), ... |
12 | 76 | 'Vectorized', 'on'); |
13 | 77 | end |
14 | 78 |
|
15 | 79 | function fig = internalPlot(obj, t, y, varargin) |
16 | | - fig = internalPlot@otp.Problem(obj, t, y, ... |
17 | | - 'yscale', 'log', varargin{:}); |
| 80 | + fig = internalPlot@otp.Problem(obj, t, y, 'yscale', 'log', varargin{:}); |
| 81 | + end |
| 82 | + |
| 83 | + function fig = internalPlotPhaseSpace(obj, t, y, varargin) |
| 84 | + fig = internalPlotPhaseSpace@otp.Problem(obj, t, y, 'xscale', 'log', 'yscale', 'log', 'zscale', 'log', ... |
| 85 | + varargin{:}); |
18 | 86 | end |
19 | 87 |
|
20 | 88 | function mov = internalMovie(obj, t, y, varargin) |
21 | | - mov = internalMovie@otp.Problem(obj, t, y, ... |
22 | | - 'yscale', 'log', varargin{:}); |
| 89 | + mov = internalMovie@otp.Problem(obj, t, y, 'yscale', 'log', varargin{:}); |
23 | 90 | end |
24 | 91 | end |
25 | 92 | end |
|
0 commit comments