Hi,
I should also comment the matrices, in addition to the other comments.
I think the code in lib/dispersion/ns_2site_star.py is now excellently documented. A novice NMR user can now learn everything from it! I don't think that anything else is needed, though see what you think. Note that this code is currently evolving.
Edward, I also have a question to line 75: where does the factor 2 come from? that was not in the original version. I don't see what it does. I think it should not be there.
I shifted it from the inside of the for loop. Specifically the original expression "sci.expm(cR*2.*tcp))" has been changed to "expm(cR2*tcp))", where cR2 is cR pre-multiplied by 2. This decreases the number of cR*2. multiplications from the number of dispersion points to 1. It is just one of a number of small speed ups. I plan on identifying more places in the code where calculations can be shifted up the code chain to absolutely minimise the total number of mathematical operations. For example I am shifting some calculations outside of the lib.dispersion.ns_2site_star.r2eff_ns_2site_star() function to be inside the func_ns_2site_star() target function of the target_functions.relax_disp.Dispersion class. This is to minimise calculations for each spin in the cluster and magnetic field strength, i.e. the number of calculations drops from N_spins*N_B0 to 1. For large spin clusters this is significant. Another speed up used within relax target functions is the matrix creation. Currently this involves first automatic memory allocation at the start of each call followed by memory deallocation. The way this is handled in relax is that when the target function class is initialised, then all of the needed matrices are initialised. Then the target function calls just update the pre-existing matrices. This often has a significant effect on optimisation speed by minimising the calls to the Python garbage collection and memory allocation routines. In some cases, scalar multiplication and dot products for example, a new matrix is created automatically hence this trick cannot always be used (though faster alternatives can be created if desired). Cheers, Edward