<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi Yingjie,<div><br></div><div>For finite difference method, there are a lot of example in PETSc. For instance, <a href="https://www.mcs.anl.gov/petsc/petsc-current/src/ksp/ksp/examples/tutorials/ex29.c.html">https://www.mcs.anl.gov/petsc/petsc-current/src/ksp/ksp/examples/tutorials/ex29.c.html</a></div><div><br></div><div>For linear eigenvalue problems, there is a list of examples at <a href="http://slepc.upv.es/documentation/current/src/eps/examples/tutorials/index.html">http://slepc.upv.es/documentation/current/src/eps/examples/tutorials/index.html</a></div><div><br></div><div>Before you go to implement your inver power algorithm, I would like to suggest you go though PETSc manual and SLEPc manual. <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manual.pdf">https://www.mcs.anl.gov/petsc/petsc-current/docs/manual.pdf</a> and <a href="http://slepc.upv.es/documentation/slepc.pdf">http://slepc.upv.es/documentation/slepc.pdf</a></div><div>SLEPc has both nonlinear and linear inverse power iteration methods, and you can pick any version you want.</div><div><br></div><div>It is a good idea to have big picture before you do anything using PETSc or SLEPc. </div><div><br></div><div>Fande,</div><div><br><div class="gmail_quote"><div dir="ltr">On Wed, Sep 26, 2018 at 8:17 PM Yingjie Wu <<a href="mailto:yjwu16@gmail.com">yjwu16@gmail.com</a>> wrote:<br></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">Thank you, Fande.<div><p style="margin:0px;white-space:pre-wrap">I've seen you in moose usergroup before.</p><p style="margin:0px;white-space:pre-wrap"><br></p><p style="margin:0px;white-space:pre-wrap">I've just learned about SLEPC, and I wonder if I want to do neutron eigenvalue calculations and use finite difference to discrete grids, would it be difficult to implement it in SLEPC? Is there such an example(finite difference + linear eigenvalue)?Because I don't know much about finite element.Or am I still using a loop of KSP in PETSc?I'm a newcomer to petsc, please give me some advice</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><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr">Fande Kong <<a href="mailto:fdkong.jd@gmail.com" target="_blank">fdkong.jd@gmail.com</a>> 于2018年9月27日周四 上午12:25写道:<br></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"><div dir="ltr">I have implemented this algorithm in SLEPC. Take a look at this example <a href="http://slepc.upv.es/documentation/current/src/eps/examples/tutorials/ex34.c.html" target="_blank">http://slepc.upv.es/documentation/current/src/eps/examples/tutorials/ex34.c.html</a></div><div dir="ltr"><br></div><div>The motivation of the algorithm is also for neutron calculations (a moose-based application). </div><div><br></div><div>Fande,</div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Sep 26, 2018 at 10:02 AM Yingjie Wu <<a href="mailto:yjwu16@gmail.com" target="_blank">yjwu16@gmail.com</a>> wrote:<br></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"><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_3521132741292334636m_-2346559023393431973m_3033032894627494167gmail-m_-2660186079763496000gmail-15" align="justify" style="text-align:justify"><font face="arial, helvetica, sans-serif"><span style="letter-spacing:0pt">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>
</blockquote></div>
</blockquote></div>
</blockquote></div></div></div></div></div></div></div>