|
3 | 3 | from typing import Optional |
4 | 4 |
|
5 | 5 | from ase.atoms import Atoms |
| 6 | +import pandas |
6 | 7 |
|
7 | 8 | from pyiron_lammps.compatibility.calculate import ( |
8 | 9 | calc_md, |
|
11 | 12 | ) |
12 | 13 | from pyiron_lammps.output import parse_lammps_output |
13 | 14 | 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 |
15 | 16 |
|
16 | 17 |
|
17 | 18 | def lammps_file_interface_function( |
@@ -85,11 +86,41 @@ def lammps_file_interface_function( |
85 | 86 | calc_kwargs = {} |
86 | 87 |
|
87 | 88 | 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 |
93 | 124 | lmp_str_lst += ["variable dumptime equal {} ".format(calc_kwargs.get("n_print", 1))] |
94 | 125 | lmp_str_lst += [ |
95 | 126 | "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( |
123 | 154 | units=units, |
124 | 155 | file_name="lammps.data", |
125 | 156 | working_directory=working_directory, |
| 157 | + atom_type=atom_type, |
| 158 | + potential_lst=potential_lst, |
126 | 159 | ) |
127 | 160 |
|
128 | 161 | shell = subprocess.check_output( |
|
0 commit comments