Hi, Aniruddha.

I certainly don't know the details of your system, but my first thought
would be that this term in the free energy should (physically, at least)
prevent the concentration from actually ever reaching zero, as the chemical
potential diverges when x->0. So I don't understand why you would
initialize the system with zero concentrations. From my not-super-fresh
memory of deriving the ideal solution model from a lattice model in Thermo,
I didn't think it could really apply until you could at least apply
Stirling's approximation, implying a moderately large number of the species
in the system. Anyway, is there a strong reason that you need the
concentrations to be zero? In my experience with such models, when run
dynamically, they keep concentrations away from zero.

Ray

On Tue, Feb 9, 2016 at 8:11 PM, Aniruddha Jana <[email protected]> wrote:

> Hello Everyone,
>
> I am trying to use an ideal chemical free energy formulation for a
> problem, where I have terms of the form x*log(x). Computing x*log(x) at x =
> 0 gives the error "RuntimeWarning: divide by zero encountered in log".
> Even if I try to prevent computation of x*log(x) at x = 0 by doing (for
> example):
>
> epsilon = 1.0e-3
> G.setValue((x>epsilon)*log(x>epsilon))
>
> or
>
> G.setValue(x*log(x), where=(x>0))
>
> the error persists.
>
> A test script is attached with this email.
>
> Looking up online, I read that "log" is computed before "where". Another
> suggestion says to catch and handle the exception (links below).
>
>
> http://stackoverflow.com/questions/25087769/runtimewarning-divide-by-zero-error-how-to-avoid-python-numpy
>
>
> http://stackoverflow.com/questions/13497891/python-getting-around-division-by-zero
>
> Any thoughts on how to get rid of the problem, especially for FiPy, and/or
> the ideal free energy formulation?
>
> Thank You!
>
> Best regards,
> Aniruddha
>
>
>
> _______________________________________________
> fipy mailing list
> [email protected]
> http://www.ctcms.nist.gov/fipy
>   [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
>
>
_______________________________________________
fipy mailing list
[email protected]
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]

Reply via email to