Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issues for thermal conductivity and running in parallel. #53

Merged
merged 1 commit into from
Mar 22, 2024
Merged
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
4 changes: 4 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
=======
History
=======
2024.3.22 -- Corrected issue with e.g. heat flux calculations
* Corrected an issue running LAMMPS via Python, intorduced in the new scheme for
executing. It ignored parallelism.

2024.3.21 -- Switched to new installation scheme
* Fully support ~/SEAMM/lammps.ini
* Updated to new installer
Expand Down
21 changes: 0 additions & 21 deletions lammps_step/data/configuration.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,3 @@
# they can be viewed without the SEAMM Dashboard.

# html = False

#
# SEAMM picks up the environment variables such as SLURM_NTASKS, strips the
# prefix from them and replaces any instances in the command line that are
# enclosed in braces. Hopefully this lets you construct the correct command
# line.
#
# The LAMMPS installer does not handle these variables! They are here
# just in case!

# lammps-serial = lmp_serial
# lammps-mpi = lmp_mpi
# mpiexec = mpiexec

# Optional command-line arguments for LAMMPS. These are usually used with accelerators
# such as Kokkos or GPU to automatically apply the accelerator. Again there is a normal
# and GPU version

# cmd-args = -k on -sf kk
# gpu-cmd-args = -k on g {ngpus} -sf kk -pk kokkos gpu/aware on newton on neigh full neigh/thread on neigh/transpose off comm device

18 changes: 17 additions & 1 deletion lammps_step/data/lammps.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
# code = mpirun -n {NTASKS} -H {NODELIST} -npernode {NTASKS_PER_NODE}

code = mpirun -n {NTASKS} lmp
python = python

# Optional command-line arguments for LAMMPS. These are usually used with accelerators
# such as Kokkos or GPU to automatically apply the accelerator. Again there is a normal
# and GPU version

# cmd-args = -k on -sf kk
# gpu-cmd-args = -k on g {ngpus} -sf kk -pk kokkos gpu/aware on newton on neigh full neigh/thread on neigh/transpose off comm device

# The name and location of the Docker container to use, optionally with the version

Expand Down Expand Up @@ -53,7 +61,15 @@ installation = conda
#
# code = mpirun -n {NTASKS} -H {NODELIST} -npernode {NTASKS_PER_NODE}

code = mpirun -n {NTASKS} lmp
code = mpirun -np {NTASKS} lmp
python = mpirun -np {NTASKS} python

# Optional command-line arguments for LAMMPS. These are usually used with accelerators
# such as Kokkos or GPU to automatically apply the accelerator. Again there is a normal
# and GPU version

# cmd-args = -k on -sf kk
# gpu-cmd-args = -k on g {ngpus} -sf kk -pk kokkos gpu/aware on newton on neigh full neigh/thread on neigh/transpose off comm device

######################### conda section ############################
# The full path to the conda executable:
Expand Down
2 changes: 1 addition & 1 deletion lammps_step/data/seamm-lammps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ dependencies:
- python
# Executables, etc.
- openmpi
- lammps
- lammps * *mpi_openmpi*
- openkim-models
- mpi4py
33 changes: 24 additions & 9 deletions lammps_step/lammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,27 +663,34 @@

if path.exists():
full_config.read(ini_dir / "lammps.ini")
full_config.set("local", "_origin_", f"{ini_dir / 'lammps.ini'}")

Check warning on line 666 in lammps_step/lammps.py

View check run for this annotation

Codecov / codecov/patch

lammps_step/lammps.py#L666

Added line #L666 was not covered by tests

# If the section we need doesn't exists, get the default
if not path.exists() or executor_type not in full_config:
resources = importlib.resources.files("lammps_step") / "data"
ini_text = (resources / "lammps.ini").read_text()
full_config.read_string(ini_text)
full_config.set("local", "_origin_", "lammps default ini file")

Check warning on line 673 in lammps_step/lammps.py

View check run for this annotation

Codecov / codecov/patch

lammps_step/lammps.py#L673

Added line #L673 was not covered by tests

# Getting desperate! Look for an executable in the path
if executor_type not in full_config:
path = shutil.which("lammps")
path = shutil.which("lmp")

Check warning on line 677 in lammps_step/lammps.py

View check run for this annotation

Codecov / codecov/patch

lammps_step/lammps.py#L677

Added line #L677 was not covered by tests
if path is None:
raise RuntimeError(
f"No section for '{executor_type}' in LAMMPS ini file "
f"({ini_dir / 'lammps.ini'}), nor in the defaults, nor "
"in the path!"
)
else:
full_config[executor_type] = {
"installation": "local",
"code": str(path),
}
full_config.add_section(executor_type)
full_config.set(executor_type, "installation", "local")
full_config.set(executor_type, "code", str(path))

Check warning on line 687 in lammps_step/lammps.py

View check run for this annotation

Codecov / codecov/patch

lammps_step/lammps.py#L685-L687

Added lines #L685 - L687 were not covered by tests

# And we may need python!
full_config.set("local", "items", f"{full_config.items('local')}")
if not full_config.has_option(executor_type, "python"):
full_config.set(executor_type, "python", "mpirun -np {NTASKS} python")
full_config.set(executor_type, "_python source_", "default value")

Check warning on line 693 in lammps_step/lammps.py

View check run for this annotation

Codecov / codecov/patch

lammps_step/lammps.py#L690-L693

Added lines #L690 - L693 were not covered by tests

# If the ini file does not exist, write it out!
if not path.exists():
Expand All @@ -707,11 +714,19 @@
# Setup the command lines
cmd = []

if "python script" in files:
if "run_lammps" in files:

Check warning on line 717 in lammps_step/lammps.py

View check run for this annotation

Codecov / codecov/patch

lammps_step/lammps.py#L717

Added line #L717 was not covered by tests
cmd = ["{python}", "run_lammps"]
if "GPUS" not in ce and config["cmd_args"] != "":
if (

Check warning on line 719 in lammps_step/lammps.py

View check run for this annotation

Codecov / codecov/patch

lammps_step/lammps.py#L719

Added line #L719 was not covered by tests
"GPUS" not in ce
and "cmd_args" in config
and config["cmd_args"] != ""
):
cmd.extend(["--cmd-args", config["cmd_args"]])
if "GPUS" in ce and config["gpu_cmd_args"] != "":
if (

Check warning on line 725 in lammps_step/lammps.py

View check run for this annotation

Codecov / codecov/patch

lammps_step/lammps.py#L725

Added line #L725 was not covered by tests
"GPUS" in ce
and "gpu_cmd_args" in config
and config["gpu_cmd_args"] != ""
):
cmd.extend(["--cmd-args", config["gpu_cmd_args"]])
else:
cmd = ["{code}"]
Expand All @@ -723,7 +738,7 @@
cmd.extend(config["cmd_args"].split())
if (
"GPUS" in ce
and config["gpu_cmd_args"] != ""
and "gpu_cmd_args" in config
and config["gpu_cmd_args"] != ""
):
cmd.extend(config["gpu_cmd_args"].split())
Expand Down
Loading