CppNoddy  0.92
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CppNoddy::ArcLength_base< _Type > Class Template Referenceabstract

#include <ArcLength_base.h>

Inheritance diagram for CppNoddy::ArcLength_base< _Type >:
CppNoddy::Uncopyable CppNoddy::ODE_BVP< D_complex > CppNoddy::Newton< _Type > CppNoddy::ODE_BVP< _Type, _Xtype >

Public Member Functions

 ArcLength_base ()
 
virtual ~ArcLength_base ()
 
void init_arc (DenseVector< _Type > x, _Type *p, const double &length, const double &max_length)
 Initialise the class ready for arc-length continuation. More...
 
virtual void solve (DenseVector< _Type > &x)=0
 Compute a solution for that state & parameter variables that are an arc-length 'ds' from the current state. More...
 
double & ds ()
 Return a handle to the arclength step. More...
 
double & arcstep_multiplier ()
 Used to set the multiplication constant used when increasing or decreasing the arclength step. More...
 
bool & rescale_theta ()
 Handle to the RESCALE_THETA flag. More...
 
double & theta ()
 Set the arclength theta parameter. More...
 
double & desired_arc_proportion ()
 Handle to the desired proportion of the parameter to be used in the arc length solver. More...
 

Protected Member Functions

void update (const DenseVector< _Type > &x)
 A method called by arclength_solve and init_arc which stores the current converged state and parameter and hence computes the derivatives w.r.t the arc-length. More...
 
double arclength_residual (const DenseVector< _Type > &x) const
 The extra constraint that is to be used to replace the unknown arc length. More...
 
DenseVector< _Type > Jac_arclength_residual (DenseVector< _Type > &x) const
 The derivative of the arclength_residual function with respect to each of the state variables. More...
 
void update_theta (const DenseVector< _Type > &x)
 Automatically update the Keller THETA such that the proportion of the arclength obtained from the parameter is the desired value. More...
 

Protected Attributes

_Type * p_PARAM
 pointer to the parameter in arclength solves More...
 
DenseVector< _Type > LAST_X
 state variable at the last computed solution More...
 
DenseVector< _Type > X_DERIV_S
 derivative of the state variable w.r.t. arc length More...
 
_Type LAST_PARAM
 parameter value at the last computed solution More...
 
_Type PARAM_DERIV_S
 derivative of the parameter w.r.t arc length More...
 
double DS
 size of the arc length step More...
 
double MAX_DS
 maximum arc length step to be taken More...
 
double ARCSTEP_MULTIPLIER
 step change multiplier More...
 
bool INITIALISED
 for the arc-length solver - to show it has been initialised More...
 
double THETA
 the arclength theta More...
 

Detailed Description

template<typename _Type>
class CppNoddy::ArcLength_base< _Type >

Definition at line 16 of file ArcLength_base.h.

Constructor & Destructor Documentation

◆ ArcLength_base()

template<typename _Type >
CppNoddy::ArcLength_base< _Type >::ArcLength_base ( )
inline

Definition at line 20 of file ArcLength_base.h.

20 :
22 INITIALISED(false),
23 THETA(0.5),
24 DESIRED_ARC_PROPORTION(0.5),
25 RESCALE_THETA(false)
26 {}
bool INITIALISED
for the arc-length solver - to show it has been initialised
double ARCSTEP_MULTIPLIER
step change multiplier
double THETA
the arclength theta

◆ ~ArcLength_base()

template<typename _Type >
virtual CppNoddy::ArcLength_base< _Type >::~ArcLength_base ( )
inlinevirtual

Definition at line 28 of file ArcLength_base.h.

29 {}

Member Function Documentation

◆ arclength_residual()

template<typename _Type >
double CppNoddy::ArcLength_base< _Type >::arclength_residual ( const DenseVector< _Type > &  x) const
protected

The extra constraint that is to be used to replace the unknown arc length.

Returns
The residual of this constraint

Definition at line 81 of file ArcLength_base.cpp.

81 {
82 return THETA * (x - LAST_X).two_norm() / x.size()
83 + (1.0 - THETA) * std::pow(std::abs(*p_PARAM - LAST_PARAM), 2)
84 - DS * DS;
85 }
_Type * p_PARAM
pointer to the parameter in arclength solves
double DS
size of the arc length step
_Type LAST_PARAM
parameter value at the last computed solution
DenseVector< _Type > LAST_X
state variable at the last computed solution

References CppNoddy::DenseVector< _Type >::size().

◆ arcstep_multiplier()

template<typename _Type >
double & CppNoddy::ArcLength_base< _Type >::arcstep_multiplier

Used to set the multiplication constant used when increasing or decreasing the arclength step.

Definition at line 18 of file ArcLength_base.cpp.

18 {
19 return ARCSTEP_MULTIPLIER;
20 }

◆ desired_arc_proportion()

template<typename _Type >
double & CppNoddy::ArcLength_base< _Type >::desired_arc_proportion

Handle to the desired proportion of the parameter to be used in the arc length solver.

If this parameter is 1, then the system is effectively doing zero-order continuation in the secondary parameter.

Definition at line 33 of file ArcLength_base.cpp.

33 {
34 return DESIRED_ARC_PROPORTION;
35 }

Referenced by main().

◆ ds()

template<typename _Type >
double & CppNoddy::ArcLength_base< _Type >::ds

Return a handle to the arclength step.

This is normally done via the init_arc method, but one can use this to change the setting post-initialisation.

Definition at line 13 of file ArcLength_base.cpp.

13 {
14 return DS;
15 }

◆ init_arc()

template<typename _Type >
void CppNoddy::ArcLength_base< _Type >::init_arc ( DenseVector< _Type >  x,
_Type *  p,
const double &  length,
const double &  max_length 
)

Initialise the class ready for arc-length continuation.

This will ensure that x is a solution at the current parameter value and compute the required derivatives with respect to the parameter.

Parameters
xThe initial guess at a solution
pA pointer to the required parameter
lengthInitial arc-length step to take
max_lengthMaximum absolute arc length step permitted

Definition at line 53 of file ArcLength_base.cpp.

56 {
57 // set the pointers to the parameter & state variable
58 p_PARAM = param;
59 // compute the solution at this parameter value in usual way
60 solve(x);
61 // store the converged solution at this point
62 LAST_X = x;
64 //
65 // we now have one solution and can get ready to arc-length continue
66 //
67 DS = length;
68 // put the arc-length entirely into a parameter for step 1
69 *p_PARAM += DS;
70 // recompute the state at this parameter value
71 solve(x);
72 // update the derivatives of state & parameter variables
73 update(x);
74 INITIALISED = true;
75 MAX_DS = max_length;
76 }
virtual void solve(DenseVector< _Type > &x)=0
Compute a solution for that state & parameter variables that are an arc-length 'ds' from the current ...
void update(const DenseVector< _Type > &x)
A method called by arclength_solve and init_arc which stores the current converged state and paramete...
double MAX_DS
maximum arc length step to be taken

Referenced by main().

◆ Jac_arclength_residual()

template<typename _Type >
DenseVector< _Type > CppNoddy::ArcLength_base< _Type >::Jac_arclength_residual ( DenseVector< _Type > &  x) const
inlineprotected

The derivative of the arclength_residual function with respect to each of the state variables.

When arc-length continuing boundary value problems you would NOT want to finite-difference this since vector lengths will be of the order of 10^3.

Parameters
xThe state vector.
Returns
The derivative of the arclength_residual function with respect to each state variable.

Definition at line 94 of file ArcLength_base.h.

94 {
95 // a by-hand differentiation of 'arclength_residual' provides
96 // the follwoing result.
97 DenseVector<_Type> Jx(x - LAST_X);
98 Jx *= THETA / (x.size() * (x - LAST_X).two_norm());
99 return Jx;
100 }

References CppNoddy::ArcLength_base< _Type >::LAST_X, CppNoddy::DenseVector< _Type >::size(), and CppNoddy::ArcLength_base< _Type >::THETA.

◆ rescale_theta()

template<typename _Type >
bool & CppNoddy::ArcLength_base< _Type >::rescale_theta

Handle to the RESCALE_THETA flag.

If true the arclength theta will be rescaled to balance the relative importance of the state variables and the parameter.

Definition at line 23 of file ArcLength_base.cpp.

23 {
24 return RESCALE_THETA;
25 }

Referenced by main().

◆ solve()

template<typename _Type >
void CppNoddy::ArcLength_base< _Type >::solve ( DenseVector< _Type > &  x)
pure virtual

Compute a solution for that state & parameter variables that are an arc-length 'ds' from the current state.

virtual void arclength_solve( DenseVector<_Type> &x ) = 0; Solve the system for a given initial guess.

Parameters
xThe initial guess for the system.

Implemented in CppNoddy::Newton< _Type >.

Definition at line 38 of file ArcLength_base.cpp.

39 {}

◆ theta()

template<typename _Type >
double & CppNoddy::ArcLength_base< _Type >::theta

Set the arclength theta parameter.

Definition at line 28 of file ArcLength_base.cpp.

28 {
29 return THETA;
30 }

Referenced by main().

◆ update()

template<typename _Type >
void CppNoddy::ArcLength_base< _Type >::update ( const DenseVector< _Type > &  x)
protected

A method called by arclength_solve and init_arc which stores the current converged state and parameter and hence computes the derivatives w.r.t the arc-length.

Definition at line 42 of file ArcLength_base.cpp.

42 {
43 if(RESCALE_THETA) {
44 update_theta(x);
45 }
46 X_DERIV_S = (x - LAST_X) / DS;
48 LAST_X = x;
50 }
void update_theta(const DenseVector< _Type > &x)
Automatically update the Keller THETA such that the proportion of the arclength obtained from the par...
_Type PARAM_DERIV_S
derivative of the parameter w.r.t arc length
DenseVector< _Type > X_DERIV_S
derivative of the state variable w.r.t. arc length

◆ update_theta()

template<typename _Type >
void CppNoddy::ArcLength_base< _Type >::update_theta ( const DenseVector< _Type > &  x)
protected

Automatically update the Keller THETA such that the proportion of the arclength obtained from the parameter is the desired value.

This method will only have any effect of the RESCALE_THETA flag is true.

Definition at line 88 of file ArcLength_base.cpp.

88 {
89 if(RESCALE_THETA) {
90 double Delta_p2 = std::pow(std::abs(*p_PARAM - LAST_PARAM), 2);
91 double Delta_x2 = (x - LAST_X).two_norm() / x.size();
92 THETA = Delta_p2 * (DESIRED_ARC_PROPORTION - 1.0)
93 / (Delta_p2 * (DESIRED_ARC_PROPORTION - 1.0)
94 - DESIRED_ARC_PROPORTION * Delta_x2);
95 }
96 }

References CppNoddy::DenseVector< _Type >::size().

Member Data Documentation

◆ ARCSTEP_MULTIPLIER

template<typename _Type >
double CppNoddy::ArcLength_base< _Type >::ARCSTEP_MULTIPLIER
protected

step change multiplier

Definition at line 123 of file ArcLength_base.h.

◆ DS

template<typename _Type >
double CppNoddy::ArcLength_base< _Type >::DS
protected

size of the arc length step

Definition at line 119 of file ArcLength_base.h.

◆ INITIALISED

template<typename _Type >
bool CppNoddy::ArcLength_base< _Type >::INITIALISED
protected

for the arc-length solver - to show it has been initialised

Definition at line 125 of file ArcLength_base.h.

◆ LAST_PARAM

template<typename _Type >
_Type CppNoddy::ArcLength_base< _Type >::LAST_PARAM
protected

parameter value at the last computed solution

Definition at line 115 of file ArcLength_base.h.

◆ LAST_X

template<typename _Type >
DenseVector<_Type> CppNoddy::ArcLength_base< _Type >::LAST_X
protected

state variable at the last computed solution

Definition at line 111 of file ArcLength_base.h.

Referenced by CppNoddy::ArcLength_base< _Type >::Jac_arclength_residual().

◆ MAX_DS

template<typename _Type >
double CppNoddy::ArcLength_base< _Type >::MAX_DS
protected

maximum arc length step to be taken

Definition at line 121 of file ArcLength_base.h.

◆ p_PARAM

template<typename _Type >
_Type* CppNoddy::ArcLength_base< _Type >::p_PARAM
protected

pointer to the parameter in arclength solves

Definition at line 109 of file ArcLength_base.h.

◆ PARAM_DERIV_S

template<typename _Type >
_Type CppNoddy::ArcLength_base< _Type >::PARAM_DERIV_S
protected

derivative of the parameter w.r.t arc length

Definition at line 117 of file ArcLength_base.h.

◆ THETA

template<typename _Type >
double CppNoddy::ArcLength_base< _Type >::THETA
protected

the arclength theta

Definition at line 127 of file ArcLength_base.h.

Referenced by CppNoddy::ArcLength_base< _Type >::Jac_arclength_residual().

◆ X_DERIV_S

template<typename _Type >
DenseVector<_Type> CppNoddy::ArcLength_base< _Type >::X_DERIV_S
protected

derivative of the state variable w.r.t. arc length

Definition at line 113 of file ArcLength_base.h.


The documentation for this class was generated from the following files:

© 2012

R.E. Hewitt