MaginnGroup / PyLAT

GNU General Public License v3.0
103 stars 54 forks source link

Two Problems In Conductivity Calculation #25

Open RiverEric opened 1 year ago

RiverEric commented 1 year ago

Hi Mike, thank you for the great code! I met two problems when calculating conductivity.

The first is in calcCond.py, it seems that the function: clacJ(self, jx, jy, jz, dt, tsjump, firstpoint,ver) will never use the variable 'firstpoint', which is the GKC_Skip.

The second one is in calcDiffusivity.py. I got a extreme low conductivity because of one negative diffusivity of component. It seems that the maximum possible value of firststep is the len(lnMSD) -1 ( = len( MSD ) -2 since lnMSD = np.log(MSD[1:]) ). Considering len(Time ) = len(MSD), the number of possible i in line 77( for i in range(int(firststep), len(Time)):) is at least 2, which will make the if statement in line 81( if len(calctime)==1:) never be true. Will it be better if change the for loop to be " for i in range(int(firststep)+1, len(Time)): "?

mike5603 commented 1 year ago

I think both of these points are artifacts of how the code has evolved. For the first point, the correlation calculation used to be performed manually, which was significantly more expensive than the current method using fft, so skipping data isn't as important. I suppose if you needed to skip to account for equilibration or something like that, I believe if you add '[firstpoint:]' to all of the jx[l] and similar calls that should handle that. (It's been a while since I've looked at this code so I'm not certain).

For the second case, the len(calctime)==1 test is purely a test to confirm that the msd is long enough to calculate the diffusivity. Again, its been a while since have looked at the code, so I'm not exactly sure what the max value of firststep would be. While PyLAT does attempt to determine the linear region of the MSD for you, it is not perfect so I would always recommend plotting your MSD, especially if you are seeing unexpected values for your diffusivity