The Conley-Morse Graphs Software
m_duffing_a.h
Go to the documentation of this file.
1/////////////////////////////////////////////////////////////////////////////
2///
3/// @file m_duffing_a.h
4///
5/// An approximate time-t map for the Duffing equations.
6/// This map defines a sample time-t map for an ODE.
7///
8/// @author Pawel Pilarczyk
9///
10/////////////////////////////////////////////////////////////////////////////
11
12// Copyright (C) 1997-2014 by Pawel Pilarczyk.
13//
14// This file is part of my research software package. This is free software:
15// you can redistribute it and/or modify it under the terms of the GNU
16// General Public License as published by the Free Software Foundation,
17// either version 3 of the License, or (at your option) any later version.
18//
19// This software is distributed in the hope that it will be useful,
20// but WITHOUT ANY WARRANTY; without even the implied warranty of
21// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22// GNU General Public License for more details.
23//
24// You should have received a copy of the GNU General Public License
25// along with this software; see the file "license.txt". If not,
26// please, see <https://www.gnu.org/licenses/>.
27
28// Started on December 28, 2010. Last revision: December 28, 2010.
29
30
31#ifndef _CMGRAPHS_DUFAPPROX_H_
32#define _CMGRAPHS_DUFAPPROX_H_
33
34
35// include some standard C++ header files
36#include <cmath>
37
38// include local header files
39#include "maptype.h"
40#include "odeapprox.h"
41
42
43// --------------------------------------------------
44// ------------ the Vanderpol time-t map ------------
45// --------------------------------------------------
46
47/// An approximate time-t map for the Vanderpol equations.
49{
50public:
51 /// The constructor of a Vanderpol map object.
53
54private:
55 /// The vector field.
56 void vectorField (double, const double *x, double *y, int dim) const;
57
58}; /* class MapDuffingApprox */
59
60// --------------------------------------------------
61
63 MapOdeApprox (2.0 * M_PI / 256.0, 256, 2)
64{
65 return;
66} /* MapDuffingApprox::MapDuffingApprox */
67
68inline void MapDuffingApprox::vectorField (double t,
69 const double *x, double *y, int dim) const
70{
71 if (dim != 2)
72 throw "This model is valid in dimension 2 only.";
73
74 // is this equation with reversed time?
75 const bool reversed = false;
76
77 // retrieve the parameters (the left bound only)
78 double a = getLeftParam (0);
79 double b = getLeftParam (1);
80
81 // compute the vector field
82 y [0] = x [1];
83 y [1] = x [0] - a * x [1] - x [0] * x [0] * x [0] +
84 b * std::cos (t);
85
86 // reverse the vector field if requested to
87 if (reversed)
88 {
89 for (int i = 0; i < dim; ++ i)
90 y [i] = -y [i];
91 }
92
93 return;
94} /* MapDuffingApprox::vectorField */
95
96
97
98#endif // _CMGRAPHS_DUFAPPROX_H_
99
An approximate time-t map for the Vanderpol equations.
Definition: m_duffing_a.h:49
MapDuffingApprox()
The constructor of a Vanderpol map object.
Definition: m_duffing_a.h:62
void vectorField(double, const double *x, double *y, int dim) const
The vector field.
Definition: m_duffing_a.h:68
This class defines a map for the nonlinear density dependent overcompensatory Leslie population model...
Definition: odeapprox.h:61
const double & getLeftParam(int n) const
Returns the left value of the given parameter.
Definition: maptype.h:196
An abstract map type.
A generic method for computing a time-t map for ODEs in an approximate way.