Skip to content

Commit

Permalink
Update extract_dHdl* to use prec
Browse files Browse the repository at this point in the history
  • Loading branch information
jaclark5 committed Jul 15, 2024
1 parent e30d7f8 commit 368f314
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/alchemlyb/parsing/lammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ def extract_dHdl_from_u_n(
column_u_cross=None,
dependence=lambda x: (1 / x),
units="real",
prec=4,
):
"""Produce dHdl dataframe from separated contributions of the potential energy.
Expand All @@ -677,6 +678,8 @@ def extract_dHdl_from_u_n(
potential energy to the derivative with respect to eps.
units : str, default="real"
Unit system used in LAMMPS calculation. Currently supported: "real" and "lj"
prec : int, default=4
Number of decimal places defined used in ``round()`` function.
Results
-------
Expand Down Expand Up @@ -725,6 +728,7 @@ def extract_dHdl_from_u_n(
data = data.iloc[:, col_indices]

Check warning on line 728 in src/alchemlyb/parsing/lammps.py

View check run for this annotation

Codecov / codecov/patch

src/alchemlyb/parsing/lammps.py#L728

Added line #L728 was not covered by tests

data.columns = ["time", "fep-lambda", "U"]

Check warning on line 730 in src/alchemlyb/parsing/lammps.py

View check run for this annotation

Codecov / codecov/patch

src/alchemlyb/parsing/lammps.py#L730

Added line #L730 was not covered by tests
data["fep-lambda"] = data["fep-lambda"].apply(lambda x: round(x, prec))
data["fep"] = dependence(data.loc[:, "fep-lambda"]) * data.U
data.drop(columns=["U"], inplace=True)

Check warning on line 733 in src/alchemlyb/parsing/lammps.py

View check run for this annotation

Codecov / codecov/patch

src/alchemlyb/parsing/lammps.py#L732-L733

Added lines #L732 - L733 were not covered by tests

Expand All @@ -747,6 +751,7 @@ def extract_dHdl(
columns_derivative1=[11, 10],
columns_derivative2=[13, 12],
units="real",
prec=4,
):
"""This function will go into alchemlyb.parsing.lammps
Expand Down Expand Up @@ -783,6 +788,8 @@ def extract_dHdl(
and backward distance respectively.
units : str, default="real"
Unit system used in LAMMPS calculation. Currently supported: "real" and "lj"
prec : int, default=4
Number of decimal places defined used in ``round()`` function.
Results
-------
Expand Down Expand Up @@ -883,6 +890,7 @@ def extract_dHdl(
if column_lambda2 is None:
# dU_back: U(l-dl) - U(l); dU_forw: U(l+dl) - U(l)
data.columns = ["time", "fep-lambda", "dlambda", "dU_back", "dU_forw"]

Check warning on line 892 in src/alchemlyb/parsing/lammps.py

View check run for this annotation

Codecov / codecov/patch

src/alchemlyb/parsing/lammps.py#L892

Added line #L892 was not covered by tests
data["fep-lambda"] = data["fep-lambda"].apply(lambda x: round(x, prec))
data["fep"] = (data.dU_forw - data.dU_back) / (2 * data.dlambda)
data.drop(columns=["dlambda", "dU_back", "dU_forw"], inplace=True)

Check warning on line 895 in src/alchemlyb/parsing/lammps.py

View check run for this annotation

Codecov / codecov/patch

src/alchemlyb/parsing/lammps.py#L894-L895

Added lines #L894 - L895 were not covered by tests
else:
Expand All @@ -897,6 +905,7 @@ def extract_dHdl(
"dU_back_coul",
"dU_forw_coul",
]
data["vdw-lambda"] = data["vdw-lambda"].apply(lambda x: round(x, prec))
data["coul"] = (data.dU_forw_coul - data.dU_back_coul) / (

Check warning on line 909 in src/alchemlyb/parsing/lammps.py

View check run for this annotation

Codecov / codecov/patch

src/alchemlyb/parsing/lammps.py#L909

Added line #L909 was not covered by tests
2 * data.dlambda_coul
)
Expand Down

0 comments on commit 368f314

Please sign in to comment.