Skip to content

Commit

Permalink
Run github tests on old stella releases
Browse files Browse the repository at this point in the history
  • Loading branch information
HanneThienpondt committed Sep 30, 2024
1 parent 3289d75 commit 57844be
Show file tree
Hide file tree
Showing 6 changed files with 218 additions and 6 deletions.
185 changes: 185 additions & 0 deletions .github/workflows/old_stella_releases.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
# Run these tests automatically on Github on every push and pull request.
# Use the macOS operating system, which has 4 cores.
name: Check old stella releases
on: [push]

# We always run in a bash shell
defaults:
run:
shell: bash

# First build stella, and then perform python tests
jobs:

#-----------------------------------------------------------------------
# Python tests
#-----------------------------------------------------------------------

# Perform python tests one by one
stella_v0.5:
runs-on: ubuntu-22.04
env:
OMPI_MCA_rmaps_base_oversubscribe: yes
MPIRUN: mpiexec -np
STELLA_SYSTEM: gnu_ubuntu

# Run the same set-up multiple times
strategy:
fail-fast: false
matrix:
config:
- name: "1 - Does stella run "
#- name: "2 - Geometry"
#- name: "3 - Gyrokinetic equation"
#- name: "4 - Flux tube"
#- name: "5 - Diagnostics"
#- name: "6 - Full Flux Surface"
#- name: "7 - Electromagnetic effects"

steps:

# Check-out repository under $GITHUB_WORKSPACE
- name: Check out repository
uses: actions/checkout@v4

# Install dependencies
- name: Install dependencies and python virtual environment
run: |
sudo apt update
sudo apt install -y gfortran make libfftw3-dev libnetcdf-dev libnetcdff-dev
sudo apt install -y netcdf-bin python3 python3-pip openmpi-bin libopenmpi-dev
pip3 install --user -r AUTOMATIC_TESTS/requirements.txt
sed -i 's/nproc = 16/nproc = 4/g' AUTOMATIC_TESTS/config.ini
# Coppy stella executable from AUTOMATIC_TESTS/numerical_tests/stella_releases
- name: Download stella
run: |
cp AUTOMATIC_TESTS/numerical_tests/stella_releases/stella_v0.7 stella
# Perform python tests
- name: Numerical python tests
run: |
# Make stella executable
chmod +x stella
# Run one of the python tests
if ${{ contains(matrix.config.name, '1 -') }}; then make numerical-tests-1; fi
if ${{ contains(matrix.config.name, '2 -') }}; then make numerical-tests-2; fi
if ${{ contains(matrix.config.name, '3 -') }}; then make numerical-tests-3; fi
if ${{ contains(matrix.config.name, '4 -') }}; then make numerical-tests-4; fi
if ${{ contains(matrix.config.name, '5 -') }}; then make numerical-tests-5; fi
if ${{ contains(matrix.config.name, '6 -') }}; then make numerical-tests-6; fi
if ${{ contains(matrix.config.name, '7 -') }}; then make numerical-tests-7; fi
# Perform python tests one by one
stella_v0.6:
runs-on: ubuntu-22.04
env:
OMPI_MCA_rmaps_base_oversubscribe: yes
MPIRUN: mpiexec -np
STELLA_SYSTEM: gnu_ubuntu

# Run the same set-up multiple times
strategy:
fail-fast: false
matrix:
config:
- name: "1 - Does stella run "
#- name: "2 - Geometry"
#- name: "3 - Gyrokinetic equation"
#- name: "4 - Flux tube"
#- name: "5 - Diagnostics"
#- name: "6 - Full Flux Surface"
#- name: "7 - Electromagnetic effects"

steps:

# Check-out repository under $GITHUB_WORKSPACE
- name: Check out repository
uses: actions/checkout@v4

# Install dependencies
- name: Install dependencies and python virtual environment
run: |
sudo apt update
sudo apt install -y gfortran make libfftw3-dev libnetcdf-dev libnetcdff-dev
sudo apt install -y netcdf-bin python3 python3-pip openmpi-bin libopenmpi-dev
pip3 install --user -r AUTOMATIC_TESTS/requirements.txt
sed -i 's/nproc = 16/nproc = 4/g' AUTOMATIC_TESTS/config.ini
# Coppy stella executable from AUTOMATIC_TESTS/numerical_tests/stella_releases
- name: Download stella
run: |
cp AUTOMATIC_TESTS/numerical_tests/stella_releases/stella_v0.6 stella
# Perform python tests
- name: Numerical python tests
run: |
# Make stella executable
chmod +x stella
# Run one of the python tests
if ${{ contains(matrix.config.name, '1 -') }}; then make numerical-tests-1; fi
if ${{ contains(matrix.config.name, '2 -') }}; then make numerical-tests-2; fi
if ${{ contains(matrix.config.name, '3 -') }}; then make numerical-tests-3; fi
if ${{ contains(matrix.config.name, '4 -') }}; then make numerical-tests-4; fi
if ${{ contains(matrix.config.name, '5 -') }}; then make numerical-tests-5; fi
if ${{ contains(matrix.config.name, '6 -') }}; then make numerical-tests-6; fi
if ${{ contains(matrix.config.name, '7 -') }}; then make numerical-tests-7; fi
# Perform python tests one by one
stella_v0.7:
runs-on: ubuntu-22.04
env:
OMPI_MCA_rmaps_base_oversubscribe: yes
MPIRUN: mpiexec -np
STELLA_SYSTEM: gnu_ubuntu

# Run the same set-up multiple times
strategy:
fail-fast: false
matrix:
config:
- name: "1 - Does stella run "
#- name: "2 - Geometry"
#- name: "3 - Gyrokinetic equation"
#- name: "4 - Flux tube"
#- name: "5 - Diagnostics"
#- name: "6 - Full Flux Surface"
#- name: "7 - Electromagnetic effects"

steps:

# Check-out repository under $GITHUB_WORKSPACE
- name: Check out repository
uses: actions/checkout@v4

# Install dependencies
- name: Install dependencies and python virtual environment
run: |
sudo apt update
sudo apt install -y gfortran make libfftw3-dev libnetcdf-dev libnetcdff-dev
sudo apt install -y netcdf-bin python3 python3-pip openmpi-bin libopenmpi-dev
pip3 install --user -r AUTOMATIC_TESTS/requirements.txt
sed -i 's/nproc = 16/nproc = 4/g' AUTOMATIC_TESTS/config.ini
# Coppy stella executable from AUTOMATIC_TESTS/numerical_tests/stella_releases
- name: Download stella
run: |
cp AUTOMATIC_TESTS/numerical_tests/stella_releases/stella_v0.7 stella
# Perform python tests
- name: Numerical python tests
run: |
# Make stella executable
chmod +x stella
# Run one of the python tests
if ${{ contains(matrix.config.name, '1 -') }}; then make numerical-tests-1; fi
if ${{ contains(matrix.config.name, '2 -') }}; then make numerical-tests-2; fi
if ${{ contains(matrix.config.name, '3 -') }}; then make numerical-tests-3; fi
if ${{ contains(matrix.config.name, '4 -') }}; then make numerical-tests-4; fi
if ${{ contains(matrix.config.name, '5 -') }}; then make numerical-tests-5; fi
if ${{ contains(matrix.config.name, '6 -') }}; then make numerical-tests-6; fi
if ${{ contains(matrix.config.name, '7 -') }}; then make numerical-tests-7; fi
6 changes: 6 additions & 0 deletions AUTOMATIC_TESTS/numerical_tests/stella_releases/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@


The stella releases are found at:
https://github.com/stellaGK/stella/releases

Note that for stella_v0.7 we commented line 224 in run_parameters.f90 (error = .true.), in order to allow stella to run when the variables `fapar` and `fbpar` are set in the input file. Since these variables are needed for stella_v0.6.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ def test_whether_correct_quantities_are_present_in_netcdf_file(error=False):
# Find the netcdf output file which was generated during our local stella run
local_netcdf_file = local_stella_run_directory / input_filename.replace('.in', '.out.nc')

# Different stella versions have different variables
stella_v8 = True
stella_v7 = False
stella_v6 = False

# Open the netcdf file
with xr.open_dataset(local_netcdf_file) as local_netcdf:

Expand All @@ -99,22 +104,35 @@ def test_whether_correct_quantities_are_present_in_netcdf_file(error=False):

# Check whether all the diagnostics data is present in the netcdf file
dist_extensions = ['_vs_vpamus', '_vs_zvpas', '_vs_zmus', '_vs_zvpamus']
expected_keys = ['t', 'omega', 'phi2', 'apar2', 'bpar2', 'omega']; new_keys = True
expected_keys = ['t', 'omega', 'phi2', 'apar2', 'bpar2', 'omega'];
expected_keys += [i+j for i in ['pflux', 'qflux', 'vflux'] for j in ['_vs_s', '_vs_kxkyzs']]
expected_keys += [i+j for i in ['g2', 'h2', 'f2', 'g2nozonal', 'h2nozonal', 'f2nozonal'] for j in dist_extensions]
expected_keys += ['g2_vs_zkykxs', 'h2_vs_zkykxs', 'f2_vs_zkykxs']
for key in expected_keys:
if (key not in local_netcdf):
print(f'ERROR: The quantity {key} could not be found in the netcdf file.'); new_keys = False
print(f'ERROR: The quantity {key} could not be found in the netcdf file.')
stella_v8 = False; stella_v7 = True

# Try old stella names
if new_keys==False:
if stella_v7==True:
print('--------------------------------------------------')
print(' The new stella keys werent found, try old keys.')
print(' The new stella keys werent found, try older keys.')
print('--------------------------------------------------')
expected_keys = ['t', 'omega', 'phi2', 'apar2', 'bpar2', 'pflx', 'vflx', 'phi_vs_t', 'phi2_vs_kxky', \
expected_keys = ['t', 'omega', 'phi2', 'apar2', 'bpar2', 'qflx', 'pflx', 'vflx', 'phi_vs_t', 'phi2_vs_kxky', \
'pflx_vs_kxky', 'vflx_vs_kxky', 'qflx_vs_kxky', 'pflux_x', 'vflux_x', 'qflux_x', \
'dens_x', 'upar_x', 'temp_x', 'pflx_kxky', 'vflx_kxky', 'qflx_kxky', 'gvmus', 'gzvs']
'dens_x', 'upar_x', 'temp_x', 'pflx_kxky', 'vflx_kxky', 'qflx_kxky', 'gvmus', 'gzvs']
for key in expected_keys:
if (key not in local_netcdf):
print(f'ERROR: The quantity {key} could not be found in the netcdf file.');
stella_v7 = False; stella_v6 = True

# Try old stella names
if stella_v6==True:
print('--------------------------------------------------')
print(' The new stella keys werent found, try older keys.')
print('--------------------------------------------------')
expected_keys = ['t', 'omega', 'phi2', 'phi_vs_t', 'phi2_vs_kxky', 'pflux_x', 'vflux_x', 'qflux_x', \
'dens_x', 'upar_x', 'temp_x', 'pflx_kxky', 'vflx_kxky', 'qflx_kxky', 'gvmus', 'gzvs']
for key in expected_keys:
if (key not in local_netcdf):
print(f'ERROR: The quantity {key} could not be found in the netcdf file.'); error = True
Expand Down

0 comments on commit 57844be

Please sign in to comment.