Skip to content

Commit

Permalink
Merge 819fff0 into ce2fb4e
Browse files Browse the repository at this point in the history
  • Loading branch information
htz1992213 committed May 3, 2021
2 parents ce2fb4e + 819fff0 commit c5b2a0a
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions pymatgen/io/lammps/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def structure(self):
site_properties=site_properties,
)

def get_string(self, distance=6, velocity=8, charge=4):
def get_string(self, distance=6, velocity=8, charge=4, hybrid=True):
"""
Returns the string representation of LammpsData, essentially
the string to be written to a file. Support hybrid style
Expand All @@ -358,6 +358,11 @@ def get_string(self, distance=6, velocity=8, charge=4):
velocities. Default to 8.
charge (int): No. of significant figures to output for
charges. Default to 3.
hybrid (bool): Whether to write hybrid coeffs types.
Default to True. If the data object has no hybrid
coeffs types and has large coeffs section, one may
use False to speedup the process. Otherwise the
default is recommanded.
Returns:
String representation
Expand Down Expand Up @@ -441,12 +446,16 @@ def map_charges(q):
parts = []
for k, v in body_dict.items():
index = k != "PairIJ Coeffs"
if k in [
"Bond Coeffs",
"Angle Coeffs",
"Dihedral Coeffs",
"Improper Coeffs",
]:
if (
k
in [
"Bond Coeffs",
"Angle Coeffs",
"Dihedral Coeffs",
"Improper Coeffs",
]
and hybrid
):
listofdf = np.array_split(v, len(v.index))
df_string = ""
for i, df in enumerate(listofdf):
Expand Down Expand Up @@ -1444,6 +1453,21 @@ def get_string(self, distance=6, velocity=8, charge=4):
lines.insert(1, info)
return "\n".join(lines)

def as_lammpsdata(self):
"""
Convert a CombinedData object to a LammpsData object.
"""
items = dict()
items["box"] = self.box
items["masses"] = self.masses
items["atoms"] = self.atoms
items["atom_style"] = self.atom_style
items["velocities"] = self.velocities
items["force_field"] = self.force_field
items["topology"] = self.topology
return LammpsData(**items)


@deprecated(
LammpsData.from_structure,
Expand Down

0 comments on commit c5b2a0a

Please sign in to comment.