multistate_accumulator

This module analyzes and manipulates multistate accumulators. For example, the canonical ensemble average energy for a given number of particles.

multistate_accumulator.splice_by_max_column(prefix, suffix, column='moment0', crit_prefix=None, crit_suffix=None)[source]

Combine all files with matching prefix and suffix, each with the same number of states, by assigning rows based on the maximum in the given column.

Parameters:
  • prefix (str) – Find all files beginning with this prefix.

  • suffix (str) – Find all files endding with this suffix.

  • column (str) – Use the row with the maximum column. For example, moment0 is the highest number of samples.

  • crit_prefix (str) – Use criteria to read only specific macrostates, if given.

  • crit_suffix (str) – Use criteria to read only specific macrostates, if given.

>>> import pandas as pd
>>> from pyfeasst import multistate_accumulator
>>> spliced = multistate_accumulator.splice_by_max_column(prefix="../../tests/lj_enn0s",
...                                                       suffix='.txt')
>>> en0 = pd.read_csv('../../tests/lj_enn0s00.txt')
>>> en1 = pd.read_csv('../../tests/lj_enn0s01.txt')
>>> assert spliced['average'][136] == en0['average'][136]
>>> assert spliced['average'][136] != en1['average'][136]
>>> assert spliced['average'][137] == en0['average'][137]
>>> assert spliced['average'][137] == en1['average'][137]
>>> assert spliced['average'][138] != en0['average'][138]
>>> assert spliced['average'][138] == en1['average'][138]
multistate_accumulator.splice_by_node(prefix, suffix, num_nodes, extra_overlap=0)[source]

Use splice_by_max_column for each node, with prefix=prefix+node. Then, drop 1+extra_overlap Combine all files with matching prefix and suffix, each with the same number of states, by assigning rows based on the maximum in the given column.

Parameters:

num_nodes (int) – The number of nodes to splice.

>>> import pandas as pd
>>> from pyfeasst import multistate_accumulator
>>> from pyfeasst import macrostate_distribution
>>> spliced = splice_by_node(prefix='../../tests/lj_enn', suffix='.txt', num_nodes=2)
>>> round(float(spliced['average'][375]), 8)
-2001.76687973
>>> round(float(spliced['average'][376]), 8)
-2012.46764871
>>> len(spliced)
476
>>> spliced.to_csv('spliced.csv')
>>> lnpi = macrostate_distribution.splice_files(prefix='../../tests/lj_lnpin', suffix='.txt')
>>> lnpi.concat_dataframe(spliced, add_prefix='e_')
>>> round(float(lnpi.equilibrium()), 8)
-0.31402411
>>> vapor, liquid = lnpi.split()
>>> round(float(-vapor.ln_prob()[0]*0.7/8**3), 8)  # pressure
0.00136904
>>> round(float(vapor.ensemble_average('e_average')/vapor.average_macrostate()), 8)
-0.02500369
>>> round(float(liquid.ensemble_average('e_average')/liquid.average_macrostate()), 8)
-6.09838831