Hi Dmitry,

if I get it right, the problematic entries are the derivatives of the second 
phase's mass balance equation w.r.t. to the saturation

at the own DOF.


Could it be that you consider the another phase than the numerical derivative 
does? (e.g. Sw instead of Sn)


I mean, which formulation are you using? pw-Sn or pn-Sw? Maybe just just need 
to consider the other phase's saturation in your

analytical derivative?


Best wishes

Kilian


________________________________
Von: Dumux <dumux-boun...@listserv.uni-stuttgart.de> im Auftrag von Dmitry 
Pavlov <dmitry.pav...@outlook.com>
Gesendet: Samstag, 4. April 2020 12:48
An: DuMuX User Forum
Betreff: [DuMuX] DiffMethod::numeric and DiffMethod::analytic giving opposite 
signs in the Jacobian

Hello,

I just ran into a weird problem with DuMux 3.1. As I reported before, I
was having trouble replacing the numeric derivatives with my own
analytic ones. Now I made a very small and simplified example and made
some debug printing to track down the issue.

The problem being solved is 2p (TwoPIncompressibleLocalResidual), fully
implicit scheme. The assembler is FVAssembler<TypeTag,
DiffMethod::numeric>. The boundary conditions are: neumann (injection
well), all Dirichlet (production well). No customary flux derivatives,
no other fancy stuff.

Here is the first output of the debug printing that I added into
NewtonSolver::solveLinearSystem_:

Jacobian [n=4,m=4,rowdim=8,coldim=8]
row    0   5.20412e-12  -7.65000e+09  -5.10436e-12
0.00000e+00             .             . .             .
row    1   2.43297e-09   6.50250e+09  -2.43297e-09
0.00000e+00             .             . .             .
row    2  -5.10436e-12   0.00000e+00   1.02087e-11 -7.65000e+09
-5.10436e-12   0.00000e+00 .             .
row    3  -2.43297e-09   0.00000e+00   4.86593e-09 6.50250e+09
-2.43297e-09   0.00000e+00 .             .
row    4             .             .  -5.10436e-12 0.00000e+00
1.02087e-11  -7.65000e+09  -5.10436e-12 0.00000e+00
row    5             .             .  -2.43297e-09 0.00000e+00
4.86593e-09   6.50250e+09  -2.43297e-09 0.00000e+00
row    6             .             .             . .  -5.10436e-12
0.00000e+00   1.53131e-11  -7.65000e+09
row    7             .             .             . .  -2.43297e-09
0.00000e+00   7.29888e-09   6.50250e+09
residual [blocks=4,dimension=8]
row    0 -2.17e-02 0.00e+00 0.00e+00 0.00e+00 0.00e+00 0.00e+00 1.02e-06
4.87e-04

And the simulation goes fine after that (more or less). And here is what
the first debug output becomes when I use FVAssembler<TypeTag,
DiffMethod::analytic> instead:

Jacobian [n=4,m=4,rowdim=8,coldim=8]
row    0   5.10435e-12  -7.65000e+09  -5.10435e-12
0.00000e+00             .             . .             .
row    1   2.43296e-09  -6.50250e+09  -2.43296e-09
0.00000e+00             .             . .             .
row    2  -5.10435e-12   0.00000e+00   1.02087e-11 -7.65000e+09
-5.10435e-12   0.00000e+00 .             .
row    3  -2.43296e-09   0.00000e+00   4.86593e-09 -6.50250e+09
-2.43296e-09   0.00000e+00 .             .
row    4             .             .  -5.10435e-12 0.00000e+00
1.02087e-11  -7.65000e+09  -5.10435e-12 0.00000e+00
row    5             .             .  -2.43296e-09 0.00000e+00
4.86593e-09  -6.50250e+09  -2.43296e-09 0.00000e+00
row    6             .             . .             .  -5.10435e-12
0.00000e+00   1.53131e-11 -7.65000e+09
row    7             .             . .             .  -2.43296e-09
0.00000e+00   7.29889e-09 -6.50250e+09
residual [blocks=4,dimension=8]
row    0 -2.17e-02 0.00e+00 0.00e+00 0.00e+00 0.00e+00 0.00e+00 1.02e-06
4.87e-04

And the simulation stucks instantly. You see that the odd diagonal
elements have the opposite signs as compared to the ones of the analytic
Jacobian.

Did I run into a bug? Did I misuse DuMux? I will appreciate any comments.

Best regards,

Dmitry


_______________________________________________
Dumux mailing list
Dumux@listserv.uni-stuttgart.de
https://listserv.uni-stuttgart.de/mailman/listinfo/dumux
_______________________________________________
Dumux mailing list
Dumux@listserv.uni-stuttgart.de
https://listserv.uni-stuttgart.de/mailman/listinfo/dumux

Reply via email to