Oh, never mind, I missed this part
const auto elemSol = elementSolution(element, curElemVolVars,
fvGeometry);
Sorry for the noise.
Best regards,
Dmitry
On 16.05.2020 15:47, Dmitry Pavlov wrote:
Timo,
Thank you for the pointers. In my MaterialLawParams, I store some
coefficients that are calculated basing on evalGradients() which I
call inside
MySpatialParams::materialLawParams(const Element& element, const
SubControlVolume& scv, const ElementSolution& elemSol)
Inside this function, I have everything I need to call
evalGradients(). The coefficients are then used in
MyMaterialLaw::krw() and friends.
So it is all very nice until I have to implement derivatives, too.
There is no ElementSolution passed to
MyLocalResidual::addFluxDerivatives() or
MyLocalResidual::addRobinFluxDerivatives(). MaterialLawParams also are
not passed there. So how can I do my thing with the evalGradients()
there, or, if that is not possible, what are my other options to get
the pressure gradient? Thank you.
Best regards,
Dmitry
On 15.05.2020 19:46, Timo Koch wrote:
--
_________________________________________________
Timo Koch phone: +49 711 685 64676
IWS, Universität Stuttgart fax: +49 711 685 60430
Pfaffenwaldring 61 email: timo.k...@iws.uni-stuttgart.de
<mailto:timo.k...@iws.uni-stuttgart.de>
D-70569 Stuttgart url: www.iws.uni-stuttgart.de/en/lh2/
<http://www.iws.uni-stuttgart.de/en/lh2/>
_________________________________________________
On 15. May 2020, at 18:25, Dmitry Pavlov <dmitry.pav...@outlook.com
<mailto:dmitry.pav...@outlook.com>> wrote:
Hello,
I am struggling to do a simulation in DuMux 3.1 with a two-phase
flow in porous medium (oil + aqueous solution containing a polymer
and a surfactant). I am using the 2pnc model and the Box method,
because it allows a fully implicit solution taking into account the
dependence of material parameters on the pressure gradient. I am
using a numeric FVAssembler and UMFPack as the linear backend of the
Newton method.
The simulation works, but is hugely impractical because the time
convergence is slow. The time step goes down to the length of a few
seconds.
So I am considering using an analytical Jacobian here. Why so?
Because of two clues:
1. I once had trouble with a numerical Jacobian causing the method
to diverge, and analytical Jacobian helped (after a bug in its
implementation was fixed) [1].
2. There are not many software packages claiming to be able to do
this kind of simulation. One of those who do is MRST, and it
advertises its automatic differentiation approach [2]. (It also says
that it uses TPFA, but it is not a good option with DuMux in this
case because there is no possibility with TPFA to account for the
pressure gradient on the current step [3]).
Now, I can not compile my program with FVAssembler<TypeTag,
DiffMethod::analytic>, because the addFluxDerivatives method that I
am using gives an error, saying "Only fluids with constant
viscosities are allowed!". The viscosity of aqueous phase in my case
is not constant because it depends on polymer concentration. Is
there any example of analytic flux derivatives implementation for
this case? If not, what would be the general recommendations on how
I can implement such a thing myself?
If you think that I am not on the right path and the numeric
differentiation should not be a problem, and the problem is
something else, feel free to let me know, too. Thank you.
Hi Dmitry,
bad Newton convergence can have many reasons. Could depend on the BC
or general problem setup. The derivatives could also be a problem but
there is now way to find the exact reason without a close
investigation of the actual setup.
You may get better convergence if you think about how you can maybe
remove some non-linearities and couplings in your equations. Maybe (I
have no idea) some couplings in your specific model are quite weak
but not very important.
Then the approximation of the Jacobian could be bad and you would be
better off removing the coupling completely.
As for analytical Jacobian: as the error suggests, the
TwoPIncompressibleLocalResidual you are using assumes constant
viscosity. This is because it’s not generally possible to get the
exact derivative because we don’t know what Fluid System is used.
(AD would be an option but currently not implemented in Dumux). In
your case, if you know the derivative of the viscosity with respect
to all primary variables, you can provide your own implementation of
TwoPIncompressibleLocalResidual. Basically use product rule in terms
where the viscosity occurs.
I personally don’t know of any example implementation.
Then, just set your custom class as the “LocalResidual” property.
If the derivative is very complicated you could also use numeric
differentiation for the viscosity or try to locally use an AD library
to evaluate the derivative.
Good luck
Timo
Best regards,
Dmitry
[1] https://listserv.uni-stuttgart.de/pipermail/dumux/2020q2/002492.html
[2] https://www.sintef.no/projectweb/mrst/modules/ad-eor/
[3] https://listserv.uni-stuttgart.de/pipermail/dumux/2020q2/002516.html
_______________________________________________
Dumux mailing list
Dumux@listserv.uni-stuttgart.de
https://listserv.uni-stuttgart.de/mailman/listinfo/dumux