<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><font face="tahoma, sans-serif">Dear Petsc developer: </font></div><div dir="ltr"><font face="tahoma, sans-serif">Hi, </font></div><div dir="ltr"><p class="gmail-m_-2660186079763496000gmail-15" align="justify" style="text-align:justify"><font face="arial, helvetica, sans-serif"><span style="letter-spacing:0pt;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial">Thank you very much for your previous reply, they</span></font><span style="white-space:pre-wrap"> really helped me a lot.</span></p><p style="margin:0px;white-space:pre-wrap">I've been doing neutron calculations recently, and I want to use the power Iteration method to calculate the neutron flux, essentially to solve linear equations, but after each solution is done, a scalar <b>K</b> is updated to form a new right end term <b>b</b>, and the next linear equation system is solved until the convergence criterion is satisfied. The flow of the source iteration algorithm is as follows:</p><p style="margin:0px;white-space:pre-wrap"><br></p><p style="margin:0px"><span style="white-space:pre-wrap">1: <b>Φ</b>(0) = arbitrary nonzero vector
2: K(0) = arbitrary nonzero constant
3: <b>for</b> n = 1; 2; 3; ::: do
4: <b>b </b>= 1 / K(n-1) *F *</span>
<span style="white-space:pre-wrap"> Φ(n-1)</span> <span style="white-space:pre-wrap">
5: </span><span style="white-space:pre-wrap"><b>Φ</b>(n) * M</span> <span style="white-space:pre-wrap"> = <b>b</b>
6: K</span><span style="white-space:pre-wrap">(n) = k(n-1)* </span><span style="white-space:pre-wrap">(F</span> *
<span style="white-space:pre-wrap"><b>Φ</b>(n)</span> <span style="white-space:pre-wrap">,F</span>
<span style="white-space:pre-wrap"><b>Φ</b>(n)</span> <span style="white-space:pre-wrap">) / </span><span style="white-space:pre-wrap">(F</span>
<span style="white-space:pre-wrap"><b>Φ</b>(n-1)</span> ,<span style="white-space:pre-wrap">F</span>
<span style="white-space:pre-wrap"><b>Φ</b>(n-1)</span> <span style="white-space:pre-wrap">)</span></p><p style="margin:0px"><span style="white-space:pre-wrap">7: check convergence of eigenvalue and eigenvector
8: <b>end for</b></span><br></p><p style="margin:0px"><span style="white-space:pre-wrap"><b><br></b></span></p><p style="margin:0px"><span style="white-space:pre-wrap">(F , M are the coefficient matrix.)</span></p><p style="margin:0px"><span style="white-space:pre-wrap"><b><br></b></span></p><p style="margin:0px;white-space:pre-wrap">The difficulty is that I need to set up an extra loop to regulate KSP. Does PETSc have such an example? How do I implement this algorithm in PETsc? Please tell me the key functions if possible.</p><p style="margin:0px;white-space:pre-wrap"><br></p><p style="margin:0px;white-space:pre-wrap">Thanks,</p><p style="margin:0px;white-space:pre-wrap">Yingjie</p><p style="margin:0px"><span style="white-space:pre-wrap"><b><br></b></span></p></div></div></div></div>