Skip to content
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
60 changes: 60 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,63 @@ jobs:
path: |
run/
pip-freeze.txt

lammps-lpc3d-cpu:
# Workflow test of the LAMMPS-LPC3D coupling on a reduced system:
# 2 pore sizes, 10% of the molecules, 100 NPT + 200 NVT steps, 4 MPI ranks.
# The densities are not physically meaningful; the test checks that the
# calls (fftool, packmol, LAMMPS, centre of mass, LPC3D) and the MPI
# workflow run end to end.
name: LAMMPS-LPC3D coupling (CPU, MPI)
runs-on: ubuntu-latest
timeout-minutes: 45
defaults:
run:
shell: bash -el {0}

steps:
- uses: actions/checkout@v4

- name: Set up conda environment (LAMMPS, mpi4py, packmol)
uses: mamba-org/setup-micromamba@v2
with:
environment-file: tests/ci/coupling/environment.yml
cache-environment: true

- name: Check LAMMPS installation
run: |
python -c "from lammps import lammps; l = lammps(cmdargs=['-log', 'none']); print('LAMMPS', l.version(), 'MPI:', l.has_mpi_support); missing = {'MOLECULE', 'KSPACE', 'RIGID'} - set(l.installed_packages); assert not missing, f'missing LAMMPS packages: {missing}'"
micromamba env export > conda-env.yml

- name: Prepare reduced coupled run
run: bash tests/ci/coupling/prepare.sh run

- name: Run LAMMPS-LPC3D
working-directory: run
env:
OMP_NUM_THREADS: "1"
run: |
set -o pipefail
mpirun --oversubscribe -np 4 python3 LAMMPS-LPC3D.py -i lattice_gas.inpt 2>&1 | tee log.lpc3d

- name: Check LAMMPS side of the coupling
run: python3 tests/ci/coupling/check_coupling.py run

- name: Check LPC3D outputs
run: python3 tests/ci/check_outputs.py run 3

- name: Upload outputs and environment
if: always()
uses: actions/upload-artifact@v4
with:
name: lammps-lpc3d-cpu
path: |
run/log.lpc3d
run/all_densities.dat
run/*.txt
run/*.dat
run/simulation_*/log.lammps
run/simulation_*/packmol.log
run/simulation_*/fftool.log*
run/simulation_*/NVT/log.lammps
conda-env.yml
4 changes: 3 additions & 1 deletion LAMMPS-LPC3D/LAMMPS-LPC3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,9 @@ def fourier_transform(ReGtotsmp, ImGtotsmp, Nvalues, dwell, larmorfreq, tau, nsa
minvalue = np.min(NMR_spec)
NMR_spec -= minvalue

save = np.trapz(NMR_spec, NMR_freq)
# np.trapz was renamed np.trapezoid in NumPy 2.0 and later removed
trapezoid = getattr(np, "trapezoid", None) or np.trapz
save = trapezoid(NMR_spec, NMR_freq)

name = f"Normalised_spectrum-{nsample}-bloc-{nb}.dat"
with open(name, "w") as outFT:
Expand Down
40 changes: 40 additions & 0 deletions ci-fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 79f7dc3..927349d 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -29,7 +29,8 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
- pip install pystencils numba ipython matplotlib pyevtk
+ # LPC3D uses pystencils.session, removed in pystencils 2.x
+ pip install "pystencils<2" numba ipython matplotlib pyevtk
pip freeze > pip-freeze.txt

- name: Prepare run directory
@@ -45,7 +46,9 @@ jobs:
env:
OMP_NUM_THREADS: "2"
NUMBA_NUM_THREADS: "2"
- run: python3 ../LPC3D.py -i lattice_gas.inpt | tee log.lpc3d
+ run: |
+ set -o pipefail
+ python3 ../LPC3D.py -i lattice_gas.inpt | tee log.lpc3d

- name: Check outputs
run: |
diff --git a/LPC3D.py b/LPC3D.py
index ac43f4d..e0cc7ab 100644
--- a/LPC3D.py
+++ b/LPC3D.py
@@ -492,7 +492,9 @@ def main():
minvalue = np.min(NMR_spec)
NMR_spec -= minvalue

- save = np.trapz(NMR_spec, NMR_freq)
+ # np.trapz was renamed np.trapezoid in NumPy 2.0 and later removed
+ trapezoid = getattr(np, "trapezoid", None) or np.trapz
+ save = trapezoid(NMR_spec, NMR_freq)

name = f"Normalised_spectrum-{nsample}-bloc-{nb}.dat"
with open(name, "w") as outFT:
Loading
Loading