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 FalsePositionMethod( 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 false position method (aka regula falsi).
! If new iterate does not lie within the lower and upper points then
! the Bisection method is used instead.
!
! Convergence rate is at best superlinear.
!
! PRECONDITION:
! Lower and upper points must be defined and distinct.
!
! 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
REAL(r64) :: Num, Den
! FLOW:
Num = RootFinderData%UpperPoint%X - RootFinderData%LowerPoint%X
Den = RootFinderData%UpperPoint%Y - RootFinderData%LowerPoint%Y
IF ( Den /= 0.0d0 ) THEN
! False position method
RootFinderData%CurrentMethodType = iMethodFalsePosition
XCandidate = RootFinderData%LowerPoint%X - RootFinderData%LowerPoint%Y * Num/Den
! Check that new candidate is within range and brackets
IF ( .NOT.CheckRootFinderCandidate(RootFinderData, XCandidate) ) THEN
! Recovery method
XCandidate = BisectionMethod(RootFinderData)
END IF
ELSE
! Recovery method
XCandidate = BisectionMethod(RootFinderData)
END IF
FalsePositionMethod = XCandidate
RETURN
END FUNCTION FalsePositionMethod