sfepy.solvers.nls module

class sfepy.solvers.nls.Newton(conf, **kwargs)[source]

Solves a nonlinear system

System Message: WARNING/2 (f(x) = 0)

latex exited with error [stdout] This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/TeX Live for SUSE Linux) restricted \write18 enabled. entering extended mode (./math.tex LaTeX2e <2011/06/27> Babel <3.9f> and hyphenation patterns for 78 languages loaded. (/usr/share/texmf/tex/latex/base/article.cls Document Class: article 2007/10/19 v1.4h Standard LaTeX document class (/usr/share/texmf/tex/latex/base/size12.clo)) (/usr/share/texmf/tex/latex/base/inputenc.sty ! LaTeX Error: File `utf8x.def’ not found. Type X to quit or <RETURN> to proceed, or enter new name. (Default extension: def) Enter file name: ! Emergency stop. <read *> l.131 \endinput ^^M No pages of output. Transcript written on math.log.
using the Newton method with backtracking line-search, starting with an initial guess

System Message: WARNING/2 (x^0)

latex exited with error [stdout] This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/TeX Live for SUSE Linux) restricted \write18 enabled. entering extended mode (./math.tex LaTeX2e <2011/06/27> Babel <3.9f> and hyphenation patterns for 78 languages loaded. (/usr/share/texmf/tex/latex/base/article.cls Document Class: article 2007/10/19 v1.4h Standard LaTeX document class (/usr/share/texmf/tex/latex/base/size12.clo)) (/usr/share/texmf/tex/latex/base/inputenc.sty ! LaTeX Error: File `utf8x.def’ not found. Type X to quit or <RETURN> to proceed, or enter new name. (Default extension: def) Enter file name: ! Emergency stop. <read *> l.131 \endinput ^^M No pages of output. Transcript written on math.log.
.

For common configuration parameters, see Solver.

Parameters:

i_max : int

The maximum number of iterations.

eps_a : float

The absolute tolerance for the residual, i.e.

System Message: WARNING/2 (||f(x^i)||)

latex exited with error [stdout] This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/TeX Live for SUSE Linux) restricted \write18 enabled. entering extended mode (./math.tex LaTeX2e <2011/06/27> Babel <3.9f> and hyphenation patterns for 78 languages loaded. (/usr/share/texmf/tex/latex/base/article.cls Document Class: article 2007/10/19 v1.4h Standard LaTeX document class (/usr/share/texmf/tex/latex/base/size12.clo)) (/usr/share/texmf/tex/latex/base/inputenc.sty ! LaTeX Error: File `utf8x.def’ not found. Type X to quit or <RETURN> to proceed, or enter new name. (Default extension: def) Enter file name: ! Emergency stop. <read *> l.131 \endinput ^^M No pages of output. Transcript written on math.log.

.

eps_r : float

The relative tolerance for the residual, i.e.

System Message: WARNING/2 (||f(x^i)|| / ||f(x^0)||)

latex exited with error [stdout] This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/TeX Live for SUSE Linux) restricted \write18 enabled. entering extended mode (./math.tex LaTeX2e <2011/06/27> Babel <3.9f> and hyphenation patterns for 78 languages loaded. (/usr/share/texmf/tex/latex/base/article.cls Document Class: article 2007/10/19 v1.4h Standard LaTeX document class (/usr/share/texmf/tex/latex/base/size12.clo)) (/usr/share/texmf/tex/latex/base/inputenc.sty ! LaTeX Error: File `utf8x.def’ not found. Type X to quit or <RETURN> to proceed, or enter new name. (Default extension: def) Enter file name: ! Emergency stop. <read *> l.131 \endinput ^^M No pages of output. Transcript written on math.log.

.

macheps : float

The float considered to be machine “zero”.

lin_red : float

The linear system solution error should be smaller than (eps_a * lin_red), otherwise a warning is printed.

lin_precision : float or None

If not None, the linear system solution tolerances are set in each nonlinear iteration relative to the current residual norm by the lin_precision factor. Ignored for direct linear solvers.

ls_on : float

Start the backtracking line-search by reducing the step, if

System Message: WARNING/2 (||f(x^i)|| / ||f(x^{i-1})||)

latex exited with error [stdout] This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/TeX Live for SUSE Linux) restricted \write18 enabled. entering extended mode (./math.tex LaTeX2e <2011/06/27> Babel <3.9f> and hyphenation patterns for 78 languages loaded. (/usr/share/texmf/tex/latex/base/article.cls Document Class: article 2007/10/19 v1.4h Standard LaTeX document class (/usr/share/texmf/tex/latex/base/size12.clo)) (/usr/share/texmf/tex/latex/base/inputenc.sty ! LaTeX Error: File `utf8x.def’ not found. Type X to quit or <RETURN> to proceed, or enter new name. (Default extension: def) Enter file name: ! Emergency stop. <read *> l.131 \endinput ^^M No pages of output. Transcript written on math.log.

is larger than ls_on.

ls_red : 0.0 < float < 1.0

The step reduction factor in case of correct residual assembling.

ls_red_warp : 0.0 < float < 1.0

The step reduction factor in case of failed residual assembling (e.g. the “warp violation” error caused by a negative volume element resulting from too large deformations).

ls_min : 0.0 < float < 1.0

The minimum step reduction factor.

give_up_warp : bool

If True, abort on the “warp violation” error.

check : 0, 1 or 2

If >= 1, check the tangent matrix using finite differences. If 2, plot the resulting sparsity patterns.

delta : float

If check >= 1, the finite difference matrix is taken as

System Message: WARNING/2 (A_{ij} = \frac{f_i(x_j + \delta) - f_i(x_j - \delta)}{2 \delta})

latex exited with error [stdout] This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/TeX Live for SUSE Linux) restricted \write18 enabled. entering extended mode (./math.tex LaTeX2e <2011/06/27> Babel <3.9f> and hyphenation patterns for 78 languages loaded. (/usr/share/texmf/tex/latex/base/article.cls Document Class: article 2007/10/19 v1.4h Standard LaTeX document class (/usr/share/texmf/tex/latex/base/size12.clo)) (/usr/share/texmf/tex/latex/base/inputenc.sty ! LaTeX Error: File `utf8x.def’ not found. Type X to quit or <RETURN> to proceed, or enter new name. (Default extension: def) Enter file name: ! Emergency stop. <read *> l.131 \endinput ^^M No pages of output. Transcript written on math.log.

.

is_plot : False

If True, plot the solution and residual in each step.

log : dict or None

If not None, log the convergence according to the configuration in the following form:

{'text' : 'log.txt', 'plot' : 'log.pdf'}

Each of the dict items can be None.

problem : ‘nonlinear’ or ‘linear’

Specifies if the problem is linear or non-linear.

__call__(vec_x0, conf=None, fun=None, fun_grad=None, lin_solver=None, iter_hook=None, status=None)[source]

Nonlinear system solver call.

Solves a nonlinear system

System Message: WARNING/2 (f(x) = 0)

latex exited with error [stdout] This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/TeX Live for SUSE Linux) restricted \write18 enabled. entering extended mode (./math.tex LaTeX2e <2011/06/27> Babel <3.9f> and hyphenation patterns for 78 languages loaded. (/usr/share/texmf/tex/latex/base/article.cls Document Class: article 2007/10/19 v1.4h Standard LaTeX document class (/usr/share/texmf/tex/latex/base/size12.clo)) (/usr/share/texmf/tex/latex/base/inputenc.sty ! LaTeX Error: File `utf8x.def’ not found. Type X to quit or <RETURN> to proceed, or enter new name. (Default extension: def) Enter file name: ! Emergency stop. <read *> l.131 \endinput ^^M No pages of output. Transcript written on math.log.
using the Newton method with backtracking line-search, starting with an initial guess

System Message: WARNING/2 (x^0)

latex exited with error [stdout] This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/TeX Live for SUSE Linux) restricted \write18 enabled. entering extended mode (./math.tex LaTeX2e <2011/06/27> Babel <3.9f> and hyphenation patterns for 78 languages loaded. (/usr/share/texmf/tex/latex/base/article.cls Document Class: article 2007/10/19 v1.4h Standard LaTeX document class (/usr/share/texmf/tex/latex/base/size12.clo)) (/usr/share/texmf/tex/latex/base/inputenc.sty ! LaTeX Error: File `utf8x.def’ not found. Type X to quit or <RETURN> to proceed, or enter new name. (Default extension: def) Enter file name: ! Emergency stop. <read *> l.131 \endinput ^^M No pages of output. Transcript written on math.log.
.

Parameters:

vec_x0 : array

The initial guess vector

System Message: WARNING/2 (x_0)

latex exited with error [stdout] This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/TeX Live for SUSE Linux) restricted \write18 enabled. entering extended mode (./math.tex LaTeX2e <2011/06/27> Babel <3.9f> and hyphenation patterns for 78 languages loaded. (/usr/share/texmf/tex/latex/base/article.cls Document Class: article 2007/10/19 v1.4h Standard LaTeX document class (/usr/share/texmf/tex/latex/base/size12.clo)) (/usr/share/texmf/tex/latex/base/inputenc.sty ! LaTeX Error: File `utf8x.def’ not found. Type X to quit or <RETURN> to proceed, or enter new name. (Default extension: def) Enter file name: ! Emergency stop. <read *> l.131 \endinput ^^M No pages of output. Transcript written on math.log.

.

conf : Struct instance, optional

The solver configuration parameters,

fun : function, optional

The function

System Message: WARNING/2 (f(x))

latex exited with error [stdout] This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/TeX Live for SUSE Linux) restricted \write18 enabled. entering extended mode (./math.tex LaTeX2e <2011/06/27> Babel <3.9f> and hyphenation patterns for 78 languages loaded. (/usr/share/texmf/tex/latex/base/article.cls Document Class: article 2007/10/19 v1.4h Standard LaTeX document class (/usr/share/texmf/tex/latex/base/size12.clo)) (/usr/share/texmf/tex/latex/base/inputenc.sty ! LaTeX Error: File `utf8x.def’ not found. Type X to quit or <RETURN> to proceed, or enter new name. (Default extension: def) Enter file name: ! Emergency stop. <read *> l.131 \endinput ^^M No pages of output. Transcript written on math.log.

whose zero is sought - the residual.

fun_grad : function, optional

The gradient of

System Message: WARNING/2 (f(x))

latex exited with error [stdout] This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/TeX Live for SUSE Linux) restricted \write18 enabled. entering extended mode (./math.tex LaTeX2e <2011/06/27> Babel <3.9f> and hyphenation patterns for 78 languages loaded. (/usr/share/texmf/tex/latex/base/article.cls Document Class: article 2007/10/19 v1.4h Standard LaTeX document class (/usr/share/texmf/tex/latex/base/size12.clo)) (/usr/share/texmf/tex/latex/base/inputenc.sty ! LaTeX Error: File `utf8x.def’ not found. Type X to quit or <RETURN> to proceed, or enter new name. (Default extension: def) Enter file name: ! Emergency stop. <read *> l.131 \endinput ^^M No pages of output. Transcript written on math.log.

- the tangent matrix.

lin_solver : LinearSolver instance, optional

The linear solver for each nonlinear iteration.

iter_hook : function, optional

User-supplied function to call before each iteration.

status : dict-like, optional

The user-supplied object to hold convergence statistics.

Notes

  • The optional parameters except iter_hook and status need to be given either here or upon Newton construction.
  • Setting conf.problem == ‘linear’ means a pre-assembled and possibly pre-solved matrix. This is mostly useful for linear time-dependent problems.
__init__(conf, **kwargs)[source]
__module__ = 'sfepy.solvers.nls'
name = 'nls.newton'
static process_conf(conf, kwargs)[source]

Missing items are set to default values for a linear problem.

Example configuration, all items:

solver_1 = {
    'name' : 'newton',
    'kind' : 'nls.newton',

    'i_max' : 2,
    'eps_a' : 1e-8,
    'eps_r' : 1e-2,
    'macheps' : 1e-16,
    'lin_red' : 1e-2, # Linear system error < (eps_a * lin_red).
    'lin_precision' : None,
    'ls_on' : 0.99999,
    'ls_red' : 0.1,
    'ls_red_warp' : 0.001,
    'ls_min' : 1e-5,
    'give_up_warp' : False,
    'check' : 0,
    'delta' : 1e-6,
    'is_plot' : False,
    'log' : None, # 'nonlinear' or 'linear' (ignore i_max)
    'problem' : 'nonlinear',
}
class sfepy.solvers.nls.ScipyBroyden(conf, **kwargs)[source]

Interface to Broyden and Anderson solvers from scipy.optimize.

__call__(vec_x0, conf=None, fun=None, fun_grad=None, lin_solver=None, iter_hook=None, status=None)[source]
__init__(conf, **kwargs)[source]
__module__ = 'sfepy.solvers.nls'
name = 'nls.scipy_broyden_like'
static process_conf(conf, kwargs)[source]

Missing items are left to scipy defaults. Unused options are ignored.

Example configuration, all items:

solver_1 = {
    'name' : 'broyden',
    'kind' : 'nls.scipy_broyden_like',

    'method'  : 'broyden3',
    'i_max'   : 10,
    'alpha'   : 0.9,
    'M'       : 5,
    'w0'      : 0.1,
    'f_tol'   : 6e-6,
    'verbose' : True,
}
set_method(conf)[source]
sfepy.solvers.nls.check_tangent_matrix(conf, vec_x0, fun, fun_grad)[source]

Verify the correctness of the tangent matrix as computed by fun_grad() by comparing it with its finite difference approximation evaluated by repeatedly calling fun() with vec_x items perturbed by a small delta.

sfepy.solvers.nls.conv_test(conf, it, err, err0)[source]