Skip to content

Commit

Permalink
minor formatting #28
Browse files Browse the repository at this point in the history
  • Loading branch information
HanmeiTang committed Sep 19, 2019
1 parent d613682 commit 879d1e4
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions pymatgen_diffusion/aimd/van_hove.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ def __init__(self, diffusion_analyzer, avg_nsteps=50, ngrid=101, rmax=10.0,
tracking_ions = np.array(tracking_ions)
ref_ions = np.array(ref_ions)

gaussians = norm.pdf(interval[:, None], interval[None, :], sigma) / float(avg_nsteps) / float(len(ref_indices))
gaussians = norm.pdf(interval[:, None], interval[None, :],
sigma) / float(avg_nsteps) / float(
len(ref_indices))

# calculate self part of van Hove function
image = np.array([0, 0, 0])
Expand All @@ -142,7 +144,8 @@ def __init__(self, diffusion_analyzer, avg_nsteps=50, ngrid=101, rmax=10.0,
arange = r[:, None] * np.array([1, 0, 0])[None, :]
brange = r[:, None] * np.array([0, 1, 0])[None, :]
crange = r[:, None] * np.array([0, 0, 1])[None, :]
images = arange[:, None, None] + brange[None, :, None] + crange[None, None, :]
images = arange[:, None, None] + brange[None, :, None] + crange[None,
None, :]
images = images.reshape((len(r) ** 3, 3))

# find the zero image vector
Expand All @@ -154,7 +157,9 @@ def __init__(self, diffusion_analyzer, avg_nsteps=50, ngrid=101, rmax=10.0,
it0 = min(it * step_skip, ntsteps)

for it1 in range(avg_nsteps):
dcf = (tracking_ions[it0 + it1, :, None, None, :] + images[None, None, :, :] -
dcf = (tracking_ions[it0 + it1, :, None, None, :] + images[None,
None, :,
:] -
ref_ions[it1, None, :, None, :])
dcc = lattice.get_cartesian_coords(dcf)
d2 = np.sum(dcc ** 2, axis=3)
Expand Down Expand Up @@ -327,15 +332,17 @@ def __init__(self, structures, indices, reference_indices, ngrid=101,
arange = r[:, None] * np.array([1, 0, 0])[None, :]
brange = r[:, None] * np.array([0, 1, 0])[None, :]
crange = r[:, None] * np.array([0, 0, 1])[None, :]
images = arange[:, None, None] + brange[None, :, None] + crange[None, None, :]
images = arange[:, None, None] + \
brange[None, :, None] + crange[None, None, :]
images = images.reshape((len(r) ** 3, 3))

# find the zero image vector
zd = np.sum(images ** 2, axis=1)
indx0 = np.argmin(zd)

for fcoords, ref_fcoords in zip(fcoords_list, ref_fcoords_list):
dcf = fcoords[:, None, None, :] + images[None, None, :, :] - ref_fcoords[None, :, None, :]
dcf = fcoords[:, None, None, :] + \
images[None, None, :, :] - ref_fcoords[None, :, None, :]
dcc = lattice.get_cartesian_coords(dcf)
d2 = np.sum(dcc ** 2, axis=3)
dists = [d2[u, v, j] ** 0.5 for u in range(len(indices))
Expand All @@ -350,10 +357,12 @@ def __init__(self, structures, indices, reference_indices, ngrid=101,
if indx > len(interval) - 1:
continue

ff = 4.0 / 3.0 * np.pi * (interval[indx + 1] ** 3 - interval[indx] ** 3)
ff = 4.0 / 3.0 * np.pi * (
interval[indx + 1] ** 3 - interval[indx] ** 3)

rdf[:] += (stats.norm.pdf(interval, interval[indx], sigma) * dn /
float(len(reference_indices)) / ff / self.rho / len(fcoords_list) * dr)
float(len(reference_indices)) / ff / self.rho / len(
fcoords_list) * dr)
# additional dr factor renormalises overlapping gaussians.
raw_rdf[indx] += dn / float(
len(reference_indices)) / ff / self.rho / len(
Expand Down Expand Up @@ -622,7 +631,8 @@ def get_df(self, func, save_csv=None, **kwargs):
for structure in self.structures:
prop_table.append(func(structure, **kwargs))

index = np.arange(len(self.structures)) * self.time_step * self.step / 1000
index = np.arange(
len(self.structures)) * self.time_step * self.step / 1000
columns = np.linspace(0, self.rmax, ngrid)
df = pds.DataFrame(prop_table, index=index, columns=columns)

Expand Down

0 comments on commit 879d1e4

Please sign in to comment.