yaeos__math_continuation Module

Numerical continuation

Predictor-corrector continuation of nonlinear solution curves.

Description

The module defines callback interfaces and a continuation driver for tracing solutions of as a scalar specification changes. At each accepted point the routine solves for the local tangent , predicts the next state, and corrects it with a nonlinear solver. The caller may customize the specification update, post-processing, point solver, and stopping condition.

Examples

curve = continuation(fun, X0, ns0, S0, dS0, &
   max_points=100, solver_tol=1.0e-8_pr)

Uses

  • module~~yaeos__math_continuation~~UsesGraph module~yaeos__math_continuation yaeos__math_continuation module~yaeos__constants yaeos__constants module~yaeos__math_continuation->module~yaeos__constants module~yaeos__math_linalg yaeos__math_linalg module~yaeos__math_continuation->module~yaeos__math_linalg iso_fortran_env iso_fortran_env module~yaeos__constants->iso_fortran_env module~yaeos__math_linalg->module~yaeos__constants

Used by

  • module~~yaeos__math_continuation~~UsedByGraph module~yaeos__math_continuation yaeos__math_continuation module~yaeos__equilibria_boundaries_phase_envelopes_pt yaeos__equilibria_boundaries_phase_envelopes_pt module~yaeos__equilibria_boundaries_phase_envelopes_pt->module~yaeos__math_continuation module~yaeos__equilibria_boundaries_phase_envelopes_mp yaeos__equilibria_boundaries_phase_envelopes_mp module~yaeos__equilibria_boundaries_phase_envelopes_pt->module~yaeos__equilibria_boundaries_phase_envelopes_mp module~yaeos__equilibria_boundaries_phase_envelopes_px yaeos__equilibria_boundaries_phase_envelopes_px module~yaeos__equilibria_boundaries_phase_envelopes_px->module~yaeos__math_continuation module~yaeos__equilibria_boundaries_auxiliar yaeos__equilibria_boundaries_auxiliar module~yaeos__equilibria_boundaries_phase_envelopes_px->module~yaeos__equilibria_boundaries_auxiliar module~yaeos__equilibria_boundaries_phase_envelopes_tx yaeos__equilibria_boundaries_phase_envelopes_tx module~yaeos__equilibria_boundaries_phase_envelopes_tx->module~yaeos__math_continuation module~yaeos__equilibria_boundaries_phase_envelopes_tx->module~yaeos__equilibria_boundaries_auxiliar module~yaeos__equilibria_boundaries_pure_saturation yaeos__equilibria_boundaries_pure_saturation module~yaeos__equilibria_boundaries_pure_saturation->module~yaeos__math_continuation module~yaeos__math yaeos__math module~yaeos__math->module~yaeos__math_continuation proc~critical_line critical_line proc~critical_line->module~yaeos__math_continuation proc~critical_line->module~yaeos__math module~yaeos__equilibria yaeos__equilibria module~yaeos__equilibria->module~yaeos__equilibria_boundaries_phase_envelopes_pt module~yaeos__equilibria->module~yaeos__equilibria_boundaries_phase_envelopes_px module~yaeos__equilibria->module~yaeos__equilibria_boundaries_phase_envelopes_tx module~yaeos__equilibria->module~yaeos__equilibria_boundaries_pure_saturation module~yaeos__equilibria_binaries yaeos__equilibria_binaries module~yaeos__equilibria->module~yaeos__equilibria_binaries module~yaeos__equilibria_boundaries_generalized_isopleths yaeos__equilibria_boundaries_generalized_isopleths module~yaeos__equilibria->module~yaeos__equilibria_boundaries_generalized_isopleths module~yaeos__equilibria->module~yaeos__equilibria_boundaries_phase_envelopes_mp module~yaeos__equilibria_boundaries_phase_envelopes_mp_px yaeos__equilibria_boundaries_phase_envelopes_mp_px module~yaeos__equilibria->module~yaeos__equilibria_boundaries_phase_envelopes_mp_px module~yaeos__equilibria_boundaries_phase_envelopes_mp_tx yaeos__equilibria_boundaries_phase_envelopes_mp_tx module~yaeos__equilibria->module~yaeos__equilibria_boundaries_phase_envelopes_mp_tx module~yaeos__equilibria_boundaries_phase_envelopes_pt3 yaeos__equilibria_boundaries_phase_envelopes_pt3 module~yaeos__equilibria->module~yaeos__equilibria_boundaries_phase_envelopes_pt3 module~yaeos__equilibria_boundaries_phase_envelopes_px3 yaeos__equilibria_boundaries_phase_envelopes_px3 module~yaeos__equilibria->module~yaeos__equilibria_boundaries_phase_envelopes_px3 module~yaeos__equilibria_binaries->module~yaeos__math module~yaeos__equilibria_boundaries_auxiliar->module~yaeos__math module~yaeos__equilibria_boundaries_generalized_isopleths->module~yaeos__math module~yaeos__equilibria_boundaries_phase_envelopes_mp->module~yaeos__math module~yaeos__equilibria_boundaries_phase_envelopes_mp->module~yaeos__equilibria_boundaries_auxiliar module~yaeos__equilibria_boundaries_phase_envelopes_mp_px->module~yaeos__math module~yaeos__equilibria_boundaries_phase_envelopes_mp_px->module~yaeos__equilibria_boundaries_auxiliar module~yaeos__equilibria_boundaries_phase_envelopes_mp_tx->module~yaeos__math module~yaeos__equilibria_boundaries_phase_envelopes_mp_tx->module~yaeos__equilibria_boundaries_auxiliar module~yaeos__equilibria_boundaries_phase_envelopes_pt3->module~yaeos__math module~yaeos__equilibria_boundaries_phase_envelopes_px3->module~yaeos__math module~yaeos__equilibria_boundaries_phase_envelopes_px3->module~yaeos__equilibria_boundaries_auxiliar module~yaeos__models_ge_uniquac yaeos__models_ge_uniquac module~yaeos__models_ge_uniquac->module~yaeos__math proc~check_critical_jump check_critical_jump proc~check_critical_jump->module~yaeos__math proc~critical_point critical_point proc~critical_point->module~yaeos__math proc~detect_critical detect_critical proc~detect_critical->module~yaeos__math proc~estimate_critical_point estimate_critical_point proc~estimate_critical_point->module~yaeos__equilibria_boundaries_pure_saturation proc~homotopy homotopy proc~homotopy->module~yaeos__math proc~look_for_cep look_for_cep proc~look_for_cep->module~yaeos__math proc~refit_rkpr_k refit_rkpr_k proc~refit_rkpr_k->module~yaeos__equilibria_boundaries_pure_saturation proc~solve_generalized_point solve_generalized_point proc~solve_generalized_point->module~yaeos__math proc~solve_mp_flash_point solve_mp_flash_point proc~solve_mp_flash_point->module~yaeos__math proc~solve_point PXEnvelMP%solve_point proc~solve_point->module~yaeos__math proc~solve_point_psat solve_point_psat proc~solve_point_psat->module~yaeos__math proc~solve_point~2 TXEnvelMP%solve_point proc~solve_point~2->module~yaeos__math proc~solve_point~4 PTEnvelMP%solve_point proc~solve_point~4->module~yaeos__math proc~solve_tp solve_TP proc~solve_tp->module~yaeos__math proc~solve_vxvyt solve_VxVyT proc~solve_vxvyt->module~yaeos__math proc~three_phase_line_f three_phase_line_F proc~three_phase_line_f->module~yaeos__math proc~three_phase_line_f_solve three_phase_line_F_solve proc~three_phase_line_f_solve->module~yaeos__math proc~volume~2 ArModel%volume proc~volume~2->module~yaeos__math proc~volume~3 Gerg2008%volume proc~volume~3->module~yaeos__math module~yaeos yaeos module~yaeos->module~yaeos__equilibria module~yaeos__models yaeos__models module~yaeos->module~yaeos__models module~yaeos__models_ge_implementations yaeos__models_ge_implementations module~yaeos__models_ge_implementations->module~yaeos__models_ge_uniquac proc~update_specification~3 update_specification proc~update_specification~3->module~yaeos__equilibria_boundaries_auxiliar module~yaeos__models->module~yaeos__models_ge_implementations proc~psrk PSRK proc~psrk->module~yaeos__models_ge_implementations module~yaeos__extra_fluids yaeos__extra_fluids module~yaeos__extra_fluids->module~yaeos__models proc~co2_h2o_isop co2_h2o_isop proc~co2_h2o_isop->module~yaeos__models

Abstract Interfaces

abstract interface

  • public subroutine continuation_function(X, ns, S, F, dF, dFdS)

    continuation_function

    Evaluate the nonlinear residual and its local derivatives.

    Description

    The equations are . Return the Jacobian with respect to and the derivative with respect to the scalar .

    Arguments

    Type IntentOptional Attributes Name
    real(kind=pr), intent(in) :: X(:)

    Current unknown vector.

    integer, intent(in) :: ns

    Index of the specified entry in X.

    real(kind=pr), intent(in) :: S

    Current specification value.

    real(kind=pr), intent(out) :: F(:)

    Residual vector, zero at a solution.

    real(kind=pr), intent(out) :: dF(:,:)

    Jacobian .

    real(kind=pr), intent(out) :: dFdS(:)

    Derivative .

abstract interface

  • public subroutine continuation_solver(fun, iters, X, ns, S, dS, dXdS, point, max_iters, F, df, dfds, tol)

    continuation_solver

    Description

    Solver to solve a point during numerical continuation.

    Arguments

    Type IntentOptional Attributes Name
    procedure(continuation_function) :: fun

    Function to solve

    integer, intent(out) :: iters

    Number of iterations needed

    real(kind=pr), intent(inout) :: X(:)

    Variables vector

    integer, intent(in) :: ns

    Specification number

    real(kind=pr), intent(in) :: S

    Specification value

    real(kind=pr), intent(in) :: dS

    Delta spec

    real(kind=pr), intent(in) :: dXdS(:)

    Tangent used for the predictor

    integer, intent(in) :: point

    Point number

    integer, intent(in) :: max_iters

    Maximum iterations

    real(kind=pr), intent(out) :: F(:)

    Function values at solved point

    real(kind=pr), intent(out) :: df(:,:)

    Jacobian values

    real(kind=pr), intent(out) :: dfds(:)

    dFdS

    real(kind=pr), intent(in) :: tol

    Solver tolerance

abstract interface

  • public function continuation_stopper(X, ns, S, dS, dXdS, iterations)

    continuation_stopper

    Description

    Function that returns true if the method should stop

    Arguments

    Type IntentOptional Attributes Name
    real(kind=pr), intent(inout) :: X(:)

    Vector of variables

    integer, intent(inout) :: ns

    Position of specified variable

    real(kind=pr), intent(inout) :: S

    Specification variable value

    real(kind=pr), intent(inout) :: dS

    Step of specification in the method

    real(kind=pr), intent(inout) :: dXdS(:)

    integer, intent(in) :: iterations

    Iterations needed to converge point

    Return Value logical

abstract interface

  • public subroutine process(X, ns, S, dS, dXdS, iterations)

    Subroutine to make variation in the method after a point converged

    Arguments

    Type IntentOptional Attributes Name
    real(kind=pr), intent(inout) :: X(:)

    Vector of variables

    integer, intent(inout) :: ns

    Position of specified variable

    real(kind=pr), intent(inout) :: S

    Specification variable value

    real(kind=pr), intent(inout) :: dS

    Step of specification in the method

    real(kind=pr), intent(inout) :: dXdS(:)

    integer, intent(in) :: iterations

    Iterations needed to converge point


Derived Types

type, public ::  ContinuationVariable

State of the unknown vector and specification at one curve point.

Read more…

Components

Type Visibility Attributes Name Initial
real(kind=pr), public :: S

Value of the specified variable.

real(kind=pr), public, allocatable :: X(:)

Unknown vector at the point.

real(kind=pr), public :: dS

Signed step proposed for the next continuation point.

integer, public :: ns

Index of the component of X used as the specification.


Functions

public function continuation(f, X0, ns0, S0, dS0, max_points, solver_tol, update_specification, postprocess, solver, stop) result(XS)

Trace a one-dimensional solution manifold of a nonlinear system.

Read more…

Arguments

Type IntentOptional Attributes Name
procedure(continuation_function) :: f

Residual and derivative callback for .

real(kind=pr), intent(in) :: X0(:)

Initial converged unknown vector.

integer, intent(in) :: ns0

Index of the initially specified variable in X0.

real(kind=pr), intent(in) :: S0

Initial value of the specified variable.

real(kind=pr), intent(in) :: dS0

Signed first step in the specification.

integer, intent(in) :: max_points

Maximum number of continuation points to store.

real(kind=pr), intent(in) :: solver_tol

Residual tolerance for the point corrector.

procedure(process), optional :: update_specification

Optional callback to select the next specification and step. If absent, the tangent component of largest magnitude is selected and the step is scaled using that component:

Read more…
procedure(process), optional :: postprocess

Optional callback to modify the state or step after specification selection, for example to enforce bounds or change step direction.

procedure(continuation_solver), optional :: solver

Optional point corrector. The built-in Newton solver is used by default.

procedure(continuation_stopper), optional :: stop

Optional callback evaluated after each accepted point; true terminates continuation.

Return Value real(kind=pr), (max_points,size(X0))

Stored solution vectors, one per row.


Subroutines

public subroutine full_newton(fun, iters, X, ns, S, dS, dXdS, point, max_iters, F, df, dfds, tol)

Correct one predicted continuation point with Newton’s method. The correction solves at fixed specification value, halving the Newton step until . It stops when or tol. If iteration 10 is reached (for points after the first), is reset to the previous point plus 10% of the predictor step. On failure iters ends at max_iters + 1.

Read more…

Arguments

Type IntentOptional Attributes Name
procedure(continuation_function) :: fun

Residual/Jacobian callback.

integer, intent(out) :: iters

Newton iterations used for this point.

real(kind=pr), intent(inout) :: X(:)

Predicted vector; corrected solution on return.

integer, intent(in) :: ns

Index of the specified variable.

real(kind=pr), intent(in) :: S

Fixed specification value for this correction.

real(kind=pr), intent(in) :: dS

Step used to form the predictor.

real(kind=pr), intent(in) :: dXdS(:)

Tangent used by the predictor and recovery logic.

integer, intent(in) :: point

One-based continuation point number.

integer, intent(in) :: max_iters

Maximum Newton iterations for correction.

real(kind=pr), intent(out) :: F(:)

Residual at the corrected point.

real(kind=pr), intent(out) :: df(:,:)

Jacobian .

real(kind=pr), intent(out) :: dfds(:)

Derivative .

real(kind=pr), intent(in) :: tol

Residual (max-norm) convergence tolerance.