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

Implement ISM chemistry including metals and dust #1642

Merged
merged 126 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
6e594fd
modified CMakeLists to include metal_chem network
Jul 15, 2024
cd76a86
updated initializations to be general for both primordial chem and me…
Jul 15, 2024
52e65c1
added network and actual_rhs for metal chem network
Jul 15, 2024
ce8eac9
added unit test for metal chem network
Jul 15, 2024
dd075da
added additional input params, fixed bug
Jul 15, 2024
b380c11
added metal chem RHS
Jul 15, 2024
e59827a
write_network for all networks separately
Jul 15, 2024
f36abc6
merge development
Aug 22, 2024
95a5287
update RHS including ices
Aug 22, 2024
6dd9deb
reset to contain 14 species; change formatting
Aug 22, 2024
f2b1aba
update runtime params
Aug 22, 2024
a58d82b
only need to declare and define tdust and semenov cooling in actual rhs
Aug 22, 2024
e296cbe
reset comment
Aug 22, 2024
42f2a85
add EOS for metal ISm chemistry
Aug 22, 2024
052e3b9
update to include metal chem EOS
Aug 22, 2024
57a0676
use eos_rp to identify species
Aug 22, 2024
ea444d5
fix bug
Aug 22, 2024
cf778f3
fix indent
Aug 22, 2024
de2b60c
dont use tabs
Aug 22, 2024
3fc9001
d2g should be scaled wrt solar
Aug 22, 2024
89e9c4c
define metallicity Z
Aug 22, 2024
7332abe
update to use metal chem dirs
Aug 22, 2024
ea0bccc
update to use metal chem dirs
Aug 22, 2024
938e68b
only need 34 species
Aug 22, 2024
725c0c3
update electron conservation
Aug 22, 2024
029ccac
update initial abundances
Aug 22, 2024
3c38eec
updated .net file; cannot call carbon C because it conflicts with the…
Aug 22, 2024
9ef16a2
correct name
Aug 22, 2024
1a5fd03
fix bug
Aug 22, 2024
e740b86
initial point is now 0.1 cm**-3, 300 K
Aug 22, 2024
3e49e51
remove trailing whitespaces
Aug 23, 2024
af21a2d
remove unused param
Aug 23, 2024
8df0086
primordial chem works now
Aug 23, 2024
b7875cd
make test similar to python
Aug 23, 2024
1f09cb8
store Tdust as an aux variable
Aug 23, 2024
d11cf2b
limit max step size to 0.1*dt
Aug 24, 2024
0b0b93d
update tolerances
Aug 24, 2024
7bedfcd
revert to using std::pow because some exp calls calculate to 0
Aug 24, 2024
75a6fe9
add opacity table from Semenov+2003
Aug 24, 2024
1aeb023
interpolate over semenov table
Aug 24, 2024
1f1d23d
move reading semenov tables to init routine
Aug 25, 2024
4cca500
remove old code
Aug 25, 2024
f7b8be0
remove old code
Aug 25, 2024
9040932
fix bug: re-initialize sum_numdens to 0 before summing
Aug 25, 2024
6202e2d
include actual_network_data.cpp for metal_chem
Aug 26, 2024
53af3a1
use size_t instead of int
Aug 26, 2024
441d67d
remove whitspace
Aug 26, 2024
7fc46d7
remove whitspace
Aug 26, 2024
2e0ca1d
use powi in tdust computation
Aug 26, 2024
3bba6a4
remove whitespace
Aug 26, 2024
744c6cb
remove state over time
Aug 26, 2024
6e9628d
max timestep=0.1*dt
Aug 26, 2024
ca777fc
only build subdirectory if primordial chem test above was not built
Aug 26, 2024
2c02f64
max step <= dt; display final numdens
Aug 26, 2024
7f60837
use jacobian caching and take smaller steps (tff_reduc)
Aug 26, 2024
c1ce718
cannot build both PC and MC tests together
Aug 26, 2024
d1c571a
added reference solution
Aug 26, 2024
c0ea186
added test for solar metallicity
Aug 26, 2024
e28163e
rename test file
Aug 26, 2024
6f20e77
rename test file
Aug 26, 2024
629b9e9
rename workflow file
Aug 26, 2024
3129ae6
remove period from input file
Aug 26, 2024
c7a6606
rename input file for workflow test
Aug 26, 2024
a400022
supply dummy aion for ices
Aug 26, 2024
d190487
supply dummy zion for ices
Aug 26, 2024
713639a
use ceiling in H2 cooling to ensure no overflows when Tgas is low
Aug 26, 2024
6f73f3a
add correct reference solution
Aug 26, 2024
82608f5
debug workflow file
Aug 26, 2024
c54ea0b
adjust lines
Aug 26, 2024
79dbd2a
adjust line numbers
Aug 26, 2024
de8a37d
adjust ref line numbers
Aug 26, 2024
5dd8fff
add test for z=1e-6
Aug 26, 2024
39b38c5
add input file for Z=1e-6
Aug 26, 2024
0bf5496
adjust line numbers for Z=1e-6
Aug 26, 2024
b088e60
added input files at all Z
Aug 26, 2024
42a0f68
remove old test
Aug 26, 2024
87056ce
rename
Aug 26, 2024
9518260
added ref solution for Z=1e-1
Aug 26, 2024
402472d
add test for Z=1e-1
Aug 26, 2024
8591f4c
no line adjust for Z=1e-1
Aug 26, 2024
0659ed2
add tests for all intermediate Z
Aug 26, 2024
db53a35
remove debug lines
Aug 26, 2024
149121f
floor Tgas to TCMB
Aug 26, 2024
3d3779b
added files for z=10 test
Aug 26, 2024
cc91cab
rename
Aug 26, 2024
d7d48ef
add test for redshift 10
Aug 26, 2024
1fbfbc5
add checks at intermediate densities for high-z test
Aug 26, 2024
ea87726
actually build primordial chem test
Aug 26, 2024
0075392
add amrex debug and fpe trapping options in comments
Aug 26, 2024
9f00a85
added metal chem macos test
Aug 26, 2024
e6dbe56
fix bug in cmake; ensure opacity datafile is available to target
Aug 26, 2024
f29037b
print debug Ts
Aug 27, 2024
5f4c047
reset to default values
Aug 27, 2024
497e06a
cmake test passes
Aug 27, 2024
1a53f2d
fix whitespaces
Aug 27, 2024
0c4ae80
adjust line numbers
Aug 27, 2024
bec1fb7
adjust line numbers
Aug 27, 2024
4d65a84
updated readme
Aug 27, 2024
e904fe3
adjust line numbers
Aug 27, 2024
8f168a0
remove old code
Aug 27, 2024
3638ae8
use for loop instead of while
Aug 27, 2024
251a5ca
reduce number of lines in ref output
Aug 27, 2024
84e3dc1
start line num from 1
Aug 27, 2024
a716a16
reduce ref file sizes
Aug 27, 2024
e45fd4b
do binary search instead of linear
Aug 27, 2024
b86f994
reduce size of z=10 ref
Aug 27, 2024
c1e6e5a
consolidate
Aug 27, 2024
2948d7f
compile
Aug 27, 2024
9226d88
adjust ref line nums in z=10 output
Aug 27, 2024
3f1ea68
adjust ref line nums in z=10 output
Aug 27, 2024
4e973f1
initialize index
Aug 27, 2024
a436882
use macro to initialize specie masses and gammas
Aug 27, 2024
b5e2a6d
remove spaces around index
Aug 27, 2024
8cd2302
Merge branch 'development' into metal_chemistry
psharda Aug 27, 2024
613f38f
create and call a function in networks to balance charge
Aug 27, 2024
9aedc9a
only use one input file
Aug 27, 2024
600359a
remove extra input files
Aug 27, 2024
f9b03b9
use amrex::Error instead of std::runtime_error
Aug 27, 2024
f03c1b4
define starting index for gas phase species
Aug 29, 2024
1eaecc3
Merge branch 'development' into metal_chemistry
psharda Aug 29, 2024
1fb3bfa
update value
Aug 29, 2024
7056045
add function to balance charge
Aug 29, 2024
6e2141f
use balance charge function
Aug 29, 2024
14eb8be
Revert "use balance charge function"
Aug 29, 2024
0401c93
revert
Aug 29, 2024
bba236b
use macro to initialize species masses and gammas
Aug 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 75 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.20)

project(Microphysics
VERSION 1.0.0
DESCRIPTION "building primordial_chemistry network in Microphysics with CMake"
DESCRIPTION "building primordial_chemistry or metal_chemistry networks in Microphysics with CMake"
LANGUAGES CXX C)

#----------------------------------------------------------------------------------------------------------------------
Expand All @@ -23,11 +23,11 @@ function(setup_target_for_microphysics_compilation network_name output_dir)
set(integrationparamfile "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/integration/_parameters")
set(unittestparamfile "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/unit_test/_parameters")

set(networkpropfile "${output_dir}/network_properties.H")

if (${network_name} STREQUAL "gamma_law")
set(EOSparamfile "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/EOS/gamma_law/_parameters")

set(networkpropfile "${output_dir}/network_properties.H")
set(networkfile "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/networks/general_null/gammalaw.net")
set(networkdir "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/networks/general_null/")
set(networkheadertemplatefile "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/networks/general_null/network_header.template")
Expand All @@ -44,6 +44,7 @@ function(setup_target_for_microphysics_compilation network_name output_dir)
set(gamma_law_sources ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/interfaces/eos_data.cpp
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/interfaces/network_initialization.cpp
${output_dir}/extern_parameters.cpp PARENT_SCOPE)
execute_process(COMMAND python3 "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/networks/general_null/write_network.py" --header_template "${networkheadertemplatefile}" --header_output "${networkpropfile}" -s "${networkfile}" WORKING_DIRECTORY ${output_dir}/)

elseif (${network_name} STREQUAL "primordial_chem")
#need these to write extern_parameters.H
Expand All @@ -52,6 +53,7 @@ function(setup_target_for_microphysics_compilation network_name output_dir)
set(networkpcparamfile "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/networks/primordial_chem/_parameters")

#similarly, we want network_properties.H
set(networkpropfile "${output_dir}/network_properties.H")
set(networkfile "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/networks/primordial_chem/pynucastro.net")
set(networkdir "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/networks/primordial_chem/")
set(networkheadertemplatefile "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/networks/general_null/network_header.template")
Expand All @@ -71,7 +73,7 @@ function(setup_target_for_microphysics_compilation network_name output_dir)
#so, if any of the _parameter files are changed, one needs to re-run 'cmake'
#to generate updated header files

if(BUILD_UNIT_TEST)
if(BUILD_UNIT_TEST_PC)
execute_process(COMMAND python3 "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/util/build_scripts/write_probin.py" --pa "${paramfile} ${EOSparamfile}
${networkpcparamfile} ${networkparamfile} ${VODEparamfile} ${integrationparamfile} ${unittestparamfile}" --use_namespace WORKING_DIRECTORY ${output_dir}/)
else()
Expand All @@ -88,13 +90,59 @@ function(setup_target_for_microphysics_compilation network_name output_dir)

#below for NAUX
execute_process(COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${PYTHONPATH}:${CMAKE_CURRENT_FUNCTION_LIST_DIR}/networks/general_null" python3 "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/networks/get_naux.py" --net "${networkdir}" --microphysics_path "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/" WORKING_DIRECTORY ${output_dir}/)
execute_process(COMMAND python3 "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/networks/general_null/write_network.py" --header_template "${networkheadertemplatefile}" --header_output "${networkpropfile}" -s "${networkfile}" WORKING_DIRECTORY ${output_dir}/)

elseif (${network_name} STREQUAL "metal_chem")
#need these to write extern_parameters.H
set(paramfile "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/unit_test/burn_cell_metal_chem/_parameters")
set(EOSparamfile "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/EOS/metal_chem/_parameters")
set(networkpcparamfile "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/networks/metal_chem/_parameters")

#similarly, we want network_properties.H
set(networkpropfile "${output_dir}/network_properties.H")
set(networkfile "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/networks/metal_chem/pynucastro.net")
set(networkdir "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/networks/metal_chem/")
set(networkheadertemplatefile "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/networks/general_null/network_header.template")

#DO NOT change the order of the directories below!
set (metal_chem_dirs ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/util ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/util/gcem/include
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/integration/VODE ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/integration/utils
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/integration ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/interfaces
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/EOS ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/EOS/metal_chem
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/networks/metal_chem ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/networks
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/constants
PARENT_SCOPE)

#we need to have extern_parameters.cpp be available at configure time
#the script write_probin.py writes this .cpp file so we call it here
#note, execute_process only works on 'cmake' and not 'make'
#so, if any of the _parameter files are changed, one needs to re-run 'cmake'
#to generate updated header files

if(BUILD_UNIT_TEST_MC)
execute_process(COMMAND python3 "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/util/build_scripts/write_probin.py" --pa "${paramfile} ${EOSparamfile}
${networkpcparamfile} ${networkparamfile} ${VODEparamfile} ${integrationparamfile} ${unittestparamfile}" --use_namespace WORKING_DIRECTORY ${output_dir}/)
else()
#do not need paramfile and unittestparamfile
execute_process(COMMAND python3 "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/util/build_scripts/write_probin.py" --pa "${EOSparamfile} ${networkpcparamfile}
${networkparamfile} ${VODEparamfile} ${integrationparamfile} " --use_namespace WORKING_DIRECTORY ${output_dir}/)
endif()

set(primordial_chem_sources ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/interfaces/eos_data.cpp
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/interfaces/network_initialization.cpp
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/EOS/metal_chem/actual_eos_data.cpp
${output_dir}/extern_parameters.cpp PARENT_SCOPE)


#below for NAUX
execute_process(COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${PYTHONPATH}:${CMAKE_CURRENT_FUNCTION_LIST_DIR}/networks/general_null" python3 "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/networks/get_naux.py" --net "${networkdir}" --microphysics_path "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/" WORKING_DIRECTORY ${output_dir}/)
execute_process(COMMAND python3 "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/networks/general_null/write_network.py" --header_template "${networkheadertemplatefile}" --header_output "${networkpropfile}" -s "${networkfile}" WORKING_DIRECTORY ${output_dir}/)

else()
message(FATAL_ERROR "Given network_name " ${network_name} " currently not supported. Use either 'gamma_law' or 'primordial_chem' ")

endif()

execute_process(COMMAND python3 "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/networks/general_null/write_network.py" --header_template "${networkheadertemplatefile}" --header_output "${networkpropfile}" -s "${networkfile}" WORKING_DIRECTORY ${output_dir}/)

endfunction()

Expand Down Expand Up @@ -126,8 +174,11 @@ endif()

#set a cache variable that controls whether
#we want to build the unit test or not
set(BUILD_UNIT_TEST false CACHE BOOL "Do you want to build the unit test? (true/false)")
message("Building unit test -- ${BUILD_UNIT_TEST}")
set(BUILD_UNIT_TEST_PC false CACHE BOOL "Do you want to build the primordial chem unit test? (true/false)")
message("Building unit test -- ${BUILD_UNIT_TEST_PC}")

set(BUILD_UNIT_TEST_MC false CACHE BOOL "Do you want to build the metal chem unit test? (true/false)")
message("Building unit test -- ${BUILD_UNIT_TEST_MC}")

add_compile_options(-Werror -Wall -Wextra)

Expand All @@ -140,12 +191,12 @@ add_compile_options(-Werror -Wall -Wextra)
#this will generate a warning but it will build successfully
#do not need unit_test paramfiles when unit_test is not built

if(BUILD_UNIT_TEST)
if(BUILD_UNIT_TEST_PC)
#Build primordial chem unit test
setup_target_for_microphysics_compilation("primordial_chem" ${CMAKE_BINARY_DIR})

include_directories(${primordial_chem_dirs})

#adding unit_test as subdirectories
#adding unit_tests as subdirectories
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/unit_test)
message("Building primordial chem unit test")

Expand All @@ -155,4 +206,19 @@ else()
endif()


if(BUILD_UNIT_TEST_MC)
#Build metal chem unit test
setup_target_for_microphysics_compilation("metal_chem" ${CMAKE_BINARY_DIR})
include_directories(${metal_chem_dirs})

#adding unit_tests as subdirectories
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/unit_test)
message("Building metal chem unit test")

else()

message("Not building metal chem unit test")
endif()



3 changes: 3 additions & 0 deletions EOS/metal_chem/Make.package
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CEXE_headers += actual_eos.H
CEXE_headers += actual_eos_data.H
CEXE_sources += actual_eos_data.cpp
140 changes: 140 additions & 0 deletions EOS/metal_chem/_parameters
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
@namespace: eos

eos_gamma_default real 1.4

# define the specie names, and their masses and gammas
species_1_name string "co_ice"
species_1_gamma real 5./3.
species_1_mass real 0.0

species_2_name string "h2o_ice"
species_2_gamma real 5./3.
species_2_mass real 0.0

species_3_name string "elec"
species_3_gamma real 5./3.
species_3_mass real 9.10938188e-28

species_4_name string "hp"
species_4_gamma real 5./3.
species_4_mass real 1.67262158e-24

species_5_name string "h"
species_5_gamma real 5./3.
species_5_mass real 1.67353251819e-24

species_6_name string "hm"
species_6_gamma real 5./3.
species_6_mass real 1.67444345638e-24

species_7_name string "dp"
species_7_gamma real 5./3.
species_7_mass real 3.34512158e-24

species_8_name string "d"
species_8_gamma real 5./3.
species_8_mass real 3.34603251819e-24

species_9_name string "h2p"
species_9_gamma real 1.4
species_9_mass real 3.34615409819e-24

species_10_name string "dm"
species_10_gamma real 5./3.
species_10_mass real 3.34694345638e-24

species_11_name string "h2"
species_11_gamma real 1.4
species_11_mass real 3.34706503638e-24

species_12_name string "hdp"
species_12_gamma real 1.4
species_12_mass real 5.01865409819e-24

species_13_name string "hd"
species_13_gamma real 1.4
species_13_mass real 5.01956503638e-24

species_14_name string "hepp"
species_14_gamma real 5./3.
species_14_mass real 6.69024316e-24

species_15_name string "hep"
species_15_gamma real 5./3.
species_15_mass real 6.69115409819e-24

species_16_name string "he"
species_16_gamma real 5./3.
species_16_mass real 6.69206503638e-24

species_17_name string "cp"
species_17_gamma real 5./3.
species_17_mass real 2.007528417094e-23

species_18_name string "c"
species_18_gamma real 5./3.
species_18_mass real 2.0076195109128e-23

species_19_name string "ch"
species_19_gamma real 1.4
species_19_mass real 2.1749727627316e-23

species_20_name string "ch2"
species_20_gamma real 1.4
species_20_mass real 2.3423260145503998e-23

species_21_name string "ch3"
species_21_gamma real 1.4
species_21_mass real .5096792663692e-23

species_22_name string "op"
species_22_gamma real 5./3.
species_22_mass real 2.6767349207316e-23

species_23_name string "o"
species_23_gamma real 5./3.
species_23_mass real 2.6768260145504e-23

species_24_name string "ch4"
species_24_gamma real 1.4
species_24_mass real 2.677032518188e-23

species_25_name string "ohp"
species_25_gamma real 1.4
species_25_mass real 2.8440881725504e-23

species_26_name string "oh"
species_26_gamma real 1.4
species_26_mass real 2.8441792663692003e-23

species_27_name string "h2op"
species_27_gamma real 1.4
species_27_mass real 3.0114414243692e-23

species_28_name string "h2o"
species_28_gamma real 1.4
species_28_mass real 3.011532518188e-23

species_29_name string "h3op"
species_29_gamma real 1.4
species_29_mass real 3.178794676188e-23

species_30_name string "cop"
species_30_gamma real 1.4
species_30_mass real 4.6843544316444e-23

species_31_name string "co"
species_31_gamma real 1.4
species_31_mass real 4.6844455254632e-23

species_32_name string "o2p"
species_32_gamma real 1.4
species_32_mass real 5.353560935282e-23

species_33_name string "o2"
species_33_gamma real 1.4
species_33_mass real 5.3536520291008e-23

species_34_name string "co2"
species_34_gamma real 1.4
species_34_mass real 7.3612715400136e-23
Loading
Loading