hompack_nf Module

Specific routines for the fixpnf solver.


Uses

  • module~~hompack_nf~~UsesGraph module~hompack_nf hompack_nf iso_c_binding iso_c_binding module~hompack_nf->iso_c_binding iso_fortran_env iso_fortran_env module~hompack_nf->iso_fortran_env module~hompack_core hompack_core module~hompack_nf->module~hompack_core module~hompack_kinds hompack_kinds module~hompack_nf->module~hompack_kinds module~hompack_core->iso_c_binding module~hompack_core->module~hompack_kinds module~hompack_kinds->iso_fortran_env

Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: fixpnf_success = hompack_success
integer, public, parameter :: fixpnf_tol_increased = 2
integer, public, parameter :: fixpnf_iter_limit = 3
integer, public, parameter :: fixpnf_rank_loss = 4
integer, public, parameter :: fixpnf_lost_curve = 5
integer, public, parameter :: fixpnf_newton_failed = 6
integer, public, parameter :: fixpnf_input_error = 7
integer, public, parameter :: fixpnf_memory_error = 8

Derived Types

type, public ::  nf_workspace

Linear-algebra workspace for fixpnf.

Components

Type Visibility Attributes Name Initial
real(kind=dp), public, allocatable :: alpha(:)

Array used during interpolation and Newton-step calculations.

real(kind=dp), public, allocatable :: qr(:,:)

Matrix for QR factorizations used in Newton-step calculations.

real(kind=dp), public, allocatable :: tz(:)

Array used in QR-factorization and Newton-step computations.

real(kind=dp), public, allocatable :: w(:)

Array used during interpolation and Newton-step calculations.

real(kind=dp), public, allocatable :: wp(:)

Array used during interpolation and Newton-step calculations.

real(kind=dp), public, allocatable :: z0(:)

Array used for estimating the optimal next step size.

real(kind=dp), public, allocatable :: z1(:)

Array used for estimating the optimal next step size.

integer, public, allocatable :: pivot(:)

Pivot indices used by the QR factorization.

Type-Bound Procedures

procedure, public :: alloc => alloc_workspace

type, public ::  nf_state

State variables for fixpnf.

Components

Type Visibility Attributes Name Initial
real(kind=dp), public :: abserr = zero

Absolute error tolerance.

real(kind=dp), public :: relerr = zero

Relative error tolerance.

real(kind=dp), public :: curtol = zero

Curvature-based error tolerance.

real(kind=dp), public :: h = zero

Optimal step size for the next step to be attempted by stepnf.

real(kind=dp), public :: hold = zero

||yp - ypold|| at the previous step.

real(kind=dp), public :: s = zero

Total arc length of the solution path followed by the algorithm.

integer, public :: iflag = -100

Problem type and status flag.

integer, public :: limit = -100

Limit on the number of steps allowed in the main loop of fixpnf.

integer, public :: n = 0

Problem dimension.

integer, public :: nfe = 0

Number of homotopy/Jacobian evaluations performed. This counter is incremented once for each call to tangnf, where the homotopy map and its Jacobian are assembled and used to compute a tangent vector and Newton correction.

logical, public :: start = .true.

Flag to indicate the first call to stepnf.

logical, public :: crash = .false.

Flag to indicate that the return state of stepnf is a crash.

real(kind=dp), public, allocatable :: a(:)

Parameter vector for curve-tracking problems, or initial point for the fixed-point and zero-finding problems.

real(kind=dp), public, allocatable :: y(:)

Current point on the zero curve.

real(kind=dp), public, allocatable :: yold(:)

Previous point found on the zero curve.

real(kind=dp), public, allocatable :: yp(:)

Unit tangent vector to the zero curve at y.

real(kind=dp), public, allocatable :: ypold(:)

Unit tangent vector to the zero curve at yold.

type(nf_workspace), public :: workspace

Linear-algebra workspace.

Type-Bound Procedures

procedure, public :: alloc => alloc_state

type, public ::  nf_config

Container to hold the configuration for a call to fixpnf.

Components

Type Visibility Attributes Name Initial
real(kind=dp), public :: arcre = zero

Relative error tolerance for the normal-flow iteration used while tracking the zero curve. If nonpositive, the default value arcre=0.5*sqrt(ansre) is used.

real(kind=dp), public :: arcae = zero

Absolute error tolerance for the normal-flow iteration used while tracking the zero curve. If nonpositive, the default value arcae=0.5*sqrt(ansae) is used.

real(kind=dp), public :: ansre = 1e-10_dp

Relative error tolerance required of the final solution at lambda=1.

real(kind=dp), public :: ansae = 1e-10_dp

Absolute error tolerance required of the final solution at lambda=1.

real(kind=dp), public :: cursw = 10.0_dp

Curvature switch. If the curvature of any component of y exceeds this value, the tolerances for the normal-flow iteration are switched from arcre and arcae to the finer tolerances ansre and ansae, respectively.

real(kind=dp), public, dimension(8) :: sspar = zero

Step-size control parameters: (lideal, rideal, dideal, hmin, hmax, bmin, bmax, p). Elements that are nonpositive on input are replaced by default values.

integer, public :: max_steps = 1000

Maximum number of steps allowed in the main loop.

integer, public :: lunit = 0

Logical I/O unit for intermediate output. * 0 : No output is printed (default). * 6 : Standard output (mapped internally to output_unit) * otherwise : Output to the specified I/O unit.

logical, public :: polsys = .false.

Optional flag used only by the polynomial-system driver POLSYS1H.

type, public ::  nf_solver

Container to hold the state variables and user-supplied callbacks for fixpnf.

Components

Type Visibility Attributes Name Initial
integer, public :: problem_type = -100
logical, public :: initialized = .false.
type(nf_state), public :: state
type(nf_config), public :: config
type(hompack_f_callbacks), public :: callbacks

Type-Bound Procedures

procedure, public :: initialize => nf_solver_initialize
procedure, public :: solve => nf_solver_solve
procedure, public :: restart => nf_solver_restart

type, public ::  nf_result

Container to hold the results of a call to fixpnf.

Components

Type Visibility Attributes Name Initial
real(kind=dp), public :: arc_length = zero

Arc length of the zero curve until the solution was found.

real(kind=dp), public :: lambda = zero

Final value of the homotopy parameter at the solution.

real(kind=dp), public, allocatable :: x(:)

Final value of the independent variable at the solution.

integer, public :: nfe = 0

Number of homotopy/Jacobian evaluations.

type(hompack_status), public :: status

Status.


Functions

public function nf_solver_initialize(self, problem_type, callbacks, n, dima, config) result(status)

This function initializes a nf_solver object for a specified problem type, user-supplied callbacks, and configuration parameters. It validates the inputs, allocates necessary state variables (deallocation included), and binds the callbacks to the solver object.

Arguments

Type IntentOptional Attributes Name
class(nf_solver), intent(inout) :: self

Solver object.

integer, intent(in) :: problem_type

Problem type. Must be one of the following: * fix_point : solve . * zero_find : solve . * curve_track : track a zero curve of .

type(hompack_f_callbacks), intent(in) :: callbacks

User-supplied function and Jacobian evaluation subroutines. Required callbacks depend on problem_type as follows: * For problem_type = fix_point or zero_find, callbacks f and fjac must be provided. * For problem_type = curve_track, callbacks rho and rhojac must be provided.

integer, intent(in) :: n

Problem dimension, i.e., the dimension of the independent variable .

integer, intent(in), optional :: dima

Dimension of the parameter vector for curve-tracking problems. Required if problem_type is curve_track.

type(nf_config), intent(in), optional :: config

Configuration parameters. If not provided, default values are used.

Return Value type(hompack_status)

public function nf_solver_solve(self, x0, a) result(result)

Arguments

Type IntentOptional Attributes Name
class(nf_solver), intent(inout) :: self

Solver object.

real(kind=dp), intent(in) :: x0(:)

Initial point for the solver. For fixed-point and zero-finding problems, this is the initial guess . For curve-tracking problems, this is the initial solution at .

real(kind=dp), intent(in), optional :: a(:)

Parameter vector for curve-tracking problems. Required if the solver was initialized with problem_type = curve_track.

Return Value type(nf_result)

public function nf_solver_restart(self) result(result)

Arguments

Type IntentOptional Attributes Name
class(nf_solver), intent(inout) :: self

Solver object.

Return Value type(nf_result)


Subroutines

public subroutine fixpnf(state, callbacks, n, x0, iflag, config, a)

This subroutine finds a fixed point or zero of the N-dimensional vector function , or tracks a zero curve of a general homotopy map .

Read more…

Arguments

Type IntentOptional Attributes Name
type(nf_state), intent(inout) :: state

Preallocated state for fixpnf. Set to start conditions on the first call, and updated on subsequent calls when iflag=2 or iflag=3.

type(hompack_f_callbacks), intent(in) :: callbacks

User-supplied function and Jacobian evaluation subroutines.

integer, intent(in) :: n

Problem dimension.

real(kind=dp), intent(in) :: x0(:)

Initial point for the solver. For fixed-point and zero-finding problems, this is identical to the initial guess . For curve-tracking problems, this is the initial solution at .

integer, intent(inout) :: iflag

Problem type and status flag.

Read more…
type(nf_config), intent(inout) :: config

Configuration parameters for the solver. Optional settings will be set to default values. Tolerances may be updated (increased) on output if iflag=2.

real(kind=dp), intent(in), optional :: a(:)

Parameter vector a for curve-tracking problems. Ignored for fixed-point and zero-finding problems.

public subroutine rootnf(state, callbacks, relerr, abserr)

This subroutine finds the point ybar = (1, xbar) on the zero curve of the homotopy map. It starts with two points yold = (lambdaold, xold) and y = (lambda, x) such that lambdaold < 1 <= lambda , and alternates between secant estimates of ybar and Newton iteration until convergence.

Arguments

Type IntentOptional Attributes Name
type(nf_state), intent(inout) :: state

State variables for fixpnf.

type(hompack_f_callbacks) :: callbacks

User-supplied function and Jacobian evaluation subroutines.

real(kind=dp), intent(in) :: relerr

Relative convergence tolerance. Iteration is considered converged when |y(1) - 1| <= relerr + abserr and the Newton correction satisfies ||z|| <= relerr*||x|| + abserr.

real(kind=dp), intent(in) :: abserr

Absolute convergence tolerance. Used together with relerr in the convergence criteria.

public subroutine stepnf(state, callbacks, sspar)

This subroutine takes one step along the zero curve of the homotopy map using a predictor-corrector algorithm. The predictor uses a Hermite cubic interpolant, and the corrector returns to the zero curve along the flow normal to the Davidenko flow. stepnf also estimates a step size h for the next step along the zero curve. Normally, stepnf is used indirectly through fixpnf, and should be called directly only if it is necessary to modify the stepping algorithm's parameters.

Arguments

Type IntentOptional Attributes Name
type(nf_state), intent(inout) :: state

State variables for fixpnf.

type(hompack_f_callbacks), intent(in) :: callbacks

User-supplied function and Jacobian evaluation subroutines.

real(kind=dp), intent(in) :: sspar(:)

Step-size control parameters: (lideal, rideal, dideal, hmin, hmax, bmin, bmax, p).

public subroutine tangnf(callbacks, rholen, n, y, yp, ypold, a, nfe, iflag, qr, alpha, tz, pivot)

This subroutine builds the Jacobian matrix of the homotopy map, computes a QR decomposition of that matrix, and then calculates the (unit) tangent vector and the Newton step.

Arguments

Type IntentOptional Attributes Name
type(hompack_f_callbacks) :: callbacks

User-supplied function and Jacobian evaluation subroutines.

real(kind=dp), intent(inout) :: rholen

Controls computation of the homotopy residual norm.

Read more…
integer, intent(in) :: n

Problem dimension.

real(kind=dp), intent(in) :: y(:)

Current point on the homotopy zero curve. Shape: (n+1). Contains (lambda, x).

real(kind=dp), intent(out) :: yp(:)

Unit tangent vector to the zero curve at y. Shape: (n+1). Represents dy/ds, where s is arc length along the zero curve.

real(kind=dp), intent(in) :: ypold(:)

Unit tangent vector at the previous point on the zero curve. Shape: (n+1). Used to determine a consistent orientation for the newly computed tangent vector.

real(kind=dp), intent(in) :: a(:)

Parameter vector used in the homotopy map.

integer, intent(inout) :: nfe

Number of homotopy/Jacobian evaluations performed. Incremented by one on every successful call.

integer, intent(inout) :: iflag

Problem type and return status flag.

Read more…
real(kind=dp), intent(inout) :: qr(:,:)

Workspace containing the Jacobian matrix and its QR factorization. Shape: (n, n+2).

real(kind=dp), intent(inout) :: alpha(:)

Workspace array used during QR factorization and related linear algebra operations. Shape: (3*n+3).

real(kind=dp), intent(out) :: tz(:)

Newton correction vector. Shape: (n+1). Equal to the negative pseudoinverse of the homotopy Jacobian applied to the homotopy residual.

integer, intent(inout) :: pivot(:)

Pivot indices produced by the QR factorization. Shape: (n+1).

public pure subroutine alloc_workspace(self, n, stat)

Initializes nf_workspace, i.e., (re)allocates all allocatable arrays and sets them to zero.

Arguments

Type IntentOptional Attributes Name
class(nf_workspace), intent(inout) :: self

Workspace object.

integer, intent(in) :: n

Problem dimension.

integer, intent(out), optional :: stat

Error status of the allocation.

public pure subroutine alloc_state(self, n, dima, stat)

Initializes nf_state, i.e., (re)allocates all allocatable arrays and sets them to zero.

Arguments

Type IntentOptional Attributes Name
class(nf_state), intent(inout) :: self

State object.

integer, intent(in) :: n

Problem dimension.

integer, intent(in) :: dima

Dimension of the parameter vector a.

integer, intent(out), optional :: stat

Error status of the allocation.