<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Jan 18, 2014 at 1:46 PM, Que Cat <span dir="ltr"><<a href="mailto:quecat001@gmail.com" target="_blank">quecat001@gmail.com</a>></span> wrote:</div>
<div class="gmail_quote">Dear Petsc-Users,<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>I debug my code. I solve the small linear system using KSP. </div>
<div>The matrix is:</div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>row 0: (0, -123354) (1, 6.92922e-310) (2, 123354) (3, 1.38582e-309) </div>
</div><div><div>row 1: (0, 1.3858e-309) (1, 91156.6) (2, 6.92901e-310) (3, 91156.6) </div></div><div><div>row 2: (0, 8768.96) (1, 2.47033e-323) (2, -171955) (3, 1.02212e-316) (4, 163186) (5, 0) </div></div><div><div>
row 3: (0, 0) (1, -59201.7) (2, 0) (3, 156037) (4, 0) (5, 93996.1) </div></div><div><div>row 4: (2, 13422.8) (3, 0) (4, -13422.8) (5, 0) </div></div><div><div>row 5: (2, 0) (3, -58000.3) (4, 0) (5, 59201.7) </div>
</div></blockquote></div></blockquote><div><br></div><div>1) Get rid of the entries that are 1e-300 or below</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>
</div></blockquote><div>the RHS vector:</div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>-9115.66</div></div><div><div>-17760.5</div></div><div><div>-425.926</div></div><div><div>-35400.9</div>
</div><div><div>9541.58</div></div><div><div>-17520.2</div></div></blockquote>the solution I got was:<blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>-2.00943e+52</div></div><div><div>-1.17929e+18</div>
</div><div><div>-2.00943e+52</div></div><div><div>7.121e+16</div></div><div><div>-2.00943e+52</div></div><div><div>-7.0943e+16</div></div></blockquote><div><div>I checked with matlab and I got the totally different solution. I guess there is something wrong with the linear solver I set up as follow:</div>
</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><div> KSPSetOperators(ksp, mat_A, mat_A, SAME_NONZERO_PATTERN);</div></div></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px">
// set the linear solve options <br> KSPSetType(ksp, KSPGMRES);<br> KSPGMRESSetRestart(ksp, 100);<br> // set preconditioning options <br> KSPGetPC(ksp, &pc);<br> PCSetType(pc, PCBJACOBI);<br> KSPSetFromOptions(ksp);<br>
// Solve the linear system<div><div><div> KSPSolve(ksp,vec_rhs,vec_sol);</div></div></div></blockquote>Could anyone give me a suggestion where should be the source of error? Thank you!</div></blockquote><div><br></div>
<div>2) Always start with -pc_type lu -ksp_type preonly</div><div><br></div><div>3) It appears that your matrix is close to singular (LU will check)</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><span class="HOEnZb"><font color="#888888"><div>Que<br><div>
<div><br></div></div></div></font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener
</div></div>