Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
fecef55
fixed atom_style issue when converting from structure
vir-k01 Oct 31, 2024
159be72
BaseLammpsGenerator can def benefit from taking both raw strings and …
vir-k01 Dec 3, 2024
b6edc3d
Merge pull request #1 from materialsproject/master
vir-k01 Dec 3, 2024
cfac0bf
Need this to have a general way to write out FF (and other non-standa…
vir-k01 Dec 10, 2024
fd0cc72
Merge pull request #2 from materialsproject/master
vir-k01 Jan 6, 2025
410d4b4
Added new base lammps generator
vir-k01 Jan 8, 2025
37c387f
fixed atom_style issue when converting from structure
vir-k01 Oct 31, 2024
f736361
BaseLammpsGenerator can def benefit from taking both raw strings and …
vir-k01 Dec 3, 2024
fc0bb82
Need this to have a general way to write out FF (and other non-standa…
vir-k01 Dec 10, 2024
5d71ba2
Added new base lammps generator
vir-k01 Jan 8, 2025
74a2ce5
Add LammpsSettings to check convenience input
esoteric-ephemera Jan 8, 2025
c1f2ed6
Merge branch 'lammps_sets' of github.com:vir-k01/pymatgen into lammps…
vir-k01 Jan 8, 2025
608e889
Revert "Merge branch 'lammps_sets' of github.com:vir-k01/pymatgen int…
vir-k01 Jan 8, 2025
363fee6
Fixed commit merge issues
vir-k01 Jan 8, 2025
3f2d0b1
Removed LammpsInputSettings class, moved to convience LammpsSettings …
vir-k01 Jan 9, 2025
f88cc2d
Updated docstring for LammpsInput
vir-k01 Jan 9, 2025
edcfe39
Redid BaseLammpsGenerator
vir-k01 Apr 18, 2025
0ab2389
Merge remote-tracking branch 'upstream/master' into lammps_sets_templ…
vir-k01 Apr 19, 2025
d1dd967
Made input set validation far more general, updated minimize template
vir-k01 Apr 19, 2025
be77b06
removed debugging print statements
vir-k01 Apr 19, 2025
aa32a30
pre-commit auto-fixes
pre-commit-ci[bot] Apr 19, 2025
75b0637
Merge remote-tracking branch 'upstream/master' into lammps_sets_templ…
esoteric-ephemera Apr 21, 2025
f8f33b4
precommit / sync head
esoteric-ephemera Apr 21, 2025
3e2a5a0
Account for species specified through the FF dict
vir-k01 Apr 21, 2025
192dcb0
bug fix in latest commit
vir-k01 Apr 22, 2025
d8a5ae5
fix bug in specifying fixes
vir-k01 Apr 22, 2025
43647bf
Add thermostating options when using berendsen barostats
vir-k01 Apr 22, 2025
b4eb27c
added langevin barostat, fixed barostat init
vir-k01 Apr 22, 2025
da8f9bc
Fixed warnings, better default handling
vir-k01 Apr 29, 2025
bc9a36e
e Use ### for filtering out flags, cleaned out base settings loop
vir-k01 Apr 29, 2025
95bed24
possible bug in conditional if recontructing LammpsData from a serial…
vir-k01 May 6, 2025
3a2c21a
bug fix in setting read_restart command, changed input data to input.…
vir-k01 May 6, 2025
240a604
Merge remote-tracking branch 'remotes/upstream/master' into lammps_se…
vir-k01 Jun 26, 2025
95a3b4c
Added convinience method for LammpsData.from_molecule
vir-k01 Jun 26, 2025
44f37cb
added basic support for molecules, plus inputs tailored to molecules
vir-k01 Jun 26, 2025
c97762c
Merge pull request #4 from materialsproject/master
vir-k01 Jul 30, 2025
158f9ad
Merge pull request #5 from materialsproject/master
vir-k01 Sep 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/pymatgen.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 49 additions & 6 deletions src/pymatgen/io/lammps/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@
from collections.abc import Sequence
from typing import Any, Literal

from numpy.typing import ArrayLike
from typing_extensions import Self

from pymatgen.core.sites import Site
from pymatgen.core.structure import IStructure, SiteCollection
from pymatgen.core.structure import IMolecule, IStructure, SiteCollection

__author__ = "Kiran Mathew, Zhi Deng, Tingzheng Hou"
__copyright__ = "Copyright 2018, The Materials Virtual Lab"
Expand Down Expand Up @@ -259,8 +260,8 @@ class 2 force field are valid keys, and each value is a
keys, and each value is a DataFrame.
atom_style (str): Output atom_style. Default to "full".
"""
if velocities is not None and len(atoms) != len(velocities):
raise ValueError(f"{len(atoms)=} and {len(velocities)=} mismatch")
# if velocities is not None and len(atoms) != len(velocities):
# raise ValueError(f"{len(atoms)=} and {len(velocities)=} mismatch")

if force_field:
all_ff_kws = SECTION_KEYWORDS["ff"] + SECTION_KEYWORDS["class2"]
Expand Down Expand Up @@ -851,7 +852,7 @@ def from_structure(
cls,
structure: Structure | IStructure,
ff_elements: Sequence[str] | None = None,
atom_style: Literal["atomic", "charge"] = "charge",
atom_style: Literal["atomic", "charge", "full"] = "charge",
is_sort: bool = False,
) -> Self:
"""Simple constructor building LammpsData from a structure without
Expand All @@ -863,7 +864,7 @@ def from_structure(
be present due to force field settings but not
necessarily in the structure. Default to None.
atom_style (str): Choose between "atomic" (neutral) and
"charge" (charged). Default to "charge".
"charge" (charged) and "full". Default to "charge".
is_sort (bool): whether to sort sites
"""
struct = structure.get_sorted_structure() if is_sort else structure.copy()
Expand Down Expand Up @@ -892,6 +893,48 @@ def from_structure(
topo = Topology(boxed_s)
return cls.from_ff_and_topologies(box=box, ff=ff, topologies=[topo], atom_style=atom_style)

@classmethod
def from_molecule(
cls, molecule: Molecule | IMolecule, box_or_lattice: LammpsBox | Lattice | ArrayLike, **kwargs
) -> Self:
"""Simple constructor building LammpsData from a molecule and a Lattice without
force field parameters. When dealing with molecules however, it is RECOMMENDED to
define a LammpsData object from a ForceField object and a Topology object
instead, which allows for more flexibility in defining force field parameters and
topologies. This implementation is mainly for convenience, and does not assign
"bonds" and "angles" sections in the topology!

Args:
molecule (Molecule): Input molecule.
box_or_lattice (LammpsBox or Lattice or ArrayLike): Simulation box or lattice.
ff_elements ([str]): List of strings of elements that must
be present due to force field settings but not
necessarily in the molecule. Default to None.
atom_style (str): Choose between "atomic" (neutral) and
"charge" (charged) and "full". Default to "charge".
"""

if isinstance(box_or_lattice, LammpsBox):
box_or_lattice = box_or_lattice.to_lattice()

box_or_lattice.pbc = (False, False, False)

structure = Structure(
lattice=box_or_lattice,
species=molecule.species,
coords=molecule.cart_coords,
site_properties=molecule.site_properties if hasattr(molecule, "site_properties") else {},
charge=molecule.charge if hasattr(molecule, "charge") else 0,
coords_are_cartesian=True,
labels=molecule.labels if hasattr(molecule, "labels") else None,
properties=molecule.properties if hasattr(molecule, "properties") else {},
)

return cls.from_structure(
structure=structure,
**kwargs,
)

def set_charge_atom(self, charges: dict[int, float]) -> None:
"""Set the charges of specific atoms of the data.

Expand Down Expand Up @@ -1299,7 +1342,7 @@ def __init__(
self._coordinates.index = self._coordinates.index.map(int)
max_xyz = self._coordinates[["x", "y", "z"]].max().max()
min_xyz = self._coordinates[["x", "y", "z"]].min().min()
self.box = LammpsBox(np.array(3 * [[min_xyz - 0.5, max_xyz + 0.5]]))
self.box = LammpsBox(3 * [[min_xyz - 0.5, max_xyz + 0.5]])
self.atom_style = atom_style
self.n = sum(self._list_of_numbers)
self.names = []
Expand Down
Loading