17 class Harmonic_equation :
public Equation<double>
47 cout <<
"=== IVP: solving harmonic equation ==================\n";
48 cout <<
" Solving between x = 0 to x = 10 \n";
50 cout <<
" Running shoot45 method - auto step choice \n";
67 problem.
coord(0) = 0.0;
68 ode.
shoot45( u_init, tol, 0.01 );
72 u_final = ode.
shoot45( u_init, tol, 0.01 );
74 catch (
const std::runtime_error &error )
76 cout <<
" \033[1;31;48m * FAILED THROUGH EXCEPTION BEING RAISED \033[0m\n";
82 for (
int j = 1; j < 7; j++ )
85 tol = 1. / ( pow( 10., j ) );
87 u_final = ode.
shoot45( u_init, tol, 0.01 );
90 cout <<
" Error relative tol : " << tol <<
"\n";
91 cout <<
" Error |num - exact|: "
92 << abs( u_final[ 0 ] - cos( sqrt( problem.
lambda ) * 10. ) ) <<
"\n";
94 if ( abs( u_final[ 0 ] - cos( sqrt( problem.
lambda ) * 10. ) ) > 10. * tol )
102 cout <<
"\033[1;31;48m * FAILED \033[0m\n";
107 cout <<
"\033[1;32;48m * PASSED \033[0m\n";
A shorter bundled include file for initial-value problems.
An DenseVector class – a dense vector object.
An equation object base class used in the BVP/IVP classes.
Define the harmonic equation by inheriting the Equation base class.
void residual_fn(const DenseVector< double > &z, DenseVector< double > &f) const
We implement the equation as 2 first-order ODEs.
double lambda
A parameter.
Harmonic_equation()
The harmonic equation is 2nd order.
A templated object for real/complex vector system of first-order ordinary differential equations.
DenseVector< _Type > shoot45(DenseVector< _Type > u, const double &tol, const double &h_init)
A Runge-Kutta-Fehlberg integrator.
_Xtype & coord(const unsigned &i)
General handle access to the coordinates.
A simple CPU-clock-tick timer for timing metods.
int & counter()
Increment an internal discrete counter.
A collection of OO numerical routines aimed at simple (typical) applied problems in continuum mechani...