Skip to content

Commit 0428e03

Browse files
committed
Merge branch 'development' into eos_extra
2 parents 74d8771 + ed9c7fb commit 0428e03

File tree

531 files changed

+76454
-24111
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

531 files changed

+76454
-24111
lines changed

.codespellrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[codespell]
2-
skip = .git,*.ipynb,*.bib,*.ps,*~
2+
skip = .git,*.ipynb,*.bib,*.ps,*~,./util/autodiff
33
ignore-words = .codespell-ignore-words
44

55

.editorconfig

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ indent_style = tab
5353
indent_size = unset
5454

5555

56-
[util/gcem/**]
57-
# don't mess with the gcem subtree
56+
[util/{autodiff,gcem}/**]
57+
# don't mess with the autodiff or gcem subtrees
5858
indent_style = unset
5959
indent_size = unset
6060
trim_trailing_whitespace = unset

.github/workflows/burn_cell.yml

+23-17
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,21 @@ jobs:
2626
sudo apt-get update -y -qq
2727
sudo apt-get -qq -y install curl cmake jq clang g++>=9.3.0
2828
29-
- name: Compile, burn_cell (VODE, subch_approx)
29+
- name: Compile, burn_cell (VODE, subch_simple)
3030
run: |
3131
cd unit_test/burn_cell
3232
make realclean
33-
make NETWORK_DIR=subch_approx -j 4
33+
make NETWORK_DIR=subch_simple -j 4
3434
35-
- name: Run burn_cell (VODE, subch_approx)
35+
- name: Run burn_cell (VODE, subch_simple)
3636
run: |
3737
cd unit_test/burn_cell
38-
./main3d.gnu.ex inputs_subch_approx > test.out
38+
./main3d.gnu.ex inputs_subch_simple amrex.fpe_trap_{invalid,zero,overflow}=1 > test.out
3939
40-
- name: Compare to stored output (VODE, subch_approx)
40+
- name: Compare to stored output (VODE, subch_simple)
4141
run: |
4242
cd unit_test/burn_cell
43-
diff -I "^Initializing AMReX" -I "^AMReX" -I "^reading in reaclib rates" test.out ci-benchmarks/subch_approx_unit_test.out
43+
diff -I "^Initializing AMReX" -I "^AMReX" -I "^reading in reaclib rates" test.out ci-benchmarks/subch_simple_unit_test.out
4444
4545
- name: Compile, burn_cell (VODE, ECSN)
4646
run: |
@@ -51,7 +51,9 @@ jobs:
5151
- name: Run burn_cell (VODE, ECSN)
5252
run: |
5353
cd unit_test/burn_cell
54-
./main3d.gnu.ex inputs_ecsn > test.out
54+
# disable fpe_trap_overflow, as there's a spurious exception when
55+
# calculating DEL in vode_dvnlsd.H.
56+
./main3d.gnu.ex inputs_ecsn amrex.fpe_trap_{invalid,zero}=1 > test.out
5557
5658
- name: Compare to stored output (VODE, ECSN)
5759
run: |
@@ -67,7 +69,7 @@ jobs:
6769
- name: Run burn_cell (VODE, ignition_chamulak)
6870
run: |
6971
cd unit_test/burn_cell
70-
./main3d.gnu.ex inputs_ignition_chamulak > test.out
72+
./main3d.gnu.ex inputs_ignition_chamulak amrex.fpe_trap_{invalid,zero,overflow}=1 > test.out
7173
7274
- name: Compare to stored output (VODE, ignition_chamulak)
7375
run: |
@@ -83,28 +85,28 @@ jobs:
8385
- name: Run burn_cell (ForwardEuler, triple_alpha_plus_cago)
8486
run: |
8587
cd unit_test/burn_cell
86-
./main3d.gnu.ex inputs_triple > test.out
88+
./main3d.gnu.ex inputs_triple amrex.fpe_trap_{invalid,zero,overflow}=1 > test.out
8789
8890
- name: Compare to stored output (ForwardEuler, triple_alpha_plus_cago)
8991
run: |
9092
cd unit_test/burn_cell
9193
diff -I "^Initializing AMReX" -I "^AMReX" -I "^reading in reaclib rates" test.out ci-benchmarks/triple_alpha_plus_cago_FE_unit_test.out
9294
93-
- name: Compile, burn_cell (BackwardEuler, subch_approx)
95+
- name: Compile, burn_cell (BackwardEuler, subch_simple)
9496
run: |
9597
cd unit_test/burn_cell
9698
make realclean
97-
make NETWORK_DIR=subch_approx INTEGRATOR_DIR=BackwardEuler -j 4
99+
make NETWORK_DIR=subch_simple INTEGRATOR_DIR=BackwardEuler -j 4
98100
99-
- name: Run burn_cell (BackwardEuler, subch_approx)
101+
- name: Run burn_cell (BackwardEuler, subch_simple)
100102
run: |
101103
cd unit_test/burn_cell
102-
./main3d.gnu.ex inputs_subch_approx > test.out
104+
./main3d.gnu.ex inputs_subch_simple amrex.fpe_trap_{invalid,zero,overflow}=1 > test.out
103105
104-
- name: Compare to stored output (BackwardEuler, subch_approx)
106+
- name: Compare to stored output (BackwardEuler, subch_simple)
105107
run: |
106108
cd unit_test/burn_cell
107-
diff -I "^Initializing AMReX" -I "^AMReX" -I "^reading in reaclib rates" test.out ci-benchmarks/subch_approx_BE_unit_test.out
109+
diff -I "^Initializing AMReX" -I "^AMReX" -I "^reading in reaclib rates" test.out ci-benchmarks/subch_simple_BE_unit_test.out
108110
109111
- name: Compile, burn_cell (QSS, aprox13)
110112
run: |
@@ -115,7 +117,7 @@ jobs:
115117
- name: Run burn_cell (QSS, aprox13)
116118
run: |
117119
cd unit_test/burn_cell
118-
./main3d.gnu.ex inputs_aprox13 > test.out
120+
./main3d.gnu.ex inputs_aprox13 amrex.fpe_trap_{invalid,zero,overflow}=1 > test.out
119121
120122
- name: Compare to stored output (QSS, aprox13)
121123
run: |
@@ -131,9 +133,13 @@ jobs:
131133
- name: Run burn_cell (RKC, aprox13)
132134
run: |
133135
cd unit_test/burn_cell
134-
./main3d.gnu.ex inputs_aprox13 unit_test.temperature=1.e9 > test.out
136+
./main3d.gnu.ex inputs_aprox13 unit_test.temperature=1.e9 amrex.fpe_trap_{invalid,zero,overflow}=1 > test.out
135137
136138
- name: Compare to stored output (RKC, aprox13)
137139
run: |
138140
cd unit_test/burn_cell
139141
diff -I "^Initializing AMReX" -I "^AMReX" -I "^reading in reaclib rates" test.out ci-benchmarks/aprox13_RKC_unit_test.out
142+
143+
- name: Print backtrace
144+
if: ${{ failure() && hashFiles('unit_test/burn_cell/Backtrace.0') != '' }}
145+
run: cat unit_test/burn_cell/Backtrace.0
+146
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
name: burn_cell_metal_chem
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
burn_cell_metal_chem:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v4
11+
with:
12+
fetch-depth: 0
13+
14+
- name: Get AMReX
15+
run: |
16+
mkdir external
17+
cd external
18+
git clone https://github.com/AMReX-Codes/amrex.git
19+
cd amrex
20+
git checkout development
21+
echo 'AMREX_HOME=$(GITHUB_WORKSPACE)/external/amrex' >> $GITHUB_ENV
22+
echo $AMREX_HOME
23+
if [[ -n "${AMREX_HOME}" ]]; then exit 1; fi
24+
cd ../..
25+
26+
- name: Install dependencies
27+
run: |
28+
sudo apt-get update -y -qq
29+
sudo apt-get -qq -y install curl cmake jq clang g++>=9.3.0
30+
31+
- name: Compile
32+
run: |
33+
cd unit_test/burn_cell_metal_chem
34+
make -j 2
35+
36+
- name: Run and compare outputs for different Z values, also including cosmic ray ionization
37+
run: |
38+
set -e
39+
cd unit_test/burn_cell_metal_chem
40+
41+
declare -A line_numbers_map=(
42+
["Z=1"]="4450 4452 4454 4456 4457 4460 4461 4464 4470 4475"
43+
["Z=1_z10"]="1613 1615 4456 4458 4460 4463 4470 4476 4481"
44+
["Z=1e-1"]="4438 4440 4442 4444 4445 4448 4449 4452 4458 4463"
45+
["Z=1e-2"]="4438 4440 4442 4444 4445 4448 4449 4452 4458 4463"
46+
["Z=1e-3"]="4438 4440 4442 4444 4445 4448 4449 4452 4458 4463"
47+
["Z=1e-4"]="4438 4440 4442 4444 4445 4448 4449 4452 4458 4463"
48+
["Z=1e-5"]="4438 4440 4442 4444 4445 4448 4449 4452 4458 4463"
49+
["Z=1e-6"]="4463 4465 4467 4469 4470 4473 4474 4477 4483 4488"
50+
["Z=1_cr"]="652 654 656 658 659 662 663 666 672 677"
51+
["Z=1e-4_cr"]="652 654 656 658 659 662 663 666 672 677"
52+
)
53+
54+
declare -A ref_map=(
55+
["Z=1"]="reference_solution_1.out"
56+
["Z=1_z10"]="reference_solution_1_z10.out"
57+
["Z=1e-1"]="reference_solution_1e-1.out"
58+
["Z=1e-2"]="reference_solution_1e-2.out"
59+
["Z=1e-3"]="reference_solution_1e-3.out"
60+
["Z=1e-4"]="reference_solution_1e-4.out"
61+
["Z=1e-5"]="reference_solution_1e-5.out"
62+
["Z=1e-6"]="reference_solution_1e-6.out"
63+
["Z=1_cr"]="reference_solution_1_cr.out"
64+
["Z=1e-4_cr"]="reference_solution_1e-4_cr.out"
65+
)
66+
67+
ref_line_number_z10=(1 2 3 5 7 10 17 23 28)
68+
69+
# Original input file
70+
original_input_file="inputs_metal_chem_1"
71+
modified_input_file="inputs_metal_chem_modified"
72+
73+
for Z in "Z=1" "Z=1_z10" "Z=1e-1" "Z=1e-2" "Z=1e-3" "Z=1e-4" "Z=1e-5" "Z=1e-6" "Z=1_cr" "Z=1e-4_cr"; do
74+
cp $original_input_file $modified_input_file
75+
Z_val=${Z//Z=/}
76+
77+
if [[ "$Z" == "Z=1_z10" ]]; then
78+
# Modify the redshift line for Z=1_z10
79+
sed -i 's/network.redshift = 0.0/network.redshift = 10.0/g' $modified_input_file
80+
elif [[ "$Z" != "Z=1_cr" && "$Z" != "Z=1e-4_cr" ]]; then
81+
# Replace the metallicity and dust2gas_ratio values for other Z values
82+
sed -i 's/network.metallicity = .*/network.metallicity = '"$Z_val"'/g' $modified_input_file
83+
sed -i 's/network.dust2gas_ratio = .*/network.dust2gas_ratio = '"$Z_val"'/g' $modified_input_file
84+
fi
85+
86+
if [[ "$Z" == "Z=1_cr" || "$Z" == "Z=1e-4_cr" ]]; then
87+
# Modify the number of steps, since CRs impact lowest densities
88+
sed -i 's/unit_test.nsteps = 100000/unit_test.nsteps = 600/g' $modified_input_file
89+
# Modify the crate line for Z=1_cr
90+
sed -i 's/network.crate = 0.0/network.crate = 3e-17/g' $modified_input_file
91+
if [[ "$Z" == "Z=1e-4_cr" ]]; then
92+
# Replace the metallicity and dust2gas_ratio values for other Z values
93+
sed -i 's/network.metallicity = 1/network.metallicity = 1e-4/g' $modified_input_file
94+
sed -i 's/network.dust2gas_ratio = 1/network.dust2gas_ratio = 1e-4/g' $modified_input_file
95+
fi
96+
fi
97+
98+
output_file="test_${Z_val}.out"
99+
./main1d.gnu.DEBUG.ex $modified_input_file amrex.fpe_trap_{invalid,zero,overflow}=1 > $output_file
100+
101+
line_numbers="${line_numbers_map[$Z]}"
102+
ref_file="${ref_map[$Z]}"
103+
104+
error_found=false
105+
index=0
106+
for line_number in $line_numbers; do
107+
value1=$(awk 'NR=='"$line_number"' {match($0, /[+-]?[0-9]+([.][0-9]+)?[eE]?[+-]?[0-9]+/); if (RSTART) print substr($0, RSTART, RLENGTH); else print 0}' $output_file)
108+
109+
# Adjust the line number for the reference file
110+
if [[ "$Z" == "Z=1" ]]; then
111+
reference_line_number=$((line_number - 4449))
112+
elif [[ "$Z" == "Z=1_z10" ]]; then
113+
reference_line_number=${ref_line_number_z10[$index]}
114+
elif [[ "$Z" == "Z=1e-6" ]]; then
115+
reference_line_number=$((line_number - 4462))
116+
elif [[ "$Z" == "Z=1_cr" || "$Z" == "Z=1e-4_cr" ]]; then
117+
reference_line_number=$((line_number - 651))
118+
else
119+
reference_line_number=$((line_number - 4437))
120+
fi
121+
122+
value2=$(awk 'NR=='"$reference_line_number"' {match($0, /[+-]?[0-9]+([.][0-9]+)?[eE]?[+-]?[0-9]+/); if (RSTART) print substr($0, RSTART, RLENGTH)}' $ref_file)
123+
124+
difference=$(awk -v val1="$value1" -v val2="$value2" 'BEGIN { printf "%.2f", (val1 - val2) / val2 }')
125+
126+
if (( $(echo "$difference > 0.01" | bc -l) )); then
127+
echo "Z: $Z"
128+
echo "Line number: $line_number"
129+
echo "Value in $output_file: $value1"
130+
echo "Value in $ref_file: $value2"
131+
echo "Difference between test and reference value is $difference, more than allowed threshold of 0.01"
132+
echo
133+
error_found=true
134+
fi
135+
index=$((index + 1))
136+
done
137+
138+
if [[ $error_found == true ]]; then
139+
exit 1
140+
fi
141+
done
142+
143+
- name: Print backtrace if any failure
144+
if: ${{ failure() && hashFiles('unit_test/burn_cell_metal_chem/Backtrace.0') != '' }}
145+
run: cat unit_test/burn_cell_metal_chem/Backtrace.0
146+

.github/workflows/burn_cell_primordial_chem.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ jobs:
3232
run: |
3333
cd unit_test/burn_cell_primordial_chem
3434
make -j 2
35-
./main1d.gnu.DEBUG.ex inputs_primordial_chem > test.out
35+
./main1d.gnu.DEBUG.ex inputs_primordial_chem amrex.fpe_trap_{invalid,zero,overflow}=1 > test.out
36+
37+
- name: Print backtrace
38+
if: ${{ failure() && hashFiles('unit_test/burn_cell_primordial_chem/Backtrace.0') != '' }}
39+
run: cat unit_test/burn_cell_primordial_chem/Backtrace.0
3640

3741
- name: Compare to stored output
3842
run: |

.github/workflows/burn_cell_sdc.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: Run burn_cell_sdc (aprox19)
3636
run: |
3737
cd unit_test/burn_cell_sdc
38-
./main3d.gnu.ex inputs_aprox19.ci
38+
./main3d.gnu.ex inputs_aprox19.ci amrex.fpe_trap_{invalid,zero,overflow}=1
3939
4040
- name: Compare to stored output (aprox19)
4141
run: |
@@ -51,7 +51,7 @@ jobs:
5151
- name: Run burn_cell_sdc (BackwardEuler, aprox19)
5252
run: |
5353
cd unit_test/burn_cell_sdc
54-
./main3d.gnu.ex inputs_aprox19.ci
54+
./main3d.gnu.ex inputs_aprox19.ci amrex.fpe_trap_{invalid,zero,overflow}=1
5555
5656
- name: Compare to stored output (BackwardEuler, aprox19)
5757
run: |
@@ -67,10 +67,13 @@ jobs:
6767
- name: Run burn_cell_sdc (RKC, aprox19)
6868
run: |
6969
cd unit_test/burn_cell_sdc
70-
./main3d.gnu.ex inputs_aprox19.ci
70+
./main3d.gnu.ex inputs_aprox19.ci amrex.fpe_trap_{invalid,zero,overflow}=1
7171
7272
- name: Compare to stored output (RKC, aprox19)
7373
run: |
7474
cd unit_test/burn_cell_sdc
7575
diff state_over_time.txt ci-benchmarks/aprox19_RKC_state_over_time.txt
7676
77+
- name: Print backtrace
78+
if: ${{ failure() && hashFiles('unit_test/burn_cell_sdc/Backtrace.0') != '' }}
79+
run: cat unit_test/burn_cell_sdc/Backtrace.0

.github/workflows/check_ifdefs.py

+3
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ def check_file(filename):
7878
if "tmp_build_dir" in f.parts:
7979
# skip generated files
8080
continue
81+
if f.parts[:2] == ("util", "autodiff"):
82+
# skip third-party autodiff files
83+
continue
8184
ierr, defines = check_file(f)
8285
all_defines += defines
8386
total_errors += ierr

.github/workflows/check_powi.py

+13-8
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,21 @@
55

66

77
def pow_to_powi(text):
8-
# Finds all possible std::pow(x, n) or gcem::pow(x, n)
8+
# Finds all possible std::pow(x, n), gcem::pow(x, n), or admath::pow(x, n)
99
# where n is a potential integer to amrex::Math::powi<n>(x)
1010

11-
# Check for all positive and negative integer, whole float numbers
11+
# Match all positive and negative integers, whole float numbers
1212
# with and without _rt
13-
match_pattern = r"([^,]+),\s*(-?(?:\d+\.0*_rt?|\d))"
13+
integer_pattern = r"-?(?:\d+\.0*(?:e0)?(?:_rt)?|\d)"
14+
15+
# Check for an integer in the second argument
16+
match_pattern = rf"([^,]+),\s*({integer_pattern})"
1417

1518
# Match fails when there is a nested pow, so only inner most pow is matched
16-
negate_pattern = r"(?![\s\S]*(?:std|gcem)::pow\((?:[^,]+),\s*(?:-?(?:\d+\.0*_rt?|\d))\))"
19+
negate_pattern = rf"(?![\s\S]*(?:std|gcem|admath)::pow\((?:[^,]+),\s*(?:{integer_pattern})\))"
1720

1821
# Final pattern
19-
pattern = rf"(?:std|gcem)::pow\({negate_pattern}{match_pattern}\)"
22+
pattern = rf"(?:std|gcem|admath)::pow\({negate_pattern}{match_pattern}\)"
2023
# pattern = rf"(?:std|gcem)::pow\((?![\s\S]*(?:std|gcem)::pow\((?:[^,]+),\s*(?:-?(?:\d+\.0*_rt?|\d))\))([^,]+),\s*(-?(?:\d+\.0*_rt?|\d))\)"
2124

2225
def replacement(match):
@@ -33,6 +36,8 @@ def replacement(match):
3336
def process_content(dir_path):
3437
# This function processes all text in the given directory
3538
for root, dirs, filenames in os.walk(dir_path):
39+
if "util/autodiff/" in root:
40+
continue
3641
for filename in filenames:
3742
if filename.endswith(".H") or filename.endswith(".cpp"):
3843
filepath = os.path.join(root, filename)
@@ -58,9 +63,9 @@ def git_diff():
5863

5964
# Print out suggested change and raise error after detecting modification
6065
if git_diff_output.stdout:
61-
print("Detected potential usage to replace std::pow" +
62-
"with integer powers via amrex::Math::powi\n")
63-
print("Below are the suggested change:\n")
66+
print("Detected potential usage to replace std::pow"
67+
" with integer powers via amrex::Math::powi\n")
68+
print("Below are the suggested changes:\n")
6469
print(git_diff_output.stdout)
6570

6671
raise RuntimeError("Changes detected after modification")

0 commit comments

Comments
 (0)