Cleaned up and expanded the set of examples being tested

This commit is contained in:
Trung Nguyen
2024-01-31 14:47:11 -06:00
parent b1688d4287
commit 911227a981

View File

@ -10,47 +10,24 @@ UPDATE: Jan 30, 2024:
+ simplify the build configuration (no need to build the Python module) + simplify the build configuration (no need to build the Python module)
NOTE: Need to allow to tolerances specified for invidual input scripts, NOTE: Need to allow to tolerances specified for invidual input scripts,
or each config.yaml is for a set of example folders or each config.yaml is for a set of example folders
Example usage: Example usage:
1) Simple use: 1) Simple use (using the provided tools/regression-tests/config.yaml and the examples/ folder at the top level)
python3 run_tests.py --lmp-bin=/path/to/lmp_binary python3 run_tests.py --lmp-bin=/path/to/lmp_binary
2) Use a custom testing configuration 2) Use a custom testing configuration
python3 run_tests.py --lmp-bin=/path/to/lmp_binary --config-file=/path/to/config/file/config.yaml python3 run_tests.py --lmp-bin=/path/to/lmp_binary --config-file=/path/to/config/file/config.yaml
3) Specify a list of example folders with a modifed configuration (e.g. different tolerances)
python3 run_tests.py --lmp-bin=/path/to/lmp_binary \
-------------------------------------------------------------------------------------------------------------- --example-folders="/path/to/examples/folder1;/path/to/examples/folder2" \
Original plan: using the LAMMPS Python module --config-file=/path/to/config/file/config.yaml
The following steps are for setting up regression tests with the LAMMPS Python module
0) Create a virtual environment, and activate it
python -m venv lmp-venv
source lmp-venv/bin/activate
PYTHON_EXECUTABLE=`which python`
INSTALL_PREFIX=$(${PYTHON_EXECUTABLE} -c "import sys; print(sys.prefix)")
1) Build LAMMPS as a shared lib and install the LAMMPS python module into the virtual environment
git clone https://github.com/lammps/lammps.git lammps
cd lammps
mkdir build && cd build
cmake ../cmake/presets/basic.cmake -DBUILD_SHARED_LIBS=on -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX
make -j4
make install-python
2) Run this script, after activating the virtual environment and having the input scripts with markers ready:
source lmp-venv/bin/activate
python3 run_tests.py
''' '''
#from lammps import lammps
import os import os
import fnmatch import fnmatch
import re, yaml
import numpy as np
import subprocess import subprocess
import yaml
import numpy as np
from argparse import ArgumentParser from argparse import ArgumentParser
try: try:
@ -461,39 +438,47 @@ if __name__ == "__main__":
# Using in place input scripts # Using in place input scripts
inplace_input = True inplace_input = True
# if the example folders are not specified from the command-line argument -example-folders
if len(example_subfolders) == 0:
example_subfolders.append("../../examples/melt") example_subfolders.append("../../examples/melt")
if 'ASPHERE' in packages:
# example_subfolders.append('../../examples/ASPHERE/ellipsoid')
example_subfolders.append('../../examples/ellipse')
# append the example subfolders depending on the installed packages # append the example subfolders depending on the installed packages
if 'MOLECULE' in packages: if 'MOLECULE' in packages:
example_subfolders.append('../../examples/micelle') example_subfolders.append('../../examples/micelle')
# peptide thermo_style as multi # peptide thermo_style as multi
#example_subfolders.append('../../examples/peptide') #example_subfolders.append('../../examples/peptide')
#if 'ASPHERE' in packages:
# example_subfolders.append('../../examples/ASPHERE/ellipsoid')
if 'AMOEBA' in packages: if 'AMOEBA' in packages:
example_subfolders.append('../../examples/amoeba') example_subfolders.append('../../examples/amoeba')
if 'BODY' in packages: if 'BODY' in packages:
example_subfolders.append('../../examples/body') example_subfolders.append('../../examples/body')
if 'DIELECTRIC' in packages:
example_subfolders.append('../../examples/PACKAGES/dielectric')
if 'COLLOID' in packages: if 'COLLOID' in packages:
example_subfolders.append('../../examples/colloid') example_subfolders.append('../../examples/colloid')
if 'DIELECTRIC' in packages:
example_subfolders.append('../../examples/PACKAGES/dielectric')
if 'DIPOLE' in packages: if 'DIPOLE' in packages:
example_subfolders.append('../../examples/dipole') example_subfolders.append('../../examples/dipole')
if 'MANYBODY' in packages: if 'MANYBODY' in packages:
example_subfolders.append('../../examples/tersoff') example_subfolders.append('../../examples/tersoff')
example_subfolders.append('../../examples/vashishta') example_subfolders.append('../../examples/vashishta')
example_subfolders.append('../../examples/threebody')
if 'RIGID' in packages: if 'RIGID' in packages:
example_subfolders.append('../../examples/rigid') example_subfolders.append('../../examples/rigid')
if 'SRD' in packages:
example_subfolders.append('../../examples/srd')
if inplace_input == True: if inplace_input == True:
# save current working dir # save current working dir
@ -531,7 +516,7 @@ if __name__ == "__main__":
else: else:
# or using the input scripts in the working directory # or using the input scripts in the working directory -- for debugging purposes
input_list=['in.lj', 'in.rhodo', 'in.eam'] input_list=['in.lj', 'in.rhodo', 'in.eam']
total_tests = len(input_list) total_tests = len(input_list)
passed_tests = iterate(input_list, config) passed_tests = iterate(input_list, config)