-
|
Problem I have a trajectory where charges change dynamically in time in a polarizable surface. The charges are printed out in a lammps dump trajectory. Is there a way of reading these in and assigning to the atom charges? Expected behaviour The manual seems to indicate that there is a possibility to read in charges from a lammps trajectory. The source code suggest that this could happen via additional_columns keyword in the lammps dump reader. Actual behaviour After trying multiple ways of reading in the trajectory via mda universe, the charges remain constant at the values they are in the topology. When using the additional_columns keyword, the ts.data field does not contain any additional columns. This is true for all ways of formatting the trajectory (that is, ordering the trajectory columns) I tried out. Code to reproduce behaviour #u = mda.Universe('graphene_water.lmp','cpm_full.xyz', topology_format="DATA", format="LAMMPSDUMP",atom_style="id resid type charge x y z", additional_columns=['q'])
#u = mda.Universe('graphene_water.lmp','cpm.dcd', topology_format="DATA")
u = mda.Universe('graphene_water.lmp','cpm.lammpstrj', topology_format="DATA", format="LAMMPSDUMP", additional_columns=True)
for ts in u.trajectory:
charges = u.atoms.charges
pos = u.atoms.positions
print(f"Frame {ts.frame}, First 5 charges: {charges[:5]}")
print(f"Frame {ts.frame}, First 5 coords: {pos[:5]}")
print(ts.data)Versions MDAnalysis 2.7.0 Grateful for any tips & insights :) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
Maybe try MDAnalysis 2.9.0? I see in the docs for LAMMPS.DumpReader that the arbitrary columns were supposedly implemented in 2.7.0 but the CHANGELOG says that this actually happened in 2.8.0 — sorry for the confusion! |
Beta Was this translation helpful? Give feedback.
-
|
Thanks! Updating the version indeed did the trick. On a semi-related note: the arbitrary columns seem to only work on numerical values. Reading in atom names doesn't work because there is a string to float conversion assumed upon reading. |
Beta Was this translation helpful? Give feedback.
Maybe try MDAnalysis 2.9.0? I see in the docs for LAMMPS.DumpReader that the arbitrary columns were supposedly implemented in 2.7.0 but the CHANGELOG says that this actually happened in 2.8.0 — sorry for the confusion!