CppNoddy  0.92
Loading...
Searching...
No Matches
Classes | Namespaces | Functions
EVPShootBiharmonic.cpp File Reference

Solving a one-dimensional "Bi-harmonic" eigenvalue problem (EVP) More...

#include <IVP_bundle.h>

Go to the source code of this file.

Classes

class  CppNoddy::Example::Biharmonic_equation
 Define the biharmonic eigenvalue equation by inheriting Equation base class. More...
 
class  CppNoddy::Example::Biharmonic_residual
 Define a residual function using the boundary conditions for the biharmonic_equation. More...
 

Namespaces

namespace  CppNoddy
 A collection of OO numerical routines aimed at simple (typical) applied problems in continuum mechanics.
 
namespace  CppNoddy::Example
 

Functions

int main ()
 

Detailed Description

Solving a one-dimensional "Bi-harmonic" eigenvalue problem (EVP)

\[ \left ( \frac{\mbox{d}^2}{\mbox{d}x^2} - \lambda \right )^2 f(x) = 0\,, \quad \mbox{where} \quad f(0)=f(1)=f'(0)=f'(1)=0\,,\]

via Runge-Kutta and (vector) Newton iteration. The problem is nonlinear since $\lambda$ is unknown.

Locally solving for eigenvalues using IVP methods is generally speaking not a great way of doing things; this is just a Example rather than any recommendation! See the other EVP examples for better methods.

Definition in file EVPShootBiharmonic.cpp.

Function Documentation

◆ main()

int main ( )

Definition at line 88 of file EVPShootBiharmonic.cpp.

89{
90
91 cout << "\n";
92 cout << "=== EVP: Biharmonic equation via shooting ==========\n";
93 cout << "\n";
94
95 Example::Biharmonic_residual problem;
96 // instantiate a complex Vector Newton class for the Biharmonic
97 Newton<D_complex> Biharm( &problem );
98
99 const D_complex A( -3.0, 7.0 ); // A guess of f'''(0)
100 const D_complex B( 2.21, 1.25 ); // A guess of the eigenvalue
101 // rig up an initial guess
102 DenseVector<D_complex> unknowns( 2, 0.0 ); // Two complex quantities to to find
103 unknowns[ 0 ] = A;
104 unknowns[ 1 ] = B * B;
105
106 try
107 {
108 Biharm.iterate( unknowns );
109 }
110 catch (const std::runtime_error &error )
111 {
112 cout << " \033[1;31;48m * FAILED THROUGH EXCEPTION BEING RAISED \033[0m\n";
113 return 1;
114 }
115
116 D_complex eigenvalue( std::sqrt( unknowns[ 1 ] ) );
117
118 std::string dirname("./DATA");
119 mkdir( dirname.c_str(), S_IRWXU );
120 // output for the data
121 TrackerFile my_file( "./DATA/Biharmonic.dat" );
122 my_file.push_ptr( &eigenvalue, "eigenvalue" );
123 my_file.push_ptr( &problem.ode -> get_mesh(), "biharmonic" );
124 my_file.header();
125 my_file.update();
126
127 const double tol = 1.e-8; // A pass/fail tolerance
128 if ( abs( sin( eigenvalue ) + eigenvalue ) < tol )
129 {
130 cout << "\033[1;32;48m * PASSED \033[0m\n";
131 return 0;
132 }
133
134 cout << "\033[1;31;48m * FAILED \033[0m\n";
135 cout << " Diff = " << abs( sin( eigenvalue ) + eigenvalue ) << "\n";
136 return 1;
137
138}
An DenseVector class – a dense vector object.
Definition: DenseVector.h:34
A vector NEWTON iteration class.
Definition: Newton.h:25
double A(1.0)
initial hump amplitude
std::complex< double > D_complex
A complex double precision number using std::complex.
Definition: Types.h:98

References CppNoddy::TrackerFile::header(), CppNoddy::Newton< _Type >::iterate(), CppNoddy::Example::Biharmonic_residual::ode, CppNoddy::TrackerFile::push_ptr(), and CppNoddy::TrackerFile::update().

© 2012

R.E. Hewitt