Hi Troels, There is another bug here. Although it looks like you are dividing by zero when kex is 0.0, what is happening is that you have 0.0 / 0.0 ! The result should not be Inf (or a big number). Do you have access to symbolic maths software such as Maxima, Mathematica, etc.? You should put in the dispersion equations, and then ask the software to simplify the equation with the assumption that kex = 0.0. Then you'll see that the LM63 model collapses down to: R2eff = R20. You can also do this by hand. You'll see that tanh(0.0) = 0.0, and phi_ex has kex in it so it too is 0.0. You can then just replace the 0.0 / 0.0 parts with 1: R2eff = R20 + 0.0/0.0 (1 - 0.0/0.0), R2eff = R20 + 1 (1 - 1), R2eff = R20. The 0.0 / 0.0 operation is the origin of the numpy warnings. The unit tests I mentioned at http://www.mail-archive.com/relax-devel@xxxxxxx/msg05742.html would comprehensively catch all problems in the dispersion code. Regards, Edward On 21 May 2014 13:03, <tlinnet@xxxxxxxxxxxxx> wrote:
Author: tlinnet Date: Wed May 21 13:02:59 2014 New Revision: 23298 URL: http://svn.gna.org/viewcvs/relax?rev=23298&view=rev Log: Align math-domain catching for model LM63 with trunk implementation. task #7793: (https://gna.org/task/?7793) Speed-up of dispersion models. This is to implement catching of math domain errors, before they occur. The catching of errors have to be more careful. Modified: branches/disp_speed/lib/dispersion/lm63.py Modified: branches/disp_speed/lib/dispersion/lm63.py URL: http://svn.gna.org/viewcvs/relax/branches/disp_speed/lib/dispersion/lm63.py?rev=23298&r1=23297&r2=23298&view=diff ============================================================================== --- branches/disp_speed/lib/dispersion/lm63.py (original) +++ branches/disp_speed/lib/dispersion/lm63.py Wed May 21 13:02:59 2014 @@ -85,6 +85,15 @@ @type num_points: int """ + # Catch divide with zeros (to avoid pointless mathematical operations). + if kex == 0.0: + return array([1e100]*num_points) + + # Catch zeros (to avoid pointless mathematical operations). + # This will result in no exchange, returning flat lines. + if phi_ex == 0.0: + return array([r20]*num_points) + # Repetitive calculations (to speed up calculations). rex = phi_ex / kex kex_4 = 4.0 / kex _______________________________________________ relax (http://www.nmr-relax.com) This is the relax-commits mailing list relax-commits@xxxxxxx To unsubscribe from this list, get a password reminder, or change your subscription options, visit the list information page at https://mail.gna.org/listinfo/relax-commits