Skip to content

Commit

Permalink
Merge branch 'development' into eos_extra
Browse files Browse the repository at this point in the history
  • Loading branch information
zingale committed Nov 20, 2024
2 parents 74d8771 + ed9c7fb commit 0428e03
Show file tree
Hide file tree
Showing 531 changed files with 76,454 additions and 24,111 deletions.
2 changes: 1 addition & 1 deletion .codespellrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[codespell]
skip = .git,*.ipynb,*.bib,*.ps,*~
skip = .git,*.ipynb,*.bib,*.ps,*~,./util/autodiff
ignore-words = .codespell-ignore-words


4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ indent_style = tab
indent_size = unset


[util/gcem/**]
# don't mess with the gcem subtree
[util/{autodiff,gcem}/**]
# don't mess with the autodiff or gcem subtrees
indent_style = unset
indent_size = unset
trim_trailing_whitespace = unset
Expand Down
40 changes: 23 additions & 17 deletions .github/workflows/burn_cell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ jobs:
sudo apt-get update -y -qq
sudo apt-get -qq -y install curl cmake jq clang g++>=9.3.0
- name: Compile, burn_cell (VODE, subch_approx)
- name: Compile, burn_cell (VODE, subch_simple)
run: |
cd unit_test/burn_cell
make realclean
make NETWORK_DIR=subch_approx -j 4
make NETWORK_DIR=subch_simple -j 4
- name: Run burn_cell (VODE, subch_approx)
- name: Run burn_cell (VODE, subch_simple)
run: |
cd unit_test/burn_cell
./main3d.gnu.ex inputs_subch_approx > test.out
./main3d.gnu.ex inputs_subch_simple amrex.fpe_trap_{invalid,zero,overflow}=1 > test.out
- name: Compare to stored output (VODE, subch_approx)
- name: Compare to stored output (VODE, subch_simple)
run: |
cd unit_test/burn_cell
diff -I "^Initializing AMReX" -I "^AMReX" -I "^reading in reaclib rates" test.out ci-benchmarks/subch_approx_unit_test.out
diff -I "^Initializing AMReX" -I "^AMReX" -I "^reading in reaclib rates" test.out ci-benchmarks/subch_simple_unit_test.out
- name: Compile, burn_cell (VODE, ECSN)
run: |
Expand All @@ -51,7 +51,9 @@ jobs:
- name: Run burn_cell (VODE, ECSN)
run: |
cd unit_test/burn_cell
./main3d.gnu.ex inputs_ecsn > test.out
# disable fpe_trap_overflow, as there's a spurious exception when
# calculating DEL in vode_dvnlsd.H.
./main3d.gnu.ex inputs_ecsn amrex.fpe_trap_{invalid,zero}=1 > test.out
- name: Compare to stored output (VODE, ECSN)
run: |
Expand All @@ -67,7 +69,7 @@ jobs:
- name: Run burn_cell (VODE, ignition_chamulak)
run: |
cd unit_test/burn_cell
./main3d.gnu.ex inputs_ignition_chamulak > test.out
./main3d.gnu.ex inputs_ignition_chamulak amrex.fpe_trap_{invalid,zero,overflow}=1 > test.out
- name: Compare to stored output (VODE, ignition_chamulak)
run: |
Expand All @@ -83,28 +85,28 @@ jobs:
- name: Run burn_cell (ForwardEuler, triple_alpha_plus_cago)
run: |
cd unit_test/burn_cell
./main3d.gnu.ex inputs_triple > test.out
./main3d.gnu.ex inputs_triple amrex.fpe_trap_{invalid,zero,overflow}=1 > test.out
- name: Compare to stored output (ForwardEuler, triple_alpha_plus_cago)
run: |
cd unit_test/burn_cell
diff -I "^Initializing AMReX" -I "^AMReX" -I "^reading in reaclib rates" test.out ci-benchmarks/triple_alpha_plus_cago_FE_unit_test.out
- name: Compile, burn_cell (BackwardEuler, subch_approx)
- name: Compile, burn_cell (BackwardEuler, subch_simple)
run: |
cd unit_test/burn_cell
make realclean
make NETWORK_DIR=subch_approx INTEGRATOR_DIR=BackwardEuler -j 4
make NETWORK_DIR=subch_simple INTEGRATOR_DIR=BackwardEuler -j 4
- name: Run burn_cell (BackwardEuler, subch_approx)
- name: Run burn_cell (BackwardEuler, subch_simple)
run: |
cd unit_test/burn_cell
./main3d.gnu.ex inputs_subch_approx > test.out
./main3d.gnu.ex inputs_subch_simple amrex.fpe_trap_{invalid,zero,overflow}=1 > test.out
- name: Compare to stored output (BackwardEuler, subch_approx)
- name: Compare to stored output (BackwardEuler, subch_simple)
run: |
cd unit_test/burn_cell
diff -I "^Initializing AMReX" -I "^AMReX" -I "^reading in reaclib rates" test.out ci-benchmarks/subch_approx_BE_unit_test.out
diff -I "^Initializing AMReX" -I "^AMReX" -I "^reading in reaclib rates" test.out ci-benchmarks/subch_simple_BE_unit_test.out
- name: Compile, burn_cell (QSS, aprox13)
run: |
Expand All @@ -115,7 +117,7 @@ jobs:
- name: Run burn_cell (QSS, aprox13)
run: |
cd unit_test/burn_cell
./main3d.gnu.ex inputs_aprox13 > test.out
./main3d.gnu.ex inputs_aprox13 amrex.fpe_trap_{invalid,zero,overflow}=1 > test.out
- name: Compare to stored output (QSS, aprox13)
run: |
Expand All @@ -131,9 +133,13 @@ jobs:
- name: Run burn_cell (RKC, aprox13)
run: |
cd unit_test/burn_cell
./main3d.gnu.ex inputs_aprox13 unit_test.temperature=1.e9 > test.out
./main3d.gnu.ex inputs_aprox13 unit_test.temperature=1.e9 amrex.fpe_trap_{invalid,zero,overflow}=1 > test.out
- name: Compare to stored output (RKC, aprox13)
run: |
cd unit_test/burn_cell
diff -I "^Initializing AMReX" -I "^AMReX" -I "^reading in reaclib rates" test.out ci-benchmarks/aprox13_RKC_unit_test.out
- name: Print backtrace
if: ${{ failure() && hashFiles('unit_test/burn_cell/Backtrace.0') != '' }}
run: cat unit_test/burn_cell/Backtrace.0
146 changes: 146 additions & 0 deletions .github/workflows/burn_cell_metal_chem.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
name: burn_cell_metal_chem

on: [pull_request]

jobs:
burn_cell_metal_chem:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get AMReX
run: |
mkdir external
cd external
git clone https://github.com/AMReX-Codes/amrex.git
cd amrex
git checkout development
echo 'AMREX_HOME=$(GITHUB_WORKSPACE)/external/amrex' >> $GITHUB_ENV
echo $AMREX_HOME
if [[ -n "${AMREX_HOME}" ]]; then exit 1; fi
cd ../..
- name: Install dependencies
run: |
sudo apt-get update -y -qq
sudo apt-get -qq -y install curl cmake jq clang g++>=9.3.0
- name: Compile
run: |
cd unit_test/burn_cell_metal_chem
make -j 2
- name: Run and compare outputs for different Z values, also including cosmic ray ionization
run: |
set -e
cd unit_test/burn_cell_metal_chem
declare -A line_numbers_map=(
["Z=1"]="4450 4452 4454 4456 4457 4460 4461 4464 4470 4475"
["Z=1_z10"]="1613 1615 4456 4458 4460 4463 4470 4476 4481"
["Z=1e-1"]="4438 4440 4442 4444 4445 4448 4449 4452 4458 4463"
["Z=1e-2"]="4438 4440 4442 4444 4445 4448 4449 4452 4458 4463"
["Z=1e-3"]="4438 4440 4442 4444 4445 4448 4449 4452 4458 4463"
["Z=1e-4"]="4438 4440 4442 4444 4445 4448 4449 4452 4458 4463"
["Z=1e-5"]="4438 4440 4442 4444 4445 4448 4449 4452 4458 4463"
["Z=1e-6"]="4463 4465 4467 4469 4470 4473 4474 4477 4483 4488"
["Z=1_cr"]="652 654 656 658 659 662 663 666 672 677"
["Z=1e-4_cr"]="652 654 656 658 659 662 663 666 672 677"
)
declare -A ref_map=(
["Z=1"]="reference_solution_1.out"
["Z=1_z10"]="reference_solution_1_z10.out"
["Z=1e-1"]="reference_solution_1e-1.out"
["Z=1e-2"]="reference_solution_1e-2.out"
["Z=1e-3"]="reference_solution_1e-3.out"
["Z=1e-4"]="reference_solution_1e-4.out"
["Z=1e-5"]="reference_solution_1e-5.out"
["Z=1e-6"]="reference_solution_1e-6.out"
["Z=1_cr"]="reference_solution_1_cr.out"
["Z=1e-4_cr"]="reference_solution_1e-4_cr.out"
)
ref_line_number_z10=(1 2 3 5 7 10 17 23 28)
# Original input file
original_input_file="inputs_metal_chem_1"
modified_input_file="inputs_metal_chem_modified"
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
cp $original_input_file $modified_input_file
Z_val=${Z//Z=/}
if [[ "$Z" == "Z=1_z10" ]]; then
# Modify the redshift line for Z=1_z10
sed -i 's/network.redshift = 0.0/network.redshift = 10.0/g' $modified_input_file
elif [[ "$Z" != "Z=1_cr" && "$Z" != "Z=1e-4_cr" ]]; then
# Replace the metallicity and dust2gas_ratio values for other Z values
sed -i 's/network.metallicity = .*/network.metallicity = '"$Z_val"'/g' $modified_input_file
sed -i 's/network.dust2gas_ratio = .*/network.dust2gas_ratio = '"$Z_val"'/g' $modified_input_file
fi
if [[ "$Z" == "Z=1_cr" || "$Z" == "Z=1e-4_cr" ]]; then
# Modify the number of steps, since CRs impact lowest densities
sed -i 's/unit_test.nsteps = 100000/unit_test.nsteps = 600/g' $modified_input_file
# Modify the crate line for Z=1_cr
sed -i 's/network.crate = 0.0/network.crate = 3e-17/g' $modified_input_file
if [[ "$Z" == "Z=1e-4_cr" ]]; then
# Replace the metallicity and dust2gas_ratio values for other Z values
sed -i 's/network.metallicity = 1/network.metallicity = 1e-4/g' $modified_input_file
sed -i 's/network.dust2gas_ratio = 1/network.dust2gas_ratio = 1e-4/g' $modified_input_file
fi
fi
output_file="test_${Z_val}.out"
./main1d.gnu.DEBUG.ex $modified_input_file amrex.fpe_trap_{invalid,zero,overflow}=1 > $output_file
line_numbers="${line_numbers_map[$Z]}"
ref_file="${ref_map[$Z]}"
error_found=false
index=0
for line_number in $line_numbers; do
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)
# Adjust the line number for the reference file
if [[ "$Z" == "Z=1" ]]; then
reference_line_number=$((line_number - 4449))
elif [[ "$Z" == "Z=1_z10" ]]; then
reference_line_number=${ref_line_number_z10[$index]}
elif [[ "$Z" == "Z=1e-6" ]]; then
reference_line_number=$((line_number - 4462))
elif [[ "$Z" == "Z=1_cr" || "$Z" == "Z=1e-4_cr" ]]; then
reference_line_number=$((line_number - 651))
else
reference_line_number=$((line_number - 4437))
fi
value2=$(awk 'NR=='"$reference_line_number"' {match($0, /[+-]?[0-9]+([.][0-9]+)?[eE]?[+-]?[0-9]+/); if (RSTART) print substr($0, RSTART, RLENGTH)}' $ref_file)
difference=$(awk -v val1="$value1" -v val2="$value2" 'BEGIN { printf "%.2f", (val1 - val2) / val2 }')
if (( $(echo "$difference > 0.01" | bc -l) )); then
echo "Z: $Z"
echo "Line number: $line_number"
echo "Value in $output_file: $value1"
echo "Value in $ref_file: $value2"
echo "Difference between test and reference value is $difference, more than allowed threshold of 0.01"
echo
error_found=true
fi
index=$((index + 1))
done
if [[ $error_found == true ]]; then
exit 1
fi
done
- name: Print backtrace if any failure
if: ${{ failure() && hashFiles('unit_test/burn_cell_metal_chem/Backtrace.0') != '' }}
run: cat unit_test/burn_cell_metal_chem/Backtrace.0

6 changes: 5 additions & 1 deletion .github/workflows/burn_cell_primordial_chem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ jobs:
run: |
cd unit_test/burn_cell_primordial_chem
make -j 2
./main1d.gnu.DEBUG.ex inputs_primordial_chem > test.out
./main1d.gnu.DEBUG.ex inputs_primordial_chem amrex.fpe_trap_{invalid,zero,overflow}=1 > test.out
- name: Print backtrace
if: ${{ failure() && hashFiles('unit_test/burn_cell_primordial_chem/Backtrace.0') != '' }}
run: cat unit_test/burn_cell_primordial_chem/Backtrace.0

- name: Compare to stored output
run: |
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/burn_cell_sdc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Run burn_cell_sdc (aprox19)
run: |
cd unit_test/burn_cell_sdc
./main3d.gnu.ex inputs_aprox19.ci
./main3d.gnu.ex inputs_aprox19.ci amrex.fpe_trap_{invalid,zero,overflow}=1
- name: Compare to stored output (aprox19)
run: |
Expand All @@ -51,7 +51,7 @@ jobs:
- name: Run burn_cell_sdc (BackwardEuler, aprox19)
run: |
cd unit_test/burn_cell_sdc
./main3d.gnu.ex inputs_aprox19.ci
./main3d.gnu.ex inputs_aprox19.ci amrex.fpe_trap_{invalid,zero,overflow}=1
- name: Compare to stored output (BackwardEuler, aprox19)
run: |
Expand All @@ -67,10 +67,13 @@ jobs:
- name: Run burn_cell_sdc (RKC, aprox19)
run: |
cd unit_test/burn_cell_sdc
./main3d.gnu.ex inputs_aprox19.ci
./main3d.gnu.ex inputs_aprox19.ci amrex.fpe_trap_{invalid,zero,overflow}=1
- name: Compare to stored output (RKC, aprox19)
run: |
cd unit_test/burn_cell_sdc
diff state_over_time.txt ci-benchmarks/aprox19_RKC_state_over_time.txt
- name: Print backtrace
if: ${{ failure() && hashFiles('unit_test/burn_cell_sdc/Backtrace.0') != '' }}
run: cat unit_test/burn_cell_sdc/Backtrace.0
3 changes: 3 additions & 0 deletions .github/workflows/check_ifdefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ def check_file(filename):
if "tmp_build_dir" in f.parts:
# skip generated files
continue
if f.parts[:2] == ("util", "autodiff"):
# skip third-party autodiff files
continue
ierr, defines = check_file(f)
all_defines += defines
total_errors += ierr
Expand Down
21 changes: 13 additions & 8 deletions .github/workflows/check_powi.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@


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

# Check for all positive and negative integer, whole float numbers
# Match all positive and negative integers, whole float numbers
# with and without _rt
match_pattern = r"([^,]+),\s*(-?(?:\d+\.0*_rt?|\d))"
integer_pattern = r"-?(?:\d+\.0*(?:e0)?(?:_rt)?|\d)"

# Check for an integer in the second argument
match_pattern = rf"([^,]+),\s*({integer_pattern})"

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

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

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

# Print out suggested change and raise error after detecting modification
if git_diff_output.stdout:
print("Detected potential usage to replace std::pow" +
"with integer powers via amrex::Math::powi\n")
print("Below are the suggested change:\n")
print("Detected potential usage to replace std::pow"
" with integer powers via amrex::Math::powi\n")
print("Below are the suggested changes:\n")
print(git_diff_output.stdout)

raise RuntimeError("Changes detected after modification")
Expand Down
Loading

0 comments on commit 0428e03

Please sign in to comment.