Static analyses of a model given by callables (pyfe3d.solver.analysis)#
The class Analysis receives the callables that compute the force
vectors and the stiffness matrices of a model and runs a linear static
analysis, or a non-linear static analysis with the Newton-Raphson solver of
newton_raphson or the arc-length solvers of arc_length, with
Crisfield’s convergence criterion by default, see convergence. The
optional keyword arguments of the callables are described in
callbacks. With bu, the callables work with the vectors and
matrices of all the degrees-of-freedom, as assembled by the elements of
this package, and FreeDofs restricts them to the free ones and
imposes the prescribed displacements uk.
- class pyfe3d.solver.analysis.Analysis(calc_fext=None, calc_fint=None, calc_kC=None, calc_kG=None, bu=None, uk=None)#
Linear and non-linear static analyses of a model given by callables
The structural model is defined by the callables passed to the constructor, which return the force vectors and the stiffness matrices. The static analysis, linear or non-linear, is run with
static(), whose solution is stored in the attributesincrementsandcs.The non-linear analyses find the solution vectors
cfor which the internal force vectorcalc_fint(c)balances the external force vectorcalc_fext(inc=1.)scaled by the load factor, using the tangent stiffness matrixcalc_kC(c, NLgeom=True) + calc_kG(c, NLgeom=True). With the elements of this package,calc_kCnormally returnsKC0 + KCNLandcalc_kGreturnsKG, both updated atc, andcalc_fintthe vector ofupdate_fint(..., nonlinear=1).The analysis parameters are attributes of this class, described in the following tables together with their default values:
Non-Linear Algorithm
Description
NL_methodstr,'NR'(default) for the Newton-Raphson method, seenewton_raphson._solver_NR(), or'arc_length_riks'and'arc_length_crisfield'for the arc-length methods, seearc_length._solver_arc_length()line_searchbool, activates a safeguarding line-search, for the Newton-Raphson method only, seenewton_raphson._NR_iterations(). Default isFalsemax_iter_line_searchint, maximum number of iterations of the line-search. Default is20modified_NRbool, activates the modified Newton-Raphson method, where the tangent stiffness matrix is not updated at every iteration. Default isFalse, i.e. full Newton-Raphsoncompute_every_nint, ifmodified_NR=True, the tangent stiffness matrix is updated every \(n\) iterations. Default is6kT_initial_statebool, ifmodified_NR=True, tells if the tangent stiffness matrix should be calculated already at the first iteration of the analysis, which is required for example when initial imperfections take place. Otherwise the linear constitutive stiffness matrix is used. Default isTrueIncrementation
Description
initialIncinitial load increment. In the arc-length methods it defines the initial arc-length increment, corresponding to a load factor increment of
initialIncalong the initial tangent. Default is0.1minIncminimum increment; the analysis stops when the load increment (Newton-Raphson) or the arc-length increment (arc-length methods) becomes smaller than
minInc. Default is1.e-4maxIncmaximum load increment, or maximum arc-length increment for the arc-length methods. Default is
1.maxArcLengthmaximum cumulative arc length covered by the arc-length methods, dimensionless. Default is
18Convergence Criteria
Description
convergencestr,'crisfield'(default) for Crisfield’s criterion, the residual scaled with the diagonal of the linear stiffness matrix over the free degrees-of-freedom, or'relative'for the Euclidean norm of the residual, seeconvergencerelTOLtolerance \(\epsilon\) of the relative force imbalance: Crisfield’s \(\zeta \le\)
relTOL, or, with'relative', the norm of the residual force vector smaller thanrelTOLtimes the largest norm between the external and internal force vectors. Not used ifNone. Default is1.e-9, the tight tolerance of Crisfield’s criterion with a consistent tangent, seeconvergence; the same default applies with'relative'absTOLthe convergence is also achieved when the maximum absolute residual force is smaller than this value, which depends on the units of the model. Not used if
None. Default isNonemaxNumItermaximum number of iterations (corrections) of a step; if achieved the increment is reduced. Default is
30too_slow_TOLa step is considered too slow when the smallest residual norm is not reduced by this fraction over the last iterations; the increment is then reduced. Default is
0.005- Parameters:
- calc_fextcallable, optional
calc_fext(inc=1., silent=False), must return a 1-D array with the external force vector. Required for linear and non-linear static analyses. The non-linear solvers call it withinc=1.and scale the returned vector by the load factor. It may declare the optional keyword argumentsc, the current configuration, andlbd, the current load factor, and must then return the load vector of that configuration and load factor for a unit load factor,inc=1., seecallbacks. The linear static analysis never passeslbd.- calc_fintcallable, optional
calc_fint(c, silent=False), must return a 1-D array with the internal force vector for the solution vectorc. Required for non-linear analyses. It may declare the optional keyword argumentinc, which then receives the current load factor, seecallbacks.- calc_kCcallable, optional
calc_kC(c=None, NLgeom=False, silent=False), must return a sparse matrix with the constitutive stiffness matrix. Withc=NoneandNLgeom=Falseit must return the linear stiffness matrix, which also gives the scaling of Crisfield’s criterion, and withNLgeom=Truethe constitutive part of the tangent stiffness matrix atc. Required for linear and non-linear static analyses. It may declare the optional keyword argumentinc, which then receives the current load factor in the calls withNLgeom=True, seecallbacks.- calc_kGcallable, optional
calc_kG(c=None, NLgeom=False, silent=False), must return a sparse matrix with the geometric stiffness matrix atc. It is called withNLgeom=True. Required for non-linear analyses. It may declare the optional keyword argumentinc, which then receives the current load factor, seecallbacks. The sum ofcalc_kCandcalc_kGmay be unsymmetric.- buarray_like or None, optional
Boolean mask of the free degrees-of-freedom, 1-D array of size
N. Withbu, the callables receive and return the vectors and matrices of all theNdegrees-of-freedom, e.g. assembled with the elements of this package, and the solvers work with the free ones only, seeFreeDofs. WithNone, the callables work with the vectors and matrices of the solver, i.e. of the free degrees-of-freedom only, the constrained ones being partitioned out: a null row or column of the stiffness matrices raises an error, seecheck_null_rows_cols(). DefaultNone.- ukarray_like or None, optional
Prescribed displacements for a unit load factor, 1-D array of size
N, used withbu: the displacements of the constrained degrees-of-freedom arelbd*uk[~bu], withlbdthe load factor.Nonefor null prescribed displacements. DefaultNone.
- Attributes:
Methods
static([NLgeom, silent])Linear or non-linear static analysis
Notes
For non-linear analyses, the internal force vector \(\boldsymbol{F}_{int}(\boldsymbol{c})\) must be in equilibrium with the external force vector scaled by the load factor \(\lambda\):
\[\boldsymbol{R} = \boldsymbol{F}_{int}(\boldsymbol{c}) - \lambda \boldsymbol{F}_{ext} = \boldsymbol{0}\]and the tangent stiffness matrix \(\boldsymbol{K}_T = \boldsymbol{K}_C + \boldsymbol{K}_G\), given by the callables
calc_kCandcalc_kG, should be the exact derivative of \(\boldsymbol{F}_{int}\) with respect to \(\boldsymbol{c}\), \(\boldsymbol{K}_T = \partial \boldsymbol{R}/\partial \boldsymbol{c}\), such that the Newton-Raphson iterations, \(\boldsymbol{K}_T \delta \boldsymbol{c} = -\boldsymbol{R}\), converge quadratically ([1], Section 1.2.2, p. 9). The convergence is checked by default with Crisfield’s criterion, seeconvergence.The line-search tries the full step first and only reduces it when it fails a sufficient-decrease test on the residual norm, see
newton_raphson._NR_iterations().The arc length is dimensionless, with displacements scaled by the linear solution for a load factor of 1, such that in the linear regime an arc length of about
sqrt(2)corresponds to a load factor increment of 1, seearc_length._solver_arc_length().Configuration-dependent loads
Configuration-dependent loads, e.g. follower pressures [2], are supported through optional keyword arguments, passed only to the callables that declare them explicitly, see
callbacks:calc_fint(c, inc=lbd),calc_kC(c, NLgeom=True, inc=lbd)andcalc_kG(c, NLgeom=True, inc=lbd)receive the current load factor, such thatcalc_fintmay contain the configuration-dependent part of the load, scaled byinc, andcalc_kC + calc_kGits derivative, the load stiffness matrix.calc_fext(inc=1., c=c)must return the load vector of the configurationcfor a unit load factor, minus the derivative of the residual with respect to the load factor, \(-\partial \boldsymbol{R}/\partial \lambda\), used by the arc-length solvers.calc_fext(inc=1., c=c, lbd=lbd)also receives the current load factor when it declareslbd, for a derivative \(\partial \boldsymbol{R}/\partial \lambda\) that depends on the load factor, e.g. prescribed displacements imposed exactly as linear constraints, where the reference vectorcalc_fext(inc=1.)may be null. The solvers then use \(-\partial \boldsymbol{R}/\partial \lambda\) for the displacement scale of the arc-length methods, for the predictor of the first Newton-Raphson increment and as a reference of the convergence criteria. The linear static analysis never passeslbd.
The tangent stiffness matrix may then be unsymmetric, which the solvers support, since they use LU factorizations. With
buanduk, the prescribed displacements are imposed withlbd, seeFreeDofs.References
[1]Crisfield, M. A., Non-linear Finite Element Analysis of Solids and Structures, Volume 1: Essentials, John Wiley & Sons, Chichester, 1991.
[2]Schweizerhof, K. and Ramm, E., Displacement dependent pressure loads in nonlinear finite element analyses, Computers & Structures, 18(6), 1099-1114, 1984.
- static(NLgeom=False, silent=False)#
Linear or non-linear static analysis
The linear analysis solves the system of the linear stiffness matrix
calc_kC()and the external force vectorcalc_fext()usingsolve(). When the load depends on the configuration, i.e.calc_fextdeclares the keyword argumentc, seecallbacks, the load is evaluated in the current configuration and corrected by iterations that reuse one factorization of the linear stiffness matrix, starting from the solution of the reference load, until the convergence criterion is satisfied, seecheck_convergence(), ormaxNumIteriterations are done; a warning is printed when they do not converge and the last iterate is returned. The non-linear analysis uses the solver selected by theNL_methodattribute.- Parameters:
- NLgeombool, optional
Whether a non-linear analysis is performed. Default
False.- silentbool, optional
Whether the log messages are suppressed. Default
False.
- Returns:
- incrementslist
Load factors of the converged increments, dimensionless. A linear analysis returns
[1.]. Non-linear analyses finish at a load factor of exactly1.unless they are stopped earlier, see the documentation of each solver.- cslist
Solution vectors of the converged increments, 1-D arrays, of size
Nwithbu, including the prescribed displacements.
- Raises:
- ValueError
When
NLgeom=Trueand theNL_methodattribute is not'NR','arc_length_riks'or'arc_length_crisfield', or whenukis given withoutbu.- numpy.linalg.LinAlgError
When the linear stiffness matrix of the solver
calc_kC(), withbuthat of the free degrees-of-freedom, has a null row or column, seecheck_null_rows_cols(), or when it is exactly singular. A singular tangent stiffness matrix during the non-linear iterations does not raise, it stops the iterations, see the documentation of each solver.
Notes
The linear analysis solves \(\boldsymbol{K}_{C0} \boldsymbol{c} = \boldsymbol{F}_{ext}\); with
buanduk, \(\boldsymbol{K}_{{C0}_{ff}} \boldsymbol{c} = \boldsymbol{F}_{{ext}_f} - \boldsymbol{K}_{{C0}_{fk}} \bar{\boldsymbol{u}}_k\). When the load depends on the configuration, the structure is still geometrically linear but the load is evaluated in the current configuration, \(\boldsymbol{K}_{C0} \boldsymbol{c} = \boldsymbol{F}_{ext}(\boldsymbol{c})\), which is solved by the load correction iterations\[\boldsymbol{c}_{k+1} = \boldsymbol{c}_k + \boldsymbol{K}_{C0}^{-1}(\boldsymbol{F}_{ext}(\boldsymbol{c}_k) - \boldsymbol{K}_{C0} \boldsymbol{c}_k)\]starting from \(\boldsymbol{c}_0 = \boldsymbol{K}_{C0}^{-1} \boldsymbol{F}_{ext}\), the solution of the reference load
calc_fext(), with \(\boldsymbol{F}_{ext}(\boldsymbol{c}_k)\) given bycalc_fext(inc=1., c=c_k). This is a fixed-point iteration without the load stiffness in the iteration matrix. For a follower load whose force vector is affine in \(\boldsymbol{c}\), \(\boldsymbol{F}(\boldsymbol{c}) = \boldsymbol{F}_0 - \boldsymbol{K}_F \boldsymbol{c}\), this is the solution of \((\boldsymbol{K}_{C0} + \boldsymbol{K}_F) \boldsymbol{c} = \boldsymbol{F}_0\), the error being multiplied by \(-\boldsymbol{K}_{C0}^{-1} \boldsymbol{K}_F\) at each iteration, whose spectral radius is \(1/\min|\lambda|\) over the load multipliers \(\lambda\) of \((\boldsymbol{K}_{C0} + \lambda \boldsymbol{K}_F) \boldsymbol{u} = \boldsymbol{0}\), including the negative and complex ones; beyond the load of the smallest \(|\lambda|\) the iterations diverge.
- class pyfe3d.solver.analysis.FreeDofs(calc_fext, calc_fint, calc_kC, calc_kG, bu, uk=None)#
Callables of the free degrees-of-freedom, with prescribed displacements imposed exactly
Wraps the callables of the full model, which receive and return the vectors and matrices of all the
Ndegrees-of-freedom, such that the solvers see the free degrees-of-freedombuonly. The displacements of the constrained degrees-of-freedom arelbd*uk[~bu], prescribed and proportional to the load factorlbd, or null whenukisNone. Used byAnalysiswhenbuis given.The wrapped
calc_fint,calc_kCandcalc_kGalways declareinc, which they need to build the full configuration, and pass it to the callables of the full model only when they declare it, seecallbacks. The wrappedcalc_fextdeclarescwhen the one of the full model declares it or when displacements are prescribed, andlbdwhen the one of the full model declares it or when displacements are prescribed.- Parameters:
- calc_fext, calc_fint, calc_kC, calc_kGcallable
The callables of the full model, see
Analysis.- buarray_like
Boolean mask of the free degrees-of-freedom, 1-D array of size
N.- ukarray_like or None, optional
Prescribed displacements for a unit load factor, 1-D array of size
Nwhose entries at the free degrees-of-freedom are ignored, of the dimension of the displacements and rotations.Nonefor null prescribed displacements. DefaultNone.
- Attributes:
- free, knownnp.ndarray
Indices of the free and of the constrained degrees-of-freedom.
- prescribedbool
Whether a prescribed displacement is not null.
Methods
calc_fint(c[, silent, inc])Internal force vector of the free degrees-of-freedom
calc_kC([c, NLgeom, silent, inc])Constitutive stiffness matrix of the free degrees-of-freedom
calc_kG([c, NLgeom, silent, inc])Geometric stiffness matrix of the free degrees-of-freedom
full(c, lbd)Configuration of the full model
linear_fext([c])Load vector of the linear static analysis, at a unit load factor
- Raises:
- ValueError
When
buis not a boolean array, or whenukdoes not have the size ofbu.
Notes
With \(f\) the free and \(k\) the constrained degrees-of-freedom, the configuration of the full model is
\[\begin{split}\boldsymbol{u} = \boldsymbol{Z} \boldsymbol{c} + \lambda \boldsymbol{u}_k, \qquad \boldsymbol{Z} = \begin{bmatrix} \boldsymbol{I}_{ff} \\ \boldsymbol{0}_{kf} \end{bmatrix}\end{split}\]the null-space reduction of the constraints \(\boldsymbol{u}_k = \lambda \bar{\boldsymbol{u}}_k\) imposed exactly, see
callbacks. The solvers see the reduced residual \(\boldsymbol{R}_f = \boldsymbol{F}_{{int}_f}(\boldsymbol{u}) - \lambda \boldsymbol{F}_{{ext}_f}\), its Jacobian \(\boldsymbol{K}_{T_{ff}}\) and\[-\frac{\partial \boldsymbol{R}_f}{\partial \lambda} = \boldsymbol{F}_{{ext}_f} - \boldsymbol{K}_{T_{fk}} \bar{\boldsymbol{u}}_k\]with \(\boldsymbol{K}_T\) at the current configuration and load factor, reused from the last evaluation of the tangent stiffness matrix when it was done at the same configuration and load factor. The norms of the convergence criteria are thus over the free degrees-of-freedom only. The reaction forces are \(\boldsymbol{F}_{{int}_k}(\boldsymbol{u}) - \lambda \boldsymbol{F}_{{ext}_k}\), given by the callables of the full model at a converged configuration.
- calc_fint(c, silent=True, inc=1.0)#
Internal force vector of the free degrees-of-freedom
- Parameters:
- cnp.ndarray
Configuration of the free degrees-of-freedom.
- silentbool, optional
Passed to the callable of the full model. Default
True.- incfloat, optional
Load factor, dimensionless. Default
1..
- Returns:
- fintnp.ndarray
calc_fintof the full model atfull(), restricted to the free degrees-of-freedom.
- calc_kC(c=None, NLgeom=False, silent=True, inc=1.0)#
Constitutive stiffness matrix of the free degrees-of-freedom
- Parameters:
- cnp.ndarray or None, optional
Configuration of the free degrees-of-freedom.
Nonegives the linear stiffness matrix. DefaultNone.- NLgeombool, optional
Passed to the callable of the full model;
Falsegives the linear stiffness matrix. DefaultFalse.- silentbool, optional
Passed to the callable of the full model. Default
True.- incfloat, optional
Load factor, dimensionless. Default
1..
- Returns:
- kCsparse_matrix
Free-free block of
calc_kCof the full model.
- calc_kG(c=None, NLgeom=False, silent=True, inc=1.0)#
Geometric stiffness matrix of the free degrees-of-freedom
- Parameters:
- cnp.ndarray or None, optional
Configuration of the free degrees-of-freedom. Default
None.- NLgeombool, optional
Passed to the callable of the full model. Default
False.- silentbool, optional
Passed to the callable of the full model. Default
True.- incfloat, optional
Load factor, dimensionless. Default
1..
- Returns:
- kGsparse_matrix
Free-free block of
calc_kGof the full model.
- config_dependent#
whether the external load of the full model depends on the configuration
- full(c, lbd)#
Configuration of the full model
- Parameters:
- cnp.ndarray
Configuration of the free degrees-of-freedom.
- lbdfloat
Load factor, dimensionless.
- Returns:
- unp.ndarray
Configuration of all the degrees-of-freedom, 1-D array of size
N, withlbd*ukat the constrained ones.
- linear_fext(c=None)#
Load vector of the linear static analysis, at a unit load factor
- Parameters:
- cnp.ndarray or None, optional
Configuration of the free degrees-of-freedom, passed to the
calc_fextof the full model when it declaresc. DefaultNone.
- Returns:
- fnp.ndarray
\(\boldsymbol{F}_{{ext}_f} - \boldsymbol{K}_{{C0}_{fk}} \bar{\boldsymbol{u}}_k\), with \(\boldsymbol{K}_{C0}\) the linear stiffness matrix of the full model.