<div dir="ltr"><div class="gmail_default" style="font-family:courier new,monospace"><span style="font-family:arial">On Mon, Jan 20, 2014 at 11:39 AM, Dmitry Karpeyev </span><span dir="ltr" style="font-family:arial"><<a href="mailto:karpeev@mcs.anl.gov" target="_blank">karpeev@mcs.anl.gov</a>></span><span style="font-family:arial"> wrote:</span><br>
</div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Forwarding this to petsc-dev because of (*) below.</div>
<div><br></div>The behavior of -snes_check_jacobian, is, unfortunately, controlled by several options with different prefixes.<div>This is because a mix of PETSc objects are involved.  In particular, we have -snes_test_xxx and -mat_fd_xxx determining the choice of the differencing parameter h in J(u)v ~ (F(u+hv) - F(u))/h.</div>


<div><div>In particular, -mat_fd_type ds|wp controls the order of magnitude of h:</div><div>(1) wp uses h = (1+||u||)*epsilon,</div><div>(2) ds (default) uses h = u_j*epsilon, where j is the column of the Jacobian being computed (i.e., v = e_j).  </div>


<div><br></div><div>Furthermore, epsilon is controlled by -snes_test_err (and no programmatic option?).   </div><div>By default epsilon is the square root of the machine epsilon. However, if h ends up being too small (< 1e-16, which </div>


<div>generally should only possible with -mat_fd_type ds), then h = 0.1*sign(u_j)*epsilon is used. </div><div><br></div><div>(*) Maybe control of -snes_check_jacobian, -snes_test (do we need this to be separate from -snes_check_jacobian?  maybe this can be a suboption that causes an early exit from the solve?), and -mat_fd can be made more consistent?<br>


</div><div><br></div><div>David, are you computing the Jacobian at u = 0? Then h = 0.1*epsilon, and the differenced residual should be h^2/h = (0.01*machine_epsilon)/(0.1*sqrt_machine_epsilon) and should evaluate to zero, it seems to me.  </div>
</div></div></blockquote><div><div class="gmail_default" style="font-family:'courier new',monospace">​Yes, I am.  Let me double check the code so that something else is not kicking in...</div><div class="gmail_default" style="font-family:'courier new',monospace">
<br></div><div class="gmail_default" style="font-family:'courier new',monospace">--</div><div class="gmail_default" style="font-family:'courier new',monospace">David​</div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div><span class="HOEnZb"><font color="#888888">

<div><br></div><div>Dmitry.</div><div><br></div></font></span></div></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div class="im">On Mon, Jan 20, 2014 at 10:48 AM, Andrs, David <span dir="ltr"><<a href="mailto:david.andrs@inl.gov" target="_blank">david.andrs@inl.gov</a>></span> wrote:<br>


</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div><div class="im">
<div dir="ltr">
<div style="font-family:courier new,monospace">Is there a PETSc option to control the finite differencing parameter for -snes_check_jacobian?</div>
<div style="font-family:courier new,monospace"><br>
</div>
<div style="font-family:courier new,monospace">The reason why I ask is that if I have a term like: u^2 (u is the velocity), then the FD value for this entry is something like 1e-5, but my exact one is correctly zero. Then the difference
 from PETSc is rather larger then 1e-8 (which PETSc suggest is the order of the difference it should be).</div>
<div style="font-family:courier new,monospace"><br>
</div>
<div style="font-family:courier new,monospace">--</div>
<div style="font-family:courier new,monospace">David</div>
</div></div><div><div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote"><div class="im">On Sat, Jan 18, 2014 at 10:37 AM, Dmitry Karpeyev <span dir="ltr">
<<a href="mailto:karpeev@mcs.anl.gov" target="_blank">karpeev@mcs.anl.gov</a>></span> wrote:<br>
</div><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<p dir="ltr">You might know this already:<br>
Run the smallest (fewest dofs) case possible. Identify incorrect Jacobian entries. Trace them back to the faulty mesh nodes/variables. Debug the corresponding Jacobian code. -start_in_debugger (-start_in_debugger lldb on macos) can be helpful there.
</p>
<p dir="ltr">Let me know, if you need further help.<br>
Also let me know what test cases are good for testing the element-based FD Jacobian code that I am writing.</p>
<p dir="ltr">Cheers,<br>
Dmitry</p>
<div class="gmail_quote">On Jan 18, 2014 11:26 AM, "Zou (Non-US), Ling" <<a href="mailto:ling.zou@inl.gov" target="_blank">ling.zou@inl.gov</a>> wrote:<br type="attribution">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div dir="ltr">Dmitry, this tool is VERY helpful.
<div>I showed you last time, the first several iterations were good as I could check the Jacobians for the very first iteration. It then became worse but I don't know why since I was not able to check the Jacobians.</div>



<div><br>
</div>
<div>With this new feature, I was able to find out in later steps the hand-coded Jacobians are far away from the FD Jacobians for whatever reason (bugs I bet). I am investigating my codes.</div>
<div><br>
</div>
<div>Best,</div>
<div><br>
</div>
<div>Ling</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Tue, Jan 14, 2014 at 5:10 PM, Dmitry Karpeyev <span dir="ltr">
<<a href="mailto:karpeev@mcs.anl.gov" target="_blank">karpeev@mcs.anl.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Sounds good.  Let me know, if you need help.</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">
<div>On Tue, Jan 14, 2014 at 5:02 PM, Zou (Non-US), Ling <span dir="ltr"><<a href="mailto:ling.zou@inl.gov" target="_blank">ling.zou@inl.gov</a>></span> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div>
<div dir="ltr">Thank you Dmitry.
<div>I will at first work to update my petsc version, which may need some help from MOOSE team though.</div>
<div>I will then update you the status of the Jacobian status.</div>
<div><br>
</div>
<div>Best,</div>
<div><br>
</div>
<div>Ling</div>
</div>
</div>
<div>
<div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">
<div>On Tue, Jan 14, 2014 at 4:59 PM, Dmitry Karpeyev <span dir="ltr"><<a href="mailto:karpeev@mcs.anl.gov" target="_blank">karpeev@mcs.anl.gov</a>></span> wrote:<br>
</div>
<div>
<div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hi Ling,
<div><br>
</div>
<div>You can check Jacobian at EVERY SNES solve in petsc-3.4 using </div>
<div>-snes_check_jacobian</div>
<div>and view the difference between two Jacobians using</div>
<div>-snes_check_jacobian_view.</div>
<div><br>
</div>
<div>Naturally, this is best done on the smallest problem possible, so that </div>
<div>(a) the FD Jacobian calculation doesn't take too much time,</div>
<div>(b) matrix viewing doesn't overwhelm the output.</div>
<div><br>
</div>
<div>MOOSE works with petsc-3.4.</div>
<div><br>
</div>
<div>Cheers,</div>
<div>Dmitry.</div>
</div>
</blockquote>
</div>
</div>
</div>
<br>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</blockquote>
</div>
</blockquote>
</div></div></div>
<br>
</div>
</div></div></div>

</blockquote></div><br></div>
</blockquote></div><br></div></div>