Skip to content

Commit

Permalink
Profile: new density option
Browse files Browse the repository at this point in the history
allows to compute the profile of the average value of an observable,
instead of its density, by passing density=False when calling
the method get_values()
  • Loading branch information
Marcello-Sega committed Feb 6, 2024
1 parent 0baf046 commit 7050969
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pytim/observables/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ class Profile(object):
None is supplied, it defaults to the number
density. The number density is always
calculated on a per atom basis.
:param ITIM interface: if provided, calculate the intrinsic
profile with respect to the first layers
:param str direction: 'x','y', or 'z' : calculate the profile
along this direction. (default: 'z' or
the normal direction of the interface,
if provided.
:param ITIM interface: if provided, calculate the intrinsic
profile with respect to the first layers
:param bool MCnorm: if True (default) use a simple Monte Carlo
estimate the effective volumes of the bins.
Expand Down Expand Up @@ -113,8 +113,8 @@ class Profile(object):
"""

def __init__(self,
direction=None,
observable=None,
direction=None,
interface=None,
symmetry='default',
mode='default',
Expand Down Expand Up @@ -246,7 +246,7 @@ def sample(self, group, **kargs):
self.sampled_rnd_values += rnd_accum
self._counts += 1

def get_values(self, binwidth=None, nbins=None):
def get_values(self, binwidth=None, nbins=None, density=True):
if self.sampled_values is None:
print("Warning no profile sampled so far")
# we use the largest box (largest number of bins) as reference.
Expand All @@ -264,7 +264,7 @@ def get_values(self, binwidth=None, nbins=None):
nbins += 1

vals = self.sampled_values.copy()
vals /= (np.average(self._totvol) / self._nbins)
if density: vals /= (np.average(self._totvol) / self._nbins)
vals /= self._counts
if self.interface is not None:
# new versions of scipy.binned_statistic don't like inf
Expand Down

0 comments on commit 7050969

Please sign in to comment.