<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Tue, Aug 21, 2018 at 10:00 PM Ellen M. Price <<a href="mailto:ellen.price@cfa.harvard.edu">ellen.price@cfa.harvard.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi PETSc users,<br>
<br>
I'm having trouble applying SNES to a new problem I'm working on. I'll<br>
try to be as complete as possible but can't post the full code because<br>
it's ongoing research and is pretty long anyway.<br>
<br>
The nonlinear problem arises from trying to solve a set of two coupled<br>
ODEs using a Galerkin method. I am using Mathematica to generate the<br>
objective function to solve and the Jacobian, so I *think* I can rule<br>
out human error on that front.<br>
<br>
There are four things I can easily change:<br>
<br>
- number of DMDA grid points N (I've tried 100 and 1000)<br>
- preconditioner (I've tried LU and SVD, LU appears to work better, and<br>
SVD is too slow for N = 1000)<br>
- linear solver (haven't played with this much, but sometimes smaller<br>
tolerances work better)<br>
- nonlinear solver (what I'm having trouble with)<br>
<br>
Trying different solvers should, as far as I'm aware, give comparable<br>
answers, but that's not the case here. NEWTONTR works best of the ones<br>
I've tried, but I'm suspicious that the function value barely decreases<br>
before SNES "converges" -- and none of the options I've tried changing<br>
seem to affect this, as it just finds another reason to converge without<br>
making any real progress. For example:<br>
<br>
  0 SNES Function norm 7.197788479418e+00<br>
    0 KSP Residual norm 1.721996766619e+01<br>
    1 KSP Residual norm 5.186021549059e-14<br>
  Linear solve converged due to CONVERGED_STEP_LENGTH iterations 1<br></blockquote><div><br></div><div>This makes no sense. LU should converge due to atol or rtol. Send the output of</div><div><br></div><div>  -snes_view -snes_monitor -snes_converged_reason -ksp_monitor_true_residual -ksp_converged_reason</div><div><br></div><div>  Thanks,</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">
  1 SNES Function norm 7.197777674987e+00<br>
    0 KSP Residual norm 3.296112185897e+01<br>
    1 KSP Residual norm 2.713415432045e-13<br>
  Linear solve converged due to CONVERGED_STEP_LENGTH iterations 1<br>
.....<br>
 50 SNES Function norm 7.197376803542e+00<br>
    0 KSP Residual norm 6.222518656302e+02<br>
    1 KSP Residual norm 9.630659996504e-12<br>
  Linear solve converged due to CONVERGED_STEP_LENGTH iterations 1<br>
 51 SNES Function norm 7.197376803542e+00<br>
Nonlinear solve converged due to CONVERGED_SNORM_RELATIVE iterations 50<br>
<br>
I've tried everything I can think of and the FAQ suggestions, including<br>
non-dimensionalizing the problem; I observe the same behavior either<br>
way. The particularly strange thing I can't understand is why some of<br>
the SNES methods fail outright, after just one iteration (NCG, NGMRES,<br>
and others) with DIVERGED_DTOL. Unless I've misunderstood, it seems<br>
like, for the most part, I should be able to substitute in one method<br>
for another, possibly adjusting a few parameters along the way.<br>
Furthermore, the default method, NEWTONLS, diverges with<br>
DIVERGED_LINE_SEARCH, which I'm not sure how to debug.<br>
<br>
So the only viable method is NEWTONTR, and that doesn't appear to<br>
"really" converge. Any suggestions for further things to try are<br>
appreciated. My current options are:<br>
<br>
-pc_type lu -snes_monitor -snes_converged_reason -ksp_converged_reason<br>
-snes_max_it 10000 -ksp_monitor -snes_type newtonls<br>
<br>
Thanks in advance,<br>
Ellen Price<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>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><br></div><div><a href="http://www.caam.rice.edu/~mk51/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div>