Skip to content

Commit

Permalink
v2023.10 (#40)
Browse files Browse the repository at this point in the history
New features

- New 2D Cylindrical propagation grid option (for direct mapping of 2D
input models)
- Added test models for various combinations of 1D/2D input models and
1D/2D/3D propagation grids.
- EXPERIMENTAL: Allow hybrid NLTE mode with some elements in full
Non-LTE and other elements in either LTE or photoionisation equilibrium
(classic quasi NLTE). Set with artisoptions.h LEVEL_IS_NLTE()
- EXPERIMENTAL: Enforce Saha ionisation balance (allowing NLTE level
pops) with artisoptions.h FORCE_SAHA_ION_BALANCE() function.
- EXPERIMENTAL: FORCE_SPHERICAL_ESCAPE_SURFACE to remove the corners of
a 2D or 3D model to create a spherical escape surface (allowing for
increased velocity per axis cutoff). Cells with v_r_mid > vmax are set
to empty, and packets found in cells with vel_r_inner > vmax are set to
escaped.

Fixes

- Fix virtual packets (storage of bound-free departure coeff in cell
history had introduced a dependence on the not-updated cell history)
- Fix for bug in 1D spherical grid mode that caused a some packets to
get out of their correct cells. Now ready for production use. Mapping of
1D and 2D models to a 3D Cartesian grid is still possible, but no longer
recommended for new models.
- Fix adiabatic cooling rate with NLTE populations on, replacing nnetot
(free and bound electron density) with nntot (ion plus free electron
density). No change to W7 nebular spectrum.
  • Loading branch information
lukeshingles authored Oct 21, 2023
1 parent 240684a commit 00661cf
Show file tree
Hide file tree
Showing 123 changed files with 6,304 additions and 6,795 deletions.
5 changes: 4 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ Checks: >
-llvmlibc-*,
-cert-err33-c,
-cert-err34-c,
-cert-err58-cpp,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-avoid-non-const-global-variables,
-cppcoreguidelines-no-malloc,
-cppcoreguidelines-owning-memory,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-pro-bounds-constant-array-index,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-pro-type-reinterpret-cast,
-cppcoreguidelines-pro-type-vararg,
-clang-diagnostic-error,
-fuchsia-*,
Expand All @@ -32,6 +34,7 @@ Checks: >
-hicpp-signed-bitwise,
-misc-use-anonymous-namespace,
-misc-no-recursion,
-misc-non-private-member-variables-in-classes,
-readability-identifier-length,
-readability-function-cognitive-complexity,
-readability-magic-numbers,
Expand All @@ -46,7 +49,7 @@ CheckOptions:
- key: cppcoreguidelines-init-variables.MathHeader
value: <cmath>
- key: cppcoreguidelines-narrowing-conversions.IgnoreConversionFromTypes
value: size_t;ptrdiff_t;size_type;difference_type;time_t
value: size_t;ptrdiff_t;size_type;difference_type;time_t;MPI_Aint;unsigned long
- key: cppcoreguidelines-narrowing-conversions.WarnOnFloatingPointNarrowingConversion
value: 'false'
- key: cppcoreguidelines-narrowing-conversions.WarnOnIntegerToFloatingPointNarrowingConversion
Expand Down
55 changes: 39 additions & 16 deletions .github/workflows/ci-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,26 @@ on:

jobs:
cppcheck:
runs-on: ubuntu-22.04
runs-on: macos-latest

steps:
- uses: actions/checkout@v3

- name: install dependencies
run: |
# git status
# sudo apt-get update
# sudo apt-get install libgsl-dev
# sudo apt install -y openmpi-bin libopenmpi-dev
sudo apt-get -y install cppcheck
brew update
brew install gsl openmpi cppcheck
cp artisoptions_nltenebular.h artisoptions.h
- name: run cppcheck
- name: run cppcheck and check for errors
run: |
cp artisoptions_nltenebular.h artisoptions.h
cppcheck --force --language=c++ --std=c++20 .
cppcheck --version
cppcheck --force --error-exitcode=1 --language=c++ --std=c++20 --enable=warning,performance,portability .
- name: show cppcheck style suggestions
run: |
cppcheck --version
cppcheck --force --language=c++ --std=c++20 --enable=style --suppress=knownConditionTrueFalse .
clang-format:
runs-on: ubuntu-22.04
Expand All @@ -45,12 +48,23 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
compiler: [{name: gcc, ver: 11}, {name: gcc, ver: 12}, {name: clang, ver: 14}, {name: clang, ver: 15}]
compiler: [{name: gcc, ver: 11}, {name: gcc, ver: 12}, {name: gcc, ver: 13}, {name: clang, ver: 14}, {name: clang, ver: 15}]
mpi: [ON, OFF]
openmp: [ON, OFF]
artisoptionsfile: [artisoptions_classic.h, artisoptions_nltenebular.h]
exclude:
- compiler: {name: gcc, ver: 11}
openmp: ON
- compiler: {name: gcc, ver: 12}
openmp: ON
- compiler: {name: gcc, ver: 13}
openmp: ON
- compiler: {name: clang, ver: 15}
openmp: ON
fail-fast: false

name: ${{ matrix.compiler.name }}-${{ matrix.compiler.ver }}${{ matrix.mpi == 'ON' && ' MPI' || ''}} ${{ matrix.artisoptionsfile }}
name: ${{ matrix.compiler.name }}-${{ matrix.compiler.ver }}${{ matrix.mpi == 'ON' && ' MPI' || ''}}${{ matrix.openmp == 'ON' && ' OpenMP' || ''}}
${{ matrix.artisoptionsfile }}
steps:
- uses: actions/checkout@v3

Expand All @@ -61,29 +75,38 @@ jobs:
# echo "count=$(python3 -c 'import psutil; print(int(psutil.cpu_count(logical=False)))')" >> $GITHUB_OUTPUT
echo "count=$(python3 -c 'import multiprocessing; print(multiprocessing.cpu_count())')" >> $GITHUB_OUTPUT
- name: apt-get update
- name: apt update
run: |
sudo add-apt-repository main
sudo add-apt-repository universe
sudo add-apt-repository restricted
sudo add-apt-repository multiverse
sudo apt-get update
- name: Install gcc-${{ matrix.compiler.ver }}
if: matrix.compiler.name == 'gcc'
run: |
sudo apt-get install -y gcc-${{ matrix.compiler.ver }} g++-${{ matrix.compiler.ver }}
sudo apt install -y gcc-${{ matrix.compiler.ver }} g++-${{ matrix.compiler.ver }}
echo "CXX=g++-${{ matrix.compiler.ver }}" >> $GITHUB_ENV
- name: Install clang-${{ matrix.compiler.ver }}
if: matrix.compiler.name == 'clang'
run: |
sudo apt-get install -y clang-${{ matrix.compiler.ver }} --install-suggests
sudo apt install -y clang-${{ matrix.compiler.ver }} --install-suggests
echo "CXX=clang++-${{ matrix.compiler.ver }}" >> $GITHUB_ENV
- name: install openmpi
if: matrix.mpi == 'ON'
run: |
sudo apt install -y openmpi-bin libopenmpi-dev
- name: install OpenMP
if: matrix.openmp == 'ON'
run: |
sudo apt-get install -y libomp5-14 libomp-dev
- name: install gsl
run: sudo apt-get install libgsl-dev
run: sudo apt install libgsl-dev

# - name: Set compiler environment variables (MPI off)
# if: matrix.mpi == 'OFF'
Expand All @@ -103,4 +126,4 @@ jobs:
- name: Compile
run: |
cp -v -p ${{ matrix.artisoptionsfile }} artisoptions.h
make MPI=${{matrix.mpi}} -j${{ steps.cpu-count.outputs.count}} sn3d exspec
make MPI=${{matrix.mpi}} OPENMP=${{matrix.openmp}} -j${{ steps.cpu-count.outputs.count}} sn3d exspec
54 changes: 41 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ jobs:
# os: ['ubuntu-latest', 'self-hosted']
os: [ubuntu-22.04]
testmode: [OFF, ON]
testname: [classicmode, classicmode_3d, kilonova, nebularonezone]
testname: [classicmode_1d_3dgrid, classicmode_3d, kilonova_1d_1dgrid, kilonova_1d_3dgrid, kilonova_2d_2dgrid, kilonova_2d_3dgrid, nebularonezone_1d_3dgrid]
exclude:
- os: self-hosted
testmode: ON
fail-fast: false

runs-on: ${{ matrix.os }}
timeout-minutes: 45
name: ${{ matrix.testname }} ${{ matrix.testmode == 'ON' && ' testmode ON' || ''}}
name: ${{ matrix.testname }}${{ matrix.testmode == 'ON' && ' testmode ON' || ''}}

steps:
- uses: actions/checkout@v3
Expand All @@ -38,11 +38,11 @@ jobs:
if: matrix.os != 'selfhosted'
run: |
git status
sudo apt-get update
sudo apt-get install -y gcc-12 g++-12
sudo apt-get install -y libgsl-dev
sudo apt update
sudo apt install -y gcc-13 g++-13
sudo apt install -y libgsl-dev
sudo apt install -y openmpi-bin libopenmpi-dev
echo "OMPI_CXX=g++-12" >> $GITHUB_ENV
echo "OMPI_CXX=g++-13" >> $GITHUB_ENV
- name: CPU type and core count
id: cpu-count
Expand All @@ -52,8 +52,7 @@ jobs:
# cache this for classic options because the super low integration tolerance makes generation of the file very slow
- name: Cache ratecoeff.dat
if: matrix.testname == 'classicmode' || matrix.testname == 'classicmode_3d'
# if: matrix.testname == 'classicmode' && matrix.testmode != 'ON'
if: matrix.testname == 'classicmode_1d_3dgrid' || matrix.testname == 'classicmode_3d'
uses: actions/cache@v3
with:
path: tests/${{ matrix.testname }}_testrun/ratecoeff.dat
Expand All @@ -62,15 +61,15 @@ jobs:
tests/${{ matrix.testname }}_testrun/ratecoeff.dat-
- name: Cache test atomic data
if: matrix.testname != 'classicmode'
if: ${{ !startsWith(matrix.testname, 'classicmode_1d') }}
uses: actions/cache@v3
id: cache-testatomicdata
with:
path: tests/atomicdata_feconi.tar.xz
key: tests/atomicdata_feconi.tar.xz

- name: Cache test atomic data classic
if: matrix.testname == 'classicmode'
if: ${{ startsWith(matrix.testname, 'classicmode_1d') }}
uses: actions/cache@v3
id: cache-testatomicdata-classic
with:
Expand Down Expand Up @@ -124,8 +123,7 @@ jobs:
if: always() && matrix.os != 'selfhosted' && matrix.testmode == 'OFF'
working-directory: tests/${{ matrix.testname }}_testrun
run: |
md5sum *.out job0/*.out
md5sum *.out job0/*.out | tee ../${{ matrix.testname }}_inputfiles/results_md5_job0.txt
if [ -f results_md5_job0.txt ]; then md5sum -c results_md5_job0.txt; else echo "results_md5_job0.txt not found"; fi
- name: Run test job1 resume
Expand All @@ -152,6 +150,11 @@ jobs:
working-directory: tests/${{ matrix.testname }}_testrun/
run: cat job1/output_0-0.txt

- name: cat job1 deposition.out
if: always()
working-directory: tests/${{ matrix.testname }}_testrun/
run: cat deposition.out

- name: Run exspec
if: always()
working-directory: tests/${{ matrix.testname }}_testrun/
Expand All @@ -174,7 +177,7 @@ jobs:
if: always() && matrix.os != 'selfhosted' && matrix.testmode == 'OFF'
working-directory: tests/${{ matrix.testname }}_testrun
run: |
md5sum *.out job1/*.out
md5sum *.out job1/*.out | tee ../${{ matrix.testname }}_inputfiles/results_md5_final.txt
if [ -f results_md5_final.txt ]; then md5sum -c results_md5_final.txt; else echo "results_md5_final.txt not found"; fi
- name: Prepare for next steps
Expand All @@ -192,6 +195,13 @@ jobs:
name: test-${{ matrix.testname }}-output
path: tests/${{ matrix.testname }}_testrun/output

- name: Upload checksum files
uses: actions/upload-artifact@v3
if: always() && matrix.os != 'selfhosted' && matrix.testmode == 'OFF'
with:
name: ${{ matrix.testname }}_inputfiles
path: tests/${{ matrix.testname }}_inputfiles/results_md5*

- name: Set up Python
if: always() && matrix.os != 'selfhosted' && matrix.testmode == 'OFF'
uses: actions/setup-python@v4
Expand Down Expand Up @@ -252,3 +262,21 @@ jobs:
# cp input-newrun.txt input.txt
# touch output_0-0.txt
# time mpirun -np 2 ./sn3d

combine_checksums:
needs: testmodels
if: always()
runs-on: ubuntu-latest
steps:
- name: Download test output
uses: actions/download-artifact@v3

- name: List all files
if: always()
run: find .

- name: Upload bundled checksum files
uses: actions/upload-artifact@v3
with:
name: checksums
path: '*_inputfiles/results_md5*.txt'
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
fail_fast: false
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-added-large-files
args: [--maxkb=800]
Expand Down
12 changes: 7 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.9)
cmake_minimum_required(VERSION 3.26)
project(artis)

set(default_build_type "Release")
Expand All @@ -11,16 +11,18 @@ set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
include_directories("${PROJECT_SOURCE_DIR}")

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)

set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
#set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)

set(SN3D_SOURCES sn3d.cc atomic.cc boundary.cc emissivities.cc gamma.cc globals.cc grey_emissivities.cc grid.cc input.cc kpkt.cc light_curve.cc ltepop.cc macroatom.cc nltepop.cc nonthermal.cc decay.cc packets.cc photo_electric.cc polarization.cc radfield.cc ratecoeff.cc rpkt.cc stats.cc thermalbalance.cc update_grid.cc update_packets.cc vectors.cc vpkt.cc md5.cc
set(SN3D_SOURCES sn3d.cc atomic.cc boundary.cc gammapkt.cc globals.cc grid.cc input.cc kpkt.cc light_curve.cc ltepop.cc macroatom.cc nltepop.cc nonthermal.cc decay.cc packet.cc radfield.cc ratecoeff.cc rpkt.cc spectrum.cc stats.cc thermalbalance.cc update_grid.cc update_packets.cc vectors.cc vpkt.cc md5.cc)
add_executable(sn3d ${SN3D_SOURCES})

set(EXSPEC_SOURCES exspec.cc grid.cc globals.cc input.cc vectors.cc packets.cc update_grid.cc update_packets.cc gamma.cc boundary.cc macroatom.cc decay.cc rpkt.cc kpkt.cc photo_electric.cc emissivities.cc grey_emissivities.cc ltepop.cc atomic.cc ratecoeff.cc thermalbalance.cc light_curve.cc spectrum.cc polarization.cc nltepop.cc nonthermal.cc radfield.cc stats.cc vpkt.cc md5.cc)
set(EXSPEC_SOURCES exspec.cc grid.cc globals.cc input.cc vectors.cc packet.cc update_grid.cc update_packets.cc gammapkt.cc boundary.cc macroatom.cc decay.cc rpkt.cc kpkt.cc ltepop.cc atomic.cc ratecoeff.cc thermalbalance.cc light_curve.cc spectrum.cc nltepop.cc nonthermal.cc radfield.cc stats.cc vpkt.cc md5.cc)

add_executable(exspec ${EXSPEC_SOURCES})

#if(UNIX AND NOT APPLE)
if(UNIX AND NOT APPLE)
find_package(MPI)
include_directories(SYSTEM ${MPI_INCLUDE_PATH})
Expand All @@ -32,7 +34,7 @@ add_compile_options("-Wall" "-Wextra")
string(APPEND CMAKE_CXX_FLAGS_DEBUG "-g")
string(APPEND CMAKE_CXX_FLAGS_RELEASE "-O3")

set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -march=native")
#set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -march=native")

add_compile_definitions(HAVE_INLINE)
add_compile_definitions(GSL_RANGE_CHECK_OFF)
Expand Down
34 changes: 18 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# place in architecture folder, e.g. build/arm64
BUILD_DIR = build/$(shell uname -m)

CXXFLAGS += -std=c++20 -fstrict-aliasing -ftree-vectorize -g -flto=auto -Werror -Werror=undef
# CXXFLAGS += -Wpedantic -Wextra -Wall
CXXFLAGS += -std=c++20 -fstrict-aliasing -ftree-vectorize -flto=auto

# CXXFLAGS += -Wunreachable-code

ifeq ($(shell uname -s),Darwin)
Expand All @@ -18,6 +18,7 @@ ifeq ($(shell uname -s),Darwin)
CXXFLAGS += -march=native
endif

CXXFLAGS += -fno-omit-frame-pointer
# CXXFLAGS += -Rpass=loop-vectorize
# CXXFLAGS += -Rpass-missed=loop-vectorize
# CXXFLAGS += -Rpass-analysis=loop-vectorize
Expand Down Expand Up @@ -77,20 +78,24 @@ ifeq ($(TESTMODE),ON)
CXXFLAGS += -DTESTMODE=true -O3 -DLIBCXX_ENABLE_DEBUG_MODE
# makes GitHub actions classic test run forever?
# CXXFLAGS += -D_GLIBCXX_DEBUG
CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer -fno-common
CXXFLAGS += -fsanitize=address,undefined -fno-omit-frame-pointer -fno-common
BUILD_DIR := $(BUILD_DIR)_testmode
else
# skip array range checking for better performance and use optimizations
CXXFLAGS += -DTESTMODE=false -DGSL_RANGE_CHECK_OFF -O3
endif

CXXFLAGS += -Winline -Wall -Wpedantic -Wredundant-decls -Wundef -Wno-unused-parameter -Wno-unused-function -Wstrict-aliasing -Wno-inline
CXXFLAGS += -Werror -Werror=undef -Winline -Wall -Wpedantic -Wredundant-decls -Wundef -Wno-unused-parameter -Wno-unused-function -Wstrict-aliasing -Wno-inline

ifeq ($(MPI),ON)
else ifeq ($(MPI),OFF)
else ifeq ($(MPI),)
ifeq ($(MPI),)
# MPI option not specified. set to true by default
MPI := ON
endif
ifeq ($(MPI),ON)
CXX = mpicxx
CXXFLAGS += -DMPI_ON=true
BUILD_DIR := $(BUILD_DIR)_mpi
else ifeq ($(MPI),OFF)
else
$(error bad value for MPI option. Should be ON or OFF)
endif
Expand All @@ -102,17 +107,14 @@ else
$(error bad value for testmode option. Should be ON or OFF)
endif

ifeq ($(MPI),ON)
CXX = mpicxx
CXXFLAGS += -DMPI_ON=true
BUILD_DIR := $(BUILD_DIR)_mpi
endif

ifeq ($(OPENMP),ON)
CXXFLAGS += -Xpreprocessor
CXXFLAGS += -fopenmp
CXXFLAGS += -Xpreprocessor -fopenmp
LDFLAGS += -lomp
BUILD_DIR := $(BUILD_DIR)_openmp
else ifeq ($(OPENMP),OFF)
else ifeq ($(OPENMP),)
else
$(error bad value for testmode option. Should be ON or OFF)
endif

### use pg when you want to use gprof profiler
Expand All @@ -137,7 +139,7 @@ sn3d: $(sn3d_objects)
-include $(sn3d_dep)

sn3dwhole: version.h
$(CXX) $(CXXFLAGS) $(sn3d_files) $(LDFLAGS) -o sn3d
$(CXX) $(CXXFLAGS) -g $(sn3d_files) $(LDFLAGS) -o sn3d

$(BUILD_DIR)/%.o: %.cc artisoptions.h Makefile
@mkdir -p $(@D)
Expand Down
Loading

0 comments on commit 00661cf

Please sign in to comment.