Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(RootFinderDataType), | intent(inout) | :: | RootFinderData |
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
REAL(r64) FUNCTION SecantMethod( RootFinderData )
! FUNCTION INFORMATION:
! AUTHOR Dimitri Curtil (LBNL)
! DATE WRITTEN February 2006
! MODIFIED
! RE-ENGINEERED na
! PURPOSE OF THIS FUNCTION:
! This function computes the next iterate using the secant method.
! If new iterate does not lie within the lower and upper points then
! the false position method is used instead.
!
! Convergence rate is at best superlinear.
!
! PRECONDITION:
! There must be at least 2 history points so that RootFinderData%Increment is defined.
! See FUNCTION SecantFormula.
!
! POSTCONDITION:
! - LowerPoint%X < XCandidate < UpperPoint%X
! - RootFinderData%CurrentMethodType update with current solution method.
!
! METHODOLOGY EMPLOYED:
! na
! REFERENCES:
! na
! USE STATEMENTS:
! na
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! FUNCTION ARGUMENT DEFINITIONS:
TYPE(RootFinderDataType), INTENT(INOUT) :: RootFinderData ! Data used by root finding algorithm
! FUNCTION PARAMETER DEFINITIONS:
! na
! INTERFACE BLOCK SPECIFICATIONS
! na
! DERIVED TYPE DEFINITIONS
! na
! FUNCTION LOCAL VARIABLE DECLARATIONS:
REAL(r64) :: XCandidate
! FLOW:
! Recover with false position
IF ( SecantFormula(RootFinderData, XCandidate) ) THEN
! Secant method
RootFinderData%CurrentMethodType = iMethodSecant
! Check that new candidate is within range and brackets
IF ( .NOT.CheckRootFinderCandidate(RootFinderData, XCandidate) ) THEN
! Recovery method
XCandidate = FalsePositionMethod(RootFinderData)
END IF
ELSE
! Recovery method
XCandidate = FalsePositionMethod(RootFinderData)
END IF
SecantMethod = XCandidate
RETURN
END FUNCTION SecantMethod