Skip to content

Commit c0f7a6a

Browse files
committed
handle LAMMPSDUMP with no atom energy information
1 parent 5f6b298 commit c0f7a6a

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

CodeEntropy/levels/mda.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,19 @@ def _convert_lammps_forces_energies(ts):
174174
ts.data["c_7"] *= 4.184
175175
return ts
176176

177+
def _convert_lammps_forces(ts):
178+
"""
179+
Convert lammps forces from kcal/mol/Ang to kJ/mol/Ang.
180+
181+
Args:
182+
ts: MDAnalysis timeseries from the trajectory.
183+
184+
Returns:
185+
A converted time series.
186+
"""
187+
ts.forces *= 4.184
188+
return ts
189+
177190
if fileformat == "LAMMPSDUMP":
178191
try:
179192
return mda.Universe(
@@ -184,7 +197,16 @@ def _convert_lammps_forces_energies(ts):
184197
transformations=[_convert_lammps_forces_energies],
185198
)
186199
except KeyError:
187-
raise
200+
logger.debug(
201+
f"Warning: Energy columns not found in LAMMPSDUMP: {trrfile}"
202+
)
203+
return mda.Universe(
204+
tprfile,
205+
trrfile,
206+
format=fileformat,
207+
additional_columns=["fx", "fy", "fz"],
208+
transformations=[_convert_lammps_forces],
209+
)
188210
else:
189211
raise ValueError(
190212
f"Incorrect file format: {fileformat}, LAMMPSDUMP expected"

0 commit comments

Comments
 (0)