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

Solve the nonlinear scalar residual problem. More...

#include <cassert>
#include <Newton_bundle.h>

Go to the source code of this file.

Classes

class  CppNoddy::Example::Arc_problem
 Define the residual for arc-length continuation of a circle. 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

Solve the nonlinear scalar residual problem.

\[ R \equiv (x - 3)( (x-2)^2 + (p-4) ) = 0 \]

by arc-length continuation from the starting solution $ x=0, p=0 $. There is a limit point $ x=2, p =4 $ and a transcritical bifurcation $ x =3, p=3 $ on the computed branch of solutions, both of which should be flagged through an exception being raised. The Example will fail if two bifurcations are not found.

Definition in file ArcTranscritFold.cpp.

Function Documentation

◆ main()

int main ( )

Definition at line 43 of file ArcTranscritFold.cpp.

44{
45
46 cout << "\n";
47 cout << "=== ARC: Scalar continuation and bifn detection =====\n";
48 cout << "\n";
49
50 // Instantiate the problem
51 Example::Arc_problem residual_problem;
52 residual_problem.p = 0.0;
53 residual_problem.eps = 0.0;
54
55 const double tol = 1.e-10;
56 // Scalar Newton iteration problem
57 Newton<double> newton( &residual_problem, 8, tol );
58 newton.set_monitor_det( true );
59 // initial guess
60 DenseVector<double> state( 1, 0.1 );
61 // initialise a state for arc length cont.
62 newton.init_arc( state, &residual_problem.p, 0.01, 0.5 );
63
64 // output for the data
65 std::string dirname("./DATA");
66 mkdir( dirname.c_str(), S_IRWXU );
67 TrackerFile my_file( "./DATA/Trans_Fold.dat" );
68 my_file.push_ptr( &residual_problem.p, "parameter" );
69 my_file.push_ptr( &state, "system state" );
70 my_file.header();
71 my_file.precision( 8 );
72
73 unsigned n_bif( 0 );
74 for ( int i = 0; i < 100; ++i )
75 {
76 try
77 {
78 try
79 {
80 newton.arclength_solve( state );
81 }
82 catch (const std::runtime_error &error )
83 {
84 cout << " \033[1;31;48m * FAILED THROUGH EXCEPTION BEING RAISED \033[0m\n";
85 return 1;
86 }
87 }
88 catch (const ExceptionBifurcation &bifn )
89 {
90 cout << " Bifurcation detected near x = " << state[0] <<
91 " p = " << residual_problem.p << "\n\n";
92 ++n_bif;
93 }
94 my_file.update();
95 }
96
97 if ( n_bif != 2 )
98 {
99 cout << "\033[1;31;48m * FAILED \033[0m\n";
100 return 1;
101 }
102 else
103 {
104 cout << "\033[1;32;48m * PASSED \033[0m\n";
105 return 0;
106 }
107}
An DenseVector class – a dense vector object.
Definition: DenseVector.h:34
A vector NEWTON iteration class.
Definition: Newton.h:25

References CppNoddy::Newton< _Type >::arclength_solve(), CppNoddy::Example::Arc_problem::eps, CppNoddy::TrackerFile::header(), CppNoddy::ArcLength_base< _Type >::init_arc(), CppNoddy::Example::Arc_problem::p, CppNoddy::TrackerFile::precision(), CppNoddy::TrackerFile::push_ptr(), CppNoddy::Newton< _Type >::set_monitor_det(), and CppNoddy::TrackerFile::update().

© 2012

R.E. Hewitt