ajkerr0 / kappa

A python package to calculate thermal conductivity across molecular interfaces.
MIT License
6 stars 4 forks source link

Missing total vectorization of the thermal conductivity calculation #73

Open ajkerr0 opened 8 years ago

ajkerr0 commented 8 years ago

Related to #68, where we were missing any numpy implementation that functioned correctly. Now we can take the extra step and skip the for loops in that solution by creating 3x3xNxN arrays (where N is 2 times the number of coordinates (3 times the number of atoms)).

The main obstacle is figuring out how to construct the higher dimensional arrays.

This should not be the highest priority since we believe the main bottleneck of the kappa calculation is the solving for the Green's function coefficients.

ajkerr0 commented 8 years ago

This could actually save important time when we are looking at cases with multiple drivers, very large molecules, etc.

ajkerr0 commented 8 years ago

If nothing else, this is a great exercise in working in arbitrary dimensions in numpy.

ajkerr0 commented 8 years ago

Thinking about it some more, this may not save any appreciable time because I think numpy's sum function goes like O(n) anyway, not O(log(n)). If the latter is the case, then yes, we should explore it.

ajkerr0 commented 8 years ago

Ok, it turns out that summing an array the way I was thinking (add nearest neighbors together, repeatedly add aggregates together) still has linear time complexity. I just thought about it on paper.

So pursuing this issue will not be worth it for now. We have already vectorized the important part of the calculation: the 3Nx3N sum. Python only has to do type checking for the sum of each dimension, and for each of the drivers, and for each of the crossing interactions.

Going to mark as low priority.

ajkerr0 commented 8 years ago

Full vectorization would be prime for parallelization

ajkerr0 commented 8 years ago

Putting everything in a single numpy array would also make it very clear where the N largest contributions come from.