nonlin 1.5.2
A library that provides routines to compute the solutions to systems of nonlinear equations.
Loading...
Searching...
No Matches
nonlin_core::equation_solver_1var Type Referenceabstract

A base class for various solvers of equations of one variable. More...

Inheritance diagram for nonlin_core::equation_solver_1var:
nonlin_solve::brent_solver nonlin_solve::newton_1var_solver

Public Member Functions

procedure, public get_max_fcn_evals es1_get_max_eval
 Gets the maximum number of function evaluations allowed during a single solve.
 
procedure, public set_max_fcn_evals es1_set_max_eval
 Sets the maximum number of function evaluations allowed during a single solve.
 
procedure, public get_fcn_tolerance es1_get_fcn_tol
 Gets the convergence on function value tolerance.
 
procedure, public set_fcn_tolerance es1_set_fcn_tol
 Sets the convergence on function value tolerance.
 
procedure, public get_var_tolerance es1_get_var_tol
 Gets the convergence on change in variable tolerance.
 
procedure, public set_var_tolerance es1_set_var_tol
 Sets the convergence on change in variable tolerance.
 
procedure, public get_print_status es1_get_print_status
 Gets a logical value determining if iteration status should be printed.
 
procedure, public set_print_status es1_set_print_status
 Sets a logical value determining if iteration status should be printed.
 
procedure(nonlin_solver_1var), deferred, pass, public solve nonlin_solver_1var
 Solves the equation.
 
procedure, public get_diff_tolerance es1_get_diff_tol
 Gets the convergence on slope of the function (derivative) tolerance.
 
procedure, public set_diff_tolerance es1_set_diff_tol
 Sets the convergence on slope of the function (derivative) tolerance.
 

Public Attributes

real(real64) m_fcntol = 1.0d-8
 The convergence criteria on function value.
 
real(real64) m_xtol = 1.0d-12
 The convergence criteria on change in variable value.
 
real(real64) m_difftol = 1.0d-12
 The convergence criteria on the slope of the function (derivative)
 
logical m_printstatus = .false.
 Set to true to print iteration status; else, false.
 

Private Attributes

integer(int32) m_maxeval = 100
 The maximum number of function evaluations allowed per solve.
 

Detailed Description

A base class for various solvers of equations of one variable.

Example
The following example illustrates the solution of an equation of one variable by means of Brent's method.
program example
use iso_fortran_env
implicit none
! Local variables
type(fcn1var_helper) :: obj
procedure(fcn1var), pointer :: fcn
type(brent_solver) :: solver
real(real64) :: x, f
type(value_pair) :: limits
! Define the search limits
limits%x1 = 1.5d0
limits%x2 = 5.0d0
! Establish the function
fcn => fcn1
call obj%set_fcn(fcn)
! Solve the equation
call solver%solve(obj, x, limits, f)
! Print the output and the residual
print '(AF7.5)', "The solution: ", x
print '(AE10.3)', "The residual: ", f
contains
! The function:
! f(x) = sin(x) / x, solution: x = x * pi for n = 1, 2, 3, ...
function fcn1(x) result(f)
real(real64), intent(in) :: x
real(real64) :: f
f = sin(x) / x
end function
end program
nonlin_core
nonlin_solve
The above program produces the following output.
The solution: 3.15159
The residual: -0.751E-11

Definition at line 1512 of file nonlin_core.f90.

Member Function/Subroutine Documentation

◆ get_diff_tolerance()

procedure, public nonlin_core::equation_solver_1var::get_diff_tolerance

Gets the convergence on slope of the function (derivative) tolerance.

Syntax
pure real(real64) function get_diff_tolerance(class(equation_solver_1var) this)
Parameters
[in]thisThe equation_solver object.
Returns
The tolerance value.

Definition at line 1625 of file nonlin_core.f90.

◆ get_fcn_tolerance()

procedure, public nonlin_core::equation_solver_1var::get_fcn_tolerance

Gets the convergence on function value tolerance.

Syntax
pure real(real64) function get_fcn_tolerance(class(equation_solver_1var) this)
Parameters
[in]thisThe equation_solver_1var object.
Returns
The tolerance value.

Definition at line 1556 of file nonlin_core.f90.

◆ get_max_fcn_evals()

procedure, public nonlin_core::equation_solver_1var::get_max_fcn_evals

Gets the maximum number of function evaluations allowed during a single solve.

Syntax
pure integer(int32) function get_max_fcn_evals(class(equation_solver_1var) this)
Parameters
[in]thisThe equation_solver_1var object.
Returns
The maximum number of function evaluations.

Definition at line 1535 of file nonlin_core.f90.

◆ get_print_status()

procedure, public nonlin_core::equation_solver_1var::get_print_status

Gets a logical value determining if iteration status should be printed.

Syntax
pure logical function get_print_status(class(equation_solver_1var) this)
Parameters
[in]thisThe equation_solver_1var object.
Returns
True if the iteration status should be printed; else, false.

Definition at line 1597 of file nonlin_core.f90.

◆ get_var_tolerance()

procedure, public nonlin_core::equation_solver_1var::get_var_tolerance

Gets the convergence on change in variable tolerance.

Syntax
pure real(real64) function get_var_tolerance(class(equation_solver_1var) this)
Parameters
[in]thisThe equation_solver_1var object.
Returns
The tolerance value.

Definition at line 1576 of file nonlin_core.f90.

◆ set_diff_tolerance()

procedure, public nonlin_core::equation_solver_1var::set_diff_tolerance

Sets the convergence on slope of the function (derivative) tolerance.

Syntax
subroutine set_diff_tolerance(class(equation_solver_1var) this, real(real64) x)
Parameters
[in,out]thisThe equation_solver object.
[in]xThe tolerance value.
Example
See the equation_solver type for an example on how to establish the gradient vector slope tolerance.

Definition at line 1640 of file nonlin_core.f90.

◆ set_fcn_tolerance()

procedure, public nonlin_core::equation_solver_1var::set_fcn_tolerance

Sets the convergence on function value tolerance.

Syntax
subroutine set_fcn_tolerance(class(equation_solver_1var) this, real(real64) x)
Parameters
[in,out]thisThe equation_solver_1var object.
[in]xThe tolerance value.

Definition at line 1566 of file nonlin_core.f90.

◆ set_max_fcn_evals()

procedure, public nonlin_core::equation_solver_1var::set_max_fcn_evals

Sets the maximum number of function evaluations allowed during a single solve.

Syntax
subroutine set_max_fcn_evals(class(equation_solver_1var) this, integer(int32) n)
Parameters
[in,out]thisThe equation_solver_1var object.
[in]nThe maximum number of function evaluations.

Definition at line 1546 of file nonlin_core.f90.

◆ set_print_status()

procedure, public nonlin_core::equation_solver_1var::set_print_status

Sets a logical value determining if iteration status should be printed.

Syntax
subroutine set_print_status(class(equation_solver_1var) this, logical x)
Parameters
[in,out]thisThe equation_solver_1var object.
[in]xTrue if the iteration status should be printed; else, false.

Definition at line 1608 of file nonlin_core.f90.

◆ set_var_tolerance()

procedure, public nonlin_core::equation_solver_1var::set_var_tolerance

Sets the convergence on change in variable tolerance.

Syntax
subroutine set_var_tolerance(class(equation_solver_1var) this, real(real64) x)
Parameters
[in,out]thisThe equation_solver_1var object.
[in]xThe tolerance value.

Definition at line 1586 of file nonlin_core.f90.

◆ solve()

procedure(nonlin_solver_1var), deferred, pass, public nonlin_core::equation_solver_1var::solve
pure virtual

Solves the equation.

Example
See the equation_solver_1var type for an example on how to solve a system of equations.

Implemented in nonlin_solve::brent_solver, and nonlin_solve::newton_1var_solver.

Definition at line 1614 of file nonlin_core.f90.

Member Data Documentation

◆ m_difftol

real(real64) nonlin_core::equation_solver_1var::m_difftol = 1.0d-12

The convergence criteria on the slope of the function (derivative)

Definition at line 1521 of file nonlin_core.f90.

◆ m_fcntol

real(real64) nonlin_core::equation_solver_1var::m_fcntol = 1.0d-8

The convergence criteria on function value.

Definition at line 1517 of file nonlin_core.f90.

◆ m_maxeval

integer(int32) nonlin_core::equation_solver_1var::m_maxeval = 100
private

The maximum number of function evaluations allowed per solve.

Definition at line 1515 of file nonlin_core.f90.

◆ m_printstatus

logical nonlin_core::equation_solver_1var::m_printstatus = .false.

Set to true to print iteration status; else, false.

Definition at line 1523 of file nonlin_core.f90.

◆ m_xtol

real(real64) nonlin_core::equation_solver_1var::m_xtol = 1.0d-12

The convergence criteria on change in variable value.

Definition at line 1519 of file nonlin_core.f90.


The documentation for this type was generated from the following file: