Skip to content

Commit fcedda5

Browse files
committed
add support for full style
1 parent c0a33c4 commit fcedda5

1 file changed

Lines changed: 39 additions & 6 deletions

File tree

pyiron_lammps/compatibility/file.py

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from typing import Optional
44

55
from ase.atoms import Atoms
6+
import pandas
67

78
from pyiron_lammps.compatibility.calculate import (
89
calc_md,
@@ -11,7 +12,7 @@
1112
)
1213
from pyiron_lammps.output import parse_lammps_output
1314
from pyiron_lammps.potential import get_potential_by_name
14-
from pyiron_lammps.structure import write_lammps_datafile
15+
from pyiron_lammps.compatibility.structure import write_lammps_datafile
1516

1617

1718
def lammps_file_interface_function(
@@ -85,11 +86,41 @@ def lammps_file_interface_function(
8586
calc_kwargs = {}
8687

8788
os.makedirs(working_directory, exist_ok=True)
88-
potential_dataframe = get_potential_by_name(
89-
potential_name=potential, resource_path=resource_path
90-
)
91-
lmp_str_lst = lammps_file_initialization(structure=structure)
92-
lmp_str_lst += potential_dataframe["Config"]
89+
if isinstance(potential, str):
90+
potential_dataframe = get_potential_by_name(
91+
potential_name=potential, resource_path=resource_path
92+
)
93+
elif isinstance(potential, pandas.DataFrame):
94+
potential_dataframe = potential.iloc[0]
95+
else:
96+
raise TypeError()
97+
98+
potential_replace = {}
99+
potential_lst = []
100+
for l in potential_dataframe["Config"]:
101+
if l.startswith("units"):
102+
potential_replace["units"] = l
103+
elif l.startswith("atom_style"):
104+
potential_replace["atom_style"] = l
105+
elif l.startswith("dimension"):
106+
potential_replace["dimension"] = l
107+
else:
108+
potential_lst.append(l)
109+
110+
lmp_str_lst = []
111+
atom_type = "atomic"
112+
for l in lammps_file_initialization(structure=structure):
113+
if l.startswith("units") and "units" in potential_replace:
114+
lmp_str_lst.append(potential_replace["units"])
115+
elif l.startswith("atom_style") and "atom_style" in potential_replace:
116+
lmp_str_lst.append(potential_replace["atom_style"])
117+
atom_type = potential_replace["atom_style"].split()[-1]
118+
elif l.startswith("dimension") and "dimension" in potential_replace:
119+
lmp_str_lst.append(potential_replace["dimension"])
120+
else:
121+
lmp_str_lst.append(l)
122+
123+
lmp_str_lst += potential_lst
93124
lmp_str_lst += ["variable dumptime equal {} ".format(calc_kwargs.get("n_print", 1))]
94125
lmp_str_lst += [
95126
"dump 1 all custom ${dumptime} dump.out id type xsu ysu zsu fx fy fz vx vy vz",
@@ -123,6 +154,8 @@ def lammps_file_interface_function(
123154
units=units,
124155
file_name="lammps.data",
125156
working_directory=working_directory,
157+
atom_type=atom_type,
158+
potential_lst=potential_lst,
126159
)
127160

128161
shell = subprocess.check_output(

0 commit comments

Comments
 (0)