sfepy.solvers.nls module¶
-
class
sfepy.solvers.nls.Newton(conf, **kwargs)[source]¶ Solves a nonlinear system
using the Newton method with backtracking line-search, starting with an initial guess .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.
.eps_r : float
The relative tolerance for the residual, i.e.
.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
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
.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
using the Newton method with backtracking line-search, starting with an initial guess .Parameters: vec_x0 : array
The initial guess vector
.conf : Struct instance, optional
The solver configuration parameters,
fun : function, optional
The function
whose zero is sought - the residual.fun_grad : function, optional
The gradient of
- 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.
-
__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]¶
-
__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, }
-

