<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div> I think there is likely a problem somewhere along the line in the libraries or how you are using them that causes the problem. You can run with a small problem and explicit form the inner operators and use direct solvers for the inner inverses to see what happens to the convergence of the computation of the eigenvalues. You can also use -ksp_view_eigenvalues_explicit and things like -ksp_view_mat_explicit and -ksp_view_preconditioned_operator_explicit to dump representations of the operators (for small problems) and load them in Matlab to get the eigenvalues and see if they match what the PETSc eigenvalue computation gives.<div class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Nov 11, 2021, at 4:39 AM, Vladislav Pimanov <<a href="mailto:Vladislav.Pimanov@skoltech.ru" class="">Vladislav.Pimanov@skoltech.ru</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta charset="UTF-8" class=""><div id="divtagdefaultwrapper" dir="ltr" style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif;" class=""><p style="margin-top: 0px; margin-bottom: 0px;" class=""></p><div style="margin-top: 0px; margin-bottom: 0px; font-family: Calibri, Helvetica, sans-serif, Helvetica, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;" class="">Dear Barry, </div><div style="margin-top: 0px; margin-bottom: 0px; font-family: Calibri, Helvetica, sans-serif, Helvetica, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;" class=""><br class=""></div><div style="margin-top: 0px; margin-bottom: 0px; font-family: Calibri, Helvetica, sans-serif, Helvetica, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;" class="">Let S = B A^{-1} B^T be the Schur complement, and \hat{S} = B diag(A)^{-1} B^T denotes the preconditioner.</div><div style="margin-top: 0px; margin-bottom: 0px; font-family: Calibri, Helvetica, sans-serif, Helvetica, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;" class="">I also tried <span style="font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; font-size: 16px;" class=""><i class="">KSPComputeExtremeSingularValues<span class="Apple-converted-space"> </span></i>for</span> rtol(A) = rtol(\hat{S}) = 1e-14 as you suggested. However, the results did not change much compared to rtol(A) = rtol(S) = rtol(\hat{S}). </div><div style="margin-top: 0px; margin-bottom: 0px; font-family: Calibri, Helvetica, sans-serif, Helvetica, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;" class=""><br class=""></div><div style="margin-top: 0px; margin-bottom: 0px;" class="">Additionally, I checked the identity preconditioner instead of \hat{S}. In this case, the method firstly seems to converge when reaching rtol(S)=1e-6, but then, with a further decrease of rtol(S), it begins to diverge slightly<span class="Apple-converted-space"> </span><span class="">though</span>.</div><div style="margin-top: 0px; margin-bottom: 0px; font-family: Calibri, Helvetica, sans-serif, Helvetica, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;" class=""><span class=""><br class=""></span></div><div style="margin-top: 0px; margin-bottom: 0px; font-family: Calibri, Helvetica, sans-serif, Helvetica, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;" class="">I will try generalised EVP.</div><div style="margin-top: 0px; margin-bottom: 0px; font-family: Calibri, Helvetica, sans-serif, Helvetica, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;" class=""><br class=""></div><div style="margin-top: 0px; margin-bottom: 0px; font-family: Calibri, Helvetica, sans-serif, Helvetica, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;" class="">Thanks,</div><div style="margin-top: 0px; margin-bottom: 0px; font-family: Calibri, Helvetica, sans-serif, Helvetica, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;" class="">Vlad</div><br class=""><p style="margin-top: 0px; margin-bottom: 0px;" class=""></p></div><hr tabindex="-1" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; display: inline-block; width: 1110.328125px;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class=""></span><div id="divRplyFwdMsg" dir="ltr" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><font face="Calibri, sans-serif" style="font-size: 11pt;" class=""><b class="">От:</b><span class="Apple-converted-space"> </span>Barry Smith <<a href="mailto:bsmith@petsc.dev" class="">bsmith@petsc.dev</a>><br class=""><b class="">Отправлено:</b><span class="Apple-converted-space"> </span>10 ноября 2021 г. 17:45:55<br class=""><b class="">Кому:</b><span class="Apple-converted-space"> </span>Vladislav Pimanov<br class=""><b class="">Копия:</b><span class="Apple-converted-space"> </span><a href="mailto:petsc-users@mcs.anl.gov" class="">petsc-users@mcs.anl.gov</a><br class=""><b class="">Тема:</b><span class="Apple-converted-space"> </span>Re: [petsc-users] How to compute the condition number of SchurComplementMat preconditioned with PCSHELL.</font><div class=""> </div></div><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><div class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div class=""><div dir="ltr" class=""><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="ltr" class=""><div id="gmail-m_-9053906504632661544divtagdefaultwrapper" dir="ltr" class="" style="font-size: 12pt; font-family: Calibri, Helvetica, sans-serif;"><div class="" style="margin-top: 0px; margin-bottom: 0px;">P is a diffusion matrix, which itself is inverted by <i class="">KSPCG</i>)</div></div></div></blockquote></div></div></div></div></blockquote><div class=""><br class=""></div>This worries me. Unless solved to full precision the action of solving with CG is not a linear operator in the input variable b, this means that the action of your Schur complement is not a linear operator and so iterative eigenvalue algorithms may not work correctly (even if the linear system seems to be converging). <div class=""><br class=""></div><div class="">I suggest you try a KSP tolerance of 10^-14 for the inner KSP solve when you attempt the eigenvalue computation.</div><div class=""><br class=""></div><div class="">Barry</div><div class=""><br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Nov 10, 2021, at 9:09 AM, Vladislav Pimanov <<a href="mailto:Vladislav.Pimanov@skoltech.ru" class="">Vladislav.Pimanov@skoltech.ru</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><div id="divtagdefaultwrapper" dir="ltr" class="" style="font-size: 12pt; font-family: Calibri, Helvetica, sans-serif;"><div style="margin-top: 0px; margin-bottom: 0px;" class="">Great thanks, Matt!</div><div style="margin-top: 0px; margin-bottom: 0px;" class="">The second option is what I was looking for.</div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></div><div style="margin-top: 0px; margin-bottom: 0px;" class="">Best Regards,</div><div style="margin-top: 0px; margin-bottom: 0px;" class="">Vlad</div></div><hr tabindex="-1" class="" style="display: inline-block; width: 1100.53125px;"><div id="divRplyFwdMsg" dir="ltr" class=""><font face="Calibri, sans-serif" class="" style="font-size: 11pt;"><b class="">От:</b><span class="Apple-converted-space"> </span>Matthew Knepley <<a href="mailto:knepley@gmail.com" class="">knepley@gmail.com</a>><br class=""><b class="">Отправлено:</b><span class="Apple-converted-space"> </span>10 ноября 2021 г. 16:45:00<br class=""><b class="">Кому:</b><span class="Apple-converted-space"> </span>Vladislav Pimanov<br class=""><b class="">Копия:</b><span class="Apple-converted-space"> </span><a href="mailto:petsc-users@mcs.anl.gov" class="">petsc-users@mcs.anl.gov</a><br class=""><b class="">Тема:</b><span class="Apple-converted-space"> </span>Re: [petsc-users] How to compute the condition number of SchurComplementMat preconditioned with PCSHELL.</font><div class=""> </div></div><div class=""><div dir="ltr" class=""><div dir="ltr" class="">On Wed, Nov 10, 2021 at 8:42 AM Vladislav Pimanov <<a href="mailto:Vladislav.Pimanov@skoltech.ru" class="">Vladislav.Pimanov@skoltech.ru</a>> wrote:<br class=""></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="ltr" class=""><div id="gmail-m_-9053906504632661544divtagdefaultwrapper" dir="ltr" class="" style="font-size: 12pt; font-family: Calibri, Helvetica, sans-serif;"><div style="margin-top: 0px; margin-bottom: 0px;" class="">Dear PETSc community,</div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></div><div class=""><br class="webkit-block-placeholder"></div><span class="">I wonder if you could give me a hint on how to compute the condition number of a preconditioned matrix in a proper way.</span><div style="margin-top: 0px; margin-bottom: 0px;" class="">I have a <i class="">MatSchurComplement</i><span class="Apple-converted-space"> </span>matrix S and a preconditioner P of the type<span class="Apple-converted-space"> </span><i class="">PCSHELL</i><span class="Apple-converted-space"> </span>(P is a diffusion matrix, which itself is inverted by<span class="Apple-converted-space"> </span><i class="">KSPCG</i>).</div><div style="margin-top: 0px; margin-bottom: 0px;" class="">I tried to compute the condition number of P^{-1}S "for free" during the outer PCG procedure using <span class=""><i class="">KSPComputeExtremeSingularValues()</i><span class="Apple-converted-space"> </span>routine.</span></div><div style="margin-top: 0px; margin-bottom: 0px;" class="">Unfortunately, \sigma_min does not converge even if the solution is computed with very high precision.</div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><span class="">I also looked at SLEPc interface, but did not realised how PC should be included.</span><br class=""></div><div class=""><br class="webkit-block-placeholder"></div></div></div></blockquote><div class="">You can do this at least two ways:</div><div class=""><br class=""></div><div class=""> 1) Make a MatShell for P^{-1} S. This is easy, but you will not be able to use any factorization-type PC on that matrix.</div><div class=""><br class=""></div><div class=""> 2) Solve instead the generalized EVP, S x = \lambda P x. Since you already have P^{-1}, this should work well.</div><div class=""><br class=""></div><div class=""> Thanks,</div><div class=""><br class=""></div><div class=""> Matt</div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="ltr" class=""><div id="gmail-m_-9053906504632661544divtagdefaultwrapper" dir="ltr" class="" style="font-size: 12pt; font-family: Calibri, Helvetica, sans-serif;"><div style="margin-top: 0px; margin-bottom: 0px;" class="">Thanks!</div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></div><div style="margin-top: 0px; margin-bottom: 0px;" class="">Sincerely,</div><div style="margin-top: 0px; margin-bottom: 0px;" class="">Vladislav Pimanov</div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></div></div></div></blockquote></div><br clear="all" class=""><div class=""><br class=""></div>--<span class="Apple-converted-space"> </span><br class=""><div dir="ltr" class="gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class="">What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br class="">-- Norbert Wiener</div><div class=""><br class=""></div><div class=""><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank" class="">https://www.cse.buffalo.edu/~knepley/</a></div></div></div></div></div></div></div></div></div></div></div></blockquote></div></div></div></div></blockquote></div><br class=""></div></body></html>