On Sun, Oct 26, 2014 at 9:09 PM, Evan Chenelly <[email protected]> wrote:
> Wow, thank you for both of those responses... they were extremely
> helpful. And thanks for wading through my beginner-level code. I have
> been experimenting with things to see if I could get FiPy to update
> faceValue during solve which is why I called it with faceValue() - but I
> forgot to change it back before posting. I was confused about faceGrad
> orientation as well, thanks for correcting me.
>
> I saw someone else having trouble with this boundary condition in an older
> thread.
> There was a mention to try using a divergence term to set the robin
> condition. This now works outside of the sweeping loop for me as long as I
> am using underRelaxation. Here is the equation:
>
> eq = DiffusionTerm(coeff=D) + (-hTopSurface*(phi.faceValue-tinf)/k *
> mesh2.faceNormals * mesh2.facesBack).divergence
>
> After following your advice I was getting similar numbers, ~31.32C maximum
> value. This is only ~6-9% error from my accepted value. The error was
> because of the way I set up the source term by selecting cell centers
> within the area I specified. If I set the mesh in x and y to numbers
> divisible by 4 I get closer to the correct answer. Is there anyway to make
> the source "bounds" register as key mesh points in the mesh using grid3D?
> I haven't found anything like that in the documentation.
> Suggestions are welcome too. I can try to implement something. I do want
> to eventually parametrize this with multiple sources.
>
> My goal is to create a larger python tool that uses this calculation as a
> subroutine. Both the neumann and the robin BCs will be functions of space
> (and eventually time.) And they will iteratively update according to a
> simpler iterative routine (which calculates flow, then htc from nusselt
> correlations.)
>
> I do want to be able to solve this problem relatively fast as I will want
> to sweep parameters to optimize a design. I am also only able to use high
> values of underRelaxation (0.999,0.9999). The problem I have now is that
> i'm not sure what the optimal underRelaxation and tolerances are to get a
> fast (second or two) convergence.
>
> I found one way is to change the increase (lower) the underrelaxation as I
> get res closer to restol. Suggestions are welcome again! It is still
> relatively slow... but it works now!!! Thank you very much!!!
>
Evan,
I've put together a simple 1D example to show how to do this implicitly. In
the example the problem is solved with one sweep.
http://nbviewer.ipython.org/gist/wd15/f04b22c6ec80b1eda8e3
It's not surprising that the problem is so unstable with constraints. The
linear solver doesn't know that the problem is pinned. If the source is the
wrong sign then you will of course need under-relaxation. The constraint
functionality really isn't that smart in FiPy.
The Robin boundary condition example should probably be done with source
terms rather than the constraints at this point. I think it is a lot safer.
I'm beginning to wonder if we shouldn't switch all boundary condition to
source terms and do away with constraints because they obfuscate what's
going on. I need to think about it.
I hope the example helps.
Cheers,
Daniel
--
Daniel Wheeler
_______________________________________________
fipy mailing list
[email protected]
http://www.ctcms.nist.gov/fipy
[ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]