Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions docs/input.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ This section defines how the configuration space is explored.
"_comment" : "stage 0, task group 0",
"type" : "lmp-md",
"ensemble": "nvt", "nsteps": 50, "temps": [50, 100], "trj_freq": 10,
"input_extra_files": ["assets/dp/SiC_ZBL.txt"],
"conf_idx": [0], "n_sample" : 3
},
{
Expand Down Expand Up @@ -131,6 +132,8 @@ The {dargs:argument}`"stages"<explore[lmp]/stages>` defines the exploration stag

The {dargs:argument}`"n_sample"<task_group[lmp-md]/n_sample>` tells the number of confgiruations randomly sampled from the set picked by {dargs:argument}`"conf_idx"<task_group[lmp-md]/conf_idx>` from {dargs:argument}`"configurations"<explore[lmp]/configurations>` for each exploration task. All configurations has the equal possibility to be sampled. The default value of `"n_sample"` is `null`, in this case all picked configurations are sampled. In the example, we have 3 samples for stage 0 task group 0 and 2 thermodynamic states (NVT, T=50 and 100K), then the task group has 3x2=6 NVT DPMD tasks.

The {dargs:argument}`"input_extra_files"<task_group[lmp-md]/input_extra_files>` list copies each named file into every exploration task directory. The file is available there by its basename. For example, a DP-ZBL model using `use_srtab` should list its ZBL table here and reference `SiC_ZBL.txt` from the model configuration.


### FP

Expand Down
19 changes: 19 additions & 0 deletions tests/exploration/test_make_task_group_from_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

class TestMakeLmpTaskGroupFromConfig(unittest.TestCase):
def setUp(self):
self.extra_file = Path("SiC_ZBL.txt")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fixture path has no directory component, which makes the basename behaviour invisible to the test.

Because this is the bare name SiC_ZBL.txt, Path(ii).name and str(ii) produce the identical string in npt_task_group.py, and replacing one with the other leaves all 5 tests passing. That is the specific property the new paragraph asserts ("available there by its basename") and the specific property the new example depends on - assets/dp/SiC_ZBL.txt is listed but referenced downstream as SiC_ZBL.txt.

Writing the fixture into a subdirectory and passing sub/SiC_ZBL.txt would make the stripping observable.

self.extra_file.write_text("ZBL table content\n")
self.config_npt = {
"type": "lmp-md",
"Ts": [100],
Expand All @@ -51,13 +53,30 @@ def setUp(self):

def tearDown(self):
os.remove(self.config_template["lmp_template_fname"])
self.extra_file.unlink()

def test_npt(self):
tgroup = make_lmp_task_group_from_config(
self.numb_models, self.mass_map, self.config_npt
)
self.assertTrue(isinstance(tgroup, NPTTaskGroup))

def test_npt_copies_input_extra_files_to_each_task(self):
config = {
**self.config_npt,
"input_extra_files": [str(self.extra_file)],
}
tgroup = make_lmp_task_group_from_config(
self.numb_models, self.mass_map, config
)
tgroup.set_conf(["LAMMPS configuration"])
tgroup.make_task()

self.assertEqual(
tgroup[0].files()[self.extra_file.name],
"ZBL table content\n",
)
Comment on lines +64 to +78

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This builds exactly one task, so the name ..._to_each_task and the docs claim "every exploration task directory" are both unverified here.

self.config_npt is {"type": "lmp-md", "Ts": [100]} with no press, so set_md leaves self.press = [None]; set_conf(["LAMMPS configuration"]) defaults n_sample to len(conf_list) == 1. make_task's itertools.product(confs, self.temps, self.press) is therefore 1x1x1. Since the assertion only reads tgroup[0], a regression that copied the extra file into only the first task of a multi-task group would leave this green.

"Ts": [100, 200] plus an assertion over every task in the group would pin it. I confirmed the real behaviour is correct - with two temperatures and two configurations all four tasks do carry the file - so this is about the test, not the code.


def test_template(self):
tgroup = make_lmp_task_group_from_config(
self.numb_models, self.mass_map, self.config_template
Expand Down