Calculating condition number in a nonlinear problem

In addition to @dokken’s comment, you can use a NewtonSolver and corresponding implementation of a NonlinearProblem to get the linearised operator at each Newton iteration. This is probably a good spot to compute (or estimate) the condition number. See, e.g. here.

To clarify: in each Newton iteration we compute updates to the estimate of our solution given some known initial guess u^{0}_h

u^{m+1}_h = u^{m}_h + \delta u^m_h \quad m = 0, 1, 2, \ldots.

The update \delta u^m_h is the solution of the following system: find \delta u^m_h \in V^h such that

J_u (\delta u^{m}_h; u^{m}_h, v) = - F(u^{m}_h, v) \quad \forall v \in V^h

where F(u, v) is the residual formulation, J_u = F^\prime(u, v) is its Gateaux derivative and V^h is some appropriate finite element space.

Note here it’s the form J_u(\cdot; \cdot, \cdot) which is bilinear (\delta u^m_h is unknown and u^m_h is known) and therefore its discretisation by finite elements yields the underlying linear operator. To write lhs(F) as in your code does not make sense since the residual is a linear form (and therefore a vector).

2 Likes