80{
81 cout << "\n";
82 cout << "=== BVP: finite-difference solution of Berman eqn ===\n";
83 cout << "\n";
84
85 Example::Berman_equation problem;
86 Example::Berman_left_BC BC_left;
87 Example::Berman_right_BC BC_right;
88
89
90 problem.Re = 1.0;
91
92 double delta_Re = 0.1;
93
94 double left = -1.0;
95 double right = 1.0;
96
97 int N = 1401;
98
100
101 const double tol = 1.e-4;
102
103
105
106
107 for ( int i = 0; i < N; ++i )
108 {
109 double y = ode.solution().coord( i );
110
111 ode.solution()( i,
f ) = 1.5 * ( y - y * y * y / 3 );
112
113 ode.solution()( i,
fd ) = 1.5 * ( 1 - y * y );
114
115 ode.solution()( i,
fdd ) = -3 * y;
116
117 ode.solution()( i,
fddd ) = -3;
118 }
119
120
121 do
122 {
123
124 try
125 {
126 try
127 {
128 ode.solve2();
129 }
130 catch ( const std::runtime_error& error )
131 {
132 cout << " \033[1;31;48m * FAILED THROUGH EXCEPTION BEING RAISED \033[0m\n";
133 return 1;
134 }
135 }
137 {
138 cout << " Bifurcation detected between Re = " << problem.Re - delta_Re
139 << " and Re = " << problem.Re << "\n";
140 cout << " Continuing further.\n";
141 }
142 problem.Re += delta_Re;
143
144 }
145 while ( problem.Re < 10.0 + tol );
146
147
148
149
150 if ( std::abs( 5.99898 - ode.solution()( 0,
fdd ) ) > tol )
151 {
152 cout << "\033[1;31;48m * FAILED \033[0m\n";
153 cout << std::abs( 5.99898 - ode.solution()( 0,
fdd ) ) <<
"\n";
154 return 1;
155 }
156 else
157 {
158 cout << "\033[1;32;48m * PASSED \033[0m\n";
159 return 0;
160 }
161}
An DenseVector class – a dense vector object.
A templated object for real/complex vector system of first-order ordinary differential equations.
DenseVector< double > uniform_node_vector(const double &lower, const double &upper, const std::size_t &N)
Return a DENSE vector with the nodal points of a uniform mesh distributed between the upper/lower bou...