hybrd Subroutine

private subroutine hybrd(obj, n, x, fVec, xTol, maxFev, ml, mu, epsFcn, diag, mode, factor, info, nFev, fjac, ldfjac, r, lr, qtf)

Seeks a zero of N non-linear equations in N variables.

HYBRD finds a zero of a system of N non-linear functions in N variables by a modification of the Powell hybrid method. The user must provide a subroutine which calculates the functions.

The jacobian is then calculated by a forward-difference approximation.

Arguments

Type IntentOptional Attributes Name
class(fSolve_t), intent(in) :: obj

External object with the user-supplied subroutine which calculates the functions.

integer, intent(in) :: n

The number of functions and variables

real(kind=dp), intent(inout) :: x(n)

Input initial estimate of the solution vector / output X final estimate of the solution vector

real(kind=dp), intent(out) :: fVec(n)

The functions evaluated at the output X

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

Termination occurs when the relative error between two consecutive iterates is at most XTOL. XTOL should be non-negative.

integer, intent(in) :: maxFev

Termination occurs when the number of calls to FCN is at least MAXFEV by the end of an iteration

integer, intent(in) :: ml

Specify the number of sub-diagonals within the band of the jacobian matrix. If the jacobian is not banded, set ML to at least n - 1.

integer, intent(in) :: mu

Specify the number of super-diagonals within the band of the jacobian matrix. If the jacobian is not banded, set MU to at least n - 1.

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

is used in determining a suitable step length for the forward-difference approximation. This approximation assumes that the relative errors in the functions are of the order of EPSFCN. If EPSFCN is less than the machine precision, it is assumed that the relative errors in the functions are of the order of the machine precision.

real(kind=dp), intent(inout) :: diag(n)

If MODE = 1, then DIAG is set internally. If MODE = 2, then DIAG must contain positive entries that serve as multiplicative scale factors for the variables.

integer, intent(in) :: mode

variables will be scaled internally. 2, scaling is specified by the input DIAG vector.

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

determines the initial step bound. This bound is set to the product of FACTOR and the euclidean norm of DIAG*X if non-zero, or else to FACTOR itself. In most cases, FACTOR should lie in the interval (0.1, 100) with 100 the recommended value.

integer, intent(out) :: info

Error flag

  1. Improper input parameters.
  2. Relative error between two consecutive iterates is at most XTOL.
  3. Number of calls to FCN has reached or exceeded MAXFEV.
  4. XTOL is too small. No further improvement in the approximate solution X is possible.
  5. Iteration is not making good progress, as measured by the improvement from the last five jacobian evaluations.
  6. Iteration is not making good progress, as measured by the improvement from the last ten iterations.
integer, intent(out) :: nFev

The number of calls to FCN. produced by the QR factorization of the final approximate jacobian.

real(kind=dp), intent(out) :: fjac(ldfjac,n)

Out - N by N array which contains the orthogonal matrix Q

integer, intent(in) :: ldfjac

The leading dimension of FJAC. LDFJAC must be at least N.

real(kind=dp), intent(out) :: r(lr)

Upper triangular matrix produced by the QR factorization of the final approximate jacobian, stored row-wise.

integer, intent(in) :: lr

Size of the R array, which must be no less than (N*(N+1))/2.

real(kind=dp), intent(out) :: qtf(n)

Contains the vector Q'*FVEC.


Calls

proc~~hybrd~~CallsGraph proc~hybrd hybrd fcn fcn proc~hybrd->fcn proc~dogleg dogleg proc~hybrd->proc~dogleg proc~enorm eNorm proc~hybrd->proc~enorm proc~fdjac1 fdJac1 proc~hybrd->proc~fdjac1 proc~qform qform proc~hybrd->proc~qform proc~qrfac qrFac proc~hybrd->proc~qrfac proc~r1mpyq r1mpyq proc~hybrd->proc~r1mpyq proc~r1updt r1updt proc~hybrd->proc~r1updt proc~dogleg->proc~enorm proc~fdjac1->fcn proc~qrfac->proc~enorm

Called by

proc~~hybrd~~CalledByGraph proc~hybrd hybrd proc~fsolve fsolve proc~fsolve->proc~hybrd proc~solve_junction solve_junction proc~solve_junction->proc~fsolve proc~junction_resolution_from_and_to_ports Junction_resolution_from_and_to_ports proc~junction_resolution_from_and_to_ports->proc~solve_junction proc~main_loop main_loop proc~main_loop->proc~junction_resolution_from_and_to_ports program~reims_p reims_p program~reims_p->proc~main_loop