Skip to content

Commit

Permalink
minor fix #28
Browse files Browse the repository at this point in the history
  • Loading branch information
HanmeiTang committed Sep 26, 2019
1 parent 6646791 commit f9da1f7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions pymatgen_diffusion/aimd/van_hove.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import itertools
import pandas as pds

from scipy import stats
from scipy.stats import norm
from scipy.signal import find_peaks
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -311,9 +310,11 @@ def __init__(self, structures: List, indices: List, reference_indices: List,
parameter to compute radial distribution function.
"""

assert ngrid >= 2, "ngrid should be greater than 1!"
assert sigma > 0, "sigma should be a positive number!"

if ngrid < 2:
raise ValueError("ngrid should be greater than 1!")
if sigma <= 0:
raise ValueError("sigma should be a positive number!")

lattices, rhos, fcoords_list, ref_fcoords_list = [], [], [], []

dr = rmax / (ngrid - 1)
Expand Down Expand Up @@ -368,15 +369,14 @@ def __init__(self, structures: List, indices: List, reference_indices: List,
ff = 4.0 / 3.0 * np.pi * \
(interval[indx + 1] ** 3 - interval[indx] ** 3)

rdf[:] += (stats.norm.pdf(interval, interval[indx], sigma) * dn /
rdf[:] += (norm.pdf(interval, interval[indx], sigma) * dn /
float(len(reference_indices)) / ff / rho / len(
fcoords_list) * dr)

# additional dr factor renormalises overlapping gaussians.
raw_rdf[indx] += dn / float(
len(reference_indices)) / ff / rho / len(fcoords_list)

self.dns = dns
self.rho = rho # This is the average density
self.structures = structures
self.cell_range = cell_range
Expand All @@ -391,6 +391,7 @@ def __init__(self, structures: List, indices: List, reference_indices: List,
self.rdf = rdf
self.raw_rdf = raw_rdf
self.interval = interval

# Finding peak based on smeared RDF
self.peak_indices = find_peaks(rdf)[0]
self.peak_r = [self.interval[i] for i in self.peak_indices]
Expand Down

0 comments on commit f9da1f7

Please sign in to comment.