Langevin function (division by zero)

Please login with a confirmed email address before reporting spam

Dear Forum,

I am trying to implement a modified version of the Poisson Nerst-Planck equation, where the electric permitivity of the medium varies with the local electric field. Which is calculated like this:

Where is the electric potential, is the avogadro number, is the concentration of solvent, and is the dipolar moment of the solvent.

Then the dipolar moment is calculated as

Where L(x) = coth(x) - 1/x, is the Langevine function.

When trying to implement this L(x) in COMSOL as an analytic function within the Definitions of my model, and running my model I get the following error.

' - Feature: Stationary Solver 1 (sol1/s1) Division by zero. - Function: / Failed to evaluate expression. - Expression: coth(an1__x__internalArgument)-1/an1__x__internalArgument Error in user-defined function. - Function: comp1.an1'

Basically COMSOL detects a divergence in the division, however the Langevine function does not have a divergence a x=0 because the coth(x) compensates the 1/x.

How can I solve this problem? Is there any way of including this functions within COMSOL?\

Best regards,


0 Replies Last Post 10 avr. 2020 à 05:46 UTC−4
COMSOL Moderator

Hello Oier Arcelus

Your Discussion has gone 30 days without a reply. If you still need help with COMSOL and have an on-subscription license, please visit our Support Center for help.

If you do not hold an on-subscription license, you may find an answer in another Discussion or in the Knowledge Base.


Please read the discussion forum rules before posting.

Please log in to post a reply.

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.