diff --git a/.github/important_settings.fastcompile b/.github/important_settings.fastcompile new file mode 100644 index 00000000..deddd009 --- /dev/null +++ b/.github/important_settings.fastcompile @@ -0,0 +1 @@ +OPTIMIZATION_LEVEL="-O0" diff --git a/.github/important_settings.generic b/.github/important_settings.generic new file mode 100644 index 00000000..4eca1461 --- /dev/null +++ b/.github/important_settings.generic @@ -0,0 +1,51 @@ +#!/bin/bash +# A central place to put all the important paths. You probably have to modify this to make things work. + +# the fortran compiler +FORTRAN_COMPILER="mpifort" +# required compiler flags +FCFLAGS="-ffree-line-length-none -std=gnu -cpp -fallow-argument-mismatch" +# extra flags, for debugging and such +FCFLAGS_EXTRA="" + +# optimization stuff. Go all in, sometimes +OPTIMIZATION_LEVEL="-O3" +OPTIMIZATION_SENSITIVE="-O0" + +# the flag that sets the default real to a double. +DOUBLE_FLAG= # "-fdefault-real-8" +# The flag that tells the compiler where to put .o and .mod files. +MODULE_FLAG="-J" + +# These are the BLAS/LAPACK libraries. On OSX with gfortran, use the built-in 'framework accelerate' + +# -> exported outside +# PATH_LIB="/usr/lib/x86_64-linux-gnu" +PATH_INC="/usr/include" +PATH_TO_BLASLAPACK_LIB="-L/$PATH_LIB" +PATH_TO_BLASLAPACK_INC="-I/$PATH_INC" +BLASLAPACK_LIBS="-lblas -llapack -lscalapack-openmpi" + +# I use fftw for Fourier transforms. +PATH_TO_FFTW_LIB="-L/$PATH_LIB" +PATH_TO_FFTW_INC="-I/$PATH_INC" +FFTW_LIBS="-lfftw3" + +# I also use HDF5 every now and then +PATH_TO_HDF5_LIB="-L/$PATH_LIB/hdf5/openmpi/" +PATH_TO_HDF5_INC="-I/$PATH_INC/hdf5/openmpi/" +HDF5_LIBS="-lhdf5 -lhdf5_fortran" + +USECGAL=no + +# some less important things +# the header to put in python scripts. +PYTHONHEADER="#!/usr/bin/env python" + +# Which gnuplot terminal to use by default. +# Choices: aqua, qt, wxt +GNUPLOTTERMINAL="qt" + +# Precompiler flags. Selecting default gnuplot terminal, and make the progressbars work. +PRECOMPILER_FLAGS="-DGP${GNUPLOTTERMINAL} -Dclusterprogressbar" + diff --git a/.github/important_settings.x86_64 b/.github/important_settings.x86_64 new file mode 100644 index 00000000..765c1cbb --- /dev/null +++ b/.github/important_settings.x86_64 @@ -0,0 +1,54 @@ +#!/bin/bash +# A central place to put all the important paths. You probably have to modify this to make things work. + +# the fortran compiler +FORTRAN_COMPILER="mpifort" +# required compiler flags +FCFLAGS="-ffree-line-length-none -std=gnu -cpp -fallow-argument-mismatch" +# extra flags, for debugging and such +FCFLAGS_EXTRA="" + +# optimization stuff. Go all in, sometimes +OPTIMIZATION_LEVEL="-O3" +OPTIMIZATION_SENSITIVE="-O0" + +# the flag that sets the default real to a double. +DOUBLE_FLAG= # "-fdefault-real-8" +# The flag that tells the compiler where to put .o and .mod files. +MODULE_FLAG="-J" + +# These are the BLAS/LAPACK libraries. On OSX with gfortran, use the built-in 'framework accelerate' +PATH_LIB="/usr/lib/x86_64-linux-gnu" +PATH_INC="/usr/include" +PATH_TO_BLASLAPACK_LIB="-L/$PATH_LIB" +PATH_TO_BLASLAPACK_INC="-I/$PATH_INC" +BLASLAPACK_LIBS="-lblas -llapack -lscalapack-openmpi" + +# I use fftw for Fourier transforms. +PATH_TO_FFTW_LIB="-L/$PATH_LIB" +PATH_TO_FFTW_INC="-I/$PATH_INC" +FFTW_LIBS="-lfftw3" + +# we use mpifort so not needed +# PATH_TO_MPI_LIB="-L/usr/lib/x86_64-linux-gnu" +# PATH_TO_MPI_INC="-I/$PATH_INC" +# MPI_LIBS="-lmpi_mpifh -lmpi" + +# I also use HDF5 every now and then +PATH_TO_HDF5_LIB="-L/usr/lib/x86_64-linux-gnu/hdf5/openmpi/" +PATH_TO_HDF5_INC="-I/usr/include/hdf5/openmpi/" +HDF5_LIBS="-lhdf5 -lhdf5_fortran" + +USECGAL=no + +# some less important things +# the header to put in python scripts. +PYTHONHEADER="#!/usr/bin/env python" + +# Which gnuplot terminal to use by default. +# Choices: aqua, qt, wxt +GNUPLOTTERMINAL="qt" + +# Precompiler flags. Selecting default gnuplot terminal, and make the progressbars work. +PRECOMPILER_FLAGS="-DGP${GNUPLOTTERMINAL} -Dclusterprogressbar" + diff --git a/.github/important_settings.x86_64_debugflags b/.github/important_settings.x86_64_debugflags new file mode 100644 index 00000000..c559cf9b --- /dev/null +++ b/.github/important_settings.x86_64_debugflags @@ -0,0 +1,7 @@ +# debug flags +# FCFLAGS_EXTRA="-g -fbacktrace -fcheck=all -finit-real=nan -finit-derived -fmax-errors=10 --pedantic -Wall -Wextra -pedantic -Wcast-align -Wdisabled-optimization -Wmissing-include-dirs -Wshadow -Wunused -fdiagnostics-show-option -fcheck=all -Wstrict-overflow=0 -Wrealloc-lhs" +# FCFLAGS_EXTRA="-fbacktrace -fcheck=all -finit-real=nan -finit-derived -fmax-errors=10 --pedantic --warn-all" +FCFLAGS_EXTRA="-fbacktrace -finit-real=nan -finit-derived -fmax-errors=10 --pedantic --warn-all" +# PRECOMPILER_FLAGS="-DGP${GNUPLOTTERMINAL} -Dclusterprogressbar -DAGRESSIVE_SANITY" +PRECOMPILER_FLAGS="-DGP${GNUPLOTTERMINAL} -Dclusterprogressbar" +OPTIMIZATION_LEVEL="-O0" diff --git a/.github/important_settings.x86_64_fastcompile b/.github/important_settings.x86_64_fastcompile new file mode 100644 index 00000000..deddd009 --- /dev/null +++ b/.github/important_settings.x86_64_fastcompile @@ -0,0 +1 @@ +OPTIMIZATION_LEVEL="-O0" diff --git a/.github/workflows/ci_simple_compilation_and_test.yml b/.github/workflows/ci_simple_compilation_and_test.yml new file mode 100644 index 00000000..d5360133 --- /dev/null +++ b/.github/workflows/ci_simple_compilation_and_test.yml @@ -0,0 +1,78 @@ +name: Compile TDEP and test binaries +run-name: ${{ github.actor }} is trying to compile and run TDEP +on: + pull_request: + paths: + - .github/workflows/ci_simple_compilation_and_test.yml + - src/** + - tests/** + workflow_dispatch: + +env: + ARTIFACTS: tdep-test-artifacts + N_THREADS: 4 + +jobs: + Compile-and-run-TDEP: + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - name: Check out TDEP code + uses: actions/checkout@v4 + with: + repository: tdep-developers/tdep + - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." + - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." + - name: Install packages required for building TDEP + run: | + sudo apt-get update + sudo apt-get install -y \ + gfortran \ + libblas-dev \ + liblapack-dev \ + libhdf5-dev \ + libhdf5-serial-dev \ + libhdf5-openmpi-dev \ + openmpi-bin \ + libopenmpi-dev \ + libfftw3-dev \ + libscalapack-openmpi-dev + - name: compile TDEP with debug flags + id: compile_debug + run: | + cd ${{ github.workspace }} + cp .github/important_settings.x86_64 important_settings + cat .github/important_settings.fastcompile >> important_settings + cat .github/important_settings.x86_64_debugflags >> important_settings + bash build_things.sh --nthreads_make ${{ env.N_THREADS }} + - name: compile TDEP production + if: steps.compile_debug.outcome == 'success' + id: compile_production + run: | + cd ${{ github.workspace }} + cp .github/important_settings.x86_64 important_settings + bash build_things.sh --nthreads_make ${{ env.N_THREADS }} + - name: Create testfiles + id: testfiles + if: steps.compile_production.outcome == 'success' + run: | + cd ${{ github.workspace }}/tests + make + - name: Check tests + id: test + if: steps.testfiles.outcome == 'success' + run: | + cd ${{ github.workspace }}/tests + pip install -r requirements.txt + make test || exit 1 + - name: Upload results + uses: actions/upload-artifact@v4 + if: failure() + with: + name: ${{ env.ARTIFACTS }} + path: | + ${{ github.workspace }}/bin/ + ${{ github.workspace }}/build/ + ${{ github.workspace }}/tests/ + ${{ github.workspace }}/bashrc_tdep + retention-days: 7 diff --git a/tests/pytest.ini b/tests/pytest.ini index 233f24b5..58620ffb 100644 --- a/tests/pytest.ini +++ b/tests/pytest.ini @@ -1,3 +1,5 @@ # pytest.ini or .pytest.ini [pytest] norecursedirs = optional +filterwarnings = + ignore::RuntimeWarning:importlib._bootstrap: diff --git a/tests/thermal_conductivity/reference/outfile.thermal_conductivity_grid.hdf5 b/tests/thermal_conductivity/reference/outfile.thermal_conductivity_grid.hdf5 deleted file mode 100644 index f8bd4e9e..00000000 Binary files a/tests/thermal_conductivity/reference/outfile.thermal_conductivity_grid.hdf5 and /dev/null differ diff --git a/tests/thermal_conductivity/test_thermal_conductivity.py b/tests/thermal_conductivity/test_thermal_conductivity.py index c8f36bfa..92772dc6 100644 --- a/tests/thermal_conductivity/test_thermal_conductivity.py +++ b/tests/thermal_conductivity/test_thermal_conductivity.py @@ -5,12 +5,11 @@ parent = Path(__file__).parent folder = parent / "reference" -files_hdf5 = [ - "outfile.thermal_conductivity_grid.hdf5", -] +file = "outfile.thermal_conductivity" +file_hdf5 = "outfile.thermal_conductivity_grid.hdf5" -def test_thermal_conductivity(file="outfile.thermal_conductivity", atol=20, rtol=5): +def test_thermal_conductivity(file=file, atol=1, rtol=0.1): file_ref = folder / file file_new = parent / file @@ -22,20 +21,23 @@ def test_thermal_conductivity(file="outfile.thermal_conductivity", atol=20, rtol ) -def test_hdf5(files=files_hdf5, atol=1, rtol=0.01): - for file in files: - file_ref = folder / file - file_new = parent / file +def test_conductivity_comparison( + file=parent / file, + file_grid=parent / file_hdf5, +): + """Check if the thermal conducivities conincide""" + data1 = np.loadtxt(file) - ds_ref = xr.load_dataset(file_ref) - ds_new = xr.load_dataset(file_new) + # without off-diagonal contribution + kappa1 = data1[0][:3] + data1[1][:3] - for var in ds_ref.data_vars: - x = ds_ref[var] - y = ds_new[var] - np.testing.assert_allclose(x, y, atol=atol, rtol=rtol, err_msg=var) + ds = xr.load_dataset(file_grid) + + kappa2 = np.diag(ds.thermal_conductivity.sum(axis=(0, 1)) / ds.number_of_qpoints) + + np.testing.assert_allclose(kappa1, kappa2) if __name__ == "__main__": test_thermal_conductivity() - test_hdf5() + test_conductivity_comparison()