Hi Andy,
The origin of the code was my fat head.
That's good enough :)
One thing relevent: the cofactors i've called F0 and F2 turned out the same as used by Carver and Richards. In my hands at least, there is a faster way of computing them using trig functions rather than square-roots-of-square-roots (see my code for details). Also, i'd make triple sure that the definitions you've used for e.g tau_c match mine. There are at least three conventions I know of in the literature. In my code, a CPMG cycle is tau/180/tau/tau/180/tau. That'll be the same as Flemming and Dimitri use. There's a typo in Carver Richard's paper that has propagated nastily throughout the literature. I can send my implementation of CR that I used for direct comparison with my result and the numerical result if that helps keep your headaches down.
The Carver and Richards code in relax is fast enough, though Troels might have an interest in squeezing out a little more speed. Though it would require different value checking to avoid NaNs, divide by zeros, trig function overflows (which don't occur for math.sqrt), etc. Any changes would have to be heavily documented in the manual, wiki, etc. For the tau_c, tau_cp, tau_cpmg, etc. definitions, comparing the relax code to your script will ensure that the correct definition is used. That's how I've made sure that all other dispersion models are correctly handled - simple comparison to other software. I'm only aware of two definitions though: tau_cpmg = 1 / (4 nu_cpmg) tau_cpmg = 1 / (2 nu_cpmg) What is the third? Internally in relax, the 1 / (4 nu_cpmg) definition is used. But the user inputs nu_cpmg. This avoids the user making this mistake as nu_cpmg only has one definition.
You guys are free to use my code (I don't mind the gnu license) or of course implement from scratch as needed.
Cheers! For a valid copyright licensing agreement, you'll need text something along the lines of: "I agree to licence my contributions to the code in the file http://gna.org/support/download.php?file_id=20615 attached to http://gna.org/support/?3154 under the GNU General Public Licence, version three or higher." Feel free to copy and paste.
I'd like to note again though that anyone using this formula to fit data, though exact in the case of 2site exchange/inphase magnetisation, evaluated at double floating point precision should not be doing so! Neglecting scalar coupling/off resonance/spin flips/the details of the specific pulse sequence used will lead to avoidable foobars. I do see value in this, as described in the paper, as being a feeder for initial conditions for a more fancy implemenation. But beyond that, 'tis a bad idea. Ideally this should appear in big red letters in your (very nice!) gui when used.
In relax, we allow the user to do anything though, via the auto-analysis (hence the GUI), we direct the user along the best path. The default is to use the CR72 and 'NS CPMG 2-site expanded' models (Carver & Richards, and Martin Tollinger and Nikolai Skrynnikov's Maple expansion numeric model). We use the CR72 model result as the starting point for optimisation of the numeric models, allowing a huge speed up in the analysis. The user can also choose to not use the CR72 model results for the final model selection - for determining dispersion curve significance. As for the scalar coupling and spin flips, I am unaware of any dispersion software that handles this. And only Flemming's CATIA handles the CPMG off-resonance effects. This is all explained in the relax manual. I have asked the authors of most dispersion software about this too, just to be sure. I don't know how much of an effect these have though. But one day they may be implemented in relax as well, and then the user can perform the comparison themselves and see if all these claims hold. Anyway, the warnings about analytic versers numeric are described in the manual. But your new model which adds a new factor to the CR72 model, just as Dimitry Korzhnev's cpmg_fit software does for his multiple quantum extension of the equation (from his 2004 and 2005 papers), sounds like it removes the major differences between the analytic and numeric results anyway. In any case, I have never seen an analytic result which is more than 10% different in parameter values (kex specifically) compared to the numeric results. I am constantly on the lookout for a real or synthetic data set to add to relax to prove this wrong though. Cheers, Edward