Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Add gcc-14 and run on Ubuntu-24.04 #59

Merged
merged 11 commits into from
May 15, 2024
19 changes: 10 additions & 9 deletions .github/workflows/ci-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
cppcheck --force --language=c++ --std=c++20 --enable=style --suppress=knownConditionTrueFalse --check-level=exhaustive .

clang-format:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -97,17 +97,17 @@ jobs:
run-clang-tidy

compile:
runs-on: ubuntu-22.04
env:
CXX: g++
strategy:
matrix:
compiler: [
{name: gcc, ver: 11},
{name: gcc, ver: 12},
{name: gcc, ver: 13},
# {name: gcc, ver: 14},
{name: nvc++, ver: '24.3'},
compiler:
[
{os: ubuntu-24.04, name: gcc, ver: 11},
{os: ubuntu-24.04, name: gcc, ver: 12},
{os: ubuntu-24.04, name: gcc, ver: 13},
{os: ubuntu-24.04, name: gcc, ver: 14},
{os: ubuntu-22.04, name: nvc++, ver: '24.3'},
]
mpi: [ON, OFF]
openmp: [ON, OFF]
Expand All @@ -117,6 +117,7 @@ jobs:
stdpar: ON
fail-fast: false

runs-on: ${{ matrix.compiler.os }}
name: ${{ matrix.compiler.name }} ${{ matrix.compiler.ver }}${{ matrix.mpi == 'ON' && ' MPI' || ''}}${{ matrix.openmp == 'ON' && ' OpenMP' || ''}}${{ matrix.stdpar == 'ON' && ' stdpar' || ''}}
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -181,7 +182,7 @@ jobs:
- name: install OpenMP
if: matrix.openmp == 'ON'
run: |
sudo apt-get install -y libomp5-14 libomp-dev
sudo apt-get install -y libomp5 libomp-dev

- name: Compile classic mode
run: |
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ jobs:
testmodels:
strategy:
matrix:
# os: ['ubuntu-latest', 'self-hosted']
os: [ubuntu-22.04]
os: [ubuntu-24.04]
testmode: [OFF, ON]
testname:
[
Expand Down Expand Up @@ -57,12 +56,12 @@ jobs:
# sudo add-apt-repository multiverse
sudo apt-get update

- name: Install gcc-13
- name: Install gcc-14
if: always()
uses: fortran-lang/setup-fortran@v1
with:
compiler: gcc
version: 13
version: 14

- name: install gsl and openmpi
run: |
Expand Down Expand Up @@ -297,7 +296,7 @@ jobs:
combine_checksums:
needs: testmodels
if: always()
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- name: Download test output
uses: actions/download-artifact@v4
Expand Down
5 changes: 1 addition & 4 deletions .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.5.0
rev: v4.6.0
hooks:
- id: check-added-large-files
args: [--maxkb=800]
Expand All @@ -12,16 +12,13 @@ repos:
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- id: detect-private-key
- id: destroyed-symlinks
- id: fix-byte-order-marker
- id: forbid-new-submodules
- id: mixed-line-ending
args: [--fix=lf]
- id: name-tests-test
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://github.com/pocc/pre-commit-hooks
rev: v1.3.5
Expand Down
13 changes: 4 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,6 @@ endif
ifeq ($(shell uname -s),Darwin)
# macOS

ifeq ($(COMPILER_NAME),GCC)
# fixes linking on macOS with gcc
LDFLAGS += -Xlinker -ld_classic
endif

ifeq ($(shell uname -m),arm64)
# On Arm, -mcpu combines -march and -mtune
CXXFLAGS += -mcpu=native
Expand Down Expand Up @@ -229,11 +224,11 @@ CXXFLAGS += -Winline -Wall -Wpedantic -Wredundant-decls -Wno-unused-parameter -W
# sn3d.cc and exspec.cc have main() defined
common_files := $(filter-out sn3d.cc exspec.cc, $(wildcard *.cc))

sn3d_files = sn3d.cc $(common_files)
sn3d_files = $(common_files) sn3d.cc
sn3d_objects = $(addprefix $(BUILD_DIR)/,$(sn3d_files:.cc=.o))
sn3d_dep = $(sn3d_objects:%.o=%.d)

exspec_files = exspec.cc $(common_files)
exspec_files = $(common_files) exspec.cc
exspec_objects = $(addprefix $(BUILD_DIR)/,$(exspec_files:.cc=.o))
exspec_dep = $(exspec_objects:%.o=%.d)

Expand All @@ -248,14 +243,14 @@ $(BUILD_DIR)/sn3d.o $(BUILD_DIR)/exspec.o: version.h artisoptions.h Makefile
check: $(sn3d_files)
run-clang-tidy $(sn3d_files)

sn3d: $(sn3d_objects) artisoptions.h Makefile
sn3d: artisoptions.h Makefile $(sn3d_objects)
$(CXX) $(CXXFLAGS) $(sn3d_objects) $(LDFLAGS) -o sn3d
-include $(sn3d_dep)

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

exspec: $(exspec_objects) artisoptions.h Makefile
exspec: artisoptions.h Makefile $(exspec_objects)
$(CXX) $(CXXFLAGS) $(exspec_objects) $(LDFLAGS) -o exspec
-include $(exspec_dep)

Expand Down
2 changes: 2 additions & 0 deletions artisoptions_christinenonthermal.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,7 @@ constexpr bool EXPANSION_OPAC_SAMPLE_KAPPAPLANCK = false;

constexpr bool USE_XCOM_GAMMAPHOTOION = false;

constexpr auto GAMMA_THERMALISATION_SCHEME = ThermalisationScheme::DETAILED;

// NOLINTEND(modernize*,misc-unused-parameters)
#endif // ARTISOPTIONS_H
4 changes: 3 additions & 1 deletion artisoptions_classic.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,7 @@ constexpr bool EXPANSION_OPAC_SAMPLE_KAPPAPLANCK = false;

constexpr bool USE_XCOM_GAMMAPHOTOION = false;

constexpr auto GAMMA_THERMALISATION_SCHEME = ThermalisationScheme::DETAILED;

// NOLINTEND(modernize*,misc-unused-parameters)
#endif // ARTISOPTIONS_H
#endif // ARTISOPTIONS_H
2 changes: 2 additions & 0 deletions artisoptions_kilonova_lte.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,7 @@ constexpr bool EXPANSION_OPAC_SAMPLE_KAPPAPLANCK = false;

constexpr bool USE_XCOM_GAMMAPHOTOION = false;

constexpr auto GAMMA_THERMALISATION_SCHEME = ThermalisationScheme::DETAILED;

// NOLINTEND(modernize*,misc-unused-parameters)
#endif // ARTISOPTIONS_H
2 changes: 2 additions & 0 deletions artisoptions_nltenebular.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,7 @@ constexpr bool EXPANSION_OPAC_SAMPLE_KAPPAPLANCK = false;

constexpr bool USE_XCOM_GAMMAPHOTOION = false;

constexpr auto GAMMA_THERMALISATION_SCHEME = ThermalisationScheme::DETAILED;

// NOLINTEND(modernize*,misc-unused-parameters)
#endif // ARTISOPTIONS_H
2 changes: 2 additions & 0 deletions artisoptions_nltewithoutnonthermal.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,7 @@ constexpr bool EXPANSION_OPAC_SAMPLE_KAPPAPLANCK = false;

constexpr bool USE_XCOM_GAMMAPHOTOION = false;

constexpr auto GAMMA_THERMALISATION_SCHEME = ThermalisationScheme::DETAILED;

// NOLINTEND(modernize*,misc-unused-parameters)
#endif // ARTISOPTIONS_H
4 changes: 3 additions & 1 deletion constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,6 @@ enum timestepsizemethods {
TIMESTEP_SIZES_CONSTANT_THEN_LOGARITHMIC = 3,
};

#endif
enum class ThermalisationScheme { DETAILED, BARNES_GLOBAL, BARNES_LOCAL };

#endif
2 changes: 1 addition & 1 deletion data/xcom_photoion_data.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Photoionization data from the XCOM database by NIST (https://www.nist.gov/pml/xcom-photon-cross-sections-database, Berger et al. 2010)
# Photoionization data from the XCOM database by NIST (https://www.nist.gov/pml/xcom-photon-cross-sections-database, Berger et al. 2010)
1 1.000000000000E-03 1.141000000000E+01
1 1.500000000000E-03 2.932000000000E+00
1 2.000000000000E-03 1.111000000000E+00
Expand Down
2 changes: 0 additions & 2 deletions decay.cc
Original file line number Diff line number Diff line change
Expand Up @@ -669,8 +669,6 @@ void init_nuclides(const std::vector<int> &custom_zlist, const std::vector<int>
nuclides.back().endecay_q[DECAYTYPE_BETAMINUS] = q_mev * MEV;
nuclides.back().endecay_electron = e_elec_mev * MEV;
nuclides.back().endecay_gamma = e_gamma_mev * MEV;
// printout("betaminus file: Adding (Z=%d)%s%d endecay_electron %g endecay_gamma %g tau_s %g\n",
// z, get_elname(z), a, e_elec_mev, e_gamma_mev, tau_sec);
assert_always(e_elec_mev >= 0.);
}

Expand Down
58 changes: 56 additions & 2 deletions gammapkt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ void pair_prod(Packet &pkt) {
}
}

void do_gamma(Packet &pkt, double t2)
void transport_gamma(Packet &pkt, double t2)
// Now routine for moving a gamma packet. Idea is that we have as input
// a gamma packet with known properties at time t1 and we want to follow it
// until time t2.
Expand Down Expand Up @@ -969,4 +969,58 @@ void do_gamma(Packet &pkt, double t2)
}
}

} // namespace gammapkt
void barnes_thermalization(Packet &pkt, bool local)
// Barnes treatment: packet is either getting absorbed immediately and locally
// creating a k-packet or it escapes. The absorption probability matches the
// Barnes thermalization efficiency, for expressions see the original paper:
// https://ui.adsabs.harvard.edu/abs/2016ApJ...829..110B
{
// compute thermalization efficiency (= absorption probability)
constexpr double mean_gamma_opac = 0.1;

// determine average initial density
double V_0 = 0.;
for (int nonemptymgi = 0; nonemptymgi < grid::get_nonempty_npts_model(); nonemptymgi++) {
const int mgi = grid::get_mgi_of_nonemptymgi(nonemptymgi);
V_0 += grid::get_modelcell_assocvolume_tmin(mgi);
}
double rho_0 = 0.;
if (!local) {
rho_0 = grid::mtot_input / V_0;
} else {
rho_0 = grid::get_rho_tmin(grid::get_cell_modelgridindex(pkt.where));
}

const double R_0 = pow(3 * V_0 / (4 * PI), 1 / 3.);
const double t_0 = grid::get_t_model();
const double tau_ineff = sqrt(rho_0 * R_0 * pow(t_0, 2) * mean_gamma_opac);
// get current time
const double t = t_0 + pkt.prop_time;
const double tau = pow(tau_ineff / t, 2.);
const double f_gamma = 1. - exp(-tau);

// either absorb packet or let it escape
if (rng_uniform() < f_gamma) {
// packet is absorbed and contributes to the heating as a k-packet
pkt.type = TYPE_NTLEPTON;
pkt.absorptiontype = -4;
} else {
// let packet escape, i.e. make it inactive
pkt.type = TYPE_ESCAPE;
grid::change_cell(pkt, -99);
}
}

void do_gamma(Packet &pkt, double t2) {
if constexpr (GAMMA_THERMALISATION_SCHEME == ThermalisationScheme::DETAILED) {
transport_gamma(pkt, t2);
} else if constexpr (GAMMA_THERMALISATION_SCHEME == ThermalisationScheme::BARNES_GLOBAL) {
barnes_thermalization(pkt, false);
} else if constexpr (GAMMA_THERMALISATION_SCHEME == ThermalisationScheme::BARNES_LOCAL) {
barnes_thermalization(pkt, true);
} else {
__builtin_unreachable();
}
}

} // namespace gammapkt
5 changes: 3 additions & 2 deletions grid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ std::array<int, 3> ncoord_model{0}; // the model.txt input grid dimensions

double min_den; // minimum model density

double mtot_input;
double mfeg; /// Total mass of Fe group elements in ejecta

int first_cellindex = -1; // auto-dermine first cell index in model.txt (usually 1 or 0)
Expand Down Expand Up @@ -2025,7 +2024,9 @@ static void setup_grid_cartesian_3d()
// have a higher expansion velocity than the sides
const double vmax_corner = sqrt(3 * pow(globals::vmax, 2));
printout("corner vmax %g [cm/s] (%.2fc)\n", vmax_corner, vmax_corner / CLIGHT);
assert_always(vmax_corner < CLIGHT);
if (!FORCE_SPHERICAL_ESCAPE_SURFACE) {
assert_always(vmax_corner < CLIGHT);
}

/// Set grid size for uniform xyz grid
if (get_model_type() == GRID_CARTESIAN3D) {
Expand Down
2 changes: 2 additions & 0 deletions grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ inline ModelGridCell *modelgrid{};

inline int ngrid{0};

inline double mtot_input;

[[nodiscard]] auto get_elements_uppermost_ion(int modelgridindex, int element) -> int;
void set_elements_uppermost_ion(int modelgridindex, int element, int newvalue);
[[nodiscard]] auto wid_init(int cellindex, int axis) -> double;
Expand Down
42 changes: 21 additions & 21 deletions tests/classicmode_1d_3dgrid_inputfiles/results_md5_final.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
24109f2d09a0dc6f111430bcac62e362 absorption.out
f99d272a5701a67ddbdbe3cc572dfdc0 absorptionpol.out
50ef16bf43784e7f8dfbe2f6c285bc0a absorption.out
1a9d7d912bdc103a43b378b90e24c4ba absorptionpol.out
c0604236aa7df99cda43e5c7bbe7b6f4 bflist.out
b9494795649e4c892a5864e1364702ac deposition.out
b235a725a159945147f84384a1295123 emission.out
32a92ebc53f27d5a549d9242cf9ff7a8 emissionpol.out
5c07db44ce0f562f0e7f67202df5ae46 emissiontrue.out
638daf26cdb4249c06fb4475f4f2b078 gamma_light_curve.out
93a975936b353d1f78f275229cdb2a28 gamma_spec.out
fc4fc40330c7ecf916358cc744c422f3 deposition.out
fef7cc28820f477dd111d905a7cbdf5a emission.out
ca589bac83866a9479519cab74f31a09 emissionpol.out
21a1f61ef79299c43761614d097584b6 emissiontrue.out
1c8f43523a8bf1e24cd24db7f256701f gamma_light_curve.out
0c2a7f61dce00daa1da52a3085c41224 gamma_spec.out
057b226c371f3819cba5e04bfea3d114 gammalinelist.out
20bddb22b6f084a7abc105c210366bfd grid.out
281553bd29e414420511af82b97c2ba2 light_curve.out
2918754ae0ca07ebba74ad8a148646ee light_curve.out
5740f40190d45653e5fce57ddf577dc8 linestat.out
c4e4e8d00846618f3931dc01cf52615f modelgridrankassignments.out
d6e3ae254d56e6649c2ea35a81437beb packets00_0000.out
6f6af500b379fdef6c04e2e480d0293a packets00_0001.out
887fe3ebcd66343afa8d283ca8289a0d spec.out
08b4509cde05029747a3015743b0be9b specpol.out
58fbae3d776d484d27cc7adb4d63d909 packets00_0000.out
fd81df81ec3fa4fbab5924f2892e59b4 packets00_0001.out
454b13ad8770380932e05e51bea9b9dc spec.out
ed8e92aa9a5d0d3717f697c967a35245 specpol.out
040c71f981716a2abf0467a82b1ac13c timesteps.out
1ab572d6289a8f7c192ae6e2e9a412e3 vpackets_0000.out
4b2790b819ef0518a4f1f21fc81fd495 vpackets_0001.out
45d2451baa526cfe6789594cfedaf19e vpkt_grid_0-0.out
9261e4760253227d7856d16989573a52 vpkt_grid_1-0.out
96ae0b30d1315ec67794c399f350636f vspecpol_0-0.out
1b1c71cbc0616c3c09527702cea59e58 vspecpol_1-0.out
758593c9177b6eefb1a8e25d7a64752b job1/estimators_0000.out
0c75c9ce7960ee93ed3ec63c2373867d job1/estimators_0001.out
508619acff2a825d7e3ce9a7536d2371 vpackets_0000.out
8be926090f01f929ef2f620a119db621 vpackets_0001.out
49214f0ff96736c807dfada58cd31f63 vpkt_grid_0000.out
aee10c0ea4c9070a6a99371e738cf1d0 vpkt_grid_0001.out
a5df7ee0f2b64fc14298b71f1c69a357 vspecpol_0000.out
1ea589c07198665405b2d037c104ad0f vspecpol_0001.out
1289d2c8180a1b1d0fbee86b07b97501 job1/estimators_0000.out
44aef2b4c845f2d5887c4949eca08a28 job1/estimators_0001.out
Loading
Loading