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
46 changes: 46 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# test based on ChatGPT's suggestion
name: CI

on:
push:
branches: [ master ] # run for every push to master
pull_request: # run for every PR

jobs:
tests:
runs-on: ubuntu-latest # GitHub-hosted Linux runner

steps:
# 1️⃣ Bring the source onto the runner
- name: Check out code
uses: actions/checkout@v4

# 2️⃣ System packages for build & tests
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential gfortran make \
libfftw3-dev liblapack-dev \
python3 python3-numpy

# 3️⃣ Compile the QDyn executable (bin ends up in src/qdyn)
- name: Build qdyn
run: |
make -C src clean
make -C src \
LIBS="-lfftw3 -lm -llapack" # override local path in Makefile

# 4️⃣ Run the full regression-test suite
- name: Run test suite
run: |
cd tests
bash run_test_suite.sh | tee ../test_output.log

# 5️⃣ Fail the workflow if any test reported an error
- name: Check for test failures
run: |
if grep "ERROR found" test_output.log; then
echo "Some tests failed — see log above."
exit 1
fi
7 changes: 3 additions & 4 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
# Compiler
FC = gfortran
FFLAGS =
# FFTW library needed
LIBS = -L/Users/janosj/Documents/Programs/fftw/fftw-3.3.10/lib -lfftw3 -lm -llapack
LDLIBS = -lfftw3 # This is necessary only on clusters, not on MacOS
LIBS = -L/Users/janosj/Documents/Programs/fftw/fftw-3.3.10/lib -lfftw3 -lm -llapack # FFTW and lapack libraries needed
LDLIBS =

# Name of program
OUT = qdyn
Expand All @@ -16,7 +15,7 @@ OUT = qdyn
OBJS = vars.o fparser.o fftw.o utils.o exactfactor.o init.o propag.o qdyn.o

myprogram: $(OBJS)
$(FC) -o $(OUT) ${LIBS} ${FFLAGS} $(OBJS) ${LDLIBS}
$(FC) -o $(OUT) ${FFLAGS} $(OBJS) ${LIBS} ${LDLIBS}

clean:
/bin/rm -f *.o *.mod $(OUT)
Expand Down
4 changes: 2 additions & 2 deletions tests/EF_LaserPulse_OH_1D/check_ef.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
# calculate maximum difference in the files (including x axis which shouldn't change)
max_difference = max(abs(data - ref))

# compare max difference to threshold
if max_difference > 1e-10:
# compare max difference to threshold (set based on difference produced by my Mac and GitHub Actions)
if max_difference > 5e-8:
result = False
output.write(f"Mismatch found in '{data_file}'! (max difference: {max_difference:.2e})\n")

Expand Down
9 changes: 4 additions & 5 deletions tests/RT_LaserPulse_CH3I_1D/check_ch3i.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from os.path import exists

import matplotlib.pyplot as plt
from numpy import genfromtxt, linspace, interp, std, trapz, sqrt, array, reshape, shape

xngrid = 256

# reading calculated data
wf = genfromtxt('wf1d_ad.1.dat')
nframes_wf = int(shape(wf)[0]/xngrid)
nframes_wf = int(shape(wf)[0] / xngrid)
wf = reshape(wf, (nframes_wf, xngrid, 5)).transpose((0, 2, 1))
energy = genfromtxt('energies.dat').T
t = energy[0]
Expand All @@ -33,12 +32,12 @@
# calculating mean <x> and <delta x>
x = [[], [], []]
for i in range(0, nframes_wf, 10):
x[0].append(t[i]*0.02418884254)
x[0].append(t[i] * 0.02418884254)
dx = wf[i][0][1] - wf[i][0][1]
norm = trapz(wf[i][3], wf[i][0], dx=dx)
aver_x = trapz(wf[i][3]*wf[i][0], wf[i][0], dx=dx)/norm
aver_x = trapz(wf[i][3] * wf[i][0], wf[i][0], dx=dx) / norm
x[1].append(aver_x)
aver_dx = sqrt(trapz(wf[i][3]*wf[i][0]**2, wf[i][0], dx=dx)/norm - aver_x**2)
aver_dx = sqrt(trapz(wf[i][3] * wf[i][0] ** 2, wf[i][0], dx=dx) / norm - aver_x ** 2)
x[2].append(aver_dx)
x = array(x)

Expand Down