From 723067f0c8ae144b7c70c7f664df4affe7ac950f Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 19 Nov 2025 09:11:08 -0500 Subject: [PATCH 001/175] introduce FrozenKeyIdxBiMap data structure --- CMakePresets.json | 2 +- src/clib/CMakeLists.txt | 1 + src/clib/utils/FrozenKeyIdxBiMap.hpp | 226 ++++++++++++++++++ tests/unit/CMakeLists.txt | 4 + tests/unit/test_unit_FrozenKeyIdxBiMap.cpp | 262 +++++++++++++++++++++ 5 files changed, 494 insertions(+), 1 deletion(-) create mode 100644 src/clib/utils/FrozenKeyIdxBiMap.hpp create mode 100644 tests/unit/test_unit_FrozenKeyIdxBiMap.cpp diff --git a/CMakePresets.json b/CMakePresets.json index b91a0cd74..037914b50 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -51,7 +51,7 @@ "cacheVariables" : { "CMAKE_COMPILE_WARNING_AS_ERROR": "ON", "CMAKE_C_FLAGS": "-Wall -Wpedantic -Wextra -Wno-error=unused-variable -Wno-error=newline-eof -Wno-unused-parameter", - "CMAKE_CXX_FLAGS": "-Wall -Wpedantic -Wno-c++17-attribute-extensions -Wno-unused-parameter" + "CMAKE_CXX_FLAGS": "-Wall -Wpedantic -Wno-c++17-attribute-extensions -Wno-unused-parameter -Wno-error=self-assign" } }, { diff --git a/src/clib/CMakeLists.txt b/src/clib/CMakeLists.txt index 6e3b757c8..f865f97e7 100644 --- a/src/clib/CMakeLists.txt +++ b/src/clib/CMakeLists.txt @@ -125,6 +125,7 @@ add_library(Grackle_Grackle solve_rate_cool_g-cpp.cpp solve_rate_cool_g-cpp.h step_rate_newton_raphson.hpp time_deriv_0d.hpp + utils/FrozenKeyIdxBiMap.hpp utils-cpp.cpp utils-cpp.hpp utils-field.hpp fortran_func_wrappers.hpp diff --git a/src/clib/utils/FrozenKeyIdxBiMap.hpp b/src/clib/utils/FrozenKeyIdxBiMap.hpp new file mode 100644 index 000000000..7bf0b2772 --- /dev/null +++ b/src/clib/utils/FrozenKeyIdxBiMap.hpp @@ -0,0 +1,226 @@ +//===----------------------------------------------------------------------===// +// +// See the LICENSE file for license and copyright information +// SPDX-License-Identifier: NCSA AND BSD-3-Clause +// +//===----------------------------------------------------------------------===// +/// +/// @file +/// Declares the internal FrozenKeyIdxBiMap type +/// +/// All insertions occur during initialization. This simplifies a lot of +/// bookkeeping. +/// +/// The underlying implementation of this type is *highly* suboptimal (it's +/// simplistic at the cost of speed). PR #270 introduce a drop-in replacement +/// that maintains the exact same API +/// +//===----------------------------------------------------------------------===// +#ifndef UTILS_FROZENKEYIDXBIMAP_HPP +#define UTILS_FROZENKEYIDXBIMAP_HPP + +#include +#include +#include +#include + +#include "grackle.h" +#include "status_reporting.h" + +// the motivation for these constants are provided in PR #270 (they are related +// to some optimizations in the FrozenKeyIdxBiMap implementation) +namespace grackle::impl::bimap { +/// specifies an invalid value of the map (we state that you can't store the +/// maximum u16 value) +inline constexpr std::uint16_t invalid_val = + std::numeric_limits::max(); + +/// specifies maximum allowed length of a key (excluding the null character). +inline constexpr std::uint16_t keylen_max = 29; +} + +// these are just here for to make it easier for us to adopt changes from PR +// #270 (then we can delete these macros) +#define STRU16MAP_INVALID_VAL grackle::impl::bimap::invalid_val +#define STRU16MAP_KEYLEN_MAX grackle::impl::bimap::keylen_max + +namespace grackle::impl { + +enum class BiMapMode { + REFS_KEYDATA = 0, + COPIES_KEYDATA = 1 +}; + +/// @brief This is a bidirectional map (bimap). It is specialized to map `n` +/// unique string keys to unique indexes with values of `0` through `n-1` and +/// vice versa. The ordering of keys is set at initialization and frozen. +/// +/// This is primarily intended to be used in the implementation of Maps of +/// arrays (where the values could be part of a single contiguous array or are +/// individual arrays), but this but may be broadly useful for other +/// applications. +/// +/// This operates in 2 modes: +/// 1. @ref BiMapMode::REFS_KEYDATA This is the default, where we operate +/// under the assumption that the allocations holding the string characters +/// outlive the bimap. In this mode the bimap is intended to hold +/// string-literals. (which are live for the entirety of a program). This +/// minimizes memory usage. +/// 2. @ref BiMapMode::COPIES_KEYDATA Under this mode, the bimap copies the +/// data of all keys. This is useful for testing purposes. In the long-term, +/// if we allow dynamic extension of chemistry networks, it will also be +/// useful. If we are implement the optimizations described down below +/// (where we directly embed the string in the hash-table-rows), this will +/// probably be a quite a bit faster +/// +/// Replacement in PR #270 +/// ====================== +/// The current implementation is extremely oversimplified and inefficient! It +/// doesn't even use a hash table. The purpose is to create a simple abstract +/// data structure for which the implementation will be dramatically improved +/// by PR #270 (but the interface won't be touched at all). +/// +/// The PR with the improved version, also updates this docstring with a +/// detailed explanation of design decisions (like why the contents +/// are "frozen") and highlights a number of potential improvements. +/// +/// > [!note] +/// > The contents of this struct should be considered an implementation +/// > detail! Always prefer the associated functions (they are defined in such +/// > a way that they should be inlined +struct FrozenKeyIdxBiMap{ + // don't forget to update FrozenKeyIdxBiMap_clone when changing members + + /// the number of contained strings + int length; + /// array of keys + const char** keys; + /// indicates whether the map "owns" the memory holding the characters in + /// each key or just references it + BiMapMode mode; +}; + +/// Constructs a new FrozenKeyIdxBiMap +/// +/// @param[out] out Pointer where the allocated type is stored +/// @param[in] keys Sequence of 1 or more unique strings. Each string must +/// include at least 1 non-null character and be null-terminated +/// @param[in] key_count The length of keys +/// @param[in] mode specifies handling of keys. This will be passed on to any +/// clones that are made. +inline int new_FrozenKeyIdxBiMap( + FrozenKeyIdxBiMap** out, const char* keys[], int key_count, + BiMapMode mode +) { + + // check the specified keys + long long max_keys = static_cast(bimap::invalid_val) - 1LL; + if (key_count < 1 || static_cast(key_count) > max_keys) { + return GrPrintAndReturnErr( + "key_count must be positive and cannot exceed %lld", max_keys + ); + } else if (keys == nullptr) { + return GrPrintAndReturnErr("keys must not be a nullptr"); + } + for (int i = 0; i < key_count; i++) { + GR_INTERNAL_REQUIRE(keys[i] != nullptr, "Can't specify a nullptr key"); + std::size_t n_chrs_without_nul = std::strlen(keys[i]); + if (n_chrs_without_nul == 0 || n_chrs_without_nul > bimap::keylen_max) { + return GrPrintAndReturnErr( + "calling strlen on \"%s\", the key @ index %d, yields 0 or a length " + "exceeding %d", + keys[i], i, bimap::keylen_max + ); + } + // check uniqueness + for (int j = 0; j < i; j++) { + if (strcmp(keys[i], keys[j]) == 0) { + return GrPrintAndReturnErr("\"%s\" key repeats", keys[i]); + } + } + } + + // now, actually construct the result + const char** out_keys = nullptr; + switch (mode) { + case BiMapMode::REFS_KEYDATA: { + out_keys = new const char*[key_count]; + for (int i = 0; i < key_count; i++) { + out_keys[i] = keys[i]; + } + break; + } + case BiMapMode::COPIES_KEYDATA: { + char** tmp_keys = new char*[key_count]; + for (int i = 0; i < key_count; i++) { + std::size_t n_chrs_without_nul = std::strlen(keys[i]); + tmp_keys[i] = new char[n_chrs_without_nul + 1]; + std::memcpy(tmp_keys[i], keys[i], n_chrs_without_nul + 1); + } + out_keys = (const char**)tmp_keys; + break; + } + default: return GrPrintAndReturnErr("unknown mode"); + } + + (*out) = new FrozenKeyIdxBiMap; + (*out)->length = key_count; + (*out)->keys = out_keys; + + return GR_SUCCESS; +} + +/// Destroys the specified FrozenKeyIdxBiMap +inline void drop_FrozenKeyIdxBiMap(FrozenKeyIdxBiMap* ptr) { + if (ptr->mode == BiMapMode::COPIES_KEYDATA) { + for (int i = 0; i < ptr->length; i++) { + delete[] ptr->keys[i]; + } + } + delete[] ptr->keys; + delete ptr; +} + + +/// Makes a clone of the specified FrozenKeyIdxBiMap (the clone inherites the +/// original BiMapMode). +int FrozenKeyIdxBiMap_clone(FrozenKeyIdxBiMap** out, + const FrozenKeyIdxBiMap* ptr) { + return new_FrozenKeyIdxBiMap(out, ptr->keys, ptr->length, ptr->mode); +}; + +/// returns the value associated with the key or (if the key can't be found) +/// @ref grackle::impl::bimap::invalid_val +inline std::uint16_t FrozenKeyIdxBiMap_idx_from_key( + const FrozenKeyIdxBiMap* map, const char* key +) +{ + GR_INTERNAL_REQUIRE(key != nullptr, "A nullptr key is forbidden"); + for (int i = 0; i < map->length; i++) { + if (std::strcmp(map->keys[i], key) == 0) { + return static_cast(i); + } + } + return bimap::invalid_val; +} + +/// checks if the map contains a key +inline int FrozenKeyIdxBiMap_contains(const FrozenKeyIdxBiMap* map, + const char* key) { + return FrozenKeyIdxBiMap_idx_from_key(map, key) != bimap::invalid_val; +} + +inline int FrozenKeyIdxBiMap_size(const FrozenKeyIdxBiMap* map) +{ return map->length; } + +/// Return the ith key (this is effectively a reverse lookup) +inline const char* FrozenKeyIdxBiMap_key_from_idx( + const FrozenKeyIdxBiMap* map, std::uint16_t i +) { + if (i >= map->length) { return nullptr; } + return map->keys[i]; // this can't be a nullptr +} + +} // namespace grackle::impl + +#endif // UTILS_FROZENKEYIDXBIMAP_HPP diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index 9e05050ba..b6c9e0ba1 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -48,6 +48,10 @@ target_compile_definitions(grtest_utils # start declaring targets for tests # --------------------------------- +add_executable(testFrozenKeyIdxBiMap test_unit_FrozenKeyIdxBiMap.cpp) +target_link_libraries(testFrozenKeyIdxBiMap testdeps) +gtest_discover_tests(testFrozenKeyIdxBiMap) + add_executable(runInterpolationTests test_unit_interpolators_g.cpp) target_link_libraries(runInterpolationTests testdeps) diff --git a/tests/unit/test_unit_FrozenKeyIdxBiMap.cpp b/tests/unit/test_unit_FrozenKeyIdxBiMap.cpp new file mode 100644 index 000000000..83aabc0ca --- /dev/null +++ b/tests/unit/test_unit_FrozenKeyIdxBiMap.cpp @@ -0,0 +1,262 @@ +//===----------------------------------------------------------------------===// +// +// See the LICENSE file for license and copyright information +// SPDX-License-Identifier: NCSA AND BSD-3-Clause +// +//===----------------------------------------------------------------------===// +/// +/// @file +/// tests the @ref grackle::impl::FrozenKeyIdxBiMap +/// +//===----------------------------------------------------------------------===// + +#include +#include + +#include +#include "utils/FrozenKeyIdxBiMap.hpp" +#include "grackle.h" + +class FrozenKeyIdxBiMapConstructorSuite : + public testing::TestWithParam { + // You can implement all the usual fixture class members here. + // To access the test parameter, call GetParam() from class + // TestWithParam. + +}; + +TEST_P(FrozenKeyIdxBiMapConstructorSuite, Simple) { + grackle::impl::FrozenKeyIdxBiMap* tmp = nullptr; + const char* keys[] = {"denisty", "internal_energy"}; + + EXPECT_EQ(new_FrozenKeyIdxBiMap(&tmp, keys, 2, GetParam()), GR_SUCCESS); + ASSERT_NE(tmp, nullptr); + grackle::impl::drop_FrozenKeyIdxBiMap(tmp); +} + +TEST_P(FrozenKeyIdxBiMapConstructorSuite, LongKey) { + grackle::impl::FrozenKeyIdxBiMap* tmp = nullptr; + + const char* first_key = "density"; + std::string long_key(STRU16MAP_KEYLEN_MAX, 'A'); + const char* keys[2] = {first_key, long_key.data()}; + EXPECT_EQ(new_FrozenKeyIdxBiMap(&tmp, keys, 2, GetParam()), GR_SUCCESS); + ASSERT_NE(tmp, nullptr); + grackle::impl::drop_FrozenKeyIdxBiMap(tmp); +} + +TEST_P(FrozenKeyIdxBiMapConstructorSuite, TooLongKey) { + grackle::impl::FrozenKeyIdxBiMap* tmp = nullptr; + + const char* first_key = "density"; + std::string long_key(STRU16MAP_KEYLEN_MAX+1, 'A'); + const char* keys[2] = {first_key, long_key.data()}; + EXPECT_NE(new_FrozenKeyIdxBiMap(&tmp, keys, 2, GetParam()), GR_SUCCESS); + ASSERT_EQ(tmp, nullptr); +} + +TEST_P(FrozenKeyIdxBiMapConstructorSuite, 0LenKey) { + grackle::impl::FrozenKeyIdxBiMap* tmp = nullptr; + + const char* keys[2] = {"density",""}; + EXPECT_NE(new_FrozenKeyIdxBiMap(&tmp, keys, 2, GetParam()), GR_SUCCESS); + ASSERT_EQ(tmp, nullptr); +} + +TEST_P(FrozenKeyIdxBiMapConstructorSuite, NoKeys) { + grackle::impl::FrozenKeyIdxBiMap* tmp = nullptr; + + EXPECT_NE(new_FrozenKeyIdxBiMap(&tmp, nullptr, 0, GetParam()), GR_SUCCESS); + ASSERT_EQ(tmp, nullptr); // if this fails, we'll leak memory (but not much + // can be done) +} + +INSTANTIATE_TEST_SUITE_P( + , /* <- leaving Instantiation name empty */ + FrozenKeyIdxBiMapConstructorSuite, + testing::Values(grackle::impl::BiMapMode::REFS_KEYDATA, grackle::impl::BiMapMode::COPIES_KEYDATA), + [](const testing::TestParamInfo& info){ + if (info.param == grackle::impl::BiMapMode::REFS_KEYDATA) { + return std::string("BIMAP_REFS_KEYDATA"); + } else { + return std::string("BIMAP_COPIES_KEYDATA"); + } + } +); + + +/// helper function to initialize a map from a vector +int new_FrozenKeyIdxBiMap(grackle::impl::FrozenKeyIdxBiMap** out, + const std::vector& vec_, + grackle::impl::BiMapMode mode) +{ + std::size_t key_count = vec_.size(); + + // create a vector of pointers + std::vector key_ptr_l(key_count, nullptr); + for (std::size_t i = 0; i < key_count; i++) { + key_ptr_l[i] = vec_[i].c_str(); + } + + return new_FrozenKeyIdxBiMap(out, key_ptr_l.data(), key_count, mode); +} + +class FrozenKeyIdxBiMapGeneralSuite : + public testing::TestWithParam +{ +protected: + std::vector ordered_keys; + grackle::impl::FrozenKeyIdxBiMap* bimap_p = nullptr; + + // we use SetUp/Teardown instead of constructor and destructor so we can + // perform some sanity checks with ASSERTIONs + void SetUp() override { + ordered_keys = std::vector{ + "internal_energy", "density", "metal_density" + }; + + grackle::impl::BiMapMode mode = this->GetParam(); + ASSERT_EQ( + new_FrozenKeyIdxBiMap(&this->bimap_p, ordered_keys, mode), + GR_SUCCESS + ); + + } + + void TearDown() override { + if (bimap_p != nullptr) { grackle::impl::drop_FrozenKeyIdxBiMap(bimap_p); } + } + + bool ReusesOriginalKeyPtrs(const grackle::impl::FrozenKeyIdxBiMap* p) const { + for (int i = 0; i < 3; i++) { + const char* orig_key_ptr = ordered_keys[i].c_str(); + if (grackle::impl::FrozenKeyIdxBiMap_key_from_idx(p, i) != orig_key_ptr) { + return false; + } + } + return true; + } + +}; + +TEST_P(FrozenKeyIdxBiMapGeneralSuite, IdxFromKey_ContainedKey) { + EXPECT_EQ( + grackle::impl::FrozenKeyIdxBiMap_idx_from_key(bimap_p, "density"), + 1 + ); + EXPECT_EQ( + grackle::impl::FrozenKeyIdxBiMap_idx_from_key(bimap_p, "internal_energy"), + 0 + ); + EXPECT_EQ( + grackle::impl::FrozenKeyIdxBiMap_idx_from_key(bimap_p, "metal_density"), + 2 + ); +} + +TEST_P(FrozenKeyIdxBiMapGeneralSuite, IdxFromKey_AbsentKey) { + EXPECT_EQ( + grackle::impl::FrozenKeyIdxBiMap_idx_from_key(bimap_p, "notAKey"), + STRU16MAP_INVALID_VAL + ); +} + +TEST_P(FrozenKeyIdxBiMapGeneralSuite, IdxFromKey_AbsentIrregularKeys) { + EXPECT_EQ( + grackle::impl::FrozenKeyIdxBiMap_idx_from_key(bimap_p, ""), + STRU16MAP_INVALID_VAL + ); + + std::string key(STRU16MAP_KEYLEN_MAX+1, 'A'); + EXPECT_EQ( + grackle::impl::FrozenKeyIdxBiMap_idx_from_key(bimap_p, key.data()), + STRU16MAP_INVALID_VAL + ); +} + +TEST_P(FrozenKeyIdxBiMapGeneralSuite, KeyFromIdx_InvalidIdx) { + EXPECT_EQ(grackle::impl::FrozenKeyIdxBiMap_key_from_idx(bimap_p, 3), nullptr); + EXPECT_EQ( + grackle::impl::FrozenKeyIdxBiMap_key_from_idx(bimap_p, + STRU16MAP_INVALID_VAL), + nullptr + ); +} + +TEST_P(FrozenKeyIdxBiMapGeneralSuite, KeyFromIdx_ValidIdx) { + EXPECT_EQ( + std::string(grackle::impl::FrozenKeyIdxBiMap_key_from_idx(bimap_p, 2)), + std::string("metal_density") + ); + EXPECT_EQ( + std::string(grackle::impl::FrozenKeyIdxBiMap_key_from_idx(bimap_p, 1)), + std::string("density") + ); + EXPECT_EQ( + std::string(grackle::impl::FrozenKeyIdxBiMap_key_from_idx(bimap_p, 0)), + std::string("internal_energy") + ); + + // check whether the bimap is using pointers to the keys used during init + if (GetParam() == grackle::impl::BiMapMode::REFS_KEYDATA) { + EXPECT_TRUE(ReusesOriginalKeyPtrs(bimap_p)); + } else { + EXPECT_FALSE(ReusesOriginalKeyPtrs(bimap_p)); + } +} + +TEST_P(FrozenKeyIdxBiMapGeneralSuite, Clone) { + grackle::impl::FrozenKeyIdxBiMap* clone_p = nullptr; + EXPECT_EQ( + grackle::impl::FrozenKeyIdxBiMap_clone(&clone_p, bimap_p), + GR_SUCCESS + ); + ASSERT_NE(clone_p, nullptr); + + // for the sake of robustly checking everything, we delete bimap_p + grackle::impl::drop_FrozenKeyIdxBiMap(bimap_p); + bimap_p = nullptr; + + EXPECT_EQ( + grackle::impl::FrozenKeyIdxBiMap_idx_from_key(clone_p, "internal_energy"), + 0 + ); + EXPECT_EQ( + grackle::impl::FrozenKeyIdxBiMap_idx_from_key(clone_p, "notAKey"), + STRU16MAP_INVALID_VAL + ); + + EXPECT_EQ( + grackle::impl::FrozenKeyIdxBiMap_key_from_idx(clone_p, 3), + nullptr + ); + EXPECT_EQ( + std::string(grackle::impl::FrozenKeyIdxBiMap_key_from_idx(clone_p, 1)), + std::string("density") + ); + + // check whether the clone is using pointers to the keys used during init + if (GetParam() == grackle::impl::BiMapMode::REFS_KEYDATA) { + EXPECT_TRUE(ReusesOriginalKeyPtrs(clone_p)); + } else { + EXPECT_FALSE(ReusesOriginalKeyPtrs(clone_p)); + } + + // finally, cleanup the clone + grackle::impl::drop_FrozenKeyIdxBiMap(clone_p); +} + + +INSTANTIATE_TEST_SUITE_P( + , /* <- leaving Instantiation name empty */ + FrozenKeyIdxBiMapGeneralSuite, + testing::Values(grackle::impl::BiMapMode::REFS_KEYDATA, + grackle::impl::BiMapMode::COPIES_KEYDATA), + [](const testing::TestParamInfo& info){ + if (info.param == grackle::impl::BiMapMode::REFS_KEYDATA) { + return std::string("BIMAP_REFS_KEYDATA"); + } else { + return std::string("BIMAP_COPIES_KEYDATA"); + } + } +); From cdecbb5222583ef7cf0b6f18d2ea8b1cf59f2a8d Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 19 Nov 2025 09:18:30 -0500 Subject: [PATCH 002/175] address clang-tidy issues --- .clang-tidy | 1 - tests/unit/test_unit_FrozenKeyIdxBiMap.cpp | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 34b430c8a..fc03db36d 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -84,7 +84,6 @@ Checks: > readability-reference-to-constructed-temporary, readability-simplify-boolean-expr, readability-simplify-subscript-expr, - readability-static-accessed-through-instance, readability-string-compare, readability-uniqueptr-delete-release, diff --git a/tests/unit/test_unit_FrozenKeyIdxBiMap.cpp b/tests/unit/test_unit_FrozenKeyIdxBiMap.cpp index 83aabc0ca..b645b3e50 100644 --- a/tests/unit/test_unit_FrozenKeyIdxBiMap.cpp +++ b/tests/unit/test_unit_FrozenKeyIdxBiMap.cpp @@ -139,7 +139,7 @@ class FrozenKeyIdxBiMapGeneralSuite : }; -TEST_P(FrozenKeyIdxBiMapGeneralSuite, IdxFromKey_ContainedKey) { +TEST_P(FrozenKeyIdxBiMapGeneralSuite, IdxFromKeyContainedKey) { EXPECT_EQ( grackle::impl::FrozenKeyIdxBiMap_idx_from_key(bimap_p, "density"), 1 @@ -154,14 +154,14 @@ TEST_P(FrozenKeyIdxBiMapGeneralSuite, IdxFromKey_ContainedKey) { ); } -TEST_P(FrozenKeyIdxBiMapGeneralSuite, IdxFromKey_AbsentKey) { +TEST_P(FrozenKeyIdxBiMapGeneralSuite, IdxFromKeyAbsentKey) { EXPECT_EQ( grackle::impl::FrozenKeyIdxBiMap_idx_from_key(bimap_p, "notAKey"), STRU16MAP_INVALID_VAL ); } -TEST_P(FrozenKeyIdxBiMapGeneralSuite, IdxFromKey_AbsentIrregularKeys) { +TEST_P(FrozenKeyIdxBiMapGeneralSuite, IdxFromKeyAbsentIrregularKeys) { EXPECT_EQ( grackle::impl::FrozenKeyIdxBiMap_idx_from_key(bimap_p, ""), STRU16MAP_INVALID_VAL @@ -174,7 +174,7 @@ TEST_P(FrozenKeyIdxBiMapGeneralSuite, IdxFromKey_AbsentIrregularKeys) { ); } -TEST_P(FrozenKeyIdxBiMapGeneralSuite, KeyFromIdx_InvalidIdx) { +TEST_P(FrozenKeyIdxBiMapGeneralSuite, KeyFromIdxInvalidIdx) { EXPECT_EQ(grackle::impl::FrozenKeyIdxBiMap_key_from_idx(bimap_p, 3), nullptr); EXPECT_EQ( grackle::impl::FrozenKeyIdxBiMap_key_from_idx(bimap_p, @@ -183,7 +183,7 @@ TEST_P(FrozenKeyIdxBiMapGeneralSuite, KeyFromIdx_InvalidIdx) { ); } -TEST_P(FrozenKeyIdxBiMapGeneralSuite, KeyFromIdx_ValidIdx) { +TEST_P(FrozenKeyIdxBiMapGeneralSuite, KeyFromIdxValidIdx) { EXPECT_EQ( std::string(grackle::impl::FrozenKeyIdxBiMap_key_from_idx(bimap_p, 2)), std::string("metal_density") From ce3c40471e71f14f58bed610ab552f20ea3a9ab5 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 19 Nov 2025 09:25:08 -0500 Subject: [PATCH 003/175] a few minor tweaks --- src/clib/utils/FrozenKeyIdxBiMap.hpp | 3 +++ tests/unit/test_unit_FrozenKeyIdxBiMap.cpp | 18 +++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/clib/utils/FrozenKeyIdxBiMap.hpp b/src/clib/utils/FrozenKeyIdxBiMap.hpp index 7bf0b2772..093be15e5 100644 --- a/src/clib/utils/FrozenKeyIdxBiMap.hpp +++ b/src/clib/utils/FrozenKeyIdxBiMap.hpp @@ -15,6 +15,9 @@ /// simplistic at the cost of speed). PR #270 introduce a drop-in replacement /// that maintains the exact same API /// +/// If we decide to more fully embrace C++, it would make a lot of sense to +/// convert this to a full-blown class. +/// //===----------------------------------------------------------------------===// #ifndef UTILS_FROZENKEYIDXBIMAP_HPP #define UTILS_FROZENKEYIDXBIMAP_HPP diff --git a/tests/unit/test_unit_FrozenKeyIdxBiMap.cpp b/tests/unit/test_unit_FrozenKeyIdxBiMap.cpp index b645b3e50..94a977e9d 100644 --- a/tests/unit/test_unit_FrozenKeyIdxBiMap.cpp +++ b/tests/unit/test_unit_FrozenKeyIdxBiMap.cpp @@ -38,7 +38,7 @@ TEST_P(FrozenKeyIdxBiMapConstructorSuite, LongKey) { grackle::impl::FrozenKeyIdxBiMap* tmp = nullptr; const char* first_key = "density"; - std::string long_key(STRU16MAP_KEYLEN_MAX, 'A'); + std::string long_key(grackle::impl::bimap::keylen_max, 'A'); const char* keys[2] = {first_key, long_key.data()}; EXPECT_EQ(new_FrozenKeyIdxBiMap(&tmp, keys, 2, GetParam()), GR_SUCCESS); ASSERT_NE(tmp, nullptr); @@ -49,7 +49,7 @@ TEST_P(FrozenKeyIdxBiMapConstructorSuite, TooLongKey) { grackle::impl::FrozenKeyIdxBiMap* tmp = nullptr; const char* first_key = "density"; - std::string long_key(STRU16MAP_KEYLEN_MAX+1, 'A'); + std::string long_key(grackle::impl::bimap::keylen_max+1, 'A'); const char* keys[2] = {first_key, long_key.data()}; EXPECT_NE(new_FrozenKeyIdxBiMap(&tmp, keys, 2, GetParam()), GR_SUCCESS); ASSERT_EQ(tmp, nullptr); @@ -157,28 +157,28 @@ TEST_P(FrozenKeyIdxBiMapGeneralSuite, IdxFromKeyContainedKey) { TEST_P(FrozenKeyIdxBiMapGeneralSuite, IdxFromKeyAbsentKey) { EXPECT_EQ( grackle::impl::FrozenKeyIdxBiMap_idx_from_key(bimap_p, "notAKey"), - STRU16MAP_INVALID_VAL + grackle::impl::bimap::invalid_val ); } TEST_P(FrozenKeyIdxBiMapGeneralSuite, IdxFromKeyAbsentIrregularKeys) { EXPECT_EQ( grackle::impl::FrozenKeyIdxBiMap_idx_from_key(bimap_p, ""), - STRU16MAP_INVALID_VAL + grackle::impl::bimap::invalid_val ); - std::string key(STRU16MAP_KEYLEN_MAX+1, 'A'); + std::string key(grackle::impl::bimap::keylen_max+1, 'A'); EXPECT_EQ( grackle::impl::FrozenKeyIdxBiMap_idx_from_key(bimap_p, key.data()), - STRU16MAP_INVALID_VAL + grackle::impl::bimap::invalid_val ); } TEST_P(FrozenKeyIdxBiMapGeneralSuite, KeyFromIdxInvalidIdx) { EXPECT_EQ(grackle::impl::FrozenKeyIdxBiMap_key_from_idx(bimap_p, 3), nullptr); EXPECT_EQ( - grackle::impl::FrozenKeyIdxBiMap_key_from_idx(bimap_p, - STRU16MAP_INVALID_VAL), + grackle::impl::FrozenKeyIdxBiMap_key_from_idx( + bimap_p, grackle::impl::bimap::invalid_val), nullptr ); } @@ -223,7 +223,7 @@ TEST_P(FrozenKeyIdxBiMapGeneralSuite, Clone) { ); EXPECT_EQ( grackle::impl::FrozenKeyIdxBiMap_idx_from_key(clone_p, "notAKey"), - STRU16MAP_INVALID_VAL + grackle::impl::bimap::invalid_val ); EXPECT_EQ( From 660431f6aeecedf733365ae790b3d50a252f7cdd Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 19 Nov 2025 10:46:05 -0500 Subject: [PATCH 004/175] Refactor for consistency with other internal types There is some unforunate consequences, but if we don't do this you end up with some pretty confusing looking code... (the confusion primarily arises if new_FrozenKeyIdxBiMap or drop_FrozenKeyIdxBiMap has different behavior from other functions with similar names). I really think it would be better to make this into a simple C++ class with a constructor and destructor, but thats a topic for another time --- src/clib/utils/FrozenKeyIdxBiMap.hpp | 73 +++++++++++++++------- tests/unit/test_unit_FrozenKeyIdxBiMap.cpp | 73 +++++++++++----------- 2 files changed, 88 insertions(+), 58 deletions(-) diff --git a/src/clib/utils/FrozenKeyIdxBiMap.hpp b/src/clib/utils/FrozenKeyIdxBiMap.hpp index 093be15e5..a7eb21a37 100644 --- a/src/clib/utils/FrozenKeyIdxBiMap.hpp +++ b/src/clib/utils/FrozenKeyIdxBiMap.hpp @@ -12,11 +12,14 @@ /// bookkeeping. /// /// The underlying implementation of this type is *highly* suboptimal (it's -/// simplistic at the cost of speed). PR #270 introduce a drop-in replacement -/// that maintains the exact same API +/// simplistic at the cost of speed). PR #270 introduce a replacement that +/// maintains almost the exact same API (the new_FrozenKeyIdxBiMap, +/// FrozenKeyIdxBiMap_clone, and drop_FrozenKeyIdxBiMap functions will need to +/// be tweaked) /// -/// If we decide to more fully embrace C++, it would make a lot of sense to -/// convert this to a full-blown class. +/// If we decide to more fully embrace C++, it would make a LOT of sense to +/// convert this to a full-blown class (and delete copy constructor/copy +/// assignement OR adopt reference counting). /// //===----------------------------------------------------------------------===// #ifndef UTILS_FROZENKEYIDXBIMAP_HPP @@ -105,40 +108,51 @@ struct FrozenKeyIdxBiMap{ /// Constructs a new FrozenKeyIdxBiMap /// -/// @param[out] out Pointer where the allocated type is stored /// @param[in] keys Sequence of 1 or more unique strings. Each string must /// include at least 1 non-null character and be null-terminated /// @param[in] key_count The length of keys /// @param[in] mode specifies handling of keys. This will be passed on to any /// clones that are made. -inline int new_FrozenKeyIdxBiMap( - FrozenKeyIdxBiMap** out, const char* keys[], int key_count, - BiMapMode mode +/// +/// > [!note] +/// > If this function returns `bimap`, then the caller should invoke +/// > `FrozenKeyIdxBiMap_is_ok(&bimap)` to test whether there was an error. +/// > This is pretty ugly/clunky, but its the only practical way to achieve +/// > comparable behavior to other internal datatypes (ideally, we would make +/// > this a simple C++ class instead) +inline FrozenKeyIdxBiMap new_FrozenKeyIdxBiMap( + const char* keys[], int key_count, BiMapMode mode ) { + // this will be returned if there is an error + FrozenKeyIdxBiMap erroneous_obj{0, nullptr, BiMapMode::REFS_KEYDATA}; // check the specified keys long long max_keys = static_cast(bimap::invalid_val) - 1LL; if (key_count < 1 || static_cast(key_count) > max_keys) { - return GrPrintAndReturnErr( + GrPrintErrMsg( "key_count must be positive and cannot exceed %lld", max_keys ); + return erroneous_obj; } else if (keys == nullptr) { - return GrPrintAndReturnErr("keys must not be a nullptr"); + GrPrintErrMsg("keys must not be a nullptr"); + return erroneous_obj; } for (int i = 0; i < key_count; i++) { GR_INTERNAL_REQUIRE(keys[i] != nullptr, "Can't specify a nullptr key"); std::size_t n_chrs_without_nul = std::strlen(keys[i]); if (n_chrs_without_nul == 0 || n_chrs_without_nul > bimap::keylen_max) { - return GrPrintAndReturnErr( + GrPrintErrMsg( "calling strlen on \"%s\", the key @ index %d, yields 0 or a length " "exceeding %d", keys[i], i, bimap::keylen_max ); + return erroneous_obj; } // check uniqueness for (int j = 0; j < i; j++) { if (strcmp(keys[i], keys[j]) == 0) { - return GrPrintAndReturnErr("\"%s\" key repeats", keys[i]); + GrPrintErrMsg("\"%s\" key repeats", keys[i]); + return erroneous_obj; } } } @@ -163,14 +177,22 @@ inline int new_FrozenKeyIdxBiMap( out_keys = (const char**)tmp_keys; break; } - default: return GrPrintAndReturnErr("unknown mode"); + default: { + GrPrintErrMsg("unknown mode"); + return erroneous_obj; + } } - (*out) = new FrozenKeyIdxBiMap; - (*out)->length = key_count; - (*out)->keys = out_keys; + return FrozenKeyIdxBiMap{ + /* length = */ key_count, + /* keys = */ out_keys, + /* mode = */ mode + }; +} - return GR_SUCCESS; +/// returns whether new_FrozenKeyIdxBiMap constructed a valid object +inline bool FrozenKeyIdxBiMap_is_ok(FrozenKeyIdxBiMap* ptr) { + return (ptr->length > 0); } /// Destroys the specified FrozenKeyIdxBiMap @@ -180,16 +202,23 @@ inline void drop_FrozenKeyIdxBiMap(FrozenKeyIdxBiMap* ptr) { delete[] ptr->keys[i]; } } - delete[] ptr->keys; - delete ptr; + if (ptr->keys != nullptr) { + delete[] ptr->keys; + } } /// Makes a clone of the specified FrozenKeyIdxBiMap (the clone inherites the /// original BiMapMode). -int FrozenKeyIdxBiMap_clone(FrozenKeyIdxBiMap** out, - const FrozenKeyIdxBiMap* ptr) { - return new_FrozenKeyIdxBiMap(out, ptr->keys, ptr->length, ptr->mode); +/// +/// > [!note] +/// > If this function returns `bimap`, then the caller should invoke +/// > `FrozenKeyIdxBiMap_is_ok(&bimap)` to test whether there was an error. +/// > This is pretty ugly/clunky, but its the only practical way to achieve +/// > comparable behavior to other internal datatypes (ideally, we would make +/// > this a simple C++ class instead) +FrozenKeyIdxBiMap FrozenKeyIdxBiMap_clone(const FrozenKeyIdxBiMap* ptr) { + return new_FrozenKeyIdxBiMap(ptr->keys, ptr->length, ptr->mode); }; /// returns the value associated with the key or (if the key can't be found) diff --git a/tests/unit/test_unit_FrozenKeyIdxBiMap.cpp b/tests/unit/test_unit_FrozenKeyIdxBiMap.cpp index 94a977e9d..8bfe41a68 100644 --- a/tests/unit/test_unit_FrozenKeyIdxBiMap.cpp +++ b/tests/unit/test_unit_FrozenKeyIdxBiMap.cpp @@ -26,49 +26,49 @@ class FrozenKeyIdxBiMapConstructorSuite : }; TEST_P(FrozenKeyIdxBiMapConstructorSuite, Simple) { - grackle::impl::FrozenKeyIdxBiMap* tmp = nullptr; const char* keys[] = {"denisty", "internal_energy"}; - EXPECT_EQ(new_FrozenKeyIdxBiMap(&tmp, keys, 2, GetParam()), GR_SUCCESS); - ASSERT_NE(tmp, nullptr); - grackle::impl::drop_FrozenKeyIdxBiMap(tmp); + grackle::impl::FrozenKeyIdxBiMap tmp + = grackle::impl::new_FrozenKeyIdxBiMap(keys, 2, GetParam()); + + EXPECT_TRUE(grackle::impl::FrozenKeyIdxBiMap_is_ok(&tmp)); + grackle::impl::drop_FrozenKeyIdxBiMap(&tmp); } TEST_P(FrozenKeyIdxBiMapConstructorSuite, LongKey) { - grackle::impl::FrozenKeyIdxBiMap* tmp = nullptr; - const char* first_key = "density"; std::string long_key(grackle::impl::bimap::keylen_max, 'A'); const char* keys[2] = {first_key, long_key.data()}; - EXPECT_EQ(new_FrozenKeyIdxBiMap(&tmp, keys, 2, GetParam()), GR_SUCCESS); - ASSERT_NE(tmp, nullptr); - grackle::impl::drop_FrozenKeyIdxBiMap(tmp); + + grackle::impl::FrozenKeyIdxBiMap tmp + = grackle::impl::new_FrozenKeyIdxBiMap(keys, 2, GetParam()); + + ASSERT_TRUE(grackle::impl::FrozenKeyIdxBiMap_is_ok(&tmp)); + grackle::impl::drop_FrozenKeyIdxBiMap(&tmp); } TEST_P(FrozenKeyIdxBiMapConstructorSuite, TooLongKey) { - grackle::impl::FrozenKeyIdxBiMap* tmp = nullptr; - const char* first_key = "density"; std::string long_key(grackle::impl::bimap::keylen_max+1, 'A'); const char* keys[2] = {first_key, long_key.data()}; - EXPECT_NE(new_FrozenKeyIdxBiMap(&tmp, keys, 2, GetParam()), GR_SUCCESS); - ASSERT_EQ(tmp, nullptr); + + grackle::impl::FrozenKeyIdxBiMap tmp + = grackle::impl::new_FrozenKeyIdxBiMap(keys, 2, GetParam()); + ASSERT_FALSE(grackle::impl::FrozenKeyIdxBiMap_is_ok(&tmp)); } TEST_P(FrozenKeyIdxBiMapConstructorSuite, 0LenKey) { - grackle::impl::FrozenKeyIdxBiMap* tmp = nullptr; - const char* keys[2] = {"density",""}; - EXPECT_NE(new_FrozenKeyIdxBiMap(&tmp, keys, 2, GetParam()), GR_SUCCESS); - ASSERT_EQ(tmp, nullptr); + grackle::impl::FrozenKeyIdxBiMap tmp + = grackle::impl::new_FrozenKeyIdxBiMap(keys, 2, GetParam()); + ASSERT_FALSE(grackle::impl::FrozenKeyIdxBiMap_is_ok(&tmp)); } TEST_P(FrozenKeyIdxBiMapConstructorSuite, NoKeys) { - grackle::impl::FrozenKeyIdxBiMap* tmp = nullptr; - EXPECT_NE(new_FrozenKeyIdxBiMap(&tmp, nullptr, 0, GetParam()), GR_SUCCESS); - ASSERT_EQ(tmp, nullptr); // if this fails, we'll leak memory (but not much - // can be done) + grackle::impl::FrozenKeyIdxBiMap tmp + = grackle::impl::new_FrozenKeyIdxBiMap(nullptr, 0, GetParam()); + ASSERT_FALSE(grackle::impl::FrozenKeyIdxBiMap_is_ok(&tmp)); } INSTANTIATE_TEST_SUITE_P( @@ -86,9 +86,8 @@ INSTANTIATE_TEST_SUITE_P( /// helper function to initialize a map from a vector -int new_FrozenKeyIdxBiMap(grackle::impl::FrozenKeyIdxBiMap** out, - const std::vector& vec_, - grackle::impl::BiMapMode mode) +grackle::impl::FrozenKeyIdxBiMap new_FrozenKeyIdxBiMap( + const std::vector& vec_, grackle::impl::BiMapMode mode) { std::size_t key_count = vec_.size(); @@ -98,7 +97,7 @@ int new_FrozenKeyIdxBiMap(grackle::impl::FrozenKeyIdxBiMap** out, key_ptr_l[i] = vec_[i].c_str(); } - return new_FrozenKeyIdxBiMap(out, key_ptr_l.data(), key_count, mode); + return new_FrozenKeyIdxBiMap(key_ptr_l.data(), key_count, mode); } class FrozenKeyIdxBiMapGeneralSuite : @@ -116,15 +115,19 @@ class FrozenKeyIdxBiMapGeneralSuite : }; grackle::impl::BiMapMode mode = this->GetParam(); - ASSERT_EQ( - new_FrozenKeyIdxBiMap(&this->bimap_p, ordered_keys, mode), - GR_SUCCESS - ); + grackle::impl::FrozenKeyIdxBiMap tmp + = new_FrozenKeyIdxBiMap(ordered_keys, mode); + ASSERT_TRUE(grackle::impl::FrozenKeyIdxBiMap_is_ok(&tmp)); + bimap_p = new grackle::impl::FrozenKeyIdxBiMap; + (*bimap_p) = tmp; } void TearDown() override { - if (bimap_p != nullptr) { grackle::impl::drop_FrozenKeyIdxBiMap(bimap_p); } + if (bimap_p != nullptr) { + grackle::impl::drop_FrozenKeyIdxBiMap(bimap_p); + delete bimap_p; + } } bool ReusesOriginalKeyPtrs(const grackle::impl::FrozenKeyIdxBiMap* p) const { @@ -206,12 +209,10 @@ TEST_P(FrozenKeyIdxBiMapGeneralSuite, KeyFromIdxValidIdx) { } TEST_P(FrozenKeyIdxBiMapGeneralSuite, Clone) { - grackle::impl::FrozenKeyIdxBiMap* clone_p = nullptr; - EXPECT_EQ( - grackle::impl::FrozenKeyIdxBiMap_clone(&clone_p, bimap_p), - GR_SUCCESS - ); - ASSERT_NE(clone_p, nullptr); + grackle::impl::FrozenKeyIdxBiMap clone = + grackle::impl::FrozenKeyIdxBiMap_clone(bimap_p); + ASSERT_TRUE(grackle::impl::FrozenKeyIdxBiMap_is_ok(&clone)); + grackle::impl::FrozenKeyIdxBiMap* clone_p = &clone; // for the sake of robustly checking everything, we delete bimap_p grackle::impl::drop_FrozenKeyIdxBiMap(bimap_p); From 1f42941e364f142eb27ade9ad9e88d29ff7c897c Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 19 Nov 2025 10:51:08 -0500 Subject: [PATCH 005/175] restore clang-tidy setting from a few commits back --- .clang-tidy | 1 + tests/unit/test_unit_FrozenKeyIdxBiMap.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.clang-tidy b/.clang-tidy index fc03db36d..34b430c8a 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -84,6 +84,7 @@ Checks: > readability-reference-to-constructed-temporary, readability-simplify-boolean-expr, readability-simplify-subscript-expr, + readability-static-accessed-through-instance, readability-string-compare, readability-uniqueptr-delete-release, diff --git a/tests/unit/test_unit_FrozenKeyIdxBiMap.cpp b/tests/unit/test_unit_FrozenKeyIdxBiMap.cpp index 8bfe41a68..dfff5ba99 100644 --- a/tests/unit/test_unit_FrozenKeyIdxBiMap.cpp +++ b/tests/unit/test_unit_FrozenKeyIdxBiMap.cpp @@ -114,7 +114,7 @@ class FrozenKeyIdxBiMapGeneralSuite : "internal_energy", "density", "metal_density" }; - grackle::impl::BiMapMode mode = this->GetParam(); + grackle::impl::BiMapMode mode = GetParam(); grackle::impl::FrozenKeyIdxBiMap tmp = new_FrozenKeyIdxBiMap(ordered_keys, mode); ASSERT_TRUE(grackle::impl::FrozenKeyIdxBiMap_is_ok(&tmp)); From a6aa793ff5c1eb81d827e5dda4924d5df70ad0ed Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 19 Nov 2025 10:53:21 -0500 Subject: [PATCH 006/175] apply clang-format --- src/clib/utils/FrozenKeyIdxBiMap.hpp | 55 +++---- tests/unit/test_unit_FrozenKeyIdxBiMap.cpp | 181 +++++++++------------ 2 files changed, 99 insertions(+), 137 deletions(-) diff --git a/src/clib/utils/FrozenKeyIdxBiMap.hpp b/src/clib/utils/FrozenKeyIdxBiMap.hpp index a7eb21a37..c884c9bbf 100644 --- a/src/clib/utils/FrozenKeyIdxBiMap.hpp +++ b/src/clib/utils/FrozenKeyIdxBiMap.hpp @@ -43,7 +43,7 @@ inline constexpr std::uint16_t invalid_val = /// specifies maximum allowed length of a key (excluding the null character). inline constexpr std::uint16_t keylen_max = 29; -} +} // namespace grackle::impl::bimap // these are just here for to make it easier for us to adopt changes from PR // #270 (then we can delete these macros) @@ -52,10 +52,7 @@ inline constexpr std::uint16_t keylen_max = 29; namespace grackle::impl { -enum class BiMapMode { - REFS_KEYDATA = 0, - COPIES_KEYDATA = 1 -}; +enum class BiMapMode { REFS_KEYDATA = 0, COPIES_KEYDATA = 1 }; /// @brief This is a bidirectional map (bimap). It is specialized to map `n` /// unique string keys to unique indexes with values of `0` through `n-1` and @@ -94,7 +91,7 @@ enum class BiMapMode { /// > The contents of this struct should be considered an implementation /// > detail! Always prefer the associated functions (they are defined in such /// > a way that they should be inlined -struct FrozenKeyIdxBiMap{ +struct FrozenKeyIdxBiMap { // don't forget to update FrozenKeyIdxBiMap_clone when changing members /// the number of contained strings @@ -120,18 +117,16 @@ struct FrozenKeyIdxBiMap{ /// > This is pretty ugly/clunky, but its the only practical way to achieve /// > comparable behavior to other internal datatypes (ideally, we would make /// > this a simple C++ class instead) -inline FrozenKeyIdxBiMap new_FrozenKeyIdxBiMap( - const char* keys[], int key_count, BiMapMode mode -) { +inline FrozenKeyIdxBiMap new_FrozenKeyIdxBiMap(const char* keys[], + int key_count, BiMapMode mode) { // this will be returned if there is an error FrozenKeyIdxBiMap erroneous_obj{0, nullptr, BiMapMode::REFS_KEYDATA}; // check the specified keys long long max_keys = static_cast(bimap::invalid_val) - 1LL; if (key_count < 1 || static_cast(key_count) > max_keys) { - GrPrintErrMsg( - "key_count must be positive and cannot exceed %lld", max_keys - ); + GrPrintErrMsg("key_count must be positive and cannot exceed %lld", + max_keys); return erroneous_obj; } else if (keys == nullptr) { GrPrintErrMsg("keys must not be a nullptr"); @@ -142,10 +137,9 @@ inline FrozenKeyIdxBiMap new_FrozenKeyIdxBiMap( std::size_t n_chrs_without_nul = std::strlen(keys[i]); if (n_chrs_without_nul == 0 || n_chrs_without_nul > bimap::keylen_max) { GrPrintErrMsg( - "calling strlen on \"%s\", the key @ index %d, yields 0 or a length " - "exceeding %d", - keys[i], i, bimap::keylen_max - ); + "calling strlen on \"%s\", the key @ index %d, yields 0 or a length " + "exceeding %d", + keys[i], i, bimap::keylen_max); return erroneous_obj; } // check uniqueness @@ -183,11 +177,9 @@ inline FrozenKeyIdxBiMap new_FrozenKeyIdxBiMap( } } - return FrozenKeyIdxBiMap{ - /* length = */ key_count, - /* keys = */ out_keys, - /* mode = */ mode - }; + return FrozenKeyIdxBiMap{/* length = */ key_count, + /* keys = */ out_keys, + /* mode = */ mode}; } /// returns whether new_FrozenKeyIdxBiMap constructed a valid object @@ -207,7 +199,6 @@ inline void drop_FrozenKeyIdxBiMap(FrozenKeyIdxBiMap* ptr) { } } - /// Makes a clone of the specified FrozenKeyIdxBiMap (the clone inherites the /// original BiMapMode). /// @@ -224,9 +215,7 @@ FrozenKeyIdxBiMap FrozenKeyIdxBiMap_clone(const FrozenKeyIdxBiMap* ptr) { /// returns the value associated with the key or (if the key can't be found) /// @ref grackle::impl::bimap::invalid_val inline std::uint16_t FrozenKeyIdxBiMap_idx_from_key( - const FrozenKeyIdxBiMap* map, const char* key -) -{ + const FrozenKeyIdxBiMap* map, const char* key) { GR_INTERNAL_REQUIRE(key != nullptr, "A nullptr key is forbidden"); for (int i = 0; i < map->length; i++) { if (std::strcmp(map->keys[i], key) == 0) { @@ -242,15 +231,17 @@ inline int FrozenKeyIdxBiMap_contains(const FrozenKeyIdxBiMap* map, return FrozenKeyIdxBiMap_idx_from_key(map, key) != bimap::invalid_val; } -inline int FrozenKeyIdxBiMap_size(const FrozenKeyIdxBiMap* map) -{ return map->length; } +inline int FrozenKeyIdxBiMap_size(const FrozenKeyIdxBiMap* map) { + return map->length; +} /// Return the ith key (this is effectively a reverse lookup) -inline const char* FrozenKeyIdxBiMap_key_from_idx( - const FrozenKeyIdxBiMap* map, std::uint16_t i -) { - if (i >= map->length) { return nullptr; } - return map->keys[i]; // this can't be a nullptr +inline const char* FrozenKeyIdxBiMap_key_from_idx(const FrozenKeyIdxBiMap* map, + std::uint16_t i) { + if (i >= map->length) { + return nullptr; + } + return map->keys[i]; // this can't be a nullptr } } // namespace grackle::impl diff --git a/tests/unit/test_unit_FrozenKeyIdxBiMap.cpp b/tests/unit/test_unit_FrozenKeyIdxBiMap.cpp index dfff5ba99..61e45cf60 100644 --- a/tests/unit/test_unit_FrozenKeyIdxBiMap.cpp +++ b/tests/unit/test_unit_FrozenKeyIdxBiMap.cpp @@ -17,19 +17,18 @@ #include "utils/FrozenKeyIdxBiMap.hpp" #include "grackle.h" -class FrozenKeyIdxBiMapConstructorSuite : - public testing::TestWithParam { +class FrozenKeyIdxBiMapConstructorSuite + : public testing::TestWithParam { // You can implement all the usual fixture class members here. // To access the test parameter, call GetParam() from class // TestWithParam. - }; TEST_P(FrozenKeyIdxBiMapConstructorSuite, Simple) { const char* keys[] = {"denisty", "internal_energy"}; - grackle::impl::FrozenKeyIdxBiMap tmp - = grackle::impl::new_FrozenKeyIdxBiMap(keys, 2, GetParam()); + grackle::impl::FrozenKeyIdxBiMap tmp = + grackle::impl::new_FrozenKeyIdxBiMap(keys, 2, GetParam()); EXPECT_TRUE(grackle::impl::FrozenKeyIdxBiMap_is_ok(&tmp)); grackle::impl::drop_FrozenKeyIdxBiMap(&tmp); @@ -40,8 +39,8 @@ TEST_P(FrozenKeyIdxBiMapConstructorSuite, LongKey) { std::string long_key(grackle::impl::bimap::keylen_max, 'A'); const char* keys[2] = {first_key, long_key.data()}; - grackle::impl::FrozenKeyIdxBiMap tmp - = grackle::impl::new_FrozenKeyIdxBiMap(keys, 2, GetParam()); + grackle::impl::FrozenKeyIdxBiMap tmp = + grackle::impl::new_FrozenKeyIdxBiMap(keys, 2, GetParam()); ASSERT_TRUE(grackle::impl::FrozenKeyIdxBiMap_is_ok(&tmp)); grackle::impl::drop_FrozenKeyIdxBiMap(&tmp); @@ -49,46 +48,44 @@ TEST_P(FrozenKeyIdxBiMapConstructorSuite, LongKey) { TEST_P(FrozenKeyIdxBiMapConstructorSuite, TooLongKey) { const char* first_key = "density"; - std::string long_key(grackle::impl::bimap::keylen_max+1, 'A'); + std::string long_key(grackle::impl::bimap::keylen_max + 1, 'A'); const char* keys[2] = {first_key, long_key.data()}; - grackle::impl::FrozenKeyIdxBiMap tmp - = grackle::impl::new_FrozenKeyIdxBiMap(keys, 2, GetParam()); + grackle::impl::FrozenKeyIdxBiMap tmp = + grackle::impl::new_FrozenKeyIdxBiMap(keys, 2, GetParam()); ASSERT_FALSE(grackle::impl::FrozenKeyIdxBiMap_is_ok(&tmp)); } TEST_P(FrozenKeyIdxBiMapConstructorSuite, 0LenKey) { - const char* keys[2] = {"density",""}; - grackle::impl::FrozenKeyIdxBiMap tmp - = grackle::impl::new_FrozenKeyIdxBiMap(keys, 2, GetParam()); + const char* keys[2] = {"density", ""}; + grackle::impl::FrozenKeyIdxBiMap tmp = + grackle::impl::new_FrozenKeyIdxBiMap(keys, 2, GetParam()); ASSERT_FALSE(grackle::impl::FrozenKeyIdxBiMap_is_ok(&tmp)); } TEST_P(FrozenKeyIdxBiMapConstructorSuite, NoKeys) { - - grackle::impl::FrozenKeyIdxBiMap tmp - = grackle::impl::new_FrozenKeyIdxBiMap(nullptr, 0, GetParam()); + grackle::impl::FrozenKeyIdxBiMap tmp = + grackle::impl::new_FrozenKeyIdxBiMap(nullptr, 0, GetParam()); ASSERT_FALSE(grackle::impl::FrozenKeyIdxBiMap_is_ok(&tmp)); } INSTANTIATE_TEST_SUITE_P( - , /* <- leaving Instantiation name empty */ - FrozenKeyIdxBiMapConstructorSuite, - testing::Values(grackle::impl::BiMapMode::REFS_KEYDATA, grackle::impl::BiMapMode::COPIES_KEYDATA), - [](const testing::TestParamInfo& info){ - if (info.param == grackle::impl::BiMapMode::REFS_KEYDATA) { - return std::string("BIMAP_REFS_KEYDATA"); - } else { - return std::string("BIMAP_COPIES_KEYDATA"); - } - } -); - + , /* <- leaving Instantiation name empty */ + FrozenKeyIdxBiMapConstructorSuite, + testing::Values(grackle::impl::BiMapMode::REFS_KEYDATA, + grackle::impl::BiMapMode::COPIES_KEYDATA), + [](const testing::TestParamInfo< + FrozenKeyIdxBiMapConstructorSuite::ParamType>& info) { + if (info.param == grackle::impl::BiMapMode::REFS_KEYDATA) { + return std::string("BIMAP_REFS_KEYDATA"); + } else { + return std::string("BIMAP_COPIES_KEYDATA"); + } + }); /// helper function to initialize a map from a vector grackle::impl::FrozenKeyIdxBiMap new_FrozenKeyIdxBiMap( - const std::vector& vec_, grackle::impl::BiMapMode mode) -{ + const std::vector& vec_, grackle::impl::BiMapMode mode) { std::size_t key_count = vec_.size(); // create a vector of pointers @@ -100,9 +97,8 @@ grackle::impl::FrozenKeyIdxBiMap new_FrozenKeyIdxBiMap( return new_FrozenKeyIdxBiMap(key_ptr_l.data(), key_count, mode); } -class FrozenKeyIdxBiMapGeneralSuite : - public testing::TestWithParam -{ +class FrozenKeyIdxBiMapGeneralSuite + : public testing::TestWithParam { protected: std::vector ordered_keys; grackle::impl::FrozenKeyIdxBiMap* bimap_p = nullptr; @@ -110,13 +106,12 @@ class FrozenKeyIdxBiMapGeneralSuite : // we use SetUp/Teardown instead of constructor and destructor so we can // perform some sanity checks with ASSERTIONs void SetUp() override { - ordered_keys = std::vector{ - "internal_energy", "density", "metal_density" - }; + ordered_keys = + std::vector{"internal_energy", "density", "metal_density"}; grackle::impl::BiMapMode mode = GetParam(); - grackle::impl::FrozenKeyIdxBiMap tmp - = new_FrozenKeyIdxBiMap(ordered_keys, mode); + grackle::impl::FrozenKeyIdxBiMap tmp = + new_FrozenKeyIdxBiMap(ordered_keys, mode); ASSERT_TRUE(grackle::impl::FrozenKeyIdxBiMap_is_ok(&tmp)); bimap_p = new grackle::impl::FrozenKeyIdxBiMap; @@ -139,66 +134,50 @@ class FrozenKeyIdxBiMapGeneralSuite : } return true; } - }; TEST_P(FrozenKeyIdxBiMapGeneralSuite, IdxFromKeyContainedKey) { + EXPECT_EQ(grackle::impl::FrozenKeyIdxBiMap_idx_from_key(bimap_p, "density"), + 1); EXPECT_EQ( - grackle::impl::FrozenKeyIdxBiMap_idx_from_key(bimap_p, "density"), - 1 - ); + grackle::impl::FrozenKeyIdxBiMap_idx_from_key(bimap_p, "internal_energy"), + 0); EXPECT_EQ( - grackle::impl::FrozenKeyIdxBiMap_idx_from_key(bimap_p, "internal_energy"), - 0 - ); - EXPECT_EQ( - grackle::impl::FrozenKeyIdxBiMap_idx_from_key(bimap_p, "metal_density"), - 2 - ); + grackle::impl::FrozenKeyIdxBiMap_idx_from_key(bimap_p, "metal_density"), + 2); } TEST_P(FrozenKeyIdxBiMapGeneralSuite, IdxFromKeyAbsentKey) { - EXPECT_EQ( - grackle::impl::FrozenKeyIdxBiMap_idx_from_key(bimap_p, "notAKey"), - grackle::impl::bimap::invalid_val - ); + EXPECT_EQ(grackle::impl::FrozenKeyIdxBiMap_idx_from_key(bimap_p, "notAKey"), + grackle::impl::bimap::invalid_val); } TEST_P(FrozenKeyIdxBiMapGeneralSuite, IdxFromKeyAbsentIrregularKeys) { - EXPECT_EQ( - grackle::impl::FrozenKeyIdxBiMap_idx_from_key(bimap_p, ""), - grackle::impl::bimap::invalid_val - ); + EXPECT_EQ(grackle::impl::FrozenKeyIdxBiMap_idx_from_key(bimap_p, ""), + grackle::impl::bimap::invalid_val); - std::string key(grackle::impl::bimap::keylen_max+1, 'A'); - EXPECT_EQ( - grackle::impl::FrozenKeyIdxBiMap_idx_from_key(bimap_p, key.data()), - grackle::impl::bimap::invalid_val - ); + std::string key(grackle::impl::bimap::keylen_max + 1, 'A'); + EXPECT_EQ(grackle::impl::FrozenKeyIdxBiMap_idx_from_key(bimap_p, key.data()), + grackle::impl::bimap::invalid_val); } TEST_P(FrozenKeyIdxBiMapGeneralSuite, KeyFromIdxInvalidIdx) { EXPECT_EQ(grackle::impl::FrozenKeyIdxBiMap_key_from_idx(bimap_p, 3), nullptr); - EXPECT_EQ( - grackle::impl::FrozenKeyIdxBiMap_key_from_idx( - bimap_p, grackle::impl::bimap::invalid_val), - nullptr - ); + EXPECT_EQ(grackle::impl::FrozenKeyIdxBiMap_key_from_idx( + bimap_p, grackle::impl::bimap::invalid_val), + nullptr); } TEST_P(FrozenKeyIdxBiMapGeneralSuite, KeyFromIdxValidIdx) { EXPECT_EQ( - std::string(grackle::impl::FrozenKeyIdxBiMap_key_from_idx(bimap_p, 2)), - std::string("metal_density") - ); + std::string(grackle::impl::FrozenKeyIdxBiMap_key_from_idx(bimap_p, 2)), + std::string("metal_density")); EXPECT_EQ( - std::string(grackle::impl::FrozenKeyIdxBiMap_key_from_idx(bimap_p, 1)), - std::string("density") - ); + std::string(grackle::impl::FrozenKeyIdxBiMap_key_from_idx(bimap_p, 1)), + std::string("density")); EXPECT_EQ( - std::string(grackle::impl::FrozenKeyIdxBiMap_key_from_idx(bimap_p, 0)), - std::string("internal_energy") - ); + std::string(grackle::impl::FrozenKeyIdxBiMap_key_from_idx(bimap_p, 0)), + std::string("internal_energy")); // check whether the bimap is using pointers to the keys used during init if (GetParam() == grackle::impl::BiMapMode::REFS_KEYDATA) { @@ -209,8 +188,8 @@ TEST_P(FrozenKeyIdxBiMapGeneralSuite, KeyFromIdxValidIdx) { } TEST_P(FrozenKeyIdxBiMapGeneralSuite, Clone) { - grackle::impl::FrozenKeyIdxBiMap clone = - grackle::impl::FrozenKeyIdxBiMap_clone(bimap_p); + grackle::impl::FrozenKeyIdxBiMap clone = + grackle::impl::FrozenKeyIdxBiMap_clone(bimap_p); ASSERT_TRUE(grackle::impl::FrozenKeyIdxBiMap_is_ok(&clone)); grackle::impl::FrozenKeyIdxBiMap* clone_p = &clone; @@ -219,22 +198,15 @@ TEST_P(FrozenKeyIdxBiMapGeneralSuite, Clone) { bimap_p = nullptr; EXPECT_EQ( - grackle::impl::FrozenKeyIdxBiMap_idx_from_key(clone_p, "internal_energy"), - 0 - ); - EXPECT_EQ( - grackle::impl::FrozenKeyIdxBiMap_idx_from_key(clone_p, "notAKey"), - grackle::impl::bimap::invalid_val - ); + grackle::impl::FrozenKeyIdxBiMap_idx_from_key(clone_p, "internal_energy"), + 0); + EXPECT_EQ(grackle::impl::FrozenKeyIdxBiMap_idx_from_key(clone_p, "notAKey"), + grackle::impl::bimap::invalid_val); + EXPECT_EQ(grackle::impl::FrozenKeyIdxBiMap_key_from_idx(clone_p, 3), nullptr); EXPECT_EQ( - grackle::impl::FrozenKeyIdxBiMap_key_from_idx(clone_p, 3), - nullptr - ); - EXPECT_EQ( - std::string(grackle::impl::FrozenKeyIdxBiMap_key_from_idx(clone_p, 1)), - std::string("density") - ); + std::string(grackle::impl::FrozenKeyIdxBiMap_key_from_idx(clone_p, 1)), + std::string("density")); // check whether the clone is using pointers to the keys used during init if (GetParam() == grackle::impl::BiMapMode::REFS_KEYDATA) { @@ -247,17 +219,16 @@ TEST_P(FrozenKeyIdxBiMapGeneralSuite, Clone) { grackle::impl::drop_FrozenKeyIdxBiMap(clone_p); } - INSTANTIATE_TEST_SUITE_P( - , /* <- leaving Instantiation name empty */ - FrozenKeyIdxBiMapGeneralSuite, - testing::Values(grackle::impl::BiMapMode::REFS_KEYDATA, - grackle::impl::BiMapMode::COPIES_KEYDATA), - [](const testing::TestParamInfo& info){ - if (info.param == grackle::impl::BiMapMode::REFS_KEYDATA) { - return std::string("BIMAP_REFS_KEYDATA"); - } else { - return std::string("BIMAP_COPIES_KEYDATA"); - } - } -); + , /* <- leaving Instantiation name empty */ + FrozenKeyIdxBiMapGeneralSuite, + testing::Values(grackle::impl::BiMapMode::REFS_KEYDATA, + grackle::impl::BiMapMode::COPIES_KEYDATA), + [](const testing::TestParamInfo& + info) { + if (info.param == grackle::impl::BiMapMode::REFS_KEYDATA) { + return std::string("BIMAP_REFS_KEYDATA"); + } else { + return std::string("BIMAP_COPIES_KEYDATA"); + } + }); From 19d4f7e64948cf1fbf6a9062a2aa66d28f4bb6c4 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 19 Nov 2025 12:31:00 -0500 Subject: [PATCH 007/175] a minor tweak to rerun CI --- src/clib/utils/FrozenKeyIdxBiMap.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/clib/utils/FrozenKeyIdxBiMap.hpp b/src/clib/utils/FrozenKeyIdxBiMap.hpp index c884c9bbf..a9537a5c0 100644 --- a/src/clib/utils/FrozenKeyIdxBiMap.hpp +++ b/src/clib/utils/FrozenKeyIdxBiMap.hpp @@ -18,8 +18,8 @@ /// be tweaked) /// /// If we decide to more fully embrace C++, it would make a LOT of sense to -/// convert this to a full-blown class (and delete copy constructor/copy -/// assignement OR adopt reference counting). +/// convert this to a full-blown class (we would probably delete the copy +/// constructor And copy assignement methods OR adopt reference counting). /// //===----------------------------------------------------------------------===// #ifndef UTILS_FROZENKEYIDXBIMAP_HPP From 9d2b9cf4dd94ae09d8bb7a78f25e464188b03e5b Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Mon, 8 Dec 2025 12:17:32 -0500 Subject: [PATCH 008/175] convert interp_table_utils.{h->hpp} --- .clang-format-ignore | 2 +- src/clib/CMakeLists.txt | 2 +- src/clib/init_misc_species_cool_rates.cpp | 2 +- src/clib/initialize_chemistry_data.cpp | 12 +++--- src/clib/interp_table_utils.h | 43 --------------------- src/clib/interp_table_utils.hpp | 46 +++++++++++++++++++++++ 6 files changed, 56 insertions(+), 51 deletions(-) delete mode 100644 src/clib/interp_table_utils.h create mode 100644 src/clib/interp_table_utils.hpp diff --git a/.clang-format-ignore b/.clang-format-ignore index ab4b6b6f1..4cda5afa3 100644 --- a/.clang-format-ignore +++ b/.clang-format-ignore @@ -36,7 +36,7 @@ src/clib/initialize_dust_yields.cpp src/clib/initialize_rates.cpp src/clib/internal_types.hpp src/clib/internal_units.h -src/clib/interp_table_utils.h +src/clib/interp_table_utils.hpp src/clib/interpolate.hpp src/clib/phys_constants.h src/clib/rate_functions.c diff --git a/src/clib/CMakeLists.txt b/src/clib/CMakeLists.txt index c9ae9f141..07734e2d6 100644 --- a/src/clib/CMakeLists.txt +++ b/src/clib/CMakeLists.txt @@ -118,6 +118,7 @@ add_library(Grackle_Grackle initialize_dust_yields.cpp initialize_dust_yields.hpp initialize_rates.cpp initialize_rates.hpp internal_types.cpp internal_types.hpp + interp_table_utils.hpp lookup_cool_rates1d.hpp make_consistent.cpp make_consistent.hpp opaque_storage.hpp @@ -173,7 +174,6 @@ add_library(Grackle_Grackle grackle_chemistry_data_fields.def # <-- acts as a C header grackle_macros.h index_helper.h - interp_table_utils.h phys_constants.h collisional_rxn_rate_members.def # <-- acts as a C header utils.h diff --git a/src/clib/init_misc_species_cool_rates.cpp b/src/clib/init_misc_species_cool_rates.cpp index 83e1dd9c4..90393711a 100644 --- a/src/clib/init_misc_species_cool_rates.cpp +++ b/src/clib/init_misc_species_cool_rates.cpp @@ -17,7 +17,7 @@ #include "grackle.h" #include "grackle_macros.h" -#include "interp_table_utils.h" // free_interp_grid_ +#include "interp_table_utils.hpp" // free_interp_grid_ #include "init_misc_species_cool_rates.hpp" // forward declarations #include "internal_units.h" #include "phys_constants.h" diff --git a/src/clib/initialize_chemistry_data.cpp b/src/clib/initialize_chemistry_data.cpp index b8b39fabf..44d253348 100644 --- a/src/clib/initialize_chemistry_data.cpp +++ b/src/clib/initialize_chemistry_data.cpp @@ -19,7 +19,7 @@ #include "grackle.h" #include "grackle_macros.h" #include "auto_general.h" -#include "interp_table_utils.h" // free_interp_grid_ +#include "interp_table_utils.hpp" // free_interp_grid_ #include "init_misc_species_cool_rates.hpp" // free_misc_species_cool_rates #include "initialize_cloudy_data.h" #include "initialize_dust_yields.hpp" // free_dust_yields @@ -574,13 +574,13 @@ extern "C" int local_free_chemistry_data(chemistry_data *my_chemistry, GRACKLE_FREE(my_rates->gas_grain); GRACKLE_FREE(my_rates->gas_grain2); - free_interp_grid_(&my_rates->LH2); - free_interp_grid_(&my_rates->LHD); + grackle::impl::free_interp_grid_(&my_rates->LH2); + grackle::impl::free_interp_grid_(&my_rates->LHD); // we deal with freeing other interp grids inside of // free_misc_species_cool_rates - free_interp_grid_(&my_rates->alphap); + grackle::impl::free_interp_grid_(&my_rates->alphap); GRACKLE_FREE(my_rates->gr_N); @@ -647,7 +647,9 @@ extern "C" int local_free_chemistry_data(chemistry_data *my_chemistry, // delete contents of h2dust_grain_interp_props (automatically handles the // case where we didn't allocate anything) - free_interp_grid_props_(&my_rates->opaque_storage->h2dust_grain_interp_props); + grackle::impl::free_interp_grid_props_( + &my_rates->opaque_storage->h2dust_grain_interp_props, + /* use_delete = */ false); // since h2dust_grain_interp_props isn't a pointer, there is nothing more to // allocate right here diff --git a/src/clib/interp_table_utils.h b/src/clib/interp_table_utils.h deleted file mode 100644 index a9ad59147..000000000 --- a/src/clib/interp_table_utils.h +++ /dev/null @@ -1,43 +0,0 @@ -/*********************************************************************** -/ -/ Declare utility functions related to the interpolation tables -/ -/ -/ Copyright (c) 2013, Enzo/Grackle Development Team. -/ -/ Distributed under the terms of the Enzo Public Licence. -/ -/ The full license is in the file LICENSE, distributed with this -/ software. -************************************************************************/ - -#ifndef INTERP_TABLE_UTILS_H -#define INTERP_TABLE_UTILS_H - -#include "grackle.h" // gr_interp_grid, GRACKLE_CLOUDY_TABLE_MAX_DIMENSION -#include "grackle_macros.h" // GRACKLE_FREE - -#ifdef __cplusplus -extern "C" { -#endif - -/// Free memory associated with a #gr_interp_grid_props instance -static inline void free_interp_grid_props_(gr_interp_grid_props* props) -{ - for (int i = 0; i < GRACKLE_CLOUDY_TABLE_MAX_DIMENSION; i++) { - GRACKLE_FREE(props->parameters[i]); - } -} - -/// Free memory associated with a #gr_interp_grid -static inline void free_interp_grid_(gr_interp_grid* grid) -{ - free_interp_grid_props_(&(grid->props)); - GRACKLE_FREE(grid->data); -} - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif /* INTERP_TABLE_UTILS_H */ diff --git a/src/clib/interp_table_utils.hpp b/src/clib/interp_table_utils.hpp new file mode 100644 index 000000000..243d61876 --- /dev/null +++ b/src/clib/interp_table_utils.hpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// See the LICENSE file for license and copyright information +// SPDX-License-Identifier: NCSA AND BSD-3-Clause +// +//===----------------------------------------------------------------------===// +/// +/// @file +/// Declare utility functions related to the interpolation tables +/// +//===----------------------------------------------------------------------===// + +#ifndef INTERP_TABLE_UTILS_HPP +#define INTERP_TABLE_UTILS_HPP + +#include "grackle.h" // gr_interp_grid, GRACKLE_CLOUDY_TABLE_MAX_DIMENSION +#include "grackle_macros.h" // GRACKLE_FREE + +namespace grackle::impl { + +/// Free memory associated with a #gr_interp_grid_props instance +inline void free_interp_grid_props_(gr_interp_grid_props* props, + bool use_delete) +{ + for (int i = 0; i < GRACKLE_CLOUDY_TABLE_MAX_DIMENSION; i++) { + if (use_delete) { + if (props->parameters[i] != nullptr) { + delete[] props->parameters[i]; + props->parameters[i] = nullptr; + } + } else { + GRACKLE_FREE(props->parameters[i]); + } + } +} + +/// Free memory associated with a #gr_interp_grid +inline void free_interp_grid_(gr_interp_grid* grid) +{ + free_interp_grid_props_(&(grid->props), /* use_delete = */ false); + GRACKLE_FREE(grid->data); +} + +} // namespace grackle::impl + +#endif /* INTERP_TABLE_UTILS_HPP */ From d7727b33a6a666b3f68f297f915c64c7b15eb835 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Mon, 8 Dec 2025 12:18:56 -0500 Subject: [PATCH 009/175] apply clang-format to src/clib/interp_table_utils.hpp --- .clang-format-ignore | 1 - src/clib/interp_table_utils.hpp | 10 ++++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.clang-format-ignore b/.clang-format-ignore index 4cda5afa3..d15536e08 100644 --- a/.clang-format-ignore +++ b/.clang-format-ignore @@ -36,7 +36,6 @@ src/clib/initialize_dust_yields.cpp src/clib/initialize_rates.cpp src/clib/internal_types.hpp src/clib/internal_units.h -src/clib/interp_table_utils.hpp src/clib/interpolate.hpp src/clib/phys_constants.h src/clib/rate_functions.c diff --git a/src/clib/interp_table_utils.hpp b/src/clib/interp_table_utils.hpp index 243d61876..c799c851e 100644 --- a/src/clib/interp_table_utils.hpp +++ b/src/clib/interp_table_utils.hpp @@ -13,15 +13,14 @@ #ifndef INTERP_TABLE_UTILS_HPP #define INTERP_TABLE_UTILS_HPP -#include "grackle.h" // gr_interp_grid, GRACKLE_CLOUDY_TABLE_MAX_DIMENSION -#include "grackle_macros.h" // GRACKLE_FREE +#include "grackle.h" // gr_interp_grid, GRACKLE_CLOUDY_TABLE_MAX_DIMENSION +#include "grackle_macros.h" // GRACKLE_FREE namespace grackle::impl { /// Free memory associated with a #gr_interp_grid_props instance inline void free_interp_grid_props_(gr_interp_grid_props* props, - bool use_delete) -{ + bool use_delete) { for (int i = 0; i < GRACKLE_CLOUDY_TABLE_MAX_DIMENSION; i++) { if (use_delete) { if (props->parameters[i] != nullptr) { @@ -35,8 +34,7 @@ inline void free_interp_grid_props_(gr_interp_grid_props* props, } /// Free memory associated with a #gr_interp_grid -inline void free_interp_grid_(gr_interp_grid* grid) -{ +inline void free_interp_grid_(gr_interp_grid* grid) { free_interp_grid_props_(&(grid->props), /* use_delete = */ false); GRACKLE_FREE(grid->data); } From 0cd4082fdd3104e9d3b28ef2c78c54af5b5fa52b Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Mon, 8 Dec 2025 13:01:45 -0500 Subject: [PATCH 010/175] shift 2 functions out of src/clib/initialize_chemistry_data into interp_table_utils.hpp --- src/clib/initialize_chemistry_data.cpp | 39 ++++++++------------------ src/clib/interp_table_utils.hpp | 17 +++++++++++ 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/clib/initialize_chemistry_data.cpp b/src/clib/initialize_chemistry_data.cpp index 44d253348..e9089c782 100644 --- a/src/clib/initialize_chemistry_data.cpp +++ b/src/clib/initialize_chemistry_data.cpp @@ -19,7 +19,7 @@ #include "grackle.h" #include "grackle_macros.h" #include "auto_general.h" -#include "interp_table_utils.hpp" // free_interp_grid_ +#include "interp_table_utils.hpp" #include "init_misc_species_cool_rates.hpp" // free_misc_species_cool_rates #include "initialize_cloudy_data.h" #include "initialize_dust_yields.hpp" // free_dust_yields @@ -49,23 +49,6 @@ static void show_version(FILE *fp) fprintf (fp, "\n"); } -/// initialize an empty #gr_interp_grid_props -static void init_empty_interp_grid_props_(gr_interp_grid_props* props) { - props->rank = 0; - for (int i = 0; i < GRACKLE_CLOUDY_TABLE_MAX_DIMENSION; i++){ - props->dimension[i] = 0; - props->parameters[i] = nullptr; - props->parameter_spacing[i] = 0.0; - } - props->data_size = 0; -} - -/// Initialize an empty #gr_interp_grid -static void initialize_empty_interp_grid_(gr_interp_grid* grid) -{ - init_empty_interp_grid_props_(&(grid->props)); - grid->data=NULL; -} /** * Initializes an empty #chemistry_data_storage struct with zeros and NULLs. @@ -152,18 +135,18 @@ static void initialize_empty_chemistry_data_storage_struct(chemistry_data_storag my_rates->cieY06 = NULL; - initialize_empty_interp_grid_(&my_rates->LH2); - initialize_empty_interp_grid_(&my_rates->LHD); + grackle::impl::initialize_empty_interp_grid_(&my_rates->LH2); + grackle::impl::initialize_empty_interp_grid_(&my_rates->LHD); - initialize_empty_interp_grid_(&my_rates->LCI); - initialize_empty_interp_grid_(&my_rates->LCII); - initialize_empty_interp_grid_(&my_rates->LOI); + grackle::impl::initialize_empty_interp_grid_(&my_rates->LCI); + grackle::impl::initialize_empty_interp_grid_(&my_rates->LCII); + grackle::impl::initialize_empty_interp_grid_(&my_rates->LOI); - initialize_empty_interp_grid_(&my_rates->LCO); - initialize_empty_interp_grid_(&my_rates->LOH); - initialize_empty_interp_grid_(&my_rates->LH2O); + grackle::impl::initialize_empty_interp_grid_(&my_rates->LCO); + grackle::impl::initialize_empty_interp_grid_(&my_rates->LOH); + grackle::impl::initialize_empty_interp_grid_(&my_rates->LH2O); - initialize_empty_interp_grid_(&my_rates->alphap); + grackle::impl::initialize_empty_interp_grid_(&my_rates->alphap); my_rates->gr_N = NULL; my_rates->gr_Size = 0; @@ -400,7 +383,7 @@ extern "C" int local_initialize_chemistry_data(chemistry_data *my_chemistry, my_rates->opaque_storage->kcol_rate_tables = nullptr; my_rates->opaque_storage->used_kcol_rate_indices = nullptr; my_rates->opaque_storage->n_kcol_rate_indices = 0; - init_empty_interp_grid_props_( + grackle::impl::init_empty_interp_grid_props_( &my_rates->opaque_storage->h2dust_grain_interp_props); my_rates->opaque_storage->grain_species_info = nullptr; diff --git a/src/clib/interp_table_utils.hpp b/src/clib/interp_table_utils.hpp index c799c851e..121767c09 100644 --- a/src/clib/interp_table_utils.hpp +++ b/src/clib/interp_table_utils.hpp @@ -18,6 +18,23 @@ namespace grackle::impl { +/// initialize an empty #gr_interp_grid_props +inline void init_empty_interp_grid_props_(gr_interp_grid_props* props) { + props->rank = 0; + for (int i = 0; i < GRACKLE_CLOUDY_TABLE_MAX_DIMENSION; i++) { + props->dimension[i] = 0; + props->parameters[i] = nullptr; + props->parameter_spacing[i] = 0.0; + } + props->data_size = 0; +} + +/// Initialize an empty #gr_interp_grid +inline void initialize_empty_interp_grid_(gr_interp_grid* grid) { + init_empty_interp_grid_props_(&(grid->props)); + grid->data = nullptr; +} + /// Free memory associated with a #gr_interp_grid_props instance inline void free_interp_grid_props_(gr_interp_grid_props* props, bool use_delete) { From 44438b74d4dd03920db005e3ee3632a7f2d6a70d Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 5 Nov 2025 10:44:31 -0500 Subject: [PATCH 011/175] Begin introducing GrainMetalInjectPathways There's still a lot of work to be done (the type is incomplete and isn't filled by anything at all) --- src/clib/CMakeLists.txt | 1 + src/clib/grain_metal_inject_pathways.hpp | 148 +++++++++++++++++++++++ src/clib/initialize_chemistry_data.cpp | 12 +- src/clib/initialize_dust_yields.cpp | 18 ++- src/clib/opaque_storage.hpp | 5 + 5 files changed, 178 insertions(+), 6 deletions(-) create mode 100644 src/clib/grain_metal_inject_pathways.hpp diff --git a/src/clib/CMakeLists.txt b/src/clib/CMakeLists.txt index 77fe17e03..52557be3f 100644 --- a/src/clib/CMakeLists.txt +++ b/src/clib/CMakeLists.txt @@ -113,6 +113,7 @@ add_library(Grackle_Grackle cool_multi_time_g.cpp cool_multi_time_g.h dust_props.hpp dust/grain_species_info.cpp dust/grain_species_info.hpp + grain_metal_inject_pathways.hpp init_misc_species_cool_rates.cpp init_misc_species_cool_rates.hpp initialize_chemistry_data.cpp initialize_dust_yields.cpp initialize_dust_yields.hpp diff --git a/src/clib/grain_metal_inject_pathways.hpp b/src/clib/grain_metal_inject_pathways.hpp new file mode 100644 index 000000000..3ec9af073 --- /dev/null +++ b/src/clib/grain_metal_inject_pathways.hpp @@ -0,0 +1,148 @@ +//===----------------------------------------------------------------------===// +// +// See the LICENSE file for license and copyright information +// SPDX-License-Identifier: NCSA AND BSD-3-Clause +// +//===----------------------------------------------------------------------===// +/// +/// @file +/// Defines the GrainMetalInjectPathways type +/// +//===----------------------------------------------------------------------===// +#ifndef GRAIN_METAL_INJECT_PATHWAYS_HPP +#define GRAIN_METAL_INJECT_PATHWAYS_HPP + +// after dealing with GH Issue #446, move this file into the dust subdirectory + +#include "LUT.hpp" +#include "internal_types.hpp" +#include "visitor/common.hpp" + +// this is a separate namespace because we are probably going to delete the +// contents (when we deal with GH Issue #446) +namespace grackle::impl::yields { + +/// Tables of values for each metal nuclide known to Grackle. Each table +/// has an entry for each injection pathway modelled in the current +/// configuration +/// +/// @note +/// When we deal with GH Issue #446, we'll almost certainly delete this. We +/// avoid using the visitor pattern here since this is very much an ephemeral +/// type introduced as a stopgap solution (and because types used to implement +/// the visitor pattern, namely ``vis::idx_range_len_multiple``) should probably +/// be renamed to have a more general-sounding name +struct MetalTables { + double* C; + double* O; + double* Mg; + double* Al; + double* Si; + double* S; + double* Fe; +}; + +/// allocates the contents of a new MetalTable +/// +/// @param nelem The number of elements in each buffer +inline MetalTables new_MetalTables(int nelem) { + MetalTables out; + + out.C = new double[nelem]; + out.O = new double[nelem]; + out.Mg = new double[nelem]; + out.Al = new double[nelem]; + out.Si = new double[nelem]; + out.S = new double[nelem]; + out.Fe = new double[nelem]; + + return out; +} + +/// performs cleanup of the contents of MetalTable +/// +/// This effectively invokes a destructor +inline void drop_MetalTables(MetalTables* ptr) { + delete[] ptr->C; + delete[] ptr->O; + delete[] ptr->Mg; + delete[] ptr->Al; + delete[] ptr->Si; + delete[] ptr->S; + delete[] ptr->Fe; +} + +} // namespace grackle::impl::yields + +namespace grackle::impl { + +/// The basic premise is that this tracks tables of data pertaining to the +/// list of injection pathways for dust grains and metal species +/// +/// @note +/// The organization of data is a little suboptimal. But, we can reorganize +/// later. +struct GrainMetalInjectPathways { + /// the number of modelled injection pathways + int n_pathways; + + /// holds 1D tables (tabulated with respect to each injection pathway) that + /// tracks the fraction of the injected mass density corresponding to + /// occurences of given metal nuclide in both the gas phase **AND** as part + /// of dust grains + /// + /// @important + /// This counts up occurences of nulcides (i.e. a nuclide is allowed to occur + /// multiple times within a single molecule) + /// + /// @note + /// this variables holds information that is somewhat actually redundant with + /// other tables that we are tracking + yields::MetalTables total_metal_nuclide_yields; + + /// holds 1D tables that tracks the fraction of the injected mass density + /// that corresponds to the **INITIAL** occurences of given metal nuclide in + /// the gas phase. + /// + /// This holds a separate table for each metal nuclide and each table has an + /// entry for each injection pathway. + /// + /// @important + /// This counts up occurences of nulcides (i.e. a nuclide is allowed to occur + /// multiple times within a single molecule) + yields::MetalTables gas_metal_nuclide_yields; + + /// holds 1D tables (tabulated with respect to each injection pathway) that + /// tracks the fraction of the injected mass density that corresponds to the + /// **INITIAL** occurences of a given grain species + /// + /// This holds a separate table for each grain species and every table has an + /// entry for each injection pathway. + GrainSpeciesCollection grain_yields; +}; + +/// allocates the contents of a new GrainMetalInjectPathways +/// +/// @param n_pathways The number of modeled injection pathways +inline GrainMetalInjectPathways new_GrainMetalInjectPathways(int n_pathways) { + GrainMetalInjectPathways out; + out.n_pathways = n_pathways; + out.total_metal_nuclide_yields = yields::new_MetalTables(n_pathways); + out.gas_metal_nuclide_yields = yields::new_MetalTables(n_pathways); + out.grain_yields = new_GrainSpeciesCollection(n_pathways); + + return out; +} + +/// performs cleanup of the contents of GrainMetalInjectPathways +/// +/// This effectively invokes a destructor +inline void drop_GrainMetalInjectPathways(GrainMetalInjectPathways* ptr) { + yields::drop_MetalTables(&ptr->total_metal_nuclide_yields); + yields::drop_MetalTables(&ptr->gas_metal_nuclide_yields); + drop_GrainSpeciesCollection(&ptr->grain_yields); +} + +} // namespace grackle::impl + +#endif // GRAIN_METAL_INJECT_PATHWAYS_HPP diff --git a/src/clib/initialize_chemistry_data.cpp b/src/clib/initialize_chemistry_data.cpp index e9089c782..1968feb8f 100644 --- a/src/clib/initialize_chemistry_data.cpp +++ b/src/clib/initialize_chemistry_data.cpp @@ -19,6 +19,7 @@ #include "grackle.h" #include "grackle_macros.h" #include "auto_general.h" +#include "grain_metal_inject_pathways.hpp" #include "interp_table_utils.hpp" #include "init_misc_species_cool_rates.hpp" // free_misc_species_cool_rates #include "initialize_cloudy_data.h" @@ -386,6 +387,7 @@ extern "C" int local_initialize_chemistry_data(chemistry_data *my_chemistry, grackle::impl::init_empty_interp_grid_props_( &my_rates->opaque_storage->h2dust_grain_interp_props); my_rates->opaque_storage->grain_species_info = nullptr; + my_rates->opaque_storage->inject_pathway_props = nullptr; double co_length_units, co_density_units; if (my_units->comoving_coordinates == TRUE) { @@ -640,10 +642,18 @@ extern "C" int local_free_chemistry_data(chemistry_data *my_chemistry, // delete contents of grain_species_info grackle::impl::drop_GrainSpeciesInfo( my_rates->opaque_storage->grain_species_info); - // delete kcol_rate_tables, itself + // delete grain_species_info, itself delete my_rates->opaque_storage->grain_species_info; } + if (my_rates->opaque_storage->inject_pathway_props != nullptr) { + // delete contents of inject_pathway_props + grackle::impl::drop_GrainMetalInjectPathways( + my_rates->opaque_storage->inject_pathway_props); + // delete inject_pathway_props, itself + delete my_rates->opaque_storage->inject_pathway_props; + } + delete my_rates->opaque_storage; my_rates->opaque_storage = nullptr; diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index 41f137ca5..fdb44cefb 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -16,6 +16,7 @@ #include "grackle_macros.h" #include "grackle_chemistry_data.h" #include "initialize_dust_yields.hpp" // forward declarations +#include "opaque_storage.hpp" // forward declare some functions @@ -47,12 +48,19 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, return SUCCESS; } - int NSN, NTd, Nmom; - double Td0, dTd; - int iSN, iTd, imom, itab; + int n_pathways = 12; + my_rates->opaque_storage->inject_pathway_props = + new grackle::impl::GrainMetalInjectPathways; + *(my_rates->opaque_storage->inject_pathway_props) = + new_GrainMetalInjectPathways(n_pathways); - NSN = 12; - my_rates->SN0_N = NSN; + + int NTd, Nmom; + double Td0, dTd; + int iSN, iTd, imom, itab; + + int NSN = n_pathways; // todo: delete me! + my_rates->SN0_N = n_pathways; my_rates->SN0_XC = (double*)malloc(NSN * sizeof(double)); my_rates->SN0_XO = (double*)malloc(NSN * sizeof(double)); diff --git a/src/clib/opaque_storage.hpp b/src/clib/opaque_storage.hpp index a118d42c4..c30030b21 100644 --- a/src/clib/opaque_storage.hpp +++ b/src/clib/opaque_storage.hpp @@ -15,6 +15,7 @@ #include "grackle.h" #include "dust/grain_species_info.hpp" +#include "grain_metal_inject_pathways.hpp" #include "internal_types.hpp" /// a struct that used to wrap some private storage details @@ -95,6 +96,10 @@ struct gr_opaque_storage { /// > calculations). An alternative would be to briefly initialize an /// > instance during setup and then repack the data. grackle::impl::GrainSpeciesInfo* grain_species_info; + + /// Tracks metal and grain yields for each modeled injection pathway as well + /// as other grain properties + grackle::impl::GrainMetalInjectPathways* inject_pathway_props; }; #endif /* OPAQUE_STORAGE_HPP */ From dac21ea4a3aac2a2f752d263bb778e8a3ab5a2ee Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Thu, 6 Nov 2025 11:37:12 -0500 Subject: [PATCH 012/175] an incremental step towards adopting GrainMetalInjectPathways --- src/clib/initialize_dust_yields.cpp | 99 ++++++++++++++++------------- 1 file changed, 55 insertions(+), 44 deletions(-) diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index fdb44cefb..44c89edbd 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -54,6 +54,9 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, *(my_rates->opaque_storage->inject_pathway_props) = new_GrainMetalInjectPathways(n_pathways); + grackle::impl::GrainMetalInjectPathways* inject_pathway_props + = my_rates->opaque_storage->inject_pathway_props; + int NTd, Nmom; double Td0, dTd; @@ -62,35 +65,39 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, int NSN = n_pathways; // todo: delete me! my_rates->SN0_N = n_pathways; - my_rates->SN0_XC = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_XO = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_XMg = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_XAl = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_XSi = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_XS = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_XFe = (double*)malloc(NSN * sizeof(double)); - - my_rates->SN0_fC = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_fO = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_fMg = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_fAl = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_fSi = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_fS = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_fFe = (double*)malloc(NSN * sizeof(double)); - - my_rates->SN0_fSiM = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_fFeM = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_fMg2SiO4 = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_fMgSiO3 = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_fFe3O4 = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_fAC = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_fSiO2D = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_fMgO = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_fFeS = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_fAl2O3 = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_freforg = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_fvolorg = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_fH2Oice = (double*)malloc(NSN * sizeof(double)); + // crude hack (until we delete all of chemistry_data_storage's SN0_X* and + // SN0_f* members -- this has to wait until after we merge in the + // transcription of make_consistent) + my_rates->SN0_XC = inject_pathway_props->total_metal_nuclide_yields.C; + my_rates->SN0_XO = inject_pathway_props->total_metal_nuclide_yields.O; + my_rates->SN0_XMg = inject_pathway_props->total_metal_nuclide_yields.Mg; + my_rates->SN0_XAl = inject_pathway_props->total_metal_nuclide_yields.Al; + my_rates->SN0_XSi = inject_pathway_props->total_metal_nuclide_yields.Si; + my_rates->SN0_XS = inject_pathway_props->total_metal_nuclide_yields.S; + my_rates->SN0_XFe = inject_pathway_props->total_metal_nuclide_yields.Fe; + + my_rates->SN0_fC = inject_pathway_props->gas_metal_nuclide_yields.C; + my_rates->SN0_fO = inject_pathway_props->gas_metal_nuclide_yields.O; + my_rates->SN0_fMg = inject_pathway_props->gas_metal_nuclide_yields.Mg; + my_rates->SN0_fAl = inject_pathway_props->gas_metal_nuclide_yields.Al; + my_rates->SN0_fSi = inject_pathway_props->gas_metal_nuclide_yields.Si; + my_rates->SN0_fS = inject_pathway_props->gas_metal_nuclide_yields.S; + my_rates->SN0_fFe = inject_pathway_props->gas_metal_nuclide_yields.Fe; + + // we can simply delete these when we have the oportunity + my_rates->SN0_fSiM = (double*)malloc(NSN * sizeof(double)); + my_rates->SN0_fFeM = (double*)malloc(NSN * sizeof(double)); + my_rates->SN0_fMg2SiO4 = (double*)malloc(NSN * sizeof(double)); + my_rates->SN0_fMgSiO3 = (double*)malloc(NSN * sizeof(double)); + my_rates->SN0_fFe3O4 = (double*)malloc(NSN * sizeof(double)); + my_rates->SN0_fAC = (double*)malloc(NSN * sizeof(double)); + my_rates->SN0_fSiO2D = (double*)malloc(NSN * sizeof(double)); + my_rates->SN0_fMgO = (double*)malloc(NSN * sizeof(double)); + my_rates->SN0_fFeS = (double*)malloc(NSN * sizeof(double)); + my_rates->SN0_fAl2O3 = (double*)malloc(NSN * sizeof(double)); + my_rates->SN0_freforg = (double*)malloc(NSN * sizeof(double)); + my_rates->SN0_fvolorg = (double*)malloc(NSN * sizeof(double)); + my_rates->SN0_fH2Oice = (double*)malloc(NSN * sizeof(double)); for(iSN = 0; iSN < NSN; iSN++) { my_rates->SN0_XC [iSN] = 0.0; @@ -231,21 +238,25 @@ int grackle::impl::free_dust_yields(chemistry_data *my_chemistry, if (my_chemistry->metal_chemistry == 0) return SUCCESS; - GRACKLE_FREE(my_rates->SN0_XC); - GRACKLE_FREE(my_rates->SN0_XO); - GRACKLE_FREE(my_rates->SN0_XMg); - GRACKLE_FREE(my_rates->SN0_XAl); - GRACKLE_FREE(my_rates->SN0_XSi); - GRACKLE_FREE(my_rates->SN0_XS); - GRACKLE_FREE(my_rates->SN0_XFe); - - GRACKLE_FREE(my_rates->SN0_fC); - GRACKLE_FREE(my_rates->SN0_fO); - GRACKLE_FREE(my_rates->SN0_fMg); - GRACKLE_FREE(my_rates->SN0_fAl); - GRACKLE_FREE(my_rates->SN0_fSi); - GRACKLE_FREE(my_rates->SN0_fS); - GRACKLE_FREE(my_rates->SN0_fFe); + // reminder: we have adopted a crude hack (until we delete all of + // chemistry_data_storage's SN0_X* and SN0_f* members -- this has to wait + // until after we merge in the transcription of make_consistent), where + // the yield fraction for each metal nuclide is an alias to a pointer + my_rates->SN0_XC = nullptr; + my_rates->SN0_XO = nullptr; + my_rates->SN0_XMg = nullptr; + my_rates->SN0_XAl = nullptr; + my_rates->SN0_XSi = nullptr; + my_rates->SN0_XS = nullptr; + my_rates->SN0_XFe = nullptr; + + my_rates->SN0_fC = nullptr; + my_rates->SN0_fO = nullptr; + my_rates->SN0_fMg = nullptr; + my_rates->SN0_fAl = nullptr; + my_rates->SN0_fSi = nullptr; + my_rates->SN0_fS = nullptr; + my_rates->SN0_fFe = nullptr; GRACKLE_FREE(my_rates->SN0_fSiM); GRACKLE_FREE(my_rates->SN0_fFeM); From 43e246480751f17f05324312d7043110205ddae5 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Thu, 6 Nov 2025 11:55:57 -0500 Subject: [PATCH 013/175] another step --- src/clib/initialize_dust_yields.cpp | 464 +++++++++++++++------------- 1 file changed, 250 insertions(+), 214 deletions(-) diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index 44c89edbd..1eb709dce 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -60,7 +60,7 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, int NTd, Nmom; double Td0, dTd; - int iSN, iTd, imom, itab; + int iTd, imom, itab; int NSN = n_pathways; // todo: delete me! my_rates->SN0_N = n_pathways; @@ -99,37 +99,37 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, my_rates->SN0_fvolorg = (double*)malloc(NSN * sizeof(double)); my_rates->SN0_fH2Oice = (double*)malloc(NSN * sizeof(double)); - for(iSN = 0; iSN < NSN; iSN++) { - my_rates->SN0_XC [iSN] = 0.0; - my_rates->SN0_XO [iSN] = 0.0; - my_rates->SN0_XMg[iSN] = 0.0; - my_rates->SN0_XAl[iSN] = 0.0; - my_rates->SN0_XSi[iSN] = 0.0; - my_rates->SN0_XS [iSN] = 0.0; - my_rates->SN0_XFe[iSN] = 0.0; - - my_rates->SN0_fC [iSN] = 0.0; - my_rates->SN0_fO [iSN] = 0.0; - my_rates->SN0_fMg[iSN] = 0.0; - my_rates->SN0_fAl[iSN] = 0.0; - my_rates->SN0_fSi[iSN] = 0.0; - my_rates->SN0_fS [iSN] = 0.0; - my_rates->SN0_fFe[iSN] = 0.0; - - my_rates->SN0_fSiM [iSN] = 0.0; - my_rates->SN0_fFeM [iSN] = 0.0; - my_rates->SN0_fMg2SiO4 [iSN] = 0.0; - my_rates->SN0_fMgSiO3 [iSN] = 0.0; - my_rates->SN0_fFe3O4 [iSN] = 0.0; - my_rates->SN0_fAC [iSN] = 0.0; - my_rates->SN0_fSiO2D [iSN] = 0.0; - my_rates->SN0_fMgO [iSN] = 0.0; - my_rates->SN0_fFeS [iSN] = 0.0; - my_rates->SN0_fAl2O3 [iSN] = 0.0; - my_rates->SN0_freforg [iSN] = 0.0; - my_rates->SN0_fvolorg [iSN] = 0.0; - my_rates->SN0_fH2Oice [iSN] = 0.0; - } + for(int iSN = 0; iSN < NSN; iSN++) { + inject_pathway_props->total_metal_nuclide_yields.C [iSN] = 0.0; + inject_pathway_props->total_metal_nuclide_yields.O [iSN] = 0.0; + inject_pathway_props->total_metal_nuclide_yields.Mg[iSN] = 0.0; + inject_pathway_props->total_metal_nuclide_yields.Al[iSN] = 0.0; + inject_pathway_props->total_metal_nuclide_yields.Si[iSN] = 0.0; + inject_pathway_props->total_metal_nuclide_yields.S [iSN] = 0.0; + inject_pathway_props->total_metal_nuclide_yields.Fe[iSN] = 0.0; + + inject_pathway_props->gas_metal_nuclide_yields.C [iSN] = 0.0; + inject_pathway_props->gas_metal_nuclide_yields.O [iSN] = 0.0; + inject_pathway_props->gas_metal_nuclide_yields.Mg[iSN] = 0.0; + inject_pathway_props->gas_metal_nuclide_yields.Al[iSN] = 0.0; + inject_pathway_props->gas_metal_nuclide_yields.Si[iSN] = 0.0; + inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 0.0; + inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 0.0; + + my_rates->SN0_fSiM [iSN] = 0.0; + my_rates->SN0_fFeM [iSN] = 0.0; + my_rates->SN0_fMg2SiO4 [iSN] = 0.0; + my_rates->SN0_fMgSiO3 [iSN] = 0.0; + my_rates->SN0_fFe3O4 [iSN] = 0.0; + my_rates->SN0_fAC [iSN] = 0.0; + my_rates->SN0_fSiO2D [iSN] = 0.0; + my_rates->SN0_fMgO [iSN] = 0.0; + my_rates->SN0_fFeS [iSN] = 0.0; + my_rates->SN0_fAl2O3 [iSN] = 0.0; + my_rates->SN0_freforg [iSN] = 0.0; + my_rates->SN0_fvolorg [iSN] = 0.0; + my_rates->SN0_fH2Oice [iSN] = 0.0; + } my_rates->SN0_r0SiM = (double*)malloc(NSN * 3 * sizeof(double)); my_rates->SN0_r0FeM = (double*)malloc(NSN * 3 * sizeof(double)); @@ -146,7 +146,7 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, my_rates->SN0_r0H2Oice = (double*)malloc(NSN * 3 * sizeof(double)); itab = 0; - for(iSN = 0; iSN < NSN; iSN++) { + for(int iSN = 0; iSN < NSN; iSN++) { for(imom = 0; imom < 3; imom++) { my_rates->SN0_r0SiM [itab] = 0.0; my_rates->SN0_r0FeM [itab] = 0.0; @@ -193,7 +193,7 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, my_rates->SN0_kpH2Oice = (double*)malloc(NSN * Nmom * NTd * sizeof(double)); itab = 0; - for(iSN = 0; iSN < NSN; iSN++) { + for(int iSN = 0; iSN < NSN; iSN++) { for(imom = 0; imom < Nmom; imom++) { for(iTd = 0; iTd < NTd; iTd++) { my_rates->SN0_kpSiM [itab] = 0.0; @@ -313,21 +313,24 @@ int calc_rates_dust_loc(int iSN, chemistry_data *my_chemistry, chemistry_data_st int NTd, Nmom; int iTd, imom, itab0, itab; - my_rates->SN0_XC [iSN] = 1.79042e-01; - my_rates->SN0_XO [iSN] = 5.11524e-01; - my_rates->SN0_XMg[iSN] = 3.46246e-02; - my_rates->SN0_XAl[iSN] = 3.07922e-03; - my_rates->SN0_XSi[iSN] = 3.76121e-02; - my_rates->SN0_XS [iSN] = 2.21374e-02; - my_rates->SN0_XFe[iSN] = 6.77017e-02; - - my_rates->SN0_fC [iSN] = 5.01317e-02; - my_rates->SN0_fO [iSN] = 2.78491e-01; - my_rates->SN0_fMg[iSN] = 0.00000e+00; - my_rates->SN0_fAl[iSN] = 3.07922e-03; - my_rates->SN0_fSi[iSN] = 3.50813e-03; - my_rates->SN0_fS [iSN] = 0.00000e+00; - my_rates->SN0_fFe[iSN] = 1.66568e-04; + grackle::impl::GrainMetalInjectPathways* inject_pathway_props + = my_rates->opaque_storage->inject_pathway_props; + + inject_pathway_props->total_metal_nuclide_yields.C [iSN] = 1.79042e-01; + inject_pathway_props->total_metal_nuclide_yields.O [iSN] = 5.11524e-01; + inject_pathway_props->total_metal_nuclide_yields.Mg[iSN] = 3.46246e-02; + inject_pathway_props->total_metal_nuclide_yields.Al[iSN] = 3.07922e-03; + inject_pathway_props->total_metal_nuclide_yields.Si[iSN] = 3.76121e-02; + inject_pathway_props->total_metal_nuclide_yields.S [iSN] = 2.21374e-02; + inject_pathway_props->total_metal_nuclide_yields.Fe[iSN] = 6.77017e-02; + + inject_pathway_props->gas_metal_nuclide_yields.C [iSN] = 5.01317e-02; + inject_pathway_props->gas_metal_nuclide_yields.O [iSN] = 2.78491e-01; + inject_pathway_props->gas_metal_nuclide_yields.Mg[iSN] = 0.00000e+00; + inject_pathway_props->gas_metal_nuclide_yields.Al[iSN] = 3.07922e-03; + inject_pathway_props->gas_metal_nuclide_yields.Si[iSN] = 3.50813e-03; + inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 0.00000e+00; + inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 1.66568e-04; my_rates->SN0_fFeM [iSN] = 1.35403e-02; my_rates->SN0_fMg2SiO4 [iSN] = 1.36165e-01; @@ -650,21 +653,24 @@ int calc_rates_dust_C13(int iSN, chemistry_data *my_chemistry, chemistry_data_st int NTd, Nmom; int iTd, imom, itab0, itab; - my_rates->SN0_XC [iSN] = 2.65314e-01; - my_rates->SN0_XO [iSN] = 3.00982e-01; - my_rates->SN0_XMg[iSN] = 3.06651e-02; - my_rates->SN0_XAl[iSN] = 2.47296e-04; - my_rates->SN0_XSi[iSN] = 6.38319e-02; - my_rates->SN0_XS [iSN] = 3.40910e-02; - my_rates->SN0_XFe[iSN] = 9.62448e-02; - - my_rates->SN0_fC [iSN] = 2.16731e-01; - my_rates->SN0_fO [iSN] = 2.99231e-01; - my_rates->SN0_fMg[iSN] = 3.03586e-02; - my_rates->SN0_fAl[iSN] = 2.47296e-04; - my_rates->SN0_fSi[iSN] = 4.59041e-02; - my_rates->SN0_fS [iSN] = 3.40903e-02; - my_rates->SN0_fFe[iSN] = 7.22586e-02; + grackle::impl::GrainMetalInjectPathways* inject_pathway_props + = my_rates->opaque_storage->inject_pathway_props; + + inject_pathway_props->total_metal_nuclide_yields.C [iSN] = 2.65314e-01; + inject_pathway_props->total_metal_nuclide_yields.O [iSN] = 3.00982e-01; + inject_pathway_props->total_metal_nuclide_yields.Mg[iSN] = 3.06651e-02; + inject_pathway_props->total_metal_nuclide_yields.Al[iSN] = 2.47296e-04; + inject_pathway_props->total_metal_nuclide_yields.Si[iSN] = 6.38319e-02; + inject_pathway_props->total_metal_nuclide_yields.S [iSN] = 3.40910e-02; + inject_pathway_props->total_metal_nuclide_yields.Fe[iSN] = 9.62448e-02; + + inject_pathway_props->gas_metal_nuclide_yields.C [iSN] = 2.16731e-01; + inject_pathway_props->gas_metal_nuclide_yields.O [iSN] = 2.99231e-01; + inject_pathway_props->gas_metal_nuclide_yields.Mg[iSN] = 3.03586e-02; + inject_pathway_props->gas_metal_nuclide_yields.Al[iSN] = 2.47296e-04; + inject_pathway_props->gas_metal_nuclide_yields.Si[iSN] = 4.59041e-02; + inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 3.40903e-02; + inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 7.22586e-02; my_rates->SN0_fSiM [iSN] = 1.65746e-02; my_rates->SN0_fFeM [iSN] = 2.39849e-02; @@ -1029,21 +1035,24 @@ int calc_rates_dust_C20(int iSN, chemistry_data *my_chemistry, chemistry_data_st int NTd, Nmom; int iTd, imom, itab0, itab; - my_rates->SN0_XC [iSN] = 1.00183e-01; - my_rates->SN0_XO [iSN] = 6.06515e-01; - my_rates->SN0_XMg[iSN] = 2.75968e-02; - my_rates->SN0_XAl[iSN] = 1.87118e-04; - my_rates->SN0_XSi[iSN] = 1.00051e-01; - my_rates->SN0_XS [iSN] = 6.02208e-02; - my_rates->SN0_XFe[iSN] = 3.07560e-02; - - my_rates->SN0_fC [iSN] = 8.74563e-02; - my_rates->SN0_fO [iSN] = 6.04383e-01; - my_rates->SN0_fMg[iSN] = 2.63753e-02; - my_rates->SN0_fAl[iSN] = 1.87118e-04; - my_rates->SN0_fSi[iSN] = 6.44592e-02; - my_rates->SN0_fS [iSN] = 6.02018e-02; - my_rates->SN0_fFe[iSN] = 2.69505e-02; + grackle::impl::GrainMetalInjectPathways* inject_pathway_props + = my_rates->opaque_storage->inject_pathway_props; + + inject_pathway_props->total_metal_nuclide_yields.C [iSN] = 1.00183e-01; + inject_pathway_props->total_metal_nuclide_yields.O [iSN] = 6.06515e-01; + inject_pathway_props->total_metal_nuclide_yields.Mg[iSN] = 2.75968e-02; + inject_pathway_props->total_metal_nuclide_yields.Al[iSN] = 1.87118e-04; + inject_pathway_props->total_metal_nuclide_yields.Si[iSN] = 1.00051e-01; + inject_pathway_props->total_metal_nuclide_yields.S [iSN] = 6.02208e-02; + inject_pathway_props->total_metal_nuclide_yields.Fe[iSN] = 3.07560e-02; + + inject_pathway_props->gas_metal_nuclide_yields.C [iSN] = 8.74563e-02; + inject_pathway_props->gas_metal_nuclide_yields.O [iSN] = 6.04383e-01; + inject_pathway_props->gas_metal_nuclide_yields.Mg[iSN] = 2.63753e-02; + inject_pathway_props->gas_metal_nuclide_yields.Al[iSN] = 1.87118e-04; + inject_pathway_props->gas_metal_nuclide_yields.Si[iSN] = 6.44592e-02; + inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 6.02018e-02; + inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 2.69505e-02; my_rates->SN0_fSiM [iSN] = 3.44388e-02; my_rates->SN0_fFeM [iSN] = 3.77223e-03; @@ -1450,21 +1459,24 @@ int calc_rates_dust_C25(int iSN, chemistry_data *my_chemistry, chemistry_data_st int NTd, Nmom; int iTd, imom, itab0, itab; - my_rates->SN0_XC [iSN] = 1.75488e-01; - my_rates->SN0_XO [iSN] = 5.69674e-01; - my_rates->SN0_XMg[iSN] = 3.12340e-02; - my_rates->SN0_XAl[iSN] = 2.98415e-04; - my_rates->SN0_XSi[iSN] = 8.33205e-02; - my_rates->SN0_XS [iSN] = 4.73930e-02; - my_rates->SN0_XFe[iSN] = 1.98197e-02; - - my_rates->SN0_fC [iSN] = 1.34092e-01; - my_rates->SN0_fO [iSN] = 5.53726e-01; - my_rates->SN0_fMg[iSN] = 2.48100e-02; - my_rates->SN0_fAl[iSN] = 2.98415e-04; - my_rates->SN0_fSi[iSN] = 3.47760e-02; - my_rates->SN0_fS [iSN] = 4.72556e-02; - my_rates->SN0_fFe[iSN] = 1.46955e-02; + grackle::impl::GrainMetalInjectPathways* inject_pathway_props + = my_rates->opaque_storage->inject_pathway_props; + + inject_pathway_props->total_metal_nuclide_yields.C [iSN] = 1.75488e-01; + inject_pathway_props->total_metal_nuclide_yields.O [iSN] = 5.69674e-01; + inject_pathway_props->total_metal_nuclide_yields.Mg[iSN] = 3.12340e-02; + inject_pathway_props->total_metal_nuclide_yields.Al[iSN] = 2.98415e-04; + inject_pathway_props->total_metal_nuclide_yields.Si[iSN] = 8.33205e-02; + inject_pathway_props->total_metal_nuclide_yields.S [iSN] = 4.73930e-02; + inject_pathway_props->total_metal_nuclide_yields.Fe[iSN] = 1.98197e-02; + + inject_pathway_props->gas_metal_nuclide_yields.C [iSN] = 1.34092e-01; + inject_pathway_props->gas_metal_nuclide_yields.O [iSN] = 5.53726e-01; + inject_pathway_props->gas_metal_nuclide_yields.Mg[iSN] = 2.48100e-02; + inject_pathway_props->gas_metal_nuclide_yields.Al[iSN] = 2.98415e-04; + inject_pathway_props->gas_metal_nuclide_yields.Si[iSN] = 3.47760e-02; + inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 4.72556e-02; + inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 1.46955e-02; my_rates->SN0_fSiM [iSN] = 3.83373e-02; my_rates->SN0_fFeM [iSN] = 4.88366e-03; @@ -1871,21 +1883,24 @@ int calc_rates_dust_C30(int iSN, chemistry_data *my_chemistry, chemistry_data_st int NTd, Nmom; int iTd, imom, itab0, itab; - my_rates->SN0_XC [iSN] = 4.99965e-02; - my_rates->SN0_XO [iSN] = 7.32832e-01; - my_rates->SN0_XMg[iSN] = 3.87430e-02; - my_rates->SN0_XAl[iSN] = 8.61678e-04; - my_rates->SN0_XSi[iSN] = 7.18810e-02; - my_rates->SN0_XS [iSN] = 3.70455e-02; - my_rates->SN0_XFe[iSN] = 1.45822e-02; - - my_rates->SN0_fC [iSN] = 4.93773e-02; - my_rates->SN0_fO [iSN] = 7.29130e-01; - my_rates->SN0_fMg[iSN] = 3.76731e-02; - my_rates->SN0_fAl[iSN] = 8.61678e-04; - my_rates->SN0_fSi[iSN] = 4.01269e-02; - my_rates->SN0_fS [iSN] = 3.68812e-02; - my_rates->SN0_fFe[iSN] = 1.23641e-02; + grackle::impl::GrainMetalInjectPathways* inject_pathway_props + = my_rates->opaque_storage->inject_pathway_props; + + inject_pathway_props->total_metal_nuclide_yields.C [iSN] = 4.99965e-02; + inject_pathway_props->total_metal_nuclide_yields.O [iSN] = 7.32832e-01; + inject_pathway_props->total_metal_nuclide_yields.Mg[iSN] = 3.87430e-02; + inject_pathway_props->total_metal_nuclide_yields.Al[iSN] = 8.61678e-04; + inject_pathway_props->total_metal_nuclide_yields.Si[iSN] = 7.18810e-02; + inject_pathway_props->total_metal_nuclide_yields.S [iSN] = 3.70455e-02; + inject_pathway_props->total_metal_nuclide_yields.Fe[iSN] = 1.45822e-02; + + inject_pathway_props->gas_metal_nuclide_yields.C [iSN] = 4.93773e-02; + inject_pathway_props->gas_metal_nuclide_yields.O [iSN] = 7.29130e-01; + inject_pathway_props->gas_metal_nuclide_yields.Mg[iSN] = 3.76731e-02; + inject_pathway_props->gas_metal_nuclide_yields.Al[iSN] = 8.61678e-04; + inject_pathway_props->gas_metal_nuclide_yields.Si[iSN] = 4.01269e-02; + inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 3.68812e-02; + inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 1.23641e-02; my_rates->SN0_fSiM [iSN] = 2.91389e-02; my_rates->SN0_fFeM [iSN] = 1.93065e-03; @@ -2292,21 +2307,24 @@ int calc_rates_dust_F13(int iSN, chemistry_data *my_chemistry, chemistry_data_st int NTd, Nmom; int iTd, imom, itab0, itab; - my_rates->SN0_XC [iSN] = 6.69235e-01; - my_rates->SN0_XO [iSN] = 3.30556e-01; - my_rates->SN0_XMg[iSN] = 1.86824e-04; - my_rates->SN0_XAl[iSN] = 1.97017e-07; - my_rates->SN0_XSi[iSN] = 1.30184e-05; - my_rates->SN0_XS [iSN] = 0.00000e+00; - my_rates->SN0_XFe[iSN] = 8.90341e-06; - - my_rates->SN0_fC [iSN] = 4.93693e-01; - my_rates->SN0_fO [iSN] = 3.30556e-01; - my_rates->SN0_fMg[iSN] = 1.86824e-04; - my_rates->SN0_fAl[iSN] = 1.97017e-07; - my_rates->SN0_fSi[iSN] = 1.30184e-05; - my_rates->SN0_fS [iSN] = 0.00000e+00; - my_rates->SN0_fFe[iSN] = 8.90341e-06; + grackle::impl::GrainMetalInjectPathways* inject_pathway_props + = my_rates->opaque_storage->inject_pathway_props; + + inject_pathway_props->total_metal_nuclide_yields.C [iSN] = 6.69235e-01; + inject_pathway_props->total_metal_nuclide_yields.O [iSN] = 3.30556e-01; + inject_pathway_props->total_metal_nuclide_yields.Mg[iSN] = 1.86824e-04; + inject_pathway_props->total_metal_nuclide_yields.Al[iSN] = 1.97017e-07; + inject_pathway_props->total_metal_nuclide_yields.Si[iSN] = 1.30184e-05; + inject_pathway_props->total_metal_nuclide_yields.S [iSN] = 0.00000e+00; + inject_pathway_props->total_metal_nuclide_yields.Fe[iSN] = 8.90341e-06; + + inject_pathway_props->gas_metal_nuclide_yields.C [iSN] = 4.93693e-01; + inject_pathway_props->gas_metal_nuclide_yields.O [iSN] = 3.30556e-01; + inject_pathway_props->gas_metal_nuclide_yields.Mg[iSN] = 1.86824e-04; + inject_pathway_props->gas_metal_nuclide_yields.Al[iSN] = 1.97017e-07; + inject_pathway_props->gas_metal_nuclide_yields.Si[iSN] = 1.30184e-05; + inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 0.00000e+00; + inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 8.90341e-06; my_rates->SN0_fFeM [iSN] = 6.31648e-26; my_rates->SN0_fMg2SiO4 [iSN] = 2.06081e-16; @@ -2629,21 +2647,24 @@ int calc_rates_dust_F15(int iSN, chemistry_data *my_chemistry, chemistry_data_st int NTd, Nmom; int iTd, imom, itab0, itab; - my_rates->SN0_XC [iSN] = 6.46299e-01; - my_rates->SN0_XO [iSN] = 3.53548e-01; - my_rates->SN0_XMg[iSN] = 1.29204e-04; - my_rates->SN0_XAl[iSN] = 2.22729e-07; - my_rates->SN0_XSi[iSN] = 1.32242e-05; - my_rates->SN0_XS [iSN] = 0.00000e+00; - my_rates->SN0_XFe[iSN] = 9.66658e-06; - - my_rates->SN0_fC [iSN] = 4.57071e-01; - my_rates->SN0_fO [iSN] = 3.53548e-01; - my_rates->SN0_fMg[iSN] = 1.29204e-04; - my_rates->SN0_fAl[iSN] = 2.22729e-07; - my_rates->SN0_fSi[iSN] = 1.32242e-05; - my_rates->SN0_fS [iSN] = 0.00000e+00; - my_rates->SN0_fFe[iSN] = 9.66658e-06; + grackle::impl::GrainMetalInjectPathways* inject_pathway_props + = my_rates->opaque_storage->inject_pathway_props; + + inject_pathway_props->total_metal_nuclide_yields.C [iSN] = 6.46299e-01; + inject_pathway_props->total_metal_nuclide_yields.O [iSN] = 3.53548e-01; + inject_pathway_props->total_metal_nuclide_yields.Mg[iSN] = 1.29204e-04; + inject_pathway_props->total_metal_nuclide_yields.Al[iSN] = 2.22729e-07; + inject_pathway_props->total_metal_nuclide_yields.Si[iSN] = 1.32242e-05; + inject_pathway_props->total_metal_nuclide_yields.S [iSN] = 0.00000e+00; + inject_pathway_props->total_metal_nuclide_yields.Fe[iSN] = 9.66658e-06; + + inject_pathway_props->gas_metal_nuclide_yields.C [iSN] = 4.57071e-01; + inject_pathway_props->gas_metal_nuclide_yields.O [iSN] = 3.53548e-01; + inject_pathway_props->gas_metal_nuclide_yields.Mg[iSN] = 1.29204e-04; + inject_pathway_props->gas_metal_nuclide_yields.Al[iSN] = 2.22729e-07; + inject_pathway_props->gas_metal_nuclide_yields.Si[iSN] = 1.32242e-05; + inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 0.00000e+00; + inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 9.66658e-06; my_rates->SN0_fFeM [iSN] = 1.53361e-25; my_rates->SN0_fMg2SiO4 [iSN] = 1.56864e-15; @@ -2966,21 +2987,24 @@ int calc_rates_dust_F50(int iSN, chemistry_data *my_chemistry, chemistry_data_st int NTd, Nmom; int iTd, imom, itab0, itab; - my_rates->SN0_XC [iSN] = 2.79167e-01; - my_rates->SN0_XO [iSN] = 7.20575e-01; - my_rates->SN0_XMg[iSN] = 2.49794e-04; - my_rates->SN0_XAl[iSN] = 1.66468e-08; - my_rates->SN0_XSi[iSN] = 4.01099e-06; - my_rates->SN0_XS [iSN] = 0.00000e+00; - my_rates->SN0_XFe[iSN] = 4.15804e-06; - - my_rates->SN0_fC [iSN] = 2.79057e-01; - my_rates->SN0_fO [iSN] = 7.20575e-01; - my_rates->SN0_fMg[iSN] = 2.49793e-04; - my_rates->SN0_fAl[iSN] = 1.66468e-08; - my_rates->SN0_fSi[iSN] = 4.01058e-06; - my_rates->SN0_fS [iSN] = 0.00000e+00; - my_rates->SN0_fFe[iSN] = 4.15804e-06; + grackle::impl::GrainMetalInjectPathways* inject_pathway_props + = my_rates->opaque_storage->inject_pathway_props; + + inject_pathway_props->total_metal_nuclide_yields.C [iSN] = 2.79167e-01; + inject_pathway_props->total_metal_nuclide_yields.O [iSN] = 7.20575e-01; + inject_pathway_props->total_metal_nuclide_yields.Mg[iSN] = 2.49794e-04; + inject_pathway_props->total_metal_nuclide_yields.Al[iSN] = 1.66468e-08; + inject_pathway_props->total_metal_nuclide_yields.Si[iSN] = 4.01099e-06; + inject_pathway_props->total_metal_nuclide_yields.S [iSN] = 0.00000e+00; + inject_pathway_props->total_metal_nuclide_yields.Fe[iSN] = 4.15804e-06; + + inject_pathway_props->gas_metal_nuclide_yields.C [iSN] = 2.79057e-01; + inject_pathway_props->gas_metal_nuclide_yields.O [iSN] = 7.20575e-01; + inject_pathway_props->gas_metal_nuclide_yields.Mg[iSN] = 2.49793e-04; + inject_pathway_props->gas_metal_nuclide_yields.Al[iSN] = 1.66468e-08; + inject_pathway_props->gas_metal_nuclide_yields.Si[iSN] = 4.01058e-06; + inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 0.00000e+00; + inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 4.15804e-06; my_rates->SN0_fFeM [iSN] = 2.33171e-24; my_rates->SN0_fMg2SiO4 [iSN] = 2.62486e-10; @@ -3303,21 +3327,24 @@ int calc_rates_dust_F80(int iSN, chemistry_data *my_chemistry, chemistry_data_st int NTd, Nmom; int iTd, imom, itab0, itab; - my_rates->SN0_XC [iSN] = 2.52563e-01; - my_rates->SN0_XO [iSN] = 7.46061e-01; - my_rates->SN0_XMg[iSN] = 1.36917e-03; - my_rates->SN0_XAl[iSN] = 1.55602e-08; - my_rates->SN0_XSi[iSN] = 3.63906e-06; - my_rates->SN0_XS [iSN] = 0.00000e+00; - my_rates->SN0_XFe[iSN] = 2.43915e-06; - - my_rates->SN0_fC [iSN] = 2.43883e-01; - my_rates->SN0_fO [iSN] = 7.46061e-01; - my_rates->SN0_fMg[iSN] = 1.36917e-03; - my_rates->SN0_fAl[iSN] = 1.55602e-08; - my_rates->SN0_fSi[iSN] = 3.63906e-06; - my_rates->SN0_fS [iSN] = 0.00000e+00; - my_rates->SN0_fFe[iSN] = 2.43915e-06; + grackle::impl::GrainMetalInjectPathways* inject_pathway_props + = my_rates->opaque_storage->inject_pathway_props; + + inject_pathway_props->total_metal_nuclide_yields.C [iSN] = 2.52563e-01; + inject_pathway_props->total_metal_nuclide_yields.O [iSN] = 7.46061e-01; + inject_pathway_props->total_metal_nuclide_yields.Mg[iSN] = 1.36917e-03; + inject_pathway_props->total_metal_nuclide_yields.Al[iSN] = 1.55602e-08; + inject_pathway_props->total_metal_nuclide_yields.Si[iSN] = 3.63906e-06; + inject_pathway_props->total_metal_nuclide_yields.S [iSN] = 0.00000e+00; + inject_pathway_props->total_metal_nuclide_yields.Fe[iSN] = 2.43915e-06; + + inject_pathway_props->gas_metal_nuclide_yields.C [iSN] = 2.43883e-01; + inject_pathway_props->gas_metal_nuclide_yields.O [iSN] = 7.46061e-01; + inject_pathway_props->gas_metal_nuclide_yields.Mg[iSN] = 1.36917e-03; + inject_pathway_props->gas_metal_nuclide_yields.Al[iSN] = 1.55602e-08; + inject_pathway_props->gas_metal_nuclide_yields.Si[iSN] = 3.63906e-06; + inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 0.00000e+00; + inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 2.43915e-06; my_rates->SN0_fFeM [iSN] = 3.87590e-26; my_rates->SN0_fMg2SiO4 [iSN] = 2.36180e-13; @@ -3640,21 +3667,24 @@ int calc_rates_dust_P170(int iSN, chemistry_data *my_chemistry, chemistry_data_s int NTd, Nmom; int iTd, imom, itab0, itab; - my_rates->SN0_XC [iSN] = 5.29975e-02; - my_rates->SN0_XO [iSN] = 5.60864e-01; - my_rates->SN0_XMg[iSN] = 3.58367e-02; - my_rates->SN0_XAl[iSN] = 3.27680e-04; - my_rates->SN0_XSi[iSN] = 1.52750e-01; - my_rates->SN0_XS [iSN] = 8.06035e-02; - my_rates->SN0_XFe[iSN] = 5.29729e-02; - - my_rates->SN0_fC [iSN] = 5.29528e-02; - my_rates->SN0_fO [iSN] = 5.60799e-01; - my_rates->SN0_fMg[iSN] = 3.58366e-02; - my_rates->SN0_fAl[iSN] = 3.27680e-04; - my_rates->SN0_fSi[iSN] = 1.39585e-01; - my_rates->SN0_fS [iSN] = 8.06035e-02; - my_rates->SN0_fFe[iSN] = 5.29394e-02; + grackle::impl::GrainMetalInjectPathways* inject_pathway_props + = my_rates->opaque_storage->inject_pathway_props; + + inject_pathway_props->total_metal_nuclide_yields.C [iSN] = 5.29975e-02; + inject_pathway_props->total_metal_nuclide_yields.O [iSN] = 5.60864e-01; + inject_pathway_props->total_metal_nuclide_yields.Mg[iSN] = 3.58367e-02; + inject_pathway_props->total_metal_nuclide_yields.Al[iSN] = 3.27680e-04; + inject_pathway_props->total_metal_nuclide_yields.Si[iSN] = 1.52750e-01; + inject_pathway_props->total_metal_nuclide_yields.S [iSN] = 8.06035e-02; + inject_pathway_props->total_metal_nuclide_yields.Fe[iSN] = 5.29729e-02; + + inject_pathway_props->gas_metal_nuclide_yields.C [iSN] = 5.29528e-02; + inject_pathway_props->gas_metal_nuclide_yields.O [iSN] = 5.60799e-01; + inject_pathway_props->gas_metal_nuclide_yields.Mg[iSN] = 3.58366e-02; + inject_pathway_props->gas_metal_nuclide_yields.Al[iSN] = 3.27680e-04; + inject_pathway_props->gas_metal_nuclide_yields.Si[iSN] = 1.39585e-01; + inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 8.06035e-02; + inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 5.29394e-02; my_rates->SN0_fSiM [iSN] = 1.31079e-02; my_rates->SN0_fFeM [iSN] = 3.34688e-05; @@ -3977,21 +4007,24 @@ int calc_rates_dust_P200(int iSN, chemistry_data *my_chemistry, chemistry_data_s int NTd, Nmom; int iTd, imom, itab0, itab; - my_rates->SN0_XC [iSN] = 3.65050e-02; - my_rates->SN0_XO [iSN] = 4.88552e-01; - my_rates->SN0_XMg[iSN] = 2.69665e-02; - my_rates->SN0_XAl[iSN] = 1.36872e-04; - my_rates->SN0_XSi[iSN] = 1.87324e-01; - my_rates->SN0_XS [iSN] = 1.15582e-01; - my_rates->SN0_XFe[iSN] = 6.79294e-02; - - my_rates->SN0_fC [iSN] = 3.64677e-02; - my_rates->SN0_fO [iSN] = 4.88307e-01; - my_rates->SN0_fMg[iSN] = 2.69665e-02; - my_rates->SN0_fAl[iSN] = 1.36872e-04; - my_rates->SN0_fSi[iSN] = 1.87051e-01; - my_rates->SN0_fS [iSN] = 1.15582e-01; - my_rates->SN0_fFe[iSN] = 6.75026e-02; + grackle::impl::GrainMetalInjectPathways* inject_pathway_props + = my_rates->opaque_storage->inject_pathway_props; + + inject_pathway_props->total_metal_nuclide_yields.C [iSN] = 3.65050e-02; + inject_pathway_props->total_metal_nuclide_yields.O [iSN] = 4.88552e-01; + inject_pathway_props->total_metal_nuclide_yields.Mg[iSN] = 2.69665e-02; + inject_pathway_props->total_metal_nuclide_yields.Al[iSN] = 1.36872e-04; + inject_pathway_props->total_metal_nuclide_yields.Si[iSN] = 1.87324e-01; + inject_pathway_props->total_metal_nuclide_yields.S [iSN] = 1.15582e-01; + inject_pathway_props->total_metal_nuclide_yields.Fe[iSN] = 6.79294e-02; + + inject_pathway_props->gas_metal_nuclide_yields.C [iSN] = 3.64677e-02; + inject_pathway_props->gas_metal_nuclide_yields.O [iSN] = 4.88307e-01; + inject_pathway_props->gas_metal_nuclide_yields.Mg[iSN] = 2.69665e-02; + inject_pathway_props->gas_metal_nuclide_yields.Al[iSN] = 1.36872e-04; + inject_pathway_props->gas_metal_nuclide_yields.Si[iSN] = 1.87051e-01; + inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 1.15582e-01; + inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 6.75026e-02; my_rates->SN0_fSiM [iSN] = 5.90622e-05; my_rates->SN0_fFeM [iSN] = 4.26809e-04; @@ -4272,21 +4305,24 @@ int calc_rates_dust_Y19(int iSN, chemistry_data *my_chemistry, chemistry_data_st int NTd, Nmom; int iTd, imom, itab0, itab; - my_rates->SN0_XC [iSN] = 2.50000e-01; - my_rates->SN0_XO [iSN] = 2.93867e-01; - my_rates->SN0_XMg[iSN] = 6.00000e-02; - my_rates->SN0_XAl[iSN] = 2.85361e-03; - my_rates->SN0_XSi[iSN] = 7.00000e-02; - my_rates->SN0_XS [iSN] = 1.58191e-02; - my_rates->SN0_XFe[iSN] = 6.64078e-02; - - my_rates->SN0_fC [iSN] = 0.00000e+00; - my_rates->SN0_fO [iSN] = 1.73867e-01; - my_rates->SN0_fMg[iSN] = 0.00000e+00; - my_rates->SN0_fAl[iSN] = 2.85361e-03; - my_rates->SN0_fSi[iSN] = 0.00000e+00; - my_rates->SN0_fS [iSN] = 1.58191e-02; - my_rates->SN0_fFe[iSN] = 6.64078e-02; + grackle::impl::GrainMetalInjectPathways* inject_pathway_props + = my_rates->opaque_storage->inject_pathway_props; + + inject_pathway_props->total_metal_nuclide_yields.C [iSN] = 2.50000e-01; + inject_pathway_props->total_metal_nuclide_yields.O [iSN] = 2.93867e-01; + inject_pathway_props->total_metal_nuclide_yields.Mg[iSN] = 6.00000e-02; + inject_pathway_props->total_metal_nuclide_yields.Al[iSN] = 2.85361e-03; + inject_pathway_props->total_metal_nuclide_yields.Si[iSN] = 7.00000e-02; + inject_pathway_props->total_metal_nuclide_yields.S [iSN] = 1.58191e-02; + inject_pathway_props->total_metal_nuclide_yields.Fe[iSN] = 6.64078e-02; + + inject_pathway_props->gas_metal_nuclide_yields.C [iSN] = 0.00000e+00; + inject_pathway_props->gas_metal_nuclide_yields.O [iSN] = 1.73867e-01; + inject_pathway_props->gas_metal_nuclide_yields.Mg[iSN] = 0.00000e+00; + inject_pathway_props->gas_metal_nuclide_yields.Al[iSN] = 2.85361e-03; + inject_pathway_props->gas_metal_nuclide_yields.Si[iSN] = 0.00000e+00; + inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 1.58191e-02; + inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 6.64078e-02; my_rates->SN0_fMgSiO3 [iSN] = 2.50000e-01; my_rates->SN0_fAC [iSN] = 2.50000e-01; From e67ee1b6b5b0bb148878aac17777204e30ac19ce Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Thu, 6 Nov 2025 13:42:19 -0500 Subject: [PATCH 014/175] transition to using grain_yields stored within GrainMetalInjectPathways --- src/clib/fortran_func_wrappers.hpp | 19 ++- src/clib/initialize_chemistry_data.cpp | 41 ++--- src/clib/initialize_dust_yields.cpp | 226 +++++++++++-------------- src/include/grackle_chemistry_data.h | 3 - 4 files changed, 128 insertions(+), 161 deletions(-) diff --git a/src/clib/fortran_func_wrappers.hpp b/src/clib/fortran_func_wrappers.hpp index e311723a3..cd561e8f5 100644 --- a/src/clib/fortran_func_wrappers.hpp +++ b/src/clib/fortran_func_wrappers.hpp @@ -25,10 +25,12 @@ #include "grackle.h" #include "dust_props.hpp" #include "fortran_func_decls.h" +#include "grain_metal_inject_pathways.hpp" #include "index_helper.h" #include "internal_types.hpp" #include "internal_units.h" #include "LUT.hpp" +#include "opaque_storage.hpp" #include "utils-cpp.hpp" // callers of these functions are generally expected to locally shorten the @@ -107,10 +109,19 @@ inline void calc_grain_size_increment_1d ( my_fields->fsn13_metal_density, my_fields->fsn15_metal_density, my_fields->fsn50_metal_density, my_fields->fsn80_metal_density, my_fields->pisn170_metal_density, my_fields->pisn200_metal_density, my_fields->y19_metal_density, &my_rates->SN0_N, - my_rates->SN0_fSiM, my_rates->SN0_fFeM, my_rates->SN0_fMg2SiO4, my_rates->SN0_fMgSiO3, - my_rates->SN0_fFe3O4, my_rates->SN0_fAC, my_rates->SN0_fSiO2D, my_rates->SN0_fMgO, - my_rates->SN0_fFeS, my_rates->SN0_fAl2O3, - my_rates->SN0_freforg, my_rates->SN0_fvolorg, my_rates->SN0_fH2Oice, + my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust], + my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust], + my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust], + my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust], + my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Fe3O4_dust], + my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust], + my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust], + my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgO_dust], + my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeS_dust], + my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Al2O3_dust], + my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::ref_org_dust], + my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::vol_org_dust], + my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::H2O_ice_dust], my_rates->SN0_r0SiM, my_rates->SN0_r0FeM, my_rates->SN0_r0Mg2SiO4, my_rates->SN0_r0MgSiO3, my_rates->SN0_r0Fe3O4, my_rates->SN0_r0AC, my_rates->SN0_r0SiO2D, my_rates->SN0_r0MgO, my_rates->SN0_r0FeS, my_rates->SN0_r0Al2O3, diff --git a/src/clib/initialize_chemistry_data.cpp b/src/clib/initialize_chemistry_data.cpp index 1968feb8f..273b317c1 100644 --- a/src/clib/initialize_chemistry_data.cpp +++ b/src/clib/initialize_chemistry_data.cpp @@ -154,33 +154,20 @@ static void initialize_empty_chemistry_data_storage_struct(chemistry_data_storag my_rates->gr_dT = 0.; my_rates->gr_Td = NULL; my_rates->SN0_N = 0; - my_rates->SN0_XC = NULL; - my_rates->SN0_XO = NULL; - my_rates->SN0_XMg = NULL; - my_rates->SN0_XAl = NULL; - my_rates->SN0_XSi = NULL; - my_rates->SN0_XS = NULL; - my_rates->SN0_XFe = NULL; - my_rates->SN0_fC = NULL; - my_rates->SN0_fO = NULL; - my_rates->SN0_fMg = NULL; - my_rates->SN0_fAl = NULL; - my_rates->SN0_fSi = NULL; - my_rates->SN0_fS = NULL; - my_rates->SN0_fFe = NULL; - my_rates->SN0_fSiM = NULL; - my_rates->SN0_fFeM = NULL; - my_rates->SN0_fMg2SiO4 = NULL; - my_rates->SN0_fMgSiO3 = NULL; - my_rates->SN0_fFe3O4 = NULL; - my_rates->SN0_fAC = NULL; - my_rates->SN0_fSiO2D = NULL; - my_rates->SN0_fMgO = NULL; - my_rates->SN0_fFeS = NULL; - my_rates->SN0_fAl2O3 = NULL; - my_rates->SN0_freforg = NULL; - my_rates->SN0_fvolorg = NULL; - my_rates->SN0_fH2Oice = NULL; + my_rates->SN0_XC = nullptr; + my_rates->SN0_XO = nullptr; + my_rates->SN0_XMg = nullptr; + my_rates->SN0_XAl = nullptr; + my_rates->SN0_XSi = nullptr; + my_rates->SN0_XS = nullptr; + my_rates->SN0_XFe = nullptr; + my_rates->SN0_fC = nullptr; + my_rates->SN0_fO = nullptr; + my_rates->SN0_fMg = nullptr; + my_rates->SN0_fAl = nullptr; + my_rates->SN0_fSi = nullptr; + my_rates->SN0_fS = nullptr; + my_rates->SN0_fFe = nullptr; my_rates->SN0_r0SiM = NULL; my_rates->SN0_r0FeM = NULL; my_rates->SN0_r0Mg2SiO4 = NULL; diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index 1eb709dce..dfd7c0d78 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -16,6 +16,7 @@ #include "grackle_macros.h" #include "grackle_chemistry_data.h" #include "initialize_dust_yields.hpp" // forward declarations +#include "LUT.hpp" #include "opaque_storage.hpp" // forward declare some functions @@ -84,21 +85,6 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, my_rates->SN0_fS = inject_pathway_props->gas_metal_nuclide_yields.S; my_rates->SN0_fFe = inject_pathway_props->gas_metal_nuclide_yields.Fe; - // we can simply delete these when we have the oportunity - my_rates->SN0_fSiM = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_fFeM = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_fMg2SiO4 = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_fMgSiO3 = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_fFe3O4 = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_fAC = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_fSiO2D = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_fMgO = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_fFeS = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_fAl2O3 = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_freforg = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_fvolorg = (double*)malloc(NSN * sizeof(double)); - my_rates->SN0_fH2Oice = (double*)malloc(NSN * sizeof(double)); - for(int iSN = 0; iSN < NSN; iSN++) { inject_pathway_props->total_metal_nuclide_yields.C [iSN] = 0.0; inject_pathway_props->total_metal_nuclide_yields.O [iSN] = 0.0; @@ -116,19 +102,19 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 0.0; inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 0.0; - my_rates->SN0_fSiM [iSN] = 0.0; - my_rates->SN0_fFeM [iSN] = 0.0; - my_rates->SN0_fMg2SiO4 [iSN] = 0.0; - my_rates->SN0_fMgSiO3 [iSN] = 0.0; - my_rates->SN0_fFe3O4 [iSN] = 0.0; - my_rates->SN0_fAC [iSN] = 0.0; - my_rates->SN0_fSiO2D [iSN] = 0.0; - my_rates->SN0_fMgO [iSN] = 0.0; - my_rates->SN0_fFeS [iSN] = 0.0; - my_rates->SN0_fAl2O3 [iSN] = 0.0; - my_rates->SN0_freforg [iSN] = 0.0; - my_rates->SN0_fvolorg [iSN] = 0.0; - my_rates->SN0_fH2Oice [iSN] = 0.0; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust] [iSN] = 0.0; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 0.0; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 0.0; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN] = 0.0; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Fe3O4_dust] [iSN] = 0.0; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust] [iSN] = 0.0; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust] [iSN] = 0.0; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgO_dust] [iSN] = 0.0; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeS_dust] [iSN] = 0.0; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Al2O3_dust] [iSN] = 0.0; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::ref_org_dust] [iSN] = 0.0; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::vol_org_dust] [iSN] = 0.0; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::H2O_ice_dust] [iSN] = 0.0; } my_rates->SN0_r0SiM = (double*)malloc(NSN * 3 * sizeof(double)); @@ -258,20 +244,6 @@ int grackle::impl::free_dust_yields(chemistry_data *my_chemistry, my_rates->SN0_fS = nullptr; my_rates->SN0_fFe = nullptr; - GRACKLE_FREE(my_rates->SN0_fSiM); - GRACKLE_FREE(my_rates->SN0_fFeM); - GRACKLE_FREE(my_rates->SN0_fMg2SiO4); - GRACKLE_FREE(my_rates->SN0_fMgSiO3); - GRACKLE_FREE(my_rates->SN0_fFe3O4); - GRACKLE_FREE(my_rates->SN0_fAC); - GRACKLE_FREE(my_rates->SN0_fSiO2D); - GRACKLE_FREE(my_rates->SN0_fMgO); - GRACKLE_FREE(my_rates->SN0_fFeS); - GRACKLE_FREE(my_rates->SN0_fAl2O3); - GRACKLE_FREE(my_rates->SN0_freforg); - GRACKLE_FREE(my_rates->SN0_fvolorg); - GRACKLE_FREE(my_rates->SN0_fH2Oice); - GRACKLE_FREE(my_rates->SN0_r0SiM); GRACKLE_FREE(my_rates->SN0_r0FeM); GRACKLE_FREE(my_rates->SN0_r0Mg2SiO4); @@ -332,13 +304,13 @@ int calc_rates_dust_loc(int iSN, chemistry_data *my_chemistry, chemistry_data_st inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 0.00000e+00; inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 1.66568e-04; - my_rates->SN0_fFeM [iSN] = 1.35403e-02; - my_rates->SN0_fMg2SiO4 [iSN] = 1.36165e-01; - my_rates->SN0_fMgSiO3 [iSN] = 3.84003e-02; - my_rates->SN0_fFeS [iSN] = 3.04389e-02; - my_rates->SN0_freforg [iSN] = 1.86114e-01; - my_rates->SN0_fvolorg [iSN] = 3.81956e-02; - my_rates->SN0_fH2Oice [iSN] = 6.33011e-02; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 1.35403e-02; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust][iSN] = 1.36165e-01; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN] = 3.84003e-02; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeS_dust] [iSN] = 3.04389e-02; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::ref_org_dust][iSN] = 1.86114e-01; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::vol_org_dust][iSN] = 3.81956e-02; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::H2O_ice_dust][iSN] = 6.33011e-02; itab0 = 3 * iSN; my_rates->SN0_r0FeM [itab0 + 0] = 8.33039e-07; @@ -672,14 +644,14 @@ int calc_rates_dust_C13(int iSN, chemistry_data *my_chemistry, chemistry_data_st inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 3.40903e-02; inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 7.22586e-02; - my_rates->SN0_fSiM [iSN] = 1.65746e-02; - my_rates->SN0_fFeM [iSN] = 2.39849e-02; - my_rates->SN0_fMg2SiO4 [iSN] = 8.69522e-04; - my_rates->SN0_fMgSiO3 [iSN] = 2.87802e-06; - my_rates->SN0_fAC [iSN] = 4.85826e-02; - my_rates->SN0_fSiO2D [iSN] = 2.52534e-03; - my_rates->SN0_fMgO [iSN] = 1.28672e-05; - my_rates->SN0_fFeS [iSN] = 2.09730e-06; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust] [iSN] = 1.65746e-02; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 2.39849e-02; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 8.69522e-04; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN] = 2.87802e-06; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust] [iSN] = 4.85826e-02; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust] [iSN] = 2.52534e-03; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgO_dust] [iSN] = 1.28672e-05; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeS_dust] [iSN] = 2.09730e-06; itab0 = 3 * iSN; my_rates->SN0_r0SiM [itab0 + 0] = 1.68557e-06; @@ -1054,15 +1026,15 @@ int calc_rates_dust_C20(int iSN, chemistry_data *my_chemistry, chemistry_data_st inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 6.02018e-02; inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 2.69505e-02; - my_rates->SN0_fSiM [iSN] = 3.44388e-02; - my_rates->SN0_fFeM [iSN] = 3.77223e-03; - my_rates->SN0_fMg2SiO4 [iSN] = 1.90086e-03; - my_rates->SN0_fMgSiO3 [iSN] = 2.57266e-06; - my_rates->SN0_fAC [iSN] = 1.27270e-02; - my_rates->SN0_fSiO2D [iSN] = 1.65484e-03; - my_rates->SN0_fMgO [iSN] = 9.48713e-04; - my_rates->SN0_fFeS [iSN] = 5.23050e-05; - my_rates->SN0_fAl2O3 [iSN] = 1.31693e-29; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust] [iSN] = 3.44388e-02; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 3.77223e-03; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 1.90086e-03; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN] = 2.57266e-06; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust] [iSN] = 1.27270e-02; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust] [iSN] = 1.65484e-03; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgO_dust] [iSN] = 9.48713e-04; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeS_dust] [iSN] = 5.23050e-05; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Al2O3_dust] [iSN] = 1.31693e-29; itab0 = 3 * iSN; my_rates->SN0_r0SiM [itab0 + 0] = 1.24861e-05; @@ -1478,15 +1450,15 @@ int calc_rates_dust_C25(int iSN, chemistry_data *my_chemistry, chemistry_data_st inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 4.72556e-02; inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 1.46955e-02; - my_rates->SN0_fSiM [iSN] = 3.83373e-02; - my_rates->SN0_fFeM [iSN] = 4.88366e-03; - my_rates->SN0_fMg2SiO4 [iSN] = 1.68068e-02; - my_rates->SN0_fMgSiO3 [iSN] = 2.49736e-05; - my_rates->SN0_fAC [iSN] = 4.13961e-02; - my_rates->SN0_fSiO2D [iSN] = 1.46546e-02; - my_rates->SN0_fMgO [iSN] = 1.09289e-03; - my_rates->SN0_fFeS [iSN] = 3.77935e-04; - my_rates->SN0_fAl2O3 [iSN] = 1.65550e-31; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust] [iSN] = 3.83373e-02; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 4.88366e-03; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 1.68068e-02; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN] = 2.49736e-05; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust] [iSN] = 4.13961e-02; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust] [iSN] = 1.46546e-02; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgO_dust] [iSN] = 1.09289e-03; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeS_dust] [iSN] = 3.77935e-04; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Al2O3_dust] [iSN] = 1.65550e-31; itab0 = 3 * iSN; my_rates->SN0_r0SiM [itab0 + 0] = 1.72153e-05; @@ -1902,15 +1874,15 @@ int calc_rates_dust_C30(int iSN, chemistry_data *my_chemistry, chemistry_data_st inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 3.68812e-02; inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 1.23641e-02; - my_rates->SN0_fSiM [iSN] = 2.91389e-02; - my_rates->SN0_fFeM [iSN] = 1.93065e-03; - my_rates->SN0_fMg2SiO4 [iSN] = 7.73041e-04; - my_rates->SN0_fMgSiO3 [iSN] = 4.17376e-06; - my_rates->SN0_fAC [iSN] = 6.19235e-04; - my_rates->SN0_fSiO2D [iSN] = 5.27016e-03; - my_rates->SN0_fMgO [iSN] = 1.33978e-03; - my_rates->SN0_fFeS [iSN] = 4.51744e-04; - my_rates->SN0_fAl2O3 [iSN] = 5.79251e-12; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust] [iSN] = 2.91389e-02; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 1.93065e-03; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 7.73041e-04; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN] = 4.17376e-06; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust] [iSN] = 6.19235e-04; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust] [iSN] = 5.27016e-03; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgO_dust] [iSN] = 1.33978e-03; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeS_dust] [iSN] = 4.51744e-04; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Al2O3_dust] [iSN] = 5.79251e-12; itab0 = 3 * iSN; my_rates->SN0_r0SiM [itab0 + 0] = 2.56305e-05; @@ -2326,13 +2298,13 @@ int calc_rates_dust_F13(int iSN, chemistry_data *my_chemistry, chemistry_data_st inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 0.00000e+00; inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 8.90341e-06; - my_rates->SN0_fFeM [iSN] = 6.31648e-26; - my_rates->SN0_fMg2SiO4 [iSN] = 2.06081e-16; - my_rates->SN0_fMgSiO3 [iSN] = 3.19262e-15; - my_rates->SN0_fFe3O4 [iSN] = 4.37192e-15; - my_rates->SN0_fAC [iSN] = 1.75542e-01; - my_rates->SN0_fSiO2D [iSN] = 1.92019e-16; - my_rates->SN0_fAl2O3 [iSN] = 6.23283e-17; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 6.31648e-26; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 2.06081e-16; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN] = 3.19262e-15; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Fe3O4_dust] [iSN] = 4.37192e-15; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust] [iSN] = 1.75542e-01; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust] [iSN] = 1.92019e-16; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Al2O3_dust] [iSN] = 6.23283e-17; itab0 = 3 * iSN; my_rates->SN0_r0FeM [itab0 + 0] = 4.02937e-08; @@ -2666,13 +2638,13 @@ int calc_rates_dust_F15(int iSN, chemistry_data *my_chemistry, chemistry_data_st inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 0.00000e+00; inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 9.66658e-06; - my_rates->SN0_fFeM [iSN] = 1.53361e-25; - my_rates->SN0_fMg2SiO4 [iSN] = 1.56864e-15; - my_rates->SN0_fMgSiO3 [iSN] = 2.13810e-14; - my_rates->SN0_fFe3O4 [iSN] = 1.22287e-14; - my_rates->SN0_fAC [iSN] = 1.89229e-01; - my_rates->SN0_fSiO2D [iSN] = 1.47463e-15; - my_rates->SN0_fAl2O3 [iSN] = 2.15191e-16; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 1.53361e-25; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 1.56864e-15; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN] = 2.13810e-14; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Fe3O4_dust] [iSN] = 1.22287e-14; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust] [iSN] = 1.89229e-01; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust] [iSN] = 1.47463e-15; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Al2O3_dust] [iSN] = 2.15191e-16; itab0 = 3 * iSN; my_rates->SN0_r0FeM [itab0 + 0] = 4.02634e-08; @@ -3006,13 +2978,13 @@ int calc_rates_dust_F50(int iSN, chemistry_data *my_chemistry, chemistry_data_st inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 0.00000e+00; inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 4.15804e-06; - my_rates->SN0_fFeM [iSN] = 2.33171e-24; - my_rates->SN0_fMg2SiO4 [iSN] = 2.62486e-10; - my_rates->SN0_fMgSiO3 [iSN] = 1.21446e-09; - my_rates->SN0_fFe3O4 [iSN] = 2.41799e-13; - my_rates->SN0_fAC [iSN] = 1.09849e-04; - my_rates->SN0_fSiO2D [iSN] = 3.41863e-11; - my_rates->SN0_fAl2O3 [iSN] = 2.53950e-17; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 2.33171e-24; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 2.62486e-10; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN] = 1.21446e-09; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Fe3O4_dust] [iSN] = 2.41799e-13; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust] [iSN] = 1.09849e-04; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust] [iSN] = 3.41863e-11; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Al2O3_dust] [iSN] = 2.53950e-17; itab0 = 3 * iSN; my_rates->SN0_r0FeM [itab0 + 0] = 4.02891e-08; @@ -3346,13 +3318,13 @@ int calc_rates_dust_F80(int iSN, chemistry_data *my_chemistry, chemistry_data_st inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 0.00000e+00; inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 2.43915e-06; - my_rates->SN0_fFeM [iSN] = 3.87590e-26; - my_rates->SN0_fMg2SiO4 [iSN] = 2.36180e-13; - my_rates->SN0_fMgSiO3 [iSN] = 2.48190e-12; - my_rates->SN0_fFe3O4 [iSN] = 3.01120e-15; - my_rates->SN0_fAC [iSN] = 8.68025e-03; - my_rates->SN0_fSiO2D [iSN] = 3.70132e-14; - my_rates->SN0_fAl2O3 [iSN] = 3.77811e-18; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 3.87590e-26; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 2.36180e-13; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN] = 2.48190e-12; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Fe3O4_dust] [iSN] = 3.01120e-15; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust] [iSN] = 8.68025e-03; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust] [iSN] = 3.70132e-14; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Al2O3_dust] [iSN] = 3.77811e-18; itab0 = 3 * iSN; my_rates->SN0_r0FeM [itab0 + 0] = 4.02891e-08; @@ -3686,13 +3658,13 @@ int calc_rates_dust_P170(int iSN, chemistry_data *my_chemistry, chemistry_data_s inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 8.06035e-02; inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 5.29394e-02; - my_rates->SN0_fSiM [iSN] = 1.31079e-02; - my_rates->SN0_fFeM [iSN] = 3.34688e-05; - my_rates->SN0_fMg2SiO4 [iSN] = 2.84952e-13; - my_rates->SN0_fMgSiO3 [iSN] = 7.72302e-25; - my_rates->SN0_fAC [iSN] = 4.47758e-05; - my_rates->SN0_fSiO2D [iSN] = 1.23405e-04; - my_rates->SN0_fMgO [iSN] = 1.41247e-07; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust] [iSN] = 1.31079e-02; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 3.34688e-05; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 2.84952e-13; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN] = 7.72302e-25; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust] [iSN] = 4.47758e-05; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust] [iSN] = 1.23405e-04; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgO_dust] [iSN] = 1.41247e-07; itab0 = 3 * iSN; my_rates->SN0_r0SiM [itab0 + 0] = 2.72050e-06; @@ -4026,12 +3998,12 @@ int calc_rates_dust_P200(int iSN, chemistry_data *my_chemistry, chemistry_data_s inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 1.15582e-01; inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 6.75026e-02; - my_rates->SN0_fSiM [iSN] = 5.90622e-05; - my_rates->SN0_fFeM [iSN] = 4.26809e-04; - my_rates->SN0_fMg2SiO4 [iSN] = 4.08246e-15; - my_rates->SN0_fAC [iSN] = 3.72287e-05; - my_rates->SN0_fSiO2D [iSN] = 4.59330e-04; - my_rates->SN0_fMgO [iSN] = 5.38389e-09; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust] [iSN] = 5.90622e-05; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 4.26809e-04; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 4.08246e-15; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust] [iSN] = 3.72287e-05; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust] [iSN] = 4.59330e-04; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgO_dust] [iSN] = 5.38389e-09; itab0 = 3 * iSN; my_rates->SN0_r0SiM [itab0 + 0] = 8.86269e-07; @@ -4324,8 +4296,8 @@ int calc_rates_dust_Y19(int iSN, chemistry_data *my_chemistry, chemistry_data_st inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 1.58191e-02; inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 6.64078e-02; - my_rates->SN0_fMgSiO3 [iSN] = 2.50000e-01; - my_rates->SN0_fAC [iSN] = 2.50000e-01; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust][iSN] = 2.50000e-01; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust] [iSN] = 2.50000e-01; itab0 = 3 * iSN; my_rates->SN0_r0MgSiO3 [itab0 + 0] = 1.00000e-05; diff --git a/src/include/grackle_chemistry_data.h b/src/include/grackle_chemistry_data.h index 82da80112..d34a1e323 100644 --- a/src/include/grackle_chemistry_data.h +++ b/src/include/grackle_chemistry_data.h @@ -611,9 +611,6 @@ typedef struct int SN0_N; double *SN0_XC , *SN0_XO , *SN0_XMg, *SN0_XAl, *SN0_XSi, *SN0_XS , *SN0_XFe; double *SN0_fC , *SN0_fO , *SN0_fMg, *SN0_fAl, *SN0_fSi, *SN0_fS , *SN0_fFe; - double *SN0_fSiM, *SN0_fFeM, *SN0_fMg2SiO4, *SN0_fMgSiO3, *SN0_fFe3O4 - , *SN0_fAC, *SN0_fSiO2D, *SN0_fMgO, *SN0_fFeS, *SN0_fAl2O3 - , *SN0_freforg , *SN0_fvolorg , *SN0_fH2Oice; double *SN0_r0SiM, *SN0_r0FeM, *SN0_r0Mg2SiO4, *SN0_r0MgSiO3, *SN0_r0Fe3O4 , *SN0_r0AC, *SN0_r0SiO2D, *SN0_r0MgO, *SN0_r0FeS, *SN0_r0Al2O3 , *SN0_r0reforg , *SN0_r0volorg , *SN0_r0H2Oice; From 40031e67de7093add80c4c327b940b791d63631f Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 12 Nov 2025 08:11:55 -0500 Subject: [PATCH 015/175] calc_grain_size_increment_species_1d: comment the code and add a very minor tweak --- src/clib/calc_grain_size_increment_1d.F | 133 ++++++++++++++++++++---- 1 file changed, 112 insertions(+), 21 deletions(-) diff --git a/src/clib/calc_grain_size_increment_1d.F b/src/clib/calc_grain_size_increment_1d.F index 7dd050d0b..530035ac1 100644 --- a/src/clib/calc_grain_size_increment_1d.F +++ b/src/clib/calc_grain_size_increment_1d.F @@ -444,7 +444,17 @@ subroutine calc_grain_size_increment_species_1d( & , gr_N, gr_Size, gr_dT, gr_Td, SN_kp0sp & ) - +! +! Calculates properties that are derived from the grain size increment +! for a single grain species. +! +! NOTE: the subroutine's name should be more descriptive +! +! INPUTS: +! ssp - the density of an individual dust grain species. At the time +! of writing it has units of g/cm^3 +! +! implicit NONE #include "grackle_fortran_types.def" @@ -469,6 +479,7 @@ subroutine calc_grain_size_increment_species_1d( ! local integer i real*8 coef0, coef1, coef2, coef3 + real*8 dsp_inject_sum real*8 dsp0, SN_sgsp, SN_kpsp real*8 SN_dsp0(SN0_N), SN_nsp0(SN0_N) real*8 drsp(in) @@ -496,6 +507,10 @@ subroutine calc_grain_size_increment_species_1d( !!!!!!!!!!!!! !!!! if( dsp(i,j,k) .gt. 1.d-15*d(i,j,k) ) then !!!!!!!!!!!!! + +! Step 1: compute the total mass density of the current grain species +! that was injected (by summing the amounts injected by each +! injection pathway) do iSN = 1, nSN if(SN_fsp(iSN) .gt. 0.d0) then SN_dsp0(iSN) = SN_fsp(iSN) * SN_metal(i, iSN) @@ -504,63 +519,139 @@ subroutine calc_grain_size_increment_species_1d( endif enddo +! Step 2: Compute the size increment for the grain species +! +! Let's go into detail: +! - todo: maybe we move most of this description into the docstring +! and possibly move some of it into the narrative documentation +! - let's define some notation: +! - for some time t, let φ(r,t) denote the grain species's +! differential size distribution at time t, ρ(t) denote the grain +! species's mass density, and n(t) denote it number density. +! - we define (t) as the `p`th order moment of `φ(r,t)`. In +! other words, ⱼ = ∫ rᵖ φⱼ dr, where the integral is taken +! from 0 to infinity +! - for additional context: +! - φ(r,t) is normalized such that the p=0 moment is 1 +! - n(t)*φ(r,t) specifies the number density of the grain with +! radii between r and r+dr +! - given the mass density of a single grain, ζ, the variables +! are related via ρ(t) = (4π/3) ζ n(t) (t). +! - we define Φⱼ(r) as the grain species's initial differential +! size distribution when distributed by injection pathway j. +! - for notational convenience, we define ⱼ as the `p`th order +! moment of `Φⱼ(r)` +! - NOTE: we don't explicitly track φ(r,t) or Φⱼ(r), instead we +! track moments +! - The underlying model assumes that all injection pathways inject +! the grain species at a single time t_inj. +! - In other words: φ(r,t_inj) = (∑ⱼ nⱼ Φⱼ(r)) / (∑ⱼ nⱼ) +! - Consequently: +! (t_inj) = (∑ⱼ nⱼ ⱼ) / (∑ⱼ nⱼ) +! OR +! (t_inj) = (∑ⱼ ⱼ ρⱼ/ⱼ) / (∑ⱼ ρⱼ/ⱼ) +! - Furthermore we assume that: +! - grains can only be created via injection (i.e. the number +! density of the grain species is frozen) +! - φ(r,t) can't be deformed. However it can be translated (which +! is exactly what happens when grains undergo growth). +! - Thus, when we model growth, φ(r,t) = φ(r - δr(t), t_inj) where +! we call δr(t) the "size increment" +! +! Anybody reading this might notice that several limitations to this +! model. This is discussed in detail in GH Issue 444 (the description +! should be made part of the narrative docs + if(igrgr .eq. 0) then +! the model is constructed such that δr(t) = 0 if we aren't +! modelling grain growth drsp(i) = 0.d0 else -!!! TEST !!!!!! TEST !!!!!! TEST !!!!!! TEST !!!!!! TEST !!!!!! TEST !!! -!!! dsp(i,j,k) = 3.d0 * dsp(i,j,k) -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -! calculate grain size increment from the conservation of mass - - coef0 = 0.d0 +! here we calculate the current grain size increment, δr(t), using +! conservation of grain number (i.e. grains are only created via +! injection pathways) +! - recall that to model growth we effectively assume that each +! occurrence of a grain species was injected at a single time, t_inj +! - conservation of grain number tells us that +! (t) = (t_inj) * ρ(t) / ρ(t_inj), +! where ρ(t_inj) = ∑ⱼ ρⱼ +! - Equation A3 of Chiaki & Wise 2019 indicates that the grain-size +! increment is the root of the following cubic equation +! [(t_inj) - (t)] + [3 * (t_inj)] * δr(t) +! + [3 * (t_inj)] * δr²(t) + δr³(t) = 0 +! - Let's rewrite the expression ((t_inj) - (t)). First, +! let's plug in the equation from conservation of grain number: +! (t_inj) - (t) = (t_inj) * [ 1 - (ρ(t)/∑ⱼρⱼ)] +! Now, let's plug in (t_inj) = (∑ⱼρⱼ) / (∑ⱼ ρⱼ/ⱼ), which +! comes from the generic formula for (t_inj) defined earlier: +! (t_inj) - (t) = [(∑ⱼρⱼ) - ρ(t)] / (∑ⱼ ρⱼ/ⱼ) +! - If we plug this into the preceding cubic equation and multiply the +! resulting equation by (∑ⱼ ρⱼ/ⱼ), we get: +! coef0 + coef1 * δr(t) + coef2 * δr²(t) + coef3 * δr³(t) = 0 +! where: +! - coef0 = (∑ⱼ ρⱼ) - ρ(t) +! - coef1 = ∑ⱼ 3 ⱼ ρⱼ/ⱼ +! - coef2 = ∑ⱼ 3 ⱼ ρⱼ/ⱼ +! - coef3 = ∑ⱼ ρⱼ/ⱼ + +! Let's compute these coefficients + dsp_inject_sum = 0.d0 +! We'll use dsp_inject_sum to compute coef0 coef1 = 0.d0 coef2 = 0.d0 coef3 = 0.d0 + +! Loop over each injection pathway do iSN = 1, nSN if(SN_fsp(iSN) .gt. 0.d0) then +! Calculate 4πζnⱼ/3 = ρⱼ/ⱼ +! -> recall: that ζ is the mass density of a single grain of the +! current grain species (i.e. it's a constant) +! -> TODO: its very confusing that we store the result within SN_nsp0 +! since that variable is later reused to directly hold nⱼ SN_nsp0(iSN) = SN_dsp0(iSN) / SN_r0sp(3,iSN) - coef0 = coef0 + SN_dsp0(iSN) + + dsp_inject_sum = dsp_inject_sum + SN_dsp0(iSN) coef1 = coef1 + 3.d0 * SN_nsp0(iSN) * SN_r0sp(2,iSN) coef2 = coef2 + 3.d0 * SN_nsp0(iSN) * SN_r0sp(1,iSN) coef3 = coef3 + SN_nsp0(iSN) endif enddo -!! write(*,*) coef0, dsp(i,j,k) - coef0 = coef0 - dsp(i,j,k) -!! write(*,*) coef0, coef1, coef2, coef3 + coef0 = dsp_inject_sum - dsp(i,j,k) + +! Let's actually solve for the δr(t), the root of the cubic equation +! - before we do that, we divide both sides of the equation by the +! value of coef3. This ensures that the rescaled value of coef3 is +! exactly 1 (a requirement of the solve_cubic_equation routine) +! - todo: consider not modifying the variables in-place or performing +! this operation within the solve_cubic_equation coef0 = coef0 / coef3 coef1 = coef1 / coef3 coef2 = coef2 / coef3 - + call solve_cubic_equation(coef2, coef1, coef0, drsp(i)) -!! write(*,*) coef0, coef1, coef2, coef3, drsp(i) drsp(i) = max(drsp(i), 0.d0) endif -! calculate number density (code_density / g) +! Step 3: calculate number density (code_density / g) do iSN = 1, nSN if(SN_fsp(iSN) .gt. 0.d0) then SN_nsp0(iSN) = SN_dsp0(iSN) & / (4.d0*pi/3.d0 * ssp * SN_r0sp(3,iSN)) -! if(iSN.eq.1) -! & write(*,*) 'aa', SN_dsp0(iSN), dsp(i,j,k) -! & , (4.d0*pi/3.d0 * ssp * SN_r0sp(3,iSN)) -! & , SN_nsp0(iSN) else SN_nsp0(iSN) = 0.d0 endif enddo -! calculate geometrical cross-section per unit gas mass +! Step 4: calculate geometrical cross-section per unit gas mass sgsp(i) = 0.d0 do iSN = 1, nSN if( SN_fsp(iSN) .gt. 0.d0) then @@ -581,7 +672,7 @@ subroutine calc_grain_size_increment_species_1d( enddo sgsp(i) = sgsp(i) / d(i,j,k) -! calculate optical cross-section per unit gas mass +! Step 5: calculate optical cross-section per unit gas mass do iTd = 1, gr_N(2) iTd0 = (iTd-1)*gr_N(1) alsp(iTd,i) = 0.d0 From 55aa77a11dc0c2b5af6b93d71e4536f02617c8a9 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 12 Nov 2025 08:42:00 -0500 Subject: [PATCH 016/175] remove some commented out debugging code from calc_grain_size_increment_species_1d --- src/clib/calc_grain_size_increment_1d.F | 62 ------------------------- 1 file changed, 62 deletions(-) diff --git a/src/clib/calc_grain_size_increment_1d.F b/src/clib/calc_grain_size_increment_1d.F index 530035ac1..40724fa0b 100644 --- a/src/clib/calc_grain_size_increment_1d.F +++ b/src/clib/calc_grain_size_increment_1d.F @@ -485,28 +485,10 @@ subroutine calc_grain_size_increment_species_1d( real*8 drsp(in) real*8, parameter :: pi = pi_val real*8, parameter :: mh = mass_h -! debug - real*8 SN_dsp(SN0_N), SN_msp(SN0_N), dsp1 integer iTd, iTd0 - -! write(*,*) SN_fsp(1) -! write(*,*) SN_r0sp(1,1) -! & , SN_r0sp(2,1) -! & , SN_r0sp(3,1) -! do iTd = 1, gr_N(2) -! iTd0 = (iTd-1)*gr_N(1) -! write(*,*) gr_Td(iTd) -! & , SN_kp0sp(iTd0+1,1) -! & , SN_kp0sp(iTd0+2,1) -! & , SN_kp0sp(iTd0+3,1) -! & , SN_kp0sp(iTd0+4,1) -! enddo do i = is+1, ie+1 if ( itmask(i) .ne. MASK_FALSE ) then -!!!!!!!!!!!!! -!!!! if( dsp(i,j,k) .gt. 1.d-15*d(i,j,k) ) then -!!!!!!!!!!!!! ! Step 1: compute the total mass density of the current grain species ! that was injected (by summing the amounts injected by each @@ -514,8 +496,6 @@ subroutine calc_grain_size_increment_species_1d( do iSN = 1, nSN if(SN_fsp(iSN) .gt. 0.d0) then SN_dsp0(iSN) = SN_fsp(iSN) * SN_metal(i, iSN) -!! write(*,*) iSN, SN_fsp(iSN) -!! & , SN_metal(i, iSN) endif enddo @@ -664,11 +644,6 @@ subroutine calc_grain_size_increment_species_1d( SN_sgsp = 0.d0 endif sgsp(i) = sgsp(i) + SN_nsp0(iSN) * SN_sgsp -!! if(iSN.eq.1) -!! & write(*,*) dsp(i,j,k)/d(i,j,k) -!! & , SN_dsp0(iSN)/d(i,j,k) -!! & , ssp, SN_r0sp(3, iSN), SN_r0sp(2,iSN) -!! & , drsp(i), sgsp(i)/d(i,j,k) enddo sgsp(i) = sgsp(i) / d(i,j,k) @@ -688,47 +663,10 @@ subroutine calc_grain_size_increment_species_1d( SN_kpsp = 0.d0 endif alsp(iTd,i) = alsp(iTd,i) + SN_nsp0(iSN) * SN_kpsp -! if(iSN.eq.1) -! & write(*,*) gr_Td(iTd) -! & , SN_dsp0(iSN)/d(i,j,k) -! & , (4.d0*pi/3.d0 * ssp * SN_kp0sp(iTd0+4,iSN)) -! & / (4.d0*pi/3.d0 * ssp * SN_r0sp(3,iSN)) enddo alsp(iTd,i) = alsp(iTd,i) / d(i,j,k) enddo -! decompose grain mass density for each SN model !!!!!!!!!!!!!!!!!!!!!!! -! dsp0 = 0.d0 -! dsp1 = 0.d0 -! do iSN = 1, nSN -! dsp0 = dsp0 + SN_dsp0(iSN) -! if( SN_fsp(iSN) .gt. 0.d0) then -! SN_dsp(iSN) = 4.d0*pi/3.d0 * ssp * ( -! & SN_nsp0(iSN) * SN_r0sp(3,iSN) -! & + 3.d0 * SN_nsp0(iSN) * SN_r0sp(2,iSN) * drsp(i) -! & + 3.d0 * SN_nsp0(iSN) * SN_r0sp(1,iSN) * drsp(i)**2 -! & + SN_nsp0(iSN) * drsp(i)**3 -! & ) -! SN_msp(iSN) = 4.d0*pi/3.d0 * ssp * ( -! & SN_r0sp(3,iSN) -! & + 3.d0 * SN_r0sp(2,iSN) * drsp(i) -! & + 3.d0 * SN_r0sp(1,iSN) * drsp(i)**2 -! & + drsp(i)**3 -! & ) -!! if(iSN.eq.2) -!! & write(*,*) iSN, (SN_dsp(iSN)/SN_msp(iSN))/SN_nsp0(iSN) -! dsp1 = dsp1 + SN_dsp(iSN) -! endif -! enddo -! write(*,*) drsp(i), dsp1/dsp(i,j,k) -!!!!!!!!!!!!! -!!!! else - -!!!! sgsp (i) = tiny8 -!!!! alsp(:,i) = tiny8 - -!!!! endif -!!!!!!!!!!!!! endif ! itmask enddo From 97f90d599c4661eb74c1e762d717e8ccf7883dda Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 12 Nov 2025 09:32:26 -0500 Subject: [PATCH 017/175] minor tweaks --- src/clib/initialize_dust_yields.cpp | 50 +++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index dfd7c0d78..670f8dff0 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -59,10 +59,6 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, = my_rates->opaque_storage->inject_pathway_props; - int NTd, Nmom; - double Td0, dTd; - int iTd, imom, itab; - int NSN = n_pathways; // todo: delete me! my_rates->SN0_N = n_pathways; @@ -131,9 +127,9 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, my_rates->SN0_r0volorg = (double*)malloc(NSN * 3 * sizeof(double)); my_rates->SN0_r0H2Oice = (double*)malloc(NSN * 3 * sizeof(double)); - itab = 0; + int itab = 0; for(int iSN = 0; iSN < NSN; iSN++) { - for(imom = 0; imom < 3; imom++) { + for(int imom = 0; imom < 3; imom++) { my_rates->SN0_r0SiM [itab] = 0.0; my_rates->SN0_r0FeM [itab] = 0.0; my_rates->SN0_r0Mg2SiO4 [itab] = 0.0; @@ -151,18 +147,41 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, } } - NTd = 35; - Td0 = 0.0000000; - dTd = 0.1000000; - Nmom = 4; - + // write out the opacity related quantities + + // todo: consider renaming Nmom -> Ncoef + int Nmom = 4; // todo: remove me! + // todo: more this into GrainMetalInjectPathways + // - essentially, each SN0_kpGRSP array is a 3D array of shape + // (n_pathways, NTd, Nmom). This shape uses numpy conventions (i.e. Nmom is + // the fast-axis). + // - In more detail: + // - n_pathways is the number of injection pathways + // - NTd corresponds to the number of dust temperatures we consider + // - Nmom corresponds to the number of coefficients that we track for + // computing an opacity related quantity. This quantity is given by + // 4πζ/3 * ( SN0_kpGRSP[path_j, iTd, 3] + + // SN0_kpGRSP[path_j, iTd, 2] * δr(t) + + // SN0_kpGRSP[path_j, iTd, 1] * δr²(t) + + // SN0_kpGRSP[path_j, iTd, 0] * δr³(t)) + // where + // - ζ is the mass density of a single grain (in g/cm³) + // - δr(t) refers to the derived "size increment" (it is a central + // quantity in the model) + // - I **think** the resulting quantity is the optical cross-section + double NTd = 35; // todo: remove me! + double Td0 = 0.0000000; // todo: remove me! + double dTd = 0.1000000; // todo: remove me! + + // todo: rename gr_Td, dTd since they are related to log10(Tdust) or ln(Tdust) my_rates->gr_Td = (double*)malloc(NTd * Nmom * sizeof(double)); my_rates->gr_Size = NTd * Nmom; my_rates->gr_N[0] = Nmom; my_rates->gr_N[1] = NTd; my_rates->gr_dT = dTd; - for(iTd = 0; iTd < NTd; iTd++) + for(int iTd = 0; iTd < NTd; iTd++) { my_rates->gr_Td[iTd] = Td0 + (double)iTd * dTd; + } my_rates->SN0_kpSiM = (double*)malloc(NSN * Nmom * NTd * sizeof(double)); my_rates->SN0_kpFeM = (double*)malloc(NSN * Nmom * NTd * sizeof(double)); @@ -180,8 +199,11 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, itab = 0; for(int iSN = 0; iSN < NSN; iSN++) { - for(imom = 0; imom < Nmom; imom++) { - for(iTd = 0; iTd < NTd; iTd++) { + // TODO: I'm pretty sure we want to flip the order of inner loops + // - while it doesn't actually effect the result this is extremely + // confusing if the grain-temperature axis isn't the fast axis. + for(int imom = 0; imom < Nmom; imom++) { + for(int iTd = 0; iTd < NTd; iTd++) { my_rates->SN0_kpSiM [itab] = 0.0; my_rates->SN0_kpFeM [itab] = 0.0; my_rates->SN0_kpMg2SiO4 [itab] = 0.0; From c1a54e31ae6c0f59ee1ce0799974e4166541e811 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Fri, 14 Nov 2025 11:21:19 -0500 Subject: [PATCH 018/175] add more commentary to calc_grain_size_increment_1d --- src/clib/calc_grain_size_increment_1d.F | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/clib/calc_grain_size_increment_1d.F b/src/clib/calc_grain_size_increment_1d.F index 40724fa0b..89dce70e0 100644 --- a/src/clib/calc_grain_size_increment_1d.F +++ b/src/clib/calc_grain_size_increment_1d.F @@ -632,6 +632,7 @@ subroutine calc_grain_size_increment_species_1d( enddo ! Step 4: calculate geometrical cross-section per unit gas mass +! -> units of cm^2/g sgsp(i) = 0.d0 do iSN = 1, nSN if( SN_fsp(iSN) .gt. 0.d0) then @@ -647,7 +648,14 @@ subroutine calc_grain_size_increment_species_1d( enddo sgsp(i) = sgsp(i) / d(i,j,k) -! Step 5: calculate optical cross-section per unit gas mass +! Step 5: calculate optical opacity related quantities +! -> we are effectively constructing a 1d table of values, at various +! possible grain temperature for each injection pathway (in other +! words, its a 2D table) +! -> I'm pretty sure that the values we are the opacity (per unit gas +! mass) +! -> I'm pretty confident that the units are independent of code units +! (I think the units are cm^2/g) do iTd = 1, gr_N(2) iTd0 = (iTd-1)*gr_N(1) alsp(iTd,i) = 0.d0 From 2a1a6d5cf554e8304b44a98ef5f2bc557a5db8dd Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Fri, 14 Nov 2025 11:24:53 -0500 Subject: [PATCH 019/175] spruce up some commentary --- src/clib/dust_props.hpp | 2 +- src/clib/phys_constants.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/clib/dust_props.hpp b/src/clib/dust_props.hpp index 8639b3833..dcba84235 100644 --- a/src/clib/dust_props.hpp +++ b/src/clib/dust_props.hpp @@ -87,7 +87,7 @@ struct InternalDustPropBuf { /// - the fact that this holds a 1d table of values for each zone for each /// species seems extremely inefficient! /// - If we really do need to construct the full table, then (if possible) - /// we restructuring the algorithm so that: + /// we should restructure the algorithm so that: /// - we can reuse the buffer for different species /// - we can also reuse the buffer for different zones (this would probably /// involve reorganizing the tables of data for each metal-source in diff --git a/src/clib/phys_constants.h b/src/clib/phys_constants.h index a2362296a..5121d314e 100644 --- a/src/clib/phys_constants.h +++ b/src/clib/phys_constants.h @@ -122,6 +122,11 @@ * are hardcoded based on the values currently held by these constants. */ +// these constants are give the intrinsic density of an individual grain for +// each grain species in units of g/cm^3. +// - Equation A1 of Chiaki & Wise 2019 represents these quantities using the +// zeta_i variable. Equation 2 of Chiaki+15 denotes the variable as s_i + #define sSiM 2.34118e0 #define sFeM 7.95995e0 #define sMg2SiO4 3.22133e0 From a92e11d965c3331af5d124c89de52395281307a9 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Fri, 14 Nov 2025 11:25:45 -0500 Subject: [PATCH 020/175] add some commentary explaining how calc_tdust_1d_g.F actually works --- src/clib/calc_tdust_1d_g.F | 41 +++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/src/clib/calc_tdust_1d_g.F b/src/clib/calc_tdust_1d_g.F index 502dd9f78..bbeb792ec 100644 --- a/src/clib/calc_tdust_1d_g.F +++ b/src/clib/calc_tdust_1d_g.F @@ -18,6 +18,13 @@ subroutine calc_tdust_1d_g( ! PURPOSE: ! Calculate dust temperature. ! +! TODO: +! this docstring, and the docstrings of all helper functions should +! EXPLICITLY document how the meaning of arguments change based on +! whether we are using the single-field dust model or the +! multi-species dust model. The different meaning of each variable +! gets VERY confusing +! ! INPUTS: ! in - dimension of 1D slice ! @@ -347,11 +354,22 @@ subroutine calc_kappa_gr_g( ! ! written by: Britton Smith ! date: September, 2011 -! modified1: ! ! PURPOSE: ! Calculate grain plank mean opacity ! +! TODO: +! this docstring should EXPLICITLY document how the action of this +! function changes based on whether we are using the single-field +! dust model or the multi-species dust model. +! +! In the classic single single-field model, the returned opacities +! have units of cm^2/g and they are measured "per unit grain mass" +! +! In the multi-species dust model, I THINK that the returned +! opacities have units of cm^2/g and they are measured "per unit +! gas mass." +! ! INPUTS: ! in - i dimension of 3D fields ! @@ -472,6 +490,19 @@ subroutine calc_gr_balance_g( ! ! PURPOSE: ! Calculate grain heating/cooling balance + +! TODO: +! this docstring should EXPLICITLY document how the action of this +! function changes based on whether we are using the single-field +! dust model or the multi-species dust model. +! +! In the classic single single-field model, the returned values +! are emission/absorption rate per unit grain mass with units of +! erg/s/g +! +! In the multi-species dust model, I **THINK** that the returned +! values are emission/absorption rate per unit gas mass with units +! of erg/s/g (But I'm not entirely unsure). ! ! INPUTS: ! in - i dimension of 3D fields @@ -531,8 +562,12 @@ subroutine calc_gr_balance_g( & (trad4 - tdust(i)**4) + & (gasgr(i) * nh(i) * & (tgas(i) - tdust(i))) - ! emission/absorption rate per unit grain mass [erg/s/g] - ! for Z = Zsun (default) + ! Historically, the following comment was present here: + ! emission/absorption rate per unit grain mass [erg/s/g] + ! for Z = Zsun (default) + ! This comment is **ONLY** correct when the function used as + ! part of the single-field dust model. See the docstring for + ! more details. endif enddo From d251a232184eaecd5fd5dc1d82f27a7f2019a76a Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Fri, 14 Nov 2025 14:19:01 -0500 Subject: [PATCH 021/175] lay ground work for size_moments --- src/clib/grain_metal_inject_pathways.hpp | 57 +++++++++++++++++++++--- 1 file changed, 50 insertions(+), 7 deletions(-) diff --git a/src/clib/grain_metal_inject_pathways.hpp b/src/clib/grain_metal_inject_pathways.hpp index 3ec9af073..e0c8e0c00 100644 --- a/src/clib/grain_metal_inject_pathways.hpp +++ b/src/clib/grain_metal_inject_pathways.hpp @@ -88,12 +88,12 @@ struct GrainMetalInjectPathways { /// holds 1D tables (tabulated with respect to each injection pathway) that /// tracks the fraction of the injected mass density corresponding to - /// occurences of given metal nuclide in both the gas phase **AND** as part + /// occurrences of given metal nuclide in both the gas phase **AND** as part /// of dust grains /// /// @important - /// This counts up occurences of nulcides (i.e. a nuclide is allowed to occur - /// multiple times within a single molecule) + /// This counts up occurrences of nulcides (i.e. a nuclide is allowed to + /// occur multiple times within a single molecule) /// /// @note /// this variables holds information that is somewhat actually redundant with @@ -101,24 +101,65 @@ struct GrainMetalInjectPathways { yields::MetalTables total_metal_nuclide_yields; /// holds 1D tables that tracks the fraction of the injected mass density - /// that corresponds to the **INITIAL** occurences of given metal nuclide in + /// that corresponds to the **INITIAL** occurrences of given metal nuclide in /// the gas phase. /// /// This holds a separate table for each metal nuclide and each table has an /// entry for each injection pathway. /// /// @important - /// This counts up occurences of nulcides (i.e. a nuclide is allowed to occur - /// multiple times within a single molecule) + /// This counts up occurrences of nulcides (i.e. a nuclide is allowed to + /// occur multiple times within a single molecule) yields::MetalTables gas_metal_nuclide_yields; /// holds 1D tables (tabulated with respect to each injection pathway) that /// tracks the fraction of the injected mass density that corresponds to the - /// **INITIAL** occurences of a given grain species + /// **INITIAL** occurrences of a given grain species /// /// This holds a separate table for each grain species and every table has an /// entry for each injection pathway. GrainSpeciesCollection grain_yields; + + /// holds 1D tables (tabulated with respect to each injection pathway) that + /// tracks the 3 coefficients, derived from the 1st, 2nd, and 3rd order + /// moments of the initial size distribution for a given grain species. + /// + /// This holds a separate table for each grain species and every table has 3 + /// contiguous entries for each pathway. In other words, each table has the + /// shape ``(n_pathways, 3)`` using numpy conventions for a C-ordered array + /// (to pass the array to Fortran, we would say a table has the shape + /// ``(3, n_pathways)``. + /// + /// For a given grain species, I'm pretty confident that the entry at: + /// - ``[j, 0]`` specifies \f$\langle r^1 \rangle_j\f$. This is the grain + /// species's average **INITIAL** radius, when injected by pathway ``j``. + /// The value has units of cm. + /// - ``[j, 1]`` specifies \f$\langle r^2 \rangle_j\f$. The product of this + /// value and π gives the grain species's average **INITIAL** + /// cross-section, when injected by pathway ``j``. The value has units of + /// centimeters squared. + /// - ``[j, 2]`` specifies \f$\langle r^3 \rangle_j\f$. The product of this + /// value and (4π/3) is the grain species's average **INITIAL** volume, + /// when injected by pathway ``j``. The value has units of centimeters + /// cubed. + /// + /// @todo + /// What are the units of each quantity? (the dimensionality is obvious) + /// + /// where \f$\langle r^2 \rangle_j=\int_0^\infty r^p \Phi_j(r)\, {\rm d}r\f$ + /// is an abbreviation for the ``p``th moment of the \f$\Phi_j(r)\f$, or the + /// initial differential grain size distribution for pathway ``j`` (this + /// differs for each grain species). For added context: + /// - \f$\Phi_j(r)\f$ is normalized such that the ``p=0`` moment is 1 + /// - if the number density of the given grain species injected by pathway + /// ``j`` is \f$n_j\f$, then \f$n_j\Phi_j(r)\f$ gives the initial number + /// density of the grain species with radii between ``r`` and ``r + dr`` + /// + /// @todo + /// We should move the detailed descriptions of the size distribution + /// functions to the narrative docs and refer the reader to the appropriate + /// section of documentation + GrainSpeciesCollection size_moments; }; /// allocates the contents of a new GrainMetalInjectPathways @@ -130,6 +171,7 @@ inline GrainMetalInjectPathways new_GrainMetalInjectPathways(int n_pathways) { out.total_metal_nuclide_yields = yields::new_MetalTables(n_pathways); out.gas_metal_nuclide_yields = yields::new_MetalTables(n_pathways); out.grain_yields = new_GrainSpeciesCollection(n_pathways); + out.size_moments = new_GrainSpeciesCollection(3 * n_pathways); return out; } @@ -141,6 +183,7 @@ inline void drop_GrainMetalInjectPathways(GrainMetalInjectPathways* ptr) { yields::drop_MetalTables(&ptr->total_metal_nuclide_yields); yields::drop_MetalTables(&ptr->gas_metal_nuclide_yields); drop_GrainSpeciesCollection(&ptr->grain_yields); + drop_GrainSpeciesCollection(&ptr->size_moments); } } // namespace grackle::impl From 024c0da25b8a306e52e82ca47b1ded1ae1b840dd Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sat, 15 Nov 2025 16:24:30 -0500 Subject: [PATCH 022/175] incremental commit --- src/clib/initialize_dust_yields.cpp | 221 +++++++++++++++++++++++++++- 1 file changed, 219 insertions(+), 2 deletions(-) diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index 670f8dff0..6e10a0cf3 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -10,6 +10,7 @@ /// //===----------------------------------------------------------------------===// +#include #include #include #include @@ -18,11 +19,80 @@ #include "initialize_dust_yields.hpp" // forward declarations #include "LUT.hpp" #include "opaque_storage.hpp" +#include "status_reporting.h" // GrPrintAndReturnErr -// forward declare some functions +static constexpr int N_Tdust_Opacity_Table = 35; +static constexpr int N_Opacity_Coef = 4; namespace { // stuff inside an anonymous namespace is local to this file +struct MetalNuclideYieldProps; +struct GrainSpeciesYieldProps; + +/// This is used to organize the storage of the injection pathway data +/// +/// Essentially, this dictates how the data is organized on disk (as part of +/// the Grackle library). This data will be somewhat reordered to actually +/// perform calculations +/// +/// There are a few reasons why it makes some sense to store this data in a +/// a slightly different format than the way is organized during the core +/// calculations: +/// - the way we organize it here (which has some similarities to a struct of +/// arrays) is a lot less error-prone. +/// - the way we organize it here allows us to use a more sparse representation +/// (i.e. we omit yields from pathways when the yields are 0) +/// +/// @note +/// The plan is to eventually shift the data into a file loaded at runtime +struct InjectionPathwayInputData { + const char* name; + + const MetalNuclideYieldProps* metal_nuclide_yields; + int n_metal_nuclide_yields; + + const GrainSpeciesYieldProps* initial_grain_props; + int n_injected_grain_species; +}; + + +struct MetalNuclideYieldProps { + /// name of the nuclide + const char* name; + + /// total fraction of non-primordial injection corresponding to the nuclide + double total_yield; + + /// fraction of non-primordial injection corresponding to the nuclide in + /// the gas phase + double gas_yield; +}; + +/// Each injection array will hold an array of these structs +struct GrainSpeciesYieldProps { + /// name of the Grain Species + const char* name; + + /// Initial yield + double nonprimoridal_yield_frac; + + /// the 1st, 2nd, and 3rd order moments of the initial size distribution for + /// the grain species. + /// + /// - Element 0 specifies \f$\langle r^1 \rangle_j\f$. This is the grain + /// species's average **INITIAL** radius. Has units of cm. + /// - Element 1 specifies \f$\langle r^2 \rangle_j\f$. The product of this + /// value and π gives the grain species's average **INITIAL** + /// cross-section. Has units of centimeters squared. + /// - Element 2 specifies \f$\langle r^3 \rangle_j\f$. The product of this + /// value and (4π/3) is the grain species's average **INITIAL** volume. + /// Has units of centimeters cubed. + double size_moments[3]; + + double opacity_coef_table[N_Tdust_Opacity_Table][N_Opacity_Coef]; +}; + +// forward declare some functions int calc_rates_dust_loc(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates); int calc_rates_dust_C13(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates); int calc_rates_dust_C20(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates); @@ -169,7 +239,7 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, // - δr(t) refers to the derived "size increment" (it is a central // quantity in the model) // - I **think** the resulting quantity is the optical cross-section - double NTd = 35; // todo: remove me! + double NTd = N_Tdust_Opacity_Table; // todo: remove me! double Td0 = 0.0000000; // todo: remove me! double dTd = 0.1000000; // todo: remove me! @@ -301,6 +371,153 @@ int grackle::impl::free_dust_yields(chemistry_data *my_chemistry, namespace { // stuff inside an anonymous namespace is local to this file +int setup_yield_table_helper( + int pathway_idx, + chemistry_data_storage *my_rates, + const InjectionPathwayInputData *input) +{ + + grackle::impl::GrainMetalInjectPathways* inject_pathway_props + = my_rates->opaque_storage->inject_pathway_props; + + // record each metal nuclide yield + // -> there is less value to using string keys in this case, but it makes + // some sense to be semi-consistent with the handling of the dust species + // yields + for (int i = 0; i < input->n_metal_nuclide_yields; i++) { + const MetalNuclideYieldProps& yield_info = input->metal_nuclide_yields[i]; + + double* total_yield = nullptr; + double* gas_yield = nullptr; + + // todo: refactor to use a map (I have a rough plan) + if (std::strcmp("C", yield_info.name) == 0) { + total_yield = inject_pathway_props->total_metal_nuclide_yields.C; + gas_yield = inject_pathway_props->gas_metal_nuclide_yields.C; + } else if (std::strcmp("O", yield_info.name) == 0) { + total_yield = inject_pathway_props->total_metal_nuclide_yields.O; + gas_yield = inject_pathway_props->gas_metal_nuclide_yields.O; + } else if (std::strcmp("Mg", yield_info.name) == 0) { + total_yield = inject_pathway_props->total_metal_nuclide_yields.Mg; + gas_yield = inject_pathway_props->gas_metal_nuclide_yields.Mg; + } else if (std::strcmp("Al", yield_info.name) == 0) { + total_yield = inject_pathway_props->total_metal_nuclide_yields.Al; + gas_yield = inject_pathway_props->gas_metal_nuclide_yields.Al; + } else if (std::strcmp("Si", yield_info.name) == 0) { + total_yield = inject_pathway_props->total_metal_nuclide_yields.Si; + gas_yield = inject_pathway_props->gas_metal_nuclide_yields.Si; + } else if (std::strcmp("S", yield_info.name) == 0) { + total_yield = inject_pathway_props->total_metal_nuclide_yields.S; + gas_yield = inject_pathway_props->gas_metal_nuclide_yields.S; + } else if (std::strcmp("Fe", yield_info.name) == 0) { + total_yield = inject_pathway_props->total_metal_nuclide_yields.Fe; + gas_yield = inject_pathway_props->gas_metal_nuclide_yields.Fe; + } else { + return GrPrintAndReturnErr( + "`%s` not a known metal nuclide", yield_info.name); + } + + total_yield[pathway_idx] = yield_info.total_yield; + gas_yield[pathway_idx] = yield_info.gas_yield; + } + + // record each grain species yield + for (int yield_idx = 0; yield_idx < input->n_injected_grain_species; + yield_idx++) { + const GrainSpeciesYieldProps& yield_info = + input->initial_grain_props[yield_idx]; + + int grain_species_idx = -1; + double* size_mom_table = nullptr; + double* opac_coef_table = nullptr; + + // with a little refactoring, this will get a lot more concise + if (std::strcmp("MgSiO3_dust", yield_info.name) == 0) { + grain_species_idx = OnlyGrainSpLUT::MgSiO3_dust; + size_mom_table = my_rates->SN0_r0MgSiO3; + opac_coef_table = my_rates->SN0_kpMgSiO3; + } else if (std::strcmp("AC_dust", yield_info.name) == 0) { + grain_species_idx = OnlyGrainSpLUT::AC_dust; + size_mom_table = my_rates->SN0_r0AC; + opac_coef_table = my_rates->SN0_kpAC; + } else if (std::strcmp("SiM_dust", yield_info.name) == 0) { + grain_species_idx = OnlyGrainSpLUT::SiM_dust; + size_mom_table = my_rates->SN0_r0SiM; + opac_coef_table = my_rates->SN0_kpSiM; + } else if (std::strcmp("FeM_dust", yield_info.name) == 0) { + grain_species_idx = OnlyGrainSpLUT::FeM_dust; + size_mom_table = my_rates->SN0_r0FeM; + opac_coef_table = my_rates->SN0_kpFeM; + } else if (std::strcmp("Mg2SiO4_dust", yield_info.name) == 0) { + grain_species_idx = OnlyGrainSpLUT::Mg2SiO4_dust; + size_mom_table = my_rates->SN0_r0Mg2SiO4; + opac_coef_table = my_rates->SN0_kpMg2SiO4; + } else if (std::strcmp("Fe3O4_dust", yield_info.name) == 0) { + grain_species_idx = OnlyGrainSpLUT::Fe3O4_dust; + size_mom_table = my_rates->SN0_r0Fe3O4; + opac_coef_table = my_rates->SN0_kpFe3O4; + } else if (std::strcmp("SiO2_dust", yield_info.name) == 0) { + grain_species_idx = OnlyGrainSpLUT::SiO2_dust; + size_mom_table = my_rates->SN0_r0SiO2D; + opac_coef_table = my_rates->SN0_kpSiO2D; + } else if (std::strcmp("MgO_dust", yield_info.name) == 0) { + grain_species_idx = OnlyGrainSpLUT::MgO_dust; + size_mom_table = my_rates->SN0_r0MgO; + opac_coef_table = my_rates->SN0_kpMgO; + } else if (std::strcmp("FeS_dust", yield_info.name) == 0) { + grain_species_idx = OnlyGrainSpLUT::FeS_dust; + size_mom_table = my_rates->SN0_r0FeS; + opac_coef_table = my_rates->SN0_kpFeS; + } else if (std::strcmp("Al2O3_dust", yield_info.name) == 0) { + grain_species_idx = OnlyGrainSpLUT::Al2O3_dust; + size_mom_table = my_rates->SN0_r0Al2O3; + opac_coef_table = my_rates->SN0_kpAl2O3; + } else if (std::strcmp("ref_org_dust", yield_info.name) == 0) { + grain_species_idx = OnlyGrainSpLUT::ref_org_dust; + size_mom_table = my_rates->SN0_r0reforg; + opac_coef_table = my_rates->SN0_kpreforg; + } else if (std::strcmp("vol_org_dust", yield_info.name) == 0) { + grain_species_idx = OnlyGrainSpLUT::vol_org_dust; + size_mom_table = my_rates->SN0_r0volorg; + opac_coef_table = my_rates->SN0_kpvolorg; + } else if (std::strcmp("H2O_ice_dust", yield_info.name) == 0) { + grain_species_idx = OnlyGrainSpLUT::H2O_ice_dust; + size_mom_table = my_rates->SN0_r0H2Oice; + opac_coef_table = my_rates->SN0_kpH2Oice; + } else { + return GrPrintAndReturnErr( + "`%s` not a known grain species", yield_info.name); + } + + // copy the nonprimordial yield fraction + inject_pathway_props->grain_yields.data[grain_species_idx][pathway_idx] + = yield_info.nonprimoridal_yield_frac; + + /* + // copy the 1st, 2nd, and 3rd moments of the size distribution + // (the 0th moment isn't recorded anywhere + for (int i = 0; i < 3; i++) { + size_mom_table[pathway_idx*3+i] = yield_info.size_moments[i]; + } + + // copy over the opacity coefficients table + { + int n_Td = N_Tdust_Opacity_Table; + int n_coef = N_Opacity_Coef; + + for (int i_Td = 0; i_Td < n_Td; i_Td++) { + for (int i_coef = 0; i_coef < n_coef; i_coef++) { + int i = (pathway_idx * n_Td * n_coef) + (i_Td * n_coef) + i_coef; + opac_coef_table[i] = yield_info.opacity_coef_table[i_Td][i_coef]; + } + } + } + */ + } + + return GR_SUCCESS; +} + int calc_rates_dust_loc(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates) { From 2a56c85415fd3d3a3a10fbd6167119836192852f Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Fri, 5 Dec 2025 13:22:54 -0500 Subject: [PATCH 023/175] light refactoring --- src/clib/initialize_dust_yields.cpp | 40 +++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index 6e10a0cf3..9efe2bef6 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -11,7 +11,8 @@ //===----------------------------------------------------------------------===// #include -#include +#include +#include #include #include #include "grackle_macros.h" @@ -21,10 +22,22 @@ #include "opaque_storage.hpp" #include "status_reporting.h" // GrPrintAndReturnErr -static constexpr int N_Tdust_Opacity_Table = 35; +/// datastructures declared in this namespace are a temporarily introduced for +/// encoding the injection model data, until we shift to using HDF5 +/// +/// @note +/// At this point, the main barrier to adopting HDF5 is that I would like to +/// first remove all usage of MetalNuclideYieldProps::total_yield (so that we +/// don't need to encode it in the HDF5 file). +namespace grackle::impl::inj_model_input { + +/// the number of opacity-related coefficients that are grouped together +/// in the opacity table static constexpr int N_Opacity_Coef = 4; -namespace { // stuff inside an anonymous namespace is local to this file +/// the number of Tdust values in an opacity table for a given grain species +/// and injection pathway. For each Tdust, there are N_Opacity_Coef coefficients +static constexpr int N_Tdust_Opacity_Table = 35; struct MetalNuclideYieldProps; struct GrainSpeciesYieldProps; @@ -60,12 +73,13 @@ struct MetalNuclideYieldProps { /// name of the nuclide const char* name; - /// total fraction of non-primordial injection corresponding to the nuclide - double total_yield; - /// fraction of non-primordial injection corresponding to the nuclide in /// the gas phase double gas_yield; + + /// total fraction of non-primordial injection corresponding to the nuclide + /// - I'm pretty sure we can get rid of this information in the future + double total_yield; }; /// Each injection array will hold an array of these structs @@ -92,6 +106,10 @@ struct GrainSpeciesYieldProps { double opacity_coef_table[N_Tdust_Opacity_Table][N_Opacity_Coef]; }; +} // namespace grackle::impl::inj_model_input + +namespace { // stuff inside an anonymous namespace is local to this file + // forward declare some functions int calc_rates_dust_loc(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates); int calc_rates_dust_C13(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates); @@ -239,7 +257,7 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, // - δr(t) refers to the derived "size increment" (it is a central // quantity in the model) // - I **think** the resulting quantity is the optical cross-section - double NTd = N_Tdust_Opacity_Table; // todo: remove me! + double NTd = grackle::impl::inj_model_input::N_Tdust_Opacity_Table; double Td0 = 0.0000000; // todo: remove me! double dTd = 0.1000000; // todo: remove me! @@ -374,8 +392,9 @@ namespace { // stuff inside an anonymous namespace is local to this file int setup_yield_table_helper( int pathway_idx, chemistry_data_storage *my_rates, - const InjectionPathwayInputData *input) + const grackle::impl::inj_model_input::InjectionPathwayInputData *input) { + namespace inj_input = ::grackle::impl::inj_model_input; grackle::impl::GrainMetalInjectPathways* inject_pathway_props = my_rates->opaque_storage->inject_pathway_props; @@ -385,7 +404,8 @@ int setup_yield_table_helper( // some sense to be semi-consistent with the handling of the dust species // yields for (int i = 0; i < input->n_metal_nuclide_yields; i++) { - const MetalNuclideYieldProps& yield_info = input->metal_nuclide_yields[i]; + const inj_input::MetalNuclideYieldProps& yield_info = + input->metal_nuclide_yields[i]; double* total_yield = nullptr; double* gas_yield = nullptr; @@ -424,7 +444,7 @@ int setup_yield_table_helper( // record each grain species yield for (int yield_idx = 0; yield_idx < input->n_injected_grain_species; yield_idx++) { - const GrainSpeciesYieldProps& yield_info = + const inj_input::GrainSpeciesYieldProps& yield_info = input->initial_grain_props[yield_idx]; int grain_species_idx = -1; From 74ded6e5be695bae89e30fd976e3f7750f6fbb33 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Fri, 5 Dec 2025 16:11:00 -0500 Subject: [PATCH 024/175] shift around some files --- src/clib/CMakeLists.txt | 2 +- src/clib/fortran_func_wrappers.hpp | 2 +- src/clib/initialize_chemistry_data.cpp | 2 +- src/clib/inject_model/README.md | 6 ++++++ src/clib/{ => inject_model}/grain_metal_inject_pathways.hpp | 2 -- src/clib/opaque_storage.hpp | 2 +- 6 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 src/clib/inject_model/README.md rename src/clib/{ => inject_model}/grain_metal_inject_pathways.hpp (98%) diff --git a/src/clib/CMakeLists.txt b/src/clib/CMakeLists.txt index 52557be3f..6de54f165 100644 --- a/src/clib/CMakeLists.txt +++ b/src/clib/CMakeLists.txt @@ -113,11 +113,11 @@ add_library(Grackle_Grackle cool_multi_time_g.cpp cool_multi_time_g.h dust_props.hpp dust/grain_species_info.cpp dust/grain_species_info.hpp - grain_metal_inject_pathways.hpp init_misc_species_cool_rates.cpp init_misc_species_cool_rates.hpp initialize_chemistry_data.cpp initialize_dust_yields.cpp initialize_dust_yields.hpp initialize_rates.cpp initialize_rates.hpp + inject_model/grain_metal_inject_pathways.hpp internal_types.cpp internal_types.hpp interp_table_utils.hpp lookup_cool_rates1d.hpp diff --git a/src/clib/fortran_func_wrappers.hpp b/src/clib/fortran_func_wrappers.hpp index cd561e8f5..d6d893edc 100644 --- a/src/clib/fortran_func_wrappers.hpp +++ b/src/clib/fortran_func_wrappers.hpp @@ -25,8 +25,8 @@ #include "grackle.h" #include "dust_props.hpp" #include "fortran_func_decls.h" -#include "grain_metal_inject_pathways.hpp" #include "index_helper.h" +#include "inject_model/grain_metal_inject_pathways.hpp" #include "internal_types.hpp" #include "internal_units.h" #include "LUT.hpp" diff --git a/src/clib/initialize_chemistry_data.cpp b/src/clib/initialize_chemistry_data.cpp index 273b317c1..462d5d59a 100644 --- a/src/clib/initialize_chemistry_data.cpp +++ b/src/clib/initialize_chemistry_data.cpp @@ -19,7 +19,7 @@ #include "grackle.h" #include "grackle_macros.h" #include "auto_general.h" -#include "grain_metal_inject_pathways.hpp" +#include "inject_model/grain_metal_inject_pathways.hpp" #include "interp_table_utils.hpp" #include "init_misc_species_cool_rates.hpp" // free_misc_species_cool_rates #include "initialize_cloudy_data.h" diff --git a/src/clib/inject_model/README.md b/src/clib/inject_model/README.md new file mode 100644 index 000000000..b257bbe5e --- /dev/null +++ b/src/clib/inject_model/README.md @@ -0,0 +1,6 @@ +This subdirectory defines data structures (and routines for initializing the data structures) that pertain to the injection models. + +At the time of writing, the injection model is used by any Grackle configuration using metal chemistry. + +After we address GH Issue #446, the injection model will **ONLY** be used with the multigrain species dust model. At that point, we should move the contents of this directory into the dust subdirectory. + diff --git a/src/clib/grain_metal_inject_pathways.hpp b/src/clib/inject_model/grain_metal_inject_pathways.hpp similarity index 98% rename from src/clib/grain_metal_inject_pathways.hpp rename to src/clib/inject_model/grain_metal_inject_pathways.hpp index e0c8e0c00..1fb39e9e5 100644 --- a/src/clib/grain_metal_inject_pathways.hpp +++ b/src/clib/inject_model/grain_metal_inject_pathways.hpp @@ -12,8 +12,6 @@ #ifndef GRAIN_METAL_INJECT_PATHWAYS_HPP #define GRAIN_METAL_INJECT_PATHWAYS_HPP -// after dealing with GH Issue #446, move this file into the dust subdirectory - #include "LUT.hpp" #include "internal_types.hpp" #include "visitor/common.hpp" diff --git a/src/clib/opaque_storage.hpp b/src/clib/opaque_storage.hpp index c30030b21..585620817 100644 --- a/src/clib/opaque_storage.hpp +++ b/src/clib/opaque_storage.hpp @@ -15,7 +15,7 @@ #include "grackle.h" #include "dust/grain_species_info.hpp" -#include "grain_metal_inject_pathways.hpp" +#include "inject_model/grain_metal_inject_pathways.hpp" #include "internal_types.hpp" /// a struct that used to wrap some private storage details From ffe87a5bc5ed1774fc4f6c8b6f3eb5402cb2e481 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Fri, 5 Dec 2025 16:22:01 -0500 Subject: [PATCH 025/175] move some machinery out of initialize_dust_yields.cpp --- src/clib/CMakeLists.txt | 1 + src/clib/initialize_dust_yields.cpp | 87 +---------------------- src/clib/inject_model/raw_data.hpp | 103 ++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+), 86 deletions(-) create mode 100644 src/clib/inject_model/raw_data.hpp diff --git a/src/clib/CMakeLists.txt b/src/clib/CMakeLists.txt index 6de54f165..3a1ee38c8 100644 --- a/src/clib/CMakeLists.txt +++ b/src/clib/CMakeLists.txt @@ -118,6 +118,7 @@ add_library(Grackle_Grackle initialize_dust_yields.cpp initialize_dust_yields.hpp initialize_rates.cpp initialize_rates.hpp inject_model/grain_metal_inject_pathways.hpp + inject_model/raw_data.hpp internal_types.cpp internal_types.hpp interp_table_utils.hpp lookup_cool_rates1d.hpp diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index 9efe2bef6..34620d3fc 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -18,96 +18,11 @@ #include "grackle_macros.h" #include "grackle_chemistry_data.h" #include "initialize_dust_yields.hpp" // forward declarations +#include "inject_model/raw_data.hpp" #include "LUT.hpp" #include "opaque_storage.hpp" #include "status_reporting.h" // GrPrintAndReturnErr -/// datastructures declared in this namespace are a temporarily introduced for -/// encoding the injection model data, until we shift to using HDF5 -/// -/// @note -/// At this point, the main barrier to adopting HDF5 is that I would like to -/// first remove all usage of MetalNuclideYieldProps::total_yield (so that we -/// don't need to encode it in the HDF5 file). -namespace grackle::impl::inj_model_input { - -/// the number of opacity-related coefficients that are grouped together -/// in the opacity table -static constexpr int N_Opacity_Coef = 4; - -/// the number of Tdust values in an opacity table for a given grain species -/// and injection pathway. For each Tdust, there are N_Opacity_Coef coefficients -static constexpr int N_Tdust_Opacity_Table = 35; - -struct MetalNuclideYieldProps; -struct GrainSpeciesYieldProps; - -/// This is used to organize the storage of the injection pathway data -/// -/// Essentially, this dictates how the data is organized on disk (as part of -/// the Grackle library). This data will be somewhat reordered to actually -/// perform calculations -/// -/// There are a few reasons why it makes some sense to store this data in a -/// a slightly different format than the way is organized during the core -/// calculations: -/// - the way we organize it here (which has some similarities to a struct of -/// arrays) is a lot less error-prone. -/// - the way we organize it here allows us to use a more sparse representation -/// (i.e. we omit yields from pathways when the yields are 0) -/// -/// @note -/// The plan is to eventually shift the data into a file loaded at runtime -struct InjectionPathwayInputData { - const char* name; - - const MetalNuclideYieldProps* metal_nuclide_yields; - int n_metal_nuclide_yields; - - const GrainSpeciesYieldProps* initial_grain_props; - int n_injected_grain_species; -}; - - -struct MetalNuclideYieldProps { - /// name of the nuclide - const char* name; - - /// fraction of non-primordial injection corresponding to the nuclide in - /// the gas phase - double gas_yield; - - /// total fraction of non-primordial injection corresponding to the nuclide - /// - I'm pretty sure we can get rid of this information in the future - double total_yield; -}; - -/// Each injection array will hold an array of these structs -struct GrainSpeciesYieldProps { - /// name of the Grain Species - const char* name; - - /// Initial yield - double nonprimoridal_yield_frac; - - /// the 1st, 2nd, and 3rd order moments of the initial size distribution for - /// the grain species. - /// - /// - Element 0 specifies \f$\langle r^1 \rangle_j\f$. This is the grain - /// species's average **INITIAL** radius. Has units of cm. - /// - Element 1 specifies \f$\langle r^2 \rangle_j\f$. The product of this - /// value and π gives the grain species's average **INITIAL** - /// cross-section. Has units of centimeters squared. - /// - Element 2 specifies \f$\langle r^3 \rangle_j\f$. The product of this - /// value and (4π/3) is the grain species's average **INITIAL** volume. - /// Has units of centimeters cubed. - double size_moments[3]; - - double opacity_coef_table[N_Tdust_Opacity_Table][N_Opacity_Coef]; -}; - -} // namespace grackle::impl::inj_model_input - namespace { // stuff inside an anonymous namespace is local to this file // forward declare some functions diff --git a/src/clib/inject_model/raw_data.hpp b/src/clib/inject_model/raw_data.hpp new file mode 100644 index 000000000..97f9e0c33 --- /dev/null +++ b/src/clib/inject_model/raw_data.hpp @@ -0,0 +1,103 @@ +//===----------------------------------------------------------------------===// +// +// See the LICENSE file for license and copyright information +// SPDX-License-Identifier: NCSA AND BSD-3-Clause +// +//===----------------------------------------------------------------------===// +/// +/// @file +/// Declares some data structures used for organizing the raw input injection +/// model data, which is currently embedded as part of the Grackle library) and +/// declares a function for accessing this data. +/// +/// @note +/// It's worth emphasizing that all machinery declared in this file are only +/// introduced temporarily. The long-term plan is to drop all of the machinery +/// once we start encoding the data within HDF5 files. The main barrier to +/// adopting HDF5 for this purpose is that I would like to first remove all +/// usage of the data currently encoded in MetalNuclideYieldProps::total_yield +/// (so that we can avoid encoding it in the HDF5 file). +/// +//===----------------------------------------------------------------------===// + +#ifndef INJECT_MODEL_RAW_DATA_HPP +#define INJECT_MODEL_RAW_DATA_HPP +namespace grackle::impl::inj_model_input { + +/// the number of opacity-related coefficients that are grouped together +/// in the opacity table +static constexpr int N_Opacity_Coef = 4; + +/// the number of Tdust values in an opacity table for a given grain species +/// and injection pathway. For each Tdust, there are N_Opacity_Coef coefficients +static constexpr int N_Tdust_Opacity_Table = 35; + +struct MetalNuclideYieldProps; +struct GrainSpeciesYieldProps; + +/// This is used to organize the storage of the injection pathway data +/// +/// Essentially, this dictates how the data is organized on disk (as part of +/// the Grackle library). This data will be somewhat reordered to actually +/// perform calculations +/// +/// There are a few reasons why it makes some sense to store this data in a +/// a slightly different format than the way is organized during the core +/// calculations: +/// - the way we organize it here (which has some similarities to a struct of +/// arrays) is a lot less error-prone. +/// - the way we organize it here allows us to use a more sparse representation +/// (i.e. we omit yields from pathways when the yields are 0) +/// +/// @note +/// The plan is to eventually shift the data into a file loaded at runtime +struct InjectionPathwayInputData { + const char* name; + + const MetalNuclideYieldProps* metal_nuclide_yields; + int n_metal_nuclide_yields; + + const GrainSpeciesYieldProps* initial_grain_props; + int n_injected_grain_species; +}; + +struct MetalNuclideYieldProps { + /// name of the nuclide + const char* name; + + /// fraction of non-primordial injection corresponding to the nuclide in + /// the gas phase + double gas_yield; + + /// total fraction of non-primordial injection corresponding to the nuclide + /// - I'm pretty sure we can get rid of this information in the future + double total_yield; +}; + +/// Each injection array will hold an array of these structs +struct GrainSpeciesYieldProps { + /// name of the Grain Species + const char* name; + + /// Initial yield + double nonprimoridal_yield_frac; + + /// the 1st, 2nd, and 3rd order moments of the initial size distribution for + /// the grain species. + /// + /// - Element 0 specifies \f$\langle r^1 \rangle_j\f$. This is the grain + /// species's average **INITIAL** radius. Has units of cm. + /// - Element 1 specifies \f$\langle r^2 \rangle_j\f$. The product of this + /// value and π gives the grain species's average **INITIAL** + /// cross-section. Has units of centimeters squared. + /// - Element 2 specifies \f$\langle r^3 \rangle_j\f$. The product of this + /// value and (4π/3) is the grain species's average **INITIAL** volume. + /// Has units of centimeters cubed. + double size_moments[3]; + + double opacity_coef_table[N_Tdust_Opacity_Table][N_Opacity_Coef]; +}; + +} // namespace grackle::impl::inj_model_input + +#endif // INJECT_MODEL_RAW_DATA_HPP From be60a507f9923c666aa679fa19313abd651c17d9 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Fri, 5 Dec 2025 17:44:19 -0500 Subject: [PATCH 026/175] incremental progress --- src/clib/initialize_dust_yields.cpp | 304 ++++++++++++++-------------- src/clib/inject_model/raw_data.hpp | 41 +++- 2 files changed, 188 insertions(+), 157 deletions(-) diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index 34620d3fc..fae89780c 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -43,6 +43,160 @@ int calc_rates_dust_Y19(int iSN, chemistry_data *my_chemistry, chemistry_data_st typedef int calc_yield_rate_fn(int, chemistry_data*, chemistry_data_storage*); + +namespace { // stuff inside an anonymous namespace is local to this file + +int setup_yield_table_helper( + int pathway_idx, + chemistry_data_storage *my_rates, + const grackle::impl::inj_model_input::InjectionPathwayInputData *input) +{ + namespace inj_input = ::grackle::impl::inj_model_input; + + grackle::impl::GrainMetalInjectPathways* inject_pathway_props + = my_rates->opaque_storage->inject_pathway_props; + + // record each metal nuclide yield + // -> there is less value to using string keys in this case, but it makes + // some sense to be semi-consistent with the handling of the dust species + // yields + for (int i = 0; i < input->n_metal_nuclide_yields; i++) { + const inj_input::MetalNuclideYieldProps& yield_info = + input->metal_nuclide_yields[i]; + + double* total_yield = nullptr; + double* gas_yield = nullptr; + + // todo: refactor to use a map (I have a rough plan) + if (std::strcmp("C", yield_info.name) == 0) { + total_yield = inject_pathway_props->total_metal_nuclide_yields.C; + gas_yield = inject_pathway_props->gas_metal_nuclide_yields.C; + } else if (std::strcmp("O", yield_info.name) == 0) { + total_yield = inject_pathway_props->total_metal_nuclide_yields.O; + gas_yield = inject_pathway_props->gas_metal_nuclide_yields.O; + } else if (std::strcmp("Mg", yield_info.name) == 0) { + total_yield = inject_pathway_props->total_metal_nuclide_yields.Mg; + gas_yield = inject_pathway_props->gas_metal_nuclide_yields.Mg; + } else if (std::strcmp("Al", yield_info.name) == 0) { + total_yield = inject_pathway_props->total_metal_nuclide_yields.Al; + gas_yield = inject_pathway_props->gas_metal_nuclide_yields.Al; + } else if (std::strcmp("Si", yield_info.name) == 0) { + total_yield = inject_pathway_props->total_metal_nuclide_yields.Si; + gas_yield = inject_pathway_props->gas_metal_nuclide_yields.Si; + } else if (std::strcmp("S", yield_info.name) == 0) { + total_yield = inject_pathway_props->total_metal_nuclide_yields.S; + gas_yield = inject_pathway_props->gas_metal_nuclide_yields.S; + } else if (std::strcmp("Fe", yield_info.name) == 0) { + total_yield = inject_pathway_props->total_metal_nuclide_yields.Fe; + gas_yield = inject_pathway_props->gas_metal_nuclide_yields.Fe; + } else { + return GrPrintAndReturnErr( + "`%s` not a known metal nuclide", yield_info.name); + } + + total_yield[pathway_idx] = yield_info.total_yield; + gas_yield[pathway_idx] = yield_info.gas_yield; + } + + // record each grain species yield + for (int yield_idx = 0; yield_idx < input->n_injected_grain_species; + yield_idx++) { + const inj_input::GrainSpeciesYieldProps& yield_info = + input->initial_grain_props[yield_idx]; + + int grain_species_idx = -1; + double* size_mom_table = nullptr; + double* opac_coef_table = nullptr; + + // with a little refactoring, this will get a lot more concise + if (std::strcmp("MgSiO3_dust", yield_info.name) == 0) { + grain_species_idx = OnlyGrainSpLUT::MgSiO3_dust; + size_mom_table = my_rates->SN0_r0MgSiO3; + opac_coef_table = my_rates->SN0_kpMgSiO3; + } else if (std::strcmp("AC_dust", yield_info.name) == 0) { + grain_species_idx = OnlyGrainSpLUT::AC_dust; + size_mom_table = my_rates->SN0_r0AC; + opac_coef_table = my_rates->SN0_kpAC; + } else if (std::strcmp("SiM_dust", yield_info.name) == 0) { + grain_species_idx = OnlyGrainSpLUT::SiM_dust; + size_mom_table = my_rates->SN0_r0SiM; + opac_coef_table = my_rates->SN0_kpSiM; + } else if (std::strcmp("FeM_dust", yield_info.name) == 0) { + grain_species_idx = OnlyGrainSpLUT::FeM_dust; + size_mom_table = my_rates->SN0_r0FeM; + opac_coef_table = my_rates->SN0_kpFeM; + } else if (std::strcmp("Mg2SiO4_dust", yield_info.name) == 0) { + grain_species_idx = OnlyGrainSpLUT::Mg2SiO4_dust; + size_mom_table = my_rates->SN0_r0Mg2SiO4; + opac_coef_table = my_rates->SN0_kpMg2SiO4; + } else if (std::strcmp("Fe3O4_dust", yield_info.name) == 0) { + grain_species_idx = OnlyGrainSpLUT::Fe3O4_dust; + size_mom_table = my_rates->SN0_r0Fe3O4; + opac_coef_table = my_rates->SN0_kpFe3O4; + } else if (std::strcmp("SiO2_dust", yield_info.name) == 0) { + grain_species_idx = OnlyGrainSpLUT::SiO2_dust; + size_mom_table = my_rates->SN0_r0SiO2D; + opac_coef_table = my_rates->SN0_kpSiO2D; + } else if (std::strcmp("MgO_dust", yield_info.name) == 0) { + grain_species_idx = OnlyGrainSpLUT::MgO_dust; + size_mom_table = my_rates->SN0_r0MgO; + opac_coef_table = my_rates->SN0_kpMgO; + } else if (std::strcmp("FeS_dust", yield_info.name) == 0) { + grain_species_idx = OnlyGrainSpLUT::FeS_dust; + size_mom_table = my_rates->SN0_r0FeS; + opac_coef_table = my_rates->SN0_kpFeS; + } else if (std::strcmp("Al2O3_dust", yield_info.name) == 0) { + grain_species_idx = OnlyGrainSpLUT::Al2O3_dust; + size_mom_table = my_rates->SN0_r0Al2O3; + opac_coef_table = my_rates->SN0_kpAl2O3; + } else if (std::strcmp("ref_org_dust", yield_info.name) == 0) { + grain_species_idx = OnlyGrainSpLUT::ref_org_dust; + size_mom_table = my_rates->SN0_r0reforg; + opac_coef_table = my_rates->SN0_kpreforg; + } else if (std::strcmp("vol_org_dust", yield_info.name) == 0) { + grain_species_idx = OnlyGrainSpLUT::vol_org_dust; + size_mom_table = my_rates->SN0_r0volorg; + opac_coef_table = my_rates->SN0_kpvolorg; + } else if (std::strcmp("H2O_ice_dust", yield_info.name) == 0) { + grain_species_idx = OnlyGrainSpLUT::H2O_ice_dust; + size_mom_table = my_rates->SN0_r0H2Oice; + opac_coef_table = my_rates->SN0_kpH2Oice; + } else { + return GrPrintAndReturnErr( + "`%s` not a known grain species", yield_info.name); + } + + // copy the nonprimordial yield fraction + inject_pathway_props->grain_yields.data[grain_species_idx][pathway_idx] + = yield_info.nonprimoridal_yield_frac; + + /* + // copy the 1st, 2nd, and 3rd moments of the size distribution + // (the 0th moment isn't recorded anywhere + for (int i = 0; i < 3; i++) { + size_mom_table[pathway_idx*3+i] = yield_info.size_moments[i]; + } + + // copy over the opacity coefficients table + { + int n_Td = N_Tdust_Opacity_Table; + int n_coef = N_Opacity_Coef; + + for (int i_Td = 0; i_Td < n_Td; i_Td++) { + for (int i_coef = 0; i_coef < n_coef; i_coef++) { + int i = (pathway_idx * n_Td * n_coef) + (i_Td * n_coef) + i_coef; + opac_coef_table[i] = yield_info.opacity_coef_table[i_Td][i_coef]; + } + } + } + */ + } + + return GR_SUCCESS; +} + +} // anonymous namespace + int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, chemistry_data_storage *my_rates, code_units *my_units) @@ -302,156 +456,8 @@ int grackle::impl::free_dust_yields(chemistry_data *my_chemistry, return SUCCESS; } -namespace { // stuff inside an anonymous namespace is local to this file - -int setup_yield_table_helper( - int pathway_idx, - chemistry_data_storage *my_rates, - const grackle::impl::inj_model_input::InjectionPathwayInputData *input) -{ - namespace inj_input = ::grackle::impl::inj_model_input; - - grackle::impl::GrainMetalInjectPathways* inject_pathway_props - = my_rates->opaque_storage->inject_pathway_props; - - // record each metal nuclide yield - // -> there is less value to using string keys in this case, but it makes - // some sense to be semi-consistent with the handling of the dust species - // yields - for (int i = 0; i < input->n_metal_nuclide_yields; i++) { - const inj_input::MetalNuclideYieldProps& yield_info = - input->metal_nuclide_yields[i]; - - double* total_yield = nullptr; - double* gas_yield = nullptr; - - // todo: refactor to use a map (I have a rough plan) - if (std::strcmp("C", yield_info.name) == 0) { - total_yield = inject_pathway_props->total_metal_nuclide_yields.C; - gas_yield = inject_pathway_props->gas_metal_nuclide_yields.C; - } else if (std::strcmp("O", yield_info.name) == 0) { - total_yield = inject_pathway_props->total_metal_nuclide_yields.O; - gas_yield = inject_pathway_props->gas_metal_nuclide_yields.O; - } else if (std::strcmp("Mg", yield_info.name) == 0) { - total_yield = inject_pathway_props->total_metal_nuclide_yields.Mg; - gas_yield = inject_pathway_props->gas_metal_nuclide_yields.Mg; - } else if (std::strcmp("Al", yield_info.name) == 0) { - total_yield = inject_pathway_props->total_metal_nuclide_yields.Al; - gas_yield = inject_pathway_props->gas_metal_nuclide_yields.Al; - } else if (std::strcmp("Si", yield_info.name) == 0) { - total_yield = inject_pathway_props->total_metal_nuclide_yields.Si; - gas_yield = inject_pathway_props->gas_metal_nuclide_yields.Si; - } else if (std::strcmp("S", yield_info.name) == 0) { - total_yield = inject_pathway_props->total_metal_nuclide_yields.S; - gas_yield = inject_pathway_props->gas_metal_nuclide_yields.S; - } else if (std::strcmp("Fe", yield_info.name) == 0) { - total_yield = inject_pathway_props->total_metal_nuclide_yields.Fe; - gas_yield = inject_pathway_props->gas_metal_nuclide_yields.Fe; - } else { - return GrPrintAndReturnErr( - "`%s` not a known metal nuclide", yield_info.name); - } - - total_yield[pathway_idx] = yield_info.total_yield; - gas_yield[pathway_idx] = yield_info.gas_yield; - } - - // record each grain species yield - for (int yield_idx = 0; yield_idx < input->n_injected_grain_species; - yield_idx++) { - const inj_input::GrainSpeciesYieldProps& yield_info = - input->initial_grain_props[yield_idx]; - - int grain_species_idx = -1; - double* size_mom_table = nullptr; - double* opac_coef_table = nullptr; - - // with a little refactoring, this will get a lot more concise - if (std::strcmp("MgSiO3_dust", yield_info.name) == 0) { - grain_species_idx = OnlyGrainSpLUT::MgSiO3_dust; - size_mom_table = my_rates->SN0_r0MgSiO3; - opac_coef_table = my_rates->SN0_kpMgSiO3; - } else if (std::strcmp("AC_dust", yield_info.name) == 0) { - grain_species_idx = OnlyGrainSpLUT::AC_dust; - size_mom_table = my_rates->SN0_r0AC; - opac_coef_table = my_rates->SN0_kpAC; - } else if (std::strcmp("SiM_dust", yield_info.name) == 0) { - grain_species_idx = OnlyGrainSpLUT::SiM_dust; - size_mom_table = my_rates->SN0_r0SiM; - opac_coef_table = my_rates->SN0_kpSiM; - } else if (std::strcmp("FeM_dust", yield_info.name) == 0) { - grain_species_idx = OnlyGrainSpLUT::FeM_dust; - size_mom_table = my_rates->SN0_r0FeM; - opac_coef_table = my_rates->SN0_kpFeM; - } else if (std::strcmp("Mg2SiO4_dust", yield_info.name) == 0) { - grain_species_idx = OnlyGrainSpLUT::Mg2SiO4_dust; - size_mom_table = my_rates->SN0_r0Mg2SiO4; - opac_coef_table = my_rates->SN0_kpMg2SiO4; - } else if (std::strcmp("Fe3O4_dust", yield_info.name) == 0) { - grain_species_idx = OnlyGrainSpLUT::Fe3O4_dust; - size_mom_table = my_rates->SN0_r0Fe3O4; - opac_coef_table = my_rates->SN0_kpFe3O4; - } else if (std::strcmp("SiO2_dust", yield_info.name) == 0) { - grain_species_idx = OnlyGrainSpLUT::SiO2_dust; - size_mom_table = my_rates->SN0_r0SiO2D; - opac_coef_table = my_rates->SN0_kpSiO2D; - } else if (std::strcmp("MgO_dust", yield_info.name) == 0) { - grain_species_idx = OnlyGrainSpLUT::MgO_dust; - size_mom_table = my_rates->SN0_r0MgO; - opac_coef_table = my_rates->SN0_kpMgO; - } else if (std::strcmp("FeS_dust", yield_info.name) == 0) { - grain_species_idx = OnlyGrainSpLUT::FeS_dust; - size_mom_table = my_rates->SN0_r0FeS; - opac_coef_table = my_rates->SN0_kpFeS; - } else if (std::strcmp("Al2O3_dust", yield_info.name) == 0) { - grain_species_idx = OnlyGrainSpLUT::Al2O3_dust; - size_mom_table = my_rates->SN0_r0Al2O3; - opac_coef_table = my_rates->SN0_kpAl2O3; - } else if (std::strcmp("ref_org_dust", yield_info.name) == 0) { - grain_species_idx = OnlyGrainSpLUT::ref_org_dust; - size_mom_table = my_rates->SN0_r0reforg; - opac_coef_table = my_rates->SN0_kpreforg; - } else if (std::strcmp("vol_org_dust", yield_info.name) == 0) { - grain_species_idx = OnlyGrainSpLUT::vol_org_dust; - size_mom_table = my_rates->SN0_r0volorg; - opac_coef_table = my_rates->SN0_kpvolorg; - } else if (std::strcmp("H2O_ice_dust", yield_info.name) == 0) { - grain_species_idx = OnlyGrainSpLUT::H2O_ice_dust; - size_mom_table = my_rates->SN0_r0H2Oice; - opac_coef_table = my_rates->SN0_kpH2Oice; - } else { - return GrPrintAndReturnErr( - "`%s` not a known grain species", yield_info.name); - } - - // copy the nonprimordial yield fraction - inject_pathway_props->grain_yields.data[grain_species_idx][pathway_idx] - = yield_info.nonprimoridal_yield_frac; - - /* - // copy the 1st, 2nd, and 3rd moments of the size distribution - // (the 0th moment isn't recorded anywhere - for (int i = 0; i < 3; i++) { - size_mom_table[pathway_idx*3+i] = yield_info.size_moments[i]; - } - - // copy over the opacity coefficients table - { - int n_Td = N_Tdust_Opacity_Table; - int n_coef = N_Opacity_Coef; - for (int i_Td = 0; i_Td < n_Td; i_Td++) { - for (int i_coef = 0; i_coef < n_coef; i_coef++) { - int i = (pathway_idx * n_Td * n_coef) + (i_Td * n_coef) + i_coef; - opac_coef_table[i] = yield_info.opacity_coef_table[i_Td][i_coef]; - } - } - } - */ - } - - return GR_SUCCESS; -} +namespace { // stuff inside an anonymous namespace is local to this file int calc_rates_dust_loc(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates) { diff --git a/src/clib/inject_model/raw_data.hpp b/src/clib/inject_model/raw_data.hpp index 97f9e0c33..aad12e52c 100644 --- a/src/clib/inject_model/raw_data.hpp +++ b/src/clib/inject_model/raw_data.hpp @@ -11,17 +11,21 @@ /// declares a function for accessing this data. /// /// @note -/// It's worth emphasizing that all machinery declared in this file are only -/// introduced temporarily. The long-term plan is to drop all of the machinery -/// once we start encoding the data within HDF5 files. The main barrier to -/// adopting HDF5 for this purpose is that I would like to first remove all -/// usage of the data currently encoded in MetalNuclideYieldProps::total_yield -/// (so that we can avoid encoding it in the HDF5 file). +/// It's worth emphasizing that all machinery declared in this file is only +/// intended to be temporary. The long-term plan is to drop all of the +/// machinery once we start encoding the data within HDF5 files. The main +/// barrier to adopting HDF5 for this purpose is that I would like to first +/// remove all usage of the data currently encoded in +/// MetalNuclideYieldProps::total_yield (so that we can avoid encoding it in +/// the HDF5 file). /// //===----------------------------------------------------------------------===// #ifndef INJECT_MODEL_RAW_DATA_HPP #define INJECT_MODEL_RAW_DATA_HPP + +#include "grackle.h" // GR_SUCCESS + namespace grackle::impl::inj_model_input { /// the number of opacity-related coefficients that are grouped together @@ -52,8 +56,6 @@ struct GrainSpeciesYieldProps; /// @note /// The plan is to eventually shift the data into a file loaded at runtime struct InjectionPathwayInputData { - const char* name; - const MetalNuclideYieldProps* metal_nuclide_yields; int n_metal_nuclide_yields; @@ -98,6 +100,29 @@ struct GrainSpeciesYieldProps { double opacity_coef_table[N_Tdust_Opacity_Table][N_Opacity_Coef]; }; +extern "C" { +/// protoype for callback function used with input_inject_model_iterate +typedef int (*inj_iterate_t)(const char* name, InjectionPathwayInputData* input, + void* op_data); +} + +/// iterates over injection model input data packs with user callback routine +/// +/// @param[in] op Callback function +/// @param[inout] op_data User-defined callback function context +/// +/// @returns GR_SUCCESS if all calls to @p op returns GR_SUCCESS. Any other +/// value denotes an error. +/// +/// If any call to @p op is not `GR_SUCCESS`, this function exits immediately +/// +/// @note +/// we choose to provide access to each injection model's raw input data via +/// callback routines since the equivalent HDF5 (when we eventually shift) will +/// also involve callbacks (i.e. via `H5Literate`). By initially writing the +/// code using callbacks, the transition to HDF5 should be easier. +int input_inject_model_iterate(inj_iterate_t op, void* op_data); + } // namespace grackle::impl::inj_model_input #endif // INJECT_MODEL_RAW_DATA_HPP From 08ecd6ba0ee95de1de553d5b66cf794dd9033a59 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Fri, 5 Dec 2025 21:11:34 -0500 Subject: [PATCH 027/175] Major progress in restructuring format of injection pathway raw data We don't yet use the new format, but we are just about ready to start doing so --- src/clib/CMakeLists.txt | 2 +- src/clib/initialize_dust_yields.cpp | 67 +- src/clib/inject_model/raw_data.cpp | 3850 +++++++++++++++++++++++++++ src/clib/inject_model/raw_data.hpp | 3 +- 4 files changed, 3912 insertions(+), 10 deletions(-) create mode 100644 src/clib/inject_model/raw_data.cpp diff --git a/src/clib/CMakeLists.txt b/src/clib/CMakeLists.txt index 3a1ee38c8..67f545d74 100644 --- a/src/clib/CMakeLists.txt +++ b/src/clib/CMakeLists.txt @@ -118,7 +118,7 @@ add_library(Grackle_Grackle initialize_dust_yields.cpp initialize_dust_yields.hpp initialize_rates.cpp initialize_rates.hpp inject_model/grain_metal_inject_pathways.hpp - inject_model/raw_data.hpp + inject_model/raw_data.cpp inject_model/raw_data.hpp internal_types.cpp internal_types.hpp interp_table_utils.hpp lookup_cool_rates1d.hpp diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index fae89780c..153934cbc 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -46,13 +46,56 @@ typedef int calc_yield_rate_fn(int, chemistry_data*, chemistry_data_storage*); namespace { // stuff inside an anonymous namespace is local to this file -int setup_yield_table_helper( - int pathway_idx, - chemistry_data_storage *my_rates, - const grackle::impl::inj_model_input::InjectionPathwayInputData *input) +int lookup_pathway_idx(const char* name) { + const char * known_names[12] = { + "local_ISM", "ccsn13", "ccsn20", "ccsn25", "ccsn30", "fsn13", + "fsn15", "fsn50", "fsn80", "pisn170", "pisn200", "y19", + }; + + for (int i = 0; i < 12; i++){ + if (std::strcmp(known_names[i], name) == 0){ + return i; + } + } + return -1; +} + +/// the context object for setup_yield_table_callback +struct SetupCallbackCtx{ + chemistry_data_storage *my_rates; + int setup_counter; +}; + +/// a callback function that sets up the appropriate parts of +/// GrainMetalInjectPathways given data for a particular injection pathway +/// +/// @param[in] name Name of the current injection pathway +/// @param[in] input Holds the data for the current injection pathway. +/// @param[inout] ctx A pointer to a SetupCallbackCtx instance +/// +/// @note +/// This function has C linkage because that's the expectation of the function +/// receiving this callback +extern "C" int setup_yield_table_callback( + const char* name, + const grackle::impl::inj_model_input::InjectionPathwayInputData *input, + void* ctx) { namespace inj_input = ::grackle::impl::inj_model_input; + + int pathway_idx = lookup_pathway_idx(name); + + if (pathway_idx < 0) { + return GrPrintAndReturnErr( + "`%s` is an unexpected injection pathway name", name); + } + //printf("encounterd: `%s`, pathway_idx: %d\n", name, pathway_idx); + //fflush(stdout); + + chemistry_data_storage *my_rates = + static_cast(ctx)->my_rates; + grackle::impl::GrainMetalInjectPathways* inject_pathway_props = my_rates->opaque_storage->inject_pathway_props; @@ -94,8 +137,8 @@ int setup_yield_table_helper( "`%s` not a known metal nuclide", yield_info.name); } - total_yield[pathway_idx] = yield_info.total_yield; - gas_yield[pathway_idx] = yield_info.gas_yield; + //total_yield[pathway_idx] = yield_info.total_yield; + //gas_yield[pathway_idx] = yield_info.gas_yield; } // record each grain species yield @@ -166,11 +209,11 @@ int setup_yield_table_helper( "`%s` not a known grain species", yield_info.name); } + /* // copy the nonprimordial yield fraction inject_pathway_props->grain_yields.data[grain_species_idx][pathway_idx] = yield_info.nonprimoridal_yield_frac; - /* // copy the 1st, 2nd, and 3rd moments of the size distribution // (the 0th moment isn't recorded anywhere for (int i = 0; i < 3; i++) { @@ -392,8 +435,16 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, int rv = fn_list[i](i, my_chemistry, my_rates); if (rv != SUCCESS) { return rv; } } + SetupCallbackCtx ctx = {my_rates, 0}; - return SUCCESS; + int ret = grackle::impl::inj_model_input::input_inject_model_iterate( + &setup_yield_table_callback, static_cast(&ctx)); + if (ret != GR_SUCCESS) { + GRIMPL_ERROR("THERE WAS AN ERROR"); + } + //return GR_FAIL; + + return GR_SUCCESS; } int grackle::impl::free_dust_yields(chemistry_data *my_chemistry, diff --git a/src/clib/inject_model/raw_data.cpp b/src/clib/inject_model/raw_data.cpp new file mode 100644 index 000000000..2d5a7b72d --- /dev/null +++ b/src/clib/inject_model/raw_data.cpp @@ -0,0 +1,3850 @@ +//===----------------------------------------------------------------------===// +// +// See the LICENSE file for license and copyright information +// SPDX-License-Identifier: NCSA AND BSD-3-Clause +// +//===----------------------------------------------------------------------===// +/// +/// @file +/// Implements some data structures used for organizing the raw input injection +/// model data, which is currently embedded as part of the Grackle library) and +/// a function for accessing this data. +/// +/// @note +/// It's worth mentioning that this file is intended to be temporary. For more +/// details, see the file-level docstring in the header-file associated with +/// this file. +/// +//===----------------------------------------------------------------------===// + +#include "raw_data.hpp" + +#define ARR_LEN(var_name, type) (sizeof(var_name) / sizeof(type)) +namespace grackle::impl::inj_model_input { +// declare/initialize static constant variables holding data for each known +// injection model (in namespaces named for each model) + +// clang-format off: disable reformatting of data tables + +namespace local_ISM { +static const MetalNuclideYieldProps metal_props[] = { + // {name, gas_yield, total_yield} + {"C", 5.01317e-02, 1.79042e-01}, + {"O", 2.78491e-01, 5.11524e-01}, + {"Mg", 0.00000e+00, 3.46246e-02}, + {"Al", 3.07922e-03, 3.07922e-03}, + {"Si", 3.50813e-03, 3.76121e-02}, + {"S", 0.00000e+00, 2.21374e-02}, + {"Fe", 1.66568e-04, 6.77017e-02}, +}; + +static const GrainSpeciesYieldProps grain_props[] = { + { + /* name = */ "FeM_dust", + /* nonprimoridal_yield_frac = */ 1.35403e-02, + /* size_moments = */ {8.33039e-07, 1.16161e-12, 8.21384e-18}, + /* opacity_coef_table = */ { + {2.45237e-01, 1.46287e-07, 1.48927e-13, 1.14540e-18}, + {3.08964e-01, 1.84301e-07, 1.87627e-13, 1.44311e-18}, + {3.89192e-01, 2.32158e-07, 2.36348e-13, 1.81790e-18}, + {4.90193e-01, 2.92406e-07, 2.97684e-13, 2.28974e-18}, + {6.33568e-01, 3.77932e-07, 3.84757e-13, 2.95995e-18}, + {8.28859e-01, 4.94426e-07, 5.03359e-13, 3.87306e-18}, + {1.13002e+00, 6.74071e-07, 6.86261e-13, 5.28188e-18}, + {1.63064e+00, 9.72699e-07, 9.90315e-13, 7.62608e-18}, + {2.46680e+00, 1.47148e-06, 1.49820e-12, 1.15475e-17}, + {3.79604e+00, 2.26439e-06, 2.30565e-12, 1.77932e-17}, + {5.92492e+00, 3.53430e-06, 3.59906e-12, 2.78297e-17}, + {9.23920e+00, 5.51134e-06, 5.61323e-12, 4.35401e-17}, + {1.42293e+01, 8.48802e-06, 8.64701e-12, 6.73899e-17}, + {2.16427e+01, 1.29103e-05, 1.31570e-11, 1.03293e-16}, + {3.24523e+01, 1.93586e-05, 1.97391e-11, 1.56579e-16}, + {4.78595e+01, 2.85497e-05, 2.91302e-11, 2.33879e-16}, + {7.00593e+01, 4.17932e-05, 4.26757e-11, 3.46486e-16}, + {1.06051e+02, 6.32653e-05, 6.46560e-11, 5.28640e-16}, + {1.74267e+02, 1.03964e-04, 1.06329e-10, 8.68729e-16}, + {3.02053e+02, 1.80203e-04, 1.84359e-10, 1.49313e-15}, + {5.00593e+02, 2.98655e-04, 3.05537e-10, 2.44653e-15}, + {7.45698e+02, 4.44894e-04, 4.55158e-10, 3.61190e-15}, + {1.00149e+03, 5.97517e-04, 6.11446e-10, 4.82507e-15}, + {1.23701e+03, 7.38051e-04, 7.55475e-10, 5.93849e-15}, + {1.39749e+03, 8.33819e-04, 8.53626e-10, 6.68589e-15}, + {1.41344e+03, 8.43342e-04, 8.63374e-10, 6.74095e-15}, + {1.26599e+03, 7.55370e-04, 7.73283e-10, 6.02512e-15}, + {1.01032e+03, 6.02819e-04, 6.17127e-10, 4.80541e-15}, + {7.30148e+02, 4.35656e-04, 4.46054e-10, 3.47626e-15}, + {4.87070e+02, 2.90623e-04, 2.97653e-10, 2.32554e-15}, + {3.05625e+02, 1.82365e-04, 1.86919e-10, 1.46881e-15}, + {1.84266e+02, 1.09966e-04, 1.12993e-10, 9.02608e-16}, + {1.10340e+02, 6.58826e-05, 6.82482e-11, 5.72358e-16}, + {6.91207e+01, 4.13300e-05, 4.36913e-11, 4.08010e-16}, + {4.77899e+01, 2.86629e-05, 3.13943e-11, 3.40524e-16}, + } + }, + { + /* name = */ "Mg2SiO4_dust", + /* nonprimoridal_yield_frac = */ 1.36165e-01, + /* size_moments = */ {8.33039e-07, 1.16161e-12, 8.21384e-18}, + /* opacity_coef_table = */ { + {5.12401e-02, 3.05654e-08, 3.11170e-14, 2.39327e-19}, + {9.10229e-02, 5.42964e-08, 5.52765e-14, 4.25193e-19}, + {1.41106e-01, 8.41719e-08, 8.56916e-14, 6.59185e-19}, + {2.04158e-01, 1.21783e-07, 1.23982e-13, 9.53762e-19}, + {3.33897e-01, 1.99174e-07, 2.02773e-13, 1.56024e-18}, + {5.10947e-01, 3.04787e-07, 3.10298e-13, 2.38807e-18}, + {7.83563e-01, 4.67406e-07, 4.75863e-13, 3.66337e-18}, + {1.19854e+00, 7.14943e-07, 7.27902e-13, 5.60698e-18}, + {1.85772e+00, 1.10816e-06, 1.12831e-12, 8.70099e-18}, + {2.92247e+00, 1.74330e-06, 1.77515e-12, 1.37124e-17}, + {4.74091e+00, 2.82803e-06, 2.88010e-12, 2.23096e-17}, + {7.79816e+00, 4.65174e-06, 4.73847e-12, 3.68720e-17}, + {1.27207e+01, 7.58818e-06, 7.73243e-12, 6.06033e-17}, + {2.05556e+01, 1.22619e-05, 1.25020e-11, 9.90816e-17}, + {3.30490e+01, 1.97147e-05, 2.01153e-11, 1.61650e-16}, + {5.32277e+01, 3.17524e-05, 3.24225e-11, 2.63830e-16}, + {8.64944e+01, 5.15982e-05, 5.27236e-11, 4.32162e-16}, + {1.43144e+02, 8.53944e-05, 8.73076e-11, 7.16006e-16}, + {2.41992e+02, 1.44367e-04, 1.47663e-10, 1.20379e-15}, + {4.08980e+02, 2.43996e-04, 2.49602e-10, 2.01287e-15}, + {6.57282e+02, 3.92138e-04, 4.01100e-10, 3.19447e-15}, + {9.65951e+02, 5.76298e-04, 5.89371e-10, 4.64306e-15}, + {1.30489e+03, 7.78527e-04, 7.96032e-10, 6.21292e-15}, + {1.65692e+03, 9.88559e-04, 1.01028e-09, 7.80402e-15}, + {1.95936e+03, 1.16899e-03, 1.19360e-09, 9.11030e-15}, + {2.08639e+03, 1.24475e-03, 1.26965e-09, 9.58003e-15}, + {1.95845e+03, 1.16840e-03, 1.19068e-09, 8.90255e-15}, + {1.62353e+03, 9.68572e-04, 9.86379e-10, 7.32855e-15}, + {1.20759e+03, 7.20421e-04, 7.33336e-10, 5.42763e-15}, + {8.22295e+02, 4.90559e-04, 4.99228e-10, 3.68795e-15}, + {5.22496e+02, 3.11708e-04, 3.17198e-10, 2.34267e-15}, + {3.14915e+02, 1.87872e-04, 1.91211e-10, 1.41447e-15}, + {1.82496e+02, 1.08876e-04, 1.10875e-10, 8.23864e-16}, + {1.02901e+02, 6.13959e-05, 6.26109e-11, 4.69856e-16}, + {5.73186e+01, 3.42174e-05, 3.50508e-11, 2.68356e-16}, + } + }, + { + /* name = */ "MgSiO3_dust", + /* nonprimoridal_yield_frac = */ 3.84003e-02, + /* size_moments = */ {8.33039e-07, 1.16161e-12, 8.21384e-18}, + /* opacity_coef_table = */ { + {1.20726e-01, 7.20182e-08, 7.35280e-14, 5.95267e-19}, + {2.32766e-01, 1.38854e-07, 1.41735e-13, 1.14369e-18}, + {3.73816e-01, 2.22995e-07, 2.27602e-13, 1.83408e-18}, + {5.51388e-01, 3.28923e-07, 3.35702e-13, 2.70320e-18}, + {8.55868e-01, 5.10557e-07, 5.21179e-13, 4.21168e-18}, + {1.24954e+00, 7.45400e-07, 7.61051e-13, 6.17189e-18}, + {1.78078e+00, 1.06231e-06, 1.08497e-12, 8.85200e-18}, + {2.44607e+00, 1.45920e-06, 1.49119e-12, 1.23029e-17}, + {3.21763e+00, 1.91949e-06, 1.96357e-12, 1.65254e-17}, + {4.06334e+00, 2.42404e-06, 2.48333e-12, 2.14914e-17}, + {4.90080e+00, 2.92371e-06, 3.00112e-12, 2.69365e-17}, + {5.64261e+00, 3.36638e-06, 3.46359e-12, 3.23217e-17}, + {6.21740e+00, 3.70948e-06, 3.82669e-12, 3.70749e-17}, + {6.56246e+00, 3.91565e-06, 4.05361e-12, 4.08425e-17}, + {6.75396e+00, 4.03063e-06, 4.20072e-12, 4.47151e-17}, + {7.17709e+00, 4.28498e-06, 4.53461e-12, 5.31551e-17}, + {8.60795e+00, 5.14313e-06, 5.58433e-12, 7.44632e-17}, + {1.17764e+01, 7.04212e-06, 7.86423e-12, 1.17214e-16}, + {1.64787e+01, 9.86444e-06, 1.14471e-11, 1.95038e-16}, + {2.14143e+01, 1.28476e-05, 1.62848e-11, 3.61550e-16}, + {2.51760e+01, 1.51720e-05, 2.28477e-11, 7.25431e-16}, + {2.71833e+01, 1.64950e-05, 3.14267e-11, 1.35273e-15}, + {2.77234e+01, 1.69657e-05, 4.09753e-11, 2.14916e-15}, + {2.74221e+01, 1.69259e-05, 4.94400e-11, 2.89997e-15}, + {2.68227e+01, 1.66816e-05, 5.53227e-11, 3.43309e-15}, + {2.62247e+01, 1.64266e-05, 5.86985e-11, 3.72279e-15}, + {2.58704e+01, 1.64543e-05, 6.22578e-11, 3.90038e-15}, + {2.71342e+01, 1.84130e-05, 7.74409e-11, 4.33089e-15}, + {3.69065e+01, 2.84578e-05, 1.28908e-10, 5.42457e-15}, + {7.78838e+01, 6.43091e-05, 2.58063e-10, 7.39401e-15}, + {1.96086e+02, 1.59699e-04, 5.23332e-10, 1.03910e-14}, + {4.47749e+02, 3.52292e-04, 9.69286e-10, 1.44002e-14}, + {8.75250e+02, 6.66973e-04, 1.60576e-09, 1.92445e-14}, + {1.50099e+03, 1.11385e-03, 2.41814e-09, 2.47015e-14}, + {2.33693e+03, 1.69566e-03, 3.38124e-09, 3.05222e-14}, + } + }, + { + /* name = */ "FeS_dust", + /* nonprimoridal_yield_frac = */ 3.04389e-02, + /* size_moments = */ {8.33039e-07, 1.16161e-12, 8.21384e-18}, + /* opacity_coef_table = */ { + {4.68555e-02, 2.79499e-08, 2.84543e-14, 2.18837e-19}, + {6.66016e-02, 3.97287e-08, 4.04457e-14, 3.11065e-19}, + {9.14604e-02, 5.45574e-08, 5.55420e-14, 4.27173e-19}, + {1.22756e-01, 7.32255e-08, 7.45471e-14, 5.73344e-19}, + {2.39395e-01, 1.42802e-07, 1.45382e-13, 1.11857e-18}, + {4.33638e-01, 2.58671e-07, 2.63349e-13, 2.02683e-18}, + {8.54269e-01, 5.09583e-07, 5.18807e-13, 3.99441e-18}, + {1.71749e+00, 1.02450e-06, 1.04308e-12, 8.03545e-18}, + {3.29447e+00, 1.96520e-06, 2.00091e-12, 1.54275e-17}, + {5.86107e+00, 3.49621e-06, 3.55997e-12, 2.74796e-17}, + {9.98591e+00, 5.95675e-06, 6.06595e-12, 4.69112e-17}, + {1.64428e+01, 9.80839e-06, 9.98976e-12, 7.74960e-17}, + {2.63091e+01, 1.56939e-05, 1.59880e-11, 1.24634e-16}, + {4.13343e+01, 2.46568e-05, 2.51287e-11, 1.97408e-16}, + {6.41346e+01, 3.82579e-05, 3.90120e-11, 3.09791e-16}, + {9.87636e+01, 5.89156e-05, 6.01167e-11, 4.83037e-16}, + {1.51958e+02, 9.06488e-05, 9.25564e-11, 7.50644e-16}, + {2.34417e+02, 1.39841e-04, 1.42858e-10, 1.16365e-15}, + {3.57697e+02, 2.13387e-04, 2.18076e-10, 1.77561e-15}, + {5.28819e+02, 3.15479e-04, 3.22528e-10, 2.61825e-15}, + {7.52235e+02, 4.48774e-04, 4.59023e-10, 3.71332e-15}, + {1.02632e+03, 6.12308e-04, 6.26695e-10, 5.05587e-15}, + {1.32111e+03, 7.88218e-04, 8.07423e-10, 6.50989e-15}, + {1.57574e+03, 9.40185e-04, 9.64291e-10, 7.80218e-15}, + {1.73868e+03, 1.03748e-03, 1.06621e-09, 8.71453e-15}, + {1.80162e+03, 1.07516e-03, 1.10855e-09, 9.23861e-15}, + {1.79360e+03, 1.07058e-03, 1.10965e-09, 9.55041e-15}, + {1.76388e+03, 1.05316e-03, 1.10040e-09, 9.92949e-15}, + {1.76147e+03, 1.05218e-03, 1.11104e-09, 1.06225e-14}, + {1.80062e+03, 1.07614e-03, 1.14939e-09, 1.16303e-14}, + {1.85114e+03, 1.10702e-03, 1.19518e-09, 1.26854e-14}, + {1.87614e+03, 1.12283e-03, 1.22470e-09, 1.35171e-14}, + {1.86911e+03, 1.11985e-03, 1.23456e-09, 1.40796e-14}, + {1.85783e+03, 1.11511e-03, 1.24487e-09, 1.45610e-14}, + {1.90737e+03, 1.14893e-03, 1.30468e-09, 1.53873e-14}, + } + }, + { + /* name = */ "ref_org_dust", + /* nonprimoridal_yield_frac = */ 1.86114e-01, + /* size_moments = */ {8.33039e-07, 1.16161e-12, 8.21384e-18}, + /* opacity_coef_table = */ { + {7.02832e-02, 4.19249e-08, 4.26814e-14, 3.28255e-19}, + {9.99024e-02, 5.95931e-08, 6.06685e-14, 4.66597e-19}, + {1.37191e-01, 8.18361e-08, 8.33130e-14, 6.40759e-19}, + {1.84134e-01, 1.09838e-07, 1.11821e-13, 8.60016e-19}, + {3.59093e-01, 2.14204e-07, 2.18074e-13, 1.67786e-18}, + {6.50459e-01, 3.88007e-07, 3.95023e-13, 3.04025e-18}, + {1.28140e+00, 7.64376e-07, 7.78212e-13, 5.99162e-18}, + {2.57622e+00, 1.53675e-06, 1.56462e-12, 1.20532e-17}, + {4.94170e+00, 2.94779e-06, 3.00137e-12, 2.31413e-17}, + {8.79162e+00, 5.24433e-06, 5.33996e-12, 4.12194e-17}, + {1.49789e+01, 8.93514e-06, 9.09893e-12, 7.03669e-17}, + {2.46641e+01, 1.47126e-05, 1.49846e-11, 1.16244e-16}, + {3.94637e+01, 2.35409e-05, 2.39820e-11, 1.86951e-16}, + {6.20013e+01, 3.69851e-05, 3.76930e-11, 2.96113e-16}, + {9.62020e+01, 5.73870e-05, 5.85180e-11, 4.64688e-16}, + {1.48145e+02, 8.83735e-05, 9.01751e-11, 7.24557e-16}, + {2.27937e+02, 1.35973e-04, 1.38835e-10, 1.12597e-15}, + {3.51626e+02, 2.09762e-04, 2.14288e-10, 1.74548e-15}, + {5.36545e+02, 3.20081e-04, 3.27114e-10, 2.66341e-15}, + {7.93228e+02, 4.73218e-04, 4.83793e-10, 3.92738e-15}, + {1.12835e+03, 6.73161e-04, 6.88534e-10, 5.56999e-15}, + {1.53947e+03, 9.18463e-04, 9.40042e-10, 7.58380e-15}, + {1.98167e+03, 1.18233e-03, 1.21114e-09, 9.76484e-15}, + {2.36362e+03, 1.41028e-03, 1.44644e-09, 1.17033e-14}, + {2.60802e+03, 1.55622e-03, 1.59931e-09, 1.30718e-14}, + {2.70242e+03, 1.61274e-03, 1.66283e-09, 1.38579e-14}, + {2.69039e+03, 1.60586e-03, 1.66448e-09, 1.43256e-14}, + {2.64583e+03, 1.57974e-03, 1.65060e-09, 1.48942e-14}, + {2.64222e+03, 1.57827e-03, 1.66657e-09, 1.59338e-14}, + {2.70093e+03, 1.61421e-03, 1.72408e-09, 1.74454e-14}, + {2.77670e+03, 1.66053e-03, 1.79277e-09, 1.90281e-14}, + {2.81420e+03, 1.68424e-03, 1.83704e-09, 2.02756e-14}, + {2.80366e+03, 1.67977e-03, 1.85184e-09, 2.11194e-14}, + {2.78675e+03, 1.67267e-03, 1.86731e-09, 2.18416e-14}, + {2.86105e+03, 1.72339e-03, 1.95702e-09, 2.30809e-14}, + } + }, + { + /* name = */ "vol_org_dust", + /* nonprimoridal_yield_frac = */ 3.81956e-02, + /* size_moments = */ {8.33039e-07, 1.16161e-12, 8.21384e-18}, + /* opacity_coef_table = */ { + {6.30862e-02, 3.76318e-08, 3.83108e-14, 2.94648e-19}, + {1.09691e-01, 6.54321e-08, 6.66131e-14, 5.12363e-19}, + {1.68363e-01, 1.00431e-07, 1.02243e-13, 7.86449e-19}, + {2.42226e-01, 1.44491e-07, 1.47099e-13, 1.13150e-18}, + {3.92991e-01, 2.34424e-07, 2.38657e-13, 1.83595e-18}, + {6.03026e-01, 3.59713e-07, 3.66210e-13, 2.81745e-18}, + {9.41509e-01, 5.61623e-07, 5.71771e-13, 4.39959e-18}, + {1.54206e+00, 9.19862e-07, 9.36500e-13, 7.20849e-18}, + {2.75198e+00, 1.64160e-06, 1.67135e-12, 1.28735e-17}, + {5.12965e+00, 3.05991e-06, 3.11550e-12, 2.40170e-17}, + {9.67703e+00, 5.77249e-06, 5.87767e-12, 4.53565e-17}, + {1.70842e+01, 1.01910e-05, 1.03775e-11, 8.02010e-17}, + {2.87858e+01, 1.71712e-05, 1.74882e-11, 1.35552e-16}, + {5.22985e+01, 3.11971e-05, 3.17818e-11, 2.47506e-16}, + {1.08421e+02, 6.46756e-05, 6.59042e-11, 5.15083e-16}, + {2.29694e+02, 1.37018e-04, 1.39634e-10, 1.09171e-15}, + {4.35888e+02, 2.60019e-04, 2.64976e-10, 2.06803e-15}, + {6.94501e+02, 4.14288e-04, 4.22159e-10, 3.28761e-15}, + {9.21763e+02, 5.49857e-04, 5.60297e-10, 4.35726e-15}, + {1.06208e+03, 6.33565e-04, 6.45702e-10, 5.02330e-15}, + {1.17460e+03, 7.00699e-04, 7.14492e-10, 5.57174e-15}, + {1.41297e+03, 8.42922e-04, 8.60130e-10, 6.71698e-15}, + {1.86068e+03, 1.11004e-03, 1.13311e-09, 8.82123e-15}, + {2.38031e+03, 1.42005e-03, 1.44954e-09, 1.12234e-14}, + {2.71131e+03, 1.61753e-03, 1.65107e-09, 1.27373e-14}, + {2.72120e+03, 1.62346e-03, 1.65757e-09, 1.27900e-14}, + {2.53189e+03, 1.51058e-03, 1.54284e-09, 1.19191e-14}, + {2.48249e+03, 1.48118e-03, 1.51103e-09, 1.15227e-14}, + {2.89111e+03, 1.72503e-03, 1.75260e-09, 1.28501e-14}, + {3.66301e+03, 2.18553e-03, 2.21015e-09, 1.55022e-14}, + {4.27842e+03, 2.55260e-03, 2.57302e-09, 1.74959e-14}, + {4.29745e+03, 2.56387e-03, 2.57944e-09, 1.72213e-14}, + {3.71668e+03, 2.21732e-03, 2.22839e-09, 1.47266e-14}, + {2.83563e+03, 1.69168e-03, 1.69914e-09, 1.11685e-14}, + {1.96048e+03, 1.16958e-03, 1.17438e-09, 7.69912e-15}, + } + }, + { + /* name = */ "H2O_ice_dust", + /* nonprimoridal_yield_frac = */ 6.33011e-02, + /* size_moments = */ {8.33039e-07, 1.16161e-12, 8.21384e-18}, + /* opacity_coef_table = */ { + {3.03937e-04, 1.23816e-09, 4.62094e-14, 3.72497e-18}, + {5.33931e-04, 1.94666e-09, 6.42306e-14, 4.92267e-18}, + {8.23085e-04, 2.82715e-09, 8.64655e-14, 6.40508e-18}, + {1.18689e-03, 3.92926e-09, 1.14201e-13, 8.25547e-18}, + {1.93090e-03, 5.86828e-09, 1.50433e-13, 1.02764e-17}, + {2.95251e-03, 8.43657e-09, 1.95467e-13, 1.27089e-17}, + {4.55033e-03, 1.22013e-08, 2.52591e-13, 1.54880e-17}, + {7.04895e-03, 1.77533e-08, 3.26595e-13, 1.87358e-17}, + {1.09337e-02, 2.59554e-08, 4.24054e-13, 2.26060e-17}, + {1.67787e-02, 3.77909e-08, 5.51941e-13, 2.72576e-17}, + {2.56790e-02, 5.50228e-08, 7.20688e-13, 3.28090e-17}, + {3.89780e-02, 7.95600e-08, 9.39516e-13, 3.93285e-17}, + {5.82741e-02, 1.13372e-07, 1.21633e-12, 4.68721e-17}, + {8.58228e-02, 1.58873e-07, 1.55917e-12, 5.54857e-17}, + {1.24511e-01, 2.18724e-07, 1.97549e-12, 6.52470e-17}, + {1.78164e-01, 2.96038e-07, 2.47229e-12, 7.62244e-17}, + {2.51965e-01, 3.94501e-07, 3.05495e-12, 8.84292e-17}, + {3.53706e-01, 5.19228e-07, 3.72904e-12, 1.01872e-16}, + {4.96690e-01, 6.79268e-07, 4.51008e-12, 1.16807e-16}, + {7.06391e-01, 8.93298e-07, 5.44240e-12, 1.34078e-16}, + {1.03345e+00, 1.19958e-06, 6.62440e-12, 1.55520e-16}, + {1.58058e+00, 1.67481e-06, 8.24715e-12, 1.84604e-16}, + {2.55750e+00, 2.47088e-06, 1.06606e-11, 2.27517e-16}, + {4.39505e+00, 3.88891e-06, 1.44836e-11, 2.94492e-16}, + {7.97338e+00, 6.52370e-06, 2.07697e-11, 4.00081e-16}, + {1.50676e+01, 1.15419e-05, 3.12837e-11, 5.61771e-16}, + {2.91750e+01, 2.11959e-05, 4.90431e-11, 7.99872e-16}, + {5.69546e+01, 3.97177e-05, 7.93362e-11, 1.14279e-15}, + {1.10473e+02, 7.47151e-05, 1.31340e-10, 1.63629e-15}, + {2.10337e+02, 1.39130e-04, 2.20345e-10, 2.35251e-15}, + {3.89661e+02, 2.53753e-04, 3.70677e-10, 3.39830e-15}, + {6.99152e+02, 4.50456e-04, 6.19407e-10, 4.92457e-15}, + {1.21457e+03, 7.76739e-04, 1.02057e-09, 7.13090e-15}, + {2.05022e+03, 1.30302e-03, 1.64745e-09, 1.02322e-14}, + {3.38793e+03, 2.13731e-03, 2.59306e-09, 1.43690e-14}, + } + }, +}; + +} // namespace local_ISM + +namespace ccsn13 { +static const MetalNuclideYieldProps metal_props[] = { + // {name, gas_yield, total_yield} + {"C", 2.16731e-01, 2.65314e-01}, + {"O", 2.99231e-01, 3.00982e-01}, + {"Mg", 3.03586e-02, 3.06651e-02}, + {"Al", 2.47296e-04, 2.47296e-04}, + {"Si", 4.59041e-02, 6.38319e-02}, + {"S", 3.40903e-02, 3.40910e-02}, + {"Fe", 7.22586e-02, 9.62448e-02}, +}; + +static const GrainSpeciesYieldProps grain_props[] = { + { + /* name = */ "SiM_dust", + /* nonprimoridal_yield_frac = */ 1.65746e-02, + /* size_moments = */ {1.68557e-06, 9.75226e-12, 1.74046e-16}, + /* opacity_coef_table = */ { + {5.88921e-03, 6.87770e-08, 1.06227e-12, 2.02349e-17}, + {1.01153e-02, 1.15444e-07, 1.74157e-12, 3.24501e-17}, + {1.53919e-02, 1.73359e-07, 2.57952e-12, 4.74426e-17}, + {2.20096e-02, 2.45791e-07, 3.62468e-12, 6.61001e-17}, + {3.50047e-02, 3.82752e-07, 5.51942e-12, 9.85221e-17}, + {5.25286e-02, 5.65069e-07, 8.00632e-12, 1.40508e-16}, + {7.91090e-02, 8.36026e-07, 1.16179e-11, 2.00078e-16}, + {1.19191e-01, 1.23677e-06, 1.68430e-11, 2.84365e-16}, + {1.79251e-01, 1.82633e-06, 2.43704e-11, 4.03226e-16}, + {2.66584e-01, 2.66955e-06, 3.49349e-11, 5.66851e-16}, + {3.94058e-01, 3.87941e-06, 4.97989e-11, 7.92464e-16}, + {5.74681e-01, 5.56462e-06, 7.01108e-11, 1.09474e-15}, + {8.20409e-01, 7.81996e-06, 9.68130e-11, 1.48491e-15}, + {1.14378e+00, 1.07400e-05, 1.30804e-10, 1.97313e-15}, + {1.55566e+00, 1.44006e-05, 1.72756e-10, 2.56649e-15}, + {2.06561e+00, 1.88620e-05, 2.23158e-10, 3.26978e-15}, + {2.68069e+00, 2.41572e-05, 2.82187e-10, 4.08370e-15}, + {3.40683e+00, 3.03006e-05, 3.49792e-10, 5.00618e-15}, + {4.25797e+00, 3.73606e-05, 4.26499e-10, 6.04358e-15}, + {5.27551e+00, 4.56092e-05, 5.14976e-10, 7.23179e-15}, + {6.55438e+00, 5.57066e-05, 6.21908e-10, 8.66078e-15}, + {8.27812e+00, 6.89310e-05, 7.60263e-10, 1.05052e-14}, + {1.07753e+01, 8.75306e-05, 9.52770e-10, 1.30714e-14}, + {1.46156e+01, 1.15279e-04, 1.23703e-09, 1.68635e-14}, + {2.07765e+01, 1.58349e-04, 1.67242e-09, 2.26556e-14}, + {3.09403e+01, 2.26776e-04, 2.35074e-09, 3.15878e-14}, + {4.80249e+01, 3.37152e-04, 3.41710e-09, 4.53799e-14}, + {7.70965e+01, 5.17359e-04, 5.10858e-09, 6.67630e-14}, + {1.26831e+02, 8.14201e-04, 7.81618e-09, 1.00160e-13}, + {2.11638e+02, 1.30438e-03, 1.21704e-08, 1.52564e-13}, + {3.54644e+02, 2.11006e-03, 1.91598e-08, 2.34688e-13}, + {5.91556e+02, 3.41851e-03, 3.02724e-08, 3.62228e-13}, + {9.74370e+02, 5.49677e-03, 4.75739e-08, 5.56235e-13}, + {1.56930e+03, 8.65788e-03, 7.33192e-08, 8.38100e-13}, + {2.44406e+03, 1.31389e-02, 1.08763e-07, 1.21599e-12}, + } + }, + { + /* name = */ "FeM_dust", + /* nonprimoridal_yield_frac = */ 2.39849e-02, + /* size_moments = */ {4.62542e-06, 3.82292e-11, 4.68445e-16}, + /* opacity_coef_table = */ { + {1.05240e-01, 1.91709e-07, 6.14415e-13, 3.80291e-18}, + {1.32588e-01, 2.41526e-07, 7.74078e-13, 4.79114e-18}, + {1.67016e-01, 3.04243e-07, 9.75080e-13, 6.03524e-18}, + {2.10360e-01, 3.83198e-07, 1.22813e-12, 7.60148e-18}, + {2.71887e-01, 4.95279e-07, 1.58734e-12, 9.82485e-18}, + {3.55694e-01, 6.47944e-07, 2.07663e-12, 1.28533e-17}, + {4.84932e-01, 8.83369e-07, 2.83116e-12, 1.75235e-17}, + {6.99767e-01, 1.27472e-06, 4.08543e-12, 2.52870e-17}, + {1.05860e+00, 1.92838e-06, 6.18042e-12, 3.82543e-17}, + {1.62902e+00, 2.96748e-06, 9.51075e-12, 5.88683e-17}, + {2.54260e+00, 4.63171e-06, 1.48447e-11, 9.18851e-17}, + {3.96490e+00, 7.22268e-06, 2.31492e-11, 1.43293e-16}, + {6.10635e+00, 1.11237e-05, 3.56530e-11, 2.20699e-16}, + {9.28776e+00, 1.69193e-05, 5.42303e-11, 3.35716e-16}, + {1.39267e+01, 2.53704e-05, 8.13220e-11, 5.03475e-16}, + {2.05388e+01, 3.74163e-05, 1.19943e-10, 7.42685e-16}, + {3.00662e+01, 5.47749e-05, 1.75612e-10, 1.08767e-15}, + {4.55134e+01, 8.29222e-05, 2.65919e-10, 1.64778e-15}, + {7.47928e+01, 1.36281e-04, 4.37190e-10, 2.71088e-15}, + {1.29641e+02, 2.36241e-04, 7.58090e-10, 4.70339e-15}, + {2.14861e+02, 3.91558e-04, 1.25676e-09, 7.80036e-15}, + {3.20074e+02, 5.83333e-04, 1.87266e-09, 1.16272e-14}, + {4.29885e+02, 7.83522e-04, 2.51590e-09, 1.56273e-14}, + {5.31008e+02, 9.67906e-04, 3.10866e-09, 1.93168e-14}, + {5.99926e+02, 1.09359e-03, 3.51289e-09, 2.18342e-14}, + {6.06790e+02, 1.10614e-03, 3.55349e-09, 2.20891e-14}, + {5.43501e+02, 9.90793e-04, 3.18304e-09, 1.97873e-14}, + {4.33743e+02, 7.90717e-04, 2.54035e-09, 1.57927e-14}, + {3.13466e+02, 5.71463e-04, 1.83604e-09, 1.14151e-14}, + {2.09115e+02, 3.81238e-04, 1.22500e-09, 7.61738e-15}, + {1.31224e+02, 2.39260e-04, 7.69004e-10, 4.78403e-15}, + {7.91470e+01, 1.44373e-04, 4.64502e-10, 2.89404e-15}, + {4.74663e+01, 8.67304e-05, 2.80053e-10, 1.75354e-15}, + {2.98668e+01, 5.48299e-05, 1.78713e-10, 1.13252e-15}, + {2.08636e+01, 3.86952e-05, 1.28439e-10, 8.30592e-16}, + } + }, + { + /* name = */ "Mg2SiO4_dust", + /* nonprimoridal_yield_frac = */ 8.69522e-04, + /* size_moments = */ {1.82163e-06, 5.83823e-12, 3.61356e-17}, + /* opacity_coef_table = */ { + {2.19890e-02, 1.59707e-08, 1.64886e-14, 3.46350e-20}, + {3.90612e-02, 2.83703e-08, 2.92903e-14, 6.15261e-20}, + {6.05539e-02, 4.39805e-08, 4.54068e-14, 9.53799e-20}, + {8.76116e-02, 6.36326e-08, 6.56961e-14, 1.37999e-19}, + {1.43288e-01, 1.04070e-07, 1.07445e-13, 2.25699e-19}, + {2.19266e-01, 1.59254e-07, 1.64418e-13, 3.45380e-19}, + {3.36256e-01, 2.44223e-07, 2.52144e-13, 5.29662e-19}, + {5.14336e-01, 3.73564e-07, 3.85679e-13, 8.10191e-19}, + {7.97216e-01, 5.79021e-07, 5.97800e-13, 1.25585e-18}, + {1.25414e+00, 9.10886e-07, 9.40430e-13, 1.97579e-18}, + {2.03450e+00, 1.47766e-06, 1.52560e-12, 3.20555e-18}, + {3.34648e+00, 2.43056e-06, 2.50942e-12, 5.27367e-18}, + {5.45894e+00, 3.96485e-06, 4.09354e-12, 8.60504e-18}, + {8.82118e+00, 6.40687e-06, 6.61493e-12, 1.39111e-17}, + {1.41825e+01, 1.03009e-05, 1.06356e-11, 2.23816e-17}, + {2.28420e+01, 1.65903e-05, 1.71302e-11, 3.60870e-17}, + {3.71180e+01, 2.69593e-05, 2.78383e-11, 5.87421e-17}, + {6.14285e+01, 4.46166e-05, 4.60756e-11, 9.74574e-17}, + {1.03848e+02, 7.54274e-05, 7.79023e-11, 1.65248e-16}, + {1.75510e+02, 1.27478e-04, 1.31675e-10, 2.80026e-16}, + {2.82066e+02, 2.04875e-04, 2.11635e-10, 4.50867e-16}, + {4.14529e+02, 3.01090e-04, 3.11041e-10, 6.63478e-16}, + {5.59986e+02, 4.06746e-04, 4.20208e-10, 8.97036e-16}, + {7.11059e+02, 5.16484e-04, 5.33582e-10, 1.13854e-15}, + {8.40851e+02, 6.10764e-04, 6.30953e-10, 1.34372e-15}, + {8.95368e+02, 6.50365e-04, 6.71811e-10, 1.42700e-15}, + {8.40461e+02, 6.10482e-04, 6.30563e-10, 1.33611e-15}, + {6.96732e+02, 5.06082e-04, 5.22696e-10, 1.10542e-15}, + {5.18234e+02, 3.76427e-04, 3.88766e-10, 8.21088e-16}, + {3.52885e+02, 2.56323e-04, 2.64719e-10, 5.58648e-16}, + {2.24228e+02, 1.62872e-04, 1.68207e-10, 3.54873e-16}, + {1.35145e+02, 9.81654e-05, 1.01382e-10, 2.13970e-16}, + {7.83182e+01, 5.68892e-05, 5.87587e-11, 1.24192e-16}, + {4.41610e+01, 3.20799e-05, 3.31421e-11, 7.03026e-17}, + {2.46026e+01, 1.78814e-05, 1.84973e-11, 3.95672e-17}, + } + }, + { + /* name = */ "MgSiO3_dust", + /* nonprimoridal_yield_frac = */ 2.87802e-06, + /* size_moments = */ {7.26303e-07, 7.49856e-13, 1.57511e-18}, + /* opacity_coef_table = */ { + {3.27960e-01, 1.58173e-06, 1.28346e-11, 1.68940e-16}, + {4.38754e-01, 2.11613e-06, 1.71717e-11, 2.26045e-16}, + {5.78236e-01, 2.78890e-06, 2.26319e-11, 2.97935e-16}, + {7.53833e-01, 3.63586e-06, 2.95057e-11, 3.88440e-16}, + {1.04018e+00, 5.01714e-06, 4.07179e-11, 5.36095e-16}, + {1.41744e+00, 6.83702e-06, 5.54910e-11, 7.30661e-16}, + {1.95305e+00, 9.42082e-06, 7.64677e-11, 1.00698e-15}, + {2.71551e+00, 1.30993e-05, 1.06337e-10, 1.40054e-15}, + {3.79716e+00, 1.83183e-05, 1.48729e-10, 1.95931e-15}, + {5.29823e+00, 2.55621e-05, 2.07584e-10, 2.73540e-15}, + {7.37977e+00, 3.56090e-05, 2.89250e-10, 3.81296e-15}, + {1.02196e+01, 4.93202e-05, 4.00773e-10, 5.28580e-15}, + {1.40471e+01, 6.78071e-05, 5.51275e-10, 7.27585e-15}, + {1.92118e+01, 9.27674e-05, 7.54736e-10, 9.97084e-15}, + {2.61798e+01, 1.26469e-04, 1.02994e-09, 1.36251e-14}, + {3.55647e+01, 1.71912e-04, 1.40197e-09, 1.85822e-14}, + {4.82256e+01, 2.33320e-04, 1.90655e-09, 2.53388e-14}, + {6.54391e+01, 3.17003e-04, 2.59771e-09, 3.46585e-14}, + {8.90003e+01, 4.31918e-04, 3.55359e-09, 4.76706e-14}, + {1.21150e+02, 5.89447e-04, 4.87725e-09, 6.59296e-14}, + {1.64482e+02, 8.03274e-04, 6.70152e-09, 9.15912e-14}, + {2.22238e+02, 1.09138e-03, 9.21653e-09, 1.27994e-13}, + {2.99304e+02, 1.48143e-03, 1.27247e-08, 1.80612e-13}, + {4.02975e+02, 2.01378e-03, 1.76517e-08, 2.56967e-13}, + {5.41945e+02, 2.73383e-03, 2.44284e-08, 3.63965e-13}, + {7.24087e+02, 3.67841e-03, 3.33149e-08, 5.04207e-13}, + {9.57733e+02, 4.88178e-03, 4.44353e-08, 6.76055e-13}, + {1.25789e+03, 6.40887e-03, 5.80974e-08, 8.78814e-13}, + {1.65268e+03, 8.39077e-03, 7.51368e-08, 1.11835e-12}, + {2.18798e+03, 1.10499e-02, 9.71231e-08, 1.40975e-12}, + {2.93400e+03, 1.47364e-02, 1.26617e-07, 1.77953e-12}, + {3.99924e+03, 2.00041e-02, 1.67709e-07, 2.27029e-12}, + {5.55224e+03, 2.77223e-02, 2.26777e-07, 2.94699e-12}, + {7.83754e+03, 3.91330e-02, 3.12657e-07, 3.89444e-12}, + {1.11477e+04, 5.56050e-02, 4.34205e-07, 5.18557e-12}, + } + }, + { + /* name = */ "AC_dust", + /* nonprimoridal_yield_frac = */ 4.85826e-02, + /* size_moments = */ {4.82296e-06, 3.91353e-11, 5.15140e-16}, + /* opacity_coef_table = */ { + {7.60358e-02, 1.01529e-07, 4.49989e-13, 4.04236e-18}, + {9.07205e-02, 1.21137e-07, 5.36902e-13, 4.82320e-18}, + {1.09207e-01, 1.45823e-07, 6.46320e-13, 5.80621e-18}, + {1.32481e-01, 1.76900e-07, 7.84068e-13, 7.04376e-18}, + {1.58907e-01, 2.12188e-07, 9.40480e-13, 8.44905e-18}, + {1.91565e-01, 2.55795e-07, 1.13377e-12, 1.01857e-17}, + {2.30490e-01, 3.07773e-07, 1.36416e-12, 1.22557e-17}, + {2.76795e-01, 3.69605e-07, 1.63824e-12, 1.47181e-17}, + {3.33074e-01, 4.44757e-07, 1.97136e-12, 1.77112e-17}, + {4.05326e-01, 5.41239e-07, 2.39905e-12, 2.15541e-17}, + {5.08162e-01, 6.78559e-07, 3.00776e-12, 2.70236e-17}, + {6.72474e-01, 8.97974e-07, 3.98043e-12, 3.57640e-17}, + {9.48554e-01, 1.26665e-06, 5.61486e-12, 5.04526e-17}, + {1.41789e+00, 1.89344e-06, 8.39396e-12, 7.54321e-17}, + {2.19504e+00, 2.93130e-06, 1.29962e-11, 1.16808e-16}, + {3.46727e+00, 4.63056e-06, 2.05341e-11, 1.84616e-16}, + {5.76879e+00, 7.70562e-06, 3.41883e-11, 3.07633e-16}, + {1.17206e+01, 1.56620e-05, 6.95719e-11, 6.27184e-16}, + {3.16503e+01, 4.23092e-05, 1.88132e-10, 1.69866e-15}, + {8.68466e+01, 1.16104e-04, 5.16371e-10, 4.66366e-15}, + {1.92342e+02, 2.57132e-04, 1.14345e-09, 1.03252e-14}, + {3.36302e+02, 4.49562e-04, 1.99868e-09, 1.80397e-14}, + {5.05933e+02, 6.76162e-04, 3.00294e-09, 2.70549e-14}, + {7.20757e+02, 9.62603e-04, 4.26374e-09, 3.82441e-14}, + {9.77487e+02, 1.30417e-03, 5.75586e-09, 5.13190e-14}, + {1.18647e+03, 1.58150e-03, 6.95698e-09, 6.16931e-14}, + {1.23844e+03, 1.64960e-03, 7.23901e-09, 6.39380e-14}, + {1.11176e+03, 1.48010e-03, 6.48454e-09, 5.71201e-14}, + {8.76276e+02, 1.16622e-03, 5.10394e-09, 4.48799e-14}, + {6.22103e+02, 8.27770e-04, 3.62020e-09, 3.17970e-14}, + {4.07211e+02, 5.41759e-04, 2.36830e-09, 2.07862e-14}, + {2.50522e+02, 3.33268e-04, 1.45648e-09, 1.27774e-14}, + {1.47042e+02, 1.95598e-04, 8.54671e-10, 7.49580e-15}, + {8.32958e+01, 1.10803e-04, 4.84133e-10, 4.24560e-15}, + {4.59515e+01, 6.11325e-05, 2.67142e-10, 2.34298e-15}, + } + }, + { + /* name = */ "SiO2_dust", + /* nonprimoridal_yield_frac = */ 2.52534e-03, + /* size_moments = */ {1.33530e-06, 5.91862e-12, 5.31739e-17}, + /* opacity_coef_table = */ { + {2.25390e-04, 3.58434e-10, 1.62608e-15, 1.09114e-20}, + {4.04968e-04, 6.44015e-10, 2.92166e-15, 1.96051e-20}, + {6.31043e-04, 1.00354e-09, 4.55270e-15, 3.05498e-20}, + {9.15654e-04, 1.45615e-09, 6.60605e-15, 4.43284e-20}, + {1.52197e-03, 2.42038e-09, 1.09804e-14, 7.36816e-20}, + {2.37407e-03, 3.77546e-09, 1.71280e-14, 1.14934e-19}, + {3.77208e-03, 5.99871e-09, 2.72141e-14, 1.82615e-19}, + {6.14347e-03, 9.76990e-09, 4.43228e-14, 2.97421e-19}, + {1.01907e-02, 1.62062e-08, 7.35223e-14, 4.93362e-19}, + {1.68896e-02, 2.68594e-08, 1.21853e-13, 8.17686e-19}, + {2.96122e-02, 4.70930e-08, 2.13650e-13, 1.43371e-18}, + {6.10599e-02, 9.71067e-08, 4.40563e-13, 2.95653e-18}, + {1.43395e-01, 2.28052e-07, 1.03468e-12, 6.94381e-18}, + {3.27370e-01, 5.20656e-07, 2.36231e-12, 1.58544e-17}, + {6.39417e-01, 1.01697e-06, 4.61437e-12, 3.09706e-17}, + {1.05137e+00, 1.67234e-06, 7.58927e-12, 5.09499e-17}, + {1.55802e+00, 2.48015e-06, 1.12675e-11, 7.57604e-17}, + {2.94085e+00, 4.69147e-06, 2.13703e-11, 1.44197e-16}, + {1.32769e+01, 2.11739e-05, 9.63657e-11, 6.49212e-16}, + {7.10101e+01, 1.13066e-04, 5.13371e-10, 3.44675e-15}, + {2.54818e+02, 4.05363e-04, 1.83807e-09, 1.23170e-14}, + {6.00377e+02, 9.54596e-04, 4.32539e-09, 2.89547e-14}, + {9.94365e+02, 1.58056e-03, 7.15868e-09, 4.78926e-14}, + {1.24259e+03, 1.97471e-03, 8.94139e-09, 5.97968e-14}, + {1.24573e+03, 1.97945e-03, 8.96134e-09, 5.99160e-14}, + {1.05442e+03, 1.67534e-03, 7.58381e-09, 5.06979e-14}, + {7.85160e+02, 1.24742e-03, 5.64619e-09, 3.77407e-14}, + {5.31062e+02, 8.43677e-04, 3.81852e-09, 2.55222e-14}, + {3.34296e+02, 5.31069e-04, 2.40355e-09, 1.60640e-14}, + {1.99427e+02, 3.16805e-04, 1.43378e-09, 9.58224e-15}, + {1.14271e+02, 1.81526e-04, 8.21530e-10, 5.49033e-15}, + {6.35097e+01, 1.00887e-04, 4.56573e-10, 3.05124e-15}, + {3.44902e+01, 5.47882e-05, 2.47947e-10, 1.65699e-15}, + {1.84022e+01, 2.92323e-05, 1.32292e-10, 8.84081e-16}, + {9.68612e+00, 1.53865e-05, 6.96321e-11, 4.65335e-16}, + } + }, + { + /* name = */ "MgO_dust", + /* nonprimoridal_yield_frac = */ 1.28672e-05, + /* size_moments = */ {1.59029e-06, 7.21459e-12, 4.84120e-17}, + /* opacity_coef_table = */ { + {5.18081e-02, 3.19144e-08, 2.36505e-14, 2.15886e-20}, + {9.98885e-02, 6.15325e-08, 4.55993e-14, 4.16239e-20}, + {1.60418e-01, 9.88194e-08, 7.32312e-14, 6.68467e-20}, + {2.36621e-01, 1.45761e-07, 1.08018e-13, 9.86004e-20}, + {3.67284e-01, 2.26251e-07, 1.67666e-13, 1.53048e-19}, + {5.36223e-01, 3.30320e-07, 2.44787e-13, 2.23446e-19}, + {7.64198e-01, 4.70755e-07, 3.48859e-13, 3.18445e-19}, + {1.04970e+00, 6.46627e-07, 4.79190e-13, 4.37414e-19}, + {1.38080e+00, 8.50591e-07, 6.30340e-13, 5.75387e-19}, + {1.74373e+00, 1.07416e-06, 7.96018e-13, 7.26623e-19}, + {2.10311e+00, 1.29554e-06, 9.60079e-13, 8.76383e-19}, + {2.42144e+00, 1.49164e-06, 1.10541e-12, 1.00905e-18}, + {2.66810e+00, 1.64360e-06, 1.21802e-12, 1.11185e-18}, + {2.81617e+00, 1.73481e-06, 1.28563e-12, 1.17358e-18}, + {2.89834e+00, 1.78545e-06, 1.32317e-12, 1.20789e-18}, + {3.07987e+00, 1.89732e-06, 1.40614e-12, 1.28370e-18}, + {3.69380e+00, 2.27562e-06, 1.68664e-12, 1.53995e-18}, + {5.05331e+00, 3.11331e-06, 2.30770e-12, 2.10726e-18}, + {7.07089e+00, 4.35648e-06, 3.22940e-12, 2.94918e-18}, + {9.18826e+00, 5.66121e-06, 4.19684e-12, 3.83303e-18}, + {1.08014e+01, 6.65544e-06, 4.93433e-12, 4.50719e-18}, + {1.16611e+01, 7.18584e-06, 5.32843e-12, 4.86833e-18}, + {1.18910e+01, 7.32863e-06, 5.43584e-12, 4.96854e-18}, + {1.17598e+01, 7.24978e-06, 5.38006e-12, 4.92122e-18}, + {1.15004e+01, 7.09317e-06, 5.26837e-12, 4.82521e-18}, + {1.12405e+01, 6.93914e-06, 5.16238e-12, 4.73954e-18}, + {1.10769e+01, 6.85905e-06, 5.13138e-12, 4.75017e-18}, + {1.15509e+01, 7.24181e-06, 5.54113e-12, 5.30090e-18}, + {1.54818e+01, 9.90289e-06, 7.85008e-12, 7.89232e-18}, + {3.23248e+01, 2.09189e-05, 1.69099e-11, 1.74499e-17}, + {8.13876e+01, 5.27406e-05, 4.27128e-11, 4.41701e-17}, + {1.86528e+02, 1.20594e-04, 9.72543e-11, 9.99819e-17}, + {3.66028e+02, 2.35977e-04, 1.89337e-10, 1.93263e-16}, + {6.29868e+02, 4.05043e-04, 3.23450e-10, 3.27929e-16}, + {9.83739e+02, 6.31245e-04, 5.01948e-10, 5.05703e-16}, + } + }, + { + /* name = */ "FeS_dust", + /* nonprimoridal_yield_frac = */ 2.09730e-06, + /* size_moments = */ {6.16010e-07, 4.56500e-13, 4.16699e-19}, + /* opacity_coef_table = */ { + {1.54619e-01, 2.60128e-07, 1.49475e-12, 2.65148e-17}, + {1.94656e-01, 3.27554e-07, 1.88361e-12, 3.34351e-17}, + {2.45059e-01, 4.12439e-07, 2.37316e-12, 4.21472e-17}, + {3.08513e-01, 5.19301e-07, 2.98947e-12, 5.31150e-17}, + {3.88404e-01, 6.53894e-07, 3.76675e-12, 6.69643e-17}, + {4.88982e-01, 8.23350e-07, 4.74559e-12, 8.44087e-17}, + {6.15605e-01, 1.03673e-06, 5.97899e-12, 1.06403e-16}, + {7.75006e-01, 1.30539e-06, 7.53301e-12, 1.34131e-16}, + {9.75366e-01, 1.64315e-06, 9.48791e-12, 1.69031e-16}, + {1.22493e+00, 2.06392e-06, 1.19246e-11, 2.12553e-16}, + {1.52116e+00, 2.56344e-06, 1.48192e-11, 2.64285e-16}, + {1.83681e+00, 3.09586e-06, 1.79072e-11, 3.19511e-16}, + {2.15662e+00, 3.63549e-06, 2.10413e-11, 3.75635e-16}, + {2.55502e+00, 4.30820e-06, 2.49580e-11, 4.45921e-16}, + {3.22790e+00, 5.44497e-06, 3.15890e-11, 5.65115e-16}, + {4.33126e+00, 7.30995e-06, 4.24882e-11, 7.61352e-16}, + {5.81498e+00, 9.82030e-06, 5.72103e-11, 1.02723e-15}, + {7.48294e+00, 1.26484e-05, 7.39233e-11, 1.33106e-15}, + {9.21324e+00, 1.55973e-05, 9.16644e-11, 1.65851e-15}, + {1.11943e+01, 1.90119e-05, 1.13021e-10, 2.06536e-15}, + {1.39990e+01, 2.39150e-05, 1.45136e-10, 2.69938e-15}, + {1.78867e+01, 3.08010e-05, 1.92146e-10, 3.65687e-15}, + {2.17798e+01, 3.79266e-05, 2.45744e-10, 4.82338e-15}, + {2.38104e+01, 4.23268e-05, 2.93339e-10, 6.06677e-15}, + {2.31200e+01, 4.26489e-05, 3.30423e-10, 7.40538e-15}, + {2.05061e+01, 3.98990e-05, 3.56330e-10, 8.76054e-15}, + {1.74011e+01, 3.59849e-05, 3.69684e-10, 9.86673e-15}, + {1.47227e+01, 3.22080e-05, 3.69774e-10, 1.04731e-14}, + {1.27456e+01, 2.91368e-05, 3.59951e-10, 1.05598e-14}, + {1.18944e+01, 2.82426e-05, 3.62521e-10, 1.07315e-14}, + {1.43878e+01, 3.74123e-05, 4.87177e-10, 1.37994e-14}, + {2.85377e+01, 9.23385e-05, 1.20077e-09, 3.00478e-14}, + {7.93256e+01, 3.11569e-04, 3.91124e-09, 8.56317e-14}, + {2.33021e+02, 9.78251e-04, 1.15601e-08, 2.28453e-13}, + {6.42052e+02, 2.55294e-03, 2.77058e-08, 5.06000e-13}, + } + }, +}; + +} // namespace ccsn13 + +namespace ccsn20 { +static const MetalNuclideYieldProps metal_props[] = { + // {name, gas_yield, total_yield} + {"C", 8.74563e-02, 1.00183e-01}, + {"O", 6.04383e-01, 6.06515e-01}, + {"Mg", 2.63753e-02, 2.75968e-02}, + {"Al", 1.87118e-04, 1.87118e-04}, + {"Si", 6.44592e-02, 1.00051e-01}, + {"S", 6.02018e-02, 6.02208e-02}, + {"Fe", 2.69505e-02, 3.07560e-02}, +}; + +static const GrainSpeciesYieldProps grain_props[] = { + { + /* name = */ "SiM_dust", + /* nonprimoridal_yield_frac = */ 3.44388e-02, + /* size_moments = */ {1.24861e-05, 2.86508e-10, 1.01028e-14}, + /* opacity_coef_table = */ { + {1.10506e-02, 1.69983e-07, 3.50089e-12, 9.16404e-17}, + {1.85837e-02, 2.76971e-07, 5.53036e-12, 1.40642e-16}, + {2.79449e-02, 4.08949e-07, 8.01809e-12, 2.00458e-16}, + {3.96605e-02, 5.73574e-07, 1.11125e-11, 2.74730e-16}, + {6.19392e-02, 8.69904e-07, 1.63567e-11, 3.93140e-16}, + {9.16817e-02, 1.25867e-06, 2.31128e-11, 5.43193e-16}, + {1.36080e-01, 1.82251e-06, 3.26005e-11, 7.47226e-16}, + {2.02056e-01, 2.63811e-06, 4.59129e-11, 1.02492e-15}, + {2.99593e-01, 3.81390e-06, 6.45602e-11, 1.40281e-15}, + {4.39758e-01, 5.46636e-06, 9.01024e-11, 1.90718e-15}, + {6.41903e-01, 7.79581e-06, 1.25163e-10, 2.58082e-15}, + {9.24985e-01, 1.09870e-05, 1.71974e-10, 3.45658e-15}, + {1.30585e+00, 1.51941e-05, 2.32250e-10, 4.55695e-15}, + {1.80164e+00, 2.05666e-05, 3.07564e-10, 5.90101e-15}, + {2.42648e+00, 2.72192e-05, 3.99035e-10, 7.50126e-15}, + {3.19207e+00, 3.52384e-05, 5.07449e-10, 9.36601e-15}, + {4.10565e+00, 4.46618e-05, 6.32978e-10, 1.14947e-14}, + {5.17172e+00, 5.54917e-05, 7.75385e-10, 1.38820e-14}, + {6.40478e+00, 6.78244e-05, 9.35760e-10, 1.65481e-14}, + {7.85614e+00, 8.21045e-05, 1.11980e-09, 1.95943e-14}, + {9.64785e+00, 9.94326e-05, 1.34166e-09, 2.32660e-14}, + {1.20159e+01, 1.21941e-04, 1.62875e-09, 2.80374e-14}, + {1.53778e+01, 1.53371e-04, 2.02922e-09, 3.47445e-14}, + {2.04423e+01, 1.99938e-04, 2.62238e-09, 4.47607e-14}, + {2.83887e+01, 2.71546e-04, 3.53030e-09, 6.01372e-14}, + {4.11773e+01, 3.83718e-04, 4.93303e-09, 8.37180e-14}, + {6.21107e+01, 5.61284e-04, 7.10254e-09, 1.19520e-13}, + {9.68132e+01, 8.45164e-04, 1.04719e-08, 1.73689e-13}, + {1.54804e+02, 1.30324e-03, 1.57446e-08, 2.55980e-13}, + {2.51780e+02, 2.04562e-03, 2.40381e-08, 3.81486e-13}, + {4.12838e+02, 3.24595e-03, 3.70714e-08, 5.72650e-13}, + {6.76592e+02, 5.16747e-03, 5.73792e-08, 8.61246e-13}, + {1.09863e+03, 8.17937e-03, 8.83910e-08, 1.28821e-12}, + {1.74646e+03, 1.26954e-02, 1.33666e-07, 1.89228e-12}, + {2.67882e+03, 1.89754e-02, 1.94753e-07, 2.68226e-12}, + } + }, + { + /* name = */ "FeM_dust", + /* nonprimoridal_yield_frac = */ 3.77223e-03, + /* size_moments = */ {6.67024e-06, 7.50596e-11, 1.22752e-15}, + /* opacity_coef_table = */ { + {1.05240e-01, 1.48654e-07, 5.02591e-13, 3.24156e-18}, + {1.32588e-01, 1.87284e-07, 6.33194e-13, 4.08391e-18}, + {1.67016e-01, 2.35915e-07, 7.97614e-13, 5.14437e-18}, + {2.10360e-01, 2.97139e-07, 1.00461e-12, 6.47941e-18}, + {2.71887e-01, 3.84048e-07, 1.29844e-12, 8.37459e-18}, + {3.55694e-01, 5.02428e-07, 1.69868e-12, 1.09560e-17}, + {4.84932e-01, 6.84981e-07, 2.31589e-12, 1.49369e-17}, + {6.99767e-01, 9.88442e-07, 3.34188e-12, 2.15544e-17}, + {1.05860e+00, 1.49530e-06, 5.05559e-12, 3.26077e-17}, + {1.62902e+00, 2.30104e-06, 7.77981e-12, 5.01791e-17}, + {2.54260e+00, 3.59152e-06, 1.21430e-11, 7.83229e-17}, + {3.96490e+00, 5.60062e-06, 1.89363e-11, 1.22144e-16}, + {6.10634e+00, 8.62558e-06, 2.91646e-11, 1.88128e-16}, + {9.28774e+00, 1.31196e-05, 4.43615e-11, 2.86175e-16}, + {1.39267e+01, 1.96729e-05, 6.65240e-11, 4.29191e-16}, + {2.05387e+01, 2.90138e-05, 9.81191e-11, 6.33137e-16}, + {3.00660e+01, 4.24748e-05, 1.43665e-10, 9.27312e-16}, + {4.55128e+01, 6.43028e-05, 2.17560e-10, 1.40505e-15}, + {7.47912e+01, 1.05684e-04, 3.57721e-10, 2.31202e-15}, + {1.29637e+02, 1.83206e-04, 6.20346e-10, 4.01209e-15}, + {2.14853e+02, 3.03661e-04, 1.02847e-09, 6.65466e-15}, + {3.20060e+02, 4.52395e-04, 1.53258e-09, 9.92043e-15}, + {4.29862e+02, 6.07661e-04, 2.05913e-09, 1.33350e-14}, + {5.30972e+02, 7.50675e-04, 2.54443e-09, 1.64851e-14}, + {5.99878e+02, 8.48166e-04, 2.87540e-09, 1.86348e-14}, + {6.06737e+02, 8.57905e-04, 2.90867e-09, 1.88528e-14}, + {5.43451e+02, 7.68444e-04, 2.60547e-09, 1.68884e-14}, + {4.33701e+02, 6.13270e-04, 2.07941e-09, 1.34791e-14}, + {3.13436e+02, 4.43222e-04, 1.50292e-09, 9.74306e-15}, + {2.09092e+02, 2.95687e-04, 1.00276e-09, 6.50192e-15}, + {1.31208e+02, 1.85574e-04, 6.29536e-10, 4.08396e-15}, + {7.91293e+01, 1.11988e-04, 3.80343e-10, 2.47142e-15}, + {4.74361e+01, 6.72978e-05, 2.29477e-10, 1.49906e-15}, + {2.98121e+01, 4.25812e-05, 1.46690e-10, 9.70392e-16}, + {2.07674e+01, 3.01013e-05, 1.05718e-10, 7.13724e-16}, + } + }, + { + /* name = */ "Mg2SiO4_dust", + /* nonprimoridal_yield_frac = */ 1.90086e-03, + /* size_moments = */ {1.41253e-06, 4.77566e-12, 3.08016e-17}, + /* opacity_coef_table = */ { + {2.19890e-02, 2.22393e-08, 2.89570e-14, 6.37012e-20}, + {3.90612e-02, 3.95059e-08, 5.14391e-14, 1.13159e-19}, + {6.05539e-02, 6.12433e-08, 7.97425e-14, 1.75423e-19}, + {8.76116e-02, 8.86090e-08, 1.15374e-13, 2.53808e-19}, + {1.43288e-01, 1.44919e-07, 1.88693e-13, 4.15103e-19}, + {2.19266e-01, 2.21762e-07, 2.88749e-13, 6.35214e-19}, + {3.36256e-01, 3.40084e-07, 4.42810e-13, 9.74136e-19}, + {5.14336e-01, 5.20191e-07, 6.77322e-13, 1.49005e-18}, + {7.97217e-01, 8.06292e-07, 1.04985e-12, 2.30962e-18}, + {1.25414e+00, 1.26842e-06, 1.65157e-12, 3.63350e-18}, + {2.03450e+00, 2.05766e-06, 2.67923e-12, 5.89467e-18}, + {3.34648e+00, 3.38458e-06, 4.40703e-12, 9.69677e-18}, + {5.45894e+00, 5.52111e-06, 7.18906e-12, 1.58199e-17}, + {8.82120e+00, 8.92167e-06, 1.16172e-11, 2.55686e-17}, + {1.41826e+01, 1.43441e-05, 1.86785e-11, 4.11217e-17}, + {2.28421e+01, 2.31025e-05, 3.00847e-11, 6.62628e-17}, + {3.71183e+01, 3.75417e-05, 4.88915e-11, 1.07761e-16}, + {6.14292e+01, 6.21307e-05, 8.09232e-11, 1.78540e-16}, + {1.03850e+02, 1.05037e-04, 1.36825e-10, 3.02237e-16}, + {1.75513e+02, 1.77524e-04, 2.31276e-10, 5.11420e-16}, + {2.82073e+02, 2.85307e-04, 3.71726e-10, 8.22603e-16}, + {4.14541e+02, 4.19298e-04, 5.46336e-10, 1.20964e-15}, + {5.60007e+02, 5.66440e-04, 7.38095e-10, 1.63478e-15}, + {7.11090e+02, 7.19267e-04, 9.37240e-10, 2.07555e-15}, + {8.40892e+02, 8.50566e-04, 1.10826e-09, 2.45241e-15}, + {8.95414e+02, 9.05715e-04, 1.18001e-09, 2.60842e-15}, + {8.40504e+02, 8.50170e-04, 1.10753e-09, 2.44576e-15}, + {6.96768e+02, 7.04778e-04, 9.18057e-10, 2.02574e-15}, + {5.18260e+02, 5.24216e-04, 6.82816e-10, 1.50584e-15}, + {3.52903e+02, 3.56958e-04, 4.64940e-10, 1.02501e-15}, + {2.24241e+02, 2.26818e-04, 2.95430e-10, 6.51237e-16}, + {1.35153e+02, 1.36707e-04, 1.78065e-10, 3.92585e-16}, + {7.83236e+01, 7.92263e-05, 1.03204e-10, 2.27687e-16}, + {4.41657e+01, 4.46783e-05, 5.82153e-11, 1.28647e-16}, + {2.46133e+01, 2.49140e-05, 3.25047e-11, 7.21799e-17}, + } + }, + { + /* name = */ "MgSiO3_dust", + /* nonprimoridal_yield_frac = */ 2.57266e-06, + /* size_moments = */ {1.01138e-06, 1.31688e-12, 2.89696e-18}, + /* opacity_coef_table = */ { + {3.27960e-01, 2.60760e-07, 8.23594e-13, 1.38274e-17}, + {4.38752e-01, 3.48855e-07, 1.10197e-12, 1.85031e-17}, + {5.78230e-01, 4.59761e-07, 1.45242e-12, 2.43895e-17}, + {7.53824e-01, 5.99382e-07, 1.89361e-12, 3.18000e-17}, + {1.04013e+00, 8.27053e-07, 2.61333e-12, 4.38935e-17}, + {1.41735e+00, 1.12702e-06, 3.56171e-12, 5.98308e-17}, + {1.95293e+00, 1.55292e-06, 4.90855e-12, 8.24705e-17}, + {2.71532e+00, 2.15922e-06, 6.82677e-12, 1.14729e-16}, + {3.79677e+00, 3.01935e-06, 9.54991e-12, 1.60553e-16}, + {5.29747e+00, 4.21303e-06, 1.33318e-11, 2.24238e-16}, + {7.37841e+00, 5.86846e-06, 1.85820e-11, 3.12737e-16}, + {1.02169e+01, 8.12703e-06, 2.57565e-11, 4.33854e-16}, + {1.40423e+01, 1.11717e-05, 3.54480e-11, 5.97791e-16}, + {1.92026e+01, 1.52804e-05, 4.85668e-11, 8.20344e-16}, + {2.61626e+01, 2.08251e-05, 6.63455e-11, 1.12316e-15}, + {3.55324e+01, 2.82955e-05, 9.04435e-11, 1.53595e-15}, + {4.81644e+01, 3.83784e-05, 1.23253e-10, 2.10252e-15}, + {6.53233e+01, 5.20969e-05, 1.68441e-10, 2.89162e-15}, + {8.87789e+01, 7.08925e-05, 2.31406e-10, 4.00785e-15}, + {1.20729e+02, 9.65780e-05, 3.19528e-10, 5.60280e-15}, + {1.63666e+02, 1.31274e-04, 4.42922e-10, 7.90380e-15}, + {2.20664e+02, 1.77696e-04, 6.17150e-10, 1.12922e-14}, + {2.96276e+02, 2.39957e-04, 8.67756e-10, 1.64168e-14}, + {3.97347e+02, 3.24130e-04, 1.23022e-09, 2.41672e-14}, + {5.32072e+02, 4.37186e-04, 1.73755e-09, 3.52998e-14}, + {7.07827e+02, 5.84876e-04, 2.40229e-09, 4.99094e-14}, + {9.32126e+02, 7.72477e-04, 3.21611e-09, 6.73490e-14}, + {1.21808e+03, 1.00957e-03, 4.17439e-09, 8.68091e-14}, + {1.58941e+03, 1.31461e-03, 5.30260e-09, 1.07984e-13}, + {2.08259e+03, 1.71725e-03, 6.66833e-09, 1.31338e-13}, + {2.74876e+03, 2.26047e-03, 8.38813e-09, 1.58137e-13}, + {3.65886e+03, 3.00609e-03, 1.06436e-08, 1.90525e-13}, + {4.91536e+03, 4.04510e-03, 1.37047e-08, 2.31589e-13}, + {6.67260e+03, 5.51150e-03, 1.79301e-08, 2.84849e-13}, + {9.16963e+03, 7.59478e-03, 2.36873e-08, 3.52355e-13}, + } + }, + { + /* name = */ "AC_dust", + /* nonprimoridal_yield_frac = */ 1.27270e-02, + /* size_moments = */ {7.95099e-07, 2.51133e-12, 4.21640e-17}, + /* opacity_coef_table = */ { + {7.60358e-02, 1.06666e-07, 3.03247e-13, 1.47482e-18}, + {9.07206e-02, 1.27267e-07, 3.61815e-13, 1.75967e-18}, + {1.09208e-01, 1.53201e-07, 4.35546e-13, 2.11827e-18}, + {1.32481e-01, 1.85851e-07, 5.28369e-13, 2.56972e-18}, + {1.58907e-01, 2.22922e-07, 6.33765e-13, 3.08233e-18}, + {1.91565e-01, 2.68735e-07, 7.64012e-13, 3.71581e-18}, + {2.30490e-01, 3.23342e-07, 9.19258e-13, 4.47087e-18}, + {2.76795e-01, 3.88301e-07, 1.10394e-12, 5.36908e-18}, + {3.33074e-01, 4.67253e-07, 1.32840e-12, 6.46082e-18}, + {4.05326e-01, 5.68613e-07, 1.61658e-12, 7.86245e-18}, + {5.08161e-01, 7.12876e-07, 2.02672e-12, 9.85731e-18}, + {6.72474e-01, 9.43381e-07, 2.68206e-12, 1.30448e-17}, + {9.48552e-01, 1.33068e-06, 3.78319e-12, 1.84008e-17}, + {1.41789e+00, 1.98912e-06, 5.65528e-12, 2.75074e-17}, + {2.19503e+00, 3.07934e-06, 8.75500e-12, 4.25864e-17}, + {3.46724e+00, 4.86415e-06, 1.38300e-11, 6.72794e-17}, + {5.76869e+00, 8.09313e-06, 2.30131e-11, 1.11983e-16}, + {1.17202e+01, 1.64442e-05, 4.67706e-11, 2.27727e-16}, + {3.16486e+01, 4.44090e-05, 1.26336e-10, 6.15454e-16}, + {8.68419e+01, 1.21859e-04, 3.46686e-10, 1.68908e-15}, + {1.92333e+02, 2.69887e-04, 7.67805e-10, 3.74058e-15}, + {3.36287e+02, 4.71894e-04, 1.34247e-09, 6.53939e-15}, + {5.05924e+02, 7.09951e-04, 2.01945e-09, 9.83185e-15}, + {7.20787e+02, 1.01144e-03, 2.87594e-09, 1.39829e-14}, + {9.77602e+02, 1.37169e-03, 3.89813e-09, 1.89179e-14}, + {1.18669e+03, 1.66488e-03, 4.72879e-09, 2.29108e-14}, + {1.23874e+03, 1.73774e-03, 4.93372e-09, 2.38742e-14}, + {1.11204e+03, 1.55988e-03, 4.42750e-09, 2.14067e-14}, + {8.76525e+02, 1.22945e-03, 3.48896e-09, 1.68597e-14}, + {6.22287e+02, 8.72816e-04, 2.47658e-09, 1.19634e-14}, + {4.07334e+02, 5.71310e-04, 1.62094e-09, 7.82836e-15}, + {2.50598e+02, 3.51474e-04, 9.97166e-10, 4.81513e-15}, + {1.47088e+02, 2.06293e-04, 5.85254e-10, 2.82583e-15}, + {8.33219e+01, 1.16862e-04, 3.31541e-10, 1.60077e-15}, + {4.59660e+01, 6.44731e-05, 1.82924e-10, 8.83269e-16}, + } + }, + { + /* name = */ "SiO2_dust", + /* nonprimoridal_yield_frac = */ 1.65484e-03, + /* size_moments = */ {1.40285e-06, 3.98828e-12, 1.93974e-17}, + /* opacity_coef_table = */ { + {2.25389e-04, 2.91423e-10, 2.39426e-15, 3.55346e-20}, + {4.04967e-04, 5.23622e-10, 4.30206e-15, 6.38511e-20}, + {6.31042e-04, 8.15942e-10, 6.70384e-15, 9.94996e-20}, + {9.15653e-04, 1.18395e-09, 9.72751e-15, 1.44378e-19}, + {1.52197e-03, 1.96795e-09, 1.61693e-14, 2.39993e-19}, + {2.37407e-03, 3.06977e-09, 2.52225e-14, 3.74371e-19}, + {3.77209e-03, 4.87751e-09, 4.00763e-14, 5.94853e-19}, + {6.14348e-03, 7.94395e-09, 6.52733e-14, 9.68874e-19}, + {1.01907e-02, 1.31776e-08, 1.08281e-13, 1.60732e-18}, + {1.68897e-02, 2.18408e-08, 1.79477e-13, 2.66430e-18}, + {2.96125e-02, 3.82967e-08, 3.14746e-13, 4.67293e-18}, + {6.10610e-02, 7.89818e-08, 6.49304e-13, 9.64262e-18}, + {1.43400e-01, 1.85524e-07, 1.52569e-12, 2.26652e-17}, + {3.27383e-01, 4.23645e-07, 3.48510e-12, 5.17901e-17}, + {6.39452e-01, 8.27698e-07, 6.81196e-12, 1.01271e-16}, + {1.05149e+00, 1.36261e-06, 1.12352e-11, 1.67335e-16}, + {1.55882e+00, 2.03505e-06, 1.69775e-11, 2.55740e-16}, + {2.94474e+00, 3.91135e-06, 3.34978e-11, 5.17225e-16}, + {1.32877e+01, 1.75173e-05, 1.48167e-10, 2.26035e-15}, + {7.10035e+01, 9.20831e-05, 7.58876e-10, 1.12902e-14}, + {2.54672e+02, 3.27285e-04, 2.65806e-09, 3.89823e-14}, + {5.99878e+02, 7.67225e-04, 6.18279e-09, 8.99815e-14}, + {9.93398e+02, 1.26701e-03, 1.01648e-08, 1.47279e-13}, + {1.24125e+03, 1.58042e-03, 1.26439e-08, 1.82695e-13}, + {1.24435e+03, 1.58257e-03, 1.26385e-08, 1.82292e-13}, + {1.05321e+03, 1.33853e-03, 1.06770e-08, 1.53820e-13}, + {7.84243e+02, 9.96171e-04, 7.93973e-09, 1.14294e-13}, + {5.30434e+02, 6.73540e-04, 5.36536e-09, 7.71941e-14}, + {3.33897e+02, 4.23882e-04, 3.37536e-09, 4.85451e-14}, + {1.99187e+02, 2.52825e-04, 2.01271e-09, 2.89397e-14}, + {1.14133e+02, 1.44851e-04, 1.15293e-09, 1.65742e-14}, + {6.34329e+01, 8.04978e-05, 6.40626e-10, 9.20833e-15}, + {3.44484e+01, 4.37133e-05, 3.47851e-10, 4.99954e-15}, + {1.83799e+01, 2.33224e-05, 1.85579e-10, 2.66709e-15}, + {9.67434e+00, 1.22756e-05, 9.76752e-11, 1.40372e-15}, + } + }, + { + /* name = */ "MgO_dust", + /* nonprimoridal_yield_frac = */ 9.48713e-04, + /* size_moments = */ {1.29303e-06, 1.06240e-11, 1.57687e-16}, + /* opacity_coef_table = */ { + {5.18099e-02, 8.75057e-08, 1.64042e-13, 3.48481e-19}, + {9.98914e-02, 1.68714e-07, 3.16278e-13, 6.71882e-19}, + {1.60422e-01, 2.70949e-07, 5.07932e-13, 1.07902e-18}, + {2.36626e-01, 3.99656e-07, 7.49210e-13, 1.59157e-18}, + {3.67294e-01, 6.20351e-07, 1.16293e-12, 2.47046e-18}, + {5.36239e-01, 9.05695e-07, 1.69785e-12, 3.60681e-18}, + {7.64225e-01, 1.29076e-06, 2.41970e-12, 5.14028e-18}, + {1.04974e+00, 1.77298e-06, 3.32371e-12, 7.06072e-18}, + {1.38085e+00, 2.33223e-06, 4.37210e-12, 9.28786e-18}, + {1.74382e+00, 2.94529e-06, 5.52140e-12, 1.17294e-17}, + {2.10325e+00, 3.55236e-06, 6.65945e-12, 1.41471e-17}, + {2.42167e+00, 4.09020e-06, 7.66778e-12, 1.62893e-17}, + {2.66848e+00, 4.50708e-06, 8.44938e-12, 1.79499e-17}, + {2.81672e+00, 4.75754e-06, 8.91905e-12, 1.89480e-17}, + {2.89933e+00, 4.89720e-06, 9.18118e-12, 1.95057e-17}, + {3.08200e+00, 5.20610e-06, 9.76116e-12, 2.07399e-17}, + {3.69875e+00, 6.24871e-06, 1.17179e-11, 2.49020e-17}, + {5.06356e+00, 8.55561e-06, 1.60466e-11, 3.41079e-17}, + {7.08905e+00, 1.19792e-05, 2.24709e-11, 4.77704e-17}, + {9.21663e+00, 1.55761e-05, 2.92218e-11, 6.21311e-17}, + {1.08429e+01, 1.83272e-05, 3.43894e-11, 7.31341e-17}, + {1.17217e+01, 1.98178e-05, 3.71989e-11, 7.91392e-17}, + {1.19809e+01, 2.02656e-05, 3.80618e-11, 8.10292e-17}, + {1.18982e+01, 2.01424e-05, 3.78698e-11, 8.07160e-17}, + {1.17194e+01, 1.98680e-05, 3.74208e-11, 7.99219e-17}, + {1.16101e+01, 1.97358e-05, 3.72971e-11, 7.99631e-17}, + {1.19784e+01, 2.05514e-05, 3.92888e-11, 8.53362e-17}, + {1.49136e+01, 2.65380e-05, 5.30405e-11, 1.20988e-16}, + {2.57980e+01, 4.84122e-05, 1.02966e-10, 2.50769e-16}, + {6.12919e+01, 1.18083e-04, 2.58706e-10, 6.49359e-16}, + {1.55902e+02, 3.00837e-04, 6.60279e-10, 1.66030e-15}, + {3.47036e+02, 6.65409e-04, 1.45009e-09, 3.62025e-15}, + {6.57260e+02, 1.25056e-03, 2.70176e-09, 6.68619e-15}, + {1.09327e+03, 2.06455e-03, 4.42254e-09, 1.08501e-14}, + {1.65394e+03, 3.10062e-03, 6.58692e-09, 1.60229e-14}, + } + }, + { + /* name = */ "FeS_dust", + /* nonprimoridal_yield_frac = */ 5.23050e-05, + /* size_moments = */ {1.68897e-06, 3.16618e-12, 6.72598e-18}, + /* opacity_coef_table = */ { + {9.93250e-04, 9.14846e-11, 8.97410e-18, 9.30612e-25}, + {1.81240e-03, 1.66933e-10, 1.63752e-17, 1.69810e-24}, + {2.84365e-03, 2.61918e-10, 2.56926e-17, 2.66432e-24}, + {4.14191e-03, 3.81496e-10, 3.74225e-17, 3.88071e-24}, + {7.18271e-03, 6.61573e-10, 6.48964e-17, 6.72974e-24}, + {1.13364e-02, 1.04415e-09, 1.02425e-16, 1.06215e-23}, + {1.77361e-02, 1.63360e-09, 1.60247e-16, 1.66176e-23}, + {2.59477e-02, 2.38995e-09, 2.34440e-16, 2.43114e-23}, + {3.45425e-02, 3.18159e-09, 3.12095e-16, 3.23642e-23}, + {4.22006e-02, 3.88695e-09, 3.81286e-16, 3.95393e-23}, + {4.71420e-02, 4.34208e-09, 4.25932e-16, 4.41691e-23}, + {4.91934e-02, 4.53102e-09, 4.44466e-16, 4.60911e-23}, + {5.05162e-02, 4.65286e-09, 4.56418e-16, 4.73304e-23}, + {5.78201e-02, 5.32560e-09, 5.22410e-16, 5.41738e-23}, + {8.84237e-02, 8.14438e-09, 7.98916e-16, 8.28474e-23}, + {1.78786e-01, 1.64673e-08, 1.61535e-15, 1.67511e-22}, + {4.36404e-01, 4.01956e-08, 3.94295e-15, 4.08884e-22}, + {1.63796e+00, 1.50867e-07, 1.47992e-14, 1.53467e-21}, + {8.50819e+00, 7.83659e-07, 7.68723e-14, 7.97165e-21}, + {3.92751e+01, 3.61749e-06, 3.54854e-13, 3.67984e-20}, + {1.41439e+02, 1.30275e-05, 1.27792e-12, 1.32520e-19}, + {3.83709e+02, 3.53420e-05, 3.46684e-12, 3.59511e-19}, + {7.70411e+02, 7.09598e-05, 6.96073e-12, 7.21827e-19}, + {1.16399e+03, 1.07211e-04, 1.05167e-11, 1.09058e-18}, + {1.37566e+03, 1.26707e-04, 1.24292e-11, 1.28891e-18}, + {1.33070e+03, 1.22566e-04, 1.20230e-11, 1.24678e-18}, + {1.09978e+03, 1.01297e-04, 9.93663e-12, 1.03043e-18}, + {8.05638e+02, 7.42044e-05, 7.27901e-12, 7.54832e-19}, + {5.38690e+02, 4.96167e-05, 4.86711e-12, 5.04718e-19}, + {3.36338e+02, 3.09789e-05, 3.03884e-12, 3.15127e-19}, + {1.99460e+02, 1.83715e-05, 1.80214e-12, 1.86881e-19}, + {1.13787e+02, 1.04805e-05, 1.02808e-12, 1.06611e-19}, + {6.30411e+01, 5.80648e-06, 5.69582e-13, 5.90655e-20}, + {3.41529e+01, 3.14570e-06, 3.08575e-13, 3.19991e-20}, + {1.81893e+01, 1.67535e-06, 1.64342e-13, 1.70422e-20}, + } + }, + { + /* name = */ "Al2O3_dust", + /* nonprimoridal_yield_frac = */ 1.31693e-29, + /* size_moments = */ {9.21063e-08, 9.03508e-15, 9.36936e-22}, + /* opacity_coef_table = */ { + {1.53894e-01, 1.90916e-06, 4.34900e-11, 1.52207e-15}, + {1.93844e-01, 2.40648e-06, 5.48634e-11, 1.92178e-15}, + {2.44138e-01, 3.03256e-06, 6.91797e-11, 2.42474e-15}, + {3.07454e-01, 3.82073e-06, 8.72020e-11, 3.05783e-15}, + {3.87243e-01, 4.81526e-06, 1.09978e-10, 3.85936e-15}, + {4.87709e-01, 6.06778e-06, 1.38669e-10, 4.86916e-15}, + {6.14251e-01, 7.64642e-06, 1.74856e-10, 6.14383e-15}, + {7.73625e-01, 9.63590e-06, 2.20495e-10, 7.75268e-15}, + {9.74036e-01, 1.21392e-05, 2.77959e-10, 9.78002e-15}, + {1.22376e+00, 1.52600e-05, 3.49642e-10, 1.23105e-14}, + {1.52029e+00, 1.89682e-05, 4.34881e-10, 1.53223e-14}, + {1.83650e+00, 2.29254e-05, 5.25941e-10, 1.85447e-14}, + {2.15714e+00, 2.69443e-05, 6.18616e-10, 2.18354e-14}, + {2.55729e+00, 3.19712e-05, 7.34846e-10, 2.59753e-14}, + {3.23398e+00, 4.04866e-05, 9.32032e-10, 3.30022e-14}, + {4.34499e+00, 5.44911e-05, 1.25683e-09, 4.45846e-14}, + {5.84259e+00, 7.34292e-05, 1.69748e-09, 6.03345e-14}, + {7.53509e+00, 9.49825e-05, 2.20255e-09, 7.84868e-14}, + {9.31292e+00, 1.17996e-04, 2.75076e-09, 9.84428e-14}, + {1.14053e+01, 1.46050e-04, 3.44207e-09, 1.24265e-13}, + {1.44699e+01, 1.88865e-04, 4.53802e-09, 1.66375e-13}, + {1.88525e+01, 2.52409e-04, 6.22006e-09, 2.32633e-13}, + {2.35897e+01, 3.27106e-04, 8.33967e-09, 3.20293e-13}, + {2.71065e+01, 3.99935e-04, 1.08043e-08, 4.33797e-13}, + {2.87408e+01, 4.69399e-04, 1.38602e-08, 5.94648e-13}, + {2.88428e+01, 5.34587e-04, 1.74785e-08, 8.07129e-13}, + {2.80514e+01, 5.86377e-04, 2.09655e-08, 1.03092e-12}, + {2.67893e+01, 6.13530e-04, 2.33810e-08, 1.20137e-12}, + {2.53851e+01, 6.14601e-04, 2.43011e-08, 1.28034e-12}, + {2.53848e+01, 6.23633e-04, 2.48207e-08, 1.31287e-12}, + {3.52560e+01, 8.08661e-04, 3.01974e-08, 1.52398e-12}, + {9.64731e+01, 1.84326e-03, 5.73265e-08, 2.51143e-12}, + {3.56496e+02, 5.70937e-03, 1.44867e-07, 5.33930e-12}, + {1.16716e+03, 1.65654e-02, 3.60906e-07, 1.15456e-11}, + {3.02792e+03, 3.93985e-02, 7.71226e-07, 2.22345e-11}, + } + }, +}; + +} // namespace ccsn20 + +namespace ccsn25 { +static const MetalNuclideYieldProps metal_props[] = { + // {name, gas_yield, total_yield} + {"C", 1.34092e-01, 1.75488e-01}, + {"O", 5.53726e-01, 5.69674e-01}, + {"Mg", 2.48100e-02, 3.12340e-02}, + {"Al", 2.98415e-04, 2.98415e-04}, + {"Si", 3.47760e-02, 8.33205e-02}, + {"S", 4.72556e-02, 4.73930e-02}, + {"Fe", 1.46955e-02, 1.98197e-02}, +}; + +static const GrainSpeciesYieldProps grain_props[] = { + { + /* name = */ "SiM_dust", + /* nonprimoridal_yield_frac = */ 3.83373e-02, + /* size_moments = */ {1.72153e-05, 6.33208e-10, 4.04318e-14}, + /* opacity_coef_table = */ { + {7.05387e-02, 2.70513e-06, 1.33741e-10, 7.96280e-15}, + {1.06564e-01, 3.93018e-06, 1.88633e-10, 1.09924e-14}, + {1.50619e-01, 5.42584e-06, 2.55756e-10, 1.47090e-14}, + {2.05371e-01, 7.28371e-06, 3.39206e-10, 1.93364e-14}, + {2.90528e-01, 9.90213e-06, 4.47050e-10, 2.49139e-14}, + {3.98319e-01, 1.31460e-05, 5.78557e-10, 3.16454e-14}, + {5.44029e-01, 1.73143e-05, 7.40062e-10, 3.96165e-14}, + {7.41852e-01, 2.27123e-05, 9.40496e-10, 4.91736e-14}, + {1.01111e+00, 2.97427e-05, 1.19128e-09, 6.07485e-14}, + {1.37135e+00, 3.87934e-05, 1.50307e-09, 7.47433e-14}, + {1.85427e+00, 5.04362e-05, 1.88890e-09, 9.15116e-14}, + {2.48538e+00, 6.50566e-05, 2.35529e-09, 1.11141e-13}, + {3.28338e+00, 8.28882e-05, 2.90473e-09, 1.33599e-13}, + {4.26495e+00, 1.04109e-04, 3.53805e-09, 1.58791e-13}, + {5.44209e+00, 1.28847e-04, 4.25649e-09, 1.86722e-13}, + {6.82357e+00, 1.57201e-04, 5.06195e-09, 2.17471e-13}, + {8.41130e+00, 1.89169e-04, 5.95453e-09, 2.51081e-13}, + {1.02033e+01, 2.24714e-04, 6.93482e-09, 2.87663e-13}, + {1.22164e+01, 2.64256e-04, 8.01879e-09, 3.27999e-13}, + {1.45282e+01, 3.09507e-04, 9.26157e-09, 3.74467e-13}, + {1.73262e+01, 3.64447e-04, 1.07851e-08, 4.32120e-13}, + {2.09720e+01, 4.36715e-04, 1.28220e-08, 5.10543e-13}, + {2.61035e+01, 5.39852e-04, 1.57872e-08, 6.26923e-13}, + {3.37725e+01, 6.96147e-04, 2.03646e-08, 8.09666e-13}, + {4.55764e+01, 9.38083e-04, 2.75201e-08, 1.09797e-12}, + {6.37992e+01, 1.30793e-03, 3.84014e-08, 1.53493e-12}, + {9.17796e+01, 1.86084e-03, 5.43135e-08, 2.16276e-12}, + {1.34749e+02, 2.67751e-03, 7.69998e-08, 3.03160e-12}, + {2.01156e+02, 3.88432e-03, 1.09109e-07, 4.21570e-12}, + {3.04328e+02, 5.67395e-03, 1.54550e-07, 5.82179e-12}, + {4.64551e+02, 8.32593e-03, 2.18657e-07, 7.98599e-12}, + {7.11390e+02, 1.22244e-02, 3.08194e-07, 1.08633e-11}, + {1.08442e+03, 1.78487e-02, 4.30797e-07, 1.46043e-11}, + {1.62442e+03, 2.56300e-02, 5.92006e-07, 1.92777e-11}, + {2.34943e+03, 3.56242e-02, 7.89629e-07, 2.47479e-11}, + } + }, + { + /* name = */ "FeM_dust", + /* nonprimoridal_yield_frac = */ 4.88366e-03, + /* size_moments = */ {1.96666e-05, 5.88305e-10, 2.42323e-14}, + /* opacity_coef_table = */ { + {1.05240e-01, 2.45433e-07, 2.61677e-12, 4.51929e-17}, + {1.32588e-01, 3.09211e-07, 3.29676e-12, 5.69367e-17}, + {1.67016e-01, 3.89504e-07, 4.15283e-12, 7.17213e-17}, + {2.10360e-01, 4.90585e-07, 5.23055e-12, 9.03341e-17}, + {2.71887e-01, 6.34079e-07, 6.76050e-12, 1.16758e-16}, + {3.55694e-01, 8.29533e-07, 8.84446e-12, 1.52750e-16}, + {4.84933e-01, 1.13094e-06, 1.20582e-11, 2.08253e-16}, + {6.99770e-01, 1.63200e-06, 1.74006e-11, 3.00524e-16}, + {1.05860e+00, 2.46891e-06, 2.63246e-11, 4.54655e-16}, + {1.62903e+00, 3.79938e-06, 4.05116e-11, 6.99697e-16}, + {2.54264e+00, 5.93041e-06, 6.32372e-11, 1.09224e-15}, + {3.96499e+00, 9.24857e-06, 9.86269e-11, 1.70359e-15}, + {6.10655e+00, 1.42452e-05, 1.51927e-10, 2.62446e-15}, + {9.28824e+00, 2.16706e-05, 2.31158e-10, 3.99359e-15}, + {1.39278e+01, 3.25027e-05, 3.46790e-10, 5.99240e-15}, + {2.05413e+01, 4.79530e-05, 5.11839e-10, 8.84697e-15}, + {3.00722e+01, 7.02477e-05, 7.50339e-10, 1.29761e-14}, + {4.55290e+01, 1.06478e-04, 1.13881e-09, 1.97131e-14}, + {7.48333e+01, 1.75301e-04, 1.87829e-09, 3.25565e-14}, + {1.29734e+02, 3.04341e-04, 3.26603e-09, 5.66753e-14}, + {2.15039e+02, 5.04949e-04, 5.42460e-09, 9.42056e-14}, + {3.20373e+02, 7.52945e-04, 8.09632e-09, 1.40698e-13}, + {4.30336e+02, 1.01240e-03, 1.08979e-08, 1.89530e-13}, + {5.31620e+02, 1.25190e-03, 1.34895e-08, 2.34771e-13}, + {6.00659e+02, 1.41538e-03, 1.52608e-08, 2.65718e-13}, + {6.07548e+02, 1.43203e-03, 1.54444e-08, 2.68965e-13}, + {5.44184e+02, 1.28282e-03, 1.38365e-08, 2.40975e-13}, + {4.34292e+02, 1.02387e-03, 1.10444e-08, 1.92359e-13}, + {3.13872e+02, 7.40120e-04, 7.98523e-09, 1.39097e-13}, + {2.09392e+02, 4.93970e-04, 5.33184e-09, 9.29066e-14}, + {1.31415e+02, 3.10355e-04, 3.35361e-09, 5.84810e-14}, + {7.92901e+01, 1.87957e-04, 2.03808e-09, 3.56245e-14}, + {4.76038e+01, 1.14252e-04, 1.25235e-09, 2.20472e-14}, + {3.00283e+01, 7.42825e-05, 8.34278e-10, 1.49154e-14}, + {2.10539e+01, 5.48540e-05, 6.37875e-10, 1.16338e-14}, + } + }, + { + /* name = */ "Mg2SiO4_dust", + /* nonprimoridal_yield_frac = */ 1.68068e-02, + /* size_moments = */ {2.33213e-06, 2.48648e-11, 4.29427e-16}, + /* opacity_coef_table = */ { + {2.19890e-02, 3.41795e-08, 9.45655e-14, 4.23439e-19}, + {3.90612e-02, 6.07164e-08, 1.67986e-13, 7.52197e-19}, + {6.05539e-02, 9.41245e-08, 2.60417e-13, 1.16608e-18}, + {8.76116e-02, 1.36183e-07, 3.76781e-13, 1.68713e-18}, + {1.43288e-01, 2.22725e-07, 6.16221e-13, 2.75928e-18}, + {2.19266e-01, 3.40825e-07, 9.42974e-13, 4.22240e-18}, + {3.36256e-01, 5.22673e-07, 1.44610e-12, 6.47526e-18}, + {5.14336e-01, 7.99479e-07, 2.21195e-12, 9.90458e-18}, + {7.97217e-01, 1.23919e-06, 3.42851e-12, 1.53521e-17}, + {1.25414e+00, 1.94943e-06, 5.39358e-12, 2.41515e-17}, + {2.03450e+00, 3.16241e-06, 8.74964e-12, 3.91798e-17}, + {3.34649e+00, 5.20178e-06, 1.43922e-11, 6.44481e-17}, + {5.45897e+00, 8.48547e-06, 2.34778e-11, 1.05137e-16}, + {8.82126e+00, 1.37119e-05, 3.79391e-11, 1.69905e-16}, + {1.41827e+01, 2.20461e-05, 6.10001e-11, 2.73202e-16}, + {2.28425e+01, 3.55077e-05, 9.82519e-11, 4.40095e-16}, + {3.71193e+01, 5.77019e-05, 1.59676e-10, 7.15351e-16}, + {6.14319e+01, 9.54994e-05, 2.64297e-10, 1.18434e-15}, + {1.03856e+02, 1.61458e-04, 4.46893e-10, 2.00314e-15}, + {1.75529e+02, 2.72897e-04, 7.55426e-10, 3.38696e-15}, + {2.82103e+02, 4.38604e-04, 1.21423e-09, 5.44494e-15}, + {4.14591e+02, 6.44612e-04, 1.78465e-09, 8.00387e-15}, + {5.60087e+02, 8.70868e-04, 2.41120e-09, 1.08148e-14}, + {7.11212e+02, 1.10590e-03, 3.06203e-09, 1.37338e-14}, + {8.41053e+02, 1.30782e-03, 3.62100e-09, 1.62382e-14}, + {8.95593e+02, 1.39263e-03, 3.85557e-09, 1.72860e-14}, + {8.40674e+02, 1.30722e-03, 3.61884e-09, 1.62210e-14}, + {6.96909e+02, 1.08365e-03, 2.99976e-09, 1.34436e-14}, + {5.18364e+02, 8.06018e-04, 2.23111e-09, 9.99751e-15}, + {3.52974e+02, 5.48846e-04, 1.51920e-09, 6.80696e-15}, + {2.24287e+02, 3.48752e-04, 9.65345e-10, 4.32526e-15}, + {1.35182e+02, 2.10204e-04, 5.81862e-10, 2.60719e-15}, + {7.83444e+01, 1.21833e-04, 3.37284e-10, 1.51159e-15}, + {4.41840e+01, 6.87277e-05, 1.90332e-10, 8.53442e-16}, + {2.46537e+01, 3.84248e-05, 1.06643e-10, 4.79266e-16}, + } + }, + { + /* name = */ "MgSiO3_dust", + /* nonprimoridal_yield_frac = */ 2.49736e-05, + /* size_moments = */ {1.55439e-06, 4.30058e-12, 1.92568e-17}, + /* opacity_coef_table = */ { + {3.27960e-01, 2.60233e-07, 1.15896e-12, 3.41207e-17}, + {4.38752e-01, 3.48153e-07, 1.55085e-12, 4.56711e-17}, + {5.78230e-01, 4.58837e-07, 2.04421e-12, 6.02121e-17}, + {7.53824e-01, 5.98180e-07, 2.66530e-12, 7.85179e-17}, + {1.04013e+00, 8.25404e-07, 3.67884e-12, 1.08416e-16}, + {1.41735e+00, 1.12479e-06, 5.01451e-12, 1.47828e-16}, + {1.95293e+00, 1.54986e-06, 6.91189e-12, 2.03855e-16}, + {2.71532e+00, 2.15499e-06, 9.61533e-12, 2.83773e-16}, + {3.79678e+00, 3.01350e-06, 1.34554e-11, 3.97470e-16}, + {5.29747e+00, 4.20498e-06, 1.87919e-11, 5.55745e-16}, + {7.37842e+00, 5.85746e-06, 2.62073e-11, 7.76231e-16}, + {1.02169e+01, 8.11222e-06, 3.63532e-11, 1.07888e-15}, + {1.40424e+01, 1.11520e-05, 5.00793e-11, 1.48986e-15}, + {1.92027e+01, 1.52549e-05, 6.86959e-11, 2.04983e-15}, + {2.61627e+01, 2.07929e-05, 9.39920e-11, 2.81528e-15}, + {3.55327e+01, 2.82565e-05, 1.28407e-10, 3.86530e-15}, + {4.81650e+01, 3.83349e-05, 1.75518e-10, 5.31971e-15}, + {6.53244e+01, 5.20561e-05, 2.40904e-10, 7.37173e-15}, + {8.87808e+01, 7.08733e-05, 3.33003e-10, 1.03268e-14}, + {1.20733e+02, 9.66248e-05, 4.63924e-10, 1.46567e-14}, + {1.63674e+02, 1.31491e-04, 6.51645e-10, 2.11366e-14}, + {2.20677e+02, 1.78321e-04, 9.26445e-10, 3.11929e-14}, + {2.96305e+02, 2.41503e-04, 1.34108e-09, 4.74137e-14}, + {3.97405e+02, 3.27522e-04, 1.97072e-09, 7.35006e-14}, + {5.32189e+02, 4.43695e-04, 2.88200e-09, 1.12542e-13}, + {7.08046e+02, 5.95675e-04, 4.08283e-09, 1.64175e-13}, + {9.32526e+02, 7.88039e-04, 5.50980e-09, 2.23600e-13}, + {1.21879e+03, 1.02941e-03, 7.08050e-09, 2.84124e-13}, + {1.59074e+03, 1.33766e-03, 8.76094e-09, 3.40697e-13}, + {2.08510e+03, 1.74270e-03, 1.05986e-08, 3.91613e-13}, + {2.75362e+03, 2.28917e-03, 1.27282e-08, 4.38283e-13}, + {3.66839e+03, 3.04259e-03, 1.53805e-08, 4.84412e-13}, + {4.93379e+03, 4.10065e-03, 1.89004e-08, 5.35144e-13}, + {6.70658e+03, 5.60645e-03, 2.37440e-08, 5.95776e-13}, + {9.22668e+03, 7.75494e-03, 3.03854e-08, 6.69355e-13}, + } + }, + { + /* name = */ "AC_dust", + /* nonprimoridal_yield_frac = */ 4.13961e-02, + /* size_moments = */ {7.93494e-07, 3.53402e-12, 1.04050e-16}, + /* opacity_coef_table = */ { + {7.60344e-02, 1.95196e-07, 3.66716e-12, 1.92423e-16}, + {9.07191e-02, 2.32906e-07, 4.37632e-12, 2.29682e-16}, + {1.09206e-01, 2.80380e-07, 5.26909e-12, 2.76586e-16}, + {1.32480e-01, 3.40146e-07, 6.39301e-12, 3.35635e-16}, + {1.58906e-01, 4.08019e-07, 7.66999e-12, 4.02759e-16}, + {1.91564e-01, 4.91897e-07, 9.24810e-12, 4.85715e-16}, + {2.30489e-01, 5.91872e-07, 1.11292e-11, 5.84611e-16}, + {2.76795e-01, 7.10808e-07, 1.33674e-11, 7.02310e-16}, + {3.33075e-01, 8.55378e-07, 1.60886e-11, 8.45443e-16}, + {4.05328e-01, 1.04100e-06, 1.95833e-11, 1.02932e-15}, + {5.08167e-01, 1.30521e-06, 2.45600e-11, 1.29133e-15}, + {6.72485e-01, 1.72749e-06, 3.25210e-11, 1.71095e-15}, + {9.48580e-01, 2.43730e-06, 4.59219e-11, 2.41877e-15}, + {1.41796e+00, 3.64482e-06, 6.87751e-11, 3.63027e-15}, + {2.19521e+00, 5.64613e-06, 1.06783e-10, 5.65494e-15}, + {3.46773e+00, 8.92808e-06, 1.69393e-10, 9.00627e-15}, + {5.77034e+00, 1.48887e-05, 2.83967e-10, 1.51653e-14}, + {1.17273e+01, 3.03917e-05, 5.84644e-10, 3.13500e-14}, + {3.16762e+01, 8.23694e-05, 1.59258e-09, 8.53491e-14}, + {8.69213e+01, 2.26080e-04, 4.36458e-09, 2.32841e-13}, + {1.92500e+02, 5.00291e-04, 9.62913e-09, 5.11437e-13}, + {3.36556e+02, 8.73556e-04, 1.67531e-08, 8.86507e-13}, + {5.06180e+02, 1.30807e-03, 2.48422e-08, 1.30609e-12}, + {7.20631e+02, 1.84289e-03, 3.42245e-08, 1.77586e-12}, + {9.76452e+02, 2.46285e-03, 4.43878e-08, 2.26306e-12}, + {1.18428e+03, 2.95079e-03, 5.17620e-08, 2.59653e-12}, + {1.23545e+03, 3.05120e-03, 5.24657e-08, 2.59989e-12}, + {1.10864e+03, 2.72192e-03, 4.61791e-08, 2.26949e-12}, + {8.73605e+02, 2.13674e-03, 3.59368e-08, 1.75670e-12}, + {6.20107e+02, 1.51303e-03, 2.53058e-08, 1.23288e-12}, + {4.05864e+02, 9.88756e-04, 1.64791e-08, 8.01183e-13}, + {2.49677e+02, 6.07668e-04, 1.01055e-08, 4.90701e-13}, + {1.46540e+02, 3.56444e-04, 5.92003e-09, 2.87265e-13}, + {8.30108e+01, 2.01877e-04, 3.35130e-09, 1.62587e-13}, + {4.57957e+01, 1.11407e-04, 1.85045e-09, 8.98118e-14}, + } + }, + { + /* name = */ "SiO2_dust", + /* nonprimoridal_yield_frac = */ 1.46546e-02, + /* size_moments = */ {2.56804e-06, 4.82971e-11, 2.53766e-15}, + /* opacity_coef_table = */ { + {2.25388e-04, 8.07807e-10, 6.97998e-15, 9.10286e-20}, + {4.04965e-04, 1.45145e-09, 1.25417e-14, 1.63564e-19}, + {6.31040e-04, 2.26174e-09, 1.95435e-14, 2.54881e-19}, + {9.15651e-04, 3.28184e-09, 2.83582e-14, 3.69842e-19}, + {1.52197e-03, 5.45504e-09, 4.71373e-14, 6.14765e-19}, + {2.37408e-03, 8.50921e-09, 7.35292e-14, 9.58978e-19}, + {3.77210e-03, 1.35201e-08, 1.16831e-13, 1.52374e-18}, + {6.14351e-03, 2.20201e-08, 1.90284e-13, 2.48178e-18}, + {1.01908e-02, 3.65275e-08, 3.15657e-13, 4.11707e-18}, + {1.68899e-02, 6.05411e-08, 5.23195e-13, 6.82425e-18}, + {2.96134e-02, 1.06156e-07, 9.17483e-13, 1.19682e-17}, + {6.10648e-02, 2.18932e-07, 1.89256e-12, 2.46925e-17}, + {1.43413e-01, 5.14257e-07, 4.44656e-12, 5.80289e-17}, + {3.27427e-01, 1.17431e-06, 1.01561e-11, 1.32572e-16}, + {6.39567e-01, 2.29431e-06, 1.98486e-11, 2.59169e-16}, + {1.05188e+00, 3.77698e-06, 3.27186e-11, 4.27780e-16}, + {1.56137e+00, 5.64036e-06, 4.92651e-11, 6.49403e-16}, + {2.95878e+00, 1.08379e-05, 9.64135e-11, 1.29373e-15}, + {1.33369e+01, 4.85546e-05, 4.28194e-10, 5.69626e-15}, + {7.10715e+01, 2.55311e-04, 2.21076e-09, 2.88829e-14}, + {2.54519e+02, 9.07495e-04, 7.77715e-09, 1.00557e-13}, + {5.99024e+02, 2.12736e-03, 1.81309e-08, 2.33128e-13}, + {9.91502e+02, 3.51313e-03, 2.98462e-08, 3.82528e-13}, + {1.23853e+03, 4.38206e-03, 3.71546e-08, 4.75243e-13}, + {1.24134e+03, 4.38799e-03, 3.71575e-08, 4.74666e-13}, + {1.05053e+03, 3.71132e-03, 3.14012e-08, 4.00789e-13}, + {7.82169e+02, 2.76204e-03, 2.33559e-08, 2.97932e-13}, + {5.28995e+02, 1.86748e-03, 1.57854e-08, 2.01282e-13}, + {3.32978e+02, 1.17527e-03, 9.93166e-09, 1.26606e-13}, + {1.98632e+02, 7.00988e-04, 5.92262e-09, 7.54858e-14}, + {1.13813e+02, 4.01617e-04, 3.39280e-09, 4.32365e-14}, + {6.32536e+01, 2.23189e-04, 1.88528e-09, 2.40230e-14}, + {3.43507e+01, 1.21200e-04, 1.02371e-09, 1.30436e-14}, + {1.83277e+01, 6.46641e-05, 5.46160e-10, 6.95860e-15}, + {9.64683e+00, 3.40355e-05, 2.87461e-10, 3.66245e-15}, + } + }, + { + /* name = */ "MgO_dust", + /* nonprimoridal_yield_frac = */ 1.09289e-03, + /* size_moments = */ {3.58420e-06, 3.09713e-11, 4.03929e-16}, + /* opacity_coef_table = */ { + {5.18089e-02, 4.97944e-08, 1.27767e-13, 7.39409e-19}, + {9.98898e-02, 9.60047e-08, 2.46329e-13, 1.42543e-18}, + {1.60420e-01, 1.54180e-07, 3.95589e-13, 2.28909e-18}, + {2.36623e-01, 2.27418e-07, 5.83496e-13, 3.37637e-18}, + {3.67289e-01, 3.53003e-07, 9.05730e-13, 5.24118e-18}, + {5.36230e-01, 5.15376e-07, 1.32237e-12, 7.65247e-18}, + {7.64209e-01, 7.34494e-07, 1.88465e-12, 1.09071e-17}, + {1.04972e+00, 1.00891e-06, 2.58893e-12, 1.49849e-17}, + {1.38083e+00, 1.32717e-06, 3.40583e-12, 1.97167e-17}, + {1.74377e+00, 1.67607e-06, 4.30174e-12, 2.49099e-17}, + {2.10317e+00, 2.02159e-06, 5.18938e-12, 3.00615e-17}, + {2.42155e+00, 2.32777e-06, 5.97696e-12, 3.46445e-17}, + {2.66826e+00, 2.56519e-06, 6.58920e-12, 3.82277e-17}, + {2.81642e+00, 2.70807e-06, 6.96112e-12, 4.04503e-17}, + {2.89877e+00, 2.78835e-06, 7.17920e-12, 4.18739e-17}, + {3.08081e+00, 2.96627e-06, 7.66777e-12, 4.51307e-17}, + {3.69596e+00, 3.56434e-06, 9.27486e-12, 5.54010e-17}, + {5.05776e+00, 4.88601e-06, 1.28025e-11, 7.76522e-17}, + {7.07898e+00, 6.85096e-06, 1.80991e-11, 1.11855e-16}, + {9.20178e+00, 8.93168e-06, 2.39573e-11, 1.53397e-16}, + {1.08226e+01, 1.05533e-05, 2.89938e-11, 1.96013e-16}, + {1.16924e+01, 1.14675e-05, 3.24020e-11, 2.32497e-16}, + {1.19355e+01, 1.17825e-05, 3.42098e-11, 2.58640e-16}, + {1.18230e+01, 1.17613e-05, 3.49907e-11, 2.75275e-16}, + {1.15929e+01, 1.16487e-05, 3.54453e-11, 2.86649e-16}, + {1.13868e+01, 1.16310e-05, 3.63433e-11, 2.99851e-16}, + {1.14199e+01, 1.23167e-05, 4.12834e-11, 3.50696e-16}, + {1.29371e+01, 1.75436e-05, 7.43145e-11, 6.75730e-16}, + {2.05440e+01, 3.98903e-05, 2.16132e-10, 2.04334e-15}, + {4.78755e+01, 1.10160e-04, 6.39249e-10, 5.90057e-15}, + {1.21252e+02, 2.78758e-04, 1.57840e-09, 1.39121e-14}, + {2.69644e+02, 5.88705e-04, 3.18490e-09, 2.68674e-14}, + {5.11453e+02, 1.05406e-03, 5.44914e-09, 4.43131e-14}, + {8.53209e+02, 1.66585e-03, 8.25940e-09, 6.51454e-14}, + {1.29539e+03, 2.40455e-03, 1.14623e-08, 8.80401e-14}, + } + }, + { + /* name = */ "FeS_dust", + /* nonprimoridal_yield_frac = */ 3.77935e-04, + /* size_moments = */ {9.61035e-07, 2.46507e-12, 1.42549e-17}, + /* opacity_coef_table = */ { + {9.93250e-04, 1.98179e-11, 3.95420e-19, 7.88967e-27}, + {1.81240e-03, 3.61621e-11, 7.21529e-19, 1.43964e-26}, + {2.84365e-03, 5.67382e-11, 1.13208e-18, 2.25879e-26}, + {4.14191e-03, 8.26420e-11, 1.64892e-18, 3.29004e-26}, + {7.18271e-03, 1.43314e-10, 2.85949e-18, 5.70543e-26}, + {1.13364e-02, 2.26190e-10, 4.51309e-18, 9.00479e-26}, + {1.77361e-02, 3.53881e-10, 7.06085e-18, 1.40883e-25}, + {2.59477e-02, 5.17725e-10, 1.03300e-17, 2.06110e-25}, + {3.45425e-02, 6.89214e-10, 1.37516e-17, 2.74381e-25}, + {4.22006e-02, 8.42014e-10, 1.68004e-17, 3.35212e-25}, + {4.71420e-02, 9.40607e-10, 1.87676e-17, 3.74462e-25}, + {4.91934e-02, 9.81537e-10, 1.95842e-17, 3.90757e-25}, + {5.05162e-02, 1.00793e-09, 2.01109e-17, 4.01264e-25}, + {5.78201e-02, 1.15366e-09, 2.30186e-17, 4.59282e-25}, + {8.84237e-02, 1.76428e-09, 3.52021e-17, 7.02374e-25}, + {1.78786e-01, 3.56725e-09, 7.11761e-17, 1.42015e-24}, + {4.36404e-01, 8.70740e-09, 1.73736e-16, 3.46648e-24}, + {1.63796e+00, 3.26816e-08, 6.52083e-16, 1.30108e-23}, + {8.50817e+00, 1.69760e-07, 3.38716e-15, 6.75828e-23}, + {3.92751e+01, 7.83641e-07, 1.56357e-14, 3.11973e-22}, + {1.41433e+02, 2.82196e-06, 5.63055e-14, 1.12344e-21}, + {3.83709e+02, 7.65599e-06, 1.52757e-13, 3.04791e-21}, + {7.70411e+02, 1.53717e-05, 3.06706e-13, 6.11959e-21}, + {1.16399e+03, 2.32246e-05, 4.63392e-13, 9.24589e-21}, + {1.37566e+03, 2.74481e-05, 5.47662e-13, 1.09273e-20}, + {1.33070e+03, 2.65509e-05, 5.29761e-13, 1.05701e-20}, + {1.09978e+03, 2.19435e-05, 4.37830e-13, 8.73585e-21}, + {8.05638e+02, 1.60746e-05, 3.20730e-13, 6.39941e-21}, + {5.38690e+02, 1.07483e-05, 2.14456e-13, 4.27897e-21}, + {3.36338e+02, 6.71083e-06, 1.33899e-13, 2.67163e-21}, + {1.99460e+02, 3.97975e-06, 7.94065e-14, 1.58437e-21}, + {1.13787e+02, 2.27035e-06, 4.52995e-14, 9.03844e-22}, + {6.30411e+01, 1.25784e-06, 2.50971e-14, 5.00753e-22}, + {3.41529e+01, 6.81441e-07, 1.35965e-14, 2.71286e-22}, + {1.81893e+01, 3.62924e-07, 7.24128e-15, 1.44483e-22}, + } + }, + { + /* name = */ "Al2O3_dust", + /* nonprimoridal_yield_frac = */ 1.65550e-31, + /* size_moments = */ {1.99526e-08, 3.98107e-16, 7.94328e-24}, + /* opacity_coef_table = */ { + {1.53307e-01, 2.58151e-06, 8.97185e-11, 5.13410e-15}, + {1.93187e-01, 3.26103e-06, 1.14053e-10, 6.60852e-15}, + {2.43381e-01, 4.11484e-06, 1.44443e-10, 8.42753e-15}, + {3.06566e-01, 5.18903e-06, 1.82603e-10, 1.07022e-14}, + {3.86268e-01, 6.55217e-06, 2.31853e-10, 1.37374e-14}, + {4.86630e-01, 8.26891e-06, 2.93869e-10, 1.75576e-14}, + {6.13093e-01, 1.04376e-05, 3.72751e-10, 2.24815e-14}, + {7.72441e-01, 1.31779e-05, 4.73205e-10, 2.88483e-14}, + {9.72908e-01, 1.66348e-05, 6.00927e-10, 3.70670e-14}, + {1.22279e+00, 2.09532e-05, 7.61455e-10, 4.75186e-14}, + {1.51967e+00, 2.61010e-05, 9.54694e-10, 6.03376e-14}, + {1.83660e+00, 3.16418e-05, 1.16836e-09, 7.52509e-14}, + {2.15883e+00, 3.73832e-05, 1.40366e-09, 9.34936e-14}, + {2.56188e+00, 4.46730e-05, 1.71564e-09, 1.19386e-13}, + {3.24331e+00, 5.69556e-05, 2.23297e-09, 1.61351e-13}, + {4.36192e+00, 7.70449e-05, 3.06366e-09, 2.26659e-13}, + {5.87089e+00, 1.04185e-04, 4.17746e-09, 3.12654e-13}, + {7.58000e+00, 1.35161e-04, 5.44737e-09, 4.09330e-13}, + {9.38530e+00, 1.68565e-04, 6.82760e-09, 5.12932e-13}, + {1.15371e+01, 2.10285e-04, 8.59830e-09, 6.44799e-13}, + {1.47388e+01, 2.75860e-04, 1.14755e-08, 8.58985e-13}, + {1.93877e+01, 3.75887e-04, 1.59953e-08, 1.19600e-12}, + {2.46008e+01, 5.00971e-04, 2.20360e-08, 1.65571e-12}, + {2.90408e+01, 6.45456e-04, 3.01610e-08, 2.31085e-12}, + {3.23701e+01, 8.27330e-04, 4.23216e-08, 3.35508e-12}, + {3.49305e+01, 1.05238e-03, 5.92405e-08, 4.87268e-12}, + {3.68020e+01, 1.28200e-03, 7.79075e-08, 6.59988e-12}, + {3.76194e+01, 1.45174e-03, 9.27975e-08, 8.01634e-12}, + {3.72617e+01, 1.52446e-03, 1.00177e-07, 8.74632e-12}, + {3.76576e+01, 1.55784e-03, 1.02687e-07, 8.96074e-12}, + {4.91245e+01, 1.84545e-03, 1.14505e-07, 9.64022e-12}, + {1.17100e+02, 3.32870e-03, 1.70057e-07, 1.27411e-11}, + {3.93519e+02, 8.31574e-03, 3.27938e-07, 2.07522e-11}, + {1.23314e+03, 2.12665e-02, 6.72506e-07, 3.61691e-11}, + {3.12736e+03, 4.71942e-02, 1.26825e-06, 5.97225e-11}, + } + }, +}; + +} // namespace ccsn25 + +namespace ccsn30 { +static const MetalNuclideYieldProps metal_props[] = { + // {name, gas_yield, total_yield} + {"C", 4.93773e-02, 4.99965e-02}, + {"O", 7.29130e-01, 7.32832e-01}, + {"Mg", 3.76731e-02, 3.87430e-02}, + {"Al", 8.61678e-04, 8.61678e-04}, + {"Si", 4.01269e-02, 7.18810e-02}, + {"S", 3.68812e-02, 3.70455e-02}, + {"Fe", 1.23641e-02, 1.45822e-02}, +}; + +static const GrainSpeciesYieldProps grain_props[] = { + { + /* name = */ "SiM_dust", + /* nonprimoridal_yield_frac = */ 2.91389e-02, + /* size_moments = */ {2.56305e-05, 1.02092e-09, 5.78476e-14}, + /* opacity_coef_table = */ { + {7.21495e-02, 2.58300e-06, 1.19134e-10, 6.77090e-15}, + {1.09797e-01, 3.79107e-06, 1.69411e-10, 9.39020e-15}, + {1.55805e-01, 5.26522e-06, 2.30859e-10, 1.26025e-14}, + {2.12966e-01, 7.09577e-06, 3.07229e-10, 1.66015e-14}, + {3.02975e-01, 9.74053e-06, 4.08459e-10, 2.15040e-14}, + {4.17015e-01, 1.30295e-05, 5.32431e-10, 2.74392e-14}, + {5.71703e-01, 1.73021e-05, 6.86687e-10, 3.45374e-14}, + {7.82114e-01, 2.28860e-05, 8.80449e-10, 4.31318e-14}, + {1.06869e+00, 3.02137e-05, 1.12556e-09, 5.36402e-14}, + {1.45194e+00, 3.97008e-05, 1.43310e-09, 6.64513e-14}, + {1.96519e+00, 5.19736e-05, 1.81745e-09, 8.19495e-14}, + {2.63479e+00, 6.74573e-05, 2.28640e-09, 1.00267e-13}, + {3.47952e+00, 8.64064e-05, 2.84327e-09, 1.21406e-13}, + {4.51582e+00, 1.09014e-04, 3.48958e-09, 1.45307e-13}, + {5.75506e+00, 1.35409e-04, 4.22673e-09, 1.71980e-13}, + {7.20522e+00, 1.65686e-04, 5.05643e-09, 2.01492e-13}, + {8.86719e+00, 1.99826e-04, 5.97834e-09, 2.33868e-13}, + {1.07378e+01, 2.37775e-04, 6.99239e-09, 2.69183e-13}, + {1.28337e+01, 2.79956e-04, 8.11382e-09, 3.08137e-13}, + {1.52347e+01, 3.28163e-04, 9.39756e-09, 3.52929e-13}, + {1.81342e+01, 3.86588e-04, 1.09665e-08, 4.08289e-13}, + {2.19061e+01, 4.63288e-04, 1.30553e-08, 4.83202e-13}, + {2.72090e+01, 5.72531e-04, 1.60822e-08, 5.93756e-13}, + {3.51270e+01, 7.37785e-04, 2.07358e-08, 7.66520e-13}, + {4.72945e+01, 9.93265e-04, 2.79935e-08, 1.03837e-12}, + {6.60183e+01, 1.38363e-03, 3.90367e-08, 1.45073e-12}, + {9.46224e+01, 1.96740e-03, 5.52478e-08, 2.04604e-12}, + {1.38263e+02, 2.83025e-03, 7.85071e-08, 2.87658e-12}, + {2.05210e+02, 4.10585e-03, 1.11674e-07, 4.02015e-12}, + {3.08399e+02, 5.99700e-03, 1.58965e-07, 5.58896e-12}, + {4.67338e+02, 8.79616e-03, 2.26155e-07, 7.72827e-12}, + {7.10129e+02, 1.29022e-02, 3.20597e-07, 1.06077e-11}, + {1.07381e+03, 1.88070e-02, 4.50609e-07, 1.43975e-11}, + {1.59524e+03, 2.69407e-02, 6.22216e-07, 1.91854e-11}, + {2.28747e+03, 3.73289e-02, 8.32996e-07, 2.48404e-11}, + } + }, + { + /* name = */ "FeM_dust", + /* nonprimoridal_yield_frac = */ 1.93065e-03, + /* size_moments = */ {2.05800e-05, 5.92424e-10, 2.26690e-14}, + /* opacity_coef_table = */ { + {1.05240e-01, 4.94867e-08, 6.62401e-14, 1.80043e-19}, + {1.32588e-01, 6.23464e-08, 8.34533e-14, 2.26830e-19}, + {1.67016e-01, 7.85357e-08, 1.05123e-13, 2.85730e-19}, + {2.10360e-01, 9.89168e-08, 1.32405e-13, 3.59881e-19}, + {2.71887e-01, 1.27849e-07, 1.71131e-13, 4.65142e-19}, + {3.55694e-01, 1.67257e-07, 2.23881e-13, 6.08518e-19}, + {4.84932e-01, 2.28028e-07, 3.05226e-13, 8.29619e-19}, + {6.99767e-01, 3.29050e-07, 4.40448e-13, 1.19716e-18}, + {1.05860e+00, 4.97781e-07, 6.66304e-13, 1.81105e-18}, + {1.62902e+00, 7.66009e-07, 1.02534e-12, 2.78694e-18}, + {2.54260e+00, 1.19560e-06, 1.60037e-12, 4.34992e-18}, + {3.96488e+00, 1.86440e-06, 2.49561e-12, 6.78334e-18}, + {6.10630e+00, 2.87136e-06, 3.84349e-12, 1.04472e-17}, + {9.28767e+00, 4.36734e-06, 5.84598e-12, 1.58906e-17}, + {1.39265e+01, 6.54868e-06, 8.76595e-12, 2.38284e-17}, + {2.05383e+01, 9.65780e-06, 1.29279e-11, 3.51435e-17}, + {3.00651e+01, 1.41377e-05, 1.89253e-11, 5.14515e-17}, + {4.55105e+01, 2.14011e-05, 2.86497e-11, 7.79011e-17}, + {7.47848e+01, 3.51681e-05, 4.70833e-11, 1.28054e-16}, + {1.29623e+02, 6.09573e-05, 8.16150e-11, 2.22014e-16}, + {2.14824e+02, 1.01026e-04, 1.35269e-10, 3.68020e-16}, + {3.20010e+02, 1.50495e-04, 2.01516e-10, 5.48326e-16}, + {4.29781e+02, 2.02124e-04, 2.70665e-10, 7.36593e-16}, + {5.30850e+02, 2.49665e-04, 3.34350e-10, 9.10050e-16}, + {5.99723e+02, 2.82064e-04, 3.77759e-10, 1.02832e-15}, + {6.06569e+02, 2.85288e-04, 3.82090e-10, 1.04017e-15}, + {5.43292e+02, 2.55531e-04, 3.42243e-10, 9.31723e-16}, + {4.33571e+02, 2.03926e-04, 2.73131e-10, 7.43589e-16}, + {3.13340e+02, 1.47377e-04, 1.97394e-10, 5.37419e-16}, + {2.09022e+02, 9.83146e-05, 1.31685e-10, 3.58547e-16}, + {1.31159e+02, 6.16930e-05, 8.26409e-11, 2.25056e-16}, + {7.90789e+01, 3.72049e-05, 4.98596e-11, 1.35886e-16}, + {4.73566e+01, 2.23007e-05, 2.99370e-11, 8.18168e-17}, + {2.96727e+01, 1.40105e-05, 1.88993e-11, 5.20353e-17}, + {2.05268e+01, 9.75253e-06, 1.32995e-11, 3.71721e-17}, + } + }, + { + /* name = */ "Mg2SiO4_dust", + /* nonprimoridal_yield_frac = */ 7.73041e-04, + /* size_moments = */ {4.70227e-07, 6.29420e-13, 1.71079e-18}, + /* opacity_coef_table = */ { + {2.19890e-02, 2.24631e-08, 2.89738e-14, 5.78493e-20}, + {3.90612e-02, 3.99034e-08, 5.14691e-14, 1.02764e-19}, + {6.05539e-02, 6.18594e-08, 7.97889e-14, 1.59308e-19}, + {8.76116e-02, 8.95004e-08, 1.15442e-13, 2.30492e-19}, + {1.43288e-01, 1.46377e-07, 1.88803e-13, 3.76970e-19}, + {2.19266e-01, 2.23993e-07, 2.88916e-13, 5.76861e-19}, + {3.36256e-01, 3.43505e-07, 4.43068e-13, 8.84648e-19}, + {5.14336e-01, 5.25424e-07, 6.77716e-13, 1.35317e-18}, + {7.97217e-01, 8.14404e-07, 1.05046e-12, 2.09745e-18}, + {1.25414e+00, 1.28118e-06, 1.65253e-12, 3.29971e-18}, + {2.03450e+00, 2.07836e-06, 2.68078e-12, 5.35315e-18}, + {3.34648e+00, 3.41863e-06, 4.40956e-12, 8.80595e-18}, + {5.45894e+00, 5.57665e-06, 7.19317e-12, 1.43665e-17}, + {8.82120e+00, 9.01141e-06, 1.16237e-11, 2.32195e-17}, + {1.41826e+01, 1.44884e-05, 1.86888e-11, 3.73434e-17}, + {2.28421e+01, 2.33348e-05, 3.01009e-11, 6.01739e-17}, + {3.71183e+01, 3.79191e-05, 4.89167e-11, 9.78570e-17}, + {6.14292e+01, 6.27552e-05, 8.09620e-11, 1.62128e-16}, + {1.03850e+02, 1.06093e-04, 1.36885e-10, 2.74448e-16}, + {1.75514e+02, 1.79307e-04, 2.31368e-10, 4.64387e-16}, + {2.82073e+02, 2.88172e-04, 3.71865e-10, 7.46941e-16}, + {4.14542e+02, 4.23507e-04, 5.46530e-10, 1.09837e-15}, + {5.60007e+02, 5.72126e-04, 7.38347e-10, 1.48437e-15}, + {7.11091e+02, 7.26489e-04, 9.37565e-10, 1.88456e-15}, + {8.40894e+02, 8.59108e-04, 1.10867e-09, 2.22674e-15}, + {8.95416e+02, 9.14814e-04, 1.18049e-09, 2.36840e-15}, + {8.40506e+02, 8.58713e-04, 1.10802e-09, 2.22074e-15}, + {6.96770e+02, 7.11863e-04, 9.18488e-10, 1.83938e-15}, + {5.18262e+02, 5.29487e-04, 6.83149e-10, 1.36732e-15}, + {3.52905e+02, 3.60548e-04, 4.65172e-10, 9.30726e-16}, + {2.24242e+02, 2.29099e-04, 2.95579e-10, 5.91332e-16}, + {1.35153e+02, 1.38081e-04, 1.78153e-10, 3.56469e-16}, + {7.83239e+01, 8.00228e-05, 1.03253e-10, 2.06735e-16}, + {4.41660e+01, 4.51272e-05, 5.82391e-11, 1.16797e-16}, + {2.46140e+01, 2.51643e-05, 3.25109e-11, 6.54871e-17}, + } + }, + { + /* name = */ "MgSiO3_dust", + /* nonprimoridal_yield_frac = */ 4.17376e-06, + /* size_moments = */ {1.02156e-06, 1.31765e-12, 2.63083e-18}, + /* opacity_coef_table = */ { + {3.27960e-01, 3.83729e-07, 7.77768e-13, 2.49208e-18}, + {4.38752e-01, 5.13360e-07, 1.04052e-12, 3.33400e-18}, + {5.78230e-01, 6.76557e-07, 1.37130e-12, 4.39392e-18}, + {7.53823e-01, 8.82009e-07, 1.78773e-12, 5.72828e-18}, + {1.04013e+00, 1.21701e-06, 2.46677e-12, 7.90427e-18}, + {1.41736e+00, 1.65839e-06, 3.36142e-12, 1.07712e-17}, + {1.95293e+00, 2.28504e-06, 4.63158e-12, 1.48415e-17}, + {2.71531e+00, 3.17707e-06, 6.43967e-12, 2.06359e-17}, + {3.79677e+00, 4.44245e-06, 9.00459e-12, 2.88564e-17}, + {5.29746e+00, 6.19839e-06, 1.25639e-11, 4.02650e-17}, + {7.37839e+00, 8.63325e-06, 1.74996e-11, 5.60866e-17}, + {1.02169e+01, 1.19546e-05, 2.42326e-11, 7.76741e-17}, + {1.40423e+01, 1.64308e-05, 3.33069e-11, 1.06774e-16}, + {1.92025e+01, 2.24692e-05, 4.55495e-11, 1.46048e-16}, + {2.61625e+01, 3.06137e-05, 6.20638e-11, 1.99051e-16}, + {3.55322e+01, 4.15788e-05, 8.43006e-11, 2.70467e-16}, + {4.81640e+01, 5.63626e-05, 1.14288e-10, 3.66871e-16}, + {6.53224e+01, 7.64461e-05, 1.55039e-10, 4.98051e-16}, + {8.87770e+01, 1.03904e-04, 2.10775e-10, 6.77818e-16}, + {1.20724e+02, 1.41310e-04, 2.86753e-10, 9.23530e-16}, + {1.63658e+02, 1.91596e-04, 3.88991e-10, 1.25555e-15}, + {2.20645e+02, 2.58372e-04, 5.24942e-10, 1.69987e-15}, + {2.96236e+02, 3.47007e-04, 7.05751e-10, 2.29590e-15}, + {3.97277e+02, 4.65581e-04, 9.48153e-10, 3.10191e-15}, + {5.32000e+02, 6.23846e-04, 1.27229e-09, 4.18567e-15}, + {7.07873e+02, 8.30738e-04, 1.69662e-09, 5.60591e-15}, + {9.32623e+02, 1.09569e-03, 2.24083e-09, 7.42175e-15}, + {1.21977e+03, 1.43532e-03, 2.93992e-09, 9.74128e-15}, + {1.59377e+03, 1.87988e-03, 3.85840e-09, 1.27719e-14}, + {2.09261e+03, 2.47712e-03, 5.09977e-09, 1.68549e-14}, + {2.77023e+03, 3.29669e-03, 6.81899e-09, 2.25141e-14}, + {3.70299e+03, 4.44048e-03, 9.24971e-09, 3.05579e-14}, + {5.00261e+03, 6.06097e-03, 1.27486e-08, 4.22365e-14}, + {6.83605e+03, 8.38300e-03, 1.78358e-08, 5.93501e-14}, + {9.45120e+03, 1.17154e-02, 2.51744e-08, 8.40301e-14}, + } + }, + { + /* name = */ "AC_dust", + /* nonprimoridal_yield_frac = */ 6.19235e-04, + /* size_moments = */ {1.17005e-06, 2.37154e-12, 7.59875e-18}, + /* opacity_coef_table = */ { + {7.60354e-02, 1.23833e-07, 8.53754e-13, 1.45191e-17}, + {9.07201e-02, 1.47751e-07, 1.01868e-12, 1.73242e-17}, + {1.09207e-01, 1.77861e-07, 1.22631e-12, 2.08557e-17}, + {1.32481e-01, 2.15768e-07, 1.48770e-12, 2.53015e-17}, + {1.58907e-01, 2.58811e-07, 1.78454e-12, 3.03507e-17}, + {1.91564e-01, 3.12003e-07, 2.15137e-12, 3.65904e-17}, + {2.30490e-01, 3.75405e-07, 2.58860e-12, 4.40274e-17}, + {2.76795e-01, 4.50827e-07, 3.10875e-12, 5.28751e-17}, + {3.33074e-01, 5.42499e-07, 3.74099e-12, 6.36301e-17}, + {4.05326e-01, 6.60191e-07, 4.55275e-12, 7.74389e-17}, + {5.08163e-01, 8.27703e-07, 5.70817e-12, 9.70950e-17}, + {6.72477e-01, 1.09537e-06, 7.55468e-12, 1.28511e-16}, + {9.48561e-01, 1.54515e-06, 1.06581e-11, 1.81319e-16}, + {1.41791e+00, 2.30989e-06, 1.59363e-11, 2.71154e-16}, + {2.19508e+00, 3.57636e-06, 2.46813e-11, 4.20045e-16}, + {3.46738e+00, 5.65063e-06, 3.90198e-11, 6.64369e-16}, + {5.76921e+00, 9.40776e-06, 6.50678e-11, 1.10919e-15}, + {1.17225e+01, 1.91430e-05, 1.32874e-10, 2.27105e-15}, + {3.16576e+01, 5.17610e-05, 3.60367e-10, 6.17301e-15}, + {8.68678e+01, 1.42065e-04, 9.89621e-10, 1.69586e-14}, + {1.92388e+02, 3.14591e-04, 2.19062e-09, 3.75294e-14}, + {3.36374e+02, 5.49866e-04, 3.82570e-09, 6.54980e-14}, + {5.05999e+02, 8.26100e-04, 5.72796e-09, 9.78085e-14}, + {7.20701e+02, 1.17289e-03, 8.06418e-09, 1.36816e-13}, + {9.77142e+02, 1.58336e-03, 1.07627e-08, 1.81003e-13}, + {1.18576e+03, 1.91391e-03, 1.28756e-08, 2.14810e-13}, + {1.23749e+03, 1.99168e-03, 1.32966e-08, 2.20518e-13}, + {1.11076e+03, 1.78423e-03, 1.18503e-08, 1.95740e-13}, + {8.75424e+02, 1.40444e-03, 9.29642e-09, 1.53150e-13}, + {6.21466e+02, 9.96201e-04, 6.57984e-09, 1.08212e-13}, + {4.06780e+02, 6.51722e-04, 4.29860e-09, 7.06171e-14}, + {2.50252e+02, 4.00808e-04, 2.64130e-09, 4.33611e-14}, + {1.46882e+02, 2.35201e-04, 1.54913e-09, 2.54207e-14}, + {8.32048e+01, 1.33228e-04, 8.77332e-10, 1.43944e-14}, + {4.59015e+01, 7.35091e-05, 4.84195e-10, 7.94538e-15}, + } + }, + { + /* name = */ "SiO2_dust", + /* nonprimoridal_yield_frac = */ 5.27016e-03, + /* size_moments = */ {1.62875e-06, 1.12314e-11, 1.91031e-16}, + /* opacity_coef_table = */ { + {2.25389e-04, 5.23412e-10, 3.15038e-15, 3.37599e-20}, + {4.04967e-04, 9.40443e-10, 5.66055e-15, 6.06603e-20}, + {6.31042e-04, 1.46545e-09, 8.82067e-15, 9.45260e-20}, + {9.15653e-04, 2.12641e-09, 1.27990e-14, 1.37160e-19}, + {1.52197e-03, 3.53447e-09, 2.12745e-14, 2.27991e-19}, + {2.37407e-03, 5.51331e-09, 3.31857e-14, 3.55642e-19}, + {3.77209e-03, 8.75995e-09, 5.27284e-14, 5.65083e-19}, + {6.14348e-03, 1.42671e-08, 8.58786e-14, 9.20363e-19}, + {1.01907e-02, 2.36663e-08, 1.42459e-13, 1.52677e-18}, + {1.68897e-02, 3.92242e-08, 2.36116e-13, 2.53063e-18}, + {2.96125e-02, 6.87744e-08, 4.14030e-13, 4.43787e-18}, + {6.10613e-02, 1.41824e-07, 8.53932e-13, 9.15481e-18}, + {1.43400e-01, 3.33097e-07, 2.00598e-12, 2.15106e-17}, + {3.27386e-01, 7.60540e-07, 4.58100e-12, 4.91345e-17}, + {6.39460e-01, 1.48568e-06, 8.95096e-12, 9.60338e-17}, + {1.05151e+00, 2.44421e-06, 1.47414e-11, 1.58361e-16}, + {1.55897e+00, 3.63523e-06, 2.20702e-11, 2.39002e-16}, + {2.94595e+00, 6.92078e-06, 4.26541e-11, 4.70201e-16}, + {1.32939e+01, 3.11374e-05, 1.90589e-10, 2.08296e-15}, + {7.10280e+01, 1.65213e-04, 9.96517e-10, 1.06988e-14}, + {2.54734e+02, 5.90224e-04, 3.53091e-09, 3.75292e-14}, + {5.99997e+02, 1.38734e-03, 8.26333e-09, 8.73603e-14}, + {9.93558e+02, 2.29460e-03, 1.36329e-08, 1.43684e-13}, + {1.24146e+03, 2.86493e-03, 1.69946e-08, 1.78772e-13}, + {1.24450e+03, 2.87058e-03, 1.70110e-08, 1.78725e-13}, + {1.05332e+03, 2.42888e-03, 1.43842e-08, 1.51004e-13}, + {7.84315e+02, 1.80814e-03, 1.07031e-08, 1.12298e-13}, + {5.30478e+02, 1.22276e-03, 7.23576e-09, 7.58903e-14}, + {3.33924e+02, 7.69623e-04, 4.55334e-09, 4.77443e-14}, + {1.99202e+02, 4.59084e-04, 2.71568e-09, 2.84703e-14}, + {1.14141e+02, 2.63040e-04, 1.55583e-09, 1.63087e-14}, + {6.34373e+01, 1.46185e-04, 8.64588e-10, 9.06207e-15}, + {3.44508e+01, 7.93863e-05, 4.69493e-10, 4.92062e-15}, + {1.83812e+01, 4.23560e-05, 2.50488e-10, 2.62517e-15}, + {9.67501e+00, 2.22941e-05, 1.31841e-10, 1.38170e-15}, + } + }, + { + /* name = */ "MgO_dust", + /* nonprimoridal_yield_frac = */ 1.33978e-03, + /* size_moments = */ {2.32229e-06, 1.39783e-11, 1.49800e-16}, + /* opacity_coef_table = */ { + {5.18102e-02, 8.79700e-08, 3.32172e-13, 2.28308e-18}, + {9.98920e-02, 1.69607e-07, 6.40403e-13, 4.40131e-18}, + {1.60423e-01, 2.72381e-07, 1.02844e-12, 7.06800e-18}, + {2.36628e-01, 4.01766e-07, 1.51696e-12, 1.04252e-17}, + {3.67296e-01, 6.23631e-07, 2.35471e-12, 1.61832e-17}, + {5.36243e-01, 9.10491e-07, 3.43791e-12, 2.36285e-17}, + {7.64229e-01, 1.29761e-06, 4.89979e-12, 3.36782e-17}, + {1.04975e+00, 1.78244e-06, 6.73094e-12, 4.62695e-17}, + {1.38087e+00, 2.34473e-06, 8.85504e-12, 6.08809e-17}, + {1.74385e+00, 2.96123e-06, 1.11849e-11, 7.69178e-17}, + {2.10328e+00, 3.57180e-06, 1.34937e-11, 9.28279e-17}, + {2.42172e+00, 4.11304e-06, 1.55431e-11, 1.06984e-16}, + {2.66854e+00, 4.53297e-06, 1.71379e-11, 1.18057e-16}, + {2.81685e+00, 4.78622e-06, 1.81100e-11, 1.24934e-16}, + {2.89955e+00, 4.92990e-06, 1.86888e-11, 1.29362e-16}, + {3.08249e+00, 5.24916e-06, 1.99900e-11, 1.39496e-16}, + {3.69977e+00, 6.31698e-06, 2.42367e-11, 1.71353e-16}, + {5.06558e+00, 8.67290e-06, 3.35347e-11, 2.40280e-16}, + {7.09332e+00, 1.21816e-05, 4.75377e-11, 3.46171e-16}, + {9.22649e+00, 1.59270e-05, 6.32195e-11, 4.74390e-16}, + {1.08624e+01, 1.89007e-05, 7.70051e-11, 6.04198e-16}, + {1.17514e+01, 2.06434e-05, 8.66021e-11, 7.12327e-16}, + {1.20172e+01, 2.13237e-05, 9.19108e-11, 7.86989e-16}, + {1.19350e+01, 2.14078e-05, 9.44200e-11, 8.32977e-16}, + {1.17499e+01, 2.13514e-05, 9.60658e-11, 8.64823e-16}, + {1.16255e+01, 2.15518e-05, 9.90976e-11, 9.04821e-16}, + {1.19573e+01, 2.36139e-05, 1.14559e-10, 1.06630e-15}, + {1.51193e+01, 3.80077e-05, 2.17630e-10, 2.11441e-15}, + {2.88990e+01, 9.93223e-05, 6.64795e-10, 6.60023e-15}, + {7.41785e+01, 2.87865e-04, 1.99265e-09, 1.93332e-14}, + {1.88656e+02, 7.26466e-04, 4.90072e-09, 4.57065e-14}, + {4.09136e+02, 1.50900e-03, 9.80616e-09, 8.81118e-14}, + {7.53739e+02, 2.65184e-03, 1.66314e-08, 1.44869e-13}, + {1.22335e+03, 4.11549e-03, 2.50007e-08, 2.12244e-13}, + {1.81062e+03, 5.83587e-03, 3.44214e-08, 2.85851e-13}, + } + }, + { + /* name = */ "FeS_dust", + /* nonprimoridal_yield_frac = */ 4.51744e-04, + /* size_moments = */ {1.69769e-06, 6.40794e-12, 4.40126e-17}, + /* opacity_coef_table = */ { + {9.93250e-04, 7.58434e-11, 8.82228e-18, 1.41287e-24}, + {1.81240e-03, 1.38393e-10, 1.60982e-17, 2.57809e-24}, + {2.84365e-03, 2.17138e-10, 2.52580e-17, 4.04502e-24}, + {4.14191e-03, 3.16271e-10, 3.67894e-17, 5.89176e-24}, + {7.18271e-03, 5.48463e-10, 6.37986e-17, 1.02172e-23}, + {1.13364e-02, 8.65631e-10, 1.00692e-16, 1.61257e-23}, + {1.77361e-02, 1.35430e-09, 1.57536e-16, 2.52291e-23}, + {2.59477e-02, 1.98134e-09, 2.30474e-16, 3.69100e-23}, + {3.45425e-02, 2.63763e-09, 3.06815e-16, 4.91359e-23}, + {4.22006e-02, 3.22239e-09, 3.74836e-16, 6.00294e-23}, + {4.71420e-02, 3.59971e-09, 4.18726e-16, 6.70583e-23}, + {4.91934e-02, 3.75635e-09, 4.36947e-16, 6.99764e-23}, + {5.05162e-02, 3.85735e-09, 4.48697e-16, 7.18580e-23}, + {5.78201e-02, 4.41508e-09, 5.13572e-16, 8.22477e-23}, + {8.84237e-02, 6.75193e-09, 7.85401e-16, 1.25781e-22}, + {1.78786e-01, 1.36519e-08, 1.58802e-15, 2.54319e-22}, + {4.36405e-01, 3.33234e-08, 3.87627e-15, 6.20781e-22}, + {1.63797e+00, 1.25074e-07, 1.45490e-14, 2.33003e-21}, + {8.50820e+00, 6.49679e-07, 7.55727e-14, 1.21029e-20}, + {3.92752e+01, 2.99901e-06, 3.48854e-13, 5.58686e-20}, + {1.41437e+02, 1.08001e-05, 1.25630e-12, 2.01195e-19}, + {3.83709e+02, 2.92996e-05, 3.40821e-12, 5.45820e-19}, + {7.70412e+02, 5.88278e-05, 6.84300e-12, 1.09590e-18}, + {1.16399e+03, 8.88808e-05, 1.03388e-11, 1.65574e-18}, + {1.37566e+03, 1.05044e-04, 1.22190e-11, 1.95685e-18}, + {1.33070e+03, 1.01611e-04, 1.18196e-11, 1.89289e-18}, + {1.09978e+03, 8.39785e-05, 9.76864e-12, 1.56444e-18}, + {8.05639e+02, 6.15177e-05, 7.15589e-12, 1.14600e-18}, + {5.38690e+02, 4.11337e-05, 4.78477e-12, 7.66273e-19}, + {3.36338e+02, 2.56824e-05, 2.98743e-12, 4.78432e-19}, + {1.99460e+02, 1.52305e-05, 1.77165e-12, 2.83727e-19}, + {1.13787e+02, 8.68865e-06, 1.01068e-12, 1.61859e-19}, + {6.30411e+01, 4.81374e-06, 5.59946e-13, 8.96744e-20}, + {3.41529e+01, 2.60788e-06, 3.03354e-13, 4.85817e-20}, + {1.81893e+01, 1.38891e-06, 1.61561e-13, 2.58738e-20}, + } + }, + { + /* name = */ "Al2O3_dust", + /* nonprimoridal_yield_frac = */ 5.79251e-12, + /* size_moments = */ {7.63588e-08, 8.88224e-15, 1.42247e-21}, + /* opacity_coef_table = */ { + {1.52613e-01, 3.87036e-06, 1.51475e-10, 8.34686e-15}, + {1.92410e-01, 4.88554e-06, 1.91604e-10, 1.05937e-14}, + {2.42503e-01, 6.16264e-06, 2.42001e-10, 1.34057e-14}, + {3.05564e-01, 7.77004e-06, 3.05397e-10, 1.69392e-14}, + {3.85174e-01, 9.80462e-06, 3.86046e-10, 2.14732e-14}, + {4.85438e-01, 1.23675e-05, 4.87634e-10, 2.71828e-14}, + {6.11833e-01, 1.56019e-05, 6.16102e-10, 3.44270e-14}, + {7.71157e-01, 1.96838e-05, 7.78585e-10, 4.36231e-14}, + {9.71669e-01, 2.48269e-05, 9.83743e-10, 5.52763e-14}, + {1.22169e+00, 3.12457e-05, 1.24021e-09, 6.98829e-14}, + {1.51883e+00, 3.88844e-05, 1.54619e-09, 8.73862e-14}, + {1.83610e+00, 4.70620e-05, 1.87584e-09, 1.06471e-13}, + {2.15867e+00, 5.54249e-05, 2.21779e-09, 1.26800e-13}, + {2.56252e+00, 6.59468e-05, 2.65228e-09, 1.53070e-13}, + {3.24657e+00, 8.37697e-05, 3.38561e-09, 1.97020e-13}, + {4.37158e+00, 1.13090e-04, 4.58835e-09, 2.68525e-13}, + {5.89356e+00, 1.52861e-04, 6.22099e-09, 3.65325e-13}, + {7.62770e+00, 1.98484e-04, 8.10272e-09, 4.76950e-13}, + {9.48448e+00, 2.48132e-04, 1.01763e-08, 6.00571e-13}, + {1.17614e+01, 3.11117e-04, 1.28785e-08, 7.63878e-13}, + {1.52604e+01, 4.11692e-04, 1.73236e-08, 1.03683e-12}, + {2.04857e+01, 5.67120e-04, 2.43755e-08, 1.47603e-12}, + {2.67121e+01, 7.65926e-04, 3.38756e-08, 2.08532e-12}, + {3.30214e+01, 1.00600e-03, 4.67023e-08, 2.95970e-12}, + {3.94796e+01, 1.32148e-03, 6.59032e-08, 4.35947e-12}, + {4.60630e+01, 1.71870e-03, 9.26057e-08, 6.41018e-12}, + {5.17888e+01, 2.12529e-03, 1.22060e-07, 8.76593e-12}, + {5.52863e+01, 2.42692e-03, 1.45553e-07, 1.07154e-11}, + {5.60930e+01, 2.55895e-03, 1.57221e-07, 1.17347e-11}, + {5.70683e+01, 2.61927e-03, 1.61476e-07, 1.20713e-11}, + {7.25749e+01, 3.09971e-03, 1.82166e-07, 1.32162e-11}, + {1.59194e+02, 5.49929e-03, 2.77545e-07, 1.82852e-11}, + {4.83739e+02, 1.31658e-02, 5.43977e-07, 3.13196e-11}, + {1.39550e+03, 3.19882e-02, 1.11499e-06, 5.65773e-11}, + {3.29912e+03, 6.76125e-02, 2.08154e-06, 9.54501e-11}, + } + }, +}; + +} // namespace ccsn30 + +namespace fsn13 { +static const MetalNuclideYieldProps metal_props[] = { + // {name, gas_yield, total_yield} + {"C", 4.93693e-01, 6.69235e-01}, + {"O", 3.30556e-01, 3.30556e-01}, + {"Mg", 1.86824e-04, 1.86824e-04}, + {"Al", 1.97017e-07, 1.97017e-07}, + {"Si", 1.30184e-05, 1.30184e-05}, + {"S", 0.00000e+00, 0.00000e+00}, + {"Fe", 8.90341e-06, 8.90341e-06}, +}; + +static const GrainSpeciesYieldProps grain_props[] = { + { + /* name = */ "FeM_dust", + /* nonprimoridal_yield_frac = */ 6.31648e-26, + /* size_moments = */ {4.02937e-08, 1.67044e-15, 7.11477e-23}, + /* opacity_coef_table = */ { + {1.05240e-01, 4.24440e-09, 1.76098e-16, 7.50693e-24}, + {1.32588e-01, 5.34735e-09, 2.21859e-16, 9.45769e-24}, + {1.67016e-01, 6.73589e-09, 2.79469e-16, 1.19135e-23}, + {2.10360e-01, 8.48395e-09, 3.51995e-16, 1.50053e-23}, + {2.71887e-01, 1.09654e-08, 4.54949e-16, 1.93941e-23}, + {3.55694e-01, 1.43454e-08, 5.95184e-16, 2.53722e-23}, + {4.84932e-01, 1.95577e-08, 8.11439e-16, 3.45910e-23}, + {6.99767e-01, 2.82221e-08, 1.17092e-15, 4.99155e-23}, + {1.05860e+00, 4.26939e-08, 1.77135e-15, 7.55113e-23}, + {1.62902e+00, 6.56994e-08, 2.72584e-15, 1.16200e-22}, + {2.54260e+00, 1.02545e-07, 4.25454e-15, 1.81368e-22}, + {3.96488e+00, 1.59906e-07, 6.63444e-15, 2.82821e-22}, + {6.10630e+00, 2.46271e-07, 1.02177e-14, 4.35572e-22}, + {9.28766e+00, 3.74578e-07, 1.55411e-14, 6.62503e-22}, + {1.39265e+01, 5.61664e-07, 2.33032e-14, 9.93397e-22}, + {2.05382e+01, 8.28321e-07, 3.43667e-14, 1.46502e-21}, + {3.00649e+01, 1.21254e-06, 5.03077e-14, 2.14458e-21}, + {4.55102e+01, 1.83546e-06, 7.61523e-14, 3.24631e-21}, + {7.47839e+01, 3.01609e-06, 1.25136e-13, 5.33445e-21}, + {1.29621e+02, 5.22769e-06, 2.16895e-13, 9.24605e-21}, + {2.14820e+02, 8.66384e-06, 3.59459e-13, 1.53234e-20}, + {3.20002e+02, 1.29059e-05, 5.35460e-13, 2.28262e-20}, + {4.29768e+02, 1.73329e-05, 7.19133e-13, 3.06560e-20}, + {5.30827e+02, 2.14086e-05, 8.88234e-13, 3.78647e-20}, + {5.99694e+02, 2.41861e-05, 1.00347e-12, 4.27771e-20}, + {6.06537e+02, 2.44620e-05, 1.01492e-12, 4.32652e-20}, + {5.43262e+02, 2.19101e-05, 9.09042e-13, 3.87517e-20}, + {4.33545e+02, 1.74852e-05, 7.25453e-13, 3.09255e-20}, + {3.13324e+02, 1.26366e-05, 5.24285e-13, 2.23499e-20}, + {2.09006e+02, 8.42935e-06, 3.49730e-13, 1.49087e-20}, + {1.31150e+02, 5.28937e-06, 2.19454e-13, 9.35513e-21}, + {7.90681e+01, 3.18887e-06, 1.32305e-13, 5.64006e-21}, + {4.73389e+01, 1.90921e-06, 7.92124e-14, 3.37676e-21}, + {2.96409e+01, 1.19544e-06, 4.95982e-14, 2.11433e-21}, + {2.04708e+01, 8.25601e-07, 3.42539e-14, 1.46021e-21}, + } + }, + { + /* name = */ "Mg2SiO4_dust", + /* nonprimoridal_yield_frac = */ 2.06081e-16, + /* size_moments = */ {4.03307e-08, 1.67330e-15, 7.13316e-23}, + /* opacity_coef_table = */ { + {2.19890e-02, 8.86503e-10, 3.67618e-17, 1.56604e-24}, + {3.90612e-02, 1.57478e-09, 6.53036e-17, 2.78190e-24}, + {6.05539e-02, 2.44128e-09, 1.01236e-16, 4.31259e-24}, + {8.76116e-02, 3.53213e-09, 1.46471e-16, 6.23961e-24}, + {1.43288e-01, 5.77674e-09, 2.39552e-16, 1.02048e-23}, + {2.19266e-01, 8.83988e-09, 3.66575e-16, 1.56159e-23}, + {3.36256e-01, 1.35564e-08, 5.62160e-16, 2.39478e-23}, + {5.14336e-01, 2.07358e-08, 8.59879e-16, 3.66305e-23}, + {7.97216e-01, 3.21404e-08, 1.33281e-15, 5.67770e-23}, + {1.25414e+00, 5.05616e-08, 2.09670e-15, 8.93186e-23}, + {2.03450e+00, 8.20224e-08, 3.40133e-15, 1.44895e-22}, + {3.34648e+00, 1.34916e-07, 5.59472e-15, 2.38333e-22}, + {5.45893e+00, 2.20081e-07, 9.12638e-15, 3.88780e-22}, + {8.82117e+00, 3.55632e-07, 1.47474e-14, 6.28235e-22}, + {1.41825e+01, 5.71778e-07, 2.37106e-14, 1.01006e-21}, + {2.28419e+01, 9.20889e-07, 3.81877e-14, 1.62678e-21}, + {3.71178e+01, 1.49643e-06, 6.20544e-14, 2.64349e-21}, + {6.14272e+01, 2.47648e-06, 1.02696e-13, 4.37479e-21}, + {1.03847e+02, 4.18665e-06, 1.73613e-13, 7.39586e-21}, + {1.75507e+02, 7.07567e-06, 2.93416e-13, 1.24994e-20}, + {2.82060e+02, 1.13715e-05, 4.71555e-13, 2.00880e-20}, + {4.14519e+02, 1.67116e-05, 6.93003e-13, 2.95216e-20}, + {5.59961e+02, 2.25752e-05, 9.36157e-13, 3.98799e-20}, + {7.11024e+02, 2.86655e-05, 1.18871e-12, 5.06385e-20}, + {8.40805e+02, 3.38977e-05, 1.40568e-12, 5.98813e-20}, + {8.95312e+02, 3.60952e-05, 1.49681e-12, 6.37633e-20}, + {8.40415e+02, 3.38819e-05, 1.40503e-12, 5.98535e-20}, + {6.96693e+02, 2.80877e-05, 1.16475e-12, 4.96178e-20}, + {5.18202e+02, 2.08917e-05, 8.66344e-13, 3.69059e-20}, + {3.52864e+02, 1.42260e-05, 5.89927e-13, 2.51306e-20}, + {2.24210e+02, 9.03919e-06, 3.74840e-13, 1.59680e-20}, + {1.35138e+02, 5.44818e-06, 2.25927e-13, 9.62439e-21}, + {7.83119e+01, 3.15720e-06, 1.30924e-13, 5.57730e-21}, + {4.41553e+01, 1.78015e-06, 7.38199e-14, 3.14470e-21}, + {2.45888e+01, 9.91317e-07, 4.11082e-14, 1.75119e-21}, + } + }, + { + /* name = */ "MgSiO3_dust", + /* nonprimoridal_yield_frac = */ 3.19262e-15, + /* size_moments = */ {4.03157e-08, 1.67182e-15, 7.12190e-23}, + /* opacity_coef_table = */ { + {1.47700e-02, 5.95693e-10, 2.47155e-17, 1.05363e-24}, + {2.47694e-02, 9.98982e-10, 4.14481e-17, 1.76695e-24}, + {3.73580e-02, 1.50669e-09, 6.25133e-17, 2.66496e-24}, + {5.32060e-02, 2.14587e-09, 8.90327e-17, 3.79549e-24}, + {8.50036e-02, 3.42830e-09, 1.42241e-16, 6.06380e-24}, + {1.29213e-01, 5.21132e-09, 2.16220e-16, 9.21750e-24}, + {2.00170e-01, 8.07309e-09, 3.34956e-16, 1.42793e-23}, + {3.15560e-01, 1.27269e-08, 5.28045e-16, 2.25107e-23}, + {5.01384e-01, 2.02214e-08, 8.38995e-16, 3.57666e-23}, + {7.88907e-01, 3.18176e-08, 1.32012e-15, 5.62773e-23}, + {1.24250e+00, 5.01116e-08, 2.07915e-15, 8.86347e-23}, + {1.95225e+00, 7.87365e-08, 3.26681e-15, 1.39265e-22}, + {3.04002e+00, 1.22608e-07, 5.08704e-15, 2.16862e-22}, + {4.68918e+00, 1.89120e-07, 7.84668e-15, 3.34506e-22}, + {7.12599e+00, 2.87400e-07, 1.19243e-14, 5.08338e-22}, + {1.05834e+01, 4.26842e-07, 1.77098e-14, 7.54974e-22}, + {1.52356e+01, 6.14471e-07, 2.54946e-14, 1.08684e-21}, + {2.13345e+01, 8.60449e-07, 3.57003e-14, 1.52192e-21}, + {2.98061e+01, 1.20212e-06, 4.98762e-14, 2.12624e-21}, + {4.27642e+01, 1.72473e-06, 7.15598e-14, 3.05062e-21}, + {6.30370e+01, 2.54236e-06, 1.05483e-13, 4.49679e-21}, + {9.29361e+01, 3.74823e-06, 1.55515e-13, 6.62967e-21}, + {1.32987e+02, 5.36353e-06, 2.22535e-13, 9.48673e-21}, + {1.82150e+02, 7.34635e-06, 3.04803e-13, 1.29938e-20}, + {2.40388e+02, 9.69513e-06, 4.02254e-13, 1.71482e-20}, + {3.12065e+02, 1.25860e-05, 5.22197e-13, 2.22614e-20}, + {4.08414e+02, 1.64718e-05, 6.83423e-13, 2.91345e-20}, + {5.49591e+02, 2.21657e-05, 9.19662e-13, 3.92055e-20}, + {7.67451e+02, 3.09523e-05, 1.28422e-12, 5.47467e-20}, + {1.10725e+03, 4.46570e-05, 1.85283e-12, 7.89869e-20}, + {1.62060e+03, 6.53608e-05, 2.71184e-12, 1.15607e-19}, + {2.33999e+03, 9.43747e-05, 3.91564e-12, 1.66925e-19}, + {3.24367e+03, 1.30821e-04, 5.42783e-12, 2.31390e-19}, + {4.25716e+03, 1.71697e-04, 7.12376e-12, 3.03688e-19}, + {5.34010e+03, 2.15373e-04, 8.93591e-12, 3.80941e-19}, + } + }, + { + /* name = */ "Fe3O4_dust", + /* nonprimoridal_yield_frac = */ 4.37192e-15, + /* size_moments = */ {4.03312e-08, 1.67336e-15, 7.13357e-23}, + /* opacity_coef_table = */ { + {3.27960e-01, 2.16737e-06, 1.80151e-11, 1.72491e-16}, + {4.38754e-01, 2.89959e-06, 2.41015e-11, 2.30770e-16}, + {5.78235e-01, 3.82140e-06, 3.17638e-11, 3.04139e-16}, + {7.53832e-01, 4.98189e-06, 4.14101e-11, 3.96504e-16}, + {1.04018e+00, 6.87442e-06, 5.71418e-11, 5.47146e-16}, + {1.41746e+00, 9.36786e-06, 7.78688e-11, 7.45623e-16}, + {1.95306e+00, 1.29077e-05, 1.07295e-10, 1.02741e-15}, + {2.71551e+00, 1.79470e-05, 1.49187e-10, 1.42858e-15}, + {3.79717e+00, 2.50964e-05, 2.08623e-10, 1.99781e-15}, + {5.29825e+00, 3.50184e-05, 2.91115e-10, 2.78791e-15}, + {7.37979e+00, 4.87780e-05, 4.05522e-10, 3.88380e-15}, + {1.02197e+01, 6.75525e-05, 5.61646e-10, 5.37953e-15}, + {1.40472e+01, 9.28592e-05, 7.72124e-10, 7.39643e-15}, + {1.92121e+01, 1.27015e-04, 1.05627e-09, 1.01201e-14}, + {2.61803e+01, 1.73108e-04, 1.43985e-09, 1.37985e-14}, + {3.55654e+01, 2.35211e-04, 1.95692e-09, 1.87600e-14}, + {4.82268e+01, 3.19039e-04, 2.65535e-09, 2.54677e-14}, + {6.54410e+01, 4.33093e-04, 3.60654e-09, 3.46142e-14}, + {8.90033e+01, 5.89369e-04, 4.91159e-09, 4.71850e-14}, + {1.21154e+02, 8.02913e-04, 6.69826e-09, 6.44364e-14}, + {1.64484e+02, 1.09135e-03, 9.11847e-09, 8.78899e-14}, + {2.22227e+02, 1.47698e-03, 1.23680e-08, 1.19551e-13}, + {2.99250e+02, 1.99360e-03, 1.67456e-08, 1.62501e-13}, + {4.02841e+02, 2.69134e-03, 2.26888e-08, 2.21192e-13}, + {5.41754e+02, 3.62947e-03, 3.07031e-08, 3.00611e-13}, + {7.24111e+02, 4.86183e-03, 4.12300e-08, 4.04886e-13}, + {9.58822e+02, 6.44664e-03, 5.47294e-08, 5.38055e-13}, + {1.26198e+03, 8.49034e-03, 7.20550e-08, 7.07781e-13}, + {1.66376e+03, 1.11958e-02, 9.48672e-08, 9.29402e-13}, + {2.21388e+03, 1.49013e-02, 1.25959e-07, 1.22898e-12}, + {2.99023e+03, 2.01435e-02, 1.69784e-07, 1.64820e-12}, + {4.11644e+03, 2.77858e-02, 2.33536e-07, 2.25436e-12}, + {5.78855e+03, 3.92074e-02, 3.28708e-07, 3.15462e-12}, + {8.29050e+03, 5.63946e-02, 4.71738e-07, 4.50079e-12}, + {1.19408e+04, 8.14776e-02, 6.79738e-07, 6.44637e-12}, + } + }, + { + /* name = */ "AC_dust", + /* nonprimoridal_yield_frac = */ 1.75542e-01, + /* size_moments = */ {6.60867e-06, 5.49310e-11, 5.25955e-16}, + /* opacity_coef_table = */ { + {7.60360e-02, 3.06536e-09, 1.27110e-16, 5.41456e-24}, + {9.07207e-02, 3.65737e-09, 1.51659e-16, 6.46027e-24}, + {1.09208e-01, 4.40266e-09, 1.82564e-16, 7.77673e-24}, + {1.32481e-01, 5.34093e-09, 2.21471e-16, 9.43407e-24}, + {1.58907e-01, 6.40629e-09, 2.65648e-16, 1.13159e-23}, + {1.91565e-01, 7.72285e-09, 3.20241e-16, 1.36414e-23}, + {2.30490e-01, 9.29212e-09, 3.85313e-16, 1.64133e-23}, + {2.76795e-01, 1.11589e-08, 4.62722e-16, 1.97107e-23}, + {3.33074e-01, 1.34277e-08, 5.56804e-16, 2.37184e-23}, + {4.05325e-01, 1.63405e-08, 6.77586e-16, 2.88634e-23}, + {5.08160e-01, 2.04863e-08, 8.49498e-16, 3.61863e-23}, + {6.72472e-01, 2.71105e-08, 1.12418e-15, 4.78871e-23}, + {9.48549e-01, 3.82404e-08, 1.58570e-15, 6.75467e-23}, + {1.41787e+00, 5.71610e-08, 2.37028e-15, 1.00968e-22}, + {2.19502e+00, 8.84912e-08, 3.66944e-15, 1.56308e-22}, + {3.46719e+00, 1.39778e-07, 5.79615e-15, 2.46901e-22}, + {5.76852e+00, 2.32556e-07, 9.64331e-15, 4.10780e-22}, + {1.17194e+01, 4.72463e-07, 1.95915e-14, 8.34544e-22}, + {3.16449e+01, 1.27575e-06, 5.29012e-14, 2.25345e-21}, + {8.68296e+01, 3.50050e-06, 1.45154e-13, 6.18318e-21}, + {1.92300e+02, 7.75250e-06, 3.21470e-13, 1.36938e-20}, + {3.36231e+02, 1.35550e-05, 5.62081e-13, 2.39432e-20}, + {5.05825e+02, 2.03921e-05, 8.45594e-13, 3.60201e-20}, + {7.20624e+02, 2.90517e-05, 1.20468e-12, 5.13160e-20}, + {9.77376e+02, 3.94025e-05, 1.63389e-12, 6.95995e-20}, + {1.18646e+03, 4.78315e-05, 1.98341e-12, 8.44881e-20}, + {1.23845e+03, 4.99275e-05, 2.07033e-12, 8.81904e-20}, + {1.11188e+03, 4.48251e-05, 1.85875e-12, 7.91777e-20}, + {8.76396e+02, 3.53316e-05, 1.46508e-12, 6.24086e-20}, + {6.22207e+02, 2.50840e-05, 1.04015e-12, 4.43077e-20}, + {4.07290e+02, 1.64197e-05, 6.80872e-13, 2.90033e-20}, + {2.50573e+02, 1.01017e-05, 4.18886e-13, 1.78434e-20}, + {1.47073e+02, 5.92921e-06, 2.45865e-13, 1.04732e-20}, + {8.33122e+01, 3.35870e-06, 1.39274e-13, 5.93271e-21}, + {4.59585e+01, 1.85280e-06, 7.68295e-14, 3.27273e-21}, + } + }, + { + /* name = */ "SiO2_dust", + /* nonprimoridal_yield_frac = */ 1.92019e-16, + /* size_moments = */ {4.03146e-08, 1.67171e-15, 7.12105e-23}, + /* opacity_coef_table = */ { + {9.93250e-04, 4.00425e-11, 1.66043e-18, 7.07299e-26}, + {1.81240e-03, 7.30662e-11, 3.02981e-18, 1.29062e-25}, + {2.84365e-03, 1.14641e-10, 4.75376e-18, 2.02498e-25}, + {4.14191e-03, 1.66980e-10, 6.92409e-18, 2.94948e-25}, + {7.18271e-03, 2.89568e-10, 1.20074e-17, 5.11485e-25}, + {1.13364e-02, 4.57021e-10, 1.89512e-17, 8.07269e-25}, + {1.77361e-02, 7.15022e-10, 2.96496e-17, 1.26300e-24}, + {2.59477e-02, 1.04607e-09, 4.33772e-17, 1.84775e-24}, + {3.45425e-02, 1.39257e-09, 5.77452e-17, 2.45979e-24}, + {4.22006e-02, 1.70130e-09, 7.05474e-17, 3.00513e-24}, + {4.71420e-02, 1.90051e-09, 7.88079e-17, 3.35701e-24}, + {4.91934e-02, 1.98321e-09, 8.22373e-17, 3.50309e-24}, + {5.05162e-02, 2.03654e-09, 8.44486e-17, 3.59729e-24}, + {5.78201e-02, 2.33100e-09, 9.66587e-17, 4.11740e-24}, + {8.84237e-02, 3.56477e-09, 1.47819e-16, 6.29670e-24}, + {1.78786e-01, 7.20769e-09, 2.98879e-16, 1.27315e-23}, + {4.36404e-01, 1.75935e-08, 7.29542e-16, 3.10766e-23}, + {1.63796e+00, 6.60337e-08, 2.73820e-15, 1.16640e-22}, + {8.50817e+00, 3.43004e-07, 1.42232e-14, 6.05872e-22}, + {3.92751e+01, 1.58336e-06, 6.56567e-14, 2.79680e-21}, + {1.41436e+02, 5.70194e-06, 2.36441e-13, 1.00718e-20}, + {3.83709e+02, 1.54691e-05, 6.41451e-13, 2.73241e-20}, + {7.70411e+02, 3.10588e-05, 1.28791e-12, 5.48614e-20}, + {1.16399e+03, 4.69258e-05, 1.94586e-12, 8.28883e-20}, + {1.37566e+03, 5.54594e-05, 2.29972e-12, 9.79619e-20}, + {1.33070e+03, 5.36466e-05, 2.22455e-12, 9.47599e-20}, + {1.09978e+03, 4.43371e-05, 1.83851e-12, 7.83159e-20}, + {8.05638e+02, 3.24790e-05, 1.34680e-12, 5.73700e-20}, + {5.38690e+02, 2.17171e-05, 9.00535e-13, 3.83604e-20}, + {3.36338e+02, 1.35593e-05, 5.62261e-13, 2.39508e-20}, + {1.99460e+02, 8.04115e-06, 3.33440e-13, 1.42037e-20}, + {1.13787e+02, 4.58728e-06, 1.90220e-13, 8.10285e-21}, + {6.30411e+01, 2.54148e-06, 1.05387e-13, 4.48919e-21}, + {3.41529e+01, 1.37686e-06, 5.70939e-14, 2.43205e-21}, + {1.81893e+01, 7.33293e-07, 3.04073e-14, 1.29527e-21}, + } + }, + { + /* name = */ "Al2O3_dust", + /* nonprimoridal_yield_frac = */ 6.23283e-17, + /* size_moments = */ {4.03146e-08, 1.67171e-15, 7.12106e-23}, + /* opacity_coef_table = */ { + {1.23621e-05, 4.98941e-13, 2.07173e-20, 8.83710e-28}, + {2.19539e-05, 8.86065e-13, 3.67916e-20, 1.56937e-27}, + {3.40291e-05, 1.37342e-12, 5.70280e-20, 2.43256e-27}, + {4.92310e-05, 1.98698e-12, 8.25041e-20, 3.51925e-27}, + {8.08514e-05, 3.26317e-12, 1.35494e-19, 5.77953e-27}, + {1.25020e-04, 5.04574e-12, 2.09508e-19, 8.93651e-27}, + {1.96586e-04, 7.93387e-12, 3.29418e-19, 1.40509e-26}, + {3.14491e-04, 1.26917e-11, 5.26937e-19, 2.24747e-26}, + {5.06850e-04, 2.04532e-11, 8.49130e-19, 3.62146e-26}, + {8.07286e-04, 3.25749e-11, 1.35229e-18, 5.76710e-26}, + {1.28668e-03, 5.19155e-11, 2.15506e-18, 9.19009e-26}, + {2.05241e-03, 8.28056e-11, 3.43709e-18, 1.46562e-25}, + {3.27026e-03, 1.31928e-10, 5.47555e-18, 2.33466e-25}, + {5.23898e-03, 2.11325e-10, 8.76988e-18, 3.73889e-25}, + {8.45023e-03, 3.40811e-10, 1.41417e-17, 6.02834e-25}, + {1.37158e-02, 5.53101e-10, 2.29473e-17, 9.78076e-25}, + {2.24100e-02, 9.03572e-10, 3.74827e-17, 1.59741e-24}, + {3.70042e-02, 1.49181e-09, 6.18765e-17, 2.63669e-24}, + {6.21585e-02, 2.50559e-09, 1.03913e-16, 4.42746e-24}, + {1.07033e-01, 4.31400e-09, 1.78894e-16, 7.62148e-24}, + {1.90089e-01, 7.66095e-09, 3.17659e-16, 1.35323e-23}, + {3.49470e-01, 1.40834e-08, 5.83928e-16, 2.48739e-23}, + {6.64947e-01, 2.67957e-08, 1.11096e-15, 4.73220e-23}, + {1.30413e+00, 5.25515e-08, 2.17873e-15, 9.28021e-23}, + {2.61640e+00, 1.05429e-07, 4.37088e-15, 1.86172e-22}, + {5.31791e+00, 2.14284e-07, 8.88372e-15, 3.78386e-22}, + {1.08366e+01, 4.36654e-07, 1.81025e-14, 7.71039e-22}, + {2.19132e+01, 8.82975e-07, 3.66056e-14, 1.55913e-21}, + {4.35354e+01, 1.75422e-06, 7.27247e-14, 3.09753e-21}, + {8.42362e+01, 3.39422e-06, 1.40714e-13, 5.99335e-21}, + {1.57704e+02, 6.35452e-06, 2.63439e-13, 1.12205e-20}, + {2.84822e+02, 1.14766e-05, 4.75784e-13, 2.02648e-20}, + {4.96653e+02, 2.00121e-05, 8.29639e-13, 3.53363e-20}, + {8.39966e+02, 3.38455e-05, 1.40313e-12, 5.97626e-20}, + {1.38932e+03, 5.59813e-05, 2.32081e-12, 9.88487e-20}, + } + }, +}; + +} // namespace fsn13 + +namespace fsn15 { +static const MetalNuclideYieldProps metal_props[] = { + // {name, gas_yield, total_yield} + {"C", 4.57071e-01, 6.46299e-01}, + {"O", 3.53548e-01, 3.53548e-01}, + {"Mg", 1.29204e-04, 1.29204e-04}, + {"Al", 2.22729e-07, 2.22729e-07}, + {"Si", 1.32242e-05, 1.32242e-05}, + {"S", 0.00000e+00, 0.00000e+00}, + {"Fe", 9.66658e-06, 9.66658e-06}, +}; + +static const GrainSpeciesYieldProps grain_props[] = { + { + /* name = */ "FeM_dust", + /* nonprimoridal_yield_frac = */ 1.53361e-25, + /* size_moments = */ {4.02634e-08, 1.66860e-15, 7.10566e-23}, + /* opacity_coef_table = */ { + {1.05240e-01, 4.24452e-09, 1.76110e-16, 7.50779e-24}, + {1.32588e-01, 5.34750e-09, 2.21874e-16, 9.45877e-24}, + {1.67016e-01, 6.73607e-09, 2.79487e-16, 1.19149e-23}, + {2.10360e-01, 8.48418e-09, 3.52018e-16, 1.50070e-23}, + {2.71887e-01, 1.09657e-08, 4.54979e-16, 1.93963e-23}, + {3.55694e-01, 1.43458e-08, 5.95222e-16, 2.53751e-23}, + {4.84932e-01, 1.95582e-08, 8.11491e-16, 3.45949e-23}, + {6.99767e-01, 2.82229e-08, 1.17100e-15, 4.99212e-23}, + {1.05860e+00, 4.26950e-08, 1.77146e-15, 7.55199e-23}, + {1.62902e+00, 6.57012e-08, 2.72602e-15, 1.16214e-22}, + {2.54260e+00, 1.02548e-07, 4.25481e-15, 1.81388e-22}, + {3.96488e+00, 1.59911e-07, 6.63487e-15, 2.82853e-22}, + {6.10630e+00, 2.46278e-07, 1.02183e-14, 4.35621e-22}, + {9.28766e+00, 3.74588e-07, 1.55421e-14, 6.62579e-22}, + {1.39265e+01, 5.61679e-07, 2.33047e-14, 9.93510e-22}, + {2.05382e+01, 8.28344e-07, 3.43689e-14, 1.46519e-21}, + {3.00649e+01, 1.21257e-06, 5.03110e-14, 2.14482e-21}, + {4.55102e+01, 1.83551e-06, 7.61572e-14, 3.24668e-21}, + {7.47839e+01, 3.01617e-06, 1.25144e-13, 5.33506e-21}, + {1.29621e+02, 5.22783e-06, 2.16909e-13, 9.24710e-21}, + {2.14820e+02, 8.66407e-06, 3.59482e-13, 1.53252e-20}, + {3.20002e+02, 1.29062e-05, 5.35494e-13, 2.28288e-20}, + {4.29768e+02, 1.73333e-05, 7.19179e-13, 3.06596e-20}, + {5.30827e+02, 2.14092e-05, 8.88291e-13, 3.78690e-20}, + {5.99694e+02, 2.41867e-05, 1.00353e-12, 4.27820e-20}, + {6.06537e+02, 2.44627e-05, 1.01498e-12, 4.32701e-20}, + {5.43262e+02, 2.19107e-05, 9.09100e-13, 3.87561e-20}, + {4.33545e+02, 1.74857e-05, 7.25499e-13, 3.09290e-20}, + {3.13324e+02, 1.26369e-05, 5.24319e-13, 2.23524e-20}, + {2.09006e+02, 8.42958e-06, 3.49753e-13, 1.49104e-20}, + {1.31150e+02, 5.28951e-06, 2.19468e-13, 9.35620e-21}, + {7.90681e+01, 3.18896e-06, 1.32313e-13, 5.64070e-21}, + {4.73389e+01, 1.90926e-06, 7.92175e-14, 3.37715e-21}, + {2.96409e+01, 1.19547e-06, 4.96014e-14, 2.11457e-21}, + {2.04708e+01, 8.25623e-07, 3.42560e-14, 1.46038e-21}, + } + }, + { + /* name = */ "Mg2SiO4_dust", + /* nonprimoridal_yield_frac = */ 1.56864e-15, + /* size_moments = */ {4.03318e-08, 1.67341e-15, 7.13397e-23}, + /* opacity_coef_table = */ { + {2.19890e-02, 8.86506e-10, 3.67621e-17, 1.56606e-24}, + {3.90612e-02, 1.57479e-09, 6.53041e-17, 2.78195e-24}, + {6.05539e-02, 2.44129e-09, 1.01236e-16, 4.31266e-24}, + {8.76116e-02, 3.53214e-09, 1.46473e-16, 6.23971e-24}, + {1.43288e-01, 5.77677e-09, 2.39554e-16, 1.02050e-23}, + {2.19266e-01, 8.83991e-09, 3.66578e-16, 1.56162e-23}, + {3.36256e-01, 1.35564e-08, 5.62165e-16, 2.39482e-23}, + {5.14336e-01, 2.07359e-08, 8.59887e-16, 3.66311e-23}, + {7.97216e-01, 3.21405e-08, 1.33282e-15, 5.67779e-23}, + {1.25414e+00, 5.05618e-08, 2.09672e-15, 8.93200e-23}, + {2.03450e+00, 8.20227e-08, 3.40136e-15, 1.44897e-22}, + {3.34648e+00, 1.34916e-07, 5.59477e-15, 2.38337e-22}, + {5.45893e+00, 2.20082e-07, 9.12646e-15, 3.88786e-22}, + {8.82117e+00, 3.55633e-07, 1.47476e-14, 6.28245e-22}, + {1.41825e+01, 5.71780e-07, 2.37109e-14, 1.01008e-21}, + {2.28419e+01, 9.20892e-07, 3.81880e-14, 1.62680e-21}, + {3.71178e+01, 1.49644e-06, 6.20550e-14, 2.64353e-21}, + {6.14272e+01, 2.47649e-06, 1.02696e-13, 4.37486e-21}, + {1.03847e+02, 4.18667e-06, 1.73615e-13, 7.39597e-21}, + {1.75507e+02, 7.07570e-06, 2.93419e-13, 1.24996e-20}, + {2.82060e+02, 1.13715e-05, 4.71559e-13, 2.00884e-20}, + {4.14519e+02, 1.67117e-05, 6.93009e-13, 2.95221e-20}, + {5.59961e+02, 2.25753e-05, 9.36165e-13, 3.98805e-20}, + {7.11024e+02, 2.86656e-05, 1.18872e-12, 5.06393e-20}, + {8.40805e+02, 3.38978e-05, 1.40569e-12, 5.98823e-20}, + {8.95312e+02, 3.60953e-05, 1.49682e-12, 6.37643e-20}, + {8.40415e+02, 3.38821e-05, 1.40504e-12, 5.98544e-20}, + {6.96693e+02, 2.80878e-05, 1.16476e-12, 4.96186e-20}, + {5.18202e+02, 2.08918e-05, 8.66351e-13, 3.69065e-20}, + {3.52864e+02, 1.42260e-05, 5.89932e-13, 2.51310e-20}, + {2.24210e+02, 9.03922e-06, 3.74843e-13, 1.59683e-20}, + {1.35138e+02, 5.44820e-06, 2.25929e-13, 9.62454e-21}, + {7.83119e+01, 3.15721e-06, 1.30925e-13, 5.57739e-21}, + {4.41553e+01, 1.78016e-06, 7.38206e-14, 3.14475e-21}, + {2.45888e+01, 9.91321e-07, 4.11086e-14, 1.75122e-21}, + } + }, + { + /* name = */ "MgSiO3_dust", + /* nonprimoridal_yield_frac = */ 2.13810e-14, + /* size_moments = */ {4.03159e-08, 1.67184e-15, 7.12201e-23}, + /* opacity_coef_table = */ { + {1.47700e-02, 5.95675e-10, 2.47138e-17, 1.05350e-24}, + {2.47694e-02, 9.98953e-10, 4.14453e-17, 1.76673e-24}, + {3.73580e-02, 1.50665e-09, 6.25090e-17, 2.66463e-24}, + {5.32060e-02, 2.14580e-09, 8.90266e-17, 3.79502e-24}, + {8.50036e-02, 3.42820e-09, 1.42232e-16, 6.06304e-24}, + {1.29213e-01, 5.21117e-09, 2.16205e-16, 9.21636e-24}, + {2.00170e-01, 8.07286e-09, 3.34932e-16, 1.42775e-23}, + {3.15560e-01, 1.27266e-08, 5.28008e-16, 2.25079e-23}, + {5.01384e-01, 2.02209e-08, 8.38937e-16, 3.57622e-23}, + {7.88907e-01, 3.18167e-08, 1.32003e-15, 5.62703e-23}, + {1.24250e+00, 5.01101e-08, 2.07900e-15, 8.86237e-23}, + {1.95225e+00, 7.87342e-08, 3.26658e-15, 1.39248e-22}, + {3.04002e+00, 1.22604e-07, 5.08669e-15, 2.16835e-22}, + {4.68918e+00, 1.89115e-07, 7.84613e-15, 3.34465e-22}, + {7.12599e+00, 2.87392e-07, 1.19235e-14, 5.08275e-22}, + {1.05834e+01, 4.26829e-07, 1.77086e-14, 7.54881e-22}, + {1.52356e+01, 6.14453e-07, 2.54928e-14, 1.08671e-21}, + {2.13345e+01, 8.60424e-07, 3.56978e-14, 1.52173e-21}, + {2.98061e+01, 1.20208e-06, 4.98728e-14, 2.12597e-21}, + {4.27642e+01, 1.72468e-06, 7.15548e-14, 3.05024e-21}, + {6.30370e+01, 2.54229e-06, 1.05476e-13, 4.49623e-21}, + {9.29361e+01, 3.74812e-06, 1.55505e-13, 6.62884e-21}, + {1.32987e+02, 5.36337e-06, 2.22519e-13, 9.48555e-21}, + {1.82150e+02, 7.34614e-06, 3.04782e-13, 1.29922e-20}, + {2.40388e+02, 9.69485e-06, 4.02226e-13, 1.71461e-20}, + {3.12065e+02, 1.25856e-05, 5.22160e-13, 2.22586e-20}, + {4.08414e+02, 1.64714e-05, 6.83375e-13, 2.91309e-20}, + {5.49591e+02, 2.21650e-05, 9.19598e-13, 3.92006e-20}, + {7.67451e+02, 3.09514e-05, 1.28413e-12, 5.47399e-20}, + {1.10725e+03, 4.46557e-05, 1.85271e-12, 7.89771e-20}, + {1.62060e+03, 6.53589e-05, 2.71166e-12, 1.15592e-19}, + {2.33999e+03, 9.43719e-05, 3.91537e-12, 1.66904e-19}, + {3.24367e+03, 1.30818e-04, 5.42745e-12, 2.31361e-19}, + {4.25716e+03, 1.71692e-04, 7.12327e-12, 3.03651e-19}, + {5.34010e+03, 2.15367e-04, 8.93529e-12, 3.80893e-19}, + } + }, + { + /* name = */ "Fe3O4_dust", + /* nonprimoridal_yield_frac = */ 1.22287e-14, + /* size_moments = */ {4.03301e-08, 1.67324e-15, 7.13269e-23}, + /* opacity_coef_table = */ { + {3.27956e-01, 3.75639e-06, 5.26403e-11, 8.37270e-16}, + {4.38770e-01, 5.02579e-06, 7.04309e-11, 1.12026e-15}, + {5.78277e-01, 6.62387e-06, 9.28278e-11, 1.47653e-15}, + {7.53906e-01, 8.63573e-06, 1.21024e-10, 1.92505e-15}, + {1.04036e+00, 1.19174e-05, 1.67020e-10, 2.65676e-15}, + {1.41778e+00, 1.62414e-05, 2.27626e-10, 3.62091e-15}, + {1.95366e+00, 2.23811e-05, 3.13688e-10, 4.99012e-15}, + {2.71664e+00, 3.11237e-05, 4.36248e-10, 6.94018e-15}, + {3.79935e+00, 4.35320e-05, 6.10219e-10, 9.70860e-15}, + {5.30234e+00, 6.07596e-05, 8.51798e-10, 1.35534e-14}, + {7.38743e+00, 8.46654e-05, 1.18710e-09, 1.88910e-14}, + {1.02340e+01, 1.17314e-04, 1.64516e-09, 2.61851e-14}, + {1.40739e+01, 1.61376e-04, 2.26365e-09, 3.60378e-14}, + {1.92619e+01, 2.20951e-04, 3.10040e-09, 4.93757e-14}, + {2.62735e+01, 3.01546e-04, 4.23341e-09, 6.74511e-14}, + {3.57407e+01, 4.10519e-04, 5.76727e-09, 9.19507e-14}, + {4.85587e+01, 5.58361e-04, 7.85200e-09, 1.25306e-13}, + {6.60737e+01, 7.60948e-04, 1.07159e-08, 1.71237e-13}, + {9.02145e+01, 1.04125e-03, 1.46920e-08, 2.35213e-13}, + {1.23479e+02, 1.42959e-03, 2.02271e-08, 3.24675e-13}, + {1.68976e+02, 1.96503e-03, 2.79128e-08, 4.49723e-13}, + {2.30962e+02, 2.70317e-03, 3.86182e-08, 6.25581e-13}, + {3.16043e+02, 3.73154e-03, 5.37252e-08, 8.76701e-13}, + {4.33583e+02, 5.17180e-03, 7.51313e-08, 1.23638e-12}, + {5.93567e+02, 7.14700e-03, 1.04677e-07, 1.73582e-12}, + {8.03334e+02, 9.73553e-03, 1.43375e-07, 2.38969e-12}, + {1.06890e+03, 1.29850e-02, 1.91575e-07, 3.19823e-12}, + {1.40232e+03, 1.70036e-02, 2.50333e-07, 4.17041e-12}, + {1.82952e+03, 2.20557e-02, 3.22829e-07, 5.34792e-12}, + {2.39537e+03, 2.86193e-02, 4.15124e-07, 6.81663e-12}, + {3.17137e+03, 3.74648e-02, 5.37088e-07, 8.71845e-12}, + {4.27121e+03, 4.98190e-02, 7.04376e-07, 1.12776e-11}, + {5.87303e+03, 6.75884e-02, 9.40996e-07, 1.48329e-11}, + {8.22455e+03, 9.33574e-02, 1.27863e-06, 1.98186e-11}, + {1.15719e+04, 1.29494e-01, 1.74429e-06, 2.65764e-11}, + } + }, + { + /* name = */ "AC_dust", + /* nonprimoridal_yield_frac = */ 1.89229e-01, + /* size_moments = */ {1.14540e-05, 1.60512e-10, 2.55303e-15}, + /* opacity_coef_table = */ { + {7.60360e-02, 3.06536e-09, 1.27110e-16, 5.41456e-24}, + {9.07207e-02, 3.65737e-09, 1.51659e-16, 6.46027e-24}, + {1.09208e-01, 4.40266e-09, 1.82564e-16, 7.77673e-24}, + {1.32481e-01, 5.34093e-09, 2.21471e-16, 9.43407e-24}, + {1.58907e-01, 6.40629e-09, 2.65648e-16, 1.13159e-23}, + {1.91565e-01, 7.72285e-09, 3.20241e-16, 1.36414e-23}, + {2.30490e-01, 9.29212e-09, 3.85313e-16, 1.64133e-23}, + {2.76795e-01, 1.11589e-08, 4.62722e-16, 1.97107e-23}, + {3.33074e-01, 1.34277e-08, 5.56804e-16, 2.37184e-23}, + {4.05325e-01, 1.63405e-08, 6.77586e-16, 2.88634e-23}, + {5.08160e-01, 2.04863e-08, 8.49498e-16, 3.61864e-23}, + {6.72472e-01, 2.71105e-08, 1.12418e-15, 4.78871e-23}, + {9.48549e-01, 3.82404e-08, 1.58570e-15, 6.75467e-23}, + {1.41787e+00, 5.71610e-08, 2.37028e-15, 1.00968e-22}, + {2.19502e+00, 8.84912e-08, 3.66944e-15, 1.56308e-22}, + {3.46719e+00, 1.39778e-07, 5.79615e-15, 2.46901e-22}, + {5.76852e+00, 2.32556e-07, 9.64331e-15, 4.10780e-22}, + {1.17194e+01, 4.72463e-07, 1.95915e-14, 8.34544e-22}, + {3.16449e+01, 1.27575e-06, 5.29013e-14, 2.25345e-21}, + {8.68296e+01, 3.50050e-06, 1.45154e-13, 6.18318e-21}, + {1.92300e+02, 7.75250e-06, 3.21470e-13, 1.36938e-20}, + {3.36231e+02, 1.35550e-05, 5.62081e-13, 2.39432e-20}, + {5.05825e+02, 2.03921e-05, 8.45594e-13, 3.60201e-20}, + {7.20624e+02, 2.90517e-05, 1.20468e-12, 5.13160e-20}, + {9.77376e+02, 3.94025e-05, 1.63389e-12, 6.95995e-20}, + {1.18646e+03, 4.78315e-05, 1.98341e-12, 8.44881e-20}, + {1.23845e+03, 4.99275e-05, 2.07033e-12, 8.81904e-20}, + {1.11188e+03, 4.48251e-05, 1.85875e-12, 7.91777e-20}, + {8.76396e+02, 3.53316e-05, 1.46508e-12, 6.24086e-20}, + {6.22207e+02, 2.50840e-05, 1.04015e-12, 4.43077e-20}, + {4.07290e+02, 1.64197e-05, 6.80872e-13, 2.90033e-20}, + {2.50573e+02, 1.01017e-05, 4.18886e-13, 1.78434e-20}, + {1.47073e+02, 5.92921e-06, 2.45865e-13, 1.04732e-20}, + {8.33122e+01, 3.35870e-06, 1.39274e-13, 5.93271e-21}, + {4.59585e+01, 1.85280e-06, 7.68295e-14, 3.27273e-21}, + } + }, + { + /* name = */ "SiO2_dust", + /* nonprimoridal_yield_frac = */ 1.47463e-15, + /* size_moments = */ {4.03146e-08, 1.67171e-15, 7.12105e-23}, + /* opacity_coef_table = */ { + {9.93250e-04, 4.00425e-11, 1.66043e-18, 7.07299e-26}, + {1.81240e-03, 7.30662e-11, 3.02981e-18, 1.29062e-25}, + {2.84365e-03, 1.14641e-10, 4.75376e-18, 2.02498e-25}, + {4.14191e-03, 1.66980e-10, 6.92409e-18, 2.94948e-25}, + {7.18271e-03, 2.89568e-10, 1.20074e-17, 5.11485e-25}, + {1.13364e-02, 4.57021e-10, 1.89512e-17, 8.07269e-25}, + {1.77361e-02, 7.15022e-10, 2.96496e-17, 1.26300e-24}, + {2.59477e-02, 1.04607e-09, 4.33772e-17, 1.84775e-24}, + {3.45425e-02, 1.39257e-09, 5.77452e-17, 2.45979e-24}, + {4.22006e-02, 1.70130e-09, 7.05474e-17, 3.00513e-24}, + {4.71420e-02, 1.90051e-09, 7.88079e-17, 3.35701e-24}, + {4.91934e-02, 1.98321e-09, 8.22373e-17, 3.50309e-24}, + {5.05162e-02, 2.03654e-09, 8.44486e-17, 3.59729e-24}, + {5.78201e-02, 2.33100e-09, 9.66587e-17, 4.11741e-24}, + {8.84237e-02, 3.56477e-09, 1.47819e-16, 6.29670e-24}, + {1.78786e-01, 7.20769e-09, 2.98879e-16, 1.27315e-23}, + {4.36404e-01, 1.75935e-08, 7.29542e-16, 3.10766e-23}, + {1.63796e+00, 6.60337e-08, 2.73820e-15, 1.16640e-22}, + {8.50817e+00, 3.43004e-07, 1.42232e-14, 6.05872e-22}, + {3.92751e+01, 1.58336e-06, 6.56567e-14, 2.79680e-21}, + {1.41436e+02, 5.70194e-06, 2.36441e-13, 1.00718e-20}, + {3.83709e+02, 1.54691e-05, 6.41451e-13, 2.73241e-20}, + {7.70411e+02, 3.10588e-05, 1.28791e-12, 5.48614e-20}, + {1.16399e+03, 4.69258e-05, 1.94586e-12, 8.28883e-20}, + {1.37566e+03, 5.54594e-05, 2.29972e-12, 9.79619e-20}, + {1.33070e+03, 5.36466e-05, 2.22455e-12, 9.47599e-20}, + {1.09978e+03, 4.43371e-05, 1.83851e-12, 7.83159e-20}, + {8.05638e+02, 3.24790e-05, 1.34680e-12, 5.73700e-20}, + {5.38690e+02, 2.17171e-05, 9.00535e-13, 3.83604e-20}, + {3.36338e+02, 1.35593e-05, 5.62261e-13, 2.39508e-20}, + {1.99460e+02, 8.04115e-06, 3.33440e-13, 1.42037e-20}, + {1.13787e+02, 4.58728e-06, 1.90220e-13, 8.10285e-21}, + {6.30411e+01, 2.54148e-06, 1.05387e-13, 4.48919e-21}, + {3.41529e+01, 1.37686e-06, 5.70939e-14, 2.43205e-21}, + {1.81893e+01, 7.33293e-07, 3.04073e-14, 1.29527e-21}, + } + }, + { + /* name = */ "Al2O3_dust", + /* nonprimoridal_yield_frac = */ 2.15191e-16, + /* size_moments = */ {4.03146e-08, 1.67171e-15, 7.12106e-23}, + /* opacity_coef_table = */ { + {1.23614e-05, 4.98551e-13, 2.06942e-20, 8.82572e-28}, + {2.19525e-05, 8.85374e-13, 3.67505e-20, 1.56735e-27}, + {3.40270e-05, 1.37235e-12, 5.69643e-20, 2.42942e-27}, + {4.92280e-05, 1.98543e-12, 8.24119e-20, 3.51472e-27}, + {8.08465e-05, 3.26062e-12, 1.35343e-19, 5.77209e-27}, + {1.25012e-04, 5.04181e-12, 2.09274e-19, 8.92500e-27}, + {1.96574e-04, 7.92769e-12, 3.29050e-19, 1.40328e-26}, + {3.14473e-04, 1.26818e-11, 5.26348e-19, 2.24457e-26}, + {5.06822e-04, 2.04373e-11, 8.48182e-19, 3.61680e-26}, + {8.07243e-04, 3.25496e-11, 1.35079e-18, 5.75968e-26}, + {1.28661e-03, 5.18753e-11, 2.15265e-18, 9.17827e-26}, + {2.05232e-03, 8.27416e-11, 3.43325e-18, 1.46374e-25}, + {3.27011e-03, 1.31826e-10, 5.46945e-18, 2.33165e-25}, + {5.23877e-03, 2.11162e-10, 8.76012e-18, 3.73409e-25}, + {8.44994e-03, 3.40550e-10, 1.41259e-17, 6.02059e-25}, + {1.37154e-02, 5.52677e-10, 2.29218e-17, 9.76820e-25}, + {2.24094e-02, 9.02883e-10, 3.74411e-17, 1.59536e-24}, + {3.70035e-02, 1.49068e-09, 6.18079e-17, 2.63331e-24}, + {6.21576e-02, 2.50369e-09, 1.03798e-16, 4.42178e-24}, + {1.07032e-01, 4.31074e-09, 1.78696e-16, 7.61171e-24}, + {1.90087e-01, 7.65516e-09, 3.17308e-16, 1.35149e-23}, + {3.49468e-01, 1.40728e-08, 5.83283e-16, 2.48420e-23}, + {6.64945e-01, 2.67755e-08, 1.10973e-15, 4.72613e-23}, + {1.30413e+00, 5.25119e-08, 2.17633e-15, 9.26832e-23}, + {2.61639e+00, 1.05349e-07, 4.36605e-15, 1.85933e-22}, + {5.31790e+00, 2.14123e-07, 8.87391e-15, 3.77901e-22}, + {1.08366e+01, 4.36326e-07, 1.80825e-14, 7.70051e-22}, + {2.19131e+01, 8.82310e-07, 3.65652e-14, 1.55714e-21}, + {4.35353e+01, 1.75290e-06, 7.26444e-14, 3.09356e-21}, + {8.42362e+01, 3.39166e-06, 1.40558e-13, 5.98567e-21}, + {1.57704e+02, 6.34974e-06, 2.63148e-13, 1.12061e-20}, + {2.84822e+02, 1.14680e-05, 4.75258e-13, 2.02388e-20}, + {4.96653e+02, 1.99971e-05, 8.28723e-13, 3.52910e-20}, + {8.39966e+02, 3.38201e-05, 1.40158e-12, 5.96860e-20}, + {1.38932e+03, 5.59392e-05, 2.31824e-12, 9.87221e-20}, + } + }, +}; + +} // namespace fsn15 + +namespace fsn50 { +static const MetalNuclideYieldProps metal_props[] = { + // {name, gas_yield, total_yield} + {"C", 2.79057e-01, 2.79167e-01}, + {"O", 7.20575e-01, 7.20575e-01}, + {"Mg", 2.49793e-04, 2.49794e-04}, + {"Al", 1.66468e-08, 1.66468e-08}, + {"Si", 4.01058e-06, 4.01099e-06}, + {"S", 0.00000e+00, 0.00000e+00}, + {"Fe", 4.15804e-06, 4.15804e-06}, +}; + +static const GrainSpeciesYieldProps grain_props[] = { + { + /* name = */ "FeM_dust", + /* nonprimoridal_yield_frac = */ 2.33171e-24, + /* size_moments = */ {4.02891e-08, 1.67016e-15, 7.11339e-23}, + /* opacity_coef_table = */ { + {1.05240e-01, 1.77320e-08, 3.18492e-15, 5.89732e-22}, + {1.32588e-01, 2.23399e-08, 4.01256e-15, 7.42980e-22}, + {1.67016e-01, 2.81408e-08, 5.05449e-15, 9.35908e-22}, + {2.10360e-01, 3.54438e-08, 6.36620e-15, 1.17879e-21}, + {2.71887e-01, 4.58106e-08, 8.22824e-15, 1.52357e-21}, + {3.55694e-01, 5.99313e-08, 1.07645e-14, 1.99320e-21}, + {4.84932e-01, 8.17069e-08, 1.46757e-14, 2.71741e-21}, + {6.99767e-01, 1.17905e-07, 2.11774e-14, 3.92128e-21}, + {1.05860e+00, 1.78364e-07, 3.20367e-14, 5.93204e-21}, + {1.62902e+00, 2.74475e-07, 4.92997e-14, 9.12851e-21}, + {2.54260e+00, 4.28406e-07, 7.69478e-14, 1.42479e-20}, + {3.96488e+00, 6.68047e-07, 1.19991e-13, 2.22179e-20}, + {6.10630e+00, 1.02886e-06, 1.84797e-13, 3.42178e-20}, + {9.28766e+00, 1.56489e-06, 2.81076e-13, 5.20451e-20}, + {1.39265e+01, 2.34649e-06, 4.21463e-13, 7.80396e-20}, + {2.05382e+01, 3.46051e-06, 6.21558e-13, 1.15090e-19}, + {3.00649e+01, 5.06568e-06, 9.09868e-13, 1.68475e-19}, + {4.55102e+01, 7.66807e-06, 1.37729e-12, 2.55025e-19}, + {7.47839e+01, 1.26004e-05, 2.26322e-12, 4.19065e-19}, + {1.29621e+02, 2.18400e-05, 3.92277e-12, 7.26354e-19}, + {2.14820e+02, 3.61953e-05, 6.50119e-12, 1.20378e-18}, + {3.20002e+02, 5.39175e-05, 9.68435e-12, 1.79319e-18}, + {4.29768e+02, 7.24122e-05, 1.30063e-11, 2.40829e-18}, + {5.30829e+02, 8.94401e-05, 1.60647e-11, 2.97460e-18}, + {5.99696e+02, 1.01044e-04, 1.81489e-11, 3.36051e-18}, + {6.06539e+02, 1.02197e-04, 1.83560e-11, 3.39886e-18}, + {5.43264e+02, 9.15353e-05, 1.64410e-11, 3.04428e-18}, + {4.33547e+02, 7.30489e-05, 1.31206e-11, 2.42946e-18}, + {3.13324e+02, 5.27923e-05, 9.48225e-12, 1.75577e-18}, + {2.09008e+02, 3.52161e-05, 6.32532e-12, 1.17122e-18}, + {1.31150e+02, 2.20976e-05, 3.96905e-12, 7.34924e-19}, + {7.90692e+01, 1.33225e-05, 2.39291e-12, 4.43080e-19}, + {4.73403e+01, 7.97645e-06, 1.43269e-12, 2.65282e-19}, + {2.96433e+01, 4.99469e-06, 8.97122e-13, 1.66115e-19}, + {2.04754e+01, 3.45001e-06, 6.19680e-13, 1.14743e-19}, + } + }, + { + /* name = */ "Mg2SiO4_dust", + /* nonprimoridal_yield_frac = */ 2.62486e-10, + /* size_moments = */ {1.68491e-07, 3.02634e-14, 5.60369e-21}, + /* opacity_coef_table = */ { + {2.19890e-02, 2.92460e-09, 4.05846e-16, 5.77498e-23}, + {3.90612e-02, 5.19526e-09, 7.20944e-16, 1.02587e-22}, + {6.05539e-02, 8.05385e-09, 1.11763e-15, 1.59033e-22}, + {8.76116e-02, 1.16526e-08, 1.61703e-15, 2.30095e-22}, + {1.43288e-01, 1.90577e-08, 2.64462e-15, 3.76317e-22}, + {2.19266e-01, 2.91631e-08, 4.04694e-15, 5.75860e-22}, + {3.36256e-01, 4.47230e-08, 6.20619e-15, 8.83109e-22}, + {5.14336e-01, 6.84082e-08, 9.49297e-15, 1.35080e-21}, + {7.97216e-01, 1.06032e-07, 1.47140e-14, 2.09373e-21}, + {1.25414e+00, 1.66804e-07, 2.31474e-14, 3.29375e-21}, + {2.03450e+00, 2.70594e-07, 3.75503e-14, 5.34322e-21}, + {3.34648e+00, 4.45091e-07, 6.17651e-14, 8.78886e-21}, + {5.45893e+00, 7.26054e-07, 1.00754e-13, 1.43368e-20}, + {8.82117e+00, 1.17324e-06, 1.62810e-13, 2.31671e-20}, + {1.41825e+01, 1.88631e-06, 2.61763e-13, 3.72475e-20}, + {2.28419e+01, 3.03804e-06, 4.21588e-13, 5.99898e-20}, + {3.71178e+01, 4.93677e-06, 6.85074e-13, 9.74826e-20}, + {6.14273e+01, 8.17002e-06, 1.13375e-12, 1.61327e-19}, + {1.03847e+02, 1.38119e-05, 1.91667e-12, 2.72733e-19}, + {1.75507e+02, 2.33429e-05, 3.23928e-12, 4.60933e-19}, + {2.82060e+02, 3.75148e-05, 5.20591e-12, 7.40775e-19}, + {4.14519e+02, 5.51322e-05, 7.65067e-12, 1.08865e-18}, + {5.59962e+02, 7.44767e-05, 1.03351e-11, 1.47063e-18}, + {7.11026e+02, 9.45685e-05, 1.31232e-11, 1.86737e-18}, + {8.40809e+02, 1.11830e-04, 1.55186e-11, 2.20822e-18}, + {8.95315e+02, 1.19080e-04, 1.65246e-11, 2.35137e-18}, + {8.40416e+02, 1.11778e-04, 1.55114e-11, 2.20719e-18}, + {6.96694e+02, 9.26624e-05, 1.28587e-11, 1.82973e-18}, + {5.18204e+02, 6.89226e-05, 9.56436e-12, 1.36096e-18}, + {3.52865e+02, 4.69321e-05, 6.51275e-12, 9.26731e-19}, + {2.24211e+02, 2.98208e-05, 4.13822e-12, 5.88848e-19}, + {1.35138e+02, 1.79738e-05, 2.49421e-12, 3.54913e-19}, + {7.83122e+01, 1.04158e-05, 1.44539e-12, 2.05672e-19}, + {4.41556e+01, 5.87282e-06, 8.14969e-13, 1.15966e-19}, + {2.45896e+01, 3.27050e-06, 4.53847e-13, 6.45802e-20}, + } + }, + { + /* name = */ "MgSiO3_dust", + /* nonprimoridal_yield_frac = */ 1.21446e-09, + /* size_moments = */ {1.33003e-07, 1.84568e-14, 2.62630e-21}, + /* opacity_coef_table = */ { + {1.47700e-02, 8.71144e-10, 5.19508e-17, 3.12839e-24}, + {2.47694e-02, 1.46092e-09, 8.71220e-17, 5.24635e-24}, + {3.73580e-02, 2.20340e-09, 1.31400e-16, 7.91270e-24}, + {5.32060e-02, 3.13813e-09, 1.87143e-16, 1.12694e-23}, + {8.50036e-02, 5.01357e-09, 2.98985e-16, 1.80044e-23}, + {1.29213e-01, 7.62106e-09, 4.54483e-16, 2.73683e-23}, + {2.00170e-01, 1.18061e-08, 7.04061e-16, 4.23974e-23}, + {3.15560e-01, 1.86119e-08, 1.10993e-15, 6.68379e-23}, + {5.01384e-01, 2.95719e-08, 1.76353e-15, 1.06197e-22}, + {7.88907e-01, 4.65303e-08, 2.77484e-15, 1.67096e-22}, + {1.24250e+00, 7.32834e-08, 4.37027e-15, 2.63171e-22}, + {1.95225e+00, 1.15145e-07, 6.86667e-15, 4.13500e-22}, + {3.04002e+00, 1.79302e-07, 1.06927e-14, 6.43899e-22}, + {4.68918e+00, 2.76571e-07, 1.64933e-14, 9.93203e-22}, + {7.12599e+00, 4.20295e-07, 2.50644e-14, 1.50934e-21}, + {1.05834e+01, 6.24215e-07, 3.72252e-14, 2.24164e-21}, + {1.52356e+01, 8.98605e-07, 5.35885e-14, 3.22701e-21}, + {2.13345e+01, 1.25832e-06, 7.50404e-14, 4.51881e-21}, + {2.98061e+01, 1.75798e-06, 1.04837e-13, 6.31314e-21}, + {4.27642e+01, 2.52226e-06, 1.50415e-13, 9.05777e-21}, + {6.30370e+01, 3.71796e-06, 2.21721e-13, 1.33517e-20}, + {9.29361e+01, 5.48143e-06, 3.26886e-13, 1.96845e-20}, + {1.32987e+02, 7.84365e-06, 4.67758e-13, 2.81676e-20}, + {1.82150e+02, 1.07433e-05, 6.40681e-13, 3.85808e-20}, + {2.40388e+02, 1.41782e-05, 8.45520e-13, 5.09158e-20}, + {3.12065e+02, 1.84058e-05, 1.09763e-12, 6.60977e-20}, + {4.08414e+02, 2.40885e-05, 1.43652e-12, 8.65051e-20}, + {5.49591e+02, 3.24152e-05, 1.93309e-12, 1.16407e-19}, + {7.67451e+02, 4.52647e-05, 2.69937e-12, 1.62552e-19}, + {1.10725e+03, 6.53066e-05, 3.89457e-12, 2.34525e-19}, + {1.62060e+03, 9.55840e-05, 5.70017e-12, 3.43255e-19}, + {2.33999e+03, 1.38014e-04, 8.23049e-12, 4.95627e-19}, + {3.24369e+03, 1.91315e-04, 1.14091e-11, 6.87037e-19}, + {4.25718e+03, 2.51091e-04, 1.49739e-11, 9.01702e-19}, + {5.34014e+03, 3.14965e-04, 1.87830e-11, 1.13108e-18}, + } + }, + { + /* name = */ "Fe3O4_dust", + /* nonprimoridal_yield_frac = */ 2.41799e-13, + /* size_moments = */ {5.89806e-08, 3.51732e-15, 2.11807e-22}, + /* opacity_coef_table = */ { + {3.27960e-01, 2.23600e-07, 2.14215e-13, 2.51135e-19}, + {4.38752e-01, 2.99136e-07, 2.86582e-13, 3.35973e-19}, + {5.78230e-01, 3.94231e-07, 3.77685e-13, 4.42778e-19}, + {7.53823e-01, 5.13949e-07, 4.92378e-13, 5.77238e-19}, + {1.04013e+00, 7.09149e-07, 6.79388e-13, 7.96479e-19}, + {1.41735e+00, 9.66336e-07, 9.25781e-13, 1.08534e-18}, + {1.95292e+00, 1.33148e-06, 1.27560e-12, 1.49545e-18}, + {2.71530e+00, 1.85127e-06, 1.77357e-12, 2.07925e-18}, + {3.79675e+00, 2.58859e-06, 2.47995e-12, 2.90737e-18}, + {5.29742e+00, 3.61173e-06, 3.46016e-12, 4.05652e-18}, + {7.37832e+00, 5.03048e-06, 4.81937e-12, 5.65000e-18}, + {1.02167e+01, 6.96570e-06, 6.67339e-12, 7.82359e-18}, + {1.40420e+01, 9.57377e-06, 9.17203e-12, 1.07529e-17}, + {1.92020e+01, 1.30918e-05, 1.25425e-11, 1.47044e-17}, + {2.61614e+01, 1.78368e-05, 1.70885e-11, 2.00340e-17}, + {3.55303e+01, 2.42246e-05, 2.32084e-11, 2.72089e-17}, + {4.81604e+01, 3.28360e-05, 3.14588e-11, 3.68819e-17}, + {6.53156e+01, 4.45330e-05, 4.26657e-11, 5.00213e-17}, + {8.87641e+01, 6.05213e-05, 5.79846e-11, 6.79824e-17}, + {1.20700e+02, 8.22973e-05, 7.88495e-11, 9.24471e-17}, + {1.63611e+02, 1.11558e-04, 1.06888e-10, 1.25326e-16}, + {2.20556e+02, 1.50393e-04, 1.44104e-10, 1.68969e-16}, + {2.96069e+02, 2.01894e-04, 1.93464e-10, 2.26864e-16}, + {3.96959e+02, 2.70713e-04, 2.59434e-10, 3.04254e-16}, + {5.31398e+02, 3.62437e-04, 3.47381e-10, 4.07456e-16}, + {7.06744e+02, 4.82105e-04, 4.62166e-10, 5.42204e-16}, + {9.30503e+02, 6.34887e-04, 6.08797e-10, 7.14450e-16}, + {1.21574e+03, 8.29802e-04, 7.96038e-10, 9.34622e-16}, + {1.58603e+03, 1.08311e-03, 1.03970e-09, 1.22157e-15}, + {2.07753e+03, 1.41988e-03, 1.36429e-09, 1.60466e-15}, + {2.74067e+03, 1.87531e-03, 1.80443e-09, 2.12568e-15}, + {3.64502e+03, 2.49832e-03, 2.40876e-09, 2.84400e-15}, + {4.89065e+03, 3.35972e-03, 3.24810e-09, 3.84654e-15}, + {6.62881e+03, 4.56615e-03, 4.42856e-09, 5.26292e-15}, + {9.09708e+03, 6.28233e-03, 6.11057e-09, 7.28448e-15}, + } + }, + { + /* name = */ "AC_dust", + /* nonprimoridal_yield_frac = */ 1.09849e-04, + /* size_moments = */ {6.81790e-07, 6.53175e-13, 7.65748e-19}, + /* opacity_coef_table = */ { + {7.60360e-02, 7.46380e-09, 7.39712e-16, 7.36277e-23}, + {9.07207e-02, 8.90526e-09, 8.82572e-16, 8.78473e-23}, + {1.09208e-01, 1.07200e-08, 1.06242e-15, 1.05749e-22}, + {1.32481e-01, 1.30045e-08, 1.28884e-15, 1.28285e-22}, + {1.58907e-01, 1.55986e-08, 1.54592e-15, 1.53874e-22}, + {1.91565e-01, 1.88042e-08, 1.86363e-15, 1.85497e-22}, + {2.30490e-01, 2.26252e-08, 2.24231e-15, 2.23190e-22}, + {2.76795e-01, 2.71706e-08, 2.69279e-15, 2.68028e-22}, + {3.33074e-01, 3.26950e-08, 3.24029e-15, 3.22524e-22}, + {4.05325e-01, 3.97872e-08, 3.94318e-15, 3.92487e-22}, + {5.08160e-01, 4.98817e-08, 4.94361e-15, 4.92065e-22}, + {6.72472e-01, 6.60108e-08, 6.54211e-15, 6.51173e-22}, + {9.48549e-01, 9.31109e-08, 9.22792e-15, 9.18506e-22}, + {1.41787e+00, 1.39180e-07, 1.37937e-14, 1.37297e-21}, + {2.19502e+00, 2.15466e-07, 2.13541e-14, 2.12549e-21}, + {3.46719e+00, 3.40344e-07, 3.37304e-14, 3.35738e-21}, + {5.76852e+00, 5.66246e-07, 5.61188e-14, 5.58582e-21}, + {1.17194e+01, 1.15039e-06, 1.14012e-13, 1.13482e-20}, + {3.16449e+01, 3.10631e-06, 3.07856e-13, 3.06426e-20}, + {8.68296e+01, 8.52331e-06, 8.44717e-13, 8.40795e-20}, + {1.92300e+02, 1.88764e-05, 1.87078e-12, 1.86209e-19}, + {3.36231e+02, 3.30049e-05, 3.27100e-12, 3.25581e-19}, + {5.05825e+02, 4.96525e-05, 4.92089e-12, 4.89804e-19}, + {7.20624e+02, 7.07374e-05, 7.01055e-12, 6.97800e-19}, + {9.77376e+02, 9.59406e-05, 9.50836e-12, 9.46420e-19}, + {1.18646e+03, 1.16464e-04, 1.15424e-11, 1.14888e-18}, + {1.23845e+03, 1.21568e-04, 1.20482e-11, 1.19922e-18}, + {1.11188e+03, 1.09144e-04, 1.08169e-11, 1.07667e-18}, + {8.76396e+02, 8.60282e-05, 8.52597e-12, 8.48638e-19}, + {6.22207e+02, 6.10766e-05, 6.05311e-12, 6.02500e-19}, + {4.07290e+02, 3.99801e-05, 3.96230e-12, 3.94390e-19}, + {2.50573e+02, 2.45966e-05, 2.43769e-12, 2.42636e-19}, + {1.47073e+02, 1.44369e-05, 1.43080e-12, 1.42415e-19}, + {8.33122e+01, 8.17804e-06, 8.10499e-13, 8.06735e-20}, + {4.59586e+01, 4.51135e-06, 4.47106e-13, 4.45029e-20}, + } + }, + { + /* name = */ "SiO2_dust", + /* nonprimoridal_yield_frac = */ 3.41863e-11, + /* size_moments = */ {9.81613e-08, 9.72845e-15, 9.68327e-22}, + /* opacity_coef_table = */ { + {9.93250e-04, 4.00425e-11, 1.66043e-18, 7.07300e-26}, + {1.81240e-03, 7.30662e-11, 3.02982e-18, 1.29062e-25}, + {2.84365e-03, 1.14641e-10, 4.75377e-18, 2.02498e-25}, + {4.14191e-03, 1.66980e-10, 6.92410e-18, 2.94948e-25}, + {7.18271e-03, 2.89568e-10, 1.20074e-17, 5.11486e-25}, + {1.13364e-02, 4.57021e-10, 1.89512e-17, 8.07270e-25}, + {1.77361e-02, 7.15022e-10, 2.96496e-17, 1.26300e-24}, + {2.59477e-02, 1.04607e-09, 4.33772e-17, 1.84776e-24}, + {3.45425e-02, 1.39257e-09, 5.77453e-17, 2.45980e-24}, + {4.22006e-02, 1.70130e-09, 7.05475e-17, 3.00514e-24}, + {4.71420e-02, 1.90051e-09, 7.88080e-17, 3.35701e-24}, + {4.91934e-02, 1.98321e-09, 8.22374e-17, 3.50310e-24}, + {5.05162e-02, 2.03654e-09, 8.44487e-17, 3.59729e-24}, + {5.78201e-02, 2.33100e-09, 9.66588e-17, 4.11741e-24}, + {8.84237e-02, 3.56477e-09, 1.47819e-16, 6.29671e-24}, + {1.78786e-01, 7.20770e-09, 2.98880e-16, 1.27315e-23}, + {4.36404e-01, 1.75935e-08, 7.29543e-16, 3.10766e-23}, + {1.63796e+00, 6.60337e-08, 2.73820e-15, 1.16640e-22}, + {8.50817e+00, 3.43004e-07, 1.42232e-14, 6.05873e-22}, + {3.92751e+01, 1.58336e-06, 6.56568e-14, 2.79681e-21}, + {1.41436e+02, 5.70194e-06, 2.36441e-13, 1.00718e-20}, + {3.83709e+02, 1.54691e-05, 6.41452e-13, 2.73242e-20}, + {7.70411e+02, 3.10588e-05, 1.28791e-12, 5.48615e-20}, + {1.16399e+03, 4.69258e-05, 1.94586e-12, 8.28885e-20}, + {1.37566e+03, 5.54594e-05, 2.29972e-12, 9.79620e-20}, + {1.33070e+03, 5.36466e-05, 2.22455e-12, 9.47600e-20}, + {1.09978e+03, 4.43372e-05, 1.83852e-12, 7.83160e-20}, + {8.05638e+02, 3.24790e-05, 1.34680e-12, 5.73701e-20}, + {5.38690e+02, 2.17171e-05, 9.00536e-13, 3.83605e-20}, + {3.36338e+02, 1.35593e-05, 5.62261e-13, 2.39509e-20}, + {1.99460e+02, 8.04115e-06, 3.33440e-13, 1.42037e-20}, + {1.13787e+02, 4.58729e-06, 1.90220e-13, 8.10286e-21}, + {6.30411e+01, 2.54148e-06, 1.05387e-13, 4.48920e-21}, + {3.41529e+01, 1.37686e-06, 5.70940e-14, 2.43205e-21}, + {1.81893e+01, 7.33294e-07, 3.04073e-14, 1.29527e-21}, + } + }, + { + /* name = */ "Al2O3_dust", + /* nonprimoridal_yield_frac = */ 2.53950e-17, + /* size_moments = */ {4.03146e-08, 1.67172e-15, 7.12107e-23}, + /* opacity_coef_table = */ { + {1.23620e-05, 4.98882e-13, 2.07138e-20, 8.83538e-28}, + {2.19537e-05, 8.85960e-13, 3.67854e-20, 1.56906e-27}, + {3.40288e-05, 1.37326e-12, 5.70184e-20, 2.43208e-27}, + {4.92305e-05, 1.98674e-12, 8.24901e-20, 3.51856e-27}, + {8.08507e-05, 3.26278e-12, 1.35471e-19, 5.77841e-27}, + {1.25019e-04, 5.04514e-12, 2.09472e-19, 8.93477e-27}, + {1.96584e-04, 7.93293e-12, 3.29363e-19, 1.40481e-26}, + {3.14489e-04, 1.26902e-11, 5.26848e-19, 2.24703e-26}, + {5.06846e-04, 2.04508e-11, 8.48987e-19, 3.62076e-26}, + {8.07280e-04, 3.25711e-11, 1.35207e-18, 5.76597e-26}, + {1.28667e-03, 5.19094e-11, 2.15469e-18, 9.18830e-26}, + {2.05240e-03, 8.27959e-11, 3.43651e-18, 1.46534e-25}, + {3.27023e-03, 1.31912e-10, 5.47463e-18, 2.33420e-25}, + {5.23895e-03, 2.11300e-10, 8.76840e-18, 3.73817e-25}, + {8.45019e-03, 3.40772e-10, 1.41393e-17, 6.02717e-25}, + {1.37157e-02, 5.53037e-10, 2.29434e-17, 9.77885e-25}, + {2.24099e-02, 9.03468e-10, 3.74764e-17, 1.59710e-24}, + {3.70041e-02, 1.49164e-09, 6.18661e-17, 2.63618e-24}, + {6.21584e-02, 2.50530e-09, 1.03896e-16, 4.42660e-24}, + {1.07033e-01, 4.31351e-09, 1.78864e-16, 7.62000e-24}, + {1.90089e-01, 7.66007e-09, 3.17606e-16, 1.35297e-23}, + {3.49470e-01, 1.40818e-08, 5.83831e-16, 2.48691e-23}, + {6.64947e-01, 2.67926e-08, 1.11077e-15, 4.73128e-23}, + {1.30413e+00, 5.25455e-08, 2.17837e-15, 9.27841e-23}, + {2.61640e+00, 1.05417e-07, 4.37015e-15, 1.86136e-22}, + {5.31790e+00, 2.14259e-07, 8.88223e-15, 3.78313e-22}, + {1.08366e+01, 4.36604e-07, 1.80995e-14, 7.70889e-22}, + {2.19132e+01, 8.82874e-07, 3.65995e-14, 1.55883e-21}, + {4.35354e+01, 1.75402e-06, 7.27125e-14, 3.09693e-21}, + {8.42362e+01, 3.39383e-06, 1.40690e-13, 5.99219e-21}, + {1.57704e+02, 6.35380e-06, 2.63395e-13, 1.12183e-20}, + {2.84822e+02, 1.14753e-05, 4.75704e-13, 2.02608e-20}, + {4.96653e+02, 2.00098e-05, 8.29500e-13, 3.53294e-20}, + {8.39966e+02, 3.38417e-05, 1.40289e-12, 5.97510e-20}, + {1.38932e+03, 5.59749e-05, 2.32042e-12, 9.88295e-20}, + } + }, +}; + +} // namespace fsn50 + +namespace fsn80 { +static const MetalNuclideYieldProps metal_props[] = { + // {name, gas_yield, total_yield} + {"C", 2.43883e-01, 2.52563e-01}, + {"O", 7.46061e-01, 7.46061e-01}, + {"Mg", 1.36917e-03, 1.36917e-03}, + {"Al", 1.55602e-08, 1.55602e-08}, + {"Si", 3.63906e-06, 3.63906e-06}, + {"S", 0.00000e+00, 0.00000e+00}, + {"Fe", 2.43915e-06, 2.43915e-06}, +}; + +static const GrainSpeciesYieldProps grain_props[] = { + { + /* name = */ "FeM_dust", + /* nonprimoridal_yield_frac = */ 3.87590e-26, + /* size_moments = */ {4.02891e-08, 1.67016e-15, 7.11339e-23}, + /* opacity_coef_table = */ { + {1.05240e-01, 6.19546e-09, 3.68996e-16, 2.22004e-23}, + {1.32588e-01, 7.80541e-09, 4.64884e-16, 2.79694e-23}, + {1.67016e-01, 9.83223e-09, 5.85599e-16, 3.52321e-23}, + {2.10360e-01, 1.23838e-08, 7.37570e-16, 4.43753e-23}, + {2.71887e-01, 1.60059e-08, 9.53300e-16, 5.73545e-23}, + {3.55694e-01, 2.09396e-08, 1.24715e-15, 7.50336e-23}, + {4.84932e-01, 2.85479e-08, 1.70029e-15, 1.02296e-22}, + {6.99767e-01, 4.11952e-08, 2.45355e-15, 1.47616e-22}, + {1.05860e+00, 6.23193e-08, 3.71169e-15, 2.23311e-22}, + {1.62902e+00, 9.59000e-08, 5.71172e-15, 3.43641e-22}, + {2.54260e+00, 1.49682e-07, 8.91495e-15, 5.36361e-22}, + {3.96488e+00, 2.33412e-07, 1.39018e-14, 8.36390e-22}, + {6.10630e+00, 3.59476e-07, 2.14101e-14, 1.28812e-21}, + {9.28766e+00, 5.46763e-07, 3.25647e-14, 1.95923e-21}, + {1.39265e+01, 8.19849e-07, 4.88295e-14, 2.93779e-21}, + {2.05382e+01, 1.20908e-06, 7.20119e-14, 4.33254e-21}, + {3.00649e+01, 1.76992e-06, 1.05415e-13, 6.34219e-21}, + {4.55102e+01, 2.67918e-06, 1.59569e-13, 9.60036e-21}, + {7.47839e+01, 4.40251e-06, 2.62210e-13, 1.57756e-20}, + {1.29621e+02, 7.63075e-06, 4.54481e-13, 2.73435e-20}, + {2.14820e+02, 1.26464e-05, 7.53210e-13, 4.53162e-20}, + {3.20002e+02, 1.88384e-05, 1.12200e-12, 6.75043e-20}, + {4.29768e+02, 2.53004e-05, 1.50687e-12, 9.06596e-20}, + {5.30827e+02, 3.12497e-05, 1.86120e-12, 1.11978e-19}, + {5.99694e+02, 3.53039e-05, 2.10267e-12, 1.26505e-19}, + {6.06537e+02, 3.57067e-05, 2.12666e-12, 1.27949e-19}, + {5.43262e+02, 3.19817e-05, 1.90480e-12, 1.14601e-19}, + {4.33545e+02, 2.55227e-05, 1.52011e-12, 9.14563e-20}, + {3.13324e+02, 1.84453e-05, 1.09859e-12, 6.60956e-20}, + {2.09006e+02, 1.23041e-05, 7.32824e-13, 4.40898e-20}, + {1.31150e+02, 7.72078e-06, 4.59843e-13, 2.76661e-20}, + {7.90683e+01, 4.65474e-06, 2.77232e-13, 1.66794e-20}, + {4.73389e+01, 2.78683e-06, 1.65981e-13, 9.98614e-21}, + {2.96409e+01, 1.74496e-06, 1.03928e-13, 6.25275e-21}, + {2.04709e+01, 1.20512e-06, 7.17759e-14, 4.31834e-21}, + } + }, + { + /* name = */ "Mg2SiO4_dust", + /* nonprimoridal_yield_frac = */ 2.36180e-13, + /* size_moments = */ {5.88698e-08, 3.50624e-15, 2.10950e-22}, + /* opacity_coef_table = */ { + {2.19890e-02, 1.29231e-09, 7.68620e-17, 4.61833e-24}, + {3.90612e-02, 2.29567e-09, 1.36538e-16, 8.20401e-24}, + {6.05539e-02, 3.55881e-09, 2.11665e-16, 1.27181e-23}, + {8.76116e-02, 5.14902e-09, 3.06244e-16, 1.84010e-23}, + {1.43288e-01, 8.42115e-09, 5.00858e-16, 3.00946e-23}, + {2.19266e-01, 1.28865e-08, 7.66440e-16, 4.60523e-23}, + {3.36256e-01, 1.97621e-08, 1.17537e-15, 7.06235e-23}, + {5.14336e-01, 3.02280e-08, 1.79785e-15, 1.08026e-22}, + {7.97216e-01, 4.68532e-08, 2.78665e-15, 1.67439e-22}, + {1.25414e+00, 7.37070e-08, 4.38381e-15, 2.63406e-22}, + {2.03450e+00, 1.19569e-07, 7.11154e-15, 4.27305e-22}, + {3.34648e+00, 1.96676e-07, 1.16975e-14, 7.02858e-22}, + {5.45893e+00, 3.20827e-07, 1.90816e-14, 1.14654e-21}, + {8.82117e+00, 5.18428e-07, 3.08342e-14, 1.85270e-21}, + {1.41825e+01, 8.33519e-07, 4.95746e-14, 2.97874e-21}, + {2.28419e+01, 1.34244e-06, 7.98433e-14, 4.79747e-21}, + {3.71178e+01, 2.18145e-06, 1.29744e-13, 7.79582e-21}, + {6.14272e+01, 3.61014e-06, 2.14717e-13, 1.29015e-20}, + {1.03847e+02, 6.10317e-06, 3.62993e-13, 2.18108e-20}, + {1.75507e+02, 1.03147e-05, 6.13479e-13, 3.68615e-20}, + {2.82060e+02, 1.65769e-05, 9.85934e-13, 5.92409e-20}, + {4.14519e+02, 2.43617e-05, 1.44894e-12, 8.70611e-20}, + {5.59961e+02, 3.29094e-05, 1.95733e-12, 1.17608e-19}, + {7.11024e+02, 4.17876e-05, 2.48537e-12, 1.49336e-19}, + {8.40806e+02, 4.94150e-05, 2.93902e-12, 1.76594e-19}, + {8.95312e+02, 5.26183e-05, 3.12954e-12, 1.88042e-19}, + {8.40415e+02, 4.93920e-05, 2.93765e-12, 1.76512e-19}, + {6.96693e+02, 4.09453e-05, 2.43527e-12, 1.46326e-19}, + {5.18202e+02, 3.04552e-05, 1.81136e-12, 1.08838e-19}, + {3.52864e+02, 2.07382e-05, 1.23343e-12, 7.41118e-20}, + {2.24210e+02, 1.31770e-05, 7.83720e-13, 4.70907e-20}, + {1.35138e+02, 7.94218e-06, 4.72371e-13, 2.83829e-20}, + {7.83119e+01, 4.60247e-06, 2.73737e-13, 1.64478e-20}, + {4.41553e+01, 2.59505e-06, 1.54344e-13, 9.27391e-21}, + {2.45888e+01, 1.44511e-06, 8.59497e-14, 5.16438e-21}, + } + }, + { + /* name = */ "MgSiO3_dust", + /* nonprimoridal_yield_frac = */ 2.48190e-12, + /* size_moments = */ {5.87709e-08, 3.49547e-15, 2.10029e-22}, + /* opacity_coef_table = */ { + {1.47700e-02, 5.95736e-10, 2.47198e-17, 1.05395e-24}, + {2.47694e-02, 9.99055e-10, 4.14553e-17, 1.76749e-24}, + {3.73580e-02, 1.50680e-09, 6.25240e-17, 2.66578e-24}, + {5.32060e-02, 2.14602e-09, 8.90481e-17, 3.79666e-24}, + {8.50036e-02, 3.42855e-09, 1.42266e-16, 6.06566e-24}, + {1.29213e-01, 5.21170e-09, 2.16257e-16, 9.22034e-24}, + {2.00170e-01, 8.07368e-09, 3.35013e-16, 1.42836e-23}, + {3.15560e-01, 1.27279e-08, 5.28136e-16, 2.25176e-23}, + {5.01384e-01, 2.02229e-08, 8.39139e-16, 3.57776e-23}, + {7.88907e-01, 3.18199e-08, 1.32035e-15, 5.62946e-23}, + {1.24250e+00, 5.01152e-08, 2.07951e-15, 8.86619e-23}, + {1.95225e+00, 7.87422e-08, 3.26737e-15, 1.39308e-22}, + {3.04002e+00, 1.22617e-07, 5.08792e-15, 2.16929e-22}, + {4.68918e+00, 1.89134e-07, 7.84803e-15, 3.34609e-22}, + {7.12599e+00, 2.87421e-07, 1.19264e-14, 5.08494e-22}, + {1.05834e+01, 4.26872e-07, 1.77129e-14, 7.55206e-22}, + {1.52356e+01, 6.14515e-07, 2.54990e-14, 1.08718e-21}, + {2.13345e+01, 8.60511e-07, 3.57065e-14, 1.52238e-21}, + {2.98061e+01, 1.20220e-06, 4.98848e-14, 2.12689e-21}, + {4.27642e+01, 1.72486e-06, 7.15721e-14, 3.05155e-21}, + {6.30370e+01, 2.54254e-06, 1.05502e-13, 4.49817e-21}, + {9.29361e+01, 3.74850e-06, 1.55542e-13, 6.63170e-21}, + {1.32987e+02, 5.36392e-06, 2.22573e-13, 9.48964e-21}, + {1.82150e+02, 7.34689e-06, 3.04855e-13, 1.29978e-20}, + {2.40388e+02, 9.69583e-06, 4.02324e-13, 1.71535e-20}, + {3.12065e+02, 1.25869e-05, 5.22286e-13, 2.22682e-20}, + {4.08414e+02, 1.64730e-05, 6.83540e-13, 2.91435e-20}, + {5.49591e+02, 2.21673e-05, 9.19821e-13, 3.92175e-20}, + {7.67451e+02, 3.09545e-05, 1.28444e-12, 5.47635e-20}, + {1.10725e+03, 4.46602e-05, 1.85315e-12, 7.90111e-20}, + {1.62060e+03, 6.53655e-05, 2.71231e-12, 1.15642e-19}, + {2.33999e+03, 9.43815e-05, 3.91631e-12, 1.66976e-19}, + {3.24367e+03, 1.30831e-04, 5.42876e-12, 2.31461e-19}, + {4.25716e+03, 1.71709e-04, 7.12499e-12, 3.03781e-19}, + {5.34010e+03, 2.15389e-04, 8.93744e-12, 3.81058e-19}, + } + }, + { + /* name = */ "Fe3O4_dust", + /* nonprimoridal_yield_frac = */ 3.01120e-15, + /* size_moments = */ {4.03342e-08, 1.67365e-15, 7.13577e-23}, + /* opacity_coef_table = */ { + {3.27960e-01, 1.38598e-06, 7.55735e-12, 4.81450e-17}, + {4.38752e-01, 1.85420e-06, 1.01104e-11, 6.44096e-17}, + {5.78230e-01, 2.44365e-06, 1.33245e-11, 8.48855e-17}, + {7.53823e-01, 3.18572e-06, 1.73708e-11, 1.10663e-16}, + {1.04016e+00, 4.39581e-06, 2.39692e-11, 1.52700e-16}, + {1.41740e+00, 5.99012e-06, 3.26627e-11, 2.08084e-16}, + {1.95298e+00, 8.25351e-06, 4.50044e-11, 2.86710e-16}, + {2.71536e+00, 1.14754e-05, 6.25729e-11, 3.98636e-16}, + {3.79688e+00, 1.60461e-05, 8.74963e-11, 5.57421e-16}, + {5.29770e+00, 2.23889e-05, 1.22083e-10, 7.77774e-16}, + {7.37879e+00, 3.11841e-05, 1.70043e-10, 1.08333e-15}, + {1.02177e+01, 4.31826e-05, 2.35472e-10, 1.50021e-15}, + {1.40437e+01, 5.93525e-05, 3.23651e-10, 2.06204e-15}, + {1.92054e+01, 8.11692e-05, 4.42628e-10, 2.82017e-15}, + {2.61678e+01, 1.10598e-04, 6.03124e-10, 3.84293e-15}, + {3.55420e+01, 1.50223e-04, 8.19247e-10, 5.22035e-15}, + {4.81826e+01, 2.03661e-04, 1.11074e-09, 7.07845e-15}, + {6.53571e+01, 2.76274e-04, 1.50689e-09, 9.60430e-15}, + {8.88432e+01, 3.75591e-04, 2.04885e-09, 1.30610e-14}, + {1.20848e+02, 5.10965e-04, 2.78778e-09, 1.77762e-14}, + {1.63896e+02, 6.93122e-04, 3.78255e-09, 2.41285e-14}, + {2.21094e+02, 9.35280e-04, 5.10587e-09, 3.25877e-14}, + {2.97091e+02, 1.25728e-03, 6.86710e-09, 4.38623e-14}, + {3.98900e+02, 1.68904e-03, 9.23101e-09, 5.90159e-14}, + {5.35045e+02, 2.26701e-03, 1.23979e-08, 7.93362e-14}, + {7.13531e+02, 3.02568e-03, 1.65576e-08, 1.06036e-13}, + {9.43152e+02, 4.00348e-03, 2.19225e-08, 1.40472e-13}, + {1.23958e+03, 5.26932e-03, 2.88749e-08, 1.85093e-13}, + {1.63174e+03, 6.95105e-03, 3.81274e-08, 2.44493e-13}, + {2.16646e+03, 9.25803e-03, 5.08543e-08, 3.26274e-13}, + {2.91544e+03, 1.25164e-02, 6.89019e-08, 4.42468e-13}, + {3.98965e+03, 1.72412e-02, 9.52155e-08, 6.12399e-13}, + {5.56191e+03, 2.42454e-02, 1.34481e-07, 8.66957e-13}, + {7.88390e+03, 3.47095e-02, 1.93494e-07, 1.25089e-12}, + {1.12585e+04, 4.99889e-02, 2.79860e-07, 1.81329e-12}, + } + }, + { + /* name = */ "AC_dust", + /* nonprimoridal_yield_frac = */ 8.68025e-03, + /* size_moments = */ {4.22607e-06, 2.30435e-11, 1.46801e-16}, + /* opacity_coef_table = */ { + {7.60360e-02, 3.06759e-09, 1.27330e-16, 5.43132e-24}, + {9.07207e-02, 3.66003e-09, 1.51922e-16, 6.48026e-24}, + {1.09208e-01, 4.40586e-09, 1.82880e-16, 7.80079e-24}, + {1.32481e-01, 5.34481e-09, 2.21854e-16, 9.46325e-24}, + {1.58907e-01, 6.41094e-09, 2.66108e-16, 1.13509e-23}, + {1.91565e-01, 7.72847e-09, 3.20796e-16, 1.36836e-23}, + {2.30490e-01, 9.29887e-09, 3.85981e-16, 1.64641e-23}, + {2.76795e-01, 1.11670e-08, 4.63523e-16, 1.97717e-23}, + {3.33074e-01, 1.34375e-08, 5.57768e-16, 2.37917e-23}, + {4.05325e-01, 1.63524e-08, 6.78759e-16, 2.89527e-23}, + {5.08160e-01, 2.05012e-08, 8.50969e-16, 3.62983e-23}, + {6.72472e-01, 2.71301e-08, 1.12613e-15, 4.80353e-23}, + {9.48549e-01, 3.82682e-08, 1.58845e-15, 6.77557e-23}, + {1.41787e+00, 5.72025e-08, 2.37438e-15, 1.01280e-22}, + {2.19502e+00, 8.85555e-08, 3.67579e-15, 1.56792e-22}, + {3.46719e+00, 1.39880e-07, 5.80619e-15, 2.47665e-22}, + {5.76852e+00, 2.32725e-07, 9.66001e-15, 4.12050e-22}, + {1.17194e+01, 4.72806e-07, 1.96254e-14, 8.37126e-22}, + {3.16449e+01, 1.27668e-06, 5.29928e-14, 2.26042e-21}, + {8.68296e+01, 3.50304e-06, 1.45406e-13, 6.20231e-21}, + {1.92300e+02, 7.75813e-06, 3.22027e-13, 1.37362e-20}, + {3.36231e+02, 1.35649e-05, 5.63055e-13, 2.40173e-20}, + {5.05825e+02, 2.04070e-05, 8.47058e-13, 3.61315e-20}, + {7.20624e+02, 2.90728e-05, 1.20676e-12, 5.14748e-20}, + {9.77376e+02, 3.94312e-05, 1.63672e-12, 6.98148e-20}, + {1.18646e+03, 4.78662e-05, 1.98685e-12, 8.47495e-20}, + {1.23845e+03, 4.99638e-05, 2.07391e-12, 8.84633e-20}, + {1.11188e+03, 4.48576e-05, 1.86197e-12, 7.94227e-20}, + {8.76396e+02, 3.53572e-05, 1.46762e-12, 6.26017e-20}, + {6.22207e+02, 2.51022e-05, 1.04195e-12, 4.44448e-20}, + {4.07290e+02, 1.64317e-05, 6.82051e-13, 2.90931e-20}, + {2.50573e+02, 1.01091e-05, 4.19611e-13, 1.78986e-20}, + {1.47073e+02, 5.93352e-06, 2.46290e-13, 1.05056e-20}, + {8.33122e+01, 3.36114e-06, 1.39515e-13, 5.95106e-21}, + {4.59585e+01, 1.85415e-06, 7.69625e-14, 3.28286e-21}, + } + }, + { + /* name = */ "SiO2_dust", + /* nonprimoridal_yield_frac = */ 3.70132e-14, + /* size_moments = */ {4.03439e-08, 1.67461e-15, 7.14309e-23}, + /* opacity_coef_table = */ { + {9.93250e-04, 4.00425e-11, 1.66043e-18, 7.07300e-26}, + {1.81240e-03, 7.30662e-11, 3.02981e-18, 1.29062e-25}, + {2.84365e-03, 1.14641e-10, 4.75377e-18, 2.02498e-25}, + {4.14191e-03, 1.66980e-10, 6.92409e-18, 2.94948e-25}, + {7.18271e-03, 2.89568e-10, 1.20074e-17, 5.11485e-25}, + {1.13364e-02, 4.57021e-10, 1.89512e-17, 8.07269e-25}, + {1.77361e-02, 7.15022e-10, 2.96496e-17, 1.26300e-24}, + {2.59477e-02, 1.04607e-09, 4.33772e-17, 1.84775e-24}, + {3.45425e-02, 1.39257e-09, 5.77452e-17, 2.45980e-24}, + {4.22006e-02, 1.70130e-09, 7.05474e-17, 3.00513e-24}, + {4.71420e-02, 1.90051e-09, 7.88080e-17, 3.35701e-24}, + {4.91934e-02, 1.98321e-09, 8.22373e-17, 3.50309e-24}, + {5.05162e-02, 2.03654e-09, 8.44486e-17, 3.59729e-24}, + {5.78201e-02, 2.33100e-09, 9.66587e-17, 4.11741e-24}, + {8.84237e-02, 3.56477e-09, 1.47819e-16, 6.29671e-24}, + {1.78786e-01, 7.20770e-09, 2.98879e-16, 1.27315e-23}, + {4.36404e-01, 1.75935e-08, 7.29543e-16, 3.10766e-23}, + {1.63796e+00, 6.60337e-08, 2.73820e-15, 1.16640e-22}, + {8.50817e+00, 3.43004e-07, 1.42232e-14, 6.05872e-22}, + {3.92751e+01, 1.58336e-06, 6.56567e-14, 2.79680e-21}, + {1.41436e+02, 5.70194e-06, 2.36441e-13, 1.00718e-20}, + {3.83709e+02, 1.54691e-05, 6.41451e-13, 2.73241e-20}, + {7.70411e+02, 3.10588e-05, 1.28791e-12, 5.48615e-20}, + {1.16399e+03, 4.69258e-05, 1.94586e-12, 8.28884e-20}, + {1.37566e+03, 5.54594e-05, 2.29972e-12, 9.79619e-20}, + {1.33070e+03, 5.36466e-05, 2.22455e-12, 9.47599e-20}, + {1.09978e+03, 4.43371e-05, 1.83852e-12, 7.83159e-20}, + {8.05638e+02, 3.24790e-05, 1.34680e-12, 5.73700e-20}, + {5.38690e+02, 2.17171e-05, 9.00536e-13, 3.83605e-20}, + {3.36338e+02, 1.35593e-05, 5.62261e-13, 2.39508e-20}, + {1.99460e+02, 8.04115e-06, 3.33440e-13, 1.42037e-20}, + {1.13787e+02, 4.58729e-06, 1.90220e-13, 8.10285e-21}, + {6.30411e+01, 2.54148e-06, 1.05387e-13, 4.48920e-21}, + {3.41529e+01, 1.37686e-06, 5.70939e-14, 2.43205e-21}, + {1.81893e+01, 7.33293e-07, 3.04073e-14, 1.29527e-21}, + } + }, + { + /* name = */ "Al2O3_dust", + /* nonprimoridal_yield_frac = */ 3.77811e-18, + /* size_moments = */ {4.03146e-08, 1.67171e-15, 7.12106e-23}, + /* opacity_coef_table = */ { + {1.23620e-05, 4.98882e-13, 2.07138e-20, 8.83538e-28}, + {2.19537e-05, 8.85960e-13, 3.67854e-20, 1.56906e-27}, + {3.40288e-05, 1.37326e-12, 5.70184e-20, 2.43208e-27}, + {4.92305e-05, 1.98674e-12, 8.24901e-20, 3.51856e-27}, + {8.08507e-05, 3.26278e-12, 1.35471e-19, 5.77841e-27}, + {1.25019e-04, 5.04514e-12, 2.09472e-19, 8.93477e-27}, + {1.96584e-04, 7.93293e-12, 3.29363e-19, 1.40481e-26}, + {3.14489e-04, 1.26902e-11, 5.26848e-19, 2.24703e-26}, + {5.06846e-04, 2.04508e-11, 8.48987e-19, 3.62076e-26}, + {8.07280e-04, 3.25711e-11, 1.35207e-18, 5.76597e-26}, + {1.28667e-03, 5.19094e-11, 2.15469e-18, 9.18830e-26}, + {2.05240e-03, 8.27959e-11, 3.43651e-18, 1.46534e-25}, + {3.27023e-03, 1.31912e-10, 5.47463e-18, 2.33420e-25}, + {5.23895e-03, 2.11300e-10, 8.76840e-18, 3.73817e-25}, + {8.45019e-03, 3.40772e-10, 1.41393e-17, 6.02717e-25}, + {1.37157e-02, 5.53037e-10, 2.29434e-17, 9.77885e-25}, + {2.24099e-02, 9.03468e-10, 3.74764e-17, 1.59710e-24}, + {3.70041e-02, 1.49164e-09, 6.18661e-17, 2.63618e-24}, + {6.21584e-02, 2.50530e-09, 1.03896e-16, 4.42660e-24}, + {1.07033e-01, 4.31351e-09, 1.78864e-16, 7.62000e-24}, + {1.90089e-01, 7.66007e-09, 3.17606e-16, 1.35297e-23}, + {3.49470e-01, 1.40818e-08, 5.83831e-16, 2.48691e-23}, + {6.64947e-01, 2.67926e-08, 1.11077e-15, 4.73128e-23}, + {1.30413e+00, 5.25455e-08, 2.17837e-15, 9.27841e-23}, + {2.61640e+00, 1.05417e-07, 4.37015e-15, 1.86136e-22}, + {5.31790e+00, 2.14259e-07, 8.88223e-15, 3.78313e-22}, + {1.08366e+01, 4.36604e-07, 1.80995e-14, 7.70889e-22}, + {2.19132e+01, 8.82874e-07, 3.65995e-14, 1.55883e-21}, + {4.35354e+01, 1.75402e-06, 7.27125e-14, 3.09693e-21}, + {8.42362e+01, 3.39383e-06, 1.40690e-13, 5.99219e-21}, + {1.57704e+02, 6.35380e-06, 2.63395e-13, 1.12183e-20}, + {2.84822e+02, 1.14753e-05, 4.75704e-13, 2.02608e-20}, + {4.96653e+02, 2.00098e-05, 8.29500e-13, 3.53294e-20}, + {8.39966e+02, 3.38417e-05, 1.40289e-12, 5.97510e-20}, + {1.38932e+03, 5.59749e-05, 2.32042e-12, 9.88295e-20}, + } + }, +}; + +} // namespace fsn80 + +namespace pisn170 { +static const MetalNuclideYieldProps metal_props[] = { + // {name, gas_yield, total_yield} + {"C", 5.29528e-02, 5.29975e-02}, + {"O", 5.60799e-01, 5.60864e-01}, + {"Mg", 3.58366e-02, 3.58367e-02}, + {"Al", 3.27680e-04, 3.27680e-04}, + {"Si", 1.39585e-01, 1.52750e-01}, + {"S", 8.06035e-02, 8.06035e-02}, + {"Fe", 5.29394e-02, 5.29729e-02}, +}; + +static const GrainSpeciesYieldProps grain_props[] = { + { + /* name = */ "SiM_dust", + /* nonprimoridal_yield_frac = */ 1.31079e-02, + /* size_moments = */ {2.72050e-06, 2.87427e-11, 7.09270e-16}, + /* opacity_coef_table = */ { + {1.89038e-02, 2.14190e-07, 2.52372e-12, 3.12761e-17}, + {3.29962e-02, 3.72180e-07, 4.35946e-12, 5.36210e-17}, + {5.06585e-02, 5.69928e-07, 6.65321e-12, 8.14803e-17}, + {7.28477e-02, 8.18206e-07, 9.53077e-12, 1.16395e-16}, + {1.17388e-01, 1.31311e-06, 1.52141e-11, 1.84531e-16}, + {1.77851e-01, 1.98324e-06, 2.28841e-11, 2.76089e-16}, + {2.70459e-01, 3.00576e-06, 3.45287e-11, 4.14188e-16}, + {4.11194e-01, 4.55413e-06, 5.20790e-11, 6.21046e-16}, + {6.23355e-01, 6.88052e-06, 7.83314e-11, 9.28691e-16}, + {9.33206e-01, 1.02680e-05, 1.16407e-10, 1.37259e-15}, + {1.38665e+00, 1.52105e-05, 1.71743e-10, 2.01438e-15}, + {2.02921e+00, 2.21948e-05, 2.49647e-10, 2.91351e-15}, + {2.90114e+00, 3.16481e-05, 3.54739e-10, 4.12109e-15}, + {4.04178e+00, 4.39869e-05, 4.91497e-10, 5.68634e-15}, + {5.48102e+00, 5.95254e-05, 6.63275e-10, 7.64576e-15}, + {7.23953e+00, 7.84801e-05, 8.72371e-10, 1.00241e-14}, + {9.32332e+00, 1.00911e-04, 1.11939e-09, 1.28274e-14}, + {1.17250e+01, 1.26738e-04, 1.40342e-09, 1.60451e-14}, + {1.44493e+01, 1.56015e-04, 1.72511e-09, 1.96853e-14}, + {1.75655e+01, 1.89497e-04, 2.09290e-09, 2.38454e-14}, + {2.12689e+01, 2.29295e-04, 2.53020e-09, 2.87941e-14}, + {2.59441e+01, 2.79574e-04, 3.08321e-09, 3.50603e-14}, + {3.22597e+01, 3.47571e-04, 3.83222e-09, 4.35643e-14}, + {4.13113e+01, 4.45148e-04, 4.90883e-09, 5.58148e-14}, + {5.48617e+01, 5.91330e-04, 6.52336e-09, 7.42101e-14}, + {7.57474e+01, 8.16590e-04, 9.01042e-09, 1.02534e-13}, + {1.08611e+02, 1.17059e-03, 1.29124e-08, 1.46875e-13}, + {1.61171e+02, 1.73570e-03, 1.91260e-08, 2.17252e-13}, + {2.46323e+02, 2.64930e-03, 2.91428e-08, 3.30280e-13}, + {3.85260e+02, 4.13661e-03, 4.54013e-08, 5.13015e-13}, + {6.12075e+02, 6.55899e-03, 7.17997e-08, 8.08495e-13}, + {9.79548e+02, 1.04742e-02, 1.14330e-07, 1.28253e-12}, + {1.56260e+03, 1.66712e-02, 1.81431e-07, 2.02722e-12}, + {2.44258e+03, 2.60024e-02, 2.82158e-07, 3.14054e-12}, + {3.65611e+03, 3.88442e-02, 4.20404e-07, 4.66303e-12}, + } + }, + { + /* name = */ "FeM_dust", + /* nonprimoridal_yield_frac = */ 3.34688e-05, + /* size_moments = */ {1.08069e-05, 1.19634e-10, 1.36724e-15}, + /* opacity_coef_table = */ { + {1.05240e-01, 1.88391e-06, 3.41670e-11, 6.27487e-16}, + {1.32588e-01, 2.37346e-06, 4.30456e-11, 7.90546e-16}, + {1.67016e-01, 2.98977e-06, 5.42231e-11, 9.95825e-16}, + {2.10360e-01, 3.76566e-06, 6.82948e-11, 1.25426e-15}, + {2.71891e-01, 4.86713e-06, 8.82715e-11, 1.62113e-15}, + {3.55703e-01, 6.36747e-06, 1.15482e-10, 2.12086e-15}, + {4.84952e-01, 8.68116e-06, 1.57444e-10, 2.89150e-15}, + {6.99815e-01, 1.25274e-05, 2.27201e-10, 4.17262e-15}, + {1.05872e+00, 1.89523e-05, 3.43724e-10, 6.31261e-15}, + {1.62931e+00, 2.91665e-05, 5.28972e-10, 9.71478e-15}, + {2.54332e+00, 4.55285e-05, 8.25720e-10, 1.51647e-14}, + {3.96674e+00, 7.10095e-05, 1.28786e-09, 2.36521e-14}, + {6.11063e+00, 1.09388e-04, 1.98392e-09, 3.64359e-14}, + {9.29771e+00, 1.66443e-04, 3.01871e-09, 5.54408e-14}, + {1.39496e+01, 2.49721e-04, 4.52916e-09, 8.31823e-14}, + {2.05907e+01, 3.68616e-04, 6.68568e-09, 1.22791e-13}, + {3.01907e+01, 5.40495e-04, 9.80342e-09, 1.80058e-13}, + {4.58362e+01, 8.20646e-04, 1.48857e-08, 2.73420e-13}, + {7.56329e+01, 1.35424e-03, 2.45668e-08, 4.51281e-13}, + {1.31563e+02, 2.35588e-03, 4.27405e-08, 7.85179e-13}, + {2.18570e+02, 3.91412e-03, 7.10137e-08, 1.30465e-12}, + {3.26293e+02, 5.84347e-03, 1.06022e-07, 1.94790e-12}, + {4.39310e+02, 7.86786e-03, 1.42760e-07, 2.62299e-12}, + {5.43909e+02, 9.74168e-03, 1.76768e-07, 3.24798e-12}, + {6.15422e+02, 1.10228e-02, 2.00021e-07, 3.67534e-12}, + {6.22866e+02, 1.11563e-02, 2.02446e-07, 3.71993e-12}, + {5.58030e+02, 9.99504e-03, 1.81374e-07, 3.33274e-12}, + {4.45434e+02, 7.97833e-03, 1.44778e-07, 2.66031e-12}, + {3.22068e+02, 5.76874e-03, 1.04683e-07, 1.92357e-12}, + {2.15071e+02, 3.85233e-03, 6.99082e-08, 1.28461e-12}, + {1.35309e+02, 2.42376e-03, 4.39862e-08, 8.08311e-13}, + {8.22952e+01, 1.47437e-03, 2.67608e-08, 4.91842e-13}, + {5.06858e+01, 9.08497e-04, 1.64974e-08, 3.03339e-13}, + {3.39204e+01, 6.08602e-04, 1.10623e-08, 2.03592e-13}, + {2.60778e+01, 4.68473e-04, 8.52552e-09, 1.57083e-13}, + } + }, + { + /* name = */ "Mg2SiO4_dust", + /* nonprimoridal_yield_frac = */ 2.84952e-13, + /* size_moments = */ {1.79010e-05, 3.24658e-10, 5.96244e-15}, + /* opacity_coef_table = */ { + {2.19890e-02, 5.52339e-07, 1.38741e-11, 3.48502e-16}, + {3.90618e-02, 9.81187e-07, 2.46463e-11, 6.19087e-16}, + {6.05551e-02, 1.52108e-06, 3.82077e-11, 9.59734e-16}, + {8.76136e-02, 2.20075e-06, 5.52805e-11, 1.38858e-15}, + {1.43295e-01, 3.59940e-06, 9.04128e-11, 2.27107e-15}, + {2.19281e-01, 5.50809e-06, 1.38357e-10, 3.47537e-15}, + {3.36283e-01, 8.44705e-06, 2.12180e-10, 5.32973e-15}, + {5.14405e-01, 1.29213e-05, 3.24567e-10, 8.15276e-15}, + {7.97396e-01, 2.00297e-05, 5.03123e-10, 1.26379e-14}, + {1.25461e+00, 3.15143e-05, 7.91604e-10, 1.98842e-14}, + {2.03570e+00, 5.11345e-05, 1.28444e-09, 3.22637e-14}, + {3.34964e+00, 8.41390e-05, 2.11348e-09, 5.30881e-14}, + {5.46697e+00, 1.37324e-04, 3.44942e-09, 8.66456e-14}, + {8.84149e+00, 2.22088e-04, 5.57860e-09, 1.40128e-13}, + {1.42340e+01, 3.57543e-04, 8.98107e-09, 2.25594e-13}, + {2.29730e+01, 5.77056e-04, 1.44950e-08, 3.64097e-13}, + {3.74525e+01, 9.40765e-04, 2.36310e-08, 5.93583e-13}, + {6.22721e+01, 1.56420e-03, 3.92910e-08, 9.86946e-13}, + {1.05860e+02, 2.65909e-03, 6.67934e-08, 1.67777e-12}, + {1.79797e+02, 4.51630e-03, 1.13444e-07, 2.84959e-12}, + {2.89938e+02, 7.28291e-03, 1.82938e-07, 4.59521e-12}, + {4.27133e+02, 1.07291e-02, 2.69503e-07, 6.76961e-12}, + {5.77898e+02, 1.45162e-02, 3.64629e-07, 9.15907e-12}, + {7.33244e+02, 1.84183e-02, 4.62646e-07, 1.16211e-11}, + {8.63989e+02, 2.17024e-02, 5.45140e-07, 1.36933e-11}, + {9.15488e+02, 2.29960e-02, 5.77634e-07, 1.45095e-11}, + {8.55336e+02, 2.14851e-02, 5.39680e-07, 1.35562e-11}, + {7.06445e+02, 1.77451e-02, 4.45737e-07, 1.11964e-11}, + {5.24103e+02, 1.31649e-02, 3.30686e-07, 8.30647e-12}, + {3.56328e+02, 8.95056e-03, 2.24828e-07, 5.64742e-12}, + {2.26296e+02, 5.68431e-03, 1.42783e-07, 3.58656e-12}, + {1.36494e+02, 3.42857e-03, 8.61218e-08, 2.16328e-12}, + {7.93347e+01, 1.99280e-03, 5.00568e-08, 1.25737e-12}, + {4.50672e+01, 1.13204e-03, 2.84355e-08, 7.14267e-13}, + {2.56082e+01, 6.43249e-04, 1.61577e-08, 4.05863e-13}, + } + }, + { + /* name = */ "MgSiO3_dust", + /* nonprimoridal_yield_frac = */ 7.72302e-25, + /* size_moments = */ {2.51189e-05, 6.30957e-10, 1.58489e-14}, + /* opacity_coef_table = */ { + {3.27960e-01, 2.72950e-07, 4.37442e-13, 1.43560e-18}, + {4.38752e-01, 3.65158e-07, 5.85222e-13, 1.92064e-18}, + {5.78230e-01, 4.81242e-07, 7.71265e-13, 2.53127e-18}, + {7.53823e-01, 6.27382e-07, 1.00548e-12, 3.30001e-18}, + {1.04013e+00, 8.65671e-07, 1.38740e-12, 4.55369e-18}, + {1.41735e+00, 1.17963e-06, 1.89059e-12, 6.20550e-18}, + {1.95292e+00, 1.62537e-06, 2.60499e-12, 8.55074e-18}, + {2.71531e+00, 2.25988e-06, 3.62196e-12, 1.18896e-17}, + {3.79676e+00, 3.15995e-06, 5.06464e-12, 1.66270e-17}, + {5.29743e+00, 4.40895e-06, 7.06667e-12, 2.32024e-17}, + {7.37835e+00, 6.14088e-06, 9.84291e-12, 3.23229e-17}, + {1.02168e+01, 8.50337e-06, 1.36303e-11, 4.47703e-17}, + {1.40421e+01, 1.16873e-05, 1.87349e-11, 6.15552e-17}, + {1.92022e+01, 1.59823e-05, 2.56223e-11, 8.42199e-17}, + {2.61618e+01, 2.17754e-05, 3.49137e-11, 1.14828e-16}, + {3.55310e+01, 2.95745e-05, 4.74267e-11, 1.56111e-16}, + {4.81618e+01, 4.00896e-05, 6.43047e-11, 2.11918e-16}, + {6.53182e+01, 5.43738e-05, 8.72469e-11, 2.88010e-16}, + {8.87691e+01, 7.39018e-05, 1.18639e-10, 3.92576e-16}, + {1.20709e+02, 1.00504e-04, 1.61458e-10, 5.36074e-16}, + {1.63629e+02, 1.36264e-04, 2.19128e-10, 7.31160e-16}, + {2.20590e+02, 1.83746e-04, 2.95924e-10, 9.94659e-16}, + {2.96134e+02, 2.46760e-04, 3.98255e-10, 1.35250e-15}, + {3.97082e+02, 3.31036e-04, 5.35697e-10, 1.84221e-15}, + {5.31629e+02, 4.43468e-04, 7.19648e-10, 2.50526e-15}, + {7.07172e+02, 5.90324e-04, 9.60341e-10, 3.37390e-15}, + {9.31294e+02, 7.78129e-04, 1.26840e-09, 4.47614e-15}, + {1.21722e+03, 1.01834e-03, 1.66280e-09, 5.86569e-15}, + {1.58885e+03, 1.33177e-03, 2.17875e-09, 7.65284e-15}, + {2.08299e+03, 1.75095e-03, 2.87268e-09, 1.00241e-14}, + {2.75132e+03, 2.32265e-03, 3.82862e-09, 1.32680e-14}, + {3.66587e+03, 3.11403e-03, 5.17218e-09, 1.78307e-14}, + {4.93093e+03, 4.22440e-03, 7.09398e-09, 2.43990e-14}, + {6.70346e+03, 5.80132e-03, 9.87242e-09, 3.39492e-14}, + {9.22475e+03, 8.05642e-03, 1.38679e-08, 4.76003e-14}, + } + }, + { + /* name = */ "AC_dust", + /* nonprimoridal_yield_frac = */ 4.47758e-05, + /* size_moments = */ {8.32266e-07, 1.33383e-12, 4.37739e-18}, + /* opacity_coef_table = */ { + {7.60055e-02, 1.61556e-06, 3.49407e-11, 7.72118e-16}, + {9.06897e-02, 1.92769e-06, 4.16913e-11, 9.21295e-16}, + {1.09176e-01, 2.32063e-06, 5.01898e-11, 1.10910e-15}, + {1.32449e-01, 2.81532e-06, 6.08888e-11, 1.34553e-15}, + {1.58880e-01, 3.37714e-06, 7.30398e-11, 1.61404e-15}, + {1.91543e-01, 4.07143e-06, 8.80558e-11, 1.94587e-15}, + {2.30474e-01, 4.89894e-06, 1.05953e-10, 2.34138e-15}, + {2.76789e-01, 5.88341e-06, 1.27245e-10, 2.81190e-15}, + {3.33087e-01, 7.08010e-06, 1.53127e-10, 3.38385e-15}, + {4.05372e-01, 8.61660e-06, 1.86359e-10, 4.11822e-15}, + {5.08264e-01, 1.08037e-05, 2.33661e-10, 5.16354e-15}, + {6.72714e-01, 1.42993e-05, 3.09265e-10, 6.83430e-15}, + {9.49132e-01, 2.01750e-05, 4.36348e-10, 9.64271e-15}, + {1.41935e+00, 3.01704e-05, 6.52536e-10, 1.44204e-14}, + {2.19866e+00, 4.67362e-05, 1.01084e-09, 2.23390e-14}, + {3.47731e+00, 7.39180e-05, 1.59880e-09, 3.53339e-14}, + {5.80454e+00, 1.23397e-04, 2.66922e-09, 5.89965e-14}, + {1.18802e+01, 2.52595e-04, 5.46495e-09, 1.20817e-13}, + {3.22814e+01, 6.86446e-04, 1.48537e-08, 3.28442e-13}, + {8.86792e+01, 1.88575e-03, 4.08062e-08, 9.02327e-13}, + {1.96255e+02, 4.17327e-03, 9.03045e-08, 1.99681e-12}, + {3.42549e+02, 7.28388e-03, 1.57607e-07, 3.48479e-12}, + {5.11736e+02, 1.08798e-02, 2.35370e-07, 5.20299e-12}, + {7.16479e+02, 1.52272e-02, 3.29269e-07, 7.27459e-12}, + {9.48899e+02, 2.01568e-02, 4.35598e-07, 9.61645e-12}, + {1.12707e+03, 2.39309e-02, 5.16871e-07, 1.14029e-11}, + {1.15762e+03, 2.45716e-02, 5.30490e-07, 1.16974e-11}, + {1.02786e+03, 2.18125e-02, 4.70793e-07, 1.03775e-11}, + {8.04358e+02, 1.70671e-02, 3.68303e-07, 8.11658e-12}, + {5.68400e+02, 1.20593e-02, 2.60207e-07, 5.73357e-12}, + {3.70952e+02, 7.86976e-03, 1.69795e-07, 3.74103e-12}, + {2.27785e+02, 4.83229e-03, 1.04255e-07, 2.29687e-12}, + {1.33544e+02, 2.83297e-03, 6.11184e-08, 1.34647e-12}, + {7.56194e+01, 1.60416e-03, 3.46077e-08, 7.62416e-13}, + {4.17402e+01, 8.85464e-04, 1.91029e-08, 4.20847e-13}, + } + }, + { + /* name = */ "SiO2_dust", + /* nonprimoridal_yield_frac = */ 1.23405e-04, + /* size_moments = */ {2.12560e-05, 4.59721e-10, 1.01590e-14}, + /* opacity_coef_table = */ { + {2.25358e-04, 3.62400e-09, 5.98548e-14, 1.01451e-18}, + {4.04933e-04, 6.51178e-09, 1.07551e-13, 1.82293e-18}, + {6.31005e-04, 1.01473e-08, 1.67596e-13, 2.84068e-18}, + {9.15612e-04, 1.47241e-08, 2.43188e-13, 4.12194e-18}, + {1.52196e-03, 2.44750e-08, 4.04238e-13, 6.85169e-18}, + {2.37413e-03, 3.81788e-08, 6.30577e-13, 1.06881e-17}, + {3.77230e-03, 6.06633e-08, 1.00194e-12, 1.69826e-17}, + {6.14410e-03, 9.88050e-08, 1.63191e-12, 2.76605e-17}, + {1.01925e-02, 1.63910e-07, 2.70723e-12, 4.58870e-17}, + {1.68946e-02, 2.71691e-07, 4.48743e-12, 7.60616e-17}, + {2.96294e-02, 4.76492e-07, 7.87018e-12, 1.33401e-16}, + {6.11307e-02, 9.83118e-07, 1.62386e-11, 2.75255e-16}, + {1.43660e-01, 2.31047e-06, 3.81646e-11, 6.46939e-16}, + {3.28203e-01, 5.27865e-06, 8.71964e-11, 1.47815e-15}, + {6.41613e-01, 1.03199e-05, 1.70479e-10, 2.89009e-15}, + {1.05901e+00, 1.70371e-05, 2.81505e-10, 4.77324e-15}, + {1.60722e+00, 2.58913e-05, 4.28363e-10, 7.27252e-15}, + {3.19739e+00, 5.16560e-05, 8.57040e-10, 1.45895e-14}, + {1.40905e+01, 2.27322e-04, 3.76636e-09, 6.40310e-14}, + {7.15093e+01, 1.15025e-03, 1.90029e-08, 3.22170e-13}, + {2.48952e+02, 3.99764e-03, 6.59323e-08, 1.11600e-12}, + {5.77048e+02, 9.25757e-03, 1.52545e-07, 2.57979e-12}, + {9.46693e+02, 1.51796e-02, 2.49995e-07, 4.22569e-12}, + {1.17600e+03, 1.88501e-02, 3.10343e-07, 5.24410e-12}, + {1.17447e+03, 1.88215e-02, 3.09806e-07, 5.23395e-12}, + {9.91612e+02, 1.58888e-02, 2.61497e-07, 4.41720e-12}, + {7.37095e+02, 1.18095e-02, 1.94341e-07, 3.28252e-12}, + {4.97965e+02, 7.97772e-03, 1.31276e-07, 2.21717e-12}, + {3.13212e+02, 5.01764e-03, 8.25631e-08, 1.39438e-12}, + {1.86742e+02, 2.99150e-03, 4.92223e-08, 8.31277e-13}, + {1.06960e+02, 1.71340e-03, 2.81918e-08, 4.76098e-13}, + {5.94287e+01, 9.51978e-04, 1.56633e-08, 2.64516e-13}, + {3.22675e+01, 5.16881e-04, 8.50437e-09, 1.43617e-13}, + {1.72142e+01, 2.75746e-04, 4.53688e-09, 7.66156e-14}, + {9.06015e+00, 1.45130e-04, 2.38782e-09, 4.03237e-14}, + } + }, + { + /* name = */ "MgO_dust", + /* nonprimoridal_yield_frac = */ 1.41247e-07, + /* size_moments = */ {1.60812e-05, 2.65603e-10, 4.50188e-15}, + /* opacity_coef_table = */ { + {1.54566e-01, 4.18815e-07, 4.38802e-12, 1.07634e-16}, + {1.94597e-01, 5.27516e-07, 5.53200e-12, 1.35785e-16}, + {2.44992e-01, 6.64362e-07, 6.97216e-12, 1.71223e-16}, + {3.08437e-01, 8.36640e-07, 8.78521e-12, 2.15837e-16}, + {3.88320e-01, 1.05373e-06, 1.10736e-11, 2.72217e-16}, + {4.88890e-01, 1.32707e-06, 1.39559e-11, 3.43241e-16}, + {6.15507e-01, 1.67134e-06, 1.75891e-11, 4.32825e-16}, + {7.74906e-01, 2.10492e-06, 2.21686e-11, 5.45804e-16}, + {9.75270e-01, 2.65013e-06, 2.79315e-11, 6.88059e-16}, + {1.22485e+00, 3.32948e-06, 3.51169e-11, 8.65513e-16}, + {1.52110e+00, 4.13615e-06, 4.36560e-11, 1.07652e-15}, + {1.83679e+00, 4.99624e-06, 5.27698e-11, 1.30190e-15}, + {2.15666e+00, 5.86838e-06, 6.20278e-11, 1.53115e-15}, + {2.55518e+00, 6.95661e-06, 7.36137e-11, 1.81866e-15}, + {3.22834e+00, 8.79676e-06, 9.32496e-11, 2.30667e-15}, + {4.33225e+00, 1.18177e-05, 1.25559e-10, 3.11092e-15}, + {5.81697e+00, 1.58892e-05, 1.69288e-10, 4.20258e-15}, + {7.48671e+00, 2.04890e-05, 2.19146e-10, 5.45508e-15}, + {9.22042e+00, 2.53165e-05, 2.72602e-10, 6.81745e-15}, + {1.12094e+01, 3.09883e-05, 3.38326e-10, 8.54226e-15}, + {1.40327e+01, 3.92793e-05, 4.39589e-10, 1.12871e-14}, + {1.79556e+01, 5.11182e-05, 5.91090e-10, 1.55105e-14}, + {2.19076e+01, 6.38759e-05, 7.72200e-10, 2.08556e-14}, + {2.40396e+01, 7.32505e-05, 9.56570e-10, 2.71081e-14}, + {2.35050e+01, 7.74606e-05, 1.14341e-09, 3.48207e-14}, + {2.10698e+01, 7.75334e-05, 1.32500e-09, 4.37333e-14}, + {1.81145e+01, 7.52350e-05, 1.46962e-09, 5.20115e-14}, + {1.55283e+01, 7.16932e-05, 1.54535e-09, 5.74821e-14}, + {1.35973e+01, 6.77513e-05, 1.55041e-09, 5.93660e-14}, + {1.28568e+01, 6.72854e-05, 1.57294e-09, 6.05730e-14}, + {1.62414e+01, 9.03391e-05, 2.02876e-09, 7.45675e-14}, + {3.62078e+01, 2.25165e-04, 4.46960e-09, 1.44123e-13}, + {1.13353e+02, 7.52538e-04, 1.29670e-08, 3.61005e-13}, + {3.52139e+02, 2.31091e-03, 3.53205e-08, 8.74277e-13}, + {9.61671e+02, 5.84143e-03, 8.01724e-08, 1.81153e-12}, + } + }, +}; + +} // namespace pisn170 + +namespace pisn200 { +static const MetalNuclideYieldProps metal_props[] = { + // {name, gas_yield, total_yield} + {"C", 3.64677e-02, 3.65050e-02}, + {"O", 4.88307e-01, 4.88552e-01}, + {"Mg", 2.69665e-02, 2.69665e-02}, + {"Al", 1.36872e-04, 1.36872e-04}, + {"Si", 1.87051e-01, 1.87324e-01}, + {"S", 1.15582e-01, 1.15582e-01}, + {"Fe", 6.75026e-02, 6.79294e-02}, +}; + +static const GrainSpeciesYieldProps grain_props[] = { + { + /* name = */ "SiM_dust", + /* nonprimoridal_yield_frac = */ 5.90622e-05, + /* size_moments = */ {8.86269e-07, 1.71166e-12, 5.46663e-18}, + /* opacity_coef_table = */ { + {9.09085e-04, 3.41941e-09, 1.80920e-14, 1.27369e-19}, + {1.61039e-03, 6.04845e-09, 3.18823e-14, 2.22622e-19}, + {2.49320e-03, 9.35673e-09, 4.92187e-14, 3.42113e-19}, + {3.60452e-03, 1.35207e-08, 7.10297e-14, 4.92299e-19}, + {5.89215e-03, 2.20677e-08, 1.15535e-13, 7.95087e-19}, + {9.02912e-03, 3.37737e-08, 1.76355e-13, 1.20713e-18}, + {1.39130e-02, 5.19580e-08, 2.70494e-13, 1.84076e-18}, + {2.14719e-02, 8.00206e-08, 4.15192e-13, 2.80850e-18}, + {3.30912e-02, 1.23012e-07, 6.35936e-13, 4.27570e-18}, + {5.03917e-02, 1.86799e-07, 9.62098e-13, 6.43127e-18}, + {7.63291e-02, 2.81960e-07, 1.44615e-12, 9.61004e-18}, + {1.14179e-01, 4.19929e-07, 2.14346e-12, 1.41576e-17}, + {1.67303e-01, 6.12055e-07, 3.10728e-12, 2.03974e-17}, + {2.39689e-01, 8.71248e-07, 4.39580e-12, 2.86715e-17}, + {3.35470e-01, 1.21013e-06, 6.06256e-12, 3.92787e-17}, + {4.59119e-01, 1.64148e-06, 8.15789e-12, 5.24812e-17}, + {6.15407e-01, 2.17768e-06, 1.07246e-11, 6.84719e-17}, + {8.10332e-01, 2.83301e-06, 1.38055e-11, 8.74075e-17}, + {1.05438e+00, 3.63322e-06, 1.74835e-11, 1.09639e-16}, + {1.37021e+00, 4.63773e-06, 2.19726e-11, 1.36212e-16}, + {1.80496e+00, 5.97282e-06, 2.77433e-11, 1.69529e-16}, + {2.45118e+00, 7.88356e-06, 3.57016e-11, 2.14206e-16}, + {3.48432e+00, 1.08228e-05, 4.74799e-11, 2.78412e-16}, + {5.23381e+00, 1.56143e-05, 6.59474e-11, 3.76121e-16}, + {8.31585e+00, 2.37506e-05, 9.61230e-11, 5.31044e-16}, + {1.38802e+01, 3.79407e-05, 1.46823e-10, 7.83600e-16}, + {2.40529e+01, 6.30826e-05, 2.33568e-10, 1.20322e-15}, + {4.26908e+01, 1.07918e-04, 3.83527e-10, 1.90929e-15}, + {7.65687e+01, 1.87651e-04, 6.43418e-10, 3.10502e-15}, + {1.37077e+02, 3.27739e-04, 1.09108e-09, 5.12746e-15}, + {2.42517e+02, 5.69117e-04, 1.85185e-09, 8.51948e-15}, + {4.21112e+02, 9.75067e-04, 3.11997e-09, 1.41236e-14}, + {7.14738e+02, 1.63904e-03, 5.18038e-09, 2.31656e-14}, + {1.18235e+03, 2.68818e-03, 8.40281e-09, 3.71602e-14}, + {1.90342e+03, 4.27908e-03, 1.31829e-08, 5.74720e-14}, + } + }, + { + /* name = */ "FeM_dust", + /* nonprimoridal_yield_frac = */ 4.26809e-04, + /* size_moments = */ {2.02272e-06, 5.41308e-12, 2.06248e-17}, + /* opacity_coef_table = */ { + {1.05240e-01, 1.49640e-06, 2.15567e-11, 3.14463e-16}, + {1.32588e-01, 1.88525e-06, 2.71584e-11, 3.96179e-16}, + {1.67016e-01, 2.37479e-06, 3.42106e-11, 4.99054e-16}, + {2.10360e-01, 2.99108e-06, 4.30887e-11, 6.28566e-16}, + {2.71889e-01, 3.86597e-06, 5.56922e-11, 8.12421e-16}, + {3.55700e-01, 5.05766e-06, 7.28594e-11, 1.06285e-15}, + {4.84944e-01, 6.89538e-06, 9.93331e-11, 1.44904e-15}, + {6.99796e-01, 9.95035e-06, 1.43342e-10, 2.09104e-15}, + {1.05867e+00, 1.50532e-05, 2.16853e-10, 3.16340e-15}, + {1.62919e+00, 2.31655e-05, 3.33717e-10, 4.86818e-15}, + {2.54303e+00, 3.61594e-05, 5.20906e-10, 7.59887e-15}, + {3.96603e+00, 5.63932e-05, 8.12393e-10, 1.18511e-14}, + {6.10897e+00, 8.68643e-05, 1.25136e-09, 1.82548e-14}, + {9.29384e+00, 1.32151e-04, 1.90378e-09, 2.77724e-14}, + {1.39407e+01, 1.98229e-04, 2.85574e-09, 4.16600e-14}, + {2.05705e+01, 2.92507e-04, 4.21400e-09, 6.14759e-14}, + {3.01423e+01, 4.28630e-04, 6.17529e-09, 9.00909e-14}, + {4.57104e+01, 6.50055e-04, 9.36595e-09, 1.36648e-13}, + {7.53064e+01, 1.07104e-03, 1.54328e-08, 2.25181e-13}, + {1.30815e+02, 1.86065e-03, 2.68126e-08, 3.91253e-13}, + {2.17127e+02, 3.08849e-03, 4.45083e-08, 6.49502e-13}, + {3.23880e+02, 4.60717e-03, 6.63972e-08, 9.68963e-13}, + {4.35662e+02, 6.19759e-03, 8.93224e-08, 1.30358e-12}, + {5.38932e+02, 7.66706e-03, 1.10506e-07, 1.61282e-12}, + {6.09467e+02, 8.67078e-03, 1.24977e-07, 1.82406e-12}, + {6.16707e+02, 8.77390e-03, 1.26464e-07, 1.84580e-12}, + {5.52479e+02, 7.86016e-03, 1.13294e-07, 1.65358e-12}, + {4.40975e+02, 6.27379e-03, 9.04293e-08, 1.31986e-12}, + {3.18791e+02, 4.53552e-03, 6.53747e-08, 9.54183e-13}, + {2.12803e+02, 3.02766e-03, 4.36414e-08, 6.36986e-13}, + {1.33761e+02, 1.90318e-03, 2.74344e-08, 4.00448e-13}, + {8.11305e+01, 1.15453e-03, 1.66451e-08, 2.42996e-13}, + {4.95598e+01, 7.05594e-04, 1.01773e-08, 1.48640e-13}, + {3.25906e+01, 4.64465e-04, 6.70585e-09, 9.80294e-14}, + {2.45153e+01, 3.49814e-04, 5.05664e-09, 7.40047e-14}, + } + }, + { + /* name = */ "Mg2SiO4_dust", + /* nonprimoridal_yield_frac = */ 4.08246e-15, + /* size_moments = */ {1.42189e-05, 2.04834e-10, 2.98805e-15}, + /* opacity_coef_table = */ { + {3.27960e-01, 2.44690e-07, 3.05689e-13, 6.54462e-19}, + {4.38752e-01, 3.27351e-07, 4.08957e-13, 8.75569e-19}, + {5.78230e-01, 4.31415e-07, 5.38965e-13, 1.15393e-18}, + {7.53823e-01, 5.62424e-07, 7.02635e-13, 1.50436e-18}, + {1.04013e+00, 7.76039e-07, 9.69511e-13, 2.07581e-18}, + {1.41735e+00, 1.05749e-06, 1.32113e-12, 2.82873e-18}, + {1.95292e+00, 1.45707e-06, 1.82034e-12, 3.89771e-18}, + {2.71531e+00, 2.02589e-06, 2.53098e-12, 5.41951e-18}, + {3.79675e+00, 2.83276e-06, 3.53905e-12, 7.57851e-18}, + {5.29742e+00, 3.95242e-06, 4.93793e-12, 1.05749e-17}, + {7.37833e+00, 5.50501e-06, 6.87773e-12, 1.47304e-17}, + {1.02168e+01, 7.62282e-06, 9.52385e-12, 2.04006e-17}, + {1.40421e+01, 1.04770e-05, 1.30901e-11, 2.80446e-17}, + {1.92021e+01, 1.43270e-05, 1.79012e-11, 3.83618e-17}, + {2.61616e+01, 1.95199e-05, 2.43907e-11, 5.22874e-17}, + {3.55307e+01, 2.65108e-05, 3.31285e-11, 7.10543e-17}, + {4.81611e+01, 3.59357e-05, 4.49107e-11, 9.63939e-17}, + {6.53170e+01, 4.87382e-05, 6.09196e-11, 1.30888e-16}, + {8.87668e+01, 6.62390e-05, 8.28118e-11, 1.78181e-16}, + {1.20705e+02, 9.00772e-05, 1.12647e-10, 2.42873e-16}, + {1.63621e+02, 1.22115e-04, 1.52778e-10, 3.30388e-16}, + {2.20575e+02, 1.64642e-04, 2.06114e-10, 4.47715e-16}, + {2.96104e+02, 2.21060e-04, 2.76991e-10, 6.05473e-16}, + {3.97026e+02, 2.96479e-04, 3.71917e-10, 8.19263e-16}, + {5.31526e+02, 3.97049e-04, 4.98696e-10, 1.10695e-15}, + {7.06983e+02, 5.28345e-04, 6.64405e-10, 1.48343e-15}, + {9.30949e+02, 6.96139e-04, 8.76417e-10, 1.96294e-15}, + {1.21659e+03, 9.10536e-04, 1.14776e-09, 2.57160e-15}, + {1.58765e+03, 1.18982e-03, 1.50225e-09, 3.36001e-15}, + {2.08069e+03, 1.56242e-03, 1.97748e-09, 4.41103e-15}, + {2.74685e+03, 2.06876e-03, 2.62823e-09, 5.84923e-15}, + {3.65712e+03, 2.76611e-03, 3.53431e-09, 7.86205e-15}, + {4.91402e+03, 3.73838e-03, 4.81486e-09, 1.07337e-14}, + {6.67206e+03, 5.11081e-03, 6.64539e-09, 1.48739e-14}, + {9.17096e+03, 7.06881e-03, 9.26820e-09, 2.07940e-14}, + } + }, + { + /* name = */ "AC_dust", + /* nonprimoridal_yield_frac = */ 3.72287e-05, + /* size_moments = */ {7.46096e-07, 9.32091e-13, 1.99556e-18}, + /* opacity_coef_table = */ { + {7.60136e-02, 1.31860e-06, 2.34539e-11, 4.30529e-16}, + {9.06981e-02, 1.57333e-06, 2.79848e-11, 5.13702e-16}, + {1.09185e-01, 1.89402e-06, 3.36890e-11, 6.18411e-16}, + {1.32458e-01, 2.29774e-06, 4.08700e-11, 7.50232e-16}, + {1.58888e-01, 2.75623e-06, 4.90252e-11, 8.99935e-16}, + {1.91549e-01, 3.32281e-06, 5.91032e-11, 1.08494e-15}, + {2.30478e-01, 3.99813e-06, 7.11152e-11, 1.30544e-15}, + {2.76790e-01, 4.80151e-06, 8.54053e-11, 1.56776e-15}, + {3.33085e-01, 5.77806e-06, 1.02776e-10, 1.88663e-15}, + {4.05362e-01, 7.03188e-06, 1.25078e-10, 2.29603e-15}, + {5.08238e-01, 8.81651e-06, 1.56822e-10, 2.87877e-15}, + {6.72650e-01, 1.16686e-05, 2.07555e-10, 3.81010e-15}, + {9.48976e-01, 1.64623e-05, 2.92824e-10, 5.37545e-15}, + {1.41897e+00, 2.46158e-05, 4.37862e-10, 8.03808e-15}, + {2.19768e+00, 3.81252e-05, 6.78181e-10, 1.24501e-14}, + {3.47459e+00, 6.02792e-05, 1.07231e-09, 1.96868e-14}, + {5.79486e+00, 1.00542e-04, 1.78877e-09, 3.28453e-14}, + {1.18370e+01, 2.05418e-04, 3.65563e-09, 6.71473e-14}, + {3.21108e+01, 5.57348e-04, 9.92083e-09, 1.82279e-13}, + {8.81851e+01, 1.53068e-03, 2.72473e-08, 5.00649e-13}, + {1.95201e+02, 3.38815e-03, 6.03099e-08, 1.10811e-12}, + {3.40883e+02, 5.91645e-03, 1.05307e-07, 1.93471e-12}, + {5.10268e+02, 8.85442e-03, 1.57557e-07, 2.89365e-12}, + {7.17917e+02, 1.24511e-02, 2.21410e-07, 4.06297e-12}, + {9.57120e+02, 1.65879e-02, 2.94709e-07, 5.40198e-12}, + {1.14369e+03, 1.98088e-02, 3.51649e-07, 6.43917e-12}, + {1.17995e+03, 2.04271e-02, 3.62410e-07, 6.63127e-12}, + {1.05086e+03, 1.81866e-02, 3.22531e-07, 5.89860e-12}, + {8.23986e+02, 1.42573e-02, 2.52780e-07, 4.62145e-12}, + {5.83014e+02, 1.00864e-02, 1.78801e-07, 3.26825e-12}, + {3.80801e+02, 6.58750e-03, 1.16763e-07, 2.13399e-12}, + {2.33954e+02, 4.04697e-03, 7.17275e-08, 1.31079e-12}, + {1.37203e+02, 2.37328e-03, 4.20617e-08, 7.68622e-13}, + {7.77017e+01, 1.34403e-03, 2.38199e-08, 4.35268e-13}, + {4.28856e+01, 7.41814e-04, 1.31471e-08, 2.40245e-13}, + } + }, + { + /* name = */ "SiO2_dust", + /* nonprimoridal_yield_frac = */ 4.59330e-04, + /* size_moments = */ {1.73471e-05, 3.08556e-10, 5.66409e-15}, + /* opacity_coef_table = */ { + {2.25374e-04, 2.84663e-09, 3.59861e-14, 4.55424e-19}, + {4.04950e-04, 5.11481e-09, 6.46597e-14, 8.18303e-19}, + {6.31024e-04, 7.97028e-09, 1.00758e-13, 1.27514e-18}, + {9.15633e-04, 1.15651e-08, 1.46202e-13, 1.85026e-18}, + {1.52197e-03, 1.92235e-08, 2.43017e-13, 3.07552e-18}, + {2.37410e-03, 2.99866e-08, 3.79080e-13, 4.79746e-18}, + {3.77219e-03, 4.76455e-08, 6.02318e-13, 7.62266e-18}, + {6.14378e-03, 7.76004e-08, 9.80998e-13, 1.24151e-17}, + {1.01916e-02, 1.28728e-07, 1.62733e-12, 2.05948e-17}, + {1.68921e-02, 2.13360e-07, 2.69722e-12, 3.41348e-17}, + {2.96213e-02, 3.74139e-07, 4.72974e-12, 5.98574e-17}, + {6.10970e-02, 7.71701e-07, 9.75560e-12, 1.23463e-16}, + {1.43533e-01, 1.81293e-06, 2.29185e-11, 2.90047e-16}, + {3.27806e-01, 4.14044e-06, 5.23423e-11, 6.62424e-16}, + {6.40565e-01, 8.09084e-06, 1.02282e-10, 1.29445e-15}, + {1.05534e+00, 1.33298e-05, 1.68513e-10, 2.13267e-15}, + {1.58348e+00, 2.00015e-05, 2.52868e-10, 3.20044e-15}, + {3.07310e+00, 3.88206e-05, 4.90841e-10, 6.21320e-15}, + {1.37089e+01, 1.73169e-04, 2.18940e-09, 2.77122e-14}, + {7.13521e+01, 9.01235e-04, 1.13932e-08, 1.44189e-13}, + {2.52035e+02, 3.18325e-03, 4.02394e-08, 5.09217e-13}, + {5.88759e+02, 7.43595e-03, 9.39947e-08, 1.18943e-12}, + {9.70270e+02, 1.22542e-02, 1.54897e-07, 1.96005e-12}, + {1.20866e+03, 1.52648e-02, 1.92951e-07, 2.44153e-12}, + {1.20927e+03, 1.52725e-02, 1.93046e-07, 2.44272e-12}, + {1.02223e+03, 1.29102e-02, 1.63185e-07, 2.06485e-12}, + {7.60460e+02, 9.60416e-03, 1.21396e-07, 1.53608e-12}, + {5.14029e+02, 6.49187e-03, 8.20570e-08, 1.03830e-12}, + {3.23438e+02, 4.08481e-03, 5.16318e-08, 6.53316e-13}, + {1.92889e+02, 2.43607e-03, 3.07917e-08, 3.89618e-13}, + {1.10502e+02, 1.39557e-03, 1.76399e-08, 2.23204e-13}, + {6.14046e+01, 7.75500e-04, 9.80225e-09, 1.24031e-13}, + {3.33434e+01, 4.21106e-04, 5.32274e-09, 6.73503e-14}, + {1.77894e+01, 2.24668e-04, 2.83978e-09, 3.59327e-14}, + {9.36317e+00, 1.18251e-04, 1.49468e-09, 1.89126e-14}, + } + }, + { + /* name = */ "MgO_dust", + /* nonprimoridal_yield_frac = */ 5.38389e-09, + /* size_moments = */ {1.26307e-05, 1.59673e-10, 2.02075e-15}, + /* opacity_coef_table = */ { + {1.54645e-01, 1.37048e-07, 2.64662e-13, 8.45209e-19}, + {1.94685e-01, 1.72534e-07, 3.33193e-13, 1.06408e-18}, + {2.45092e-01, 2.17207e-07, 4.19469e-13, 1.33961e-18}, + {3.08551e-01, 2.73447e-07, 5.28084e-13, 1.68649e-18}, + {3.88446e-01, 3.44254e-07, 6.64830e-13, 2.12322e-18}, + {4.89028e-01, 4.33396e-07, 8.36986e-13, 2.67303e-18}, + {6.15654e-01, 5.45619e-07, 1.05372e-12, 3.36522e-18}, + {7.75056e-01, 6.86892e-07, 1.32656e-12, 4.23661e-18}, + {9.75414e-01, 8.64464e-07, 1.66951e-12, 5.33191e-18}, + {1.22498e+00, 1.08564e-06, 2.09668e-12, 6.69620e-18}, + {1.52119e+00, 1.34817e-06, 2.60370e-12, 8.31550e-18}, + {1.83682e+00, 1.62792e-06, 3.14401e-12, 1.00412e-17}, + {2.15660e+00, 1.91133e-06, 3.69138e-12, 1.17894e-17}, + {2.55494e+00, 2.26439e-06, 4.37331e-12, 1.39675e-17}, + {3.22768e+00, 2.86067e-06, 5.52501e-12, 1.76460e-17}, + {4.33077e+00, 3.83839e-06, 7.41349e-12, 2.36779e-17}, + {5.81399e+00, 5.15308e-06, 9.95292e-12, 3.17892e-17}, + {7.48107e+00, 6.63084e-06, 1.28076e-11, 4.09082e-17}, + {9.20965e+00, 8.16336e-06, 1.57686e-11, 5.03682e-17}, + {1.11868e+01, 9.91669e-06, 1.91573e-11, 6.11981e-17}, + {1.39824e+01, 1.23969e-05, 2.39531e-11, 7.65315e-17}, + {1.78531e+01, 1.58317e-05, 3.05972e-11, 9.77803e-17}, + {2.17179e+01, 1.92624e-05, 3.72355e-11, 1.19020e-16}, + {2.37018e+01, 2.10255e-05, 4.06526e-11, 1.29977e-16}, + {2.29438e+01, 2.03578e-05, 3.93739e-11, 1.25940e-16}, + {2.02577e+01, 1.79829e-05, 3.48015e-11, 1.11389e-16}, + {1.70972e+01, 1.51927e-05, 2.94374e-11, 9.43240e-17}, + {1.43876e+01, 1.28090e-05, 2.48736e-11, 7.98414e-17}, + {1.23927e+01, 1.10758e-05, 2.16034e-11, 6.95714e-17}, + {1.14807e+01, 1.03984e-05, 2.05890e-11, 6.70125e-17}, + {1.34941e+01, 1.30878e-05, 2.78918e-11, 9.54730e-17}, + {2.46530e+01, 2.87907e-05, 7.29927e-11, 2.79411e-16}, + {6.22628e+01, 8.83029e-05, 2.60128e-10, 1.09021e-15}, + {1.73608e+02, 2.73721e-04, 8.65552e-10, 3.78030e-15}, + {4.81453e+02, 7.67244e-04, 2.43830e-09, 1.06714e-14}, + } + }, +}; + +} // namespace pisn200 + +namespace y19 { +static const MetalNuclideYieldProps metal_props[] = { + // {name, gas_yield, total_yield} + {"C", 0.00000e+00, 2.50000e-01}, + {"O", 1.73867e-01, 2.93867e-01}, + {"Mg", 0.00000e+00, 6.00000e-02}, + {"Al", 2.85361e-03, 2.85361e-03}, + {"Si", 0.00000e+00, 7.00000e-02}, + {"S", 1.58191e-02, 1.58191e-02}, + {"Fe", 6.64078e-02, 6.64078e-02}, +}; + +static const GrainSpeciesYieldProps grain_props[] = { + { + /* name = */ "MgSiO3_dust", + /* nonprimoridal_yield_frac = */ 2.50000e-01, + /* size_moments = */ {1.00000e-05, 1.00000e-10, 1.00000e-15}, + /* opacity_coef_table = */ { + {6.76020e-02, 6.76020e-07, 6.76020e-12, 6.76020e-17}, + {1.20181e-01, 1.20181e-06, 1.20181e-11, 1.20181e-16}, + {1.86375e-01, 1.86375e-06, 1.86375e-11, 1.86375e-16}, + {2.69708e-01, 2.69708e-06, 2.69708e-11, 2.69708e-16}, + {4.44368e-01, 4.44368e-06, 4.44368e-11, 4.44368e-16}, + {6.87406e-01, 6.87406e-06, 6.87406e-11, 6.87406e-16}, + {1.07797e+00, 1.07797e-05, 1.07797e-10, 1.07797e-15}, + {1.71241e+00, 1.71241e-05, 1.71241e-10, 1.71241e-15}, + {2.74163e+00, 2.74163e-05, 2.74163e-10, 2.74163e-15}, + {4.35812e+00, 4.35812e-05, 4.35812e-10, 4.35812e-15}, + {6.98720e+00, 6.98720e-05, 6.98720e-10, 6.98720e-15}, + {1.13206e+01, 1.13206e-04, 1.13206e-09, 1.13206e-14}, + {1.85159e+01, 1.85159e-04, 1.85159e-09, 1.85159e-14}, + {3.09414e+01, 3.09414e-04, 3.09414e-09, 3.09414e-14}, + {5.34575e+01, 5.34575e-04, 5.34575e-09, 5.34575e-14}, + {9.60912e+01, 9.60912e-04, 9.60912e-09, 9.60912e-14}, + {1.76000e+02, 1.76000e-03, 1.76000e-08, 1.76000e-13}, + {3.10598e+02, 3.10598e-03, 3.10598e-08, 3.10598e-13}, + {4.95502e+02, 4.95502e-03, 4.95502e-08, 4.95502e-13}, + {6.87389e+02, 6.87389e-03, 6.87389e-08, 6.87389e-13}, + {8.21760e+02, 8.21760e-03, 8.21760e-08, 8.21760e-13}, + {8.55209e+02, 8.55209e-03, 8.55209e-08, 8.55209e-13}, + {7.90315e+02, 7.90315e-03, 7.90315e-08, 7.90315e-13}, + {6.63814e+02, 6.63814e-03, 6.63814e-08, 6.63814e-13}, + {5.19410e+02, 5.19410e-03, 5.19410e-08, 5.19410e-13}, + {3.88956e+02, 3.88956e-03, 3.88956e-08, 3.88956e-13}, + {2.88141e+02, 2.88141e-03, 2.88141e-08, 2.88141e-13}, + {2.20698e+02, 2.20698e-03, 2.20698e-08, 2.20698e-13}, + {1.84716e+02, 1.84716e-03, 1.84716e-08, 1.84716e-13}, + {1.78316e+02, 1.78316e-03, 1.78316e-08, 1.78316e-13}, + {2.05010e+02, 2.05010e-03, 2.05010e-08, 2.05010e-13}, + {2.82760e+02, 2.82760e-03, 2.82760e-08, 2.82760e-13}, + {4.70437e+02, 4.70437e-03, 4.70437e-08, 4.70437e-13}, + {9.49808e+02, 9.49808e-03, 9.49808e-08, 9.49808e-13}, + {2.18634e+03, 2.18634e-02, 2.18634e-07, 2.18634e-12}, + } + }, + { + /* name = */ "AC_dust", + /* nonprimoridal_yield_frac = */ 2.50000e-01, + /* size_moments = */ {1.00000e-05, 1.00000e-10, 1.00000e-15}, + /* opacity_coef_table = */ { + {2.19890e-02, 2.19890e-07, 2.19890e-12, 2.19890e-17}, + {3.90612e-02, 3.90612e-07, 3.90612e-12, 3.90612e-17}, + {6.05539e-02, 6.05539e-07, 6.05539e-12, 6.05539e-17}, + {8.76116e-02, 8.76116e-07, 8.76116e-12, 8.76116e-17}, + {1.43288e-01, 1.43288e-06, 1.43288e-11, 1.43288e-16}, + {2.19266e-01, 2.19266e-06, 2.19266e-11, 2.19266e-16}, + {3.36256e-01, 3.36256e-06, 3.36256e-11, 3.36256e-16}, + {5.14336e-01, 5.14336e-06, 5.14336e-11, 5.14336e-16}, + {7.97216e-01, 7.97216e-06, 7.97216e-11, 7.97216e-16}, + {1.25414e+00, 1.25414e-05, 1.25414e-10, 1.25414e-15}, + {2.03450e+00, 2.03450e-05, 2.03450e-10, 2.03450e-15}, + {3.34654e+00, 3.34654e-05, 3.34654e-10, 3.34654e-15}, + {5.45913e+00, 5.45913e-05, 5.45913e-10, 5.45913e-15}, + {8.82166e+00, 8.82166e-05, 8.82166e-10, 8.82166e-15}, + {1.41836e+01, 1.41836e-04, 1.41836e-09, 1.41836e-14}, + {2.28449e+01, 2.28449e-04, 2.28449e-09, 2.28449e-14}, + {3.71258e+01, 3.71258e-04, 3.71258e-09, 3.71258e-14}, + {6.14485e+01, 6.14485e-04, 6.14485e-09, 6.14485e-14}, + {1.03898e+02, 1.03898e-03, 1.03898e-08, 1.03898e-13}, + {1.75627e+02, 1.75627e-03, 1.75627e-08, 1.75627e-13}, + {2.82290e+02, 2.82290e-03, 2.82290e-08, 2.82290e-13}, + {4.14908e+02, 4.14908e-03, 4.14908e-08, 4.14908e-13}, + {5.60606e+02, 5.60606e-03, 5.60606e-08, 5.60606e-13}, + {7.12020e+02, 7.12020e-03, 7.12020e-08, 7.12020e-13}, + {8.42130e+02, 8.42130e-03, 8.42130e-08, 8.42130e-13}, + {8.96812e+02, 8.96812e-03, 8.96812e-08, 8.96812e-13}, + {8.41845e+02, 8.41845e-03, 8.41845e-08, 8.41845e-13}, + {6.97883e+02, 6.97883e-03, 6.97883e-08, 6.97883e-13}, + {5.19082e+02, 5.19082e-03, 5.19082e-08, 5.19082e-13}, + {3.53464e+02, 3.53464e-03, 3.53464e-08, 3.53464e-13}, + {2.24610e+02, 2.24610e-03, 2.24610e-08, 2.24610e-13}, + {1.35389e+02, 1.35389e-03, 1.35389e-08, 1.35389e-13}, + {7.84898e+01, 7.84898e-04, 7.84898e-09, 7.84898e-14}, + {4.43113e+01, 4.43113e-04, 4.43113e-09, 4.43113e-14}, + {2.49396e+01, 2.49396e-04, 2.49396e-09, 2.49396e-14}, + } + }, +}; + +} // namespace y19 + +// clang-format on +} // namespace grackle::impl::inj_model_input + +#define STRINGIFY_HELPER(s) #s + +// called inside of input_inject_model_iterate +#define PROCESS_INJ_MODEL(NAME, OP, OP_DATA) \ + { \ + grackle::impl::inj_model_input::InjectionPathwayInputData input = { \ + /* metal_nuclide_yields = */ \ + (grackle::impl::inj_model_input::NAME::metal_props), \ + \ + /* n_metal_nuclide_yields = */ \ + static_cast( \ + sizeof(grackle::impl::inj_model_input::NAME::metal_props) / \ + sizeof(grackle::impl::inj_model_input::MetalNuclideYieldProps)), \ + \ + /* initial_grain_props = */ \ + (grackle::impl::inj_model_input::NAME ::grain_props), \ + \ + /* n_injected_grain_species = */ \ + static_cast( \ + sizeof(grackle::impl::inj_model_input::NAME::grain_props) / \ + sizeof(grackle::impl::inj_model_input::GrainSpeciesYieldProps)), \ + }; \ + \ + int tmp = OP(STRINGIFY_HELPER(NAME), &input, OP_DATA); \ + if (tmp != GR_SUCCESS) { \ + return tmp; \ + } \ + } + +int grackle::impl::inj_model_input::input_inject_model_iterate(inj_iterate_t op, + void* op_data) { + PROCESS_INJ_MODEL(local_ISM, op, op_data); + PROCESS_INJ_MODEL(ccsn13, op, op_data); + PROCESS_INJ_MODEL(ccsn20, op, op_data); + PROCESS_INJ_MODEL(ccsn25, op, op_data); + PROCESS_INJ_MODEL(ccsn30, op, op_data); + PROCESS_INJ_MODEL(fsn13, op, op_data); + PROCESS_INJ_MODEL(fsn15, op, op_data); + PROCESS_INJ_MODEL(fsn50, op, op_data); + PROCESS_INJ_MODEL(fsn80, op, op_data); + PROCESS_INJ_MODEL(pisn170, op, op_data); + PROCESS_INJ_MODEL(pisn200, op, op_data); + PROCESS_INJ_MODEL(y19, op, op_data); + return GR_SUCCESS; +} diff --git a/src/clib/inject_model/raw_data.hpp b/src/clib/inject_model/raw_data.hpp index aad12e52c..c1e2ddc03 100644 --- a/src/clib/inject_model/raw_data.hpp +++ b/src/clib/inject_model/raw_data.hpp @@ -102,7 +102,8 @@ struct GrainSpeciesYieldProps { extern "C" { /// protoype for callback function used with input_inject_model_iterate -typedef int (*inj_iterate_t)(const char* name, InjectionPathwayInputData* input, +typedef int (*inj_iterate_t)(const char* name, + const InjectionPathwayInputData* input, void* op_data); } From 22c981d89a8a344f7421a97360f2e836c8ac11a0 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Fri, 5 Dec 2025 21:42:09 -0500 Subject: [PATCH 028/175] confirm new src for total nuclide yields is correct --- src/clib/initialize_dust_yields.cpp | 65 +++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 4 deletions(-) diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index 153934cbc..889f67e53 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -63,7 +63,7 @@ int lookup_pathway_idx(const char* name) { /// the context object for setup_yield_table_callback struct SetupCallbackCtx{ chemistry_data_storage *my_rates; - int setup_counter; + int counter; }; /// a callback function that sets up the appropriate parts of @@ -90,6 +90,10 @@ extern "C" int setup_yield_table_callback( return GrPrintAndReturnErr( "`%s` is an unexpected injection pathway name", name); } + + int counter_val = static_cast(ctx)->counter; + + GR_INTERNAL_REQUIRE(counter_val == pathway_idx, "sanity-checking"); //printf("encounterd: `%s`, pathway_idx: %d\n", name, pathway_idx); //fflush(stdout); @@ -99,6 +103,47 @@ extern "C" int setup_yield_table_callback( grackle::impl::GrainMetalInjectPathways* inject_pathway_props = my_rates->opaque_storage->inject_pathway_props; + GR_INTERNAL_REQUIRE(input->n_metal_nuclide_yields == 7, "sanity-checking"); + + auto copy_data = [pathway_idx](const grackle::impl::yields::MetalTables& tab, + double* ptr) + { + ptr[0] = tab.C[pathway_idx]; + ptr[1] = tab.O[pathway_idx]; + ptr[2] = tab.Mg[pathway_idx]; + ptr[3] = tab.Al[pathway_idx]; + ptr[4] = tab.Si[pathway_idx]; + ptr[5] = tab.S[pathway_idx]; + ptr[6] = tab.Fe[pathway_idx]; + }; + + auto clear_tab = [pathway_idx](const grackle::impl::yields::MetalTables& tab) + { + tab.C[pathway_idx] = NAN; + tab.O[pathway_idx] = NAN; + tab.Mg[pathway_idx] = NAN; + tab.Al[pathway_idx] = NAN; + tab.Si[pathway_idx] = NAN; + tab.S[pathway_idx] = NAN; + tab.Fe[pathway_idx] = NAN; + }; + + double original[7] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + double updated[7] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + + copy_data(inject_pathway_props->total_metal_nuclide_yields, original); + + printf("\n"); + for (int i = 0; i < 7; i++) { + printf("%g, ", original[i]); + } + printf("\n"); + fflush(stdout); + + clear_tab(inject_pathway_props->total_metal_nuclide_yields); + + + // record each metal nuclide yield // -> there is less value to using string keys in this case, but it makes // some sense to be semi-consistent with the handling of the dust species @@ -137,10 +182,19 @@ extern "C" int setup_yield_table_callback( "`%s` not a known metal nuclide", yield_info.name); } - //total_yield[pathway_idx] = yield_info.total_yield; + total_yield[pathway_idx] = yield_info.total_yield; //gas_yield[pathway_idx] = yield_info.gas_yield; } + copy_data(inject_pathway_props->total_metal_nuclide_yields, updated); + for (int i =0; i <7; i++){ + if (original[i] != updated[i]) { + printf("nuclide %d has changed!\n", i); + fflush(stdout); + return GR_FAIL; + } + } + // record each grain species yield for (int yield_idx = 0; yield_idx < input->n_injected_grain_species; yield_idx++) { @@ -235,6 +289,8 @@ extern "C" int setup_yield_table_callback( */ } + (static_cast(ctx)->counter)++; + return GR_SUCCESS; } @@ -440,9 +496,10 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, int ret = grackle::impl::inj_model_input::input_inject_model_iterate( &setup_yield_table_callback, static_cast(&ctx)); if (ret != GR_SUCCESS) { - GRIMPL_ERROR("THERE WAS AN ERROR"); + return GR_FAIL; } - //return GR_FAIL; + + GR_INTERNAL_REQUIRE(ctx.counter == 12, "sanity-checking"); return GR_SUCCESS; } From 29b602878f2c606797dfee7b89897f852d4cd377 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Fri, 5 Dec 2025 21:45:57 -0500 Subject: [PATCH 029/175] confirm new src for gas nuclide yields is correct --- src/clib/initialize_dust_yields.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index 889f67e53..48d04332b 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -131,7 +131,7 @@ extern "C" int setup_yield_table_callback( double original[7] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; double updated[7] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; - copy_data(inject_pathway_props->total_metal_nuclide_yields, original); + copy_data(inject_pathway_props->gas_metal_nuclide_yields, original); printf("\n"); for (int i = 0; i < 7; i++) { @@ -141,6 +141,7 @@ extern "C" int setup_yield_table_callback( fflush(stdout); clear_tab(inject_pathway_props->total_metal_nuclide_yields); + clear_tab(inject_pathway_props->gas_metal_nuclide_yields); @@ -183,10 +184,10 @@ extern "C" int setup_yield_table_callback( } total_yield[pathway_idx] = yield_info.total_yield; - //gas_yield[pathway_idx] = yield_info.gas_yield; + gas_yield[pathway_idx] = yield_info.gas_yield; } - copy_data(inject_pathway_props->total_metal_nuclide_yields, updated); + copy_data(inject_pathway_props->gas_metal_nuclide_yields, updated); for (int i =0; i <7; i++){ if (original[i] != updated[i]) { printf("nuclide %d has changed!\n", i); From 5b1f50bd5af492b9793b98b28caf4b26db279faf Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Fri, 5 Dec 2025 21:50:30 -0500 Subject: [PATCH 030/175] finish transition to newer datasource for metal nuclide yields --- src/clib/initialize_dust_yields.cpp | 243 ---------------------------- 1 file changed, 243 deletions(-) diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index 48d04332b..36abee786 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -103,48 +103,6 @@ extern "C" int setup_yield_table_callback( grackle::impl::GrainMetalInjectPathways* inject_pathway_props = my_rates->opaque_storage->inject_pathway_props; - GR_INTERNAL_REQUIRE(input->n_metal_nuclide_yields == 7, "sanity-checking"); - - auto copy_data = [pathway_idx](const grackle::impl::yields::MetalTables& tab, - double* ptr) - { - ptr[0] = tab.C[pathway_idx]; - ptr[1] = tab.O[pathway_idx]; - ptr[2] = tab.Mg[pathway_idx]; - ptr[3] = tab.Al[pathway_idx]; - ptr[4] = tab.Si[pathway_idx]; - ptr[5] = tab.S[pathway_idx]; - ptr[6] = tab.Fe[pathway_idx]; - }; - - auto clear_tab = [pathway_idx](const grackle::impl::yields::MetalTables& tab) - { - tab.C[pathway_idx] = NAN; - tab.O[pathway_idx] = NAN; - tab.Mg[pathway_idx] = NAN; - tab.Al[pathway_idx] = NAN; - tab.Si[pathway_idx] = NAN; - tab.S[pathway_idx] = NAN; - tab.Fe[pathway_idx] = NAN; - }; - - double original[7] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; - double updated[7] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; - - copy_data(inject_pathway_props->gas_metal_nuclide_yields, original); - - printf("\n"); - for (int i = 0; i < 7; i++) { - printf("%g, ", original[i]); - } - printf("\n"); - fflush(stdout); - - clear_tab(inject_pathway_props->total_metal_nuclide_yields); - clear_tab(inject_pathway_props->gas_metal_nuclide_yields); - - - // record each metal nuclide yield // -> there is less value to using string keys in this case, but it makes // some sense to be semi-consistent with the handling of the dust species @@ -187,15 +145,6 @@ extern "C" int setup_yield_table_callback( gas_yield[pathway_idx] = yield_info.gas_yield; } - copy_data(inject_pathway_props->gas_metal_nuclide_yields, updated); - for (int i =0; i <7; i++){ - if (original[i] != updated[i]) { - printf("nuclide %d has changed!\n", i); - fflush(stdout); - return GR_FAIL; - } - } - // record each grain species yield for (int yield_idx = 0; yield_idx < input->n_injected_grain_species; yield_idx++) { @@ -577,22 +526,6 @@ int calc_rates_dust_loc(int iSN, chemistry_data *my_chemistry, chemistry_data_st grackle::impl::GrainMetalInjectPathways* inject_pathway_props = my_rates->opaque_storage->inject_pathway_props; - inject_pathway_props->total_metal_nuclide_yields.C [iSN] = 1.79042e-01; - inject_pathway_props->total_metal_nuclide_yields.O [iSN] = 5.11524e-01; - inject_pathway_props->total_metal_nuclide_yields.Mg[iSN] = 3.46246e-02; - inject_pathway_props->total_metal_nuclide_yields.Al[iSN] = 3.07922e-03; - inject_pathway_props->total_metal_nuclide_yields.Si[iSN] = 3.76121e-02; - inject_pathway_props->total_metal_nuclide_yields.S [iSN] = 2.21374e-02; - inject_pathway_props->total_metal_nuclide_yields.Fe[iSN] = 6.77017e-02; - - inject_pathway_props->gas_metal_nuclide_yields.C [iSN] = 5.01317e-02; - inject_pathway_props->gas_metal_nuclide_yields.O [iSN] = 2.78491e-01; - inject_pathway_props->gas_metal_nuclide_yields.Mg[iSN] = 0.00000e+00; - inject_pathway_props->gas_metal_nuclide_yields.Al[iSN] = 3.07922e-03; - inject_pathway_props->gas_metal_nuclide_yields.Si[iSN] = 3.50813e-03; - inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 0.00000e+00; - inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 1.66568e-04; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 1.35403e-02; inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust][iSN] = 1.36165e-01; inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN] = 3.84003e-02; @@ -917,22 +850,6 @@ int calc_rates_dust_C13(int iSN, chemistry_data *my_chemistry, chemistry_data_st grackle::impl::GrainMetalInjectPathways* inject_pathway_props = my_rates->opaque_storage->inject_pathway_props; - inject_pathway_props->total_metal_nuclide_yields.C [iSN] = 2.65314e-01; - inject_pathway_props->total_metal_nuclide_yields.O [iSN] = 3.00982e-01; - inject_pathway_props->total_metal_nuclide_yields.Mg[iSN] = 3.06651e-02; - inject_pathway_props->total_metal_nuclide_yields.Al[iSN] = 2.47296e-04; - inject_pathway_props->total_metal_nuclide_yields.Si[iSN] = 6.38319e-02; - inject_pathway_props->total_metal_nuclide_yields.S [iSN] = 3.40910e-02; - inject_pathway_props->total_metal_nuclide_yields.Fe[iSN] = 9.62448e-02; - - inject_pathway_props->gas_metal_nuclide_yields.C [iSN] = 2.16731e-01; - inject_pathway_props->gas_metal_nuclide_yields.O [iSN] = 2.99231e-01; - inject_pathway_props->gas_metal_nuclide_yields.Mg[iSN] = 3.03586e-02; - inject_pathway_props->gas_metal_nuclide_yields.Al[iSN] = 2.47296e-04; - inject_pathway_props->gas_metal_nuclide_yields.Si[iSN] = 4.59041e-02; - inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 3.40903e-02; - inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 7.22586e-02; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust] [iSN] = 1.65746e-02; inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 2.39849e-02; inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 8.69522e-04; @@ -1299,22 +1216,6 @@ int calc_rates_dust_C20(int iSN, chemistry_data *my_chemistry, chemistry_data_st grackle::impl::GrainMetalInjectPathways* inject_pathway_props = my_rates->opaque_storage->inject_pathway_props; - inject_pathway_props->total_metal_nuclide_yields.C [iSN] = 1.00183e-01; - inject_pathway_props->total_metal_nuclide_yields.O [iSN] = 6.06515e-01; - inject_pathway_props->total_metal_nuclide_yields.Mg[iSN] = 2.75968e-02; - inject_pathway_props->total_metal_nuclide_yields.Al[iSN] = 1.87118e-04; - inject_pathway_props->total_metal_nuclide_yields.Si[iSN] = 1.00051e-01; - inject_pathway_props->total_metal_nuclide_yields.S [iSN] = 6.02208e-02; - inject_pathway_props->total_metal_nuclide_yields.Fe[iSN] = 3.07560e-02; - - inject_pathway_props->gas_metal_nuclide_yields.C [iSN] = 8.74563e-02; - inject_pathway_props->gas_metal_nuclide_yields.O [iSN] = 6.04383e-01; - inject_pathway_props->gas_metal_nuclide_yields.Mg[iSN] = 2.63753e-02; - inject_pathway_props->gas_metal_nuclide_yields.Al[iSN] = 1.87118e-04; - inject_pathway_props->gas_metal_nuclide_yields.Si[iSN] = 6.44592e-02; - inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 6.02018e-02; - inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 2.69505e-02; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust] [iSN] = 3.44388e-02; inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 3.77223e-03; inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 1.90086e-03; @@ -1723,22 +1624,6 @@ int calc_rates_dust_C25(int iSN, chemistry_data *my_chemistry, chemistry_data_st grackle::impl::GrainMetalInjectPathways* inject_pathway_props = my_rates->opaque_storage->inject_pathway_props; - inject_pathway_props->total_metal_nuclide_yields.C [iSN] = 1.75488e-01; - inject_pathway_props->total_metal_nuclide_yields.O [iSN] = 5.69674e-01; - inject_pathway_props->total_metal_nuclide_yields.Mg[iSN] = 3.12340e-02; - inject_pathway_props->total_metal_nuclide_yields.Al[iSN] = 2.98415e-04; - inject_pathway_props->total_metal_nuclide_yields.Si[iSN] = 8.33205e-02; - inject_pathway_props->total_metal_nuclide_yields.S [iSN] = 4.73930e-02; - inject_pathway_props->total_metal_nuclide_yields.Fe[iSN] = 1.98197e-02; - - inject_pathway_props->gas_metal_nuclide_yields.C [iSN] = 1.34092e-01; - inject_pathway_props->gas_metal_nuclide_yields.O [iSN] = 5.53726e-01; - inject_pathway_props->gas_metal_nuclide_yields.Mg[iSN] = 2.48100e-02; - inject_pathway_props->gas_metal_nuclide_yields.Al[iSN] = 2.98415e-04; - inject_pathway_props->gas_metal_nuclide_yields.Si[iSN] = 3.47760e-02; - inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 4.72556e-02; - inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 1.46955e-02; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust] [iSN] = 3.83373e-02; inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 4.88366e-03; inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 1.68068e-02; @@ -2147,22 +2032,6 @@ int calc_rates_dust_C30(int iSN, chemistry_data *my_chemistry, chemistry_data_st grackle::impl::GrainMetalInjectPathways* inject_pathway_props = my_rates->opaque_storage->inject_pathway_props; - inject_pathway_props->total_metal_nuclide_yields.C [iSN] = 4.99965e-02; - inject_pathway_props->total_metal_nuclide_yields.O [iSN] = 7.32832e-01; - inject_pathway_props->total_metal_nuclide_yields.Mg[iSN] = 3.87430e-02; - inject_pathway_props->total_metal_nuclide_yields.Al[iSN] = 8.61678e-04; - inject_pathway_props->total_metal_nuclide_yields.Si[iSN] = 7.18810e-02; - inject_pathway_props->total_metal_nuclide_yields.S [iSN] = 3.70455e-02; - inject_pathway_props->total_metal_nuclide_yields.Fe[iSN] = 1.45822e-02; - - inject_pathway_props->gas_metal_nuclide_yields.C [iSN] = 4.93773e-02; - inject_pathway_props->gas_metal_nuclide_yields.O [iSN] = 7.29130e-01; - inject_pathway_props->gas_metal_nuclide_yields.Mg[iSN] = 3.76731e-02; - inject_pathway_props->gas_metal_nuclide_yields.Al[iSN] = 8.61678e-04; - inject_pathway_props->gas_metal_nuclide_yields.Si[iSN] = 4.01269e-02; - inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 3.68812e-02; - inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 1.23641e-02; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust] [iSN] = 2.91389e-02; inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 1.93065e-03; inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 7.73041e-04; @@ -2571,22 +2440,6 @@ int calc_rates_dust_F13(int iSN, chemistry_data *my_chemistry, chemistry_data_st grackle::impl::GrainMetalInjectPathways* inject_pathway_props = my_rates->opaque_storage->inject_pathway_props; - inject_pathway_props->total_metal_nuclide_yields.C [iSN] = 6.69235e-01; - inject_pathway_props->total_metal_nuclide_yields.O [iSN] = 3.30556e-01; - inject_pathway_props->total_metal_nuclide_yields.Mg[iSN] = 1.86824e-04; - inject_pathway_props->total_metal_nuclide_yields.Al[iSN] = 1.97017e-07; - inject_pathway_props->total_metal_nuclide_yields.Si[iSN] = 1.30184e-05; - inject_pathway_props->total_metal_nuclide_yields.S [iSN] = 0.00000e+00; - inject_pathway_props->total_metal_nuclide_yields.Fe[iSN] = 8.90341e-06; - - inject_pathway_props->gas_metal_nuclide_yields.C [iSN] = 4.93693e-01; - inject_pathway_props->gas_metal_nuclide_yields.O [iSN] = 3.30556e-01; - inject_pathway_props->gas_metal_nuclide_yields.Mg[iSN] = 1.86824e-04; - inject_pathway_props->gas_metal_nuclide_yields.Al[iSN] = 1.97017e-07; - inject_pathway_props->gas_metal_nuclide_yields.Si[iSN] = 1.30184e-05; - inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 0.00000e+00; - inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 8.90341e-06; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 6.31648e-26; inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 2.06081e-16; inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN] = 3.19262e-15; @@ -2911,22 +2764,6 @@ int calc_rates_dust_F15(int iSN, chemistry_data *my_chemistry, chemistry_data_st grackle::impl::GrainMetalInjectPathways* inject_pathway_props = my_rates->opaque_storage->inject_pathway_props; - inject_pathway_props->total_metal_nuclide_yields.C [iSN] = 6.46299e-01; - inject_pathway_props->total_metal_nuclide_yields.O [iSN] = 3.53548e-01; - inject_pathway_props->total_metal_nuclide_yields.Mg[iSN] = 1.29204e-04; - inject_pathway_props->total_metal_nuclide_yields.Al[iSN] = 2.22729e-07; - inject_pathway_props->total_metal_nuclide_yields.Si[iSN] = 1.32242e-05; - inject_pathway_props->total_metal_nuclide_yields.S [iSN] = 0.00000e+00; - inject_pathway_props->total_metal_nuclide_yields.Fe[iSN] = 9.66658e-06; - - inject_pathway_props->gas_metal_nuclide_yields.C [iSN] = 4.57071e-01; - inject_pathway_props->gas_metal_nuclide_yields.O [iSN] = 3.53548e-01; - inject_pathway_props->gas_metal_nuclide_yields.Mg[iSN] = 1.29204e-04; - inject_pathway_props->gas_metal_nuclide_yields.Al[iSN] = 2.22729e-07; - inject_pathway_props->gas_metal_nuclide_yields.Si[iSN] = 1.32242e-05; - inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 0.00000e+00; - inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 9.66658e-06; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 1.53361e-25; inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 1.56864e-15; inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN] = 2.13810e-14; @@ -3251,22 +3088,6 @@ int calc_rates_dust_F50(int iSN, chemistry_data *my_chemistry, chemistry_data_st grackle::impl::GrainMetalInjectPathways* inject_pathway_props = my_rates->opaque_storage->inject_pathway_props; - inject_pathway_props->total_metal_nuclide_yields.C [iSN] = 2.79167e-01; - inject_pathway_props->total_metal_nuclide_yields.O [iSN] = 7.20575e-01; - inject_pathway_props->total_metal_nuclide_yields.Mg[iSN] = 2.49794e-04; - inject_pathway_props->total_metal_nuclide_yields.Al[iSN] = 1.66468e-08; - inject_pathway_props->total_metal_nuclide_yields.Si[iSN] = 4.01099e-06; - inject_pathway_props->total_metal_nuclide_yields.S [iSN] = 0.00000e+00; - inject_pathway_props->total_metal_nuclide_yields.Fe[iSN] = 4.15804e-06; - - inject_pathway_props->gas_metal_nuclide_yields.C [iSN] = 2.79057e-01; - inject_pathway_props->gas_metal_nuclide_yields.O [iSN] = 7.20575e-01; - inject_pathway_props->gas_metal_nuclide_yields.Mg[iSN] = 2.49793e-04; - inject_pathway_props->gas_metal_nuclide_yields.Al[iSN] = 1.66468e-08; - inject_pathway_props->gas_metal_nuclide_yields.Si[iSN] = 4.01058e-06; - inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 0.00000e+00; - inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 4.15804e-06; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 2.33171e-24; inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 2.62486e-10; inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN] = 1.21446e-09; @@ -3591,22 +3412,6 @@ int calc_rates_dust_F80(int iSN, chemistry_data *my_chemistry, chemistry_data_st grackle::impl::GrainMetalInjectPathways* inject_pathway_props = my_rates->opaque_storage->inject_pathway_props; - inject_pathway_props->total_metal_nuclide_yields.C [iSN] = 2.52563e-01; - inject_pathway_props->total_metal_nuclide_yields.O [iSN] = 7.46061e-01; - inject_pathway_props->total_metal_nuclide_yields.Mg[iSN] = 1.36917e-03; - inject_pathway_props->total_metal_nuclide_yields.Al[iSN] = 1.55602e-08; - inject_pathway_props->total_metal_nuclide_yields.Si[iSN] = 3.63906e-06; - inject_pathway_props->total_metal_nuclide_yields.S [iSN] = 0.00000e+00; - inject_pathway_props->total_metal_nuclide_yields.Fe[iSN] = 2.43915e-06; - - inject_pathway_props->gas_metal_nuclide_yields.C [iSN] = 2.43883e-01; - inject_pathway_props->gas_metal_nuclide_yields.O [iSN] = 7.46061e-01; - inject_pathway_props->gas_metal_nuclide_yields.Mg[iSN] = 1.36917e-03; - inject_pathway_props->gas_metal_nuclide_yields.Al[iSN] = 1.55602e-08; - inject_pathway_props->gas_metal_nuclide_yields.Si[iSN] = 3.63906e-06; - inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 0.00000e+00; - inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 2.43915e-06; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 3.87590e-26; inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 2.36180e-13; inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN] = 2.48190e-12; @@ -3931,22 +3736,6 @@ int calc_rates_dust_P170(int iSN, chemistry_data *my_chemistry, chemistry_data_s grackle::impl::GrainMetalInjectPathways* inject_pathway_props = my_rates->opaque_storage->inject_pathway_props; - inject_pathway_props->total_metal_nuclide_yields.C [iSN] = 5.29975e-02; - inject_pathway_props->total_metal_nuclide_yields.O [iSN] = 5.60864e-01; - inject_pathway_props->total_metal_nuclide_yields.Mg[iSN] = 3.58367e-02; - inject_pathway_props->total_metal_nuclide_yields.Al[iSN] = 3.27680e-04; - inject_pathway_props->total_metal_nuclide_yields.Si[iSN] = 1.52750e-01; - inject_pathway_props->total_metal_nuclide_yields.S [iSN] = 8.06035e-02; - inject_pathway_props->total_metal_nuclide_yields.Fe[iSN] = 5.29729e-02; - - inject_pathway_props->gas_metal_nuclide_yields.C [iSN] = 5.29528e-02; - inject_pathway_props->gas_metal_nuclide_yields.O [iSN] = 5.60799e-01; - inject_pathway_props->gas_metal_nuclide_yields.Mg[iSN] = 3.58366e-02; - inject_pathway_props->gas_metal_nuclide_yields.Al[iSN] = 3.27680e-04; - inject_pathway_props->gas_metal_nuclide_yields.Si[iSN] = 1.39585e-01; - inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 8.06035e-02; - inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 5.29394e-02; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust] [iSN] = 1.31079e-02; inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 3.34688e-05; inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 2.84952e-13; @@ -4271,22 +4060,6 @@ int calc_rates_dust_P200(int iSN, chemistry_data *my_chemistry, chemistry_data_s grackle::impl::GrainMetalInjectPathways* inject_pathway_props = my_rates->opaque_storage->inject_pathway_props; - inject_pathway_props->total_metal_nuclide_yields.C [iSN] = 3.65050e-02; - inject_pathway_props->total_metal_nuclide_yields.O [iSN] = 4.88552e-01; - inject_pathway_props->total_metal_nuclide_yields.Mg[iSN] = 2.69665e-02; - inject_pathway_props->total_metal_nuclide_yields.Al[iSN] = 1.36872e-04; - inject_pathway_props->total_metal_nuclide_yields.Si[iSN] = 1.87324e-01; - inject_pathway_props->total_metal_nuclide_yields.S [iSN] = 1.15582e-01; - inject_pathway_props->total_metal_nuclide_yields.Fe[iSN] = 6.79294e-02; - - inject_pathway_props->gas_metal_nuclide_yields.C [iSN] = 3.64677e-02; - inject_pathway_props->gas_metal_nuclide_yields.O [iSN] = 4.88307e-01; - inject_pathway_props->gas_metal_nuclide_yields.Mg[iSN] = 2.69665e-02; - inject_pathway_props->gas_metal_nuclide_yields.Al[iSN] = 1.36872e-04; - inject_pathway_props->gas_metal_nuclide_yields.Si[iSN] = 1.87051e-01; - inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 1.15582e-01; - inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 6.75026e-02; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust] [iSN] = 5.90622e-05; inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 4.26809e-04; inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 4.08246e-15; @@ -4569,22 +4342,6 @@ int calc_rates_dust_Y19(int iSN, chemistry_data *my_chemistry, chemistry_data_st grackle::impl::GrainMetalInjectPathways* inject_pathway_props = my_rates->opaque_storage->inject_pathway_props; - inject_pathway_props->total_metal_nuclide_yields.C [iSN] = 2.50000e-01; - inject_pathway_props->total_metal_nuclide_yields.O [iSN] = 2.93867e-01; - inject_pathway_props->total_metal_nuclide_yields.Mg[iSN] = 6.00000e-02; - inject_pathway_props->total_metal_nuclide_yields.Al[iSN] = 2.85361e-03; - inject_pathway_props->total_metal_nuclide_yields.Si[iSN] = 7.00000e-02; - inject_pathway_props->total_metal_nuclide_yields.S [iSN] = 1.58191e-02; - inject_pathway_props->total_metal_nuclide_yields.Fe[iSN] = 6.64078e-02; - - inject_pathway_props->gas_metal_nuclide_yields.C [iSN] = 0.00000e+00; - inject_pathway_props->gas_metal_nuclide_yields.O [iSN] = 1.73867e-01; - inject_pathway_props->gas_metal_nuclide_yields.Mg[iSN] = 0.00000e+00; - inject_pathway_props->gas_metal_nuclide_yields.Al[iSN] = 2.85361e-03; - inject_pathway_props->gas_metal_nuclide_yields.Si[iSN] = 0.00000e+00; - inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 1.58191e-02; - inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 6.64078e-02; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust][iSN] = 2.50000e-01; inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust] [iSN] = 2.50000e-01; From 29f04c23b6d2bd1972e764580d16bbc76a1f9ab0 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sat, 6 Dec 2025 10:24:18 -0500 Subject: [PATCH 031/175] pull out zeroing logic (inject-rates) 1 of 2 The goal is two-fold: 1. reduce the length of grackle::impl::initialize_dust_yields 2. make some anticipated spot checks a LOT easier --- src/clib/initialize_dust_yields.cpp | 93 +++++++++++++++++++---------- 1 file changed, 61 insertions(+), 32 deletions(-) diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index 36abee786..ccd3dc117 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -244,6 +244,62 @@ extern "C" int setup_yield_table_callback( return GR_SUCCESS; } +/// a helper function override the values of all metal injection properties +void override_metal_inject_props( + grackle::impl::GrainMetalInjectPathways* inject_pathway_props, + double value, int n_pathways) +{ + for(int iSN = 0; iSN < n_pathways; iSN++) { + inject_pathway_props->total_metal_nuclide_yields.C [iSN] = value; + inject_pathway_props->total_metal_nuclide_yields.O [iSN] = value; + inject_pathway_props->total_metal_nuclide_yields.Mg[iSN] = value; + inject_pathway_props->total_metal_nuclide_yields.Al[iSN] = value; + inject_pathway_props->total_metal_nuclide_yields.Si[iSN] = value; + inject_pathway_props->total_metal_nuclide_yields.S [iSN] = value; + inject_pathway_props->total_metal_nuclide_yields.Fe[iSN] = value; + + inject_pathway_props->gas_metal_nuclide_yields.C [iSN] = value; + inject_pathway_props->gas_metal_nuclide_yields.O [iSN] = value; + inject_pathway_props->gas_metal_nuclide_yields.Mg[iSN] = value; + inject_pathway_props->gas_metal_nuclide_yields.Al[iSN] = value; + inject_pathway_props->gas_metal_nuclide_yields.Si[iSN] = value; + inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = value; + inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = value; + } +} + +/// a helper function to override the values of all dust inject properties +/// +/// @note +/// to start, this only handles the grain yields +void override_dust_inject_props(chemistry_data_storage *my_rates, + double value, int n_pathways) { + + GRIMPL_REQUIRE(my_rates != nullptr && my_rates->opaque_storage != nullptr, + "sanity check -- should never ever fail!"); + grackle::impl::GrainMetalInjectPathways* inject_pathway_props + = my_rates->opaque_storage->inject_pathway_props; + + if (inject_pathway_props != nullptr) { + for(int iSN = 0; iSN < n_pathways; iSN++) { + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust] [iSN] = value; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = value; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = value; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN] = value; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Fe3O4_dust] [iSN] = value; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust] [iSN] = value; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust] [iSN] = value; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgO_dust] [iSN] = value; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeS_dust] [iSN] = value; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Al2O3_dust] [iSN] = value; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::ref_org_dust] [iSN] = value; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::vol_org_dust] [iSN] = value; + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::H2O_ice_dust] [iSN] = value; + } + } + +} + } // anonymous namespace int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, @@ -287,38 +343,6 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, my_rates->SN0_fS = inject_pathway_props->gas_metal_nuclide_yields.S; my_rates->SN0_fFe = inject_pathway_props->gas_metal_nuclide_yields.Fe; - for(int iSN = 0; iSN < NSN; iSN++) { - inject_pathway_props->total_metal_nuclide_yields.C [iSN] = 0.0; - inject_pathway_props->total_metal_nuclide_yields.O [iSN] = 0.0; - inject_pathway_props->total_metal_nuclide_yields.Mg[iSN] = 0.0; - inject_pathway_props->total_metal_nuclide_yields.Al[iSN] = 0.0; - inject_pathway_props->total_metal_nuclide_yields.Si[iSN] = 0.0; - inject_pathway_props->total_metal_nuclide_yields.S [iSN] = 0.0; - inject_pathway_props->total_metal_nuclide_yields.Fe[iSN] = 0.0; - - inject_pathway_props->gas_metal_nuclide_yields.C [iSN] = 0.0; - inject_pathway_props->gas_metal_nuclide_yields.O [iSN] = 0.0; - inject_pathway_props->gas_metal_nuclide_yields.Mg[iSN] = 0.0; - inject_pathway_props->gas_metal_nuclide_yields.Al[iSN] = 0.0; - inject_pathway_props->gas_metal_nuclide_yields.Si[iSN] = 0.0; - inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = 0.0; - inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = 0.0; - - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust] [iSN] = 0.0; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 0.0; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 0.0; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN] = 0.0; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Fe3O4_dust] [iSN] = 0.0; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust] [iSN] = 0.0; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust] [iSN] = 0.0; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgO_dust] [iSN] = 0.0; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeS_dust] [iSN] = 0.0; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Al2O3_dust] [iSN] = 0.0; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::ref_org_dust] [iSN] = 0.0; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::vol_org_dust] [iSN] = 0.0; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::H2O_ice_dust] [iSN] = 0.0; - } - my_rates->SN0_r0SiM = (double*)malloc(NSN * 3 * sizeof(double)); my_rates->SN0_r0FeM = (double*)malloc(NSN * 3 * sizeof(double)); my_rates->SN0_r0Mg2SiO4 = (double*)malloc(NSN * 3 * sizeof(double)); @@ -428,6 +452,11 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, } } + // zero-out all metal injection yield fractions and dust grain properties + override_metal_inject_props(inject_pathway_props, 0.0, n_pathways); + override_dust_inject_props(my_rates, 0.0, n_pathways); + + // initialize all of the properties calc_yield_rate_fn* fn_list[] = { &calc_rates_dust_loc, &calc_rates_dust_C13, &calc_rates_dust_C20, &calc_rates_dust_C25, &calc_rates_dust_C30, &calc_rates_dust_F13, From 0b95a9cb841e7f1611a7ecce1dc9c548708b183f Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sat, 6 Dec 2025 10:43:35 -0500 Subject: [PATCH 032/175] pull out zeroing logic (inject-rates) 2 of 2 --- src/clib/initialize_dust_yields.cpp | 83 ++++++++++++++--------------- 1 file changed, 39 insertions(+), 44 deletions(-) diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index ccd3dc117..dc9734e71 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -281,6 +281,7 @@ void override_dust_inject_props(chemistry_data_storage *my_rates, = my_rates->opaque_storage->inject_pathway_props; if (inject_pathway_props != nullptr) { + // handle the grain yields for(int iSN = 0; iSN < n_pathways; iSN++) { inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust] [iSN] = value; inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = value; @@ -298,6 +299,44 @@ void override_dust_inject_props(chemistry_data_storage *my_rates, } } + if (true) { // NOLINT(readability-simplify-boolean-expr) + + // handle the size moments + int moment_table_len = n_pathways * 3; // there are 3 size moments + for(int i = 0; i < moment_table_len; i++) { + my_rates->SN0_r0SiM [i] = value; + my_rates->SN0_r0FeM [i] = value; + my_rates->SN0_r0Mg2SiO4 [i] = value; + my_rates->SN0_r0MgSiO3 [i] = value; + my_rates->SN0_r0Fe3O4 [i] = value; + my_rates->SN0_r0AC [i] = value; + my_rates->SN0_r0SiO2D [i] = value; + my_rates->SN0_r0MgO [i] = value; + my_rates->SN0_r0FeS [i] = value; + my_rates->SN0_r0Al2O3 [i] = value; + my_rates->SN0_r0reforg [i] = value; + my_rates->SN0_r0volorg [i] = value; + my_rates->SN0_r0H2Oice [i] = value; + } + + // handle the opacity coefficient table + int opac_table_len = n_pathways * my_rates->gr_Size; + for(int i = 0; i < opac_table_len; i++) { + my_rates->SN0_kpSiM [i] = value; + my_rates->SN0_kpFeM [i] = value; + my_rates->SN0_kpMg2SiO4 [i] = value; + my_rates->SN0_kpMgSiO3 [i] = value; + my_rates->SN0_kpFe3O4 [i] = value; + my_rates->SN0_kpAC [i] = value; + my_rates->SN0_kpSiO2D [i] = value; + my_rates->SN0_kpMgO [i] = value; + my_rates->SN0_kpFeS [i] = value; + my_rates->SN0_kpAl2O3 [i] = value; + my_rates->SN0_kpreforg [i] = value; + my_rates->SN0_kpvolorg [i] = value; + my_rates->SN0_kpH2Oice [i] = value; + } + } } } // anonymous namespace @@ -357,26 +396,6 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, my_rates->SN0_r0volorg = (double*)malloc(NSN * 3 * sizeof(double)); my_rates->SN0_r0H2Oice = (double*)malloc(NSN * 3 * sizeof(double)); - int itab = 0; - for(int iSN = 0; iSN < NSN; iSN++) { - for(int imom = 0; imom < 3; imom++) { - my_rates->SN0_r0SiM [itab] = 0.0; - my_rates->SN0_r0FeM [itab] = 0.0; - my_rates->SN0_r0Mg2SiO4 [itab] = 0.0; - my_rates->SN0_r0MgSiO3 [itab] = 0.0; - my_rates->SN0_r0Fe3O4 [itab] = 0.0; - my_rates->SN0_r0AC [itab] = 0.0; - my_rates->SN0_r0SiO2D [itab] = 0.0; - my_rates->SN0_r0MgO [itab] = 0.0; - my_rates->SN0_r0FeS [itab] = 0.0; - my_rates->SN0_r0Al2O3 [itab] = 0.0; - my_rates->SN0_r0reforg [itab] = 0.0; - my_rates->SN0_r0volorg [itab] = 0.0; - my_rates->SN0_r0H2Oice [itab] = 0.0; - itab++; - } - } - // write out the opacity related quantities // todo: consider renaming Nmom -> Ncoef @@ -427,30 +446,6 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, my_rates->SN0_kpvolorg = (double*)malloc(NSN * Nmom * NTd * sizeof(double)); my_rates->SN0_kpH2Oice = (double*)malloc(NSN * Nmom * NTd * sizeof(double)); - itab = 0; - for(int iSN = 0; iSN < NSN; iSN++) { - // TODO: I'm pretty sure we want to flip the order of inner loops - // - while it doesn't actually effect the result this is extremely - // confusing if the grain-temperature axis isn't the fast axis. - for(int imom = 0; imom < Nmom; imom++) { - for(int iTd = 0; iTd < NTd; iTd++) { - my_rates->SN0_kpSiM [itab] = 0.0; - my_rates->SN0_kpFeM [itab] = 0.0; - my_rates->SN0_kpMg2SiO4 [itab] = 0.0; - my_rates->SN0_kpMgSiO3 [itab] = 0.0; - my_rates->SN0_kpFe3O4 [itab] = 0.0; - my_rates->SN0_kpAC [itab] = 0.0; - my_rates->SN0_kpSiO2D [itab] = 0.0; - my_rates->SN0_kpMgO [itab] = 0.0; - my_rates->SN0_kpFeS [itab] = 0.0; - my_rates->SN0_kpAl2O3 [itab] = 0.0; - my_rates->SN0_kpreforg [itab] = 0.0; - my_rates->SN0_kpvolorg [itab] = 0.0; - my_rates->SN0_kpH2Oice [itab] = 0.0; - itab++; - } - } - } // zero-out all metal injection yield fractions and dust grain properties override_metal_inject_props(inject_pathway_props, 0.0, n_pathways); From ff118a58e739b8901def4d797488256b233b93b0 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sat, 6 Dec 2025 12:23:27 -0500 Subject: [PATCH 033/175] add temporary machinery in preparation for transition in grain data source --- src/clib/initialize_dust_yields.cpp | 149 ++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index dc9734e71..2956549e7 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -15,6 +15,8 @@ #include #include #include +#include +#include #include "grackle_macros.h" #include "grackle_chemistry_data.h" #include "initialize_dust_yields.hpp" // forward declarations @@ -339,6 +341,145 @@ void override_dust_inject_props(chemistry_data_storage *my_rates, } } +struct SummaryGrainYieldProp{ + std::string name; + std::vector yield_frac; + std::vector size_moments; + std::vector opacity_coef_table; + + bool operator==(const SummaryGrainYieldProp& other) const { + return ( + (name == other.name) && + (yield_frac == other.yield_frac) && + (size_moments == other.size_moments) && + (opacity_coef_table == other.opacity_coef_table) + ); + } + + + bool operator!=(const SummaryGrainYieldProp& other) const { + return ( + (name != other.name) || + (yield_frac != other.yield_frac) || + (size_moments != other.size_moments) || + (opacity_coef_table != other.opacity_coef_table) + ); + } +}; + +std::vector +get_summary(chemistry_data_storage *my_rates, int n_pathways) { + + GRIMPL_REQUIRE(my_rates != nullptr && my_rates->opaque_storage != nullptr, + "sanity check -- should never ever fail!"); + grackle::impl::GrainMetalInjectPathways* inject_pathway_props + = my_rates->opaque_storage->inject_pathway_props; + + GRIMPL_REQUIRE(inject_pathway_props != nullptr, + "sanity check -- should never ever fail!"); + auto helper_fn = [=](const char* name) { + + int grain_species_idx = -1; + const double* cur_size_mom_table = nullptr; + const double* cur_opac_coef_table = nullptr; + if (std::strcmp("MgSiO3_dust", name) == 0) { + grain_species_idx = OnlyGrainSpLUT::MgSiO3_dust; + cur_size_mom_table = my_rates->SN0_r0MgSiO3; + cur_opac_coef_table = my_rates->SN0_kpMgSiO3; + } else if (std::strcmp("AC_dust", name) == 0) { + grain_species_idx = OnlyGrainSpLUT::AC_dust; + cur_size_mom_table = my_rates->SN0_r0AC; + cur_opac_coef_table = my_rates->SN0_kpAC; + } else if (std::strcmp("SiM_dust", name) == 0) { + grain_species_idx = OnlyGrainSpLUT::SiM_dust; + cur_size_mom_table = my_rates->SN0_r0SiM; + cur_opac_coef_table = my_rates->SN0_kpSiM; + } else if (std::strcmp("FeM_dust", name) == 0) { + grain_species_idx = OnlyGrainSpLUT::FeM_dust; + cur_size_mom_table = my_rates->SN0_r0FeM; + cur_opac_coef_table = my_rates->SN0_kpFeM; + } else if (std::strcmp("Mg2SiO4_dust", name) == 0) { + grain_species_idx = OnlyGrainSpLUT::Mg2SiO4_dust; + cur_size_mom_table = my_rates->SN0_r0Mg2SiO4; + cur_opac_coef_table = my_rates->SN0_kpMg2SiO4; + } else if (std::strcmp("Fe3O4_dust", name) == 0) { + grain_species_idx = OnlyGrainSpLUT::Fe3O4_dust; + cur_size_mom_table = my_rates->SN0_r0Fe3O4; + cur_opac_coef_table = my_rates->SN0_kpFe3O4; + } else if (std::strcmp("SiO2_dust", name) == 0) { + grain_species_idx = OnlyGrainSpLUT::SiO2_dust; + cur_size_mom_table = my_rates->SN0_r0SiO2D; + cur_opac_coef_table = my_rates->SN0_kpSiO2D; + } else if (std::strcmp("MgO_dust", name) == 0) { + grain_species_idx = OnlyGrainSpLUT::MgO_dust; + cur_size_mom_table = my_rates->SN0_r0MgO; + cur_opac_coef_table = my_rates->SN0_kpMgO; + } else if (std::strcmp("FeS_dust", name) == 0) { + grain_species_idx = OnlyGrainSpLUT::FeS_dust; + cur_size_mom_table = my_rates->SN0_r0FeS; + cur_opac_coef_table = my_rates->SN0_kpFeS; + } else if (std::strcmp("Al2O3_dust", name) == 0) { + grain_species_idx = OnlyGrainSpLUT::Al2O3_dust; + cur_size_mom_table = my_rates->SN0_r0Al2O3; + cur_opac_coef_table = my_rates->SN0_kpAl2O3; + } else if (std::strcmp("ref_org_dust", name) == 0) { + grain_species_idx = OnlyGrainSpLUT::ref_org_dust; + cur_size_mom_table = my_rates->SN0_r0reforg; + cur_opac_coef_table = my_rates->SN0_kpreforg; + } else if (std::strcmp("vol_org_dust", name) == 0) { + grain_species_idx = OnlyGrainSpLUT::vol_org_dust; + cur_size_mom_table = my_rates->SN0_r0volorg; + cur_opac_coef_table = my_rates->SN0_kpvolorg; + } else if (std::strcmp("H2O_ice_dust", name) == 0) { + grain_species_idx = OnlyGrainSpLUT::H2O_ice_dust; + cur_size_mom_table = my_rates->SN0_r0H2Oice; + cur_opac_coef_table = my_rates->SN0_kpH2Oice; + } else { + GRIMPL_ERROR("THERE'S A PROBLEM"); + } + + const double* cur_yields = + inject_pathway_props->grain_yields.data[grain_species_idx]; + + std::vector yields(cur_yields, cur_yields + n_pathways); + std::vector size_mom_table + (cur_size_mom_table, cur_size_mom_table + (n_pathways*3)); + std::vector opac_coef_table + (cur_opac_coef_table, + cur_opac_coef_table + (n_pathways*my_rates->gr_Size)); + return SummaryGrainYieldProp{std::string(name), + yields, + size_mom_table, + opac_coef_table}; + }; + + std::vector names = { + "MgSiO3_dust", + "AC_dust", + "SiM_dust", + "FeM_dust", + "Mg2SiO4_dust", + "Fe3O4_dust", + "SiO2_dust", + "MgO_dust", + "FeS_dust", + "Al2O3_dust", + "ref_org_dust", + "vol_org_dust", + "H2O_ice_dust", + }; + + + std::vector out; + for (auto name : names){ + out.push_back(helper_fn(name.c_str())); + } + std::printf("%s\n", out[2].name.c_str()); + return out; + +} + + } // anonymous namespace int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, @@ -451,6 +592,9 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, override_metal_inject_props(inject_pathway_props, 0.0, n_pathways); override_dust_inject_props(my_rates, 0.0, n_pathways); + + std::vector raw = get_summary(my_rates, n_pathways); + // initialize all of the properties calc_yield_rate_fn* fn_list[] = { &calc_rates_dust_loc, &calc_rates_dust_C13, &calc_rates_dust_C20, @@ -465,6 +609,11 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, int rv = fn_list[i](i, my_chemistry, my_rates); if (rv != SUCCESS) { return rv; } } + + std::vector original_set = get_summary(my_rates, + n_pathways); + // if (raw != original_set) { return GrPrintAndReturnErr("expected to fail!"); } + SetupCallbackCtx ctx = {my_rates, 0}; int ret = grackle::impl::inj_model_input::input_inject_model_iterate( From 0b74a6ba13858c7e1e80f59cb36d9f40e80134f1 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sat, 6 Dec 2025 15:36:17 -0500 Subject: [PATCH 034/175] fixed a major error in the reformated tables of injection model data (essentially data was randomly swapped between dust species within a given injection pathway) --- src/clib/inject_model/raw_data.cpp | 1422 ++++++++++++++-------------- 1 file changed, 711 insertions(+), 711 deletions(-) diff --git a/src/clib/inject_model/raw_data.cpp b/src/clib/inject_model/raw_data.cpp index 2d5a7b72d..f63ec1dae 100644 --- a/src/clib/inject_model/raw_data.cpp +++ b/src/clib/inject_model/raw_data.cpp @@ -43,6 +43,48 @@ static const GrainSpeciesYieldProps grain_props[] = { /* name = */ "FeM_dust", /* nonprimoridal_yield_frac = */ 1.35403e-02, /* size_moments = */ {8.33039e-07, 1.16161e-12, 8.21384e-18}, + /* opacity_coef_table = */ { + {3.03937e-04, 1.23816e-09, 4.62094e-14, 3.72497e-18}, + {5.33931e-04, 1.94666e-09, 6.42306e-14, 4.92267e-18}, + {8.23085e-04, 2.82715e-09, 8.64655e-14, 6.40508e-18}, + {1.18689e-03, 3.92926e-09, 1.14201e-13, 8.25547e-18}, + {1.93090e-03, 5.86828e-09, 1.50433e-13, 1.02764e-17}, + {2.95251e-03, 8.43657e-09, 1.95467e-13, 1.27089e-17}, + {4.55033e-03, 1.22013e-08, 2.52591e-13, 1.54880e-17}, + {7.04895e-03, 1.77533e-08, 3.26595e-13, 1.87358e-17}, + {1.09337e-02, 2.59554e-08, 4.24054e-13, 2.26060e-17}, + {1.67787e-02, 3.77909e-08, 5.51941e-13, 2.72576e-17}, + {2.56790e-02, 5.50228e-08, 7.20688e-13, 3.28090e-17}, + {3.89780e-02, 7.95600e-08, 9.39516e-13, 3.93285e-17}, + {5.82741e-02, 1.13372e-07, 1.21633e-12, 4.68721e-17}, + {8.58228e-02, 1.58873e-07, 1.55917e-12, 5.54857e-17}, + {1.24511e-01, 2.18724e-07, 1.97549e-12, 6.52470e-17}, + {1.78164e-01, 2.96038e-07, 2.47229e-12, 7.62244e-17}, + {2.51965e-01, 3.94501e-07, 3.05495e-12, 8.84292e-17}, + {3.53706e-01, 5.19228e-07, 3.72904e-12, 1.01872e-16}, + {4.96690e-01, 6.79268e-07, 4.51008e-12, 1.16807e-16}, + {7.06391e-01, 8.93298e-07, 5.44240e-12, 1.34078e-16}, + {1.03345e+00, 1.19958e-06, 6.62440e-12, 1.55520e-16}, + {1.58058e+00, 1.67481e-06, 8.24715e-12, 1.84604e-16}, + {2.55750e+00, 2.47088e-06, 1.06606e-11, 2.27517e-16}, + {4.39505e+00, 3.88891e-06, 1.44836e-11, 2.94492e-16}, + {7.97338e+00, 6.52370e-06, 2.07697e-11, 4.00081e-16}, + {1.50676e+01, 1.15419e-05, 3.12837e-11, 5.61771e-16}, + {2.91750e+01, 2.11959e-05, 4.90431e-11, 7.99872e-16}, + {5.69546e+01, 3.97177e-05, 7.93362e-11, 1.14279e-15}, + {1.10473e+02, 7.47151e-05, 1.31340e-10, 1.63629e-15}, + {2.10337e+02, 1.39130e-04, 2.20345e-10, 2.35251e-15}, + {3.89661e+02, 2.53753e-04, 3.70677e-10, 3.39830e-15}, + {6.99152e+02, 4.50456e-04, 6.19407e-10, 4.92457e-15}, + {1.21457e+03, 7.76739e-04, 1.02057e-09, 7.13090e-15}, + {2.05022e+03, 1.30302e-03, 1.64745e-09, 1.02322e-14}, + {3.38793e+03, 2.13731e-03, 2.59306e-09, 1.43690e-14}, + } + }, + { + /* name = */ "Mg2SiO4_dust", + /* nonprimoridal_yield_frac = */ 1.36165e-01, + /* size_moments = */ {8.33039e-07, 1.16161e-12, 8.21384e-18}, /* opacity_coef_table = */ { {2.45237e-01, 1.46287e-07, 1.48927e-13, 1.14540e-18}, {3.08964e-01, 1.84301e-07, 1.87627e-13, 1.44311e-18}, @@ -82,8 +124,8 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "Mg2SiO4_dust", - /* nonprimoridal_yield_frac = */ 1.36165e-01, + /* name = */ "MgSiO3_dust", + /* nonprimoridal_yield_frac = */ 3.84003e-02, /* size_moments = */ {8.33039e-07, 1.16161e-12, 8.21384e-18}, /* opacity_coef_table = */ { {5.12401e-02, 3.05654e-08, 3.11170e-14, 2.39327e-19}, @@ -124,8 +166,8 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "MgSiO3_dust", - /* nonprimoridal_yield_frac = */ 3.84003e-02, + /* name = */ "FeS_dust", + /* nonprimoridal_yield_frac = */ 3.04389e-02, /* size_moments = */ {8.33039e-07, 1.16161e-12, 8.21384e-18}, /* opacity_coef_table = */ { {1.20726e-01, 7.20182e-08, 7.35280e-14, 5.95267e-19}, @@ -166,8 +208,8 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "FeS_dust", - /* nonprimoridal_yield_frac = */ 3.04389e-02, + /* name = */ "ref_org_dust", + /* nonprimoridal_yield_frac = */ 1.86114e-01, /* size_moments = */ {8.33039e-07, 1.16161e-12, 8.21384e-18}, /* opacity_coef_table = */ { {4.68555e-02, 2.79499e-08, 2.84543e-14, 2.18837e-19}, @@ -208,8 +250,8 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "ref_org_dust", - /* nonprimoridal_yield_frac = */ 1.86114e-01, + /* name = */ "vol_org_dust", + /* nonprimoridal_yield_frac = */ 3.81956e-02, /* size_moments = */ {8.33039e-07, 1.16161e-12, 8.21384e-18}, /* opacity_coef_table = */ { {7.02832e-02, 4.19249e-08, 4.26814e-14, 3.28255e-19}, @@ -250,8 +292,8 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "vol_org_dust", - /* nonprimoridal_yield_frac = */ 3.81956e-02, + /* name = */ "H2O_ice_dust", + /* nonprimoridal_yield_frac = */ 6.33011e-02, /* size_moments = */ {8.33039e-07, 1.16161e-12, 8.21384e-18}, /* opacity_coef_table = */ { {6.30862e-02, 3.76318e-08, 3.83108e-14, 2.94648e-19}, @@ -291,48 +333,6 @@ static const GrainSpeciesYieldProps grain_props[] = { {1.96048e+03, 1.16958e-03, 1.17438e-09, 7.69912e-15}, } }, - { - /* name = */ "H2O_ice_dust", - /* nonprimoridal_yield_frac = */ 6.33011e-02, - /* size_moments = */ {8.33039e-07, 1.16161e-12, 8.21384e-18}, - /* opacity_coef_table = */ { - {3.03937e-04, 1.23816e-09, 4.62094e-14, 3.72497e-18}, - {5.33931e-04, 1.94666e-09, 6.42306e-14, 4.92267e-18}, - {8.23085e-04, 2.82715e-09, 8.64655e-14, 6.40508e-18}, - {1.18689e-03, 3.92926e-09, 1.14201e-13, 8.25547e-18}, - {1.93090e-03, 5.86828e-09, 1.50433e-13, 1.02764e-17}, - {2.95251e-03, 8.43657e-09, 1.95467e-13, 1.27089e-17}, - {4.55033e-03, 1.22013e-08, 2.52591e-13, 1.54880e-17}, - {7.04895e-03, 1.77533e-08, 3.26595e-13, 1.87358e-17}, - {1.09337e-02, 2.59554e-08, 4.24054e-13, 2.26060e-17}, - {1.67787e-02, 3.77909e-08, 5.51941e-13, 2.72576e-17}, - {2.56790e-02, 5.50228e-08, 7.20688e-13, 3.28090e-17}, - {3.89780e-02, 7.95600e-08, 9.39516e-13, 3.93285e-17}, - {5.82741e-02, 1.13372e-07, 1.21633e-12, 4.68721e-17}, - {8.58228e-02, 1.58873e-07, 1.55917e-12, 5.54857e-17}, - {1.24511e-01, 2.18724e-07, 1.97549e-12, 6.52470e-17}, - {1.78164e-01, 2.96038e-07, 2.47229e-12, 7.62244e-17}, - {2.51965e-01, 3.94501e-07, 3.05495e-12, 8.84292e-17}, - {3.53706e-01, 5.19228e-07, 3.72904e-12, 1.01872e-16}, - {4.96690e-01, 6.79268e-07, 4.51008e-12, 1.16807e-16}, - {7.06391e-01, 8.93298e-07, 5.44240e-12, 1.34078e-16}, - {1.03345e+00, 1.19958e-06, 6.62440e-12, 1.55520e-16}, - {1.58058e+00, 1.67481e-06, 8.24715e-12, 1.84604e-16}, - {2.55750e+00, 2.47088e-06, 1.06606e-11, 2.27517e-16}, - {4.39505e+00, 3.88891e-06, 1.44836e-11, 2.94492e-16}, - {7.97338e+00, 6.52370e-06, 2.07697e-11, 4.00081e-16}, - {1.50676e+01, 1.15419e-05, 3.12837e-11, 5.61771e-16}, - {2.91750e+01, 2.11959e-05, 4.90431e-11, 7.99872e-16}, - {5.69546e+01, 3.97177e-05, 7.93362e-11, 1.14279e-15}, - {1.10473e+02, 7.47151e-05, 1.31340e-10, 1.63629e-15}, - {2.10337e+02, 1.39130e-04, 2.20345e-10, 2.35251e-15}, - {3.89661e+02, 2.53753e-04, 3.70677e-10, 3.39830e-15}, - {6.99152e+02, 4.50456e-04, 6.19407e-10, 4.92457e-15}, - {1.21457e+03, 7.76739e-04, 1.02057e-09, 7.13090e-15}, - {2.05022e+03, 1.30302e-03, 1.64745e-09, 1.02322e-14}, - {3.38793e+03, 2.13731e-03, 2.59306e-09, 1.43690e-14}, - } - }, }; } // namespace local_ISM @@ -354,6 +354,48 @@ static const GrainSpeciesYieldProps grain_props[] = { /* name = */ "SiM_dust", /* nonprimoridal_yield_frac = */ 1.65746e-02, /* size_moments = */ {1.68557e-06, 9.75226e-12, 1.74046e-16}, + /* opacity_coef_table = */ { + {1.54619e-01, 2.60128e-07, 1.49475e-12, 2.65148e-17}, + {1.94656e-01, 3.27554e-07, 1.88361e-12, 3.34351e-17}, + {2.45059e-01, 4.12439e-07, 2.37316e-12, 4.21472e-17}, + {3.08513e-01, 5.19301e-07, 2.98947e-12, 5.31150e-17}, + {3.88404e-01, 6.53894e-07, 3.76675e-12, 6.69643e-17}, + {4.88982e-01, 8.23350e-07, 4.74559e-12, 8.44087e-17}, + {6.15605e-01, 1.03673e-06, 5.97899e-12, 1.06403e-16}, + {7.75006e-01, 1.30539e-06, 7.53301e-12, 1.34131e-16}, + {9.75366e-01, 1.64315e-06, 9.48791e-12, 1.69031e-16}, + {1.22493e+00, 2.06392e-06, 1.19246e-11, 2.12553e-16}, + {1.52116e+00, 2.56344e-06, 1.48192e-11, 2.64285e-16}, + {1.83681e+00, 3.09586e-06, 1.79072e-11, 3.19511e-16}, + {2.15662e+00, 3.63549e-06, 2.10413e-11, 3.75635e-16}, + {2.55502e+00, 4.30820e-06, 2.49580e-11, 4.45921e-16}, + {3.22790e+00, 5.44497e-06, 3.15890e-11, 5.65115e-16}, + {4.33126e+00, 7.30995e-06, 4.24882e-11, 7.61352e-16}, + {5.81498e+00, 9.82030e-06, 5.72103e-11, 1.02723e-15}, + {7.48294e+00, 1.26484e-05, 7.39233e-11, 1.33106e-15}, + {9.21324e+00, 1.55973e-05, 9.16644e-11, 1.65851e-15}, + {1.11943e+01, 1.90119e-05, 1.13021e-10, 2.06536e-15}, + {1.39990e+01, 2.39150e-05, 1.45136e-10, 2.69938e-15}, + {1.78867e+01, 3.08010e-05, 1.92146e-10, 3.65687e-15}, + {2.17798e+01, 3.79266e-05, 2.45744e-10, 4.82338e-15}, + {2.38104e+01, 4.23268e-05, 2.93339e-10, 6.06677e-15}, + {2.31200e+01, 4.26489e-05, 3.30423e-10, 7.40538e-15}, + {2.05061e+01, 3.98990e-05, 3.56330e-10, 8.76054e-15}, + {1.74011e+01, 3.59849e-05, 3.69684e-10, 9.86673e-15}, + {1.47227e+01, 3.22080e-05, 3.69774e-10, 1.04731e-14}, + {1.27456e+01, 2.91368e-05, 3.59951e-10, 1.05598e-14}, + {1.18944e+01, 2.82426e-05, 3.62521e-10, 1.07315e-14}, + {1.43878e+01, 3.74123e-05, 4.87177e-10, 1.37994e-14}, + {2.85377e+01, 9.23385e-05, 1.20077e-09, 3.00478e-14}, + {7.93256e+01, 3.11569e-04, 3.91124e-09, 8.56317e-14}, + {2.33021e+02, 9.78251e-04, 1.15601e-08, 2.28453e-13}, + {6.42052e+02, 2.55294e-03, 2.77058e-08, 5.06000e-13}, + } + }, + { + /* name = */ "FeM_dust", + /* nonprimoridal_yield_frac = */ 2.39849e-02, + /* size_moments = */ {4.62542e-06, 3.82292e-11, 4.68445e-16}, /* opacity_coef_table = */ { {5.88921e-03, 6.87770e-08, 1.06227e-12, 2.02349e-17}, {1.01153e-02, 1.15444e-07, 1.74157e-12, 3.24501e-17}, @@ -393,9 +435,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "FeM_dust", - /* nonprimoridal_yield_frac = */ 2.39849e-02, - /* size_moments = */ {4.62542e-06, 3.82292e-11, 4.68445e-16}, + /* name = */ "Mg2SiO4_dust", + /* nonprimoridal_yield_frac = */ 8.69522e-04, + /* size_moments = */ {1.82163e-06, 5.83823e-12, 3.61356e-17}, /* opacity_coef_table = */ { {1.05240e-01, 1.91709e-07, 6.14415e-13, 3.80291e-18}, {1.32588e-01, 2.41526e-07, 7.74078e-13, 4.79114e-18}, @@ -435,9 +477,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "Mg2SiO4_dust", - /* nonprimoridal_yield_frac = */ 8.69522e-04, - /* size_moments = */ {1.82163e-06, 5.83823e-12, 3.61356e-17}, + /* name = */ "MgSiO3_dust", + /* nonprimoridal_yield_frac = */ 2.87802e-06, + /* size_moments = */ {7.26303e-07, 7.49856e-13, 1.57511e-18}, /* opacity_coef_table = */ { {2.19890e-02, 1.59707e-08, 1.64886e-14, 3.46350e-20}, {3.90612e-02, 2.83703e-08, 2.92903e-14, 6.15261e-20}, @@ -477,9 +519,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "MgSiO3_dust", - /* nonprimoridal_yield_frac = */ 2.87802e-06, - /* size_moments = */ {7.26303e-07, 7.49856e-13, 1.57511e-18}, + /* name = */ "AC_dust", + /* nonprimoridal_yield_frac = */ 4.85826e-02, + /* size_moments = */ {4.82296e-06, 3.91353e-11, 5.15140e-16}, /* opacity_coef_table = */ { {3.27960e-01, 1.58173e-06, 1.28346e-11, 1.68940e-16}, {4.38754e-01, 2.11613e-06, 1.71717e-11, 2.26045e-16}, @@ -519,9 +561,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "AC_dust", - /* nonprimoridal_yield_frac = */ 4.85826e-02, - /* size_moments = */ {4.82296e-06, 3.91353e-11, 5.15140e-16}, + /* name = */ "SiO2_dust", + /* nonprimoridal_yield_frac = */ 2.52534e-03, + /* size_moments = */ {1.33530e-06, 5.91862e-12, 5.31739e-17}, /* opacity_coef_table = */ { {7.60358e-02, 1.01529e-07, 4.49989e-13, 4.04236e-18}, {9.07205e-02, 1.21137e-07, 5.36902e-13, 4.82320e-18}, @@ -561,9 +603,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "SiO2_dust", - /* nonprimoridal_yield_frac = */ 2.52534e-03, - /* size_moments = */ {1.33530e-06, 5.91862e-12, 5.31739e-17}, + /* name = */ "MgO_dust", + /* nonprimoridal_yield_frac = */ 1.28672e-05, + /* size_moments = */ {1.59029e-06, 7.21459e-12, 4.84120e-17}, /* opacity_coef_table = */ { {2.25390e-04, 3.58434e-10, 1.62608e-15, 1.09114e-20}, {4.04968e-04, 6.44015e-10, 2.92166e-15, 1.96051e-20}, @@ -603,9 +645,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "MgO_dust", - /* nonprimoridal_yield_frac = */ 1.28672e-05, - /* size_moments = */ {1.59029e-06, 7.21459e-12, 4.84120e-17}, + /* name = */ "FeS_dust", + /* nonprimoridal_yield_frac = */ 2.09730e-06, + /* size_moments = */ {6.16010e-07, 4.56500e-13, 4.16699e-19}, /* opacity_coef_table = */ { {5.18081e-02, 3.19144e-08, 2.36505e-14, 2.15886e-20}, {9.98885e-02, 6.15325e-08, 4.55993e-14, 4.16239e-20}, @@ -644,48 +686,6 @@ static const GrainSpeciesYieldProps grain_props[] = { {9.83739e+02, 6.31245e-04, 5.01948e-10, 5.05703e-16}, } }, - { - /* name = */ "FeS_dust", - /* nonprimoridal_yield_frac = */ 2.09730e-06, - /* size_moments = */ {6.16010e-07, 4.56500e-13, 4.16699e-19}, - /* opacity_coef_table = */ { - {1.54619e-01, 2.60128e-07, 1.49475e-12, 2.65148e-17}, - {1.94656e-01, 3.27554e-07, 1.88361e-12, 3.34351e-17}, - {2.45059e-01, 4.12439e-07, 2.37316e-12, 4.21472e-17}, - {3.08513e-01, 5.19301e-07, 2.98947e-12, 5.31150e-17}, - {3.88404e-01, 6.53894e-07, 3.76675e-12, 6.69643e-17}, - {4.88982e-01, 8.23350e-07, 4.74559e-12, 8.44087e-17}, - {6.15605e-01, 1.03673e-06, 5.97899e-12, 1.06403e-16}, - {7.75006e-01, 1.30539e-06, 7.53301e-12, 1.34131e-16}, - {9.75366e-01, 1.64315e-06, 9.48791e-12, 1.69031e-16}, - {1.22493e+00, 2.06392e-06, 1.19246e-11, 2.12553e-16}, - {1.52116e+00, 2.56344e-06, 1.48192e-11, 2.64285e-16}, - {1.83681e+00, 3.09586e-06, 1.79072e-11, 3.19511e-16}, - {2.15662e+00, 3.63549e-06, 2.10413e-11, 3.75635e-16}, - {2.55502e+00, 4.30820e-06, 2.49580e-11, 4.45921e-16}, - {3.22790e+00, 5.44497e-06, 3.15890e-11, 5.65115e-16}, - {4.33126e+00, 7.30995e-06, 4.24882e-11, 7.61352e-16}, - {5.81498e+00, 9.82030e-06, 5.72103e-11, 1.02723e-15}, - {7.48294e+00, 1.26484e-05, 7.39233e-11, 1.33106e-15}, - {9.21324e+00, 1.55973e-05, 9.16644e-11, 1.65851e-15}, - {1.11943e+01, 1.90119e-05, 1.13021e-10, 2.06536e-15}, - {1.39990e+01, 2.39150e-05, 1.45136e-10, 2.69938e-15}, - {1.78867e+01, 3.08010e-05, 1.92146e-10, 3.65687e-15}, - {2.17798e+01, 3.79266e-05, 2.45744e-10, 4.82338e-15}, - {2.38104e+01, 4.23268e-05, 2.93339e-10, 6.06677e-15}, - {2.31200e+01, 4.26489e-05, 3.30423e-10, 7.40538e-15}, - {2.05061e+01, 3.98990e-05, 3.56330e-10, 8.76054e-15}, - {1.74011e+01, 3.59849e-05, 3.69684e-10, 9.86673e-15}, - {1.47227e+01, 3.22080e-05, 3.69774e-10, 1.04731e-14}, - {1.27456e+01, 2.91368e-05, 3.59951e-10, 1.05598e-14}, - {1.18944e+01, 2.82426e-05, 3.62521e-10, 1.07315e-14}, - {1.43878e+01, 3.74123e-05, 4.87177e-10, 1.37994e-14}, - {2.85377e+01, 9.23385e-05, 1.20077e-09, 3.00478e-14}, - {7.93256e+01, 3.11569e-04, 3.91124e-09, 8.56317e-14}, - {2.33021e+02, 9.78251e-04, 1.15601e-08, 2.28453e-13}, - {6.42052e+02, 2.55294e-03, 2.77058e-08, 5.06000e-13}, - } - }, }; } // namespace ccsn13 @@ -708,47 +708,89 @@ static const GrainSpeciesYieldProps grain_props[] = { /* nonprimoridal_yield_frac = */ 3.44388e-02, /* size_moments = */ {1.24861e-05, 2.86508e-10, 1.01028e-14}, /* opacity_coef_table = */ { - {1.10506e-02, 1.69983e-07, 3.50089e-12, 9.16404e-17}, - {1.85837e-02, 2.76971e-07, 5.53036e-12, 1.40642e-16}, - {2.79449e-02, 4.08949e-07, 8.01809e-12, 2.00458e-16}, - {3.96605e-02, 5.73574e-07, 1.11125e-11, 2.74730e-16}, - {6.19392e-02, 8.69904e-07, 1.63567e-11, 3.93140e-16}, - {9.16817e-02, 1.25867e-06, 2.31128e-11, 5.43193e-16}, - {1.36080e-01, 1.82251e-06, 3.26005e-11, 7.47226e-16}, - {2.02056e-01, 2.63811e-06, 4.59129e-11, 1.02492e-15}, - {2.99593e-01, 3.81390e-06, 6.45602e-11, 1.40281e-15}, - {4.39758e-01, 5.46636e-06, 9.01024e-11, 1.90718e-15}, - {6.41903e-01, 7.79581e-06, 1.25163e-10, 2.58082e-15}, - {9.24985e-01, 1.09870e-05, 1.71974e-10, 3.45658e-15}, - {1.30585e+00, 1.51941e-05, 2.32250e-10, 4.55695e-15}, - {1.80164e+00, 2.05666e-05, 3.07564e-10, 5.90101e-15}, - {2.42648e+00, 2.72192e-05, 3.99035e-10, 7.50126e-15}, - {3.19207e+00, 3.52384e-05, 5.07449e-10, 9.36601e-15}, - {4.10565e+00, 4.46618e-05, 6.32978e-10, 1.14947e-14}, - {5.17172e+00, 5.54917e-05, 7.75385e-10, 1.38820e-14}, - {6.40478e+00, 6.78244e-05, 9.35760e-10, 1.65481e-14}, - {7.85614e+00, 8.21045e-05, 1.11980e-09, 1.95943e-14}, - {9.64785e+00, 9.94326e-05, 1.34166e-09, 2.32660e-14}, - {1.20159e+01, 1.21941e-04, 1.62875e-09, 2.80374e-14}, - {1.53778e+01, 1.53371e-04, 2.02922e-09, 3.47445e-14}, - {2.04423e+01, 1.99938e-04, 2.62238e-09, 4.47607e-14}, - {2.83887e+01, 2.71546e-04, 3.53030e-09, 6.01372e-14}, - {4.11773e+01, 3.83718e-04, 4.93303e-09, 8.37180e-14}, - {6.21107e+01, 5.61284e-04, 7.10254e-09, 1.19520e-13}, - {9.68132e+01, 8.45164e-04, 1.04719e-08, 1.73689e-13}, - {1.54804e+02, 1.30324e-03, 1.57446e-08, 2.55980e-13}, - {2.51780e+02, 2.04562e-03, 2.40381e-08, 3.81486e-13}, - {4.12838e+02, 3.24595e-03, 3.70714e-08, 5.72650e-13}, - {6.76592e+02, 5.16747e-03, 5.73792e-08, 8.61246e-13}, - {1.09863e+03, 8.17937e-03, 8.83910e-08, 1.28821e-12}, - {1.74646e+03, 1.26954e-02, 1.33666e-07, 1.89228e-12}, - {2.67882e+03, 1.89754e-02, 1.94753e-07, 2.68226e-12}, + {1.53894e-01, 1.90916e-06, 4.34900e-11, 1.52207e-15}, + {1.93844e-01, 2.40648e-06, 5.48634e-11, 1.92178e-15}, + {2.44138e-01, 3.03256e-06, 6.91797e-11, 2.42474e-15}, + {3.07454e-01, 3.82073e-06, 8.72020e-11, 3.05783e-15}, + {3.87243e-01, 4.81526e-06, 1.09978e-10, 3.85936e-15}, + {4.87709e-01, 6.06778e-06, 1.38669e-10, 4.86916e-15}, + {6.14251e-01, 7.64642e-06, 1.74856e-10, 6.14383e-15}, + {7.73625e-01, 9.63590e-06, 2.20495e-10, 7.75268e-15}, + {9.74036e-01, 1.21392e-05, 2.77959e-10, 9.78002e-15}, + {1.22376e+00, 1.52600e-05, 3.49642e-10, 1.23105e-14}, + {1.52029e+00, 1.89682e-05, 4.34881e-10, 1.53223e-14}, + {1.83650e+00, 2.29254e-05, 5.25941e-10, 1.85447e-14}, + {2.15714e+00, 2.69443e-05, 6.18616e-10, 2.18354e-14}, + {2.55729e+00, 3.19712e-05, 7.34846e-10, 2.59753e-14}, + {3.23398e+00, 4.04866e-05, 9.32032e-10, 3.30022e-14}, + {4.34499e+00, 5.44911e-05, 1.25683e-09, 4.45846e-14}, + {5.84259e+00, 7.34292e-05, 1.69748e-09, 6.03345e-14}, + {7.53509e+00, 9.49825e-05, 2.20255e-09, 7.84868e-14}, + {9.31292e+00, 1.17996e-04, 2.75076e-09, 9.84428e-14}, + {1.14053e+01, 1.46050e-04, 3.44207e-09, 1.24265e-13}, + {1.44699e+01, 1.88865e-04, 4.53802e-09, 1.66375e-13}, + {1.88525e+01, 2.52409e-04, 6.22006e-09, 2.32633e-13}, + {2.35897e+01, 3.27106e-04, 8.33967e-09, 3.20293e-13}, + {2.71065e+01, 3.99935e-04, 1.08043e-08, 4.33797e-13}, + {2.87408e+01, 4.69399e-04, 1.38602e-08, 5.94648e-13}, + {2.88428e+01, 5.34587e-04, 1.74785e-08, 8.07129e-13}, + {2.80514e+01, 5.86377e-04, 2.09655e-08, 1.03092e-12}, + {2.67893e+01, 6.13530e-04, 2.33810e-08, 1.20137e-12}, + {2.53851e+01, 6.14601e-04, 2.43011e-08, 1.28034e-12}, + {2.53848e+01, 6.23633e-04, 2.48207e-08, 1.31287e-12}, + {3.52560e+01, 8.08661e-04, 3.01974e-08, 1.52398e-12}, + {9.64731e+01, 1.84326e-03, 5.73265e-08, 2.51143e-12}, + {3.56496e+02, 5.70937e-03, 1.44867e-07, 5.33930e-12}, + {1.16716e+03, 1.65654e-02, 3.60906e-07, 1.15456e-11}, + {3.02792e+03, 3.93985e-02, 7.71226e-07, 2.22345e-11}, } }, { /* name = */ "FeM_dust", /* nonprimoridal_yield_frac = */ 3.77223e-03, /* size_moments = */ {6.67024e-06, 7.50596e-11, 1.22752e-15}, + /* opacity_coef_table = */ { + {1.10506e-02, 1.69983e-07, 3.50089e-12, 9.16404e-17}, + {1.85837e-02, 2.76971e-07, 5.53036e-12, 1.40642e-16}, + {2.79449e-02, 4.08949e-07, 8.01809e-12, 2.00458e-16}, + {3.96605e-02, 5.73574e-07, 1.11125e-11, 2.74730e-16}, + {6.19392e-02, 8.69904e-07, 1.63567e-11, 3.93140e-16}, + {9.16817e-02, 1.25867e-06, 2.31128e-11, 5.43193e-16}, + {1.36080e-01, 1.82251e-06, 3.26005e-11, 7.47226e-16}, + {2.02056e-01, 2.63811e-06, 4.59129e-11, 1.02492e-15}, + {2.99593e-01, 3.81390e-06, 6.45602e-11, 1.40281e-15}, + {4.39758e-01, 5.46636e-06, 9.01024e-11, 1.90718e-15}, + {6.41903e-01, 7.79581e-06, 1.25163e-10, 2.58082e-15}, + {9.24985e-01, 1.09870e-05, 1.71974e-10, 3.45658e-15}, + {1.30585e+00, 1.51941e-05, 2.32250e-10, 4.55695e-15}, + {1.80164e+00, 2.05666e-05, 3.07564e-10, 5.90101e-15}, + {2.42648e+00, 2.72192e-05, 3.99035e-10, 7.50126e-15}, + {3.19207e+00, 3.52384e-05, 5.07449e-10, 9.36601e-15}, + {4.10565e+00, 4.46618e-05, 6.32978e-10, 1.14947e-14}, + {5.17172e+00, 5.54917e-05, 7.75385e-10, 1.38820e-14}, + {6.40478e+00, 6.78244e-05, 9.35760e-10, 1.65481e-14}, + {7.85614e+00, 8.21045e-05, 1.11980e-09, 1.95943e-14}, + {9.64785e+00, 9.94326e-05, 1.34166e-09, 2.32660e-14}, + {1.20159e+01, 1.21941e-04, 1.62875e-09, 2.80374e-14}, + {1.53778e+01, 1.53371e-04, 2.02922e-09, 3.47445e-14}, + {2.04423e+01, 1.99938e-04, 2.62238e-09, 4.47607e-14}, + {2.83887e+01, 2.71546e-04, 3.53030e-09, 6.01372e-14}, + {4.11773e+01, 3.83718e-04, 4.93303e-09, 8.37180e-14}, + {6.21107e+01, 5.61284e-04, 7.10254e-09, 1.19520e-13}, + {9.68132e+01, 8.45164e-04, 1.04719e-08, 1.73689e-13}, + {1.54804e+02, 1.30324e-03, 1.57446e-08, 2.55980e-13}, + {2.51780e+02, 2.04562e-03, 2.40381e-08, 3.81486e-13}, + {4.12838e+02, 3.24595e-03, 3.70714e-08, 5.72650e-13}, + {6.76592e+02, 5.16747e-03, 5.73792e-08, 8.61246e-13}, + {1.09863e+03, 8.17937e-03, 8.83910e-08, 1.28821e-12}, + {1.74646e+03, 1.26954e-02, 1.33666e-07, 1.89228e-12}, + {2.67882e+03, 1.89754e-02, 1.94753e-07, 2.68226e-12}, + } + }, + { + /* name = */ "Mg2SiO4_dust", + /* nonprimoridal_yield_frac = */ 1.90086e-03, + /* size_moments = */ {1.41253e-06, 4.77566e-12, 3.08016e-17}, /* opacity_coef_table = */ { {1.05240e-01, 1.48654e-07, 5.02591e-13, 3.24156e-18}, {1.32588e-01, 1.87284e-07, 6.33194e-13, 4.08391e-18}, @@ -788,9 +830,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "Mg2SiO4_dust", - /* nonprimoridal_yield_frac = */ 1.90086e-03, - /* size_moments = */ {1.41253e-06, 4.77566e-12, 3.08016e-17}, + /* name = */ "MgSiO3_dust", + /* nonprimoridal_yield_frac = */ 2.57266e-06, + /* size_moments = */ {1.01138e-06, 1.31688e-12, 2.89696e-18}, /* opacity_coef_table = */ { {2.19890e-02, 2.22393e-08, 2.89570e-14, 6.37012e-20}, {3.90612e-02, 3.95059e-08, 5.14391e-14, 1.13159e-19}, @@ -830,9 +872,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "MgSiO3_dust", - /* nonprimoridal_yield_frac = */ 2.57266e-06, - /* size_moments = */ {1.01138e-06, 1.31688e-12, 2.89696e-18}, + /* name = */ "AC_dust", + /* nonprimoridal_yield_frac = */ 1.27270e-02, + /* size_moments = */ {7.95099e-07, 2.51133e-12, 4.21640e-17}, /* opacity_coef_table = */ { {3.27960e-01, 2.60760e-07, 8.23594e-13, 1.38274e-17}, {4.38752e-01, 3.48855e-07, 1.10197e-12, 1.85031e-17}, @@ -872,9 +914,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "AC_dust", - /* nonprimoridal_yield_frac = */ 1.27270e-02, - /* size_moments = */ {7.95099e-07, 2.51133e-12, 4.21640e-17}, + /* name = */ "SiO2_dust", + /* nonprimoridal_yield_frac = */ 1.65484e-03, + /* size_moments = */ {1.40285e-06, 3.98828e-12, 1.93974e-17}, /* opacity_coef_table = */ { {7.60358e-02, 1.06666e-07, 3.03247e-13, 1.47482e-18}, {9.07206e-02, 1.27267e-07, 3.61815e-13, 1.75967e-18}, @@ -914,9 +956,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "SiO2_dust", - /* nonprimoridal_yield_frac = */ 1.65484e-03, - /* size_moments = */ {1.40285e-06, 3.98828e-12, 1.93974e-17}, + /* name = */ "MgO_dust", + /* nonprimoridal_yield_frac = */ 9.48713e-04, + /* size_moments = */ {1.29303e-06, 1.06240e-11, 1.57687e-16}, /* opacity_coef_table = */ { {2.25389e-04, 2.91423e-10, 2.39426e-15, 3.55346e-20}, {4.04967e-04, 5.23622e-10, 4.30206e-15, 6.38511e-20}, @@ -956,9 +998,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "MgO_dust", - /* nonprimoridal_yield_frac = */ 9.48713e-04, - /* size_moments = */ {1.29303e-06, 1.06240e-11, 1.57687e-16}, + /* name = */ "FeS_dust", + /* nonprimoridal_yield_frac = */ 5.23050e-05, + /* size_moments = */ {1.68897e-06, 3.16618e-12, 6.72598e-18}, /* opacity_coef_table = */ { {5.18099e-02, 8.75057e-08, 1.64042e-13, 3.48481e-19}, {9.98914e-02, 1.68714e-07, 3.16278e-13, 6.71882e-19}, @@ -998,9 +1040,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "FeS_dust", - /* nonprimoridal_yield_frac = */ 5.23050e-05, - /* size_moments = */ {1.68897e-06, 3.16618e-12, 6.72598e-18}, + /* name = */ "Al2O3_dust", + /* nonprimoridal_yield_frac = */ 1.31693e-29, + /* size_moments = */ {9.21063e-08, 9.03508e-15, 9.36936e-22}, /* opacity_coef_table = */ { {9.93250e-04, 9.14846e-11, 8.97410e-18, 9.30612e-25}, {1.81240e-03, 1.66933e-10, 1.63752e-17, 1.69810e-24}, @@ -1039,48 +1081,6 @@ static const GrainSpeciesYieldProps grain_props[] = { {1.81893e+01, 1.67535e-06, 1.64342e-13, 1.70422e-20}, } }, - { - /* name = */ "Al2O3_dust", - /* nonprimoridal_yield_frac = */ 1.31693e-29, - /* size_moments = */ {9.21063e-08, 9.03508e-15, 9.36936e-22}, - /* opacity_coef_table = */ { - {1.53894e-01, 1.90916e-06, 4.34900e-11, 1.52207e-15}, - {1.93844e-01, 2.40648e-06, 5.48634e-11, 1.92178e-15}, - {2.44138e-01, 3.03256e-06, 6.91797e-11, 2.42474e-15}, - {3.07454e-01, 3.82073e-06, 8.72020e-11, 3.05783e-15}, - {3.87243e-01, 4.81526e-06, 1.09978e-10, 3.85936e-15}, - {4.87709e-01, 6.06778e-06, 1.38669e-10, 4.86916e-15}, - {6.14251e-01, 7.64642e-06, 1.74856e-10, 6.14383e-15}, - {7.73625e-01, 9.63590e-06, 2.20495e-10, 7.75268e-15}, - {9.74036e-01, 1.21392e-05, 2.77959e-10, 9.78002e-15}, - {1.22376e+00, 1.52600e-05, 3.49642e-10, 1.23105e-14}, - {1.52029e+00, 1.89682e-05, 4.34881e-10, 1.53223e-14}, - {1.83650e+00, 2.29254e-05, 5.25941e-10, 1.85447e-14}, - {2.15714e+00, 2.69443e-05, 6.18616e-10, 2.18354e-14}, - {2.55729e+00, 3.19712e-05, 7.34846e-10, 2.59753e-14}, - {3.23398e+00, 4.04866e-05, 9.32032e-10, 3.30022e-14}, - {4.34499e+00, 5.44911e-05, 1.25683e-09, 4.45846e-14}, - {5.84259e+00, 7.34292e-05, 1.69748e-09, 6.03345e-14}, - {7.53509e+00, 9.49825e-05, 2.20255e-09, 7.84868e-14}, - {9.31292e+00, 1.17996e-04, 2.75076e-09, 9.84428e-14}, - {1.14053e+01, 1.46050e-04, 3.44207e-09, 1.24265e-13}, - {1.44699e+01, 1.88865e-04, 4.53802e-09, 1.66375e-13}, - {1.88525e+01, 2.52409e-04, 6.22006e-09, 2.32633e-13}, - {2.35897e+01, 3.27106e-04, 8.33967e-09, 3.20293e-13}, - {2.71065e+01, 3.99935e-04, 1.08043e-08, 4.33797e-13}, - {2.87408e+01, 4.69399e-04, 1.38602e-08, 5.94648e-13}, - {2.88428e+01, 5.34587e-04, 1.74785e-08, 8.07129e-13}, - {2.80514e+01, 5.86377e-04, 2.09655e-08, 1.03092e-12}, - {2.67893e+01, 6.13530e-04, 2.33810e-08, 1.20137e-12}, - {2.53851e+01, 6.14601e-04, 2.43011e-08, 1.28034e-12}, - {2.53848e+01, 6.23633e-04, 2.48207e-08, 1.31287e-12}, - {3.52560e+01, 8.08661e-04, 3.01974e-08, 1.52398e-12}, - {9.64731e+01, 1.84326e-03, 5.73265e-08, 2.51143e-12}, - {3.56496e+02, 5.70937e-03, 1.44867e-07, 5.33930e-12}, - {1.16716e+03, 1.65654e-02, 3.60906e-07, 1.15456e-11}, - {3.02792e+03, 3.93985e-02, 7.71226e-07, 2.22345e-11}, - } - }, }; } // namespace ccsn20 @@ -1102,6 +1102,48 @@ static const GrainSpeciesYieldProps grain_props[] = { /* name = */ "SiM_dust", /* nonprimoridal_yield_frac = */ 3.83373e-02, /* size_moments = */ {1.72153e-05, 6.33208e-10, 4.04318e-14}, + /* opacity_coef_table = */ { + {1.53307e-01, 2.58151e-06, 8.97185e-11, 5.13410e-15}, + {1.93187e-01, 3.26103e-06, 1.14053e-10, 6.60852e-15}, + {2.43381e-01, 4.11484e-06, 1.44443e-10, 8.42753e-15}, + {3.06566e-01, 5.18903e-06, 1.82603e-10, 1.07022e-14}, + {3.86268e-01, 6.55217e-06, 2.31853e-10, 1.37374e-14}, + {4.86630e-01, 8.26891e-06, 2.93869e-10, 1.75576e-14}, + {6.13093e-01, 1.04376e-05, 3.72751e-10, 2.24815e-14}, + {7.72441e-01, 1.31779e-05, 4.73205e-10, 2.88483e-14}, + {9.72908e-01, 1.66348e-05, 6.00927e-10, 3.70670e-14}, + {1.22279e+00, 2.09532e-05, 7.61455e-10, 4.75186e-14}, + {1.51967e+00, 2.61010e-05, 9.54694e-10, 6.03376e-14}, + {1.83660e+00, 3.16418e-05, 1.16836e-09, 7.52509e-14}, + {2.15883e+00, 3.73832e-05, 1.40366e-09, 9.34936e-14}, + {2.56188e+00, 4.46730e-05, 1.71564e-09, 1.19386e-13}, + {3.24331e+00, 5.69556e-05, 2.23297e-09, 1.61351e-13}, + {4.36192e+00, 7.70449e-05, 3.06366e-09, 2.26659e-13}, + {5.87089e+00, 1.04185e-04, 4.17746e-09, 3.12654e-13}, + {7.58000e+00, 1.35161e-04, 5.44737e-09, 4.09330e-13}, + {9.38530e+00, 1.68565e-04, 6.82760e-09, 5.12932e-13}, + {1.15371e+01, 2.10285e-04, 8.59830e-09, 6.44799e-13}, + {1.47388e+01, 2.75860e-04, 1.14755e-08, 8.58985e-13}, + {1.93877e+01, 3.75887e-04, 1.59953e-08, 1.19600e-12}, + {2.46008e+01, 5.00971e-04, 2.20360e-08, 1.65571e-12}, + {2.90408e+01, 6.45456e-04, 3.01610e-08, 2.31085e-12}, + {3.23701e+01, 8.27330e-04, 4.23216e-08, 3.35508e-12}, + {3.49305e+01, 1.05238e-03, 5.92405e-08, 4.87268e-12}, + {3.68020e+01, 1.28200e-03, 7.79075e-08, 6.59988e-12}, + {3.76194e+01, 1.45174e-03, 9.27975e-08, 8.01634e-12}, + {3.72617e+01, 1.52446e-03, 1.00177e-07, 8.74632e-12}, + {3.76576e+01, 1.55784e-03, 1.02687e-07, 8.96074e-12}, + {4.91245e+01, 1.84545e-03, 1.14505e-07, 9.64022e-12}, + {1.17100e+02, 3.32870e-03, 1.70057e-07, 1.27411e-11}, + {3.93519e+02, 8.31574e-03, 3.27938e-07, 2.07522e-11}, + {1.23314e+03, 2.12665e-02, 6.72506e-07, 3.61691e-11}, + {3.12736e+03, 4.71942e-02, 1.26825e-06, 5.97225e-11}, + } + }, + { + /* name = */ "FeM_dust", + /* nonprimoridal_yield_frac = */ 4.88366e-03, + /* size_moments = */ {1.96666e-05, 5.88305e-10, 2.42323e-14}, /* opacity_coef_table = */ { {7.05387e-02, 2.70513e-06, 1.33741e-10, 7.96280e-15}, {1.06564e-01, 3.93018e-06, 1.88633e-10, 1.09924e-14}, @@ -1141,9 +1183,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "FeM_dust", - /* nonprimoridal_yield_frac = */ 4.88366e-03, - /* size_moments = */ {1.96666e-05, 5.88305e-10, 2.42323e-14}, + /* name = */ "Mg2SiO4_dust", + /* nonprimoridal_yield_frac = */ 1.68068e-02, + /* size_moments = */ {2.33213e-06, 2.48648e-11, 4.29427e-16}, /* opacity_coef_table = */ { {1.05240e-01, 2.45433e-07, 2.61677e-12, 4.51929e-17}, {1.32588e-01, 3.09211e-07, 3.29676e-12, 5.69367e-17}, @@ -1183,9 +1225,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "Mg2SiO4_dust", - /* nonprimoridal_yield_frac = */ 1.68068e-02, - /* size_moments = */ {2.33213e-06, 2.48648e-11, 4.29427e-16}, + /* name = */ "MgSiO3_dust", + /* nonprimoridal_yield_frac = */ 2.49736e-05, + /* size_moments = */ {1.55439e-06, 4.30058e-12, 1.92568e-17}, /* opacity_coef_table = */ { {2.19890e-02, 3.41795e-08, 9.45655e-14, 4.23439e-19}, {3.90612e-02, 6.07164e-08, 1.67986e-13, 7.52197e-19}, @@ -1225,9 +1267,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "MgSiO3_dust", - /* nonprimoridal_yield_frac = */ 2.49736e-05, - /* size_moments = */ {1.55439e-06, 4.30058e-12, 1.92568e-17}, + /* name = */ "AC_dust", + /* nonprimoridal_yield_frac = */ 4.13961e-02, + /* size_moments = */ {7.93494e-07, 3.53402e-12, 1.04050e-16}, /* opacity_coef_table = */ { {3.27960e-01, 2.60233e-07, 1.15896e-12, 3.41207e-17}, {4.38752e-01, 3.48153e-07, 1.55085e-12, 4.56711e-17}, @@ -1267,9 +1309,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "AC_dust", - /* nonprimoridal_yield_frac = */ 4.13961e-02, - /* size_moments = */ {7.93494e-07, 3.53402e-12, 1.04050e-16}, + /* name = */ "SiO2_dust", + /* nonprimoridal_yield_frac = */ 1.46546e-02, + /* size_moments = */ {2.56804e-06, 4.82971e-11, 2.53766e-15}, /* opacity_coef_table = */ { {7.60344e-02, 1.95196e-07, 3.66716e-12, 1.92423e-16}, {9.07191e-02, 2.32906e-07, 4.37632e-12, 2.29682e-16}, @@ -1309,9 +1351,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "SiO2_dust", - /* nonprimoridal_yield_frac = */ 1.46546e-02, - /* size_moments = */ {2.56804e-06, 4.82971e-11, 2.53766e-15}, + /* name = */ "MgO_dust", + /* nonprimoridal_yield_frac = */ 1.09289e-03, + /* size_moments = */ {3.58420e-06, 3.09713e-11, 4.03929e-16}, /* opacity_coef_table = */ { {2.25388e-04, 8.07807e-10, 6.97998e-15, 9.10286e-20}, {4.04965e-04, 1.45145e-09, 1.25417e-14, 1.63564e-19}, @@ -1351,9 +1393,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "MgO_dust", - /* nonprimoridal_yield_frac = */ 1.09289e-03, - /* size_moments = */ {3.58420e-06, 3.09713e-11, 4.03929e-16}, + /* name = */ "FeS_dust", + /* nonprimoridal_yield_frac = */ 3.77935e-04, + /* size_moments = */ {9.61035e-07, 2.46507e-12, 1.42549e-17}, /* opacity_coef_table = */ { {5.18089e-02, 4.97944e-08, 1.27767e-13, 7.39409e-19}, {9.98898e-02, 9.60047e-08, 2.46329e-13, 1.42543e-18}, @@ -1393,9 +1435,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "FeS_dust", - /* nonprimoridal_yield_frac = */ 3.77935e-04, - /* size_moments = */ {9.61035e-07, 2.46507e-12, 1.42549e-17}, + /* name = */ "Al2O3_dust", + /* nonprimoridal_yield_frac = */ 1.65550e-31, + /* size_moments = */ {1.99526e-08, 3.98107e-16, 7.94328e-24}, /* opacity_coef_table = */ { {9.93250e-04, 1.98179e-11, 3.95420e-19, 7.88967e-27}, {1.81240e-03, 3.61621e-11, 7.21529e-19, 1.43964e-26}, @@ -1434,48 +1476,6 @@ static const GrainSpeciesYieldProps grain_props[] = { {1.81893e+01, 3.62924e-07, 7.24128e-15, 1.44483e-22}, } }, - { - /* name = */ "Al2O3_dust", - /* nonprimoridal_yield_frac = */ 1.65550e-31, - /* size_moments = */ {1.99526e-08, 3.98107e-16, 7.94328e-24}, - /* opacity_coef_table = */ { - {1.53307e-01, 2.58151e-06, 8.97185e-11, 5.13410e-15}, - {1.93187e-01, 3.26103e-06, 1.14053e-10, 6.60852e-15}, - {2.43381e-01, 4.11484e-06, 1.44443e-10, 8.42753e-15}, - {3.06566e-01, 5.18903e-06, 1.82603e-10, 1.07022e-14}, - {3.86268e-01, 6.55217e-06, 2.31853e-10, 1.37374e-14}, - {4.86630e-01, 8.26891e-06, 2.93869e-10, 1.75576e-14}, - {6.13093e-01, 1.04376e-05, 3.72751e-10, 2.24815e-14}, - {7.72441e-01, 1.31779e-05, 4.73205e-10, 2.88483e-14}, - {9.72908e-01, 1.66348e-05, 6.00927e-10, 3.70670e-14}, - {1.22279e+00, 2.09532e-05, 7.61455e-10, 4.75186e-14}, - {1.51967e+00, 2.61010e-05, 9.54694e-10, 6.03376e-14}, - {1.83660e+00, 3.16418e-05, 1.16836e-09, 7.52509e-14}, - {2.15883e+00, 3.73832e-05, 1.40366e-09, 9.34936e-14}, - {2.56188e+00, 4.46730e-05, 1.71564e-09, 1.19386e-13}, - {3.24331e+00, 5.69556e-05, 2.23297e-09, 1.61351e-13}, - {4.36192e+00, 7.70449e-05, 3.06366e-09, 2.26659e-13}, - {5.87089e+00, 1.04185e-04, 4.17746e-09, 3.12654e-13}, - {7.58000e+00, 1.35161e-04, 5.44737e-09, 4.09330e-13}, - {9.38530e+00, 1.68565e-04, 6.82760e-09, 5.12932e-13}, - {1.15371e+01, 2.10285e-04, 8.59830e-09, 6.44799e-13}, - {1.47388e+01, 2.75860e-04, 1.14755e-08, 8.58985e-13}, - {1.93877e+01, 3.75887e-04, 1.59953e-08, 1.19600e-12}, - {2.46008e+01, 5.00971e-04, 2.20360e-08, 1.65571e-12}, - {2.90408e+01, 6.45456e-04, 3.01610e-08, 2.31085e-12}, - {3.23701e+01, 8.27330e-04, 4.23216e-08, 3.35508e-12}, - {3.49305e+01, 1.05238e-03, 5.92405e-08, 4.87268e-12}, - {3.68020e+01, 1.28200e-03, 7.79075e-08, 6.59988e-12}, - {3.76194e+01, 1.45174e-03, 9.27975e-08, 8.01634e-12}, - {3.72617e+01, 1.52446e-03, 1.00177e-07, 8.74632e-12}, - {3.76576e+01, 1.55784e-03, 1.02687e-07, 8.96074e-12}, - {4.91245e+01, 1.84545e-03, 1.14505e-07, 9.64022e-12}, - {1.17100e+02, 3.32870e-03, 1.70057e-07, 1.27411e-11}, - {3.93519e+02, 8.31574e-03, 3.27938e-07, 2.07522e-11}, - {1.23314e+03, 2.12665e-02, 6.72506e-07, 3.61691e-11}, - {3.12736e+03, 4.71942e-02, 1.26825e-06, 5.97225e-11}, - } - }, }; } // namespace ccsn25 @@ -1497,6 +1497,48 @@ static const GrainSpeciesYieldProps grain_props[] = { /* name = */ "SiM_dust", /* nonprimoridal_yield_frac = */ 2.91389e-02, /* size_moments = */ {2.56305e-05, 1.02092e-09, 5.78476e-14}, + /* opacity_coef_table = */ { + {1.52613e-01, 3.87036e-06, 1.51475e-10, 8.34686e-15}, + {1.92410e-01, 4.88554e-06, 1.91604e-10, 1.05937e-14}, + {2.42503e-01, 6.16264e-06, 2.42001e-10, 1.34057e-14}, + {3.05564e-01, 7.77004e-06, 3.05397e-10, 1.69392e-14}, + {3.85174e-01, 9.80462e-06, 3.86046e-10, 2.14732e-14}, + {4.85438e-01, 1.23675e-05, 4.87634e-10, 2.71828e-14}, + {6.11833e-01, 1.56019e-05, 6.16102e-10, 3.44270e-14}, + {7.71157e-01, 1.96838e-05, 7.78585e-10, 4.36231e-14}, + {9.71669e-01, 2.48269e-05, 9.83743e-10, 5.52763e-14}, + {1.22169e+00, 3.12457e-05, 1.24021e-09, 6.98829e-14}, + {1.51883e+00, 3.88844e-05, 1.54619e-09, 8.73862e-14}, + {1.83610e+00, 4.70620e-05, 1.87584e-09, 1.06471e-13}, + {2.15867e+00, 5.54249e-05, 2.21779e-09, 1.26800e-13}, + {2.56252e+00, 6.59468e-05, 2.65228e-09, 1.53070e-13}, + {3.24657e+00, 8.37697e-05, 3.38561e-09, 1.97020e-13}, + {4.37158e+00, 1.13090e-04, 4.58835e-09, 2.68525e-13}, + {5.89356e+00, 1.52861e-04, 6.22099e-09, 3.65325e-13}, + {7.62770e+00, 1.98484e-04, 8.10272e-09, 4.76950e-13}, + {9.48448e+00, 2.48132e-04, 1.01763e-08, 6.00571e-13}, + {1.17614e+01, 3.11117e-04, 1.28785e-08, 7.63878e-13}, + {1.52604e+01, 4.11692e-04, 1.73236e-08, 1.03683e-12}, + {2.04857e+01, 5.67120e-04, 2.43755e-08, 1.47603e-12}, + {2.67121e+01, 7.65926e-04, 3.38756e-08, 2.08532e-12}, + {3.30214e+01, 1.00600e-03, 4.67023e-08, 2.95970e-12}, + {3.94796e+01, 1.32148e-03, 6.59032e-08, 4.35947e-12}, + {4.60630e+01, 1.71870e-03, 9.26057e-08, 6.41018e-12}, + {5.17888e+01, 2.12529e-03, 1.22060e-07, 8.76593e-12}, + {5.52863e+01, 2.42692e-03, 1.45553e-07, 1.07154e-11}, + {5.60930e+01, 2.55895e-03, 1.57221e-07, 1.17347e-11}, + {5.70683e+01, 2.61927e-03, 1.61476e-07, 1.20713e-11}, + {7.25749e+01, 3.09971e-03, 1.82166e-07, 1.32162e-11}, + {1.59194e+02, 5.49929e-03, 2.77545e-07, 1.82852e-11}, + {4.83739e+02, 1.31658e-02, 5.43977e-07, 3.13196e-11}, + {1.39550e+03, 3.19882e-02, 1.11499e-06, 5.65773e-11}, + {3.29912e+03, 6.76125e-02, 2.08154e-06, 9.54501e-11}, + } + }, + { + /* name = */ "FeM_dust", + /* nonprimoridal_yield_frac = */ 1.93065e-03, + /* size_moments = */ {2.05800e-05, 5.92424e-10, 2.26690e-14}, /* opacity_coef_table = */ { {7.21495e-02, 2.58300e-06, 1.19134e-10, 6.77090e-15}, {1.09797e-01, 3.79107e-06, 1.69411e-10, 9.39020e-15}, @@ -1536,9 +1578,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "FeM_dust", - /* nonprimoridal_yield_frac = */ 1.93065e-03, - /* size_moments = */ {2.05800e-05, 5.92424e-10, 2.26690e-14}, + /* name = */ "Mg2SiO4_dust", + /* nonprimoridal_yield_frac = */ 7.73041e-04, + /* size_moments = */ {4.70227e-07, 6.29420e-13, 1.71079e-18}, /* opacity_coef_table = */ { {1.05240e-01, 4.94867e-08, 6.62401e-14, 1.80043e-19}, {1.32588e-01, 6.23464e-08, 8.34533e-14, 2.26830e-19}, @@ -1578,9 +1620,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "Mg2SiO4_dust", - /* nonprimoridal_yield_frac = */ 7.73041e-04, - /* size_moments = */ {4.70227e-07, 6.29420e-13, 1.71079e-18}, + /* name = */ "MgSiO3_dust", + /* nonprimoridal_yield_frac = */ 4.17376e-06, + /* size_moments = */ {1.02156e-06, 1.31765e-12, 2.63083e-18}, /* opacity_coef_table = */ { {2.19890e-02, 2.24631e-08, 2.89738e-14, 5.78493e-20}, {3.90612e-02, 3.99034e-08, 5.14691e-14, 1.02764e-19}, @@ -1620,9 +1662,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "MgSiO3_dust", - /* nonprimoridal_yield_frac = */ 4.17376e-06, - /* size_moments = */ {1.02156e-06, 1.31765e-12, 2.63083e-18}, + /* name = */ "AC_dust", + /* nonprimoridal_yield_frac = */ 6.19235e-04, + /* size_moments = */ {1.17005e-06, 2.37154e-12, 7.59875e-18}, /* opacity_coef_table = */ { {3.27960e-01, 3.83729e-07, 7.77768e-13, 2.49208e-18}, {4.38752e-01, 5.13360e-07, 1.04052e-12, 3.33400e-18}, @@ -1662,9 +1704,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "AC_dust", - /* nonprimoridal_yield_frac = */ 6.19235e-04, - /* size_moments = */ {1.17005e-06, 2.37154e-12, 7.59875e-18}, + /* name = */ "SiO2_dust", + /* nonprimoridal_yield_frac = */ 5.27016e-03, + /* size_moments = */ {1.62875e-06, 1.12314e-11, 1.91031e-16}, /* opacity_coef_table = */ { {7.60354e-02, 1.23833e-07, 8.53754e-13, 1.45191e-17}, {9.07201e-02, 1.47751e-07, 1.01868e-12, 1.73242e-17}, @@ -1704,9 +1746,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "SiO2_dust", - /* nonprimoridal_yield_frac = */ 5.27016e-03, - /* size_moments = */ {1.62875e-06, 1.12314e-11, 1.91031e-16}, + /* name = */ "MgO_dust", + /* nonprimoridal_yield_frac = */ 1.33978e-03, + /* size_moments = */ {2.32229e-06, 1.39783e-11, 1.49800e-16}, /* opacity_coef_table = */ { {2.25389e-04, 5.23412e-10, 3.15038e-15, 3.37599e-20}, {4.04967e-04, 9.40443e-10, 5.66055e-15, 6.06603e-20}, @@ -1746,9 +1788,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "MgO_dust", - /* nonprimoridal_yield_frac = */ 1.33978e-03, - /* size_moments = */ {2.32229e-06, 1.39783e-11, 1.49800e-16}, + /* name = */ "FeS_dust", + /* nonprimoridal_yield_frac = */ 4.51744e-04, + /* size_moments = */ {1.69769e-06, 6.40794e-12, 4.40126e-17}, /* opacity_coef_table = */ { {5.18102e-02, 8.79700e-08, 3.32172e-13, 2.28308e-18}, {9.98920e-02, 1.69607e-07, 6.40403e-13, 4.40131e-18}, @@ -1788,9 +1830,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "FeS_dust", - /* nonprimoridal_yield_frac = */ 4.51744e-04, - /* size_moments = */ {1.69769e-06, 6.40794e-12, 4.40126e-17}, + /* name = */ "Al2O3_dust", + /* nonprimoridal_yield_frac = */ 5.79251e-12, + /* size_moments = */ {7.63588e-08, 8.88224e-15, 1.42247e-21}, /* opacity_coef_table = */ { {9.93250e-04, 7.58434e-11, 8.82228e-18, 1.41287e-24}, {1.81240e-03, 1.38393e-10, 1.60982e-17, 2.57809e-24}, @@ -1829,48 +1871,6 @@ static const GrainSpeciesYieldProps grain_props[] = { {1.81893e+01, 1.38891e-06, 1.61561e-13, 2.58738e-20}, } }, - { - /* name = */ "Al2O3_dust", - /* nonprimoridal_yield_frac = */ 5.79251e-12, - /* size_moments = */ {7.63588e-08, 8.88224e-15, 1.42247e-21}, - /* opacity_coef_table = */ { - {1.52613e-01, 3.87036e-06, 1.51475e-10, 8.34686e-15}, - {1.92410e-01, 4.88554e-06, 1.91604e-10, 1.05937e-14}, - {2.42503e-01, 6.16264e-06, 2.42001e-10, 1.34057e-14}, - {3.05564e-01, 7.77004e-06, 3.05397e-10, 1.69392e-14}, - {3.85174e-01, 9.80462e-06, 3.86046e-10, 2.14732e-14}, - {4.85438e-01, 1.23675e-05, 4.87634e-10, 2.71828e-14}, - {6.11833e-01, 1.56019e-05, 6.16102e-10, 3.44270e-14}, - {7.71157e-01, 1.96838e-05, 7.78585e-10, 4.36231e-14}, - {9.71669e-01, 2.48269e-05, 9.83743e-10, 5.52763e-14}, - {1.22169e+00, 3.12457e-05, 1.24021e-09, 6.98829e-14}, - {1.51883e+00, 3.88844e-05, 1.54619e-09, 8.73862e-14}, - {1.83610e+00, 4.70620e-05, 1.87584e-09, 1.06471e-13}, - {2.15867e+00, 5.54249e-05, 2.21779e-09, 1.26800e-13}, - {2.56252e+00, 6.59468e-05, 2.65228e-09, 1.53070e-13}, - {3.24657e+00, 8.37697e-05, 3.38561e-09, 1.97020e-13}, - {4.37158e+00, 1.13090e-04, 4.58835e-09, 2.68525e-13}, - {5.89356e+00, 1.52861e-04, 6.22099e-09, 3.65325e-13}, - {7.62770e+00, 1.98484e-04, 8.10272e-09, 4.76950e-13}, - {9.48448e+00, 2.48132e-04, 1.01763e-08, 6.00571e-13}, - {1.17614e+01, 3.11117e-04, 1.28785e-08, 7.63878e-13}, - {1.52604e+01, 4.11692e-04, 1.73236e-08, 1.03683e-12}, - {2.04857e+01, 5.67120e-04, 2.43755e-08, 1.47603e-12}, - {2.67121e+01, 7.65926e-04, 3.38756e-08, 2.08532e-12}, - {3.30214e+01, 1.00600e-03, 4.67023e-08, 2.95970e-12}, - {3.94796e+01, 1.32148e-03, 6.59032e-08, 4.35947e-12}, - {4.60630e+01, 1.71870e-03, 9.26057e-08, 6.41018e-12}, - {5.17888e+01, 2.12529e-03, 1.22060e-07, 8.76593e-12}, - {5.52863e+01, 2.42692e-03, 1.45553e-07, 1.07154e-11}, - {5.60930e+01, 2.55895e-03, 1.57221e-07, 1.17347e-11}, - {5.70683e+01, 2.61927e-03, 1.61476e-07, 1.20713e-11}, - {7.25749e+01, 3.09971e-03, 1.82166e-07, 1.32162e-11}, - {1.59194e+02, 5.49929e-03, 2.77545e-07, 1.82852e-11}, - {4.83739e+02, 1.31658e-02, 5.43977e-07, 3.13196e-11}, - {1.39550e+03, 3.19882e-02, 1.11499e-06, 5.65773e-11}, - {3.29912e+03, 6.76125e-02, 2.08154e-06, 9.54501e-11}, - } - }, }; } // namespace ccsn30 @@ -1892,6 +1892,48 @@ static const GrainSpeciesYieldProps grain_props[] = { /* name = */ "FeM_dust", /* nonprimoridal_yield_frac = */ 6.31648e-26, /* size_moments = */ {4.02937e-08, 1.67044e-15, 7.11477e-23}, + /* opacity_coef_table = */ { + {1.23621e-05, 4.98941e-13, 2.07173e-20, 8.83710e-28}, + {2.19539e-05, 8.86065e-13, 3.67916e-20, 1.56937e-27}, + {3.40291e-05, 1.37342e-12, 5.70280e-20, 2.43256e-27}, + {4.92310e-05, 1.98698e-12, 8.25041e-20, 3.51925e-27}, + {8.08514e-05, 3.26317e-12, 1.35494e-19, 5.77953e-27}, + {1.25020e-04, 5.04574e-12, 2.09508e-19, 8.93651e-27}, + {1.96586e-04, 7.93387e-12, 3.29418e-19, 1.40509e-26}, + {3.14491e-04, 1.26917e-11, 5.26937e-19, 2.24747e-26}, + {5.06850e-04, 2.04532e-11, 8.49130e-19, 3.62146e-26}, + {8.07286e-04, 3.25749e-11, 1.35229e-18, 5.76710e-26}, + {1.28668e-03, 5.19155e-11, 2.15506e-18, 9.19009e-26}, + {2.05241e-03, 8.28056e-11, 3.43709e-18, 1.46562e-25}, + {3.27026e-03, 1.31928e-10, 5.47555e-18, 2.33466e-25}, + {5.23898e-03, 2.11325e-10, 8.76988e-18, 3.73889e-25}, + {8.45023e-03, 3.40811e-10, 1.41417e-17, 6.02834e-25}, + {1.37158e-02, 5.53101e-10, 2.29473e-17, 9.78076e-25}, + {2.24100e-02, 9.03572e-10, 3.74827e-17, 1.59741e-24}, + {3.70042e-02, 1.49181e-09, 6.18765e-17, 2.63669e-24}, + {6.21585e-02, 2.50559e-09, 1.03913e-16, 4.42746e-24}, + {1.07033e-01, 4.31400e-09, 1.78894e-16, 7.62148e-24}, + {1.90089e-01, 7.66095e-09, 3.17659e-16, 1.35323e-23}, + {3.49470e-01, 1.40834e-08, 5.83928e-16, 2.48739e-23}, + {6.64947e-01, 2.67957e-08, 1.11096e-15, 4.73220e-23}, + {1.30413e+00, 5.25515e-08, 2.17873e-15, 9.28021e-23}, + {2.61640e+00, 1.05429e-07, 4.37088e-15, 1.86172e-22}, + {5.31791e+00, 2.14284e-07, 8.88372e-15, 3.78386e-22}, + {1.08366e+01, 4.36654e-07, 1.81025e-14, 7.71039e-22}, + {2.19132e+01, 8.82975e-07, 3.66056e-14, 1.55913e-21}, + {4.35354e+01, 1.75422e-06, 7.27247e-14, 3.09753e-21}, + {8.42362e+01, 3.39422e-06, 1.40714e-13, 5.99335e-21}, + {1.57704e+02, 6.35452e-06, 2.63439e-13, 1.12205e-20}, + {2.84822e+02, 1.14766e-05, 4.75784e-13, 2.02648e-20}, + {4.96653e+02, 2.00121e-05, 8.29639e-13, 3.53363e-20}, + {8.39966e+02, 3.38455e-05, 1.40313e-12, 5.97626e-20}, + {1.38932e+03, 5.59813e-05, 2.32081e-12, 9.88487e-20}, + } + }, + { + /* name = */ "Mg2SiO4_dust", + /* nonprimoridal_yield_frac = */ 2.06081e-16, + /* size_moments = */ {4.03307e-08, 1.67330e-15, 7.13316e-23}, /* opacity_coef_table = */ { {1.05240e-01, 4.24440e-09, 1.76098e-16, 7.50693e-24}, {1.32588e-01, 5.34735e-09, 2.21859e-16, 9.45769e-24}, @@ -1931,9 +1973,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "Mg2SiO4_dust", - /* nonprimoridal_yield_frac = */ 2.06081e-16, - /* size_moments = */ {4.03307e-08, 1.67330e-15, 7.13316e-23}, + /* name = */ "MgSiO3_dust", + /* nonprimoridal_yield_frac = */ 3.19262e-15, + /* size_moments = */ {4.03157e-08, 1.67182e-15, 7.12190e-23}, /* opacity_coef_table = */ { {2.19890e-02, 8.86503e-10, 3.67618e-17, 1.56604e-24}, {3.90612e-02, 1.57478e-09, 6.53036e-17, 2.78190e-24}, @@ -1973,9 +2015,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "MgSiO3_dust", - /* nonprimoridal_yield_frac = */ 3.19262e-15, - /* size_moments = */ {4.03157e-08, 1.67182e-15, 7.12190e-23}, + /* name = */ "Fe3O4_dust", + /* nonprimoridal_yield_frac = */ 4.37192e-15, + /* size_moments = */ {4.03312e-08, 1.67336e-15, 7.13357e-23}, /* opacity_coef_table = */ { {1.47700e-02, 5.95693e-10, 2.47155e-17, 1.05363e-24}, {2.47694e-02, 9.98982e-10, 4.14481e-17, 1.76695e-24}, @@ -2015,9 +2057,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "Fe3O4_dust", - /* nonprimoridal_yield_frac = */ 4.37192e-15, - /* size_moments = */ {4.03312e-08, 1.67336e-15, 7.13357e-23}, + /* name = */ "AC_dust", + /* nonprimoridal_yield_frac = */ 1.75542e-01, + /* size_moments = */ {6.60867e-06, 5.49310e-11, 5.25955e-16}, /* opacity_coef_table = */ { {3.27960e-01, 2.16737e-06, 1.80151e-11, 1.72491e-16}, {4.38754e-01, 2.89959e-06, 2.41015e-11, 2.30770e-16}, @@ -2057,9 +2099,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "AC_dust", - /* nonprimoridal_yield_frac = */ 1.75542e-01, - /* size_moments = */ {6.60867e-06, 5.49310e-11, 5.25955e-16}, + /* name = */ "SiO2_dust", + /* nonprimoridal_yield_frac = */ 1.92019e-16, + /* size_moments = */ {4.03146e-08, 1.67171e-15, 7.12105e-23}, /* opacity_coef_table = */ { {7.60360e-02, 3.06536e-09, 1.27110e-16, 5.41456e-24}, {9.07207e-02, 3.65737e-09, 1.51659e-16, 6.46027e-24}, @@ -2099,9 +2141,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "SiO2_dust", - /* nonprimoridal_yield_frac = */ 1.92019e-16, - /* size_moments = */ {4.03146e-08, 1.67171e-15, 7.12105e-23}, + /* name = */ "Al2O3_dust", + /* nonprimoridal_yield_frac = */ 6.23283e-17, + /* size_moments = */ {4.03146e-08, 1.67171e-15, 7.12106e-23}, /* opacity_coef_table = */ { {9.93250e-04, 4.00425e-11, 1.66043e-18, 7.07299e-26}, {1.81240e-03, 7.30662e-11, 3.02981e-18, 1.29062e-25}, @@ -2140,69 +2182,69 @@ static const GrainSpeciesYieldProps grain_props[] = { {1.81893e+01, 7.33293e-07, 3.04073e-14, 1.29527e-21}, } }, +}; + +} // namespace fsn13 + +namespace fsn15 { +static const MetalNuclideYieldProps metal_props[] = { + // {name, gas_yield, total_yield} + {"C", 4.57071e-01, 6.46299e-01}, + {"O", 3.53548e-01, 3.53548e-01}, + {"Mg", 1.29204e-04, 1.29204e-04}, + {"Al", 2.22729e-07, 2.22729e-07}, + {"Si", 1.32242e-05, 1.32242e-05}, + {"S", 0.00000e+00, 0.00000e+00}, + {"Fe", 9.66658e-06, 9.66658e-06}, +}; + +static const GrainSpeciesYieldProps grain_props[] = { { - /* name = */ "Al2O3_dust", - /* nonprimoridal_yield_frac = */ 6.23283e-17, - /* size_moments = */ {4.03146e-08, 1.67171e-15, 7.12106e-23}, + /* name = */ "FeM_dust", + /* nonprimoridal_yield_frac = */ 1.53361e-25, + /* size_moments = */ {4.02634e-08, 1.66860e-15, 7.10566e-23}, /* opacity_coef_table = */ { - {1.23621e-05, 4.98941e-13, 2.07173e-20, 8.83710e-28}, - {2.19539e-05, 8.86065e-13, 3.67916e-20, 1.56937e-27}, - {3.40291e-05, 1.37342e-12, 5.70280e-20, 2.43256e-27}, - {4.92310e-05, 1.98698e-12, 8.25041e-20, 3.51925e-27}, - {8.08514e-05, 3.26317e-12, 1.35494e-19, 5.77953e-27}, - {1.25020e-04, 5.04574e-12, 2.09508e-19, 8.93651e-27}, - {1.96586e-04, 7.93387e-12, 3.29418e-19, 1.40509e-26}, - {3.14491e-04, 1.26917e-11, 5.26937e-19, 2.24747e-26}, - {5.06850e-04, 2.04532e-11, 8.49130e-19, 3.62146e-26}, - {8.07286e-04, 3.25749e-11, 1.35229e-18, 5.76710e-26}, - {1.28668e-03, 5.19155e-11, 2.15506e-18, 9.19009e-26}, - {2.05241e-03, 8.28056e-11, 3.43709e-18, 1.46562e-25}, - {3.27026e-03, 1.31928e-10, 5.47555e-18, 2.33466e-25}, - {5.23898e-03, 2.11325e-10, 8.76988e-18, 3.73889e-25}, - {8.45023e-03, 3.40811e-10, 1.41417e-17, 6.02834e-25}, - {1.37158e-02, 5.53101e-10, 2.29473e-17, 9.78076e-25}, - {2.24100e-02, 9.03572e-10, 3.74827e-17, 1.59741e-24}, - {3.70042e-02, 1.49181e-09, 6.18765e-17, 2.63669e-24}, - {6.21585e-02, 2.50559e-09, 1.03913e-16, 4.42746e-24}, - {1.07033e-01, 4.31400e-09, 1.78894e-16, 7.62148e-24}, - {1.90089e-01, 7.66095e-09, 3.17659e-16, 1.35323e-23}, - {3.49470e-01, 1.40834e-08, 5.83928e-16, 2.48739e-23}, - {6.64947e-01, 2.67957e-08, 1.11096e-15, 4.73220e-23}, - {1.30413e+00, 5.25515e-08, 2.17873e-15, 9.28021e-23}, - {2.61640e+00, 1.05429e-07, 4.37088e-15, 1.86172e-22}, - {5.31791e+00, 2.14284e-07, 8.88372e-15, 3.78386e-22}, - {1.08366e+01, 4.36654e-07, 1.81025e-14, 7.71039e-22}, - {2.19132e+01, 8.82975e-07, 3.66056e-14, 1.55913e-21}, - {4.35354e+01, 1.75422e-06, 7.27247e-14, 3.09753e-21}, - {8.42362e+01, 3.39422e-06, 1.40714e-13, 5.99335e-21}, - {1.57704e+02, 6.35452e-06, 2.63439e-13, 1.12205e-20}, - {2.84822e+02, 1.14766e-05, 4.75784e-13, 2.02648e-20}, - {4.96653e+02, 2.00121e-05, 8.29639e-13, 3.53363e-20}, - {8.39966e+02, 3.38455e-05, 1.40313e-12, 5.97626e-20}, - {1.38932e+03, 5.59813e-05, 2.32081e-12, 9.88487e-20}, + {1.23614e-05, 4.98551e-13, 2.06942e-20, 8.82572e-28}, + {2.19525e-05, 8.85374e-13, 3.67505e-20, 1.56735e-27}, + {3.40270e-05, 1.37235e-12, 5.69643e-20, 2.42942e-27}, + {4.92280e-05, 1.98543e-12, 8.24119e-20, 3.51472e-27}, + {8.08465e-05, 3.26062e-12, 1.35343e-19, 5.77209e-27}, + {1.25012e-04, 5.04181e-12, 2.09274e-19, 8.92500e-27}, + {1.96574e-04, 7.92769e-12, 3.29050e-19, 1.40328e-26}, + {3.14473e-04, 1.26818e-11, 5.26348e-19, 2.24457e-26}, + {5.06822e-04, 2.04373e-11, 8.48182e-19, 3.61680e-26}, + {8.07243e-04, 3.25496e-11, 1.35079e-18, 5.75968e-26}, + {1.28661e-03, 5.18753e-11, 2.15265e-18, 9.17827e-26}, + {2.05232e-03, 8.27416e-11, 3.43325e-18, 1.46374e-25}, + {3.27011e-03, 1.31826e-10, 5.46945e-18, 2.33165e-25}, + {5.23877e-03, 2.11162e-10, 8.76012e-18, 3.73409e-25}, + {8.44994e-03, 3.40550e-10, 1.41259e-17, 6.02059e-25}, + {1.37154e-02, 5.52677e-10, 2.29218e-17, 9.76820e-25}, + {2.24094e-02, 9.02883e-10, 3.74411e-17, 1.59536e-24}, + {3.70035e-02, 1.49068e-09, 6.18079e-17, 2.63331e-24}, + {6.21576e-02, 2.50369e-09, 1.03798e-16, 4.42178e-24}, + {1.07032e-01, 4.31074e-09, 1.78696e-16, 7.61171e-24}, + {1.90087e-01, 7.65516e-09, 3.17308e-16, 1.35149e-23}, + {3.49468e-01, 1.40728e-08, 5.83283e-16, 2.48420e-23}, + {6.64945e-01, 2.67755e-08, 1.10973e-15, 4.72613e-23}, + {1.30413e+00, 5.25119e-08, 2.17633e-15, 9.26832e-23}, + {2.61639e+00, 1.05349e-07, 4.36605e-15, 1.85933e-22}, + {5.31790e+00, 2.14123e-07, 8.87391e-15, 3.77901e-22}, + {1.08366e+01, 4.36326e-07, 1.80825e-14, 7.70051e-22}, + {2.19131e+01, 8.82310e-07, 3.65652e-14, 1.55714e-21}, + {4.35353e+01, 1.75290e-06, 7.26444e-14, 3.09356e-21}, + {8.42362e+01, 3.39166e-06, 1.40558e-13, 5.98567e-21}, + {1.57704e+02, 6.34974e-06, 2.63148e-13, 1.12061e-20}, + {2.84822e+02, 1.14680e-05, 4.75258e-13, 2.02388e-20}, + {4.96653e+02, 1.99971e-05, 8.28723e-13, 3.52910e-20}, + {8.39966e+02, 3.38201e-05, 1.40158e-12, 5.96860e-20}, + {1.38932e+03, 5.59392e-05, 2.31824e-12, 9.87221e-20}, } }, -}; - -} // namespace fsn13 - -namespace fsn15 { -static const MetalNuclideYieldProps metal_props[] = { - // {name, gas_yield, total_yield} - {"C", 4.57071e-01, 6.46299e-01}, - {"O", 3.53548e-01, 3.53548e-01}, - {"Mg", 1.29204e-04, 1.29204e-04}, - {"Al", 2.22729e-07, 2.22729e-07}, - {"Si", 1.32242e-05, 1.32242e-05}, - {"S", 0.00000e+00, 0.00000e+00}, - {"Fe", 9.66658e-06, 9.66658e-06}, -}; - -static const GrainSpeciesYieldProps grain_props[] = { { - /* name = */ "FeM_dust", - /* nonprimoridal_yield_frac = */ 1.53361e-25, - /* size_moments = */ {4.02634e-08, 1.66860e-15, 7.10566e-23}, + /* name = */ "Mg2SiO4_dust", + /* nonprimoridal_yield_frac = */ 1.56864e-15, + /* size_moments = */ {4.03318e-08, 1.67341e-15, 7.13397e-23}, /* opacity_coef_table = */ { {1.05240e-01, 4.24452e-09, 1.76110e-16, 7.50779e-24}, {1.32588e-01, 5.34750e-09, 2.21874e-16, 9.45877e-24}, @@ -2242,9 +2284,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "Mg2SiO4_dust", - /* nonprimoridal_yield_frac = */ 1.56864e-15, - /* size_moments = */ {4.03318e-08, 1.67341e-15, 7.13397e-23}, + /* name = */ "MgSiO3_dust", + /* nonprimoridal_yield_frac = */ 2.13810e-14, + /* size_moments = */ {4.03159e-08, 1.67184e-15, 7.12201e-23}, /* opacity_coef_table = */ { {2.19890e-02, 8.86506e-10, 3.67621e-17, 1.56606e-24}, {3.90612e-02, 1.57479e-09, 6.53041e-17, 2.78195e-24}, @@ -2284,9 +2326,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "MgSiO3_dust", - /* nonprimoridal_yield_frac = */ 2.13810e-14, - /* size_moments = */ {4.03159e-08, 1.67184e-15, 7.12201e-23}, + /* name = */ "Fe3O4_dust", + /* nonprimoridal_yield_frac = */ 1.22287e-14, + /* size_moments = */ {4.03301e-08, 1.67324e-15, 7.13269e-23}, /* opacity_coef_table = */ { {1.47700e-02, 5.95675e-10, 2.47138e-17, 1.05350e-24}, {2.47694e-02, 9.98953e-10, 4.14453e-17, 1.76673e-24}, @@ -2326,9 +2368,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "Fe3O4_dust", - /* nonprimoridal_yield_frac = */ 1.22287e-14, - /* size_moments = */ {4.03301e-08, 1.67324e-15, 7.13269e-23}, + /* name = */ "AC_dust", + /* nonprimoridal_yield_frac = */ 1.89229e-01, + /* size_moments = */ {1.14540e-05, 1.60512e-10, 2.55303e-15}, /* opacity_coef_table = */ { {3.27956e-01, 3.75639e-06, 5.26403e-11, 8.37270e-16}, {4.38770e-01, 5.02579e-06, 7.04309e-11, 1.12026e-15}, @@ -2368,9 +2410,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "AC_dust", - /* nonprimoridal_yield_frac = */ 1.89229e-01, - /* size_moments = */ {1.14540e-05, 1.60512e-10, 2.55303e-15}, + /* name = */ "SiO2_dust", + /* nonprimoridal_yield_frac = */ 1.47463e-15, + /* size_moments = */ {4.03146e-08, 1.67171e-15, 7.12105e-23}, /* opacity_coef_table = */ { {7.60360e-02, 3.06536e-09, 1.27110e-16, 5.41456e-24}, {9.07207e-02, 3.65737e-09, 1.51659e-16, 6.46027e-24}, @@ -2410,9 +2452,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "SiO2_dust", - /* nonprimoridal_yield_frac = */ 1.47463e-15, - /* size_moments = */ {4.03146e-08, 1.67171e-15, 7.12105e-23}, + /* name = */ "Al2O3_dust", + /* nonprimoridal_yield_frac = */ 2.15191e-16, + /* size_moments = */ {4.03146e-08, 1.67171e-15, 7.12106e-23}, /* opacity_coef_table = */ { {9.93250e-04, 4.00425e-11, 1.66043e-18, 7.07299e-26}, {1.81240e-03, 7.30662e-11, 3.02981e-18, 1.29062e-25}, @@ -2451,48 +2493,6 @@ static const GrainSpeciesYieldProps grain_props[] = { {1.81893e+01, 7.33293e-07, 3.04073e-14, 1.29527e-21}, } }, - { - /* name = */ "Al2O3_dust", - /* nonprimoridal_yield_frac = */ 2.15191e-16, - /* size_moments = */ {4.03146e-08, 1.67171e-15, 7.12106e-23}, - /* opacity_coef_table = */ { - {1.23614e-05, 4.98551e-13, 2.06942e-20, 8.82572e-28}, - {2.19525e-05, 8.85374e-13, 3.67505e-20, 1.56735e-27}, - {3.40270e-05, 1.37235e-12, 5.69643e-20, 2.42942e-27}, - {4.92280e-05, 1.98543e-12, 8.24119e-20, 3.51472e-27}, - {8.08465e-05, 3.26062e-12, 1.35343e-19, 5.77209e-27}, - {1.25012e-04, 5.04181e-12, 2.09274e-19, 8.92500e-27}, - {1.96574e-04, 7.92769e-12, 3.29050e-19, 1.40328e-26}, - {3.14473e-04, 1.26818e-11, 5.26348e-19, 2.24457e-26}, - {5.06822e-04, 2.04373e-11, 8.48182e-19, 3.61680e-26}, - {8.07243e-04, 3.25496e-11, 1.35079e-18, 5.75968e-26}, - {1.28661e-03, 5.18753e-11, 2.15265e-18, 9.17827e-26}, - {2.05232e-03, 8.27416e-11, 3.43325e-18, 1.46374e-25}, - {3.27011e-03, 1.31826e-10, 5.46945e-18, 2.33165e-25}, - {5.23877e-03, 2.11162e-10, 8.76012e-18, 3.73409e-25}, - {8.44994e-03, 3.40550e-10, 1.41259e-17, 6.02059e-25}, - {1.37154e-02, 5.52677e-10, 2.29218e-17, 9.76820e-25}, - {2.24094e-02, 9.02883e-10, 3.74411e-17, 1.59536e-24}, - {3.70035e-02, 1.49068e-09, 6.18079e-17, 2.63331e-24}, - {6.21576e-02, 2.50369e-09, 1.03798e-16, 4.42178e-24}, - {1.07032e-01, 4.31074e-09, 1.78696e-16, 7.61171e-24}, - {1.90087e-01, 7.65516e-09, 3.17308e-16, 1.35149e-23}, - {3.49468e-01, 1.40728e-08, 5.83283e-16, 2.48420e-23}, - {6.64945e-01, 2.67755e-08, 1.10973e-15, 4.72613e-23}, - {1.30413e+00, 5.25119e-08, 2.17633e-15, 9.26832e-23}, - {2.61639e+00, 1.05349e-07, 4.36605e-15, 1.85933e-22}, - {5.31790e+00, 2.14123e-07, 8.87391e-15, 3.77901e-22}, - {1.08366e+01, 4.36326e-07, 1.80825e-14, 7.70051e-22}, - {2.19131e+01, 8.82310e-07, 3.65652e-14, 1.55714e-21}, - {4.35353e+01, 1.75290e-06, 7.26444e-14, 3.09356e-21}, - {8.42362e+01, 3.39166e-06, 1.40558e-13, 5.98567e-21}, - {1.57704e+02, 6.34974e-06, 2.63148e-13, 1.12061e-20}, - {2.84822e+02, 1.14680e-05, 4.75258e-13, 2.02388e-20}, - {4.96653e+02, 1.99971e-05, 8.28723e-13, 3.52910e-20}, - {8.39966e+02, 3.38201e-05, 1.40158e-12, 5.96860e-20}, - {1.38932e+03, 5.59392e-05, 2.31824e-12, 9.87221e-20}, - } - }, }; } // namespace fsn15 @@ -2514,6 +2514,48 @@ static const GrainSpeciesYieldProps grain_props[] = { /* name = */ "FeM_dust", /* nonprimoridal_yield_frac = */ 2.33171e-24, /* size_moments = */ {4.02891e-08, 1.67016e-15, 7.11339e-23}, + /* opacity_coef_table = */ { + {1.23620e-05, 4.98882e-13, 2.07138e-20, 8.83538e-28}, + {2.19537e-05, 8.85960e-13, 3.67854e-20, 1.56906e-27}, + {3.40288e-05, 1.37326e-12, 5.70184e-20, 2.43208e-27}, + {4.92305e-05, 1.98674e-12, 8.24901e-20, 3.51856e-27}, + {8.08507e-05, 3.26278e-12, 1.35471e-19, 5.77841e-27}, + {1.25019e-04, 5.04514e-12, 2.09472e-19, 8.93477e-27}, + {1.96584e-04, 7.93293e-12, 3.29363e-19, 1.40481e-26}, + {3.14489e-04, 1.26902e-11, 5.26848e-19, 2.24703e-26}, + {5.06846e-04, 2.04508e-11, 8.48987e-19, 3.62076e-26}, + {8.07280e-04, 3.25711e-11, 1.35207e-18, 5.76597e-26}, + {1.28667e-03, 5.19094e-11, 2.15469e-18, 9.18830e-26}, + {2.05240e-03, 8.27959e-11, 3.43651e-18, 1.46534e-25}, + {3.27023e-03, 1.31912e-10, 5.47463e-18, 2.33420e-25}, + {5.23895e-03, 2.11300e-10, 8.76840e-18, 3.73817e-25}, + {8.45019e-03, 3.40772e-10, 1.41393e-17, 6.02717e-25}, + {1.37157e-02, 5.53037e-10, 2.29434e-17, 9.77885e-25}, + {2.24099e-02, 9.03468e-10, 3.74764e-17, 1.59710e-24}, + {3.70041e-02, 1.49164e-09, 6.18661e-17, 2.63618e-24}, + {6.21584e-02, 2.50530e-09, 1.03896e-16, 4.42660e-24}, + {1.07033e-01, 4.31351e-09, 1.78864e-16, 7.62000e-24}, + {1.90089e-01, 7.66007e-09, 3.17606e-16, 1.35297e-23}, + {3.49470e-01, 1.40818e-08, 5.83831e-16, 2.48691e-23}, + {6.64947e-01, 2.67926e-08, 1.11077e-15, 4.73128e-23}, + {1.30413e+00, 5.25455e-08, 2.17837e-15, 9.27841e-23}, + {2.61640e+00, 1.05417e-07, 4.37015e-15, 1.86136e-22}, + {5.31790e+00, 2.14259e-07, 8.88223e-15, 3.78313e-22}, + {1.08366e+01, 4.36604e-07, 1.80995e-14, 7.70889e-22}, + {2.19132e+01, 8.82874e-07, 3.65995e-14, 1.55883e-21}, + {4.35354e+01, 1.75402e-06, 7.27125e-14, 3.09693e-21}, + {8.42362e+01, 3.39383e-06, 1.40690e-13, 5.99219e-21}, + {1.57704e+02, 6.35380e-06, 2.63395e-13, 1.12183e-20}, + {2.84822e+02, 1.14753e-05, 4.75704e-13, 2.02608e-20}, + {4.96653e+02, 2.00098e-05, 8.29500e-13, 3.53294e-20}, + {8.39966e+02, 3.38417e-05, 1.40289e-12, 5.97510e-20}, + {1.38932e+03, 5.59749e-05, 2.32042e-12, 9.88295e-20}, + } + }, + { + /* name = */ "Mg2SiO4_dust", + /* nonprimoridal_yield_frac = */ 2.62486e-10, + /* size_moments = */ {1.68491e-07, 3.02634e-14, 5.60369e-21}, /* opacity_coef_table = */ { {1.05240e-01, 1.77320e-08, 3.18492e-15, 5.89732e-22}, {1.32588e-01, 2.23399e-08, 4.01256e-15, 7.42980e-22}, @@ -2553,9 +2595,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "Mg2SiO4_dust", - /* nonprimoridal_yield_frac = */ 2.62486e-10, - /* size_moments = */ {1.68491e-07, 3.02634e-14, 5.60369e-21}, + /* name = */ "MgSiO3_dust", + /* nonprimoridal_yield_frac = */ 1.21446e-09, + /* size_moments = */ {1.33003e-07, 1.84568e-14, 2.62630e-21}, /* opacity_coef_table = */ { {2.19890e-02, 2.92460e-09, 4.05846e-16, 5.77498e-23}, {3.90612e-02, 5.19526e-09, 7.20944e-16, 1.02587e-22}, @@ -2595,9 +2637,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "MgSiO3_dust", - /* nonprimoridal_yield_frac = */ 1.21446e-09, - /* size_moments = */ {1.33003e-07, 1.84568e-14, 2.62630e-21}, + /* name = */ "Fe3O4_dust", + /* nonprimoridal_yield_frac = */ 2.41799e-13, + /* size_moments = */ {5.89806e-08, 3.51732e-15, 2.11807e-22}, /* opacity_coef_table = */ { {1.47700e-02, 8.71144e-10, 5.19508e-17, 3.12839e-24}, {2.47694e-02, 1.46092e-09, 8.71220e-17, 5.24635e-24}, @@ -2637,9 +2679,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "Fe3O4_dust", - /* nonprimoridal_yield_frac = */ 2.41799e-13, - /* size_moments = */ {5.89806e-08, 3.51732e-15, 2.11807e-22}, + /* name = */ "AC_dust", + /* nonprimoridal_yield_frac = */ 1.09849e-04, + /* size_moments = */ {6.81790e-07, 6.53175e-13, 7.65748e-19}, /* opacity_coef_table = */ { {3.27960e-01, 2.23600e-07, 2.14215e-13, 2.51135e-19}, {4.38752e-01, 2.99136e-07, 2.86582e-13, 3.35973e-19}, @@ -2679,9 +2721,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "AC_dust", - /* nonprimoridal_yield_frac = */ 1.09849e-04, - /* size_moments = */ {6.81790e-07, 6.53175e-13, 7.65748e-19}, + /* name = */ "SiO2_dust", + /* nonprimoridal_yield_frac = */ 3.41863e-11, + /* size_moments = */ {9.81613e-08, 9.72845e-15, 9.68327e-22}, /* opacity_coef_table = */ { {7.60360e-02, 7.46380e-09, 7.39712e-16, 7.36277e-23}, {9.07207e-02, 8.90526e-09, 8.82572e-16, 8.78473e-23}, @@ -2721,9 +2763,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "SiO2_dust", - /* nonprimoridal_yield_frac = */ 3.41863e-11, - /* size_moments = */ {9.81613e-08, 9.72845e-15, 9.68327e-22}, + /* name = */ "Al2O3_dust", + /* nonprimoridal_yield_frac = */ 2.53950e-17, + /* size_moments = */ {4.03146e-08, 1.67172e-15, 7.12107e-23}, /* opacity_coef_table = */ { {9.93250e-04, 4.00425e-11, 1.66043e-18, 7.07300e-26}, {1.81240e-03, 7.30662e-11, 3.02982e-18, 1.29062e-25}, @@ -2762,10 +2804,27 @@ static const GrainSpeciesYieldProps grain_props[] = { {1.81893e+01, 7.33294e-07, 3.04073e-14, 1.29527e-21}, } }, +}; + +} // namespace fsn50 + +namespace fsn80 { +static const MetalNuclideYieldProps metal_props[] = { + // {name, gas_yield, total_yield} + {"C", 2.43883e-01, 2.52563e-01}, + {"O", 7.46061e-01, 7.46061e-01}, + {"Mg", 1.36917e-03, 1.36917e-03}, + {"Al", 1.55602e-08, 1.55602e-08}, + {"Si", 3.63906e-06, 3.63906e-06}, + {"S", 0.00000e+00, 0.00000e+00}, + {"Fe", 2.43915e-06, 2.43915e-06}, +}; + +static const GrainSpeciesYieldProps grain_props[] = { { - /* name = */ "Al2O3_dust", - /* nonprimoridal_yield_frac = */ 2.53950e-17, - /* size_moments = */ {4.03146e-08, 1.67172e-15, 7.12107e-23}, + /* name = */ "FeM_dust", + /* nonprimoridal_yield_frac = */ 3.87590e-26, + /* size_moments = */ {4.02891e-08, 1.67016e-15, 7.11339e-23}, /* opacity_coef_table = */ { {1.23620e-05, 4.98882e-13, 2.07138e-20, 8.83538e-28}, {2.19537e-05, 8.85960e-13, 3.67854e-20, 1.56906e-27}, @@ -2804,27 +2863,10 @@ static const GrainSpeciesYieldProps grain_props[] = { {1.38932e+03, 5.59749e-05, 2.32042e-12, 9.88295e-20}, } }, -}; - -} // namespace fsn50 - -namespace fsn80 { -static const MetalNuclideYieldProps metal_props[] = { - // {name, gas_yield, total_yield} - {"C", 2.43883e-01, 2.52563e-01}, - {"O", 7.46061e-01, 7.46061e-01}, - {"Mg", 1.36917e-03, 1.36917e-03}, - {"Al", 1.55602e-08, 1.55602e-08}, - {"Si", 3.63906e-06, 3.63906e-06}, - {"S", 0.00000e+00, 0.00000e+00}, - {"Fe", 2.43915e-06, 2.43915e-06}, -}; - -static const GrainSpeciesYieldProps grain_props[] = { { - /* name = */ "FeM_dust", - /* nonprimoridal_yield_frac = */ 3.87590e-26, - /* size_moments = */ {4.02891e-08, 1.67016e-15, 7.11339e-23}, + /* name = */ "Mg2SiO4_dust", + /* nonprimoridal_yield_frac = */ 2.36180e-13, + /* size_moments = */ {5.88698e-08, 3.50624e-15, 2.10950e-22}, /* opacity_coef_table = */ { {1.05240e-01, 6.19546e-09, 3.68996e-16, 2.22004e-23}, {1.32588e-01, 7.80541e-09, 4.64884e-16, 2.79694e-23}, @@ -2864,9 +2906,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "Mg2SiO4_dust", - /* nonprimoridal_yield_frac = */ 2.36180e-13, - /* size_moments = */ {5.88698e-08, 3.50624e-15, 2.10950e-22}, + /* name = */ "MgSiO3_dust", + /* nonprimoridal_yield_frac = */ 2.48190e-12, + /* size_moments = */ {5.87709e-08, 3.49547e-15, 2.10029e-22}, /* opacity_coef_table = */ { {2.19890e-02, 1.29231e-09, 7.68620e-17, 4.61833e-24}, {3.90612e-02, 2.29567e-09, 1.36538e-16, 8.20401e-24}, @@ -2906,9 +2948,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "MgSiO3_dust", - /* nonprimoridal_yield_frac = */ 2.48190e-12, - /* size_moments = */ {5.87709e-08, 3.49547e-15, 2.10029e-22}, + /* name = */ "Fe3O4_dust", + /* nonprimoridal_yield_frac = */ 3.01120e-15, + /* size_moments = */ {4.03342e-08, 1.67365e-15, 7.13577e-23}, /* opacity_coef_table = */ { {1.47700e-02, 5.95736e-10, 2.47198e-17, 1.05395e-24}, {2.47694e-02, 9.99055e-10, 4.14553e-17, 1.76749e-24}, @@ -2948,9 +2990,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "Fe3O4_dust", - /* nonprimoridal_yield_frac = */ 3.01120e-15, - /* size_moments = */ {4.03342e-08, 1.67365e-15, 7.13577e-23}, + /* name = */ "AC_dust", + /* nonprimoridal_yield_frac = */ 8.68025e-03, + /* size_moments = */ {4.22607e-06, 2.30435e-11, 1.46801e-16}, /* opacity_coef_table = */ { {3.27960e-01, 1.38598e-06, 7.55735e-12, 4.81450e-17}, {4.38752e-01, 1.85420e-06, 1.01104e-11, 6.44096e-17}, @@ -2990,9 +3032,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "AC_dust", - /* nonprimoridal_yield_frac = */ 8.68025e-03, - /* size_moments = */ {4.22607e-06, 2.30435e-11, 1.46801e-16}, + /* name = */ "SiO2_dust", + /* nonprimoridal_yield_frac = */ 3.70132e-14, + /* size_moments = */ {4.03439e-08, 1.67461e-15, 7.14309e-23}, /* opacity_coef_table = */ { {7.60360e-02, 3.06759e-09, 1.27330e-16, 5.43132e-24}, {9.07207e-02, 3.66003e-09, 1.51922e-16, 6.48026e-24}, @@ -3032,9 +3074,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "SiO2_dust", - /* nonprimoridal_yield_frac = */ 3.70132e-14, - /* size_moments = */ {4.03439e-08, 1.67461e-15, 7.14309e-23}, + /* name = */ "Al2O3_dust", + /* nonprimoridal_yield_frac = */ 3.77811e-18, + /* size_moments = */ {4.03146e-08, 1.67171e-15, 7.12106e-23}, /* opacity_coef_table = */ { {9.93250e-04, 4.00425e-11, 1.66043e-18, 7.07300e-26}, {1.81240e-03, 7.30662e-11, 3.02981e-18, 1.29062e-25}, @@ -3073,48 +3115,6 @@ static const GrainSpeciesYieldProps grain_props[] = { {1.81893e+01, 7.33293e-07, 3.04073e-14, 1.29527e-21}, } }, - { - /* name = */ "Al2O3_dust", - /* nonprimoridal_yield_frac = */ 3.77811e-18, - /* size_moments = */ {4.03146e-08, 1.67171e-15, 7.12106e-23}, - /* opacity_coef_table = */ { - {1.23620e-05, 4.98882e-13, 2.07138e-20, 8.83538e-28}, - {2.19537e-05, 8.85960e-13, 3.67854e-20, 1.56906e-27}, - {3.40288e-05, 1.37326e-12, 5.70184e-20, 2.43208e-27}, - {4.92305e-05, 1.98674e-12, 8.24901e-20, 3.51856e-27}, - {8.08507e-05, 3.26278e-12, 1.35471e-19, 5.77841e-27}, - {1.25019e-04, 5.04514e-12, 2.09472e-19, 8.93477e-27}, - {1.96584e-04, 7.93293e-12, 3.29363e-19, 1.40481e-26}, - {3.14489e-04, 1.26902e-11, 5.26848e-19, 2.24703e-26}, - {5.06846e-04, 2.04508e-11, 8.48987e-19, 3.62076e-26}, - {8.07280e-04, 3.25711e-11, 1.35207e-18, 5.76597e-26}, - {1.28667e-03, 5.19094e-11, 2.15469e-18, 9.18830e-26}, - {2.05240e-03, 8.27959e-11, 3.43651e-18, 1.46534e-25}, - {3.27023e-03, 1.31912e-10, 5.47463e-18, 2.33420e-25}, - {5.23895e-03, 2.11300e-10, 8.76840e-18, 3.73817e-25}, - {8.45019e-03, 3.40772e-10, 1.41393e-17, 6.02717e-25}, - {1.37157e-02, 5.53037e-10, 2.29434e-17, 9.77885e-25}, - {2.24099e-02, 9.03468e-10, 3.74764e-17, 1.59710e-24}, - {3.70041e-02, 1.49164e-09, 6.18661e-17, 2.63618e-24}, - {6.21584e-02, 2.50530e-09, 1.03896e-16, 4.42660e-24}, - {1.07033e-01, 4.31351e-09, 1.78864e-16, 7.62000e-24}, - {1.90089e-01, 7.66007e-09, 3.17606e-16, 1.35297e-23}, - {3.49470e-01, 1.40818e-08, 5.83831e-16, 2.48691e-23}, - {6.64947e-01, 2.67926e-08, 1.11077e-15, 4.73128e-23}, - {1.30413e+00, 5.25455e-08, 2.17837e-15, 9.27841e-23}, - {2.61640e+00, 1.05417e-07, 4.37015e-15, 1.86136e-22}, - {5.31790e+00, 2.14259e-07, 8.88223e-15, 3.78313e-22}, - {1.08366e+01, 4.36604e-07, 1.80995e-14, 7.70889e-22}, - {2.19132e+01, 8.82874e-07, 3.65995e-14, 1.55883e-21}, - {4.35354e+01, 1.75402e-06, 7.27125e-14, 3.09693e-21}, - {8.42362e+01, 3.39383e-06, 1.40690e-13, 5.99219e-21}, - {1.57704e+02, 6.35380e-06, 2.63395e-13, 1.12183e-20}, - {2.84822e+02, 1.14753e-05, 4.75704e-13, 2.02608e-20}, - {4.96653e+02, 2.00098e-05, 8.29500e-13, 3.53294e-20}, - {8.39966e+02, 3.38417e-05, 1.40289e-12, 5.97510e-20}, - {1.38932e+03, 5.59749e-05, 2.32042e-12, 9.88295e-20}, - } - }, }; } // namespace fsn80 @@ -3136,6 +3136,48 @@ static const GrainSpeciesYieldProps grain_props[] = { /* name = */ "SiM_dust", /* nonprimoridal_yield_frac = */ 1.31079e-02, /* size_moments = */ {2.72050e-06, 2.87427e-11, 7.09270e-16}, + /* opacity_coef_table = */ { + {1.54566e-01, 4.18815e-07, 4.38802e-12, 1.07634e-16}, + {1.94597e-01, 5.27516e-07, 5.53200e-12, 1.35785e-16}, + {2.44992e-01, 6.64362e-07, 6.97216e-12, 1.71223e-16}, + {3.08437e-01, 8.36640e-07, 8.78521e-12, 2.15837e-16}, + {3.88320e-01, 1.05373e-06, 1.10736e-11, 2.72217e-16}, + {4.88890e-01, 1.32707e-06, 1.39559e-11, 3.43241e-16}, + {6.15507e-01, 1.67134e-06, 1.75891e-11, 4.32825e-16}, + {7.74906e-01, 2.10492e-06, 2.21686e-11, 5.45804e-16}, + {9.75270e-01, 2.65013e-06, 2.79315e-11, 6.88059e-16}, + {1.22485e+00, 3.32948e-06, 3.51169e-11, 8.65513e-16}, + {1.52110e+00, 4.13615e-06, 4.36560e-11, 1.07652e-15}, + {1.83679e+00, 4.99624e-06, 5.27698e-11, 1.30190e-15}, + {2.15666e+00, 5.86838e-06, 6.20278e-11, 1.53115e-15}, + {2.55518e+00, 6.95661e-06, 7.36137e-11, 1.81866e-15}, + {3.22834e+00, 8.79676e-06, 9.32496e-11, 2.30667e-15}, + {4.33225e+00, 1.18177e-05, 1.25559e-10, 3.11092e-15}, + {5.81697e+00, 1.58892e-05, 1.69288e-10, 4.20258e-15}, + {7.48671e+00, 2.04890e-05, 2.19146e-10, 5.45508e-15}, + {9.22042e+00, 2.53165e-05, 2.72602e-10, 6.81745e-15}, + {1.12094e+01, 3.09883e-05, 3.38326e-10, 8.54226e-15}, + {1.40327e+01, 3.92793e-05, 4.39589e-10, 1.12871e-14}, + {1.79556e+01, 5.11182e-05, 5.91090e-10, 1.55105e-14}, + {2.19076e+01, 6.38759e-05, 7.72200e-10, 2.08556e-14}, + {2.40396e+01, 7.32505e-05, 9.56570e-10, 2.71081e-14}, + {2.35050e+01, 7.74606e-05, 1.14341e-09, 3.48207e-14}, + {2.10698e+01, 7.75334e-05, 1.32500e-09, 4.37333e-14}, + {1.81145e+01, 7.52350e-05, 1.46962e-09, 5.20115e-14}, + {1.55283e+01, 7.16932e-05, 1.54535e-09, 5.74821e-14}, + {1.35973e+01, 6.77513e-05, 1.55041e-09, 5.93660e-14}, + {1.28568e+01, 6.72854e-05, 1.57294e-09, 6.05730e-14}, + {1.62414e+01, 9.03391e-05, 2.02876e-09, 7.45675e-14}, + {3.62078e+01, 2.25165e-04, 4.46960e-09, 1.44123e-13}, + {1.13353e+02, 7.52538e-04, 1.29670e-08, 3.61005e-13}, + {3.52139e+02, 2.31091e-03, 3.53205e-08, 8.74277e-13}, + {9.61671e+02, 5.84143e-03, 8.01724e-08, 1.81153e-12}, + } + }, + { + /* name = */ "FeM_dust", + /* nonprimoridal_yield_frac = */ 3.34688e-05, + /* size_moments = */ {1.08069e-05, 1.19634e-10, 1.36724e-15}, /* opacity_coef_table = */ { {1.89038e-02, 2.14190e-07, 2.52372e-12, 3.12761e-17}, {3.29962e-02, 3.72180e-07, 4.35946e-12, 5.36210e-17}, @@ -3175,9 +3217,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "FeM_dust", - /* nonprimoridal_yield_frac = */ 3.34688e-05, - /* size_moments = */ {1.08069e-05, 1.19634e-10, 1.36724e-15}, + /* name = */ "Mg2SiO4_dust", + /* nonprimoridal_yield_frac = */ 2.84952e-13, + /* size_moments = */ {1.79010e-05, 3.24658e-10, 5.96244e-15}, /* opacity_coef_table = */ { {1.05240e-01, 1.88391e-06, 3.41670e-11, 6.27487e-16}, {1.32588e-01, 2.37346e-06, 4.30456e-11, 7.90546e-16}, @@ -3217,9 +3259,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "Mg2SiO4_dust", - /* nonprimoridal_yield_frac = */ 2.84952e-13, - /* size_moments = */ {1.79010e-05, 3.24658e-10, 5.96244e-15}, + /* name = */ "MgSiO3_dust", + /* nonprimoridal_yield_frac = */ 7.72302e-25, + /* size_moments = */ {2.51189e-05, 6.30957e-10, 1.58489e-14}, /* opacity_coef_table = */ { {2.19890e-02, 5.52339e-07, 1.38741e-11, 3.48502e-16}, {3.90618e-02, 9.81187e-07, 2.46463e-11, 6.19087e-16}, @@ -3259,9 +3301,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "MgSiO3_dust", - /* nonprimoridal_yield_frac = */ 7.72302e-25, - /* size_moments = */ {2.51189e-05, 6.30957e-10, 1.58489e-14}, + /* name = */ "AC_dust", + /* nonprimoridal_yield_frac = */ 4.47758e-05, + /* size_moments = */ {8.32266e-07, 1.33383e-12, 4.37739e-18}, /* opacity_coef_table = */ { {3.27960e-01, 2.72950e-07, 4.37442e-13, 1.43560e-18}, {4.38752e-01, 3.65158e-07, 5.85222e-13, 1.92064e-18}, @@ -3301,9 +3343,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "AC_dust", - /* nonprimoridal_yield_frac = */ 4.47758e-05, - /* size_moments = */ {8.32266e-07, 1.33383e-12, 4.37739e-18}, + /* name = */ "SiO2_dust", + /* nonprimoridal_yield_frac = */ 1.23405e-04, + /* size_moments = */ {2.12560e-05, 4.59721e-10, 1.01590e-14}, /* opacity_coef_table = */ { {7.60055e-02, 1.61556e-06, 3.49407e-11, 7.72118e-16}, {9.06897e-02, 1.92769e-06, 4.16913e-11, 9.21295e-16}, @@ -3343,9 +3385,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "SiO2_dust", - /* nonprimoridal_yield_frac = */ 1.23405e-04, - /* size_moments = */ {2.12560e-05, 4.59721e-10, 1.01590e-14}, + /* name = */ "MgO_dust", + /* nonprimoridal_yield_frac = */ 1.41247e-07, + /* size_moments = */ {1.60812e-05, 2.65603e-10, 4.50188e-15}, /* opacity_coef_table = */ { {2.25358e-04, 3.62400e-09, 5.98548e-14, 1.01451e-18}, {4.04933e-04, 6.51178e-09, 1.07551e-13, 1.82293e-18}, @@ -3384,48 +3426,6 @@ static const GrainSpeciesYieldProps grain_props[] = { {9.06015e+00, 1.45130e-04, 2.38782e-09, 4.03237e-14}, } }, - { - /* name = */ "MgO_dust", - /* nonprimoridal_yield_frac = */ 1.41247e-07, - /* size_moments = */ {1.60812e-05, 2.65603e-10, 4.50188e-15}, - /* opacity_coef_table = */ { - {1.54566e-01, 4.18815e-07, 4.38802e-12, 1.07634e-16}, - {1.94597e-01, 5.27516e-07, 5.53200e-12, 1.35785e-16}, - {2.44992e-01, 6.64362e-07, 6.97216e-12, 1.71223e-16}, - {3.08437e-01, 8.36640e-07, 8.78521e-12, 2.15837e-16}, - {3.88320e-01, 1.05373e-06, 1.10736e-11, 2.72217e-16}, - {4.88890e-01, 1.32707e-06, 1.39559e-11, 3.43241e-16}, - {6.15507e-01, 1.67134e-06, 1.75891e-11, 4.32825e-16}, - {7.74906e-01, 2.10492e-06, 2.21686e-11, 5.45804e-16}, - {9.75270e-01, 2.65013e-06, 2.79315e-11, 6.88059e-16}, - {1.22485e+00, 3.32948e-06, 3.51169e-11, 8.65513e-16}, - {1.52110e+00, 4.13615e-06, 4.36560e-11, 1.07652e-15}, - {1.83679e+00, 4.99624e-06, 5.27698e-11, 1.30190e-15}, - {2.15666e+00, 5.86838e-06, 6.20278e-11, 1.53115e-15}, - {2.55518e+00, 6.95661e-06, 7.36137e-11, 1.81866e-15}, - {3.22834e+00, 8.79676e-06, 9.32496e-11, 2.30667e-15}, - {4.33225e+00, 1.18177e-05, 1.25559e-10, 3.11092e-15}, - {5.81697e+00, 1.58892e-05, 1.69288e-10, 4.20258e-15}, - {7.48671e+00, 2.04890e-05, 2.19146e-10, 5.45508e-15}, - {9.22042e+00, 2.53165e-05, 2.72602e-10, 6.81745e-15}, - {1.12094e+01, 3.09883e-05, 3.38326e-10, 8.54226e-15}, - {1.40327e+01, 3.92793e-05, 4.39589e-10, 1.12871e-14}, - {1.79556e+01, 5.11182e-05, 5.91090e-10, 1.55105e-14}, - {2.19076e+01, 6.38759e-05, 7.72200e-10, 2.08556e-14}, - {2.40396e+01, 7.32505e-05, 9.56570e-10, 2.71081e-14}, - {2.35050e+01, 7.74606e-05, 1.14341e-09, 3.48207e-14}, - {2.10698e+01, 7.75334e-05, 1.32500e-09, 4.37333e-14}, - {1.81145e+01, 7.52350e-05, 1.46962e-09, 5.20115e-14}, - {1.55283e+01, 7.16932e-05, 1.54535e-09, 5.74821e-14}, - {1.35973e+01, 6.77513e-05, 1.55041e-09, 5.93660e-14}, - {1.28568e+01, 6.72854e-05, 1.57294e-09, 6.05730e-14}, - {1.62414e+01, 9.03391e-05, 2.02876e-09, 7.45675e-14}, - {3.62078e+01, 2.25165e-04, 4.46960e-09, 1.44123e-13}, - {1.13353e+02, 7.52538e-04, 1.29670e-08, 3.61005e-13}, - {3.52139e+02, 2.31091e-03, 3.53205e-08, 8.74277e-13}, - {9.61671e+02, 5.84143e-03, 8.01724e-08, 1.81153e-12}, - } - }, }; } // namespace pisn170 @@ -3447,6 +3447,48 @@ static const GrainSpeciesYieldProps grain_props[] = { /* name = */ "SiM_dust", /* nonprimoridal_yield_frac = */ 5.90622e-05, /* size_moments = */ {8.86269e-07, 1.71166e-12, 5.46663e-18}, + /* opacity_coef_table = */ { + {1.54645e-01, 1.37048e-07, 2.64662e-13, 8.45209e-19}, + {1.94685e-01, 1.72534e-07, 3.33193e-13, 1.06408e-18}, + {2.45092e-01, 2.17207e-07, 4.19469e-13, 1.33961e-18}, + {3.08551e-01, 2.73447e-07, 5.28084e-13, 1.68649e-18}, + {3.88446e-01, 3.44254e-07, 6.64830e-13, 2.12322e-18}, + {4.89028e-01, 4.33396e-07, 8.36986e-13, 2.67303e-18}, + {6.15654e-01, 5.45619e-07, 1.05372e-12, 3.36522e-18}, + {7.75056e-01, 6.86892e-07, 1.32656e-12, 4.23661e-18}, + {9.75414e-01, 8.64464e-07, 1.66951e-12, 5.33191e-18}, + {1.22498e+00, 1.08564e-06, 2.09668e-12, 6.69620e-18}, + {1.52119e+00, 1.34817e-06, 2.60370e-12, 8.31550e-18}, + {1.83682e+00, 1.62792e-06, 3.14401e-12, 1.00412e-17}, + {2.15660e+00, 1.91133e-06, 3.69138e-12, 1.17894e-17}, + {2.55494e+00, 2.26439e-06, 4.37331e-12, 1.39675e-17}, + {3.22768e+00, 2.86067e-06, 5.52501e-12, 1.76460e-17}, + {4.33077e+00, 3.83839e-06, 7.41349e-12, 2.36779e-17}, + {5.81399e+00, 5.15308e-06, 9.95292e-12, 3.17892e-17}, + {7.48107e+00, 6.63084e-06, 1.28076e-11, 4.09082e-17}, + {9.20965e+00, 8.16336e-06, 1.57686e-11, 5.03682e-17}, + {1.11868e+01, 9.91669e-06, 1.91573e-11, 6.11981e-17}, + {1.39824e+01, 1.23969e-05, 2.39531e-11, 7.65315e-17}, + {1.78531e+01, 1.58317e-05, 3.05972e-11, 9.77803e-17}, + {2.17179e+01, 1.92624e-05, 3.72355e-11, 1.19020e-16}, + {2.37018e+01, 2.10255e-05, 4.06526e-11, 1.29977e-16}, + {2.29438e+01, 2.03578e-05, 3.93739e-11, 1.25940e-16}, + {2.02577e+01, 1.79829e-05, 3.48015e-11, 1.11389e-16}, + {1.70972e+01, 1.51927e-05, 2.94374e-11, 9.43240e-17}, + {1.43876e+01, 1.28090e-05, 2.48736e-11, 7.98414e-17}, + {1.23927e+01, 1.10758e-05, 2.16034e-11, 6.95714e-17}, + {1.14807e+01, 1.03984e-05, 2.05890e-11, 6.70125e-17}, + {1.34941e+01, 1.30878e-05, 2.78918e-11, 9.54730e-17}, + {2.46530e+01, 2.87907e-05, 7.29927e-11, 2.79411e-16}, + {6.22628e+01, 8.83029e-05, 2.60128e-10, 1.09021e-15}, + {1.73608e+02, 2.73721e-04, 8.65552e-10, 3.78030e-15}, + {4.81453e+02, 7.67244e-04, 2.43830e-09, 1.06714e-14}, + } + }, + { + /* name = */ "FeM_dust", + /* nonprimoridal_yield_frac = */ 4.26809e-04, + /* size_moments = */ {2.02272e-06, 5.41308e-12, 2.06248e-17}, /* opacity_coef_table = */ { {9.09085e-04, 3.41941e-09, 1.80920e-14, 1.27369e-19}, {1.61039e-03, 6.04845e-09, 3.18823e-14, 2.22622e-19}, @@ -3486,9 +3528,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "FeM_dust", - /* nonprimoridal_yield_frac = */ 4.26809e-04, - /* size_moments = */ {2.02272e-06, 5.41308e-12, 2.06248e-17}, + /* name = */ "Mg2SiO4_dust", + /* nonprimoridal_yield_frac = */ 4.08246e-15, + /* size_moments = */ {1.42189e-05, 2.04834e-10, 2.98805e-15}, /* opacity_coef_table = */ { {1.05240e-01, 1.49640e-06, 2.15567e-11, 3.14463e-16}, {1.32588e-01, 1.88525e-06, 2.71584e-11, 3.96179e-16}, @@ -3528,9 +3570,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "Mg2SiO4_dust", - /* nonprimoridal_yield_frac = */ 4.08246e-15, - /* size_moments = */ {1.42189e-05, 2.04834e-10, 2.98805e-15}, + /* name = */ "AC_dust", + /* nonprimoridal_yield_frac = */ 3.72287e-05, + /* size_moments = */ {7.46096e-07, 9.32091e-13, 1.99556e-18}, /* opacity_coef_table = */ { {3.27960e-01, 2.44690e-07, 3.05689e-13, 6.54462e-19}, {4.38752e-01, 3.27351e-07, 4.08957e-13, 8.75569e-19}, @@ -3570,9 +3612,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "AC_dust", - /* nonprimoridal_yield_frac = */ 3.72287e-05, - /* size_moments = */ {7.46096e-07, 9.32091e-13, 1.99556e-18}, + /* name = */ "SiO2_dust", + /* nonprimoridal_yield_frac = */ 4.59330e-04, + /* size_moments = */ {1.73471e-05, 3.08556e-10, 5.66409e-15}, /* opacity_coef_table = */ { {7.60136e-02, 1.31860e-06, 2.34539e-11, 4.30529e-16}, {9.06981e-02, 1.57333e-06, 2.79848e-11, 5.13702e-16}, @@ -3612,9 +3654,9 @@ static const GrainSpeciesYieldProps grain_props[] = { } }, { - /* name = */ "SiO2_dust", - /* nonprimoridal_yield_frac = */ 4.59330e-04, - /* size_moments = */ {1.73471e-05, 3.08556e-10, 5.66409e-15}, + /* name = */ "MgO_dust", + /* nonprimoridal_yield_frac = */ 5.38389e-09, + /* size_moments = */ {1.26307e-05, 1.59673e-10, 2.02075e-15}, /* opacity_coef_table = */ { {2.25374e-04, 2.84663e-09, 3.59861e-14, 4.55424e-19}, {4.04950e-04, 5.11481e-09, 6.46597e-14, 8.18303e-19}, @@ -3653,48 +3695,6 @@ static const GrainSpeciesYieldProps grain_props[] = { {9.36317e+00, 1.18251e-04, 1.49468e-09, 1.89126e-14}, } }, - { - /* name = */ "MgO_dust", - /* nonprimoridal_yield_frac = */ 5.38389e-09, - /* size_moments = */ {1.26307e-05, 1.59673e-10, 2.02075e-15}, - /* opacity_coef_table = */ { - {1.54645e-01, 1.37048e-07, 2.64662e-13, 8.45209e-19}, - {1.94685e-01, 1.72534e-07, 3.33193e-13, 1.06408e-18}, - {2.45092e-01, 2.17207e-07, 4.19469e-13, 1.33961e-18}, - {3.08551e-01, 2.73447e-07, 5.28084e-13, 1.68649e-18}, - {3.88446e-01, 3.44254e-07, 6.64830e-13, 2.12322e-18}, - {4.89028e-01, 4.33396e-07, 8.36986e-13, 2.67303e-18}, - {6.15654e-01, 5.45619e-07, 1.05372e-12, 3.36522e-18}, - {7.75056e-01, 6.86892e-07, 1.32656e-12, 4.23661e-18}, - {9.75414e-01, 8.64464e-07, 1.66951e-12, 5.33191e-18}, - {1.22498e+00, 1.08564e-06, 2.09668e-12, 6.69620e-18}, - {1.52119e+00, 1.34817e-06, 2.60370e-12, 8.31550e-18}, - {1.83682e+00, 1.62792e-06, 3.14401e-12, 1.00412e-17}, - {2.15660e+00, 1.91133e-06, 3.69138e-12, 1.17894e-17}, - {2.55494e+00, 2.26439e-06, 4.37331e-12, 1.39675e-17}, - {3.22768e+00, 2.86067e-06, 5.52501e-12, 1.76460e-17}, - {4.33077e+00, 3.83839e-06, 7.41349e-12, 2.36779e-17}, - {5.81399e+00, 5.15308e-06, 9.95292e-12, 3.17892e-17}, - {7.48107e+00, 6.63084e-06, 1.28076e-11, 4.09082e-17}, - {9.20965e+00, 8.16336e-06, 1.57686e-11, 5.03682e-17}, - {1.11868e+01, 9.91669e-06, 1.91573e-11, 6.11981e-17}, - {1.39824e+01, 1.23969e-05, 2.39531e-11, 7.65315e-17}, - {1.78531e+01, 1.58317e-05, 3.05972e-11, 9.77803e-17}, - {2.17179e+01, 1.92624e-05, 3.72355e-11, 1.19020e-16}, - {2.37018e+01, 2.10255e-05, 4.06526e-11, 1.29977e-16}, - {2.29438e+01, 2.03578e-05, 3.93739e-11, 1.25940e-16}, - {2.02577e+01, 1.79829e-05, 3.48015e-11, 1.11389e-16}, - {1.70972e+01, 1.51927e-05, 2.94374e-11, 9.43240e-17}, - {1.43876e+01, 1.28090e-05, 2.48736e-11, 7.98414e-17}, - {1.23927e+01, 1.10758e-05, 2.16034e-11, 6.95714e-17}, - {1.14807e+01, 1.03984e-05, 2.05890e-11, 6.70125e-17}, - {1.34941e+01, 1.30878e-05, 2.78918e-11, 9.54730e-17}, - {2.46530e+01, 2.87907e-05, 7.29927e-11, 2.79411e-16}, - {6.22628e+01, 8.83029e-05, 2.60128e-10, 1.09021e-15}, - {1.73608e+02, 2.73721e-04, 8.65552e-10, 3.78030e-15}, - {4.81453e+02, 7.67244e-04, 2.43830e-09, 1.06714e-14}, - } - }, }; } // namespace pisn200 @@ -3716,48 +3716,6 @@ static const GrainSpeciesYieldProps grain_props[] = { /* name = */ "MgSiO3_dust", /* nonprimoridal_yield_frac = */ 2.50000e-01, /* size_moments = */ {1.00000e-05, 1.00000e-10, 1.00000e-15}, - /* opacity_coef_table = */ { - {6.76020e-02, 6.76020e-07, 6.76020e-12, 6.76020e-17}, - {1.20181e-01, 1.20181e-06, 1.20181e-11, 1.20181e-16}, - {1.86375e-01, 1.86375e-06, 1.86375e-11, 1.86375e-16}, - {2.69708e-01, 2.69708e-06, 2.69708e-11, 2.69708e-16}, - {4.44368e-01, 4.44368e-06, 4.44368e-11, 4.44368e-16}, - {6.87406e-01, 6.87406e-06, 6.87406e-11, 6.87406e-16}, - {1.07797e+00, 1.07797e-05, 1.07797e-10, 1.07797e-15}, - {1.71241e+00, 1.71241e-05, 1.71241e-10, 1.71241e-15}, - {2.74163e+00, 2.74163e-05, 2.74163e-10, 2.74163e-15}, - {4.35812e+00, 4.35812e-05, 4.35812e-10, 4.35812e-15}, - {6.98720e+00, 6.98720e-05, 6.98720e-10, 6.98720e-15}, - {1.13206e+01, 1.13206e-04, 1.13206e-09, 1.13206e-14}, - {1.85159e+01, 1.85159e-04, 1.85159e-09, 1.85159e-14}, - {3.09414e+01, 3.09414e-04, 3.09414e-09, 3.09414e-14}, - {5.34575e+01, 5.34575e-04, 5.34575e-09, 5.34575e-14}, - {9.60912e+01, 9.60912e-04, 9.60912e-09, 9.60912e-14}, - {1.76000e+02, 1.76000e-03, 1.76000e-08, 1.76000e-13}, - {3.10598e+02, 3.10598e-03, 3.10598e-08, 3.10598e-13}, - {4.95502e+02, 4.95502e-03, 4.95502e-08, 4.95502e-13}, - {6.87389e+02, 6.87389e-03, 6.87389e-08, 6.87389e-13}, - {8.21760e+02, 8.21760e-03, 8.21760e-08, 8.21760e-13}, - {8.55209e+02, 8.55209e-03, 8.55209e-08, 8.55209e-13}, - {7.90315e+02, 7.90315e-03, 7.90315e-08, 7.90315e-13}, - {6.63814e+02, 6.63814e-03, 6.63814e-08, 6.63814e-13}, - {5.19410e+02, 5.19410e-03, 5.19410e-08, 5.19410e-13}, - {3.88956e+02, 3.88956e-03, 3.88956e-08, 3.88956e-13}, - {2.88141e+02, 2.88141e-03, 2.88141e-08, 2.88141e-13}, - {2.20698e+02, 2.20698e-03, 2.20698e-08, 2.20698e-13}, - {1.84716e+02, 1.84716e-03, 1.84716e-08, 1.84716e-13}, - {1.78316e+02, 1.78316e-03, 1.78316e-08, 1.78316e-13}, - {2.05010e+02, 2.05010e-03, 2.05010e-08, 2.05010e-13}, - {2.82760e+02, 2.82760e-03, 2.82760e-08, 2.82760e-13}, - {4.70437e+02, 4.70437e-03, 4.70437e-08, 4.70437e-13}, - {9.49808e+02, 9.49808e-03, 9.49808e-08, 9.49808e-13}, - {2.18634e+03, 2.18634e-02, 2.18634e-07, 2.18634e-12}, - } - }, - { - /* name = */ "AC_dust", - /* nonprimoridal_yield_frac = */ 2.50000e-01, - /* size_moments = */ {1.00000e-05, 1.00000e-10, 1.00000e-15}, /* opacity_coef_table = */ { {2.19890e-02, 2.19890e-07, 2.19890e-12, 2.19890e-17}, {3.90612e-02, 3.90612e-07, 3.90612e-12, 3.90612e-17}, @@ -3796,6 +3754,48 @@ static const GrainSpeciesYieldProps grain_props[] = { {2.49396e+01, 2.49396e-04, 2.49396e-09, 2.49396e-14}, } }, + { + /* name = */ "AC_dust", + /* nonprimoridal_yield_frac = */ 2.50000e-01, + /* size_moments = */ {1.00000e-05, 1.00000e-10, 1.00000e-15}, + /* opacity_coef_table = */ { + {6.76020e-02, 6.76020e-07, 6.76020e-12, 6.76020e-17}, + {1.20181e-01, 1.20181e-06, 1.20181e-11, 1.20181e-16}, + {1.86375e-01, 1.86375e-06, 1.86375e-11, 1.86375e-16}, + {2.69708e-01, 2.69708e-06, 2.69708e-11, 2.69708e-16}, + {4.44368e-01, 4.44368e-06, 4.44368e-11, 4.44368e-16}, + {6.87406e-01, 6.87406e-06, 6.87406e-11, 6.87406e-16}, + {1.07797e+00, 1.07797e-05, 1.07797e-10, 1.07797e-15}, + {1.71241e+00, 1.71241e-05, 1.71241e-10, 1.71241e-15}, + {2.74163e+00, 2.74163e-05, 2.74163e-10, 2.74163e-15}, + {4.35812e+00, 4.35812e-05, 4.35812e-10, 4.35812e-15}, + {6.98720e+00, 6.98720e-05, 6.98720e-10, 6.98720e-15}, + {1.13206e+01, 1.13206e-04, 1.13206e-09, 1.13206e-14}, + {1.85159e+01, 1.85159e-04, 1.85159e-09, 1.85159e-14}, + {3.09414e+01, 3.09414e-04, 3.09414e-09, 3.09414e-14}, + {5.34575e+01, 5.34575e-04, 5.34575e-09, 5.34575e-14}, + {9.60912e+01, 9.60912e-04, 9.60912e-09, 9.60912e-14}, + {1.76000e+02, 1.76000e-03, 1.76000e-08, 1.76000e-13}, + {3.10598e+02, 3.10598e-03, 3.10598e-08, 3.10598e-13}, + {4.95502e+02, 4.95502e-03, 4.95502e-08, 4.95502e-13}, + {6.87389e+02, 6.87389e-03, 6.87389e-08, 6.87389e-13}, + {8.21760e+02, 8.21760e-03, 8.21760e-08, 8.21760e-13}, + {8.55209e+02, 8.55209e-03, 8.55209e-08, 8.55209e-13}, + {7.90315e+02, 7.90315e-03, 7.90315e-08, 7.90315e-13}, + {6.63814e+02, 6.63814e-03, 6.63814e-08, 6.63814e-13}, + {5.19410e+02, 5.19410e-03, 5.19410e-08, 5.19410e-13}, + {3.88956e+02, 3.88956e-03, 3.88956e-08, 3.88956e-13}, + {2.88141e+02, 2.88141e-03, 2.88141e-08, 2.88141e-13}, + {2.20698e+02, 2.20698e-03, 2.20698e-08, 2.20698e-13}, + {1.84716e+02, 1.84716e-03, 1.84716e-08, 1.84716e-13}, + {1.78316e+02, 1.78316e-03, 1.78316e-08, 1.78316e-13}, + {2.05010e+02, 2.05010e-03, 2.05010e-08, 2.05010e-13}, + {2.82760e+02, 2.82760e-03, 2.82760e-08, 2.82760e-13}, + {4.70437e+02, 4.70437e-03, 4.70437e-08, 4.70437e-13}, + {9.49808e+02, 9.49808e-03, 9.49808e-08, 9.49808e-13}, + {2.18634e+03, 2.18634e-02, 2.18634e-07, 2.18634e-12}, + } + }, }; } // namespace y19 From 53e79fd6bf7cd4d754b2f8ff1136bab5be43488b Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sat, 6 Dec 2025 15:36:52 -0500 Subject: [PATCH 035/175] A little more work on the machinery between the new and the old injection model format A bunch of this mess was in place to check for equivalence. Indeed, it succesfully uncovered a major error that is now fixed (in a prior commit) --- src/clib/initialize_dust_yields.cpp | 61 ++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 5 deletions(-) diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index 2956549e7..c469af56b 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -215,7 +215,6 @@ extern "C" int setup_yield_table_callback( "`%s` not a known grain species", yield_info.name); } - /* // copy the nonprimordial yield fraction inject_pathway_props->grain_yields.data[grain_species_idx][pathway_idx] = yield_info.nonprimoridal_yield_frac; @@ -228,8 +227,8 @@ extern "C" int setup_yield_table_callback( // copy over the opacity coefficients table { - int n_Td = N_Tdust_Opacity_Table; - int n_coef = N_Opacity_Coef; + int n_Td = grackle::impl::inj_model_input::N_Tdust_Opacity_Table; + int n_coef = grackle::impl::inj_model_input::N_Opacity_Coef; for (int i_Td = 0; i_Td < n_Td; i_Td++) { for (int i_coef = 0; i_coef < n_coef; i_coef++) { @@ -238,7 +237,6 @@ extern "C" int setup_yield_table_callback( } } } - */ } (static_cast(ctx)->counter)++; @@ -612,8 +610,13 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, std::vector original_set = get_summary(my_rates, n_pathways); - // if (raw != original_set) { return GrPrintAndReturnErr("expected to fail!"); } + printf("\nn grains: %d\n", (int)original_set.size()); + for (int i = 0; i < original_set.size(); i++){ + printf("->\"%s\"\n", original_set[i].name.c_str()); + } + //if (raw != original_set) { return GrPrintAndReturnErr("expected to fail!"); } + //override_dust_inject_props(my_rates, 0.0, n_pathways); SetupCallbackCtx ctx = {my_rates, 0}; int ret = grackle::impl::inj_model_input::input_inject_model_iterate( @@ -622,6 +625,54 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, return GR_FAIL; } + std::vector newer_set = get_summary(my_rates, + n_pathways); + if (newer_set.size() != original_set.size()) { + return GrPrintAndReturnErr("Shouldn't be an issue!"); + } + + for (int i =0; i < original_set.size(); i++) { + if (newer_set[i].name != original_set[i].name) { + return GrPrintAndReturnErr("Shouldn't be an issue!"); + } + + if (newer_set[i].yield_frac != original_set[i].yield_frac) { + return GrPrintAndReturnErr("issue with yield_frac"); + } + + if (newer_set[i].size_moments != original_set[i].size_moments) { + return GrPrintAndReturnErr("issue with size_moments"); + } + + for (int iSN = 0; iSN < n_pathways; iSN++) { + for (int j = 0; j < my_rates->gr_Size; j++) { + int idx = iSN * my_rates->gr_Size + j; + if (newer_set[i].opacity_coef_table[idx] != + original_set[i].opacity_coef_table[idx]) { + return GrPrintAndReturnErr( + "issue with opacity_coef_table for: %s iSN = %d, j =%d.\n" + "Traditional: %g. New:%g\n, trad - new: %g", + newer_set[i].name.c_str(), + iSN, j, original_set[i].opacity_coef_table[idx], + newer_set[i].opacity_coef_table[idx], + original_set[i].opacity_coef_table[idx] - + newer_set[i].opacity_coef_table[idx] + ); + } + + } + } + + if (newer_set[i].opacity_coef_table != original_set[i].opacity_coef_table) { + return GrPrintAndReturnErr("issue with opacity_coef_table"); + } + } + + + if (newer_set != original_set) { + return GrPrintAndReturnErr("there seems to be an issue!"); + } + GR_INTERNAL_REQUIRE(ctx.counter == 12, "sanity-checking"); return GR_SUCCESS; From 9871e851a88a401c96d28ae863b05eef83e08c69 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sat, 6 Dec 2025 15:40:13 -0500 Subject: [PATCH 036/175] another check of correctness --- src/clib/initialize_dust_yields.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index c469af56b..071ceb6da 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -616,7 +616,7 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, } //if (raw != original_set) { return GrPrintAndReturnErr("expected to fail!"); } - //override_dust_inject_props(my_rates, 0.0, n_pathways); + override_dust_inject_props(my_rates, 0.0, n_pathways); SetupCallbackCtx ctx = {my_rates, 0}; int ret = grackle::impl::inj_model_input::input_inject_model_iterate( From 6eb164e287a213e283b2bcc20f6abe01149eba80 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sat, 6 Dec 2025 15:49:05 -0500 Subject: [PATCH 037/175] remove the older injection model data organization --- src/clib/initialize_dust_yields.cpp | 4177 --------------------------- 1 file changed, 4177 deletions(-) diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index 071ceb6da..9643b8391 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -15,8 +15,6 @@ #include #include #include -#include -#include #include "grackle_macros.h" #include "grackle_chemistry_data.h" #include "initialize_dust_yields.hpp" // forward declarations @@ -25,27 +23,6 @@ #include "opaque_storage.hpp" #include "status_reporting.h" // GrPrintAndReturnErr -namespace { // stuff inside an anonymous namespace is local to this file - -// forward declare some functions -int calc_rates_dust_loc(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates); -int calc_rates_dust_C13(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates); -int calc_rates_dust_C20(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates); -int calc_rates_dust_C25(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates); -int calc_rates_dust_C30(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates); -int calc_rates_dust_F13(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates); -int calc_rates_dust_F15(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates); -int calc_rates_dust_F50(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates); -int calc_rates_dust_F80(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates); -int calc_rates_dust_P170(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates); -int calc_rates_dust_P200(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates); -int calc_rates_dust_Y19(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates); - -} // anonymous namespace - -typedef int calc_yield_rate_fn(int, chemistry_data*, chemistry_data_storage*); - - namespace { // stuff inside an anonymous namespace is local to this file int lookup_pathway_idx(const char* name) { @@ -93,12 +70,6 @@ extern "C" int setup_yield_table_callback( "`%s` is an unexpected injection pathway name", name); } - int counter_val = static_cast(ctx)->counter; - - GR_INTERNAL_REQUIRE(counter_val == pathway_idx, "sanity-checking"); - //printf("encounterd: `%s`, pathway_idx: %d\n", name, pathway_idx); - //fflush(stdout); - chemistry_data_storage *my_rates = static_cast(ctx)->my_rates; @@ -339,145 +310,6 @@ void override_dust_inject_props(chemistry_data_storage *my_rates, } } -struct SummaryGrainYieldProp{ - std::string name; - std::vector yield_frac; - std::vector size_moments; - std::vector opacity_coef_table; - - bool operator==(const SummaryGrainYieldProp& other) const { - return ( - (name == other.name) && - (yield_frac == other.yield_frac) && - (size_moments == other.size_moments) && - (opacity_coef_table == other.opacity_coef_table) - ); - } - - - bool operator!=(const SummaryGrainYieldProp& other) const { - return ( - (name != other.name) || - (yield_frac != other.yield_frac) || - (size_moments != other.size_moments) || - (opacity_coef_table != other.opacity_coef_table) - ); - } -}; - -std::vector -get_summary(chemistry_data_storage *my_rates, int n_pathways) { - - GRIMPL_REQUIRE(my_rates != nullptr && my_rates->opaque_storage != nullptr, - "sanity check -- should never ever fail!"); - grackle::impl::GrainMetalInjectPathways* inject_pathway_props - = my_rates->opaque_storage->inject_pathway_props; - - GRIMPL_REQUIRE(inject_pathway_props != nullptr, - "sanity check -- should never ever fail!"); - auto helper_fn = [=](const char* name) { - - int grain_species_idx = -1; - const double* cur_size_mom_table = nullptr; - const double* cur_opac_coef_table = nullptr; - if (std::strcmp("MgSiO3_dust", name) == 0) { - grain_species_idx = OnlyGrainSpLUT::MgSiO3_dust; - cur_size_mom_table = my_rates->SN0_r0MgSiO3; - cur_opac_coef_table = my_rates->SN0_kpMgSiO3; - } else if (std::strcmp("AC_dust", name) == 0) { - grain_species_idx = OnlyGrainSpLUT::AC_dust; - cur_size_mom_table = my_rates->SN0_r0AC; - cur_opac_coef_table = my_rates->SN0_kpAC; - } else if (std::strcmp("SiM_dust", name) == 0) { - grain_species_idx = OnlyGrainSpLUT::SiM_dust; - cur_size_mom_table = my_rates->SN0_r0SiM; - cur_opac_coef_table = my_rates->SN0_kpSiM; - } else if (std::strcmp("FeM_dust", name) == 0) { - grain_species_idx = OnlyGrainSpLUT::FeM_dust; - cur_size_mom_table = my_rates->SN0_r0FeM; - cur_opac_coef_table = my_rates->SN0_kpFeM; - } else if (std::strcmp("Mg2SiO4_dust", name) == 0) { - grain_species_idx = OnlyGrainSpLUT::Mg2SiO4_dust; - cur_size_mom_table = my_rates->SN0_r0Mg2SiO4; - cur_opac_coef_table = my_rates->SN0_kpMg2SiO4; - } else if (std::strcmp("Fe3O4_dust", name) == 0) { - grain_species_idx = OnlyGrainSpLUT::Fe3O4_dust; - cur_size_mom_table = my_rates->SN0_r0Fe3O4; - cur_opac_coef_table = my_rates->SN0_kpFe3O4; - } else if (std::strcmp("SiO2_dust", name) == 0) { - grain_species_idx = OnlyGrainSpLUT::SiO2_dust; - cur_size_mom_table = my_rates->SN0_r0SiO2D; - cur_opac_coef_table = my_rates->SN0_kpSiO2D; - } else if (std::strcmp("MgO_dust", name) == 0) { - grain_species_idx = OnlyGrainSpLUT::MgO_dust; - cur_size_mom_table = my_rates->SN0_r0MgO; - cur_opac_coef_table = my_rates->SN0_kpMgO; - } else if (std::strcmp("FeS_dust", name) == 0) { - grain_species_idx = OnlyGrainSpLUT::FeS_dust; - cur_size_mom_table = my_rates->SN0_r0FeS; - cur_opac_coef_table = my_rates->SN0_kpFeS; - } else if (std::strcmp("Al2O3_dust", name) == 0) { - grain_species_idx = OnlyGrainSpLUT::Al2O3_dust; - cur_size_mom_table = my_rates->SN0_r0Al2O3; - cur_opac_coef_table = my_rates->SN0_kpAl2O3; - } else if (std::strcmp("ref_org_dust", name) == 0) { - grain_species_idx = OnlyGrainSpLUT::ref_org_dust; - cur_size_mom_table = my_rates->SN0_r0reforg; - cur_opac_coef_table = my_rates->SN0_kpreforg; - } else if (std::strcmp("vol_org_dust", name) == 0) { - grain_species_idx = OnlyGrainSpLUT::vol_org_dust; - cur_size_mom_table = my_rates->SN0_r0volorg; - cur_opac_coef_table = my_rates->SN0_kpvolorg; - } else if (std::strcmp("H2O_ice_dust", name) == 0) { - grain_species_idx = OnlyGrainSpLUT::H2O_ice_dust; - cur_size_mom_table = my_rates->SN0_r0H2Oice; - cur_opac_coef_table = my_rates->SN0_kpH2Oice; - } else { - GRIMPL_ERROR("THERE'S A PROBLEM"); - } - - const double* cur_yields = - inject_pathway_props->grain_yields.data[grain_species_idx]; - - std::vector yields(cur_yields, cur_yields + n_pathways); - std::vector size_mom_table - (cur_size_mom_table, cur_size_mom_table + (n_pathways*3)); - std::vector opac_coef_table - (cur_opac_coef_table, - cur_opac_coef_table + (n_pathways*my_rates->gr_Size)); - return SummaryGrainYieldProp{std::string(name), - yields, - size_mom_table, - opac_coef_table}; - }; - - std::vector names = { - "MgSiO3_dust", - "AC_dust", - "SiM_dust", - "FeM_dust", - "Mg2SiO4_dust", - "Fe3O4_dust", - "SiO2_dust", - "MgO_dust", - "FeS_dust", - "Al2O3_dust", - "ref_org_dust", - "vol_org_dust", - "H2O_ice_dust", - }; - - - std::vector out; - for (auto name : names){ - out.push_back(helper_fn(name.c_str())); - } - std::printf("%s\n", out[2].name.c_str()); - return out; - -} - - } // anonymous namespace int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, @@ -590,33 +422,6 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, override_metal_inject_props(inject_pathway_props, 0.0, n_pathways); override_dust_inject_props(my_rates, 0.0, n_pathways); - - std::vector raw = get_summary(my_rates, n_pathways); - - // initialize all of the properties - calc_yield_rate_fn* fn_list[] = { - &calc_rates_dust_loc, &calc_rates_dust_C13, &calc_rates_dust_C20, - &calc_rates_dust_C25, &calc_rates_dust_C30, &calc_rates_dust_F13, - &calc_rates_dust_F15, &calc_rates_dust_F50, &calc_rates_dust_F80, - &calc_rates_dust_P170, &calc_rates_dust_P200, &calc_rates_dust_Y19 - }; - - int n_funcs = (int)(sizeof(fn_list) / sizeof(calc_yield_rate_fn*)); - - for (int i = 0; i < n_funcs; i++) { - int rv = fn_list[i](i, my_chemistry, my_rates); - if (rv != SUCCESS) { return rv; } - } - - std::vector original_set = get_summary(my_rates, - n_pathways); - printf("\nn grains: %d\n", (int)original_set.size()); - for (int i = 0; i < original_set.size(); i++){ - printf("->\"%s\"\n", original_set[i].name.c_str()); - } - //if (raw != original_set) { return GrPrintAndReturnErr("expected to fail!"); } - - override_dust_inject_props(my_rates, 0.0, n_pathways); SetupCallbackCtx ctx = {my_rates, 0}; int ret = grackle::impl::inj_model_input::input_inject_model_iterate( @@ -625,54 +430,6 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, return GR_FAIL; } - std::vector newer_set = get_summary(my_rates, - n_pathways); - if (newer_set.size() != original_set.size()) { - return GrPrintAndReturnErr("Shouldn't be an issue!"); - } - - for (int i =0; i < original_set.size(); i++) { - if (newer_set[i].name != original_set[i].name) { - return GrPrintAndReturnErr("Shouldn't be an issue!"); - } - - if (newer_set[i].yield_frac != original_set[i].yield_frac) { - return GrPrintAndReturnErr("issue with yield_frac"); - } - - if (newer_set[i].size_moments != original_set[i].size_moments) { - return GrPrintAndReturnErr("issue with size_moments"); - } - - for (int iSN = 0; iSN < n_pathways; iSN++) { - for (int j = 0; j < my_rates->gr_Size; j++) { - int idx = iSN * my_rates->gr_Size + j; - if (newer_set[i].opacity_coef_table[idx] != - original_set[i].opacity_coef_table[idx]) { - return GrPrintAndReturnErr( - "issue with opacity_coef_table for: %s iSN = %d, j =%d.\n" - "Traditional: %g. New:%g\n, trad - new: %g", - newer_set[i].name.c_str(), - iSN, j, original_set[i].opacity_coef_table[idx], - newer_set[i].opacity_coef_table[idx], - original_set[i].opacity_coef_table[idx] - - newer_set[i].opacity_coef_table[idx] - ); - } - - } - } - - if (newer_set[i].opacity_coef_table != original_set[i].opacity_coef_table) { - return GrPrintAndReturnErr("issue with opacity_coef_table"); - } - } - - - if (newer_set != original_set) { - return GrPrintAndReturnErr("there seems to be an issue!"); - } - GR_INTERNAL_REQUIRE(ctx.counter == 12, "sanity-checking"); return GR_SUCCESS; @@ -738,3937 +495,3 @@ int grackle::impl::free_dust_yields(chemistry_data *my_chemistry, return SUCCESS; } - -namespace { // stuff inside an anonymous namespace is local to this file - -int calc_rates_dust_loc(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates) -{ - - int NTd, Nmom; - int iTd, imom, itab0, itab; - - grackle::impl::GrainMetalInjectPathways* inject_pathway_props - = my_rates->opaque_storage->inject_pathway_props; - - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 1.35403e-02; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust][iSN] = 1.36165e-01; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN] = 3.84003e-02; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeS_dust] [iSN] = 3.04389e-02; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::ref_org_dust][iSN] = 1.86114e-01; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::vol_org_dust][iSN] = 3.81956e-02; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::H2O_ice_dust][iSN] = 6.33011e-02; - - itab0 = 3 * iSN; - my_rates->SN0_r0FeM [itab0 + 0] = 8.33039e-07; - my_rates->SN0_r0Mg2SiO4 [itab0 + 0] = 8.33039e-07; - my_rates->SN0_r0MgSiO3 [itab0 + 0] = 8.33039e-07; - my_rates->SN0_r0FeS [itab0 + 0] = 8.33039e-07; - my_rates->SN0_r0reforg [itab0 + 0] = 8.33039e-07; - my_rates->SN0_r0volorg [itab0 + 0] = 8.33039e-07; - my_rates->SN0_r0H2Oice [itab0 + 0] = 8.33039e-07; - - my_rates->SN0_r0FeM [itab0 + 1] = 1.16161e-12; - my_rates->SN0_r0Mg2SiO4 [itab0 + 1] = 1.16161e-12; - my_rates->SN0_r0MgSiO3 [itab0 + 1] = 1.16161e-12; - my_rates->SN0_r0FeS [itab0 + 1] = 1.16161e-12; - my_rates->SN0_r0reforg [itab0 + 1] = 1.16161e-12; - my_rates->SN0_r0volorg [itab0 + 1] = 1.16161e-12; - my_rates->SN0_r0H2Oice [itab0 + 1] = 1.16161e-12; - - my_rates->SN0_r0FeM [itab0 + 2] = 8.21384e-18; - my_rates->SN0_r0Mg2SiO4 [itab0 + 2] = 8.21384e-18; - my_rates->SN0_r0MgSiO3 [itab0 + 2] = 8.21384e-18; - my_rates->SN0_r0FeS [itab0 + 2] = 8.21384e-18; - my_rates->SN0_r0reforg [itab0 + 2] = 8.21384e-18; - my_rates->SN0_r0volorg [itab0 + 2] = 8.21384e-18; - my_rates->SN0_r0H2Oice [itab0 + 2] = 8.21384e-18; - - NTd = 35; - Nmom = 4; - - double loc_kpFeM[] = - { 3.03937e-04, 1.23816e-09, 4.62094e-14, 3.72497e-18, - 5.33931e-04, 1.94666e-09, 6.42306e-14, 4.92267e-18, - 8.23085e-04, 2.82715e-09, 8.64655e-14, 6.40508e-18, - 1.18689e-03, 3.92926e-09, 1.14201e-13, 8.25547e-18, - 1.93090e-03, 5.86828e-09, 1.50433e-13, 1.02764e-17, - 2.95251e-03, 8.43657e-09, 1.95467e-13, 1.27089e-17, - 4.55033e-03, 1.22013e-08, 2.52591e-13, 1.54880e-17, - 7.04895e-03, 1.77533e-08, 3.26595e-13, 1.87358e-17, - 1.09337e-02, 2.59554e-08, 4.24054e-13, 2.26060e-17, - 1.67787e-02, 3.77909e-08, 5.51941e-13, 2.72576e-17, - 2.56790e-02, 5.50228e-08, 7.20688e-13, 3.28090e-17, - 3.89780e-02, 7.95600e-08, 9.39516e-13, 3.93285e-17, - 5.82741e-02, 1.13372e-07, 1.21633e-12, 4.68721e-17, - 8.58228e-02, 1.58873e-07, 1.55917e-12, 5.54857e-17, - 1.24511e-01, 2.18724e-07, 1.97549e-12, 6.52470e-17, - 1.78164e-01, 2.96038e-07, 2.47229e-12, 7.62244e-17, - 2.51965e-01, 3.94501e-07, 3.05495e-12, 8.84292e-17, - 3.53706e-01, 5.19228e-07, 3.72904e-12, 1.01872e-16, - 4.96690e-01, 6.79268e-07, 4.51008e-12, 1.16807e-16, - 7.06391e-01, 8.93298e-07, 5.44240e-12, 1.34078e-16, - 1.03345e+00, 1.19958e-06, 6.62440e-12, 1.55520e-16, - 1.58058e+00, 1.67481e-06, 8.24715e-12, 1.84604e-16, - 2.55750e+00, 2.47088e-06, 1.06606e-11, 2.27517e-16, - 4.39505e+00, 3.88891e-06, 1.44836e-11, 2.94492e-16, - 7.97338e+00, 6.52370e-06, 2.07697e-11, 4.00081e-16, - 1.50676e+01, 1.15419e-05, 3.12837e-11, 5.61771e-16, - 2.91750e+01, 2.11959e-05, 4.90431e-11, 7.99872e-16, - 5.69546e+01, 3.97177e-05, 7.93362e-11, 1.14279e-15, - 1.10473e+02, 7.47151e-05, 1.31340e-10, 1.63629e-15, - 2.10337e+02, 1.39130e-04, 2.20345e-10, 2.35251e-15, - 3.89661e+02, 2.53753e-04, 3.70677e-10, 3.39830e-15, - 6.99152e+02, 4.50456e-04, 6.19407e-10, 4.92457e-15, - 1.21457e+03, 7.76739e-04, 1.02057e-09, 7.13090e-15, - 2.05022e+03, 1.30302e-03, 1.64745e-09, 1.02322e-14, - 3.38793e+03, 2.13731e-03, 2.59306e-09, 1.43690e-14 }; - - double loc_kpMg2SiO4[] = - { 2.45237e-01, 1.46287e-07, 1.48927e-13, 1.14540e-18, - 3.08964e-01, 1.84301e-07, 1.87627e-13, 1.44311e-18, - 3.89192e-01, 2.32158e-07, 2.36348e-13, 1.81790e-18, - 4.90193e-01, 2.92406e-07, 2.97684e-13, 2.28974e-18, - 6.33568e-01, 3.77932e-07, 3.84757e-13, 2.95995e-18, - 8.28859e-01, 4.94426e-07, 5.03359e-13, 3.87306e-18, - 1.13002e+00, 6.74071e-07, 6.86261e-13, 5.28188e-18, - 1.63064e+00, 9.72699e-07, 9.90315e-13, 7.62608e-18, - 2.46680e+00, 1.47148e-06, 1.49820e-12, 1.15475e-17, - 3.79604e+00, 2.26439e-06, 2.30565e-12, 1.77932e-17, - 5.92492e+00, 3.53430e-06, 3.59906e-12, 2.78297e-17, - 9.23920e+00, 5.51134e-06, 5.61323e-12, 4.35401e-17, - 1.42293e+01, 8.48802e-06, 8.64701e-12, 6.73899e-17, - 2.16427e+01, 1.29103e-05, 1.31570e-11, 1.03293e-16, - 3.24523e+01, 1.93586e-05, 1.97391e-11, 1.56579e-16, - 4.78595e+01, 2.85497e-05, 2.91302e-11, 2.33879e-16, - 7.00593e+01, 4.17932e-05, 4.26757e-11, 3.46486e-16, - 1.06051e+02, 6.32653e-05, 6.46560e-11, 5.28640e-16, - 1.74267e+02, 1.03964e-04, 1.06329e-10, 8.68729e-16, - 3.02053e+02, 1.80203e-04, 1.84359e-10, 1.49313e-15, - 5.00593e+02, 2.98655e-04, 3.05537e-10, 2.44653e-15, - 7.45698e+02, 4.44894e-04, 4.55158e-10, 3.61190e-15, - 1.00149e+03, 5.97517e-04, 6.11446e-10, 4.82507e-15, - 1.23701e+03, 7.38051e-04, 7.55475e-10, 5.93849e-15, - 1.39749e+03, 8.33819e-04, 8.53626e-10, 6.68589e-15, - 1.41344e+03, 8.43342e-04, 8.63374e-10, 6.74095e-15, - 1.26599e+03, 7.55370e-04, 7.73283e-10, 6.02512e-15, - 1.01032e+03, 6.02819e-04, 6.17127e-10, 4.80541e-15, - 7.30148e+02, 4.35656e-04, 4.46054e-10, 3.47626e-15, - 4.87070e+02, 2.90623e-04, 2.97653e-10, 2.32554e-15, - 3.05625e+02, 1.82365e-04, 1.86919e-10, 1.46881e-15, - 1.84266e+02, 1.09966e-04, 1.12993e-10, 9.02608e-16, - 1.10340e+02, 6.58826e-05, 6.82482e-11, 5.72358e-16, - 6.91207e+01, 4.13300e-05, 4.36913e-11, 4.08010e-16, - 4.77899e+01, 2.86629e-05, 3.13943e-11, 3.40524e-16 }; - - double loc_kpMgSiO3[] = - { 5.12401e-02, 3.05654e-08, 3.11170e-14, 2.39327e-19, - 9.10229e-02, 5.42964e-08, 5.52765e-14, 4.25193e-19, - 1.41106e-01, 8.41719e-08, 8.56916e-14, 6.59185e-19, - 2.04158e-01, 1.21783e-07, 1.23982e-13, 9.53762e-19, - 3.33897e-01, 1.99174e-07, 2.02773e-13, 1.56024e-18, - 5.10947e-01, 3.04787e-07, 3.10298e-13, 2.38807e-18, - 7.83563e-01, 4.67406e-07, 4.75863e-13, 3.66337e-18, - 1.19854e+00, 7.14943e-07, 7.27902e-13, 5.60698e-18, - 1.85772e+00, 1.10816e-06, 1.12831e-12, 8.70099e-18, - 2.92247e+00, 1.74330e-06, 1.77515e-12, 1.37124e-17, - 4.74091e+00, 2.82803e-06, 2.88010e-12, 2.23096e-17, - 7.79816e+00, 4.65174e-06, 4.73847e-12, 3.68720e-17, - 1.27207e+01, 7.58818e-06, 7.73243e-12, 6.06033e-17, - 2.05556e+01, 1.22619e-05, 1.25020e-11, 9.90816e-17, - 3.30490e+01, 1.97147e-05, 2.01153e-11, 1.61650e-16, - 5.32277e+01, 3.17524e-05, 3.24225e-11, 2.63830e-16, - 8.64944e+01, 5.15982e-05, 5.27236e-11, 4.32162e-16, - 1.43144e+02, 8.53944e-05, 8.73076e-11, 7.16006e-16, - 2.41992e+02, 1.44367e-04, 1.47663e-10, 1.20379e-15, - 4.08980e+02, 2.43996e-04, 2.49602e-10, 2.01287e-15, - 6.57282e+02, 3.92138e-04, 4.01100e-10, 3.19447e-15, - 9.65951e+02, 5.76298e-04, 5.89371e-10, 4.64306e-15, - 1.30489e+03, 7.78527e-04, 7.96032e-10, 6.21292e-15, - 1.65692e+03, 9.88559e-04, 1.01028e-09, 7.80402e-15, - 1.95936e+03, 1.16899e-03, 1.19360e-09, 9.11030e-15, - 2.08639e+03, 1.24475e-03, 1.26965e-09, 9.58003e-15, - 1.95845e+03, 1.16840e-03, 1.19068e-09, 8.90255e-15, - 1.62353e+03, 9.68572e-04, 9.86379e-10, 7.32855e-15, - 1.20759e+03, 7.20421e-04, 7.33336e-10, 5.42763e-15, - 8.22295e+02, 4.90559e-04, 4.99228e-10, 3.68795e-15, - 5.22496e+02, 3.11708e-04, 3.17198e-10, 2.34267e-15, - 3.14915e+02, 1.87872e-04, 1.91211e-10, 1.41447e-15, - 1.82496e+02, 1.08876e-04, 1.10875e-10, 8.23864e-16, - 1.02901e+02, 6.13959e-05, 6.26109e-11, 4.69856e-16, - 5.73186e+01, 3.42174e-05, 3.50508e-11, 2.68356e-16 }; - - double loc_kpFeS[] = - { 1.20726e-01, 7.20182e-08, 7.35280e-14, 5.95267e-19, - 2.32766e-01, 1.38854e-07, 1.41735e-13, 1.14369e-18, - 3.73816e-01, 2.22995e-07, 2.27602e-13, 1.83408e-18, - 5.51388e-01, 3.28923e-07, 3.35702e-13, 2.70320e-18, - 8.55868e-01, 5.10557e-07, 5.21179e-13, 4.21168e-18, - 1.24954e+00, 7.45400e-07, 7.61051e-13, 6.17189e-18, - 1.78078e+00, 1.06231e-06, 1.08497e-12, 8.85200e-18, - 2.44607e+00, 1.45920e-06, 1.49119e-12, 1.23029e-17, - 3.21763e+00, 1.91949e-06, 1.96357e-12, 1.65254e-17, - 4.06334e+00, 2.42404e-06, 2.48333e-12, 2.14914e-17, - 4.90080e+00, 2.92371e-06, 3.00112e-12, 2.69365e-17, - 5.64261e+00, 3.36638e-06, 3.46359e-12, 3.23217e-17, - 6.21740e+00, 3.70948e-06, 3.82669e-12, 3.70749e-17, - 6.56246e+00, 3.91565e-06, 4.05361e-12, 4.08425e-17, - 6.75396e+00, 4.03063e-06, 4.20072e-12, 4.47151e-17, - 7.17709e+00, 4.28498e-06, 4.53461e-12, 5.31551e-17, - 8.60795e+00, 5.14313e-06, 5.58433e-12, 7.44632e-17, - 1.17764e+01, 7.04212e-06, 7.86423e-12, 1.17214e-16, - 1.64787e+01, 9.86444e-06, 1.14471e-11, 1.95038e-16, - 2.14143e+01, 1.28476e-05, 1.62848e-11, 3.61550e-16, - 2.51760e+01, 1.51720e-05, 2.28477e-11, 7.25431e-16, - 2.71833e+01, 1.64950e-05, 3.14267e-11, 1.35273e-15, - 2.77234e+01, 1.69657e-05, 4.09753e-11, 2.14916e-15, - 2.74221e+01, 1.69259e-05, 4.94400e-11, 2.89997e-15, - 2.68227e+01, 1.66816e-05, 5.53227e-11, 3.43309e-15, - 2.62247e+01, 1.64266e-05, 5.86985e-11, 3.72279e-15, - 2.58704e+01, 1.64543e-05, 6.22578e-11, 3.90038e-15, - 2.71342e+01, 1.84130e-05, 7.74409e-11, 4.33089e-15, - 3.69065e+01, 2.84578e-05, 1.28908e-10, 5.42457e-15, - 7.78838e+01, 6.43091e-05, 2.58063e-10, 7.39401e-15, - 1.96086e+02, 1.59699e-04, 5.23332e-10, 1.03910e-14, - 4.47749e+02, 3.52292e-04, 9.69286e-10, 1.44002e-14, - 8.75250e+02, 6.66973e-04, 1.60576e-09, 1.92445e-14, - 1.50099e+03, 1.11385e-03, 2.41814e-09, 2.47015e-14, - 2.33693e+03, 1.69566e-03, 3.38124e-09, 3.05222e-14 }; - - double loc_kpreforg[] = - { 4.68555e-02, 2.79499e-08, 2.84543e-14, 2.18837e-19, - 6.66016e-02, 3.97287e-08, 4.04457e-14, 3.11065e-19, - 9.14604e-02, 5.45574e-08, 5.55420e-14, 4.27173e-19, - 1.22756e-01, 7.32255e-08, 7.45471e-14, 5.73344e-19, - 2.39395e-01, 1.42802e-07, 1.45382e-13, 1.11857e-18, - 4.33638e-01, 2.58671e-07, 2.63349e-13, 2.02683e-18, - 8.54269e-01, 5.09583e-07, 5.18807e-13, 3.99441e-18, - 1.71749e+00, 1.02450e-06, 1.04308e-12, 8.03545e-18, - 3.29447e+00, 1.96520e-06, 2.00091e-12, 1.54275e-17, - 5.86107e+00, 3.49621e-06, 3.55997e-12, 2.74796e-17, - 9.98591e+00, 5.95675e-06, 6.06595e-12, 4.69112e-17, - 1.64428e+01, 9.80839e-06, 9.98976e-12, 7.74960e-17, - 2.63091e+01, 1.56939e-05, 1.59880e-11, 1.24634e-16, - 4.13343e+01, 2.46568e-05, 2.51287e-11, 1.97408e-16, - 6.41346e+01, 3.82579e-05, 3.90120e-11, 3.09791e-16, - 9.87636e+01, 5.89156e-05, 6.01167e-11, 4.83037e-16, - 1.51958e+02, 9.06488e-05, 9.25564e-11, 7.50644e-16, - 2.34417e+02, 1.39841e-04, 1.42858e-10, 1.16365e-15, - 3.57697e+02, 2.13387e-04, 2.18076e-10, 1.77561e-15, - 5.28819e+02, 3.15479e-04, 3.22528e-10, 2.61825e-15, - 7.52235e+02, 4.48774e-04, 4.59023e-10, 3.71332e-15, - 1.02632e+03, 6.12308e-04, 6.26695e-10, 5.05587e-15, - 1.32111e+03, 7.88218e-04, 8.07423e-10, 6.50989e-15, - 1.57574e+03, 9.40185e-04, 9.64291e-10, 7.80218e-15, - 1.73868e+03, 1.03748e-03, 1.06621e-09, 8.71453e-15, - 1.80162e+03, 1.07516e-03, 1.10855e-09, 9.23861e-15, - 1.79360e+03, 1.07058e-03, 1.10965e-09, 9.55041e-15, - 1.76388e+03, 1.05316e-03, 1.10040e-09, 9.92949e-15, - 1.76147e+03, 1.05218e-03, 1.11104e-09, 1.06225e-14, - 1.80062e+03, 1.07614e-03, 1.14939e-09, 1.16303e-14, - 1.85114e+03, 1.10702e-03, 1.19518e-09, 1.26854e-14, - 1.87614e+03, 1.12283e-03, 1.22470e-09, 1.35171e-14, - 1.86911e+03, 1.11985e-03, 1.23456e-09, 1.40796e-14, - 1.85783e+03, 1.11511e-03, 1.24487e-09, 1.45610e-14, - 1.90737e+03, 1.14893e-03, 1.30468e-09, 1.53873e-14 }; - - double loc_kpvolorg[] = - { 7.02832e-02, 4.19249e-08, 4.26814e-14, 3.28255e-19, - 9.99024e-02, 5.95931e-08, 6.06685e-14, 4.66597e-19, - 1.37191e-01, 8.18361e-08, 8.33130e-14, 6.40759e-19, - 1.84134e-01, 1.09838e-07, 1.11821e-13, 8.60016e-19, - 3.59093e-01, 2.14204e-07, 2.18074e-13, 1.67786e-18, - 6.50459e-01, 3.88007e-07, 3.95023e-13, 3.04025e-18, - 1.28140e+00, 7.64376e-07, 7.78212e-13, 5.99162e-18, - 2.57622e+00, 1.53675e-06, 1.56462e-12, 1.20532e-17, - 4.94170e+00, 2.94779e-06, 3.00137e-12, 2.31413e-17, - 8.79162e+00, 5.24433e-06, 5.33996e-12, 4.12194e-17, - 1.49789e+01, 8.93514e-06, 9.09893e-12, 7.03669e-17, - 2.46641e+01, 1.47126e-05, 1.49846e-11, 1.16244e-16, - 3.94637e+01, 2.35409e-05, 2.39820e-11, 1.86951e-16, - 6.20013e+01, 3.69851e-05, 3.76930e-11, 2.96113e-16, - 9.62020e+01, 5.73870e-05, 5.85180e-11, 4.64688e-16, - 1.48145e+02, 8.83735e-05, 9.01751e-11, 7.24557e-16, - 2.27937e+02, 1.35973e-04, 1.38835e-10, 1.12597e-15, - 3.51626e+02, 2.09762e-04, 2.14288e-10, 1.74548e-15, - 5.36545e+02, 3.20081e-04, 3.27114e-10, 2.66341e-15, - 7.93228e+02, 4.73218e-04, 4.83793e-10, 3.92738e-15, - 1.12835e+03, 6.73161e-04, 6.88534e-10, 5.56999e-15, - 1.53947e+03, 9.18463e-04, 9.40042e-10, 7.58380e-15, - 1.98167e+03, 1.18233e-03, 1.21114e-09, 9.76484e-15, - 2.36362e+03, 1.41028e-03, 1.44644e-09, 1.17033e-14, - 2.60802e+03, 1.55622e-03, 1.59931e-09, 1.30718e-14, - 2.70242e+03, 1.61274e-03, 1.66283e-09, 1.38579e-14, - 2.69039e+03, 1.60586e-03, 1.66448e-09, 1.43256e-14, - 2.64583e+03, 1.57974e-03, 1.65060e-09, 1.48942e-14, - 2.64222e+03, 1.57827e-03, 1.66657e-09, 1.59338e-14, - 2.70093e+03, 1.61421e-03, 1.72408e-09, 1.74454e-14, - 2.77670e+03, 1.66053e-03, 1.79277e-09, 1.90281e-14, - 2.81420e+03, 1.68424e-03, 1.83704e-09, 2.02756e-14, - 2.80366e+03, 1.67977e-03, 1.85184e-09, 2.11194e-14, - 2.78675e+03, 1.67267e-03, 1.86731e-09, 2.18416e-14, - 2.86105e+03, 1.72339e-03, 1.95702e-09, 2.30809e-14 }; - - double loc_kpH2Oice[] = - { 6.30862e-02, 3.76318e-08, 3.83108e-14, 2.94648e-19, - 1.09691e-01, 6.54321e-08, 6.66131e-14, 5.12363e-19, - 1.68363e-01, 1.00431e-07, 1.02243e-13, 7.86449e-19, - 2.42226e-01, 1.44491e-07, 1.47099e-13, 1.13150e-18, - 3.92991e-01, 2.34424e-07, 2.38657e-13, 1.83595e-18, - 6.03026e-01, 3.59713e-07, 3.66210e-13, 2.81745e-18, - 9.41509e-01, 5.61623e-07, 5.71771e-13, 4.39959e-18, - 1.54206e+00, 9.19862e-07, 9.36500e-13, 7.20849e-18, - 2.75198e+00, 1.64160e-06, 1.67135e-12, 1.28735e-17, - 5.12965e+00, 3.05991e-06, 3.11550e-12, 2.40170e-17, - 9.67703e+00, 5.77249e-06, 5.87767e-12, 4.53565e-17, - 1.70842e+01, 1.01910e-05, 1.03775e-11, 8.02010e-17, - 2.87858e+01, 1.71712e-05, 1.74882e-11, 1.35552e-16, - 5.22985e+01, 3.11971e-05, 3.17818e-11, 2.47506e-16, - 1.08421e+02, 6.46756e-05, 6.59042e-11, 5.15083e-16, - 2.29694e+02, 1.37018e-04, 1.39634e-10, 1.09171e-15, - 4.35888e+02, 2.60019e-04, 2.64976e-10, 2.06803e-15, - 6.94501e+02, 4.14288e-04, 4.22159e-10, 3.28761e-15, - 9.21763e+02, 5.49857e-04, 5.60297e-10, 4.35726e-15, - 1.06208e+03, 6.33565e-04, 6.45702e-10, 5.02330e-15, - 1.17460e+03, 7.00699e-04, 7.14492e-10, 5.57174e-15, - 1.41297e+03, 8.42922e-04, 8.60130e-10, 6.71698e-15, - 1.86068e+03, 1.11004e-03, 1.13311e-09, 8.82123e-15, - 2.38031e+03, 1.42005e-03, 1.44954e-09, 1.12234e-14, - 2.71131e+03, 1.61753e-03, 1.65107e-09, 1.27373e-14, - 2.72120e+03, 1.62346e-03, 1.65757e-09, 1.27900e-14, - 2.53189e+03, 1.51058e-03, 1.54284e-09, 1.19191e-14, - 2.48249e+03, 1.48118e-03, 1.51103e-09, 1.15227e-14, - 2.89111e+03, 1.72503e-03, 1.75260e-09, 1.28501e-14, - 3.66301e+03, 2.18553e-03, 2.21015e-09, 1.55022e-14, - 4.27842e+03, 2.55260e-03, 2.57302e-09, 1.74959e-14, - 4.29745e+03, 2.56387e-03, 2.57944e-09, 1.72213e-14, - 3.71668e+03, 2.21732e-03, 2.22839e-09, 1.47266e-14, - 2.83563e+03, 1.69168e-03, 1.69914e-09, 1.11685e-14, - 1.96048e+03, 1.16958e-03, 1.17438e-09, 7.69912e-15 }; - - - itab0 = Nmom * NTd * iSN; - itab = 0; - for(imom = 0; imom < Nmom; imom++) { - for(iTd = 0; iTd < NTd; iTd++) { - my_rates->SN0_kpFeM [itab0] = loc_kpFeM [itab]; - my_rates->SN0_kpMg2SiO4 [itab0] = loc_kpMg2SiO4 [itab]; - my_rates->SN0_kpMgSiO3 [itab0] = loc_kpMgSiO3 [itab]; - my_rates->SN0_kpFeS [itab0] = loc_kpFeS [itab]; - my_rates->SN0_kpreforg [itab0] = loc_kpreforg [itab]; - my_rates->SN0_kpvolorg [itab0] = loc_kpvolorg [itab]; - my_rates->SN0_kpH2Oice [itab0] = loc_kpH2Oice [itab]; - itab0++; - itab ++; - } - } - - return SUCCESS; -} - -int calc_rates_dust_C13(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates) -{ - - int NTd, Nmom; - int iTd, imom, itab0, itab; - - grackle::impl::GrainMetalInjectPathways* inject_pathway_props - = my_rates->opaque_storage->inject_pathway_props; - - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust] [iSN] = 1.65746e-02; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 2.39849e-02; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 8.69522e-04; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN] = 2.87802e-06; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust] [iSN] = 4.85826e-02; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust] [iSN] = 2.52534e-03; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgO_dust] [iSN] = 1.28672e-05; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeS_dust] [iSN] = 2.09730e-06; - - itab0 = 3 * iSN; - my_rates->SN0_r0SiM [itab0 + 0] = 1.68557e-06; - my_rates->SN0_r0FeM [itab0 + 0] = 4.62542e-06; - my_rates->SN0_r0Mg2SiO4 [itab0 + 0] = 1.82163e-06; - my_rates->SN0_r0MgSiO3 [itab0 + 0] = 7.26303e-07; - my_rates->SN0_r0AC [itab0 + 0] = 4.82296e-06; - my_rates->SN0_r0SiO2D [itab0 + 0] = 1.33530e-06; - my_rates->SN0_r0MgO [itab0 + 0] = 1.59029e-06; - my_rates->SN0_r0FeS [itab0 + 0] = 6.16010e-07; - - my_rates->SN0_r0SiM [itab0 + 1] = 9.75226e-12; - my_rates->SN0_r0FeM [itab0 + 1] = 3.82292e-11; - my_rates->SN0_r0Mg2SiO4 [itab0 + 1] = 5.83823e-12; - my_rates->SN0_r0MgSiO3 [itab0 + 1] = 7.49856e-13; - my_rates->SN0_r0AC [itab0 + 1] = 3.91353e-11; - my_rates->SN0_r0SiO2D [itab0 + 1] = 5.91862e-12; - my_rates->SN0_r0MgO [itab0 + 1] = 7.21459e-12; - my_rates->SN0_r0FeS [itab0 + 1] = 4.56500e-13; - - my_rates->SN0_r0SiM [itab0 + 2] = 1.74046e-16; - my_rates->SN0_r0FeM [itab0 + 2] = 4.68445e-16; - my_rates->SN0_r0Mg2SiO4 [itab0 + 2] = 3.61356e-17; - my_rates->SN0_r0MgSiO3 [itab0 + 2] = 1.57511e-18; - my_rates->SN0_r0AC [itab0 + 2] = 5.15140e-16; - my_rates->SN0_r0SiO2D [itab0 + 2] = 5.31739e-17; - my_rates->SN0_r0MgO [itab0 + 2] = 4.84120e-17; - my_rates->SN0_r0FeS [itab0 + 2] = 4.16699e-19; - - NTd = 35; - Nmom = 4; - - double C13_kpSiM[] = - { 1.54619e-01, 2.60128e-07, 1.49475e-12, 2.65148e-17, - 1.94656e-01, 3.27554e-07, 1.88361e-12, 3.34351e-17, - 2.45059e-01, 4.12439e-07, 2.37316e-12, 4.21472e-17, - 3.08513e-01, 5.19301e-07, 2.98947e-12, 5.31150e-17, - 3.88404e-01, 6.53894e-07, 3.76675e-12, 6.69643e-17, - 4.88982e-01, 8.23350e-07, 4.74559e-12, 8.44087e-17, - 6.15605e-01, 1.03673e-06, 5.97899e-12, 1.06403e-16, - 7.75006e-01, 1.30539e-06, 7.53301e-12, 1.34131e-16, - 9.75366e-01, 1.64315e-06, 9.48791e-12, 1.69031e-16, - 1.22493e+00, 2.06392e-06, 1.19246e-11, 2.12553e-16, - 1.52116e+00, 2.56344e-06, 1.48192e-11, 2.64285e-16, - 1.83681e+00, 3.09586e-06, 1.79072e-11, 3.19511e-16, - 2.15662e+00, 3.63549e-06, 2.10413e-11, 3.75635e-16, - 2.55502e+00, 4.30820e-06, 2.49580e-11, 4.45921e-16, - 3.22790e+00, 5.44497e-06, 3.15890e-11, 5.65115e-16, - 4.33126e+00, 7.30995e-06, 4.24882e-11, 7.61352e-16, - 5.81498e+00, 9.82030e-06, 5.72103e-11, 1.02723e-15, - 7.48294e+00, 1.26484e-05, 7.39233e-11, 1.33106e-15, - 9.21324e+00, 1.55973e-05, 9.16644e-11, 1.65851e-15, - 1.11943e+01, 1.90119e-05, 1.13021e-10, 2.06536e-15, - 1.39990e+01, 2.39150e-05, 1.45136e-10, 2.69938e-15, - 1.78867e+01, 3.08010e-05, 1.92146e-10, 3.65687e-15, - 2.17798e+01, 3.79266e-05, 2.45744e-10, 4.82338e-15, - 2.38104e+01, 4.23268e-05, 2.93339e-10, 6.06677e-15, - 2.31200e+01, 4.26489e-05, 3.30423e-10, 7.40538e-15, - 2.05061e+01, 3.98990e-05, 3.56330e-10, 8.76054e-15, - 1.74011e+01, 3.59849e-05, 3.69684e-10, 9.86673e-15, - 1.47227e+01, 3.22080e-05, 3.69774e-10, 1.04731e-14, - 1.27456e+01, 2.91368e-05, 3.59951e-10, 1.05598e-14, - 1.18944e+01, 2.82426e-05, 3.62521e-10, 1.07315e-14, - 1.43878e+01, 3.74123e-05, 4.87177e-10, 1.37994e-14, - 2.85377e+01, 9.23385e-05, 1.20077e-09, 3.00478e-14, - 7.93256e+01, 3.11569e-04, 3.91124e-09, 8.56317e-14, - 2.33021e+02, 9.78251e-04, 1.15601e-08, 2.28453e-13, - 6.42052e+02, 2.55294e-03, 2.77058e-08, 5.06000e-13 }; - - double C13_kpFeM[] = - { 5.88921e-03, 6.87770e-08, 1.06227e-12, 2.02349e-17, - 1.01153e-02, 1.15444e-07, 1.74157e-12, 3.24501e-17, - 1.53919e-02, 1.73359e-07, 2.57952e-12, 4.74426e-17, - 2.20096e-02, 2.45791e-07, 3.62468e-12, 6.61001e-17, - 3.50047e-02, 3.82752e-07, 5.51942e-12, 9.85221e-17, - 5.25286e-02, 5.65069e-07, 8.00632e-12, 1.40508e-16, - 7.91090e-02, 8.36026e-07, 1.16179e-11, 2.00078e-16, - 1.19191e-01, 1.23677e-06, 1.68430e-11, 2.84365e-16, - 1.79251e-01, 1.82633e-06, 2.43704e-11, 4.03226e-16, - 2.66584e-01, 2.66955e-06, 3.49349e-11, 5.66851e-16, - 3.94058e-01, 3.87941e-06, 4.97989e-11, 7.92464e-16, - 5.74681e-01, 5.56462e-06, 7.01108e-11, 1.09474e-15, - 8.20409e-01, 7.81996e-06, 9.68130e-11, 1.48491e-15, - 1.14378e+00, 1.07400e-05, 1.30804e-10, 1.97313e-15, - 1.55566e+00, 1.44006e-05, 1.72756e-10, 2.56649e-15, - 2.06561e+00, 1.88620e-05, 2.23158e-10, 3.26978e-15, - 2.68069e+00, 2.41572e-05, 2.82187e-10, 4.08370e-15, - 3.40683e+00, 3.03006e-05, 3.49792e-10, 5.00618e-15, - 4.25797e+00, 3.73606e-05, 4.26499e-10, 6.04358e-15, - 5.27551e+00, 4.56092e-05, 5.14976e-10, 7.23179e-15, - 6.55438e+00, 5.57066e-05, 6.21908e-10, 8.66078e-15, - 8.27812e+00, 6.89310e-05, 7.60263e-10, 1.05052e-14, - 1.07753e+01, 8.75306e-05, 9.52770e-10, 1.30714e-14, - 1.46156e+01, 1.15279e-04, 1.23703e-09, 1.68635e-14, - 2.07765e+01, 1.58349e-04, 1.67242e-09, 2.26556e-14, - 3.09403e+01, 2.26776e-04, 2.35074e-09, 3.15878e-14, - 4.80249e+01, 3.37152e-04, 3.41710e-09, 4.53799e-14, - 7.70965e+01, 5.17359e-04, 5.10858e-09, 6.67630e-14, - 1.26831e+02, 8.14201e-04, 7.81618e-09, 1.00160e-13, - 2.11638e+02, 1.30438e-03, 1.21704e-08, 1.52564e-13, - 3.54644e+02, 2.11006e-03, 1.91598e-08, 2.34688e-13, - 5.91556e+02, 3.41851e-03, 3.02724e-08, 3.62228e-13, - 9.74370e+02, 5.49677e-03, 4.75739e-08, 5.56235e-13, - 1.56930e+03, 8.65788e-03, 7.33192e-08, 8.38100e-13, - 2.44406e+03, 1.31389e-02, 1.08763e-07, 1.21599e-12 }; - - double C13_kpMg2SiO4[] = - { 1.05240e-01, 1.91709e-07, 6.14415e-13, 3.80291e-18, - 1.32588e-01, 2.41526e-07, 7.74078e-13, 4.79114e-18, - 1.67016e-01, 3.04243e-07, 9.75080e-13, 6.03524e-18, - 2.10360e-01, 3.83198e-07, 1.22813e-12, 7.60148e-18, - 2.71887e-01, 4.95279e-07, 1.58734e-12, 9.82485e-18, - 3.55694e-01, 6.47944e-07, 2.07663e-12, 1.28533e-17, - 4.84932e-01, 8.83369e-07, 2.83116e-12, 1.75235e-17, - 6.99767e-01, 1.27472e-06, 4.08543e-12, 2.52870e-17, - 1.05860e+00, 1.92838e-06, 6.18042e-12, 3.82543e-17, - 1.62902e+00, 2.96748e-06, 9.51075e-12, 5.88683e-17, - 2.54260e+00, 4.63171e-06, 1.48447e-11, 9.18851e-17, - 3.96490e+00, 7.22268e-06, 2.31492e-11, 1.43293e-16, - 6.10635e+00, 1.11237e-05, 3.56530e-11, 2.20699e-16, - 9.28776e+00, 1.69193e-05, 5.42303e-11, 3.35716e-16, - 1.39267e+01, 2.53704e-05, 8.13220e-11, 5.03475e-16, - 2.05388e+01, 3.74163e-05, 1.19943e-10, 7.42685e-16, - 3.00662e+01, 5.47749e-05, 1.75612e-10, 1.08767e-15, - 4.55134e+01, 8.29222e-05, 2.65919e-10, 1.64778e-15, - 7.47928e+01, 1.36281e-04, 4.37190e-10, 2.71088e-15, - 1.29641e+02, 2.36241e-04, 7.58090e-10, 4.70339e-15, - 2.14861e+02, 3.91558e-04, 1.25676e-09, 7.80036e-15, - 3.20074e+02, 5.83333e-04, 1.87266e-09, 1.16272e-14, - 4.29885e+02, 7.83522e-04, 2.51590e-09, 1.56273e-14, - 5.31008e+02, 9.67906e-04, 3.10866e-09, 1.93168e-14, - 5.99926e+02, 1.09359e-03, 3.51289e-09, 2.18342e-14, - 6.06790e+02, 1.10614e-03, 3.55349e-09, 2.20891e-14, - 5.43501e+02, 9.90793e-04, 3.18304e-09, 1.97873e-14, - 4.33743e+02, 7.90717e-04, 2.54035e-09, 1.57927e-14, - 3.13466e+02, 5.71463e-04, 1.83604e-09, 1.14151e-14, - 2.09115e+02, 3.81238e-04, 1.22500e-09, 7.61738e-15, - 1.31224e+02, 2.39260e-04, 7.69004e-10, 4.78403e-15, - 7.91470e+01, 1.44373e-04, 4.64502e-10, 2.89404e-15, - 4.74663e+01, 8.67304e-05, 2.80053e-10, 1.75354e-15, - 2.98668e+01, 5.48299e-05, 1.78713e-10, 1.13252e-15, - 2.08636e+01, 3.86952e-05, 1.28439e-10, 8.30592e-16 }; - - double C13_kpMgSiO3[] = - { 2.19890e-02, 1.59707e-08, 1.64886e-14, 3.46350e-20, - 3.90612e-02, 2.83703e-08, 2.92903e-14, 6.15261e-20, - 6.05539e-02, 4.39805e-08, 4.54068e-14, 9.53799e-20, - 8.76116e-02, 6.36326e-08, 6.56961e-14, 1.37999e-19, - 1.43288e-01, 1.04070e-07, 1.07445e-13, 2.25699e-19, - 2.19266e-01, 1.59254e-07, 1.64418e-13, 3.45380e-19, - 3.36256e-01, 2.44223e-07, 2.52144e-13, 5.29662e-19, - 5.14336e-01, 3.73564e-07, 3.85679e-13, 8.10191e-19, - 7.97216e-01, 5.79021e-07, 5.97800e-13, 1.25585e-18, - 1.25414e+00, 9.10886e-07, 9.40430e-13, 1.97579e-18, - 2.03450e+00, 1.47766e-06, 1.52560e-12, 3.20555e-18, - 3.34648e+00, 2.43056e-06, 2.50942e-12, 5.27367e-18, - 5.45894e+00, 3.96485e-06, 4.09354e-12, 8.60504e-18, - 8.82118e+00, 6.40687e-06, 6.61493e-12, 1.39111e-17, - 1.41825e+01, 1.03009e-05, 1.06356e-11, 2.23816e-17, - 2.28420e+01, 1.65903e-05, 1.71302e-11, 3.60870e-17, - 3.71180e+01, 2.69593e-05, 2.78383e-11, 5.87421e-17, - 6.14285e+01, 4.46166e-05, 4.60756e-11, 9.74574e-17, - 1.03848e+02, 7.54274e-05, 7.79023e-11, 1.65248e-16, - 1.75510e+02, 1.27478e-04, 1.31675e-10, 2.80026e-16, - 2.82066e+02, 2.04875e-04, 2.11635e-10, 4.50867e-16, - 4.14529e+02, 3.01090e-04, 3.11041e-10, 6.63478e-16, - 5.59986e+02, 4.06746e-04, 4.20208e-10, 8.97036e-16, - 7.11059e+02, 5.16484e-04, 5.33582e-10, 1.13854e-15, - 8.40851e+02, 6.10764e-04, 6.30953e-10, 1.34372e-15, - 8.95368e+02, 6.50365e-04, 6.71811e-10, 1.42700e-15, - 8.40461e+02, 6.10482e-04, 6.30563e-10, 1.33611e-15, - 6.96732e+02, 5.06082e-04, 5.22696e-10, 1.10542e-15, - 5.18234e+02, 3.76427e-04, 3.88766e-10, 8.21088e-16, - 3.52885e+02, 2.56323e-04, 2.64719e-10, 5.58648e-16, - 2.24228e+02, 1.62872e-04, 1.68207e-10, 3.54873e-16, - 1.35145e+02, 9.81654e-05, 1.01382e-10, 2.13970e-16, - 7.83182e+01, 5.68892e-05, 5.87587e-11, 1.24192e-16, - 4.41610e+01, 3.20799e-05, 3.31421e-11, 7.03026e-17, - 2.46026e+01, 1.78814e-05, 1.84973e-11, 3.95672e-17 }; - - double C13_kpAC[] = - { 3.27960e-01, 1.58173e-06, 1.28346e-11, 1.68940e-16, - 4.38754e-01, 2.11613e-06, 1.71717e-11, 2.26045e-16, - 5.78236e-01, 2.78890e-06, 2.26319e-11, 2.97935e-16, - 7.53833e-01, 3.63586e-06, 2.95057e-11, 3.88440e-16, - 1.04018e+00, 5.01714e-06, 4.07179e-11, 5.36095e-16, - 1.41744e+00, 6.83702e-06, 5.54910e-11, 7.30661e-16, - 1.95305e+00, 9.42082e-06, 7.64677e-11, 1.00698e-15, - 2.71551e+00, 1.30993e-05, 1.06337e-10, 1.40054e-15, - 3.79716e+00, 1.83183e-05, 1.48729e-10, 1.95931e-15, - 5.29823e+00, 2.55621e-05, 2.07584e-10, 2.73540e-15, - 7.37977e+00, 3.56090e-05, 2.89250e-10, 3.81296e-15, - 1.02196e+01, 4.93202e-05, 4.00773e-10, 5.28580e-15, - 1.40471e+01, 6.78071e-05, 5.51275e-10, 7.27585e-15, - 1.92118e+01, 9.27674e-05, 7.54736e-10, 9.97084e-15, - 2.61798e+01, 1.26469e-04, 1.02994e-09, 1.36251e-14, - 3.55647e+01, 1.71912e-04, 1.40197e-09, 1.85822e-14, - 4.82256e+01, 2.33320e-04, 1.90655e-09, 2.53388e-14, - 6.54391e+01, 3.17003e-04, 2.59771e-09, 3.46585e-14, - 8.90003e+01, 4.31918e-04, 3.55359e-09, 4.76706e-14, - 1.21150e+02, 5.89447e-04, 4.87725e-09, 6.59296e-14, - 1.64482e+02, 8.03274e-04, 6.70152e-09, 9.15912e-14, - 2.22238e+02, 1.09138e-03, 9.21653e-09, 1.27994e-13, - 2.99304e+02, 1.48143e-03, 1.27247e-08, 1.80612e-13, - 4.02975e+02, 2.01378e-03, 1.76517e-08, 2.56967e-13, - 5.41945e+02, 2.73383e-03, 2.44284e-08, 3.63965e-13, - 7.24087e+02, 3.67841e-03, 3.33149e-08, 5.04207e-13, - 9.57733e+02, 4.88178e-03, 4.44353e-08, 6.76055e-13, - 1.25789e+03, 6.40887e-03, 5.80974e-08, 8.78814e-13, - 1.65268e+03, 8.39077e-03, 7.51368e-08, 1.11835e-12, - 2.18798e+03, 1.10499e-02, 9.71231e-08, 1.40975e-12, - 2.93400e+03, 1.47364e-02, 1.26617e-07, 1.77953e-12, - 3.99924e+03, 2.00041e-02, 1.67709e-07, 2.27029e-12, - 5.55224e+03, 2.77223e-02, 2.26777e-07, 2.94699e-12, - 7.83754e+03, 3.91330e-02, 3.12657e-07, 3.89444e-12, - 1.11477e+04, 5.56050e-02, 4.34205e-07, 5.18557e-12 }; - - double C13_kpSiO2D[] = - { 7.60358e-02, 1.01529e-07, 4.49989e-13, 4.04236e-18, - 9.07205e-02, 1.21137e-07, 5.36902e-13, 4.82320e-18, - 1.09207e-01, 1.45823e-07, 6.46320e-13, 5.80621e-18, - 1.32481e-01, 1.76900e-07, 7.84068e-13, 7.04376e-18, - 1.58907e-01, 2.12188e-07, 9.40480e-13, 8.44905e-18, - 1.91565e-01, 2.55795e-07, 1.13377e-12, 1.01857e-17, - 2.30490e-01, 3.07773e-07, 1.36416e-12, 1.22557e-17, - 2.76795e-01, 3.69605e-07, 1.63824e-12, 1.47181e-17, - 3.33074e-01, 4.44757e-07, 1.97136e-12, 1.77112e-17, - 4.05326e-01, 5.41239e-07, 2.39905e-12, 2.15541e-17, - 5.08162e-01, 6.78559e-07, 3.00776e-12, 2.70236e-17, - 6.72474e-01, 8.97974e-07, 3.98043e-12, 3.57640e-17, - 9.48554e-01, 1.26665e-06, 5.61486e-12, 5.04526e-17, - 1.41789e+00, 1.89344e-06, 8.39396e-12, 7.54321e-17, - 2.19504e+00, 2.93130e-06, 1.29962e-11, 1.16808e-16, - 3.46727e+00, 4.63056e-06, 2.05341e-11, 1.84616e-16, - 5.76879e+00, 7.70562e-06, 3.41883e-11, 3.07633e-16, - 1.17206e+01, 1.56620e-05, 6.95719e-11, 6.27184e-16, - 3.16503e+01, 4.23092e-05, 1.88132e-10, 1.69866e-15, - 8.68466e+01, 1.16104e-04, 5.16371e-10, 4.66366e-15, - 1.92342e+02, 2.57132e-04, 1.14345e-09, 1.03252e-14, - 3.36302e+02, 4.49562e-04, 1.99868e-09, 1.80397e-14, - 5.05933e+02, 6.76162e-04, 3.00294e-09, 2.70549e-14, - 7.20757e+02, 9.62603e-04, 4.26374e-09, 3.82441e-14, - 9.77487e+02, 1.30417e-03, 5.75586e-09, 5.13190e-14, - 1.18647e+03, 1.58150e-03, 6.95698e-09, 6.16931e-14, - 1.23844e+03, 1.64960e-03, 7.23901e-09, 6.39380e-14, - 1.11176e+03, 1.48010e-03, 6.48454e-09, 5.71201e-14, - 8.76276e+02, 1.16622e-03, 5.10394e-09, 4.48799e-14, - 6.22103e+02, 8.27770e-04, 3.62020e-09, 3.17970e-14, - 4.07211e+02, 5.41759e-04, 2.36830e-09, 2.07862e-14, - 2.50522e+02, 3.33268e-04, 1.45648e-09, 1.27774e-14, - 1.47042e+02, 1.95598e-04, 8.54671e-10, 7.49580e-15, - 8.32958e+01, 1.10803e-04, 4.84133e-10, 4.24560e-15, - 4.59515e+01, 6.11325e-05, 2.67142e-10, 2.34298e-15 }; - - double C13_kpMgO[] = - { 2.25390e-04, 3.58434e-10, 1.62608e-15, 1.09114e-20, - 4.04968e-04, 6.44015e-10, 2.92166e-15, 1.96051e-20, - 6.31043e-04, 1.00354e-09, 4.55270e-15, 3.05498e-20, - 9.15654e-04, 1.45615e-09, 6.60605e-15, 4.43284e-20, - 1.52197e-03, 2.42038e-09, 1.09804e-14, 7.36816e-20, - 2.37407e-03, 3.77546e-09, 1.71280e-14, 1.14934e-19, - 3.77208e-03, 5.99871e-09, 2.72141e-14, 1.82615e-19, - 6.14347e-03, 9.76990e-09, 4.43228e-14, 2.97421e-19, - 1.01907e-02, 1.62062e-08, 7.35223e-14, 4.93362e-19, - 1.68896e-02, 2.68594e-08, 1.21853e-13, 8.17686e-19, - 2.96122e-02, 4.70930e-08, 2.13650e-13, 1.43371e-18, - 6.10599e-02, 9.71067e-08, 4.40563e-13, 2.95653e-18, - 1.43395e-01, 2.28052e-07, 1.03468e-12, 6.94381e-18, - 3.27370e-01, 5.20656e-07, 2.36231e-12, 1.58544e-17, - 6.39417e-01, 1.01697e-06, 4.61437e-12, 3.09706e-17, - 1.05137e+00, 1.67234e-06, 7.58927e-12, 5.09499e-17, - 1.55802e+00, 2.48015e-06, 1.12675e-11, 7.57604e-17, - 2.94085e+00, 4.69147e-06, 2.13703e-11, 1.44197e-16, - 1.32769e+01, 2.11739e-05, 9.63657e-11, 6.49212e-16, - 7.10101e+01, 1.13066e-04, 5.13371e-10, 3.44675e-15, - 2.54818e+02, 4.05363e-04, 1.83807e-09, 1.23170e-14, - 6.00377e+02, 9.54596e-04, 4.32539e-09, 2.89547e-14, - 9.94365e+02, 1.58056e-03, 7.15868e-09, 4.78926e-14, - 1.24259e+03, 1.97471e-03, 8.94139e-09, 5.97968e-14, - 1.24573e+03, 1.97945e-03, 8.96134e-09, 5.99160e-14, - 1.05442e+03, 1.67534e-03, 7.58381e-09, 5.06979e-14, - 7.85160e+02, 1.24742e-03, 5.64619e-09, 3.77407e-14, - 5.31062e+02, 8.43677e-04, 3.81852e-09, 2.55222e-14, - 3.34296e+02, 5.31069e-04, 2.40355e-09, 1.60640e-14, - 1.99427e+02, 3.16805e-04, 1.43378e-09, 9.58224e-15, - 1.14271e+02, 1.81526e-04, 8.21530e-10, 5.49033e-15, - 6.35097e+01, 1.00887e-04, 4.56573e-10, 3.05124e-15, - 3.44902e+01, 5.47882e-05, 2.47947e-10, 1.65699e-15, - 1.84022e+01, 2.92323e-05, 1.32292e-10, 8.84081e-16, - 9.68612e+00, 1.53865e-05, 6.96321e-11, 4.65335e-16 }; - - double C13_kpFeS[] = - { 5.18081e-02, 3.19144e-08, 2.36505e-14, 2.15886e-20, - 9.98885e-02, 6.15325e-08, 4.55993e-14, 4.16239e-20, - 1.60418e-01, 9.88194e-08, 7.32312e-14, 6.68467e-20, - 2.36621e-01, 1.45761e-07, 1.08018e-13, 9.86004e-20, - 3.67284e-01, 2.26251e-07, 1.67666e-13, 1.53048e-19, - 5.36223e-01, 3.30320e-07, 2.44787e-13, 2.23446e-19, - 7.64198e-01, 4.70755e-07, 3.48859e-13, 3.18445e-19, - 1.04970e+00, 6.46627e-07, 4.79190e-13, 4.37414e-19, - 1.38080e+00, 8.50591e-07, 6.30340e-13, 5.75387e-19, - 1.74373e+00, 1.07416e-06, 7.96018e-13, 7.26623e-19, - 2.10311e+00, 1.29554e-06, 9.60079e-13, 8.76383e-19, - 2.42144e+00, 1.49164e-06, 1.10541e-12, 1.00905e-18, - 2.66810e+00, 1.64360e-06, 1.21802e-12, 1.11185e-18, - 2.81617e+00, 1.73481e-06, 1.28563e-12, 1.17358e-18, - 2.89834e+00, 1.78545e-06, 1.32317e-12, 1.20789e-18, - 3.07987e+00, 1.89732e-06, 1.40614e-12, 1.28370e-18, - 3.69380e+00, 2.27562e-06, 1.68664e-12, 1.53995e-18, - 5.05331e+00, 3.11331e-06, 2.30770e-12, 2.10726e-18, - 7.07089e+00, 4.35648e-06, 3.22940e-12, 2.94918e-18, - 9.18826e+00, 5.66121e-06, 4.19684e-12, 3.83303e-18, - 1.08014e+01, 6.65544e-06, 4.93433e-12, 4.50719e-18, - 1.16611e+01, 7.18584e-06, 5.32843e-12, 4.86833e-18, - 1.18910e+01, 7.32863e-06, 5.43584e-12, 4.96854e-18, - 1.17598e+01, 7.24978e-06, 5.38006e-12, 4.92122e-18, - 1.15004e+01, 7.09317e-06, 5.26837e-12, 4.82521e-18, - 1.12405e+01, 6.93914e-06, 5.16238e-12, 4.73954e-18, - 1.10769e+01, 6.85905e-06, 5.13138e-12, 4.75017e-18, - 1.15509e+01, 7.24181e-06, 5.54113e-12, 5.30090e-18, - 1.54818e+01, 9.90289e-06, 7.85008e-12, 7.89232e-18, - 3.23248e+01, 2.09189e-05, 1.69099e-11, 1.74499e-17, - 8.13876e+01, 5.27406e-05, 4.27128e-11, 4.41701e-17, - 1.86528e+02, 1.20594e-04, 9.72543e-11, 9.99819e-17, - 3.66028e+02, 2.35977e-04, 1.89337e-10, 1.93263e-16, - 6.29868e+02, 4.05043e-04, 3.23450e-10, 3.27929e-16, - 9.83739e+02, 6.31245e-04, 5.01948e-10, 5.05703e-16 }; - - - itab0 = Nmom * NTd * iSN; - itab = 0; - for(imom = 0; imom < Nmom; imom++) { - for(iTd = 0; iTd < NTd; iTd++) { - my_rates->SN0_kpSiM [itab0] = C13_kpSiM [itab]; - my_rates->SN0_kpFeM [itab0] = C13_kpFeM [itab]; - my_rates->SN0_kpMg2SiO4 [itab0] = C13_kpMg2SiO4 [itab]; - my_rates->SN0_kpMgSiO3 [itab0] = C13_kpMgSiO3 [itab]; - my_rates->SN0_kpAC [itab0] = C13_kpAC [itab]; - my_rates->SN0_kpSiO2D [itab0] = C13_kpSiO2D [itab]; - my_rates->SN0_kpMgO [itab0] = C13_kpMgO [itab]; - my_rates->SN0_kpFeS [itab0] = C13_kpFeS [itab]; - itab0++; - itab ++; - } - } - - return SUCCESS; -} - -int calc_rates_dust_C20(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates) -{ - - int NTd, Nmom; - int iTd, imom, itab0, itab; - - grackle::impl::GrainMetalInjectPathways* inject_pathway_props - = my_rates->opaque_storage->inject_pathway_props; - - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust] [iSN] = 3.44388e-02; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 3.77223e-03; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 1.90086e-03; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN] = 2.57266e-06; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust] [iSN] = 1.27270e-02; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust] [iSN] = 1.65484e-03; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgO_dust] [iSN] = 9.48713e-04; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeS_dust] [iSN] = 5.23050e-05; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Al2O3_dust] [iSN] = 1.31693e-29; - - itab0 = 3 * iSN; - my_rates->SN0_r0SiM [itab0 + 0] = 1.24861e-05; - my_rates->SN0_r0FeM [itab0 + 0] = 6.67024e-06; - my_rates->SN0_r0Mg2SiO4 [itab0 + 0] = 1.41253e-06; - my_rates->SN0_r0MgSiO3 [itab0 + 0] = 1.01138e-06; - my_rates->SN0_r0AC [itab0 + 0] = 7.95099e-07; - my_rates->SN0_r0SiO2D [itab0 + 0] = 1.40285e-06; - my_rates->SN0_r0MgO [itab0 + 0] = 1.29303e-06; - my_rates->SN0_r0FeS [itab0 + 0] = 1.68897e-06; - my_rates->SN0_r0Al2O3 [itab0 + 0] = 9.21063e-08; - - my_rates->SN0_r0SiM [itab0 + 1] = 2.86508e-10; - my_rates->SN0_r0FeM [itab0 + 1] = 7.50596e-11; - my_rates->SN0_r0Mg2SiO4 [itab0 + 1] = 4.77566e-12; - my_rates->SN0_r0MgSiO3 [itab0 + 1] = 1.31688e-12; - my_rates->SN0_r0AC [itab0 + 1] = 2.51133e-12; - my_rates->SN0_r0SiO2D [itab0 + 1] = 3.98828e-12; - my_rates->SN0_r0MgO [itab0 + 1] = 1.06240e-11; - my_rates->SN0_r0FeS [itab0 + 1] = 3.16618e-12; - my_rates->SN0_r0Al2O3 [itab0 + 1] = 9.03508e-15; - - my_rates->SN0_r0SiM [itab0 + 2] = 1.01028e-14; - my_rates->SN0_r0FeM [itab0 + 2] = 1.22752e-15; - my_rates->SN0_r0Mg2SiO4 [itab0 + 2] = 3.08016e-17; - my_rates->SN0_r0MgSiO3 [itab0 + 2] = 2.89696e-18; - my_rates->SN0_r0AC [itab0 + 2] = 4.21640e-17; - my_rates->SN0_r0SiO2D [itab0 + 2] = 1.93974e-17; - my_rates->SN0_r0MgO [itab0 + 2] = 1.57687e-16; - my_rates->SN0_r0FeS [itab0 + 2] = 6.72598e-18; - my_rates->SN0_r0Al2O3 [itab0 + 2] = 9.36936e-22; - - NTd = 35; - Nmom = 4; - - double C20_kpSiM[] = - { 1.53894e-01, 1.90916e-06, 4.34900e-11, 1.52207e-15, - 1.93844e-01, 2.40648e-06, 5.48634e-11, 1.92178e-15, - 2.44138e-01, 3.03256e-06, 6.91797e-11, 2.42474e-15, - 3.07454e-01, 3.82073e-06, 8.72020e-11, 3.05783e-15, - 3.87243e-01, 4.81526e-06, 1.09978e-10, 3.85936e-15, - 4.87709e-01, 6.06778e-06, 1.38669e-10, 4.86916e-15, - 6.14251e-01, 7.64642e-06, 1.74856e-10, 6.14383e-15, - 7.73625e-01, 9.63590e-06, 2.20495e-10, 7.75268e-15, - 9.74036e-01, 1.21392e-05, 2.77959e-10, 9.78002e-15, - 1.22376e+00, 1.52600e-05, 3.49642e-10, 1.23105e-14, - 1.52029e+00, 1.89682e-05, 4.34881e-10, 1.53223e-14, - 1.83650e+00, 2.29254e-05, 5.25941e-10, 1.85447e-14, - 2.15714e+00, 2.69443e-05, 6.18616e-10, 2.18354e-14, - 2.55729e+00, 3.19712e-05, 7.34846e-10, 2.59753e-14, - 3.23398e+00, 4.04866e-05, 9.32032e-10, 3.30022e-14, - 4.34499e+00, 5.44911e-05, 1.25683e-09, 4.45846e-14, - 5.84259e+00, 7.34292e-05, 1.69748e-09, 6.03345e-14, - 7.53509e+00, 9.49825e-05, 2.20255e-09, 7.84868e-14, - 9.31292e+00, 1.17996e-04, 2.75076e-09, 9.84428e-14, - 1.14053e+01, 1.46050e-04, 3.44207e-09, 1.24265e-13, - 1.44699e+01, 1.88865e-04, 4.53802e-09, 1.66375e-13, - 1.88525e+01, 2.52409e-04, 6.22006e-09, 2.32633e-13, - 2.35897e+01, 3.27106e-04, 8.33967e-09, 3.20293e-13, - 2.71065e+01, 3.99935e-04, 1.08043e-08, 4.33797e-13, - 2.87408e+01, 4.69399e-04, 1.38602e-08, 5.94648e-13, - 2.88428e+01, 5.34587e-04, 1.74785e-08, 8.07129e-13, - 2.80514e+01, 5.86377e-04, 2.09655e-08, 1.03092e-12, - 2.67893e+01, 6.13530e-04, 2.33810e-08, 1.20137e-12, - 2.53851e+01, 6.14601e-04, 2.43011e-08, 1.28034e-12, - 2.53848e+01, 6.23633e-04, 2.48207e-08, 1.31287e-12, - 3.52560e+01, 8.08661e-04, 3.01974e-08, 1.52398e-12, - 9.64731e+01, 1.84326e-03, 5.73265e-08, 2.51143e-12, - 3.56496e+02, 5.70937e-03, 1.44867e-07, 5.33930e-12, - 1.16716e+03, 1.65654e-02, 3.60906e-07, 1.15456e-11, - 3.02792e+03, 3.93985e-02, 7.71226e-07, 2.22345e-11 }; - - double C20_kpFeM[] = - { 1.10506e-02, 1.69983e-07, 3.50089e-12, 9.16404e-17, - 1.85837e-02, 2.76971e-07, 5.53036e-12, 1.40642e-16, - 2.79449e-02, 4.08949e-07, 8.01809e-12, 2.00458e-16, - 3.96605e-02, 5.73574e-07, 1.11125e-11, 2.74730e-16, - 6.19392e-02, 8.69904e-07, 1.63567e-11, 3.93140e-16, - 9.16817e-02, 1.25867e-06, 2.31128e-11, 5.43193e-16, - 1.36080e-01, 1.82251e-06, 3.26005e-11, 7.47226e-16, - 2.02056e-01, 2.63811e-06, 4.59129e-11, 1.02492e-15, - 2.99593e-01, 3.81390e-06, 6.45602e-11, 1.40281e-15, - 4.39758e-01, 5.46636e-06, 9.01024e-11, 1.90718e-15, - 6.41903e-01, 7.79581e-06, 1.25163e-10, 2.58082e-15, - 9.24985e-01, 1.09870e-05, 1.71974e-10, 3.45658e-15, - 1.30585e+00, 1.51941e-05, 2.32250e-10, 4.55695e-15, - 1.80164e+00, 2.05666e-05, 3.07564e-10, 5.90101e-15, - 2.42648e+00, 2.72192e-05, 3.99035e-10, 7.50126e-15, - 3.19207e+00, 3.52384e-05, 5.07449e-10, 9.36601e-15, - 4.10565e+00, 4.46618e-05, 6.32978e-10, 1.14947e-14, - 5.17172e+00, 5.54917e-05, 7.75385e-10, 1.38820e-14, - 6.40478e+00, 6.78244e-05, 9.35760e-10, 1.65481e-14, - 7.85614e+00, 8.21045e-05, 1.11980e-09, 1.95943e-14, - 9.64785e+00, 9.94326e-05, 1.34166e-09, 2.32660e-14, - 1.20159e+01, 1.21941e-04, 1.62875e-09, 2.80374e-14, - 1.53778e+01, 1.53371e-04, 2.02922e-09, 3.47445e-14, - 2.04423e+01, 1.99938e-04, 2.62238e-09, 4.47607e-14, - 2.83887e+01, 2.71546e-04, 3.53030e-09, 6.01372e-14, - 4.11773e+01, 3.83718e-04, 4.93303e-09, 8.37180e-14, - 6.21107e+01, 5.61284e-04, 7.10254e-09, 1.19520e-13, - 9.68132e+01, 8.45164e-04, 1.04719e-08, 1.73689e-13, - 1.54804e+02, 1.30324e-03, 1.57446e-08, 2.55980e-13, - 2.51780e+02, 2.04562e-03, 2.40381e-08, 3.81486e-13, - 4.12838e+02, 3.24595e-03, 3.70714e-08, 5.72650e-13, - 6.76592e+02, 5.16747e-03, 5.73792e-08, 8.61246e-13, - 1.09863e+03, 8.17937e-03, 8.83910e-08, 1.28821e-12, - 1.74646e+03, 1.26954e-02, 1.33666e-07, 1.89228e-12, - 2.67882e+03, 1.89754e-02, 1.94753e-07, 2.68226e-12 }; - - double C20_kpMg2SiO4[] = - { 1.05240e-01, 1.48654e-07, 5.02591e-13, 3.24156e-18, - 1.32588e-01, 1.87284e-07, 6.33194e-13, 4.08391e-18, - 1.67016e-01, 2.35915e-07, 7.97614e-13, 5.14437e-18, - 2.10360e-01, 2.97139e-07, 1.00461e-12, 6.47941e-18, - 2.71887e-01, 3.84048e-07, 1.29844e-12, 8.37459e-18, - 3.55694e-01, 5.02428e-07, 1.69868e-12, 1.09560e-17, - 4.84932e-01, 6.84981e-07, 2.31589e-12, 1.49369e-17, - 6.99767e-01, 9.88442e-07, 3.34188e-12, 2.15544e-17, - 1.05860e+00, 1.49530e-06, 5.05559e-12, 3.26077e-17, - 1.62902e+00, 2.30104e-06, 7.77981e-12, 5.01791e-17, - 2.54260e+00, 3.59152e-06, 1.21430e-11, 7.83229e-17, - 3.96490e+00, 5.60062e-06, 1.89363e-11, 1.22144e-16, - 6.10634e+00, 8.62558e-06, 2.91646e-11, 1.88128e-16, - 9.28774e+00, 1.31196e-05, 4.43615e-11, 2.86175e-16, - 1.39267e+01, 1.96729e-05, 6.65240e-11, 4.29191e-16, - 2.05387e+01, 2.90138e-05, 9.81191e-11, 6.33137e-16, - 3.00660e+01, 4.24748e-05, 1.43665e-10, 9.27312e-16, - 4.55128e+01, 6.43028e-05, 2.17560e-10, 1.40505e-15, - 7.47912e+01, 1.05684e-04, 3.57721e-10, 2.31202e-15, - 1.29637e+02, 1.83206e-04, 6.20346e-10, 4.01209e-15, - 2.14853e+02, 3.03661e-04, 1.02847e-09, 6.65466e-15, - 3.20060e+02, 4.52395e-04, 1.53258e-09, 9.92043e-15, - 4.29862e+02, 6.07661e-04, 2.05913e-09, 1.33350e-14, - 5.30972e+02, 7.50675e-04, 2.54443e-09, 1.64851e-14, - 5.99878e+02, 8.48166e-04, 2.87540e-09, 1.86348e-14, - 6.06737e+02, 8.57905e-04, 2.90867e-09, 1.88528e-14, - 5.43451e+02, 7.68444e-04, 2.60547e-09, 1.68884e-14, - 4.33701e+02, 6.13270e-04, 2.07941e-09, 1.34791e-14, - 3.13436e+02, 4.43222e-04, 1.50292e-09, 9.74306e-15, - 2.09092e+02, 2.95687e-04, 1.00276e-09, 6.50192e-15, - 1.31208e+02, 1.85574e-04, 6.29536e-10, 4.08396e-15, - 7.91293e+01, 1.11988e-04, 3.80343e-10, 2.47142e-15, - 4.74361e+01, 6.72978e-05, 2.29477e-10, 1.49906e-15, - 2.98121e+01, 4.25812e-05, 1.46690e-10, 9.70392e-16, - 2.07674e+01, 3.01013e-05, 1.05718e-10, 7.13724e-16 }; - - double C20_kpMgSiO3[] = - { 2.19890e-02, 2.22393e-08, 2.89570e-14, 6.37012e-20, - 3.90612e-02, 3.95059e-08, 5.14391e-14, 1.13159e-19, - 6.05539e-02, 6.12433e-08, 7.97425e-14, 1.75423e-19, - 8.76116e-02, 8.86090e-08, 1.15374e-13, 2.53808e-19, - 1.43288e-01, 1.44919e-07, 1.88693e-13, 4.15103e-19, - 2.19266e-01, 2.21762e-07, 2.88749e-13, 6.35214e-19, - 3.36256e-01, 3.40084e-07, 4.42810e-13, 9.74136e-19, - 5.14336e-01, 5.20191e-07, 6.77322e-13, 1.49005e-18, - 7.97217e-01, 8.06292e-07, 1.04985e-12, 2.30962e-18, - 1.25414e+00, 1.26842e-06, 1.65157e-12, 3.63350e-18, - 2.03450e+00, 2.05766e-06, 2.67923e-12, 5.89467e-18, - 3.34648e+00, 3.38458e-06, 4.40703e-12, 9.69677e-18, - 5.45894e+00, 5.52111e-06, 7.18906e-12, 1.58199e-17, - 8.82120e+00, 8.92167e-06, 1.16172e-11, 2.55686e-17, - 1.41826e+01, 1.43441e-05, 1.86785e-11, 4.11217e-17, - 2.28421e+01, 2.31025e-05, 3.00847e-11, 6.62628e-17, - 3.71183e+01, 3.75417e-05, 4.88915e-11, 1.07761e-16, - 6.14292e+01, 6.21307e-05, 8.09232e-11, 1.78540e-16, - 1.03850e+02, 1.05037e-04, 1.36825e-10, 3.02237e-16, - 1.75513e+02, 1.77524e-04, 2.31276e-10, 5.11420e-16, - 2.82073e+02, 2.85307e-04, 3.71726e-10, 8.22603e-16, - 4.14541e+02, 4.19298e-04, 5.46336e-10, 1.20964e-15, - 5.60007e+02, 5.66440e-04, 7.38095e-10, 1.63478e-15, - 7.11090e+02, 7.19267e-04, 9.37240e-10, 2.07555e-15, - 8.40892e+02, 8.50566e-04, 1.10826e-09, 2.45241e-15, - 8.95414e+02, 9.05715e-04, 1.18001e-09, 2.60842e-15, - 8.40504e+02, 8.50170e-04, 1.10753e-09, 2.44576e-15, - 6.96768e+02, 7.04778e-04, 9.18057e-10, 2.02574e-15, - 5.18260e+02, 5.24216e-04, 6.82816e-10, 1.50584e-15, - 3.52903e+02, 3.56958e-04, 4.64940e-10, 1.02501e-15, - 2.24241e+02, 2.26818e-04, 2.95430e-10, 6.51237e-16, - 1.35153e+02, 1.36707e-04, 1.78065e-10, 3.92585e-16, - 7.83236e+01, 7.92263e-05, 1.03204e-10, 2.27687e-16, - 4.41657e+01, 4.46783e-05, 5.82153e-11, 1.28647e-16, - 2.46133e+01, 2.49140e-05, 3.25047e-11, 7.21799e-17 }; - - double C20_kpAC[] = - { 3.27960e-01, 2.60760e-07, 8.23594e-13, 1.38274e-17, - 4.38752e-01, 3.48855e-07, 1.10197e-12, 1.85031e-17, - 5.78230e-01, 4.59761e-07, 1.45242e-12, 2.43895e-17, - 7.53824e-01, 5.99382e-07, 1.89361e-12, 3.18000e-17, - 1.04013e+00, 8.27053e-07, 2.61333e-12, 4.38935e-17, - 1.41735e+00, 1.12702e-06, 3.56171e-12, 5.98308e-17, - 1.95293e+00, 1.55292e-06, 4.90855e-12, 8.24705e-17, - 2.71532e+00, 2.15922e-06, 6.82677e-12, 1.14729e-16, - 3.79677e+00, 3.01935e-06, 9.54991e-12, 1.60553e-16, - 5.29747e+00, 4.21303e-06, 1.33318e-11, 2.24238e-16, - 7.37841e+00, 5.86846e-06, 1.85820e-11, 3.12737e-16, - 1.02169e+01, 8.12703e-06, 2.57565e-11, 4.33854e-16, - 1.40423e+01, 1.11717e-05, 3.54480e-11, 5.97791e-16, - 1.92026e+01, 1.52804e-05, 4.85668e-11, 8.20344e-16, - 2.61626e+01, 2.08251e-05, 6.63455e-11, 1.12316e-15, - 3.55324e+01, 2.82955e-05, 9.04435e-11, 1.53595e-15, - 4.81644e+01, 3.83784e-05, 1.23253e-10, 2.10252e-15, - 6.53233e+01, 5.20969e-05, 1.68441e-10, 2.89162e-15, - 8.87789e+01, 7.08925e-05, 2.31406e-10, 4.00785e-15, - 1.20729e+02, 9.65780e-05, 3.19528e-10, 5.60280e-15, - 1.63666e+02, 1.31274e-04, 4.42922e-10, 7.90380e-15, - 2.20664e+02, 1.77696e-04, 6.17150e-10, 1.12922e-14, - 2.96276e+02, 2.39957e-04, 8.67756e-10, 1.64168e-14, - 3.97347e+02, 3.24130e-04, 1.23022e-09, 2.41672e-14, - 5.32072e+02, 4.37186e-04, 1.73755e-09, 3.52998e-14, - 7.07827e+02, 5.84876e-04, 2.40229e-09, 4.99094e-14, - 9.32126e+02, 7.72477e-04, 3.21611e-09, 6.73490e-14, - 1.21808e+03, 1.00957e-03, 4.17439e-09, 8.68091e-14, - 1.58941e+03, 1.31461e-03, 5.30260e-09, 1.07984e-13, - 2.08259e+03, 1.71725e-03, 6.66833e-09, 1.31338e-13, - 2.74876e+03, 2.26047e-03, 8.38813e-09, 1.58137e-13, - 3.65886e+03, 3.00609e-03, 1.06436e-08, 1.90525e-13, - 4.91536e+03, 4.04510e-03, 1.37047e-08, 2.31589e-13, - 6.67260e+03, 5.51150e-03, 1.79301e-08, 2.84849e-13, - 9.16963e+03, 7.59478e-03, 2.36873e-08, 3.52355e-13 }; - - double C20_kpSiO2D[] = - { 7.60358e-02, 1.06666e-07, 3.03247e-13, 1.47482e-18, - 9.07206e-02, 1.27267e-07, 3.61815e-13, 1.75967e-18, - 1.09208e-01, 1.53201e-07, 4.35546e-13, 2.11827e-18, - 1.32481e-01, 1.85851e-07, 5.28369e-13, 2.56972e-18, - 1.58907e-01, 2.22922e-07, 6.33765e-13, 3.08233e-18, - 1.91565e-01, 2.68735e-07, 7.64012e-13, 3.71581e-18, - 2.30490e-01, 3.23342e-07, 9.19258e-13, 4.47087e-18, - 2.76795e-01, 3.88301e-07, 1.10394e-12, 5.36908e-18, - 3.33074e-01, 4.67253e-07, 1.32840e-12, 6.46082e-18, - 4.05326e-01, 5.68613e-07, 1.61658e-12, 7.86245e-18, - 5.08161e-01, 7.12876e-07, 2.02672e-12, 9.85731e-18, - 6.72474e-01, 9.43381e-07, 2.68206e-12, 1.30448e-17, - 9.48552e-01, 1.33068e-06, 3.78319e-12, 1.84008e-17, - 1.41789e+00, 1.98912e-06, 5.65528e-12, 2.75074e-17, - 2.19503e+00, 3.07934e-06, 8.75500e-12, 4.25864e-17, - 3.46724e+00, 4.86415e-06, 1.38300e-11, 6.72794e-17, - 5.76869e+00, 8.09313e-06, 2.30131e-11, 1.11983e-16, - 1.17202e+01, 1.64442e-05, 4.67706e-11, 2.27727e-16, - 3.16486e+01, 4.44090e-05, 1.26336e-10, 6.15454e-16, - 8.68419e+01, 1.21859e-04, 3.46686e-10, 1.68908e-15, - 1.92333e+02, 2.69887e-04, 7.67805e-10, 3.74058e-15, - 3.36287e+02, 4.71894e-04, 1.34247e-09, 6.53939e-15, - 5.05924e+02, 7.09951e-04, 2.01945e-09, 9.83185e-15, - 7.20787e+02, 1.01144e-03, 2.87594e-09, 1.39829e-14, - 9.77602e+02, 1.37169e-03, 3.89813e-09, 1.89179e-14, - 1.18669e+03, 1.66488e-03, 4.72879e-09, 2.29108e-14, - 1.23874e+03, 1.73774e-03, 4.93372e-09, 2.38742e-14, - 1.11204e+03, 1.55988e-03, 4.42750e-09, 2.14067e-14, - 8.76525e+02, 1.22945e-03, 3.48896e-09, 1.68597e-14, - 6.22287e+02, 8.72816e-04, 2.47658e-09, 1.19634e-14, - 4.07334e+02, 5.71310e-04, 1.62094e-09, 7.82836e-15, - 2.50598e+02, 3.51474e-04, 9.97166e-10, 4.81513e-15, - 1.47088e+02, 2.06293e-04, 5.85254e-10, 2.82583e-15, - 8.33219e+01, 1.16862e-04, 3.31541e-10, 1.60077e-15, - 4.59660e+01, 6.44731e-05, 1.82924e-10, 8.83269e-16 }; - - double C20_kpMgO[] = - { 2.25389e-04, 2.91423e-10, 2.39426e-15, 3.55346e-20, - 4.04967e-04, 5.23622e-10, 4.30206e-15, 6.38511e-20, - 6.31042e-04, 8.15942e-10, 6.70384e-15, 9.94996e-20, - 9.15653e-04, 1.18395e-09, 9.72751e-15, 1.44378e-19, - 1.52197e-03, 1.96795e-09, 1.61693e-14, 2.39993e-19, - 2.37407e-03, 3.06977e-09, 2.52225e-14, 3.74371e-19, - 3.77209e-03, 4.87751e-09, 4.00763e-14, 5.94853e-19, - 6.14348e-03, 7.94395e-09, 6.52733e-14, 9.68874e-19, - 1.01907e-02, 1.31776e-08, 1.08281e-13, 1.60732e-18, - 1.68897e-02, 2.18408e-08, 1.79477e-13, 2.66430e-18, - 2.96125e-02, 3.82967e-08, 3.14746e-13, 4.67293e-18, - 6.10610e-02, 7.89818e-08, 6.49304e-13, 9.64262e-18, - 1.43400e-01, 1.85524e-07, 1.52569e-12, 2.26652e-17, - 3.27383e-01, 4.23645e-07, 3.48510e-12, 5.17901e-17, - 6.39452e-01, 8.27698e-07, 6.81196e-12, 1.01271e-16, - 1.05149e+00, 1.36261e-06, 1.12352e-11, 1.67335e-16, - 1.55882e+00, 2.03505e-06, 1.69775e-11, 2.55740e-16, - 2.94474e+00, 3.91135e-06, 3.34978e-11, 5.17225e-16, - 1.32877e+01, 1.75173e-05, 1.48167e-10, 2.26035e-15, - 7.10035e+01, 9.20831e-05, 7.58876e-10, 1.12902e-14, - 2.54672e+02, 3.27285e-04, 2.65806e-09, 3.89823e-14, - 5.99878e+02, 7.67225e-04, 6.18279e-09, 8.99815e-14, - 9.93398e+02, 1.26701e-03, 1.01648e-08, 1.47279e-13, - 1.24125e+03, 1.58042e-03, 1.26439e-08, 1.82695e-13, - 1.24435e+03, 1.58257e-03, 1.26385e-08, 1.82292e-13, - 1.05321e+03, 1.33853e-03, 1.06770e-08, 1.53820e-13, - 7.84243e+02, 9.96171e-04, 7.93973e-09, 1.14294e-13, - 5.30434e+02, 6.73540e-04, 5.36536e-09, 7.71941e-14, - 3.33897e+02, 4.23882e-04, 3.37536e-09, 4.85451e-14, - 1.99187e+02, 2.52825e-04, 2.01271e-09, 2.89397e-14, - 1.14133e+02, 1.44851e-04, 1.15293e-09, 1.65742e-14, - 6.34329e+01, 8.04978e-05, 6.40626e-10, 9.20833e-15, - 3.44484e+01, 4.37133e-05, 3.47851e-10, 4.99954e-15, - 1.83799e+01, 2.33224e-05, 1.85579e-10, 2.66709e-15, - 9.67434e+00, 1.22756e-05, 9.76752e-11, 1.40372e-15 }; - - double C20_kpFeS[] = - { 5.18099e-02, 8.75057e-08, 1.64042e-13, 3.48481e-19, - 9.98914e-02, 1.68714e-07, 3.16278e-13, 6.71882e-19, - 1.60422e-01, 2.70949e-07, 5.07932e-13, 1.07902e-18, - 2.36626e-01, 3.99656e-07, 7.49210e-13, 1.59157e-18, - 3.67294e-01, 6.20351e-07, 1.16293e-12, 2.47046e-18, - 5.36239e-01, 9.05695e-07, 1.69785e-12, 3.60681e-18, - 7.64225e-01, 1.29076e-06, 2.41970e-12, 5.14028e-18, - 1.04974e+00, 1.77298e-06, 3.32371e-12, 7.06072e-18, - 1.38085e+00, 2.33223e-06, 4.37210e-12, 9.28786e-18, - 1.74382e+00, 2.94529e-06, 5.52140e-12, 1.17294e-17, - 2.10325e+00, 3.55236e-06, 6.65945e-12, 1.41471e-17, - 2.42167e+00, 4.09020e-06, 7.66778e-12, 1.62893e-17, - 2.66848e+00, 4.50708e-06, 8.44938e-12, 1.79499e-17, - 2.81672e+00, 4.75754e-06, 8.91905e-12, 1.89480e-17, - 2.89933e+00, 4.89720e-06, 9.18118e-12, 1.95057e-17, - 3.08200e+00, 5.20610e-06, 9.76116e-12, 2.07399e-17, - 3.69875e+00, 6.24871e-06, 1.17179e-11, 2.49020e-17, - 5.06356e+00, 8.55561e-06, 1.60466e-11, 3.41079e-17, - 7.08905e+00, 1.19792e-05, 2.24709e-11, 4.77704e-17, - 9.21663e+00, 1.55761e-05, 2.92218e-11, 6.21311e-17, - 1.08429e+01, 1.83272e-05, 3.43894e-11, 7.31341e-17, - 1.17217e+01, 1.98178e-05, 3.71989e-11, 7.91392e-17, - 1.19809e+01, 2.02656e-05, 3.80618e-11, 8.10292e-17, - 1.18982e+01, 2.01424e-05, 3.78698e-11, 8.07160e-17, - 1.17194e+01, 1.98680e-05, 3.74208e-11, 7.99219e-17, - 1.16101e+01, 1.97358e-05, 3.72971e-11, 7.99631e-17, - 1.19784e+01, 2.05514e-05, 3.92888e-11, 8.53362e-17, - 1.49136e+01, 2.65380e-05, 5.30405e-11, 1.20988e-16, - 2.57980e+01, 4.84122e-05, 1.02966e-10, 2.50769e-16, - 6.12919e+01, 1.18083e-04, 2.58706e-10, 6.49359e-16, - 1.55902e+02, 3.00837e-04, 6.60279e-10, 1.66030e-15, - 3.47036e+02, 6.65409e-04, 1.45009e-09, 3.62025e-15, - 6.57260e+02, 1.25056e-03, 2.70176e-09, 6.68619e-15, - 1.09327e+03, 2.06455e-03, 4.42254e-09, 1.08501e-14, - 1.65394e+03, 3.10062e-03, 6.58692e-09, 1.60229e-14 }; - - double C20_kpAl2O3[] = - { 9.93250e-04, 9.14846e-11, 8.97410e-18, 9.30612e-25, - 1.81240e-03, 1.66933e-10, 1.63752e-17, 1.69810e-24, - 2.84365e-03, 2.61918e-10, 2.56926e-17, 2.66432e-24, - 4.14191e-03, 3.81496e-10, 3.74225e-17, 3.88071e-24, - 7.18271e-03, 6.61573e-10, 6.48964e-17, 6.72974e-24, - 1.13364e-02, 1.04415e-09, 1.02425e-16, 1.06215e-23, - 1.77361e-02, 1.63360e-09, 1.60247e-16, 1.66176e-23, - 2.59477e-02, 2.38995e-09, 2.34440e-16, 2.43114e-23, - 3.45425e-02, 3.18159e-09, 3.12095e-16, 3.23642e-23, - 4.22006e-02, 3.88695e-09, 3.81286e-16, 3.95393e-23, - 4.71420e-02, 4.34208e-09, 4.25932e-16, 4.41691e-23, - 4.91934e-02, 4.53102e-09, 4.44466e-16, 4.60911e-23, - 5.05162e-02, 4.65286e-09, 4.56418e-16, 4.73304e-23, - 5.78201e-02, 5.32560e-09, 5.22410e-16, 5.41738e-23, - 8.84237e-02, 8.14438e-09, 7.98916e-16, 8.28474e-23, - 1.78786e-01, 1.64673e-08, 1.61535e-15, 1.67511e-22, - 4.36404e-01, 4.01956e-08, 3.94295e-15, 4.08884e-22, - 1.63796e+00, 1.50867e-07, 1.47992e-14, 1.53467e-21, - 8.50819e+00, 7.83659e-07, 7.68723e-14, 7.97165e-21, - 3.92751e+01, 3.61749e-06, 3.54854e-13, 3.67984e-20, - 1.41439e+02, 1.30275e-05, 1.27792e-12, 1.32520e-19, - 3.83709e+02, 3.53420e-05, 3.46684e-12, 3.59511e-19, - 7.70411e+02, 7.09598e-05, 6.96073e-12, 7.21827e-19, - 1.16399e+03, 1.07211e-04, 1.05167e-11, 1.09058e-18, - 1.37566e+03, 1.26707e-04, 1.24292e-11, 1.28891e-18, - 1.33070e+03, 1.22566e-04, 1.20230e-11, 1.24678e-18, - 1.09978e+03, 1.01297e-04, 9.93663e-12, 1.03043e-18, - 8.05638e+02, 7.42044e-05, 7.27901e-12, 7.54832e-19, - 5.38690e+02, 4.96167e-05, 4.86711e-12, 5.04718e-19, - 3.36338e+02, 3.09789e-05, 3.03884e-12, 3.15127e-19, - 1.99460e+02, 1.83715e-05, 1.80214e-12, 1.86881e-19, - 1.13787e+02, 1.04805e-05, 1.02808e-12, 1.06611e-19, - 6.30411e+01, 5.80648e-06, 5.69582e-13, 5.90655e-20, - 3.41529e+01, 3.14570e-06, 3.08575e-13, 3.19991e-20, - 1.81893e+01, 1.67535e-06, 1.64342e-13, 1.70422e-20 }; - - - itab0 = Nmom * NTd * iSN; - itab = 0; - for(imom = 0; imom < Nmom; imom++) { - for(iTd = 0; iTd < NTd; iTd++) { - my_rates->SN0_kpSiM [itab0] = C20_kpSiM [itab]; - my_rates->SN0_kpFeM [itab0] = C20_kpFeM [itab]; - my_rates->SN0_kpMg2SiO4 [itab0] = C20_kpMg2SiO4 [itab]; - my_rates->SN0_kpMgSiO3 [itab0] = C20_kpMgSiO3 [itab]; - my_rates->SN0_kpAC [itab0] = C20_kpAC [itab]; - my_rates->SN0_kpSiO2D [itab0] = C20_kpSiO2D [itab]; - my_rates->SN0_kpMgO [itab0] = C20_kpMgO [itab]; - my_rates->SN0_kpFeS [itab0] = C20_kpFeS [itab]; - my_rates->SN0_kpAl2O3 [itab0] = C20_kpAl2O3 [itab]; - itab0++; - itab ++; - } - } - - return SUCCESS; -} - -int calc_rates_dust_C25(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates) -{ - - int NTd, Nmom; - int iTd, imom, itab0, itab; - - grackle::impl::GrainMetalInjectPathways* inject_pathway_props - = my_rates->opaque_storage->inject_pathway_props; - - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust] [iSN] = 3.83373e-02; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 4.88366e-03; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 1.68068e-02; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN] = 2.49736e-05; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust] [iSN] = 4.13961e-02; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust] [iSN] = 1.46546e-02; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgO_dust] [iSN] = 1.09289e-03; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeS_dust] [iSN] = 3.77935e-04; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Al2O3_dust] [iSN] = 1.65550e-31; - - itab0 = 3 * iSN; - my_rates->SN0_r0SiM [itab0 + 0] = 1.72153e-05; - my_rates->SN0_r0FeM [itab0 + 0] = 1.96666e-05; - my_rates->SN0_r0Mg2SiO4 [itab0 + 0] = 2.33213e-06; - my_rates->SN0_r0MgSiO3 [itab0 + 0] = 1.55439e-06; - my_rates->SN0_r0AC [itab0 + 0] = 7.93494e-07; - my_rates->SN0_r0SiO2D [itab0 + 0] = 2.56804e-06; - my_rates->SN0_r0MgO [itab0 + 0] = 3.58420e-06; - my_rates->SN0_r0FeS [itab0 + 0] = 9.61035e-07; - my_rates->SN0_r0Al2O3 [itab0 + 0] = 1.99526e-08; - - my_rates->SN0_r0SiM [itab0 + 1] = 6.33208e-10; - my_rates->SN0_r0FeM [itab0 + 1] = 5.88305e-10; - my_rates->SN0_r0Mg2SiO4 [itab0 + 1] = 2.48648e-11; - my_rates->SN0_r0MgSiO3 [itab0 + 1] = 4.30058e-12; - my_rates->SN0_r0AC [itab0 + 1] = 3.53402e-12; - my_rates->SN0_r0SiO2D [itab0 + 1] = 4.82971e-11; - my_rates->SN0_r0MgO [itab0 + 1] = 3.09713e-11; - my_rates->SN0_r0FeS [itab0 + 1] = 2.46507e-12; - my_rates->SN0_r0Al2O3 [itab0 + 1] = 3.98107e-16; - - my_rates->SN0_r0SiM [itab0 + 2] = 4.04318e-14; - my_rates->SN0_r0FeM [itab0 + 2] = 2.42323e-14; - my_rates->SN0_r0Mg2SiO4 [itab0 + 2] = 4.29427e-16; - my_rates->SN0_r0MgSiO3 [itab0 + 2] = 1.92568e-17; - my_rates->SN0_r0AC [itab0 + 2] = 1.04050e-16; - my_rates->SN0_r0SiO2D [itab0 + 2] = 2.53766e-15; - my_rates->SN0_r0MgO [itab0 + 2] = 4.03929e-16; - my_rates->SN0_r0FeS [itab0 + 2] = 1.42549e-17; - my_rates->SN0_r0Al2O3 [itab0 + 2] = 7.94328e-24; - - NTd = 35; - Nmom = 4; - - double C25_kpSiM[] = - { 1.53307e-01, 2.58151e-06, 8.97185e-11, 5.13410e-15, - 1.93187e-01, 3.26103e-06, 1.14053e-10, 6.60852e-15, - 2.43381e-01, 4.11484e-06, 1.44443e-10, 8.42753e-15, - 3.06566e-01, 5.18903e-06, 1.82603e-10, 1.07022e-14, - 3.86268e-01, 6.55217e-06, 2.31853e-10, 1.37374e-14, - 4.86630e-01, 8.26891e-06, 2.93869e-10, 1.75576e-14, - 6.13093e-01, 1.04376e-05, 3.72751e-10, 2.24815e-14, - 7.72441e-01, 1.31779e-05, 4.73205e-10, 2.88483e-14, - 9.72908e-01, 1.66348e-05, 6.00927e-10, 3.70670e-14, - 1.22279e+00, 2.09532e-05, 7.61455e-10, 4.75186e-14, - 1.51967e+00, 2.61010e-05, 9.54694e-10, 6.03376e-14, - 1.83660e+00, 3.16418e-05, 1.16836e-09, 7.52509e-14, - 2.15883e+00, 3.73832e-05, 1.40366e-09, 9.34936e-14, - 2.56188e+00, 4.46730e-05, 1.71564e-09, 1.19386e-13, - 3.24331e+00, 5.69556e-05, 2.23297e-09, 1.61351e-13, - 4.36192e+00, 7.70449e-05, 3.06366e-09, 2.26659e-13, - 5.87089e+00, 1.04185e-04, 4.17746e-09, 3.12654e-13, - 7.58000e+00, 1.35161e-04, 5.44737e-09, 4.09330e-13, - 9.38530e+00, 1.68565e-04, 6.82760e-09, 5.12932e-13, - 1.15371e+01, 2.10285e-04, 8.59830e-09, 6.44799e-13, - 1.47388e+01, 2.75860e-04, 1.14755e-08, 8.58985e-13, - 1.93877e+01, 3.75887e-04, 1.59953e-08, 1.19600e-12, - 2.46008e+01, 5.00971e-04, 2.20360e-08, 1.65571e-12, - 2.90408e+01, 6.45456e-04, 3.01610e-08, 2.31085e-12, - 3.23701e+01, 8.27330e-04, 4.23216e-08, 3.35508e-12, - 3.49305e+01, 1.05238e-03, 5.92405e-08, 4.87268e-12, - 3.68020e+01, 1.28200e-03, 7.79075e-08, 6.59988e-12, - 3.76194e+01, 1.45174e-03, 9.27975e-08, 8.01634e-12, - 3.72617e+01, 1.52446e-03, 1.00177e-07, 8.74632e-12, - 3.76576e+01, 1.55784e-03, 1.02687e-07, 8.96074e-12, - 4.91245e+01, 1.84545e-03, 1.14505e-07, 9.64022e-12, - 1.17100e+02, 3.32870e-03, 1.70057e-07, 1.27411e-11, - 3.93519e+02, 8.31574e-03, 3.27938e-07, 2.07522e-11, - 1.23314e+03, 2.12665e-02, 6.72506e-07, 3.61691e-11, - 3.12736e+03, 4.71942e-02, 1.26825e-06, 5.97225e-11 }; - - double C25_kpFeM[] = - { 7.05387e-02, 2.70513e-06, 1.33741e-10, 7.96280e-15, - 1.06564e-01, 3.93018e-06, 1.88633e-10, 1.09924e-14, - 1.50619e-01, 5.42584e-06, 2.55756e-10, 1.47090e-14, - 2.05371e-01, 7.28371e-06, 3.39206e-10, 1.93364e-14, - 2.90528e-01, 9.90213e-06, 4.47050e-10, 2.49139e-14, - 3.98319e-01, 1.31460e-05, 5.78557e-10, 3.16454e-14, - 5.44029e-01, 1.73143e-05, 7.40062e-10, 3.96165e-14, - 7.41852e-01, 2.27123e-05, 9.40496e-10, 4.91736e-14, - 1.01111e+00, 2.97427e-05, 1.19128e-09, 6.07485e-14, - 1.37135e+00, 3.87934e-05, 1.50307e-09, 7.47433e-14, - 1.85427e+00, 5.04362e-05, 1.88890e-09, 9.15116e-14, - 2.48538e+00, 6.50566e-05, 2.35529e-09, 1.11141e-13, - 3.28338e+00, 8.28882e-05, 2.90473e-09, 1.33599e-13, - 4.26495e+00, 1.04109e-04, 3.53805e-09, 1.58791e-13, - 5.44209e+00, 1.28847e-04, 4.25649e-09, 1.86722e-13, - 6.82357e+00, 1.57201e-04, 5.06195e-09, 2.17471e-13, - 8.41130e+00, 1.89169e-04, 5.95453e-09, 2.51081e-13, - 1.02033e+01, 2.24714e-04, 6.93482e-09, 2.87663e-13, - 1.22164e+01, 2.64256e-04, 8.01879e-09, 3.27999e-13, - 1.45282e+01, 3.09507e-04, 9.26157e-09, 3.74467e-13, - 1.73262e+01, 3.64447e-04, 1.07851e-08, 4.32120e-13, - 2.09720e+01, 4.36715e-04, 1.28220e-08, 5.10543e-13, - 2.61035e+01, 5.39852e-04, 1.57872e-08, 6.26923e-13, - 3.37725e+01, 6.96147e-04, 2.03646e-08, 8.09666e-13, - 4.55764e+01, 9.38083e-04, 2.75201e-08, 1.09797e-12, - 6.37992e+01, 1.30793e-03, 3.84014e-08, 1.53493e-12, - 9.17796e+01, 1.86084e-03, 5.43135e-08, 2.16276e-12, - 1.34749e+02, 2.67751e-03, 7.69998e-08, 3.03160e-12, - 2.01156e+02, 3.88432e-03, 1.09109e-07, 4.21570e-12, - 3.04328e+02, 5.67395e-03, 1.54550e-07, 5.82179e-12, - 4.64551e+02, 8.32593e-03, 2.18657e-07, 7.98599e-12, - 7.11390e+02, 1.22244e-02, 3.08194e-07, 1.08633e-11, - 1.08442e+03, 1.78487e-02, 4.30797e-07, 1.46043e-11, - 1.62442e+03, 2.56300e-02, 5.92006e-07, 1.92777e-11, - 2.34943e+03, 3.56242e-02, 7.89629e-07, 2.47479e-11 }; - - double C25_kpMg2SiO4[] = - { 1.05240e-01, 2.45433e-07, 2.61677e-12, 4.51929e-17, - 1.32588e-01, 3.09211e-07, 3.29676e-12, 5.69367e-17, - 1.67016e-01, 3.89504e-07, 4.15283e-12, 7.17213e-17, - 2.10360e-01, 4.90585e-07, 5.23055e-12, 9.03341e-17, - 2.71887e-01, 6.34079e-07, 6.76050e-12, 1.16758e-16, - 3.55694e-01, 8.29533e-07, 8.84446e-12, 1.52750e-16, - 4.84933e-01, 1.13094e-06, 1.20582e-11, 2.08253e-16, - 6.99770e-01, 1.63200e-06, 1.74006e-11, 3.00524e-16, - 1.05860e+00, 2.46891e-06, 2.63246e-11, 4.54655e-16, - 1.62903e+00, 3.79938e-06, 4.05116e-11, 6.99697e-16, - 2.54264e+00, 5.93041e-06, 6.32372e-11, 1.09224e-15, - 3.96499e+00, 9.24857e-06, 9.86269e-11, 1.70359e-15, - 6.10655e+00, 1.42452e-05, 1.51927e-10, 2.62446e-15, - 9.28824e+00, 2.16706e-05, 2.31158e-10, 3.99359e-15, - 1.39278e+01, 3.25027e-05, 3.46790e-10, 5.99240e-15, - 2.05413e+01, 4.79530e-05, 5.11839e-10, 8.84697e-15, - 3.00722e+01, 7.02477e-05, 7.50339e-10, 1.29761e-14, - 4.55290e+01, 1.06478e-04, 1.13881e-09, 1.97131e-14, - 7.48333e+01, 1.75301e-04, 1.87829e-09, 3.25565e-14, - 1.29734e+02, 3.04341e-04, 3.26603e-09, 5.66753e-14, - 2.15039e+02, 5.04949e-04, 5.42460e-09, 9.42056e-14, - 3.20373e+02, 7.52945e-04, 8.09632e-09, 1.40698e-13, - 4.30336e+02, 1.01240e-03, 1.08979e-08, 1.89530e-13, - 5.31620e+02, 1.25190e-03, 1.34895e-08, 2.34771e-13, - 6.00659e+02, 1.41538e-03, 1.52608e-08, 2.65718e-13, - 6.07548e+02, 1.43203e-03, 1.54444e-08, 2.68965e-13, - 5.44184e+02, 1.28282e-03, 1.38365e-08, 2.40975e-13, - 4.34292e+02, 1.02387e-03, 1.10444e-08, 1.92359e-13, - 3.13872e+02, 7.40120e-04, 7.98523e-09, 1.39097e-13, - 2.09392e+02, 4.93970e-04, 5.33184e-09, 9.29066e-14, - 1.31415e+02, 3.10355e-04, 3.35361e-09, 5.84810e-14, - 7.92901e+01, 1.87957e-04, 2.03808e-09, 3.56245e-14, - 4.76038e+01, 1.14252e-04, 1.25235e-09, 2.20472e-14, - 3.00283e+01, 7.42825e-05, 8.34278e-10, 1.49154e-14, - 2.10539e+01, 5.48540e-05, 6.37875e-10, 1.16338e-14 }; - - double C25_kpMgSiO3[] = - { 2.19890e-02, 3.41795e-08, 9.45655e-14, 4.23439e-19, - 3.90612e-02, 6.07164e-08, 1.67986e-13, 7.52197e-19, - 6.05539e-02, 9.41245e-08, 2.60417e-13, 1.16608e-18, - 8.76116e-02, 1.36183e-07, 3.76781e-13, 1.68713e-18, - 1.43288e-01, 2.22725e-07, 6.16221e-13, 2.75928e-18, - 2.19266e-01, 3.40825e-07, 9.42974e-13, 4.22240e-18, - 3.36256e-01, 5.22673e-07, 1.44610e-12, 6.47526e-18, - 5.14336e-01, 7.99479e-07, 2.21195e-12, 9.90458e-18, - 7.97217e-01, 1.23919e-06, 3.42851e-12, 1.53521e-17, - 1.25414e+00, 1.94943e-06, 5.39358e-12, 2.41515e-17, - 2.03450e+00, 3.16241e-06, 8.74964e-12, 3.91798e-17, - 3.34649e+00, 5.20178e-06, 1.43922e-11, 6.44481e-17, - 5.45897e+00, 8.48547e-06, 2.34778e-11, 1.05137e-16, - 8.82126e+00, 1.37119e-05, 3.79391e-11, 1.69905e-16, - 1.41827e+01, 2.20461e-05, 6.10001e-11, 2.73202e-16, - 2.28425e+01, 3.55077e-05, 9.82519e-11, 4.40095e-16, - 3.71193e+01, 5.77019e-05, 1.59676e-10, 7.15351e-16, - 6.14319e+01, 9.54994e-05, 2.64297e-10, 1.18434e-15, - 1.03856e+02, 1.61458e-04, 4.46893e-10, 2.00314e-15, - 1.75529e+02, 2.72897e-04, 7.55426e-10, 3.38696e-15, - 2.82103e+02, 4.38604e-04, 1.21423e-09, 5.44494e-15, - 4.14591e+02, 6.44612e-04, 1.78465e-09, 8.00387e-15, - 5.60087e+02, 8.70868e-04, 2.41120e-09, 1.08148e-14, - 7.11212e+02, 1.10590e-03, 3.06203e-09, 1.37338e-14, - 8.41053e+02, 1.30782e-03, 3.62100e-09, 1.62382e-14, - 8.95593e+02, 1.39263e-03, 3.85557e-09, 1.72860e-14, - 8.40674e+02, 1.30722e-03, 3.61884e-09, 1.62210e-14, - 6.96909e+02, 1.08365e-03, 2.99976e-09, 1.34436e-14, - 5.18364e+02, 8.06018e-04, 2.23111e-09, 9.99751e-15, - 3.52974e+02, 5.48846e-04, 1.51920e-09, 6.80696e-15, - 2.24287e+02, 3.48752e-04, 9.65345e-10, 4.32526e-15, - 1.35182e+02, 2.10204e-04, 5.81862e-10, 2.60719e-15, - 7.83444e+01, 1.21833e-04, 3.37284e-10, 1.51159e-15, - 4.41840e+01, 6.87277e-05, 1.90332e-10, 8.53442e-16, - 2.46537e+01, 3.84248e-05, 1.06643e-10, 4.79266e-16 }; - - double C25_kpAC[] = - { 3.27960e-01, 2.60233e-07, 1.15896e-12, 3.41207e-17, - 4.38752e-01, 3.48153e-07, 1.55085e-12, 4.56711e-17, - 5.78230e-01, 4.58837e-07, 2.04421e-12, 6.02121e-17, - 7.53824e-01, 5.98180e-07, 2.66530e-12, 7.85179e-17, - 1.04013e+00, 8.25404e-07, 3.67884e-12, 1.08416e-16, - 1.41735e+00, 1.12479e-06, 5.01451e-12, 1.47828e-16, - 1.95293e+00, 1.54986e-06, 6.91189e-12, 2.03855e-16, - 2.71532e+00, 2.15499e-06, 9.61533e-12, 2.83773e-16, - 3.79678e+00, 3.01350e-06, 1.34554e-11, 3.97470e-16, - 5.29747e+00, 4.20498e-06, 1.87919e-11, 5.55745e-16, - 7.37842e+00, 5.85746e-06, 2.62073e-11, 7.76231e-16, - 1.02169e+01, 8.11222e-06, 3.63532e-11, 1.07888e-15, - 1.40424e+01, 1.11520e-05, 5.00793e-11, 1.48986e-15, - 1.92027e+01, 1.52549e-05, 6.86959e-11, 2.04983e-15, - 2.61627e+01, 2.07929e-05, 9.39920e-11, 2.81528e-15, - 3.55327e+01, 2.82565e-05, 1.28407e-10, 3.86530e-15, - 4.81650e+01, 3.83349e-05, 1.75518e-10, 5.31971e-15, - 6.53244e+01, 5.20561e-05, 2.40904e-10, 7.37173e-15, - 8.87808e+01, 7.08733e-05, 3.33003e-10, 1.03268e-14, - 1.20733e+02, 9.66248e-05, 4.63924e-10, 1.46567e-14, - 1.63674e+02, 1.31491e-04, 6.51645e-10, 2.11366e-14, - 2.20677e+02, 1.78321e-04, 9.26445e-10, 3.11929e-14, - 2.96305e+02, 2.41503e-04, 1.34108e-09, 4.74137e-14, - 3.97405e+02, 3.27522e-04, 1.97072e-09, 7.35006e-14, - 5.32189e+02, 4.43695e-04, 2.88200e-09, 1.12542e-13, - 7.08046e+02, 5.95675e-04, 4.08283e-09, 1.64175e-13, - 9.32526e+02, 7.88039e-04, 5.50980e-09, 2.23600e-13, - 1.21879e+03, 1.02941e-03, 7.08050e-09, 2.84124e-13, - 1.59074e+03, 1.33766e-03, 8.76094e-09, 3.40697e-13, - 2.08510e+03, 1.74270e-03, 1.05986e-08, 3.91613e-13, - 2.75362e+03, 2.28917e-03, 1.27282e-08, 4.38283e-13, - 3.66839e+03, 3.04259e-03, 1.53805e-08, 4.84412e-13, - 4.93379e+03, 4.10065e-03, 1.89004e-08, 5.35144e-13, - 6.70658e+03, 5.60645e-03, 2.37440e-08, 5.95776e-13, - 9.22668e+03, 7.75494e-03, 3.03854e-08, 6.69355e-13 }; - - double C25_kpSiO2D[] = - { 7.60344e-02, 1.95196e-07, 3.66716e-12, 1.92423e-16, - 9.07191e-02, 2.32906e-07, 4.37632e-12, 2.29682e-16, - 1.09206e-01, 2.80380e-07, 5.26909e-12, 2.76586e-16, - 1.32480e-01, 3.40146e-07, 6.39301e-12, 3.35635e-16, - 1.58906e-01, 4.08019e-07, 7.66999e-12, 4.02759e-16, - 1.91564e-01, 4.91897e-07, 9.24810e-12, 4.85715e-16, - 2.30489e-01, 5.91872e-07, 1.11292e-11, 5.84611e-16, - 2.76795e-01, 7.10808e-07, 1.33674e-11, 7.02310e-16, - 3.33075e-01, 8.55378e-07, 1.60886e-11, 8.45443e-16, - 4.05328e-01, 1.04100e-06, 1.95833e-11, 1.02932e-15, - 5.08167e-01, 1.30521e-06, 2.45600e-11, 1.29133e-15, - 6.72485e-01, 1.72749e-06, 3.25210e-11, 1.71095e-15, - 9.48580e-01, 2.43730e-06, 4.59219e-11, 2.41877e-15, - 1.41796e+00, 3.64482e-06, 6.87751e-11, 3.63027e-15, - 2.19521e+00, 5.64613e-06, 1.06783e-10, 5.65494e-15, - 3.46773e+00, 8.92808e-06, 1.69393e-10, 9.00627e-15, - 5.77034e+00, 1.48887e-05, 2.83967e-10, 1.51653e-14, - 1.17273e+01, 3.03917e-05, 5.84644e-10, 3.13500e-14, - 3.16762e+01, 8.23694e-05, 1.59258e-09, 8.53491e-14, - 8.69213e+01, 2.26080e-04, 4.36458e-09, 2.32841e-13, - 1.92500e+02, 5.00291e-04, 9.62913e-09, 5.11437e-13, - 3.36556e+02, 8.73556e-04, 1.67531e-08, 8.86507e-13, - 5.06180e+02, 1.30807e-03, 2.48422e-08, 1.30609e-12, - 7.20631e+02, 1.84289e-03, 3.42245e-08, 1.77586e-12, - 9.76452e+02, 2.46285e-03, 4.43878e-08, 2.26306e-12, - 1.18428e+03, 2.95079e-03, 5.17620e-08, 2.59653e-12, - 1.23545e+03, 3.05120e-03, 5.24657e-08, 2.59989e-12, - 1.10864e+03, 2.72192e-03, 4.61791e-08, 2.26949e-12, - 8.73605e+02, 2.13674e-03, 3.59368e-08, 1.75670e-12, - 6.20107e+02, 1.51303e-03, 2.53058e-08, 1.23288e-12, - 4.05864e+02, 9.88756e-04, 1.64791e-08, 8.01183e-13, - 2.49677e+02, 6.07668e-04, 1.01055e-08, 4.90701e-13, - 1.46540e+02, 3.56444e-04, 5.92003e-09, 2.87265e-13, - 8.30108e+01, 2.01877e-04, 3.35130e-09, 1.62587e-13, - 4.57957e+01, 1.11407e-04, 1.85045e-09, 8.98118e-14 }; - - double C25_kpMgO[] = - { 2.25388e-04, 8.07807e-10, 6.97998e-15, 9.10286e-20, - 4.04965e-04, 1.45145e-09, 1.25417e-14, 1.63564e-19, - 6.31040e-04, 2.26174e-09, 1.95435e-14, 2.54881e-19, - 9.15651e-04, 3.28184e-09, 2.83582e-14, 3.69842e-19, - 1.52197e-03, 5.45504e-09, 4.71373e-14, 6.14765e-19, - 2.37408e-03, 8.50921e-09, 7.35292e-14, 9.58978e-19, - 3.77210e-03, 1.35201e-08, 1.16831e-13, 1.52374e-18, - 6.14351e-03, 2.20201e-08, 1.90284e-13, 2.48178e-18, - 1.01908e-02, 3.65275e-08, 3.15657e-13, 4.11707e-18, - 1.68899e-02, 6.05411e-08, 5.23195e-13, 6.82425e-18, - 2.96134e-02, 1.06156e-07, 9.17483e-13, 1.19682e-17, - 6.10648e-02, 2.18932e-07, 1.89256e-12, 2.46925e-17, - 1.43413e-01, 5.14257e-07, 4.44656e-12, 5.80289e-17, - 3.27427e-01, 1.17431e-06, 1.01561e-11, 1.32572e-16, - 6.39567e-01, 2.29431e-06, 1.98486e-11, 2.59169e-16, - 1.05188e+00, 3.77698e-06, 3.27186e-11, 4.27780e-16, - 1.56137e+00, 5.64036e-06, 4.92651e-11, 6.49403e-16, - 2.95878e+00, 1.08379e-05, 9.64135e-11, 1.29373e-15, - 1.33369e+01, 4.85546e-05, 4.28194e-10, 5.69626e-15, - 7.10715e+01, 2.55311e-04, 2.21076e-09, 2.88829e-14, - 2.54519e+02, 9.07495e-04, 7.77715e-09, 1.00557e-13, - 5.99024e+02, 2.12736e-03, 1.81309e-08, 2.33128e-13, - 9.91502e+02, 3.51313e-03, 2.98462e-08, 3.82528e-13, - 1.23853e+03, 4.38206e-03, 3.71546e-08, 4.75243e-13, - 1.24134e+03, 4.38799e-03, 3.71575e-08, 4.74666e-13, - 1.05053e+03, 3.71132e-03, 3.14012e-08, 4.00789e-13, - 7.82169e+02, 2.76204e-03, 2.33559e-08, 2.97932e-13, - 5.28995e+02, 1.86748e-03, 1.57854e-08, 2.01282e-13, - 3.32978e+02, 1.17527e-03, 9.93166e-09, 1.26606e-13, - 1.98632e+02, 7.00988e-04, 5.92262e-09, 7.54858e-14, - 1.13813e+02, 4.01617e-04, 3.39280e-09, 4.32365e-14, - 6.32536e+01, 2.23189e-04, 1.88528e-09, 2.40230e-14, - 3.43507e+01, 1.21200e-04, 1.02371e-09, 1.30436e-14, - 1.83277e+01, 6.46641e-05, 5.46160e-10, 6.95860e-15, - 9.64683e+00, 3.40355e-05, 2.87461e-10, 3.66245e-15 }; - - double C25_kpFeS[] = - { 5.18089e-02, 4.97944e-08, 1.27767e-13, 7.39409e-19, - 9.98898e-02, 9.60047e-08, 2.46329e-13, 1.42543e-18, - 1.60420e-01, 1.54180e-07, 3.95589e-13, 2.28909e-18, - 2.36623e-01, 2.27418e-07, 5.83496e-13, 3.37637e-18, - 3.67289e-01, 3.53003e-07, 9.05730e-13, 5.24118e-18, - 5.36230e-01, 5.15376e-07, 1.32237e-12, 7.65247e-18, - 7.64209e-01, 7.34494e-07, 1.88465e-12, 1.09071e-17, - 1.04972e+00, 1.00891e-06, 2.58893e-12, 1.49849e-17, - 1.38083e+00, 1.32717e-06, 3.40583e-12, 1.97167e-17, - 1.74377e+00, 1.67607e-06, 4.30174e-12, 2.49099e-17, - 2.10317e+00, 2.02159e-06, 5.18938e-12, 3.00615e-17, - 2.42155e+00, 2.32777e-06, 5.97696e-12, 3.46445e-17, - 2.66826e+00, 2.56519e-06, 6.58920e-12, 3.82277e-17, - 2.81642e+00, 2.70807e-06, 6.96112e-12, 4.04503e-17, - 2.89877e+00, 2.78835e-06, 7.17920e-12, 4.18739e-17, - 3.08081e+00, 2.96627e-06, 7.66777e-12, 4.51307e-17, - 3.69596e+00, 3.56434e-06, 9.27486e-12, 5.54010e-17, - 5.05776e+00, 4.88601e-06, 1.28025e-11, 7.76522e-17, - 7.07898e+00, 6.85096e-06, 1.80991e-11, 1.11855e-16, - 9.20178e+00, 8.93168e-06, 2.39573e-11, 1.53397e-16, - 1.08226e+01, 1.05533e-05, 2.89938e-11, 1.96013e-16, - 1.16924e+01, 1.14675e-05, 3.24020e-11, 2.32497e-16, - 1.19355e+01, 1.17825e-05, 3.42098e-11, 2.58640e-16, - 1.18230e+01, 1.17613e-05, 3.49907e-11, 2.75275e-16, - 1.15929e+01, 1.16487e-05, 3.54453e-11, 2.86649e-16, - 1.13868e+01, 1.16310e-05, 3.63433e-11, 2.99851e-16, - 1.14199e+01, 1.23167e-05, 4.12834e-11, 3.50696e-16, - 1.29371e+01, 1.75436e-05, 7.43145e-11, 6.75730e-16, - 2.05440e+01, 3.98903e-05, 2.16132e-10, 2.04334e-15, - 4.78755e+01, 1.10160e-04, 6.39249e-10, 5.90057e-15, - 1.21252e+02, 2.78758e-04, 1.57840e-09, 1.39121e-14, - 2.69644e+02, 5.88705e-04, 3.18490e-09, 2.68674e-14, - 5.11453e+02, 1.05406e-03, 5.44914e-09, 4.43131e-14, - 8.53209e+02, 1.66585e-03, 8.25940e-09, 6.51454e-14, - 1.29539e+03, 2.40455e-03, 1.14623e-08, 8.80401e-14 }; - - double C25_kpAl2O3[] = - { 9.93250e-04, 1.98179e-11, 3.95420e-19, 7.88967e-27, - 1.81240e-03, 3.61621e-11, 7.21529e-19, 1.43964e-26, - 2.84365e-03, 5.67382e-11, 1.13208e-18, 2.25879e-26, - 4.14191e-03, 8.26420e-11, 1.64892e-18, 3.29004e-26, - 7.18271e-03, 1.43314e-10, 2.85949e-18, 5.70543e-26, - 1.13364e-02, 2.26190e-10, 4.51309e-18, 9.00479e-26, - 1.77361e-02, 3.53881e-10, 7.06085e-18, 1.40883e-25, - 2.59477e-02, 5.17725e-10, 1.03300e-17, 2.06110e-25, - 3.45425e-02, 6.89214e-10, 1.37516e-17, 2.74381e-25, - 4.22006e-02, 8.42014e-10, 1.68004e-17, 3.35212e-25, - 4.71420e-02, 9.40607e-10, 1.87676e-17, 3.74462e-25, - 4.91934e-02, 9.81537e-10, 1.95842e-17, 3.90757e-25, - 5.05162e-02, 1.00793e-09, 2.01109e-17, 4.01264e-25, - 5.78201e-02, 1.15366e-09, 2.30186e-17, 4.59282e-25, - 8.84237e-02, 1.76428e-09, 3.52021e-17, 7.02374e-25, - 1.78786e-01, 3.56725e-09, 7.11761e-17, 1.42015e-24, - 4.36404e-01, 8.70740e-09, 1.73736e-16, 3.46648e-24, - 1.63796e+00, 3.26816e-08, 6.52083e-16, 1.30108e-23, - 8.50817e+00, 1.69760e-07, 3.38716e-15, 6.75828e-23, - 3.92751e+01, 7.83641e-07, 1.56357e-14, 3.11973e-22, - 1.41433e+02, 2.82196e-06, 5.63055e-14, 1.12344e-21, - 3.83709e+02, 7.65599e-06, 1.52757e-13, 3.04791e-21, - 7.70411e+02, 1.53717e-05, 3.06706e-13, 6.11959e-21, - 1.16399e+03, 2.32246e-05, 4.63392e-13, 9.24589e-21, - 1.37566e+03, 2.74481e-05, 5.47662e-13, 1.09273e-20, - 1.33070e+03, 2.65509e-05, 5.29761e-13, 1.05701e-20, - 1.09978e+03, 2.19435e-05, 4.37830e-13, 8.73585e-21, - 8.05638e+02, 1.60746e-05, 3.20730e-13, 6.39941e-21, - 5.38690e+02, 1.07483e-05, 2.14456e-13, 4.27897e-21, - 3.36338e+02, 6.71083e-06, 1.33899e-13, 2.67163e-21, - 1.99460e+02, 3.97975e-06, 7.94065e-14, 1.58437e-21, - 1.13787e+02, 2.27035e-06, 4.52995e-14, 9.03844e-22, - 6.30411e+01, 1.25784e-06, 2.50971e-14, 5.00753e-22, - 3.41529e+01, 6.81441e-07, 1.35965e-14, 2.71286e-22, - 1.81893e+01, 3.62924e-07, 7.24128e-15, 1.44483e-22 }; - - - itab0 = Nmom * NTd * iSN; - itab = 0; - for(imom = 0; imom < Nmom; imom++) { - for(iTd = 0; iTd < NTd; iTd++) { - my_rates->SN0_kpSiM [itab0] = C25_kpSiM [itab]; - my_rates->SN0_kpFeM [itab0] = C25_kpFeM [itab]; - my_rates->SN0_kpMg2SiO4 [itab0] = C25_kpMg2SiO4 [itab]; - my_rates->SN0_kpMgSiO3 [itab0] = C25_kpMgSiO3 [itab]; - my_rates->SN0_kpAC [itab0] = C25_kpAC [itab]; - my_rates->SN0_kpSiO2D [itab0] = C25_kpSiO2D [itab]; - my_rates->SN0_kpMgO [itab0] = C25_kpMgO [itab]; - my_rates->SN0_kpFeS [itab0] = C25_kpFeS [itab]; - my_rates->SN0_kpAl2O3 [itab0] = C25_kpAl2O3 [itab]; - itab0++; - itab ++; - } - } - - return SUCCESS; -} - -int calc_rates_dust_C30(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates) -{ - - int NTd, Nmom; - int iTd, imom, itab0, itab; - - grackle::impl::GrainMetalInjectPathways* inject_pathway_props - = my_rates->opaque_storage->inject_pathway_props; - - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust] [iSN] = 2.91389e-02; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 1.93065e-03; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 7.73041e-04; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN] = 4.17376e-06; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust] [iSN] = 6.19235e-04; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust] [iSN] = 5.27016e-03; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgO_dust] [iSN] = 1.33978e-03; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeS_dust] [iSN] = 4.51744e-04; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Al2O3_dust] [iSN] = 5.79251e-12; - - itab0 = 3 * iSN; - my_rates->SN0_r0SiM [itab0 + 0] = 2.56305e-05; - my_rates->SN0_r0FeM [itab0 + 0] = 2.05800e-05; - my_rates->SN0_r0Mg2SiO4 [itab0 + 0] = 4.70227e-07; - my_rates->SN0_r0MgSiO3 [itab0 + 0] = 1.02156e-06; - my_rates->SN0_r0AC [itab0 + 0] = 1.17005e-06; - my_rates->SN0_r0SiO2D [itab0 + 0] = 1.62875e-06; - my_rates->SN0_r0MgO [itab0 + 0] = 2.32229e-06; - my_rates->SN0_r0FeS [itab0 + 0] = 1.69769e-06; - my_rates->SN0_r0Al2O3 [itab0 + 0] = 7.63588e-08; - - my_rates->SN0_r0SiM [itab0 + 1] = 1.02092e-09; - my_rates->SN0_r0FeM [itab0 + 1] = 5.92424e-10; - my_rates->SN0_r0Mg2SiO4 [itab0 + 1] = 6.29420e-13; - my_rates->SN0_r0MgSiO3 [itab0 + 1] = 1.31765e-12; - my_rates->SN0_r0AC [itab0 + 1] = 2.37154e-12; - my_rates->SN0_r0SiO2D [itab0 + 1] = 1.12314e-11; - my_rates->SN0_r0MgO [itab0 + 1] = 1.39783e-11; - my_rates->SN0_r0FeS [itab0 + 1] = 6.40794e-12; - my_rates->SN0_r0Al2O3 [itab0 + 1] = 8.88224e-15; - - my_rates->SN0_r0SiM [itab0 + 2] = 5.78476e-14; - my_rates->SN0_r0FeM [itab0 + 2] = 2.26690e-14; - my_rates->SN0_r0Mg2SiO4 [itab0 + 2] = 1.71079e-18; - my_rates->SN0_r0MgSiO3 [itab0 + 2] = 2.63083e-18; - my_rates->SN0_r0AC [itab0 + 2] = 7.59875e-18; - my_rates->SN0_r0SiO2D [itab0 + 2] = 1.91031e-16; - my_rates->SN0_r0MgO [itab0 + 2] = 1.49800e-16; - my_rates->SN0_r0FeS [itab0 + 2] = 4.40126e-17; - my_rates->SN0_r0Al2O3 [itab0 + 2] = 1.42247e-21; - - NTd = 35; - Nmom = 4; - - double C30_kpSiM[] = - { 1.52613e-01, 3.87036e-06, 1.51475e-10, 8.34686e-15, - 1.92410e-01, 4.88554e-06, 1.91604e-10, 1.05937e-14, - 2.42503e-01, 6.16264e-06, 2.42001e-10, 1.34057e-14, - 3.05564e-01, 7.77004e-06, 3.05397e-10, 1.69392e-14, - 3.85174e-01, 9.80462e-06, 3.86046e-10, 2.14732e-14, - 4.85438e-01, 1.23675e-05, 4.87634e-10, 2.71828e-14, - 6.11833e-01, 1.56019e-05, 6.16102e-10, 3.44270e-14, - 7.71157e-01, 1.96838e-05, 7.78585e-10, 4.36231e-14, - 9.71669e-01, 2.48269e-05, 9.83743e-10, 5.52763e-14, - 1.22169e+00, 3.12457e-05, 1.24021e-09, 6.98829e-14, - 1.51883e+00, 3.88844e-05, 1.54619e-09, 8.73862e-14, - 1.83610e+00, 4.70620e-05, 1.87584e-09, 1.06471e-13, - 2.15867e+00, 5.54249e-05, 2.21779e-09, 1.26800e-13, - 2.56252e+00, 6.59468e-05, 2.65228e-09, 1.53070e-13, - 3.24657e+00, 8.37697e-05, 3.38561e-09, 1.97020e-13, - 4.37158e+00, 1.13090e-04, 4.58835e-09, 2.68525e-13, - 5.89356e+00, 1.52861e-04, 6.22099e-09, 3.65325e-13, - 7.62770e+00, 1.98484e-04, 8.10272e-09, 4.76950e-13, - 9.48448e+00, 2.48132e-04, 1.01763e-08, 6.00571e-13, - 1.17614e+01, 3.11117e-04, 1.28785e-08, 7.63878e-13, - 1.52604e+01, 4.11692e-04, 1.73236e-08, 1.03683e-12, - 2.04857e+01, 5.67120e-04, 2.43755e-08, 1.47603e-12, - 2.67121e+01, 7.65926e-04, 3.38756e-08, 2.08532e-12, - 3.30214e+01, 1.00600e-03, 4.67023e-08, 2.95970e-12, - 3.94796e+01, 1.32148e-03, 6.59032e-08, 4.35947e-12, - 4.60630e+01, 1.71870e-03, 9.26057e-08, 6.41018e-12, - 5.17888e+01, 2.12529e-03, 1.22060e-07, 8.76593e-12, - 5.52863e+01, 2.42692e-03, 1.45553e-07, 1.07154e-11, - 5.60930e+01, 2.55895e-03, 1.57221e-07, 1.17347e-11, - 5.70683e+01, 2.61927e-03, 1.61476e-07, 1.20713e-11, - 7.25749e+01, 3.09971e-03, 1.82166e-07, 1.32162e-11, - 1.59194e+02, 5.49929e-03, 2.77545e-07, 1.82852e-11, - 4.83739e+02, 1.31658e-02, 5.43977e-07, 3.13196e-11, - 1.39550e+03, 3.19882e-02, 1.11499e-06, 5.65773e-11, - 3.29912e+03, 6.76125e-02, 2.08154e-06, 9.54501e-11 }; - - double C30_kpFeM[] = - { 7.21495e-02, 2.58300e-06, 1.19134e-10, 6.77090e-15, - 1.09797e-01, 3.79107e-06, 1.69411e-10, 9.39020e-15, - 1.55805e-01, 5.26522e-06, 2.30859e-10, 1.26025e-14, - 2.12966e-01, 7.09577e-06, 3.07229e-10, 1.66015e-14, - 3.02975e-01, 9.74053e-06, 4.08459e-10, 2.15040e-14, - 4.17015e-01, 1.30295e-05, 5.32431e-10, 2.74392e-14, - 5.71703e-01, 1.73021e-05, 6.86687e-10, 3.45374e-14, - 7.82114e-01, 2.28860e-05, 8.80449e-10, 4.31318e-14, - 1.06869e+00, 3.02137e-05, 1.12556e-09, 5.36402e-14, - 1.45194e+00, 3.97008e-05, 1.43310e-09, 6.64513e-14, - 1.96519e+00, 5.19736e-05, 1.81745e-09, 8.19495e-14, - 2.63479e+00, 6.74573e-05, 2.28640e-09, 1.00267e-13, - 3.47952e+00, 8.64064e-05, 2.84327e-09, 1.21406e-13, - 4.51582e+00, 1.09014e-04, 3.48958e-09, 1.45307e-13, - 5.75506e+00, 1.35409e-04, 4.22673e-09, 1.71980e-13, - 7.20522e+00, 1.65686e-04, 5.05643e-09, 2.01492e-13, - 8.86719e+00, 1.99826e-04, 5.97834e-09, 2.33868e-13, - 1.07378e+01, 2.37775e-04, 6.99239e-09, 2.69183e-13, - 1.28337e+01, 2.79956e-04, 8.11382e-09, 3.08137e-13, - 1.52347e+01, 3.28163e-04, 9.39756e-09, 3.52929e-13, - 1.81342e+01, 3.86588e-04, 1.09665e-08, 4.08289e-13, - 2.19061e+01, 4.63288e-04, 1.30553e-08, 4.83202e-13, - 2.72090e+01, 5.72531e-04, 1.60822e-08, 5.93756e-13, - 3.51270e+01, 7.37785e-04, 2.07358e-08, 7.66520e-13, - 4.72945e+01, 9.93265e-04, 2.79935e-08, 1.03837e-12, - 6.60183e+01, 1.38363e-03, 3.90367e-08, 1.45073e-12, - 9.46224e+01, 1.96740e-03, 5.52478e-08, 2.04604e-12, - 1.38263e+02, 2.83025e-03, 7.85071e-08, 2.87658e-12, - 2.05210e+02, 4.10585e-03, 1.11674e-07, 4.02015e-12, - 3.08399e+02, 5.99700e-03, 1.58965e-07, 5.58896e-12, - 4.67338e+02, 8.79616e-03, 2.26155e-07, 7.72827e-12, - 7.10129e+02, 1.29022e-02, 3.20597e-07, 1.06077e-11, - 1.07381e+03, 1.88070e-02, 4.50609e-07, 1.43975e-11, - 1.59524e+03, 2.69407e-02, 6.22216e-07, 1.91854e-11, - 2.28747e+03, 3.73289e-02, 8.32996e-07, 2.48404e-11 }; - - double C30_kpMg2SiO4[] = - { 1.05240e-01, 4.94867e-08, 6.62401e-14, 1.80043e-19, - 1.32588e-01, 6.23464e-08, 8.34533e-14, 2.26830e-19, - 1.67016e-01, 7.85357e-08, 1.05123e-13, 2.85730e-19, - 2.10360e-01, 9.89168e-08, 1.32405e-13, 3.59881e-19, - 2.71887e-01, 1.27849e-07, 1.71131e-13, 4.65142e-19, - 3.55694e-01, 1.67257e-07, 2.23881e-13, 6.08518e-19, - 4.84932e-01, 2.28028e-07, 3.05226e-13, 8.29619e-19, - 6.99767e-01, 3.29050e-07, 4.40448e-13, 1.19716e-18, - 1.05860e+00, 4.97781e-07, 6.66304e-13, 1.81105e-18, - 1.62902e+00, 7.66009e-07, 1.02534e-12, 2.78694e-18, - 2.54260e+00, 1.19560e-06, 1.60037e-12, 4.34992e-18, - 3.96488e+00, 1.86440e-06, 2.49561e-12, 6.78334e-18, - 6.10630e+00, 2.87136e-06, 3.84349e-12, 1.04472e-17, - 9.28767e+00, 4.36734e-06, 5.84598e-12, 1.58906e-17, - 1.39265e+01, 6.54868e-06, 8.76595e-12, 2.38284e-17, - 2.05383e+01, 9.65780e-06, 1.29279e-11, 3.51435e-17, - 3.00651e+01, 1.41377e-05, 1.89253e-11, 5.14515e-17, - 4.55105e+01, 2.14011e-05, 2.86497e-11, 7.79011e-17, - 7.47848e+01, 3.51681e-05, 4.70833e-11, 1.28054e-16, - 1.29623e+02, 6.09573e-05, 8.16150e-11, 2.22014e-16, - 2.14824e+02, 1.01026e-04, 1.35269e-10, 3.68020e-16, - 3.20010e+02, 1.50495e-04, 2.01516e-10, 5.48326e-16, - 4.29781e+02, 2.02124e-04, 2.70665e-10, 7.36593e-16, - 5.30850e+02, 2.49665e-04, 3.34350e-10, 9.10050e-16, - 5.99723e+02, 2.82064e-04, 3.77759e-10, 1.02832e-15, - 6.06569e+02, 2.85288e-04, 3.82090e-10, 1.04017e-15, - 5.43292e+02, 2.55531e-04, 3.42243e-10, 9.31723e-16, - 4.33571e+02, 2.03926e-04, 2.73131e-10, 7.43589e-16, - 3.13340e+02, 1.47377e-04, 1.97394e-10, 5.37419e-16, - 2.09022e+02, 9.83146e-05, 1.31685e-10, 3.58547e-16, - 1.31159e+02, 6.16930e-05, 8.26409e-11, 2.25056e-16, - 7.90789e+01, 3.72049e-05, 4.98596e-11, 1.35886e-16, - 4.73566e+01, 2.23007e-05, 2.99370e-11, 8.18168e-17, - 2.96727e+01, 1.40105e-05, 1.88993e-11, 5.20353e-17, - 2.05268e+01, 9.75253e-06, 1.32995e-11, 3.71721e-17 }; - - double C30_kpMgSiO3[] = - { 2.19890e-02, 2.24631e-08, 2.89738e-14, 5.78493e-20, - 3.90612e-02, 3.99034e-08, 5.14691e-14, 1.02764e-19, - 6.05539e-02, 6.18594e-08, 7.97889e-14, 1.59308e-19, - 8.76116e-02, 8.95004e-08, 1.15442e-13, 2.30492e-19, - 1.43288e-01, 1.46377e-07, 1.88803e-13, 3.76970e-19, - 2.19266e-01, 2.23993e-07, 2.88916e-13, 5.76861e-19, - 3.36256e-01, 3.43505e-07, 4.43068e-13, 8.84648e-19, - 5.14336e-01, 5.25424e-07, 6.77716e-13, 1.35317e-18, - 7.97217e-01, 8.14404e-07, 1.05046e-12, 2.09745e-18, - 1.25414e+00, 1.28118e-06, 1.65253e-12, 3.29971e-18, - 2.03450e+00, 2.07836e-06, 2.68078e-12, 5.35315e-18, - 3.34648e+00, 3.41863e-06, 4.40956e-12, 8.80595e-18, - 5.45894e+00, 5.57665e-06, 7.19317e-12, 1.43665e-17, - 8.82120e+00, 9.01141e-06, 1.16237e-11, 2.32195e-17, - 1.41826e+01, 1.44884e-05, 1.86888e-11, 3.73434e-17, - 2.28421e+01, 2.33348e-05, 3.01009e-11, 6.01739e-17, - 3.71183e+01, 3.79191e-05, 4.89167e-11, 9.78570e-17, - 6.14292e+01, 6.27552e-05, 8.09620e-11, 1.62128e-16, - 1.03850e+02, 1.06093e-04, 1.36885e-10, 2.74448e-16, - 1.75514e+02, 1.79307e-04, 2.31368e-10, 4.64387e-16, - 2.82073e+02, 2.88172e-04, 3.71865e-10, 7.46941e-16, - 4.14542e+02, 4.23507e-04, 5.46530e-10, 1.09837e-15, - 5.60007e+02, 5.72126e-04, 7.38347e-10, 1.48437e-15, - 7.11091e+02, 7.26489e-04, 9.37565e-10, 1.88456e-15, - 8.40894e+02, 8.59108e-04, 1.10867e-09, 2.22674e-15, - 8.95416e+02, 9.14814e-04, 1.18049e-09, 2.36840e-15, - 8.40506e+02, 8.58713e-04, 1.10802e-09, 2.22074e-15, - 6.96770e+02, 7.11863e-04, 9.18488e-10, 1.83938e-15, - 5.18262e+02, 5.29487e-04, 6.83149e-10, 1.36732e-15, - 3.52905e+02, 3.60548e-04, 4.65172e-10, 9.30726e-16, - 2.24242e+02, 2.29099e-04, 2.95579e-10, 5.91332e-16, - 1.35153e+02, 1.38081e-04, 1.78153e-10, 3.56469e-16, - 7.83239e+01, 8.00228e-05, 1.03253e-10, 2.06735e-16, - 4.41660e+01, 4.51272e-05, 5.82391e-11, 1.16797e-16, - 2.46140e+01, 2.51643e-05, 3.25109e-11, 6.54871e-17 }; - - double C30_kpAC[] = - { 3.27960e-01, 3.83729e-07, 7.77768e-13, 2.49208e-18, - 4.38752e-01, 5.13360e-07, 1.04052e-12, 3.33400e-18, - 5.78230e-01, 6.76557e-07, 1.37130e-12, 4.39392e-18, - 7.53823e-01, 8.82009e-07, 1.78773e-12, 5.72828e-18, - 1.04013e+00, 1.21701e-06, 2.46677e-12, 7.90427e-18, - 1.41736e+00, 1.65839e-06, 3.36142e-12, 1.07712e-17, - 1.95293e+00, 2.28504e-06, 4.63158e-12, 1.48415e-17, - 2.71531e+00, 3.17707e-06, 6.43967e-12, 2.06359e-17, - 3.79677e+00, 4.44245e-06, 9.00459e-12, 2.88564e-17, - 5.29746e+00, 6.19839e-06, 1.25639e-11, 4.02650e-17, - 7.37839e+00, 8.63325e-06, 1.74996e-11, 5.60866e-17, - 1.02169e+01, 1.19546e-05, 2.42326e-11, 7.76741e-17, - 1.40423e+01, 1.64308e-05, 3.33069e-11, 1.06774e-16, - 1.92025e+01, 2.24692e-05, 4.55495e-11, 1.46048e-16, - 2.61625e+01, 3.06137e-05, 6.20638e-11, 1.99051e-16, - 3.55322e+01, 4.15788e-05, 8.43006e-11, 2.70467e-16, - 4.81640e+01, 5.63626e-05, 1.14288e-10, 3.66871e-16, - 6.53224e+01, 7.64461e-05, 1.55039e-10, 4.98051e-16, - 8.87770e+01, 1.03904e-04, 2.10775e-10, 6.77818e-16, - 1.20724e+02, 1.41310e-04, 2.86753e-10, 9.23530e-16, - 1.63658e+02, 1.91596e-04, 3.88991e-10, 1.25555e-15, - 2.20645e+02, 2.58372e-04, 5.24942e-10, 1.69987e-15, - 2.96236e+02, 3.47007e-04, 7.05751e-10, 2.29590e-15, - 3.97277e+02, 4.65581e-04, 9.48153e-10, 3.10191e-15, - 5.32000e+02, 6.23846e-04, 1.27229e-09, 4.18567e-15, - 7.07873e+02, 8.30738e-04, 1.69662e-09, 5.60591e-15, - 9.32623e+02, 1.09569e-03, 2.24083e-09, 7.42175e-15, - 1.21977e+03, 1.43532e-03, 2.93992e-09, 9.74128e-15, - 1.59377e+03, 1.87988e-03, 3.85840e-09, 1.27719e-14, - 2.09261e+03, 2.47712e-03, 5.09977e-09, 1.68549e-14, - 2.77023e+03, 3.29669e-03, 6.81899e-09, 2.25141e-14, - 3.70299e+03, 4.44048e-03, 9.24971e-09, 3.05579e-14, - 5.00261e+03, 6.06097e-03, 1.27486e-08, 4.22365e-14, - 6.83605e+03, 8.38300e-03, 1.78358e-08, 5.93501e-14, - 9.45120e+03, 1.17154e-02, 2.51744e-08, 8.40301e-14 }; - - double C30_kpSiO2D[] = - { 7.60354e-02, 1.23833e-07, 8.53754e-13, 1.45191e-17, - 9.07201e-02, 1.47751e-07, 1.01868e-12, 1.73242e-17, - 1.09207e-01, 1.77861e-07, 1.22631e-12, 2.08557e-17, - 1.32481e-01, 2.15768e-07, 1.48770e-12, 2.53015e-17, - 1.58907e-01, 2.58811e-07, 1.78454e-12, 3.03507e-17, - 1.91564e-01, 3.12003e-07, 2.15137e-12, 3.65904e-17, - 2.30490e-01, 3.75405e-07, 2.58860e-12, 4.40274e-17, - 2.76795e-01, 4.50827e-07, 3.10875e-12, 5.28751e-17, - 3.33074e-01, 5.42499e-07, 3.74099e-12, 6.36301e-17, - 4.05326e-01, 6.60191e-07, 4.55275e-12, 7.74389e-17, - 5.08163e-01, 8.27703e-07, 5.70817e-12, 9.70950e-17, - 6.72477e-01, 1.09537e-06, 7.55468e-12, 1.28511e-16, - 9.48561e-01, 1.54515e-06, 1.06581e-11, 1.81319e-16, - 1.41791e+00, 2.30989e-06, 1.59363e-11, 2.71154e-16, - 2.19508e+00, 3.57636e-06, 2.46813e-11, 4.20045e-16, - 3.46738e+00, 5.65063e-06, 3.90198e-11, 6.64369e-16, - 5.76921e+00, 9.40776e-06, 6.50678e-11, 1.10919e-15, - 1.17225e+01, 1.91430e-05, 1.32874e-10, 2.27105e-15, - 3.16576e+01, 5.17610e-05, 3.60367e-10, 6.17301e-15, - 8.68678e+01, 1.42065e-04, 9.89621e-10, 1.69586e-14, - 1.92388e+02, 3.14591e-04, 2.19062e-09, 3.75294e-14, - 3.36374e+02, 5.49866e-04, 3.82570e-09, 6.54980e-14, - 5.05999e+02, 8.26100e-04, 5.72796e-09, 9.78085e-14, - 7.20701e+02, 1.17289e-03, 8.06418e-09, 1.36816e-13, - 9.77142e+02, 1.58336e-03, 1.07627e-08, 1.81003e-13, - 1.18576e+03, 1.91391e-03, 1.28756e-08, 2.14810e-13, - 1.23749e+03, 1.99168e-03, 1.32966e-08, 2.20518e-13, - 1.11076e+03, 1.78423e-03, 1.18503e-08, 1.95740e-13, - 8.75424e+02, 1.40444e-03, 9.29642e-09, 1.53150e-13, - 6.21466e+02, 9.96201e-04, 6.57984e-09, 1.08212e-13, - 4.06780e+02, 6.51722e-04, 4.29860e-09, 7.06171e-14, - 2.50252e+02, 4.00808e-04, 2.64130e-09, 4.33611e-14, - 1.46882e+02, 2.35201e-04, 1.54913e-09, 2.54207e-14, - 8.32048e+01, 1.33228e-04, 8.77332e-10, 1.43944e-14, - 4.59015e+01, 7.35091e-05, 4.84195e-10, 7.94538e-15 }; - - double C30_kpMgO[] = - { 2.25389e-04, 5.23412e-10, 3.15038e-15, 3.37599e-20, - 4.04967e-04, 9.40443e-10, 5.66055e-15, 6.06603e-20, - 6.31042e-04, 1.46545e-09, 8.82067e-15, 9.45260e-20, - 9.15653e-04, 2.12641e-09, 1.27990e-14, 1.37160e-19, - 1.52197e-03, 3.53447e-09, 2.12745e-14, 2.27991e-19, - 2.37407e-03, 5.51331e-09, 3.31857e-14, 3.55642e-19, - 3.77209e-03, 8.75995e-09, 5.27284e-14, 5.65083e-19, - 6.14348e-03, 1.42671e-08, 8.58786e-14, 9.20363e-19, - 1.01907e-02, 2.36663e-08, 1.42459e-13, 1.52677e-18, - 1.68897e-02, 3.92242e-08, 2.36116e-13, 2.53063e-18, - 2.96125e-02, 6.87744e-08, 4.14030e-13, 4.43787e-18, - 6.10613e-02, 1.41824e-07, 8.53932e-13, 9.15481e-18, - 1.43400e-01, 3.33097e-07, 2.00598e-12, 2.15106e-17, - 3.27386e-01, 7.60540e-07, 4.58100e-12, 4.91345e-17, - 6.39460e-01, 1.48568e-06, 8.95096e-12, 9.60338e-17, - 1.05151e+00, 2.44421e-06, 1.47414e-11, 1.58361e-16, - 1.55897e+00, 3.63523e-06, 2.20702e-11, 2.39002e-16, - 2.94595e+00, 6.92078e-06, 4.26541e-11, 4.70201e-16, - 1.32939e+01, 3.11374e-05, 1.90589e-10, 2.08296e-15, - 7.10280e+01, 1.65213e-04, 9.96517e-10, 1.06988e-14, - 2.54734e+02, 5.90224e-04, 3.53091e-09, 3.75292e-14, - 5.99997e+02, 1.38734e-03, 8.26333e-09, 8.73603e-14, - 9.93558e+02, 2.29460e-03, 1.36329e-08, 1.43684e-13, - 1.24146e+03, 2.86493e-03, 1.69946e-08, 1.78772e-13, - 1.24450e+03, 2.87058e-03, 1.70110e-08, 1.78725e-13, - 1.05332e+03, 2.42888e-03, 1.43842e-08, 1.51004e-13, - 7.84315e+02, 1.80814e-03, 1.07031e-08, 1.12298e-13, - 5.30478e+02, 1.22276e-03, 7.23576e-09, 7.58903e-14, - 3.33924e+02, 7.69623e-04, 4.55334e-09, 4.77443e-14, - 1.99202e+02, 4.59084e-04, 2.71568e-09, 2.84703e-14, - 1.14141e+02, 2.63040e-04, 1.55583e-09, 1.63087e-14, - 6.34373e+01, 1.46185e-04, 8.64588e-10, 9.06207e-15, - 3.44508e+01, 7.93863e-05, 4.69493e-10, 4.92062e-15, - 1.83812e+01, 4.23560e-05, 2.50488e-10, 2.62517e-15, - 9.67501e+00, 2.22941e-05, 1.31841e-10, 1.38170e-15 }; - - double C30_kpFeS[] = - { 5.18102e-02, 8.79700e-08, 3.32172e-13, 2.28308e-18, - 9.98920e-02, 1.69607e-07, 6.40403e-13, 4.40131e-18, - 1.60423e-01, 2.72381e-07, 1.02844e-12, 7.06800e-18, - 2.36628e-01, 4.01766e-07, 1.51696e-12, 1.04252e-17, - 3.67296e-01, 6.23631e-07, 2.35471e-12, 1.61832e-17, - 5.36243e-01, 9.10491e-07, 3.43791e-12, 2.36285e-17, - 7.64229e-01, 1.29761e-06, 4.89979e-12, 3.36782e-17, - 1.04975e+00, 1.78244e-06, 6.73094e-12, 4.62695e-17, - 1.38087e+00, 2.34473e-06, 8.85504e-12, 6.08809e-17, - 1.74385e+00, 2.96123e-06, 1.11849e-11, 7.69178e-17, - 2.10328e+00, 3.57180e-06, 1.34937e-11, 9.28279e-17, - 2.42172e+00, 4.11304e-06, 1.55431e-11, 1.06984e-16, - 2.66854e+00, 4.53297e-06, 1.71379e-11, 1.18057e-16, - 2.81685e+00, 4.78622e-06, 1.81100e-11, 1.24934e-16, - 2.89955e+00, 4.92990e-06, 1.86888e-11, 1.29362e-16, - 3.08249e+00, 5.24916e-06, 1.99900e-11, 1.39496e-16, - 3.69977e+00, 6.31698e-06, 2.42367e-11, 1.71353e-16, - 5.06558e+00, 8.67290e-06, 3.35347e-11, 2.40280e-16, - 7.09332e+00, 1.21816e-05, 4.75377e-11, 3.46171e-16, - 9.22649e+00, 1.59270e-05, 6.32195e-11, 4.74390e-16, - 1.08624e+01, 1.89007e-05, 7.70051e-11, 6.04198e-16, - 1.17514e+01, 2.06434e-05, 8.66021e-11, 7.12327e-16, - 1.20172e+01, 2.13237e-05, 9.19108e-11, 7.86989e-16, - 1.19350e+01, 2.14078e-05, 9.44200e-11, 8.32977e-16, - 1.17499e+01, 2.13514e-05, 9.60658e-11, 8.64823e-16, - 1.16255e+01, 2.15518e-05, 9.90976e-11, 9.04821e-16, - 1.19573e+01, 2.36139e-05, 1.14559e-10, 1.06630e-15, - 1.51193e+01, 3.80077e-05, 2.17630e-10, 2.11441e-15, - 2.88990e+01, 9.93223e-05, 6.64795e-10, 6.60023e-15, - 7.41785e+01, 2.87865e-04, 1.99265e-09, 1.93332e-14, - 1.88656e+02, 7.26466e-04, 4.90072e-09, 4.57065e-14, - 4.09136e+02, 1.50900e-03, 9.80616e-09, 8.81118e-14, - 7.53739e+02, 2.65184e-03, 1.66314e-08, 1.44869e-13, - 1.22335e+03, 4.11549e-03, 2.50007e-08, 2.12244e-13, - 1.81062e+03, 5.83587e-03, 3.44214e-08, 2.85851e-13 }; - - double C30_kpAl2O3[] = - { 9.93250e-04, 7.58434e-11, 8.82228e-18, 1.41287e-24, - 1.81240e-03, 1.38393e-10, 1.60982e-17, 2.57809e-24, - 2.84365e-03, 2.17138e-10, 2.52580e-17, 4.04502e-24, - 4.14191e-03, 3.16271e-10, 3.67894e-17, 5.89176e-24, - 7.18271e-03, 5.48463e-10, 6.37986e-17, 1.02172e-23, - 1.13364e-02, 8.65631e-10, 1.00692e-16, 1.61257e-23, - 1.77361e-02, 1.35430e-09, 1.57536e-16, 2.52291e-23, - 2.59477e-02, 1.98134e-09, 2.30474e-16, 3.69100e-23, - 3.45425e-02, 2.63763e-09, 3.06815e-16, 4.91359e-23, - 4.22006e-02, 3.22239e-09, 3.74836e-16, 6.00294e-23, - 4.71420e-02, 3.59971e-09, 4.18726e-16, 6.70583e-23, - 4.91934e-02, 3.75635e-09, 4.36947e-16, 6.99764e-23, - 5.05162e-02, 3.85735e-09, 4.48697e-16, 7.18580e-23, - 5.78201e-02, 4.41508e-09, 5.13572e-16, 8.22477e-23, - 8.84237e-02, 6.75193e-09, 7.85401e-16, 1.25781e-22, - 1.78786e-01, 1.36519e-08, 1.58802e-15, 2.54319e-22, - 4.36405e-01, 3.33234e-08, 3.87627e-15, 6.20781e-22, - 1.63797e+00, 1.25074e-07, 1.45490e-14, 2.33003e-21, - 8.50820e+00, 6.49679e-07, 7.55727e-14, 1.21029e-20, - 3.92752e+01, 2.99901e-06, 3.48854e-13, 5.58686e-20, - 1.41437e+02, 1.08001e-05, 1.25630e-12, 2.01195e-19, - 3.83709e+02, 2.92996e-05, 3.40821e-12, 5.45820e-19, - 7.70412e+02, 5.88278e-05, 6.84300e-12, 1.09590e-18, - 1.16399e+03, 8.88808e-05, 1.03388e-11, 1.65574e-18, - 1.37566e+03, 1.05044e-04, 1.22190e-11, 1.95685e-18, - 1.33070e+03, 1.01611e-04, 1.18196e-11, 1.89289e-18, - 1.09978e+03, 8.39785e-05, 9.76864e-12, 1.56444e-18, - 8.05639e+02, 6.15177e-05, 7.15589e-12, 1.14600e-18, - 5.38690e+02, 4.11337e-05, 4.78477e-12, 7.66273e-19, - 3.36338e+02, 2.56824e-05, 2.98743e-12, 4.78432e-19, - 1.99460e+02, 1.52305e-05, 1.77165e-12, 2.83727e-19, - 1.13787e+02, 8.68865e-06, 1.01068e-12, 1.61859e-19, - 6.30411e+01, 4.81374e-06, 5.59946e-13, 8.96744e-20, - 3.41529e+01, 2.60788e-06, 3.03354e-13, 4.85817e-20, - 1.81893e+01, 1.38891e-06, 1.61561e-13, 2.58738e-20 }; - - - itab0 = Nmom * NTd * iSN; - itab = 0; - for(imom = 0; imom < Nmom; imom++) { - for(iTd = 0; iTd < NTd; iTd++) { - my_rates->SN0_kpSiM [itab0] = C30_kpSiM [itab]; - my_rates->SN0_kpFeM [itab0] = C30_kpFeM [itab]; - my_rates->SN0_kpMg2SiO4 [itab0] = C30_kpMg2SiO4 [itab]; - my_rates->SN0_kpMgSiO3 [itab0] = C30_kpMgSiO3 [itab]; - my_rates->SN0_kpAC [itab0] = C30_kpAC [itab]; - my_rates->SN0_kpSiO2D [itab0] = C30_kpSiO2D [itab]; - my_rates->SN0_kpMgO [itab0] = C30_kpMgO [itab]; - my_rates->SN0_kpFeS [itab0] = C30_kpFeS [itab]; - my_rates->SN0_kpAl2O3 [itab0] = C30_kpAl2O3 [itab]; - itab0++; - itab ++; - } - } - - return SUCCESS; -} - -int calc_rates_dust_F13(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates) -{ - - int NTd, Nmom; - int iTd, imom, itab0, itab; - - grackle::impl::GrainMetalInjectPathways* inject_pathway_props - = my_rates->opaque_storage->inject_pathway_props; - - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 6.31648e-26; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 2.06081e-16; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN] = 3.19262e-15; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Fe3O4_dust] [iSN] = 4.37192e-15; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust] [iSN] = 1.75542e-01; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust] [iSN] = 1.92019e-16; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Al2O3_dust] [iSN] = 6.23283e-17; - - itab0 = 3 * iSN; - my_rates->SN0_r0FeM [itab0 + 0] = 4.02937e-08; - my_rates->SN0_r0Mg2SiO4 [itab0 + 0] = 4.03307e-08; - my_rates->SN0_r0MgSiO3 [itab0 + 0] = 4.03157e-08; - my_rates->SN0_r0Fe3O4 [itab0 + 0] = 4.03312e-08; - my_rates->SN0_r0AC [itab0 + 0] = 6.60867e-06; - my_rates->SN0_r0SiO2D [itab0 + 0] = 4.03146e-08; - my_rates->SN0_r0Al2O3 [itab0 + 0] = 4.03146e-08; - - my_rates->SN0_r0FeM [itab0 + 1] = 1.67044e-15; - my_rates->SN0_r0Mg2SiO4 [itab0 + 1] = 1.67330e-15; - my_rates->SN0_r0MgSiO3 [itab0 + 1] = 1.67182e-15; - my_rates->SN0_r0Fe3O4 [itab0 + 1] = 1.67336e-15; - my_rates->SN0_r0AC [itab0 + 1] = 5.49310e-11; - my_rates->SN0_r0SiO2D [itab0 + 1] = 1.67171e-15; - my_rates->SN0_r0Al2O3 [itab0 + 1] = 1.67171e-15; - - my_rates->SN0_r0FeM [itab0 + 2] = 7.11477e-23; - my_rates->SN0_r0Mg2SiO4 [itab0 + 2] = 7.13316e-23; - my_rates->SN0_r0MgSiO3 [itab0 + 2] = 7.12190e-23; - my_rates->SN0_r0Fe3O4 [itab0 + 2] = 7.13357e-23; - my_rates->SN0_r0AC [itab0 + 2] = 5.25955e-16; - my_rates->SN0_r0SiO2D [itab0 + 2] = 7.12105e-23; - my_rates->SN0_r0Al2O3 [itab0 + 2] = 7.12106e-23; - - NTd = 35; - Nmom = 4; - - double F13_kpFeM[] = - { 1.23621e-05, 4.98941e-13, 2.07173e-20, 8.83710e-28, - 2.19539e-05, 8.86065e-13, 3.67916e-20, 1.56937e-27, - 3.40291e-05, 1.37342e-12, 5.70280e-20, 2.43256e-27, - 4.92310e-05, 1.98698e-12, 8.25041e-20, 3.51925e-27, - 8.08514e-05, 3.26317e-12, 1.35494e-19, 5.77953e-27, - 1.25020e-04, 5.04574e-12, 2.09508e-19, 8.93651e-27, - 1.96586e-04, 7.93387e-12, 3.29418e-19, 1.40509e-26, - 3.14491e-04, 1.26917e-11, 5.26937e-19, 2.24747e-26, - 5.06850e-04, 2.04532e-11, 8.49130e-19, 3.62146e-26, - 8.07286e-04, 3.25749e-11, 1.35229e-18, 5.76710e-26, - 1.28668e-03, 5.19155e-11, 2.15506e-18, 9.19009e-26, - 2.05241e-03, 8.28056e-11, 3.43709e-18, 1.46562e-25, - 3.27026e-03, 1.31928e-10, 5.47555e-18, 2.33466e-25, - 5.23898e-03, 2.11325e-10, 8.76988e-18, 3.73889e-25, - 8.45023e-03, 3.40811e-10, 1.41417e-17, 6.02834e-25, - 1.37158e-02, 5.53101e-10, 2.29473e-17, 9.78076e-25, - 2.24100e-02, 9.03572e-10, 3.74827e-17, 1.59741e-24, - 3.70042e-02, 1.49181e-09, 6.18765e-17, 2.63669e-24, - 6.21585e-02, 2.50559e-09, 1.03913e-16, 4.42746e-24, - 1.07033e-01, 4.31400e-09, 1.78894e-16, 7.62148e-24, - 1.90089e-01, 7.66095e-09, 3.17659e-16, 1.35323e-23, - 3.49470e-01, 1.40834e-08, 5.83928e-16, 2.48739e-23, - 6.64947e-01, 2.67957e-08, 1.11096e-15, 4.73220e-23, - 1.30413e+00, 5.25515e-08, 2.17873e-15, 9.28021e-23, - 2.61640e+00, 1.05429e-07, 4.37088e-15, 1.86172e-22, - 5.31791e+00, 2.14284e-07, 8.88372e-15, 3.78386e-22, - 1.08366e+01, 4.36654e-07, 1.81025e-14, 7.71039e-22, - 2.19132e+01, 8.82975e-07, 3.66056e-14, 1.55913e-21, - 4.35354e+01, 1.75422e-06, 7.27247e-14, 3.09753e-21, - 8.42362e+01, 3.39422e-06, 1.40714e-13, 5.99335e-21, - 1.57704e+02, 6.35452e-06, 2.63439e-13, 1.12205e-20, - 2.84822e+02, 1.14766e-05, 4.75784e-13, 2.02648e-20, - 4.96653e+02, 2.00121e-05, 8.29639e-13, 3.53363e-20, - 8.39966e+02, 3.38455e-05, 1.40313e-12, 5.97626e-20, - 1.38932e+03, 5.59813e-05, 2.32081e-12, 9.88487e-20 }; - - double F13_kpMg2SiO4[] = - { 1.05240e-01, 4.24440e-09, 1.76098e-16, 7.50693e-24, - 1.32588e-01, 5.34735e-09, 2.21859e-16, 9.45769e-24, - 1.67016e-01, 6.73589e-09, 2.79469e-16, 1.19135e-23, - 2.10360e-01, 8.48395e-09, 3.51995e-16, 1.50053e-23, - 2.71887e-01, 1.09654e-08, 4.54949e-16, 1.93941e-23, - 3.55694e-01, 1.43454e-08, 5.95184e-16, 2.53722e-23, - 4.84932e-01, 1.95577e-08, 8.11439e-16, 3.45910e-23, - 6.99767e-01, 2.82221e-08, 1.17092e-15, 4.99155e-23, - 1.05860e+00, 4.26939e-08, 1.77135e-15, 7.55113e-23, - 1.62902e+00, 6.56994e-08, 2.72584e-15, 1.16200e-22, - 2.54260e+00, 1.02545e-07, 4.25454e-15, 1.81368e-22, - 3.96488e+00, 1.59906e-07, 6.63444e-15, 2.82821e-22, - 6.10630e+00, 2.46271e-07, 1.02177e-14, 4.35572e-22, - 9.28766e+00, 3.74578e-07, 1.55411e-14, 6.62503e-22, - 1.39265e+01, 5.61664e-07, 2.33032e-14, 9.93397e-22, - 2.05382e+01, 8.28321e-07, 3.43667e-14, 1.46502e-21, - 3.00649e+01, 1.21254e-06, 5.03077e-14, 2.14458e-21, - 4.55102e+01, 1.83546e-06, 7.61523e-14, 3.24631e-21, - 7.47839e+01, 3.01609e-06, 1.25136e-13, 5.33445e-21, - 1.29621e+02, 5.22769e-06, 2.16895e-13, 9.24605e-21, - 2.14820e+02, 8.66384e-06, 3.59459e-13, 1.53234e-20, - 3.20002e+02, 1.29059e-05, 5.35460e-13, 2.28262e-20, - 4.29768e+02, 1.73329e-05, 7.19133e-13, 3.06560e-20, - 5.30827e+02, 2.14086e-05, 8.88234e-13, 3.78647e-20, - 5.99694e+02, 2.41861e-05, 1.00347e-12, 4.27771e-20, - 6.06537e+02, 2.44620e-05, 1.01492e-12, 4.32652e-20, - 5.43262e+02, 2.19101e-05, 9.09042e-13, 3.87517e-20, - 4.33545e+02, 1.74852e-05, 7.25453e-13, 3.09255e-20, - 3.13324e+02, 1.26366e-05, 5.24285e-13, 2.23499e-20, - 2.09006e+02, 8.42935e-06, 3.49730e-13, 1.49087e-20, - 1.31150e+02, 5.28937e-06, 2.19454e-13, 9.35513e-21, - 7.90681e+01, 3.18887e-06, 1.32305e-13, 5.64006e-21, - 4.73389e+01, 1.90921e-06, 7.92124e-14, 3.37676e-21, - 2.96409e+01, 1.19544e-06, 4.95982e-14, 2.11433e-21, - 2.04708e+01, 8.25601e-07, 3.42539e-14, 1.46021e-21 }; - - double F13_kpMgSiO3[] = - { 2.19890e-02, 8.86503e-10, 3.67618e-17, 1.56604e-24, - 3.90612e-02, 1.57478e-09, 6.53036e-17, 2.78190e-24, - 6.05539e-02, 2.44128e-09, 1.01236e-16, 4.31259e-24, - 8.76116e-02, 3.53213e-09, 1.46471e-16, 6.23961e-24, - 1.43288e-01, 5.77674e-09, 2.39552e-16, 1.02048e-23, - 2.19266e-01, 8.83988e-09, 3.66575e-16, 1.56159e-23, - 3.36256e-01, 1.35564e-08, 5.62160e-16, 2.39478e-23, - 5.14336e-01, 2.07358e-08, 8.59879e-16, 3.66305e-23, - 7.97216e-01, 3.21404e-08, 1.33281e-15, 5.67770e-23, - 1.25414e+00, 5.05616e-08, 2.09670e-15, 8.93186e-23, - 2.03450e+00, 8.20224e-08, 3.40133e-15, 1.44895e-22, - 3.34648e+00, 1.34916e-07, 5.59472e-15, 2.38333e-22, - 5.45893e+00, 2.20081e-07, 9.12638e-15, 3.88780e-22, - 8.82117e+00, 3.55632e-07, 1.47474e-14, 6.28235e-22, - 1.41825e+01, 5.71778e-07, 2.37106e-14, 1.01006e-21, - 2.28419e+01, 9.20889e-07, 3.81877e-14, 1.62678e-21, - 3.71178e+01, 1.49643e-06, 6.20544e-14, 2.64349e-21, - 6.14272e+01, 2.47648e-06, 1.02696e-13, 4.37479e-21, - 1.03847e+02, 4.18665e-06, 1.73613e-13, 7.39586e-21, - 1.75507e+02, 7.07567e-06, 2.93416e-13, 1.24994e-20, - 2.82060e+02, 1.13715e-05, 4.71555e-13, 2.00880e-20, - 4.14519e+02, 1.67116e-05, 6.93003e-13, 2.95216e-20, - 5.59961e+02, 2.25752e-05, 9.36157e-13, 3.98799e-20, - 7.11024e+02, 2.86655e-05, 1.18871e-12, 5.06385e-20, - 8.40805e+02, 3.38977e-05, 1.40568e-12, 5.98813e-20, - 8.95312e+02, 3.60952e-05, 1.49681e-12, 6.37633e-20, - 8.40415e+02, 3.38819e-05, 1.40503e-12, 5.98535e-20, - 6.96693e+02, 2.80877e-05, 1.16475e-12, 4.96178e-20, - 5.18202e+02, 2.08917e-05, 8.66344e-13, 3.69059e-20, - 3.52864e+02, 1.42260e-05, 5.89927e-13, 2.51306e-20, - 2.24210e+02, 9.03919e-06, 3.74840e-13, 1.59680e-20, - 1.35138e+02, 5.44818e-06, 2.25927e-13, 9.62439e-21, - 7.83119e+01, 3.15720e-06, 1.30924e-13, 5.57730e-21, - 4.41553e+01, 1.78015e-06, 7.38199e-14, 3.14470e-21, - 2.45888e+01, 9.91317e-07, 4.11082e-14, 1.75119e-21 }; - - double F13_kpFe3O4[] = - { 1.47700e-02, 5.95693e-10, 2.47155e-17, 1.05363e-24, - 2.47694e-02, 9.98982e-10, 4.14481e-17, 1.76695e-24, - 3.73580e-02, 1.50669e-09, 6.25133e-17, 2.66496e-24, - 5.32060e-02, 2.14587e-09, 8.90327e-17, 3.79549e-24, - 8.50036e-02, 3.42830e-09, 1.42241e-16, 6.06380e-24, - 1.29213e-01, 5.21132e-09, 2.16220e-16, 9.21750e-24, - 2.00170e-01, 8.07309e-09, 3.34956e-16, 1.42793e-23, - 3.15560e-01, 1.27269e-08, 5.28045e-16, 2.25107e-23, - 5.01384e-01, 2.02214e-08, 8.38995e-16, 3.57666e-23, - 7.88907e-01, 3.18176e-08, 1.32012e-15, 5.62773e-23, - 1.24250e+00, 5.01116e-08, 2.07915e-15, 8.86347e-23, - 1.95225e+00, 7.87365e-08, 3.26681e-15, 1.39265e-22, - 3.04002e+00, 1.22608e-07, 5.08704e-15, 2.16862e-22, - 4.68918e+00, 1.89120e-07, 7.84668e-15, 3.34506e-22, - 7.12599e+00, 2.87400e-07, 1.19243e-14, 5.08338e-22, - 1.05834e+01, 4.26842e-07, 1.77098e-14, 7.54974e-22, - 1.52356e+01, 6.14471e-07, 2.54946e-14, 1.08684e-21, - 2.13345e+01, 8.60449e-07, 3.57003e-14, 1.52192e-21, - 2.98061e+01, 1.20212e-06, 4.98762e-14, 2.12624e-21, - 4.27642e+01, 1.72473e-06, 7.15598e-14, 3.05062e-21, - 6.30370e+01, 2.54236e-06, 1.05483e-13, 4.49679e-21, - 9.29361e+01, 3.74823e-06, 1.55515e-13, 6.62967e-21, - 1.32987e+02, 5.36353e-06, 2.22535e-13, 9.48673e-21, - 1.82150e+02, 7.34635e-06, 3.04803e-13, 1.29938e-20, - 2.40388e+02, 9.69513e-06, 4.02254e-13, 1.71482e-20, - 3.12065e+02, 1.25860e-05, 5.22197e-13, 2.22614e-20, - 4.08414e+02, 1.64718e-05, 6.83423e-13, 2.91345e-20, - 5.49591e+02, 2.21657e-05, 9.19662e-13, 3.92055e-20, - 7.67451e+02, 3.09523e-05, 1.28422e-12, 5.47467e-20, - 1.10725e+03, 4.46570e-05, 1.85283e-12, 7.89869e-20, - 1.62060e+03, 6.53608e-05, 2.71184e-12, 1.15607e-19, - 2.33999e+03, 9.43747e-05, 3.91564e-12, 1.66925e-19, - 3.24367e+03, 1.30821e-04, 5.42783e-12, 2.31390e-19, - 4.25716e+03, 1.71697e-04, 7.12376e-12, 3.03688e-19, - 5.34010e+03, 2.15373e-04, 8.93591e-12, 3.80941e-19 }; - - double F13_kpAC[] = - { 3.27960e-01, 2.16737e-06, 1.80151e-11, 1.72491e-16, - 4.38754e-01, 2.89959e-06, 2.41015e-11, 2.30770e-16, - 5.78235e-01, 3.82140e-06, 3.17638e-11, 3.04139e-16, - 7.53832e-01, 4.98189e-06, 4.14101e-11, 3.96504e-16, - 1.04018e+00, 6.87442e-06, 5.71418e-11, 5.47146e-16, - 1.41746e+00, 9.36786e-06, 7.78688e-11, 7.45623e-16, - 1.95306e+00, 1.29077e-05, 1.07295e-10, 1.02741e-15, - 2.71551e+00, 1.79470e-05, 1.49187e-10, 1.42858e-15, - 3.79717e+00, 2.50964e-05, 2.08623e-10, 1.99781e-15, - 5.29825e+00, 3.50184e-05, 2.91115e-10, 2.78791e-15, - 7.37979e+00, 4.87780e-05, 4.05522e-10, 3.88380e-15, - 1.02197e+01, 6.75525e-05, 5.61646e-10, 5.37953e-15, - 1.40472e+01, 9.28592e-05, 7.72124e-10, 7.39643e-15, - 1.92121e+01, 1.27015e-04, 1.05627e-09, 1.01201e-14, - 2.61803e+01, 1.73108e-04, 1.43985e-09, 1.37985e-14, - 3.55654e+01, 2.35211e-04, 1.95692e-09, 1.87600e-14, - 4.82268e+01, 3.19039e-04, 2.65535e-09, 2.54677e-14, - 6.54410e+01, 4.33093e-04, 3.60654e-09, 3.46142e-14, - 8.90033e+01, 5.89369e-04, 4.91159e-09, 4.71850e-14, - 1.21154e+02, 8.02913e-04, 6.69826e-09, 6.44364e-14, - 1.64484e+02, 1.09135e-03, 9.11847e-09, 8.78899e-14, - 2.22227e+02, 1.47698e-03, 1.23680e-08, 1.19551e-13, - 2.99250e+02, 1.99360e-03, 1.67456e-08, 1.62501e-13, - 4.02841e+02, 2.69134e-03, 2.26888e-08, 2.21192e-13, - 5.41754e+02, 3.62947e-03, 3.07031e-08, 3.00611e-13, - 7.24111e+02, 4.86183e-03, 4.12300e-08, 4.04886e-13, - 9.58822e+02, 6.44664e-03, 5.47294e-08, 5.38055e-13, - 1.26198e+03, 8.49034e-03, 7.20550e-08, 7.07781e-13, - 1.66376e+03, 1.11958e-02, 9.48672e-08, 9.29402e-13, - 2.21388e+03, 1.49013e-02, 1.25959e-07, 1.22898e-12, - 2.99023e+03, 2.01435e-02, 1.69784e-07, 1.64820e-12, - 4.11644e+03, 2.77858e-02, 2.33536e-07, 2.25436e-12, - 5.78855e+03, 3.92074e-02, 3.28708e-07, 3.15462e-12, - 8.29050e+03, 5.63946e-02, 4.71738e-07, 4.50079e-12, - 1.19408e+04, 8.14776e-02, 6.79738e-07, 6.44637e-12 }; - - double F13_kpSiO2D[] = - { 7.60360e-02, 3.06536e-09, 1.27110e-16, 5.41456e-24, - 9.07207e-02, 3.65737e-09, 1.51659e-16, 6.46027e-24, - 1.09208e-01, 4.40266e-09, 1.82564e-16, 7.77673e-24, - 1.32481e-01, 5.34093e-09, 2.21471e-16, 9.43407e-24, - 1.58907e-01, 6.40629e-09, 2.65648e-16, 1.13159e-23, - 1.91565e-01, 7.72285e-09, 3.20241e-16, 1.36414e-23, - 2.30490e-01, 9.29212e-09, 3.85313e-16, 1.64133e-23, - 2.76795e-01, 1.11589e-08, 4.62722e-16, 1.97107e-23, - 3.33074e-01, 1.34277e-08, 5.56804e-16, 2.37184e-23, - 4.05325e-01, 1.63405e-08, 6.77586e-16, 2.88634e-23, - 5.08160e-01, 2.04863e-08, 8.49498e-16, 3.61863e-23, - 6.72472e-01, 2.71105e-08, 1.12418e-15, 4.78871e-23, - 9.48549e-01, 3.82404e-08, 1.58570e-15, 6.75467e-23, - 1.41787e+00, 5.71610e-08, 2.37028e-15, 1.00968e-22, - 2.19502e+00, 8.84912e-08, 3.66944e-15, 1.56308e-22, - 3.46719e+00, 1.39778e-07, 5.79615e-15, 2.46901e-22, - 5.76852e+00, 2.32556e-07, 9.64331e-15, 4.10780e-22, - 1.17194e+01, 4.72463e-07, 1.95915e-14, 8.34544e-22, - 3.16449e+01, 1.27575e-06, 5.29012e-14, 2.25345e-21, - 8.68296e+01, 3.50050e-06, 1.45154e-13, 6.18318e-21, - 1.92300e+02, 7.75250e-06, 3.21470e-13, 1.36938e-20, - 3.36231e+02, 1.35550e-05, 5.62081e-13, 2.39432e-20, - 5.05825e+02, 2.03921e-05, 8.45594e-13, 3.60201e-20, - 7.20624e+02, 2.90517e-05, 1.20468e-12, 5.13160e-20, - 9.77376e+02, 3.94025e-05, 1.63389e-12, 6.95995e-20, - 1.18646e+03, 4.78315e-05, 1.98341e-12, 8.44881e-20, - 1.23845e+03, 4.99275e-05, 2.07033e-12, 8.81904e-20, - 1.11188e+03, 4.48251e-05, 1.85875e-12, 7.91777e-20, - 8.76396e+02, 3.53316e-05, 1.46508e-12, 6.24086e-20, - 6.22207e+02, 2.50840e-05, 1.04015e-12, 4.43077e-20, - 4.07290e+02, 1.64197e-05, 6.80872e-13, 2.90033e-20, - 2.50573e+02, 1.01017e-05, 4.18886e-13, 1.78434e-20, - 1.47073e+02, 5.92921e-06, 2.45865e-13, 1.04732e-20, - 8.33122e+01, 3.35870e-06, 1.39274e-13, 5.93271e-21, - 4.59585e+01, 1.85280e-06, 7.68295e-14, 3.27273e-21 }; - - double F13_kpAl2O3[] = - { 9.93250e-04, 4.00425e-11, 1.66043e-18, 7.07299e-26, - 1.81240e-03, 7.30662e-11, 3.02981e-18, 1.29062e-25, - 2.84365e-03, 1.14641e-10, 4.75376e-18, 2.02498e-25, - 4.14191e-03, 1.66980e-10, 6.92409e-18, 2.94948e-25, - 7.18271e-03, 2.89568e-10, 1.20074e-17, 5.11485e-25, - 1.13364e-02, 4.57021e-10, 1.89512e-17, 8.07269e-25, - 1.77361e-02, 7.15022e-10, 2.96496e-17, 1.26300e-24, - 2.59477e-02, 1.04607e-09, 4.33772e-17, 1.84775e-24, - 3.45425e-02, 1.39257e-09, 5.77452e-17, 2.45979e-24, - 4.22006e-02, 1.70130e-09, 7.05474e-17, 3.00513e-24, - 4.71420e-02, 1.90051e-09, 7.88079e-17, 3.35701e-24, - 4.91934e-02, 1.98321e-09, 8.22373e-17, 3.50309e-24, - 5.05162e-02, 2.03654e-09, 8.44486e-17, 3.59729e-24, - 5.78201e-02, 2.33100e-09, 9.66587e-17, 4.11740e-24, - 8.84237e-02, 3.56477e-09, 1.47819e-16, 6.29670e-24, - 1.78786e-01, 7.20769e-09, 2.98879e-16, 1.27315e-23, - 4.36404e-01, 1.75935e-08, 7.29542e-16, 3.10766e-23, - 1.63796e+00, 6.60337e-08, 2.73820e-15, 1.16640e-22, - 8.50817e+00, 3.43004e-07, 1.42232e-14, 6.05872e-22, - 3.92751e+01, 1.58336e-06, 6.56567e-14, 2.79680e-21, - 1.41436e+02, 5.70194e-06, 2.36441e-13, 1.00718e-20, - 3.83709e+02, 1.54691e-05, 6.41451e-13, 2.73241e-20, - 7.70411e+02, 3.10588e-05, 1.28791e-12, 5.48614e-20, - 1.16399e+03, 4.69258e-05, 1.94586e-12, 8.28883e-20, - 1.37566e+03, 5.54594e-05, 2.29972e-12, 9.79619e-20, - 1.33070e+03, 5.36466e-05, 2.22455e-12, 9.47599e-20, - 1.09978e+03, 4.43371e-05, 1.83851e-12, 7.83159e-20, - 8.05638e+02, 3.24790e-05, 1.34680e-12, 5.73700e-20, - 5.38690e+02, 2.17171e-05, 9.00535e-13, 3.83604e-20, - 3.36338e+02, 1.35593e-05, 5.62261e-13, 2.39508e-20, - 1.99460e+02, 8.04115e-06, 3.33440e-13, 1.42037e-20, - 1.13787e+02, 4.58728e-06, 1.90220e-13, 8.10285e-21, - 6.30411e+01, 2.54148e-06, 1.05387e-13, 4.48919e-21, - 3.41529e+01, 1.37686e-06, 5.70939e-14, 2.43205e-21, - 1.81893e+01, 7.33293e-07, 3.04073e-14, 1.29527e-21 }; - - - itab0 = Nmom * NTd * iSN; - itab = 0; - for(imom = 0; imom < Nmom; imom++) { - for(iTd = 0; iTd < NTd; iTd++) { - my_rates->SN0_kpFeM [itab0] = F13_kpFeM [itab]; - my_rates->SN0_kpMg2SiO4 [itab0] = F13_kpMg2SiO4 [itab]; - my_rates->SN0_kpMgSiO3 [itab0] = F13_kpMgSiO3 [itab]; - my_rates->SN0_kpFe3O4 [itab0] = F13_kpFe3O4 [itab]; - my_rates->SN0_kpAC [itab0] = F13_kpAC [itab]; - my_rates->SN0_kpSiO2D [itab0] = F13_kpSiO2D [itab]; - my_rates->SN0_kpAl2O3 [itab0] = F13_kpAl2O3 [itab]; - itab0++; - itab ++; - } - } - - return SUCCESS; -} - -int calc_rates_dust_F15(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates) -{ - - int NTd, Nmom; - int iTd, imom, itab0, itab; - - grackle::impl::GrainMetalInjectPathways* inject_pathway_props - = my_rates->opaque_storage->inject_pathway_props; - - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 1.53361e-25; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 1.56864e-15; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN] = 2.13810e-14; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Fe3O4_dust] [iSN] = 1.22287e-14; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust] [iSN] = 1.89229e-01; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust] [iSN] = 1.47463e-15; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Al2O3_dust] [iSN] = 2.15191e-16; - - itab0 = 3 * iSN; - my_rates->SN0_r0FeM [itab0 + 0] = 4.02634e-08; - my_rates->SN0_r0Mg2SiO4 [itab0 + 0] = 4.03318e-08; - my_rates->SN0_r0MgSiO3 [itab0 + 0] = 4.03159e-08; - my_rates->SN0_r0Fe3O4 [itab0 + 0] = 4.03301e-08; - my_rates->SN0_r0AC [itab0 + 0] = 1.14540e-05; - my_rates->SN0_r0SiO2D [itab0 + 0] = 4.03146e-08; - my_rates->SN0_r0Al2O3 [itab0 + 0] = 4.03146e-08; - - my_rates->SN0_r0FeM [itab0 + 1] = 1.66860e-15; - my_rates->SN0_r0Mg2SiO4 [itab0 + 1] = 1.67341e-15; - my_rates->SN0_r0MgSiO3 [itab0 + 1] = 1.67184e-15; - my_rates->SN0_r0Fe3O4 [itab0 + 1] = 1.67324e-15; - my_rates->SN0_r0AC [itab0 + 1] = 1.60512e-10; - my_rates->SN0_r0SiO2D [itab0 + 1] = 1.67171e-15; - my_rates->SN0_r0Al2O3 [itab0 + 1] = 1.67171e-15; - - my_rates->SN0_r0FeM [itab0 + 2] = 7.10566e-23; - my_rates->SN0_r0Mg2SiO4 [itab0 + 2] = 7.13397e-23; - my_rates->SN0_r0MgSiO3 [itab0 + 2] = 7.12201e-23; - my_rates->SN0_r0Fe3O4 [itab0 + 2] = 7.13269e-23; - my_rates->SN0_r0AC [itab0 + 2] = 2.55303e-15; - my_rates->SN0_r0SiO2D [itab0 + 2] = 7.12105e-23; - my_rates->SN0_r0Al2O3 [itab0 + 2] = 7.12106e-23; - - NTd = 35; - Nmom = 4; - - double F15_kpFeM[] = - { 1.23614e-05, 4.98551e-13, 2.06942e-20, 8.82572e-28, - 2.19525e-05, 8.85374e-13, 3.67505e-20, 1.56735e-27, - 3.40270e-05, 1.37235e-12, 5.69643e-20, 2.42942e-27, - 4.92280e-05, 1.98543e-12, 8.24119e-20, 3.51472e-27, - 8.08465e-05, 3.26062e-12, 1.35343e-19, 5.77209e-27, - 1.25012e-04, 5.04181e-12, 2.09274e-19, 8.92500e-27, - 1.96574e-04, 7.92769e-12, 3.29050e-19, 1.40328e-26, - 3.14473e-04, 1.26818e-11, 5.26348e-19, 2.24457e-26, - 5.06822e-04, 2.04373e-11, 8.48182e-19, 3.61680e-26, - 8.07243e-04, 3.25496e-11, 1.35079e-18, 5.75968e-26, - 1.28661e-03, 5.18753e-11, 2.15265e-18, 9.17827e-26, - 2.05232e-03, 8.27416e-11, 3.43325e-18, 1.46374e-25, - 3.27011e-03, 1.31826e-10, 5.46945e-18, 2.33165e-25, - 5.23877e-03, 2.11162e-10, 8.76012e-18, 3.73409e-25, - 8.44994e-03, 3.40550e-10, 1.41259e-17, 6.02059e-25, - 1.37154e-02, 5.52677e-10, 2.29218e-17, 9.76820e-25, - 2.24094e-02, 9.02883e-10, 3.74411e-17, 1.59536e-24, - 3.70035e-02, 1.49068e-09, 6.18079e-17, 2.63331e-24, - 6.21576e-02, 2.50369e-09, 1.03798e-16, 4.42178e-24, - 1.07032e-01, 4.31074e-09, 1.78696e-16, 7.61171e-24, - 1.90087e-01, 7.65516e-09, 3.17308e-16, 1.35149e-23, - 3.49468e-01, 1.40728e-08, 5.83283e-16, 2.48420e-23, - 6.64945e-01, 2.67755e-08, 1.10973e-15, 4.72613e-23, - 1.30413e+00, 5.25119e-08, 2.17633e-15, 9.26832e-23, - 2.61639e+00, 1.05349e-07, 4.36605e-15, 1.85933e-22, - 5.31790e+00, 2.14123e-07, 8.87391e-15, 3.77901e-22, - 1.08366e+01, 4.36326e-07, 1.80825e-14, 7.70051e-22, - 2.19131e+01, 8.82310e-07, 3.65652e-14, 1.55714e-21, - 4.35353e+01, 1.75290e-06, 7.26444e-14, 3.09356e-21, - 8.42362e+01, 3.39166e-06, 1.40558e-13, 5.98567e-21, - 1.57704e+02, 6.34974e-06, 2.63148e-13, 1.12061e-20, - 2.84822e+02, 1.14680e-05, 4.75258e-13, 2.02388e-20, - 4.96653e+02, 1.99971e-05, 8.28723e-13, 3.52910e-20, - 8.39966e+02, 3.38201e-05, 1.40158e-12, 5.96860e-20, - 1.38932e+03, 5.59392e-05, 2.31824e-12, 9.87221e-20 }; - - double F15_kpMg2SiO4[] = - { 1.05240e-01, 4.24452e-09, 1.76110e-16, 7.50779e-24, - 1.32588e-01, 5.34750e-09, 2.21874e-16, 9.45877e-24, - 1.67016e-01, 6.73607e-09, 2.79487e-16, 1.19149e-23, - 2.10360e-01, 8.48418e-09, 3.52018e-16, 1.50070e-23, - 2.71887e-01, 1.09657e-08, 4.54979e-16, 1.93963e-23, - 3.55694e-01, 1.43458e-08, 5.95222e-16, 2.53751e-23, - 4.84932e-01, 1.95582e-08, 8.11491e-16, 3.45949e-23, - 6.99767e-01, 2.82229e-08, 1.17100e-15, 4.99212e-23, - 1.05860e+00, 4.26950e-08, 1.77146e-15, 7.55199e-23, - 1.62902e+00, 6.57012e-08, 2.72602e-15, 1.16214e-22, - 2.54260e+00, 1.02548e-07, 4.25481e-15, 1.81388e-22, - 3.96488e+00, 1.59911e-07, 6.63487e-15, 2.82853e-22, - 6.10630e+00, 2.46278e-07, 1.02183e-14, 4.35621e-22, - 9.28766e+00, 3.74588e-07, 1.55421e-14, 6.62579e-22, - 1.39265e+01, 5.61679e-07, 2.33047e-14, 9.93510e-22, - 2.05382e+01, 8.28344e-07, 3.43689e-14, 1.46519e-21, - 3.00649e+01, 1.21257e-06, 5.03110e-14, 2.14482e-21, - 4.55102e+01, 1.83551e-06, 7.61572e-14, 3.24668e-21, - 7.47839e+01, 3.01617e-06, 1.25144e-13, 5.33506e-21, - 1.29621e+02, 5.22783e-06, 2.16909e-13, 9.24710e-21, - 2.14820e+02, 8.66407e-06, 3.59482e-13, 1.53252e-20, - 3.20002e+02, 1.29062e-05, 5.35494e-13, 2.28288e-20, - 4.29768e+02, 1.73333e-05, 7.19179e-13, 3.06596e-20, - 5.30827e+02, 2.14092e-05, 8.88291e-13, 3.78690e-20, - 5.99694e+02, 2.41867e-05, 1.00353e-12, 4.27820e-20, - 6.06537e+02, 2.44627e-05, 1.01498e-12, 4.32701e-20, - 5.43262e+02, 2.19107e-05, 9.09100e-13, 3.87561e-20, - 4.33545e+02, 1.74857e-05, 7.25499e-13, 3.09290e-20, - 3.13324e+02, 1.26369e-05, 5.24319e-13, 2.23524e-20, - 2.09006e+02, 8.42958e-06, 3.49753e-13, 1.49104e-20, - 1.31150e+02, 5.28951e-06, 2.19468e-13, 9.35620e-21, - 7.90681e+01, 3.18896e-06, 1.32313e-13, 5.64070e-21, - 4.73389e+01, 1.90926e-06, 7.92175e-14, 3.37715e-21, - 2.96409e+01, 1.19547e-06, 4.96014e-14, 2.11457e-21, - 2.04708e+01, 8.25623e-07, 3.42560e-14, 1.46038e-21 }; - - double F15_kpMgSiO3[] = - { 2.19890e-02, 8.86506e-10, 3.67621e-17, 1.56606e-24, - 3.90612e-02, 1.57479e-09, 6.53041e-17, 2.78195e-24, - 6.05539e-02, 2.44129e-09, 1.01236e-16, 4.31266e-24, - 8.76116e-02, 3.53214e-09, 1.46473e-16, 6.23971e-24, - 1.43288e-01, 5.77677e-09, 2.39554e-16, 1.02050e-23, - 2.19266e-01, 8.83991e-09, 3.66578e-16, 1.56162e-23, - 3.36256e-01, 1.35564e-08, 5.62165e-16, 2.39482e-23, - 5.14336e-01, 2.07359e-08, 8.59887e-16, 3.66311e-23, - 7.97216e-01, 3.21405e-08, 1.33282e-15, 5.67779e-23, - 1.25414e+00, 5.05618e-08, 2.09672e-15, 8.93200e-23, - 2.03450e+00, 8.20227e-08, 3.40136e-15, 1.44897e-22, - 3.34648e+00, 1.34916e-07, 5.59477e-15, 2.38337e-22, - 5.45893e+00, 2.20082e-07, 9.12646e-15, 3.88786e-22, - 8.82117e+00, 3.55633e-07, 1.47476e-14, 6.28245e-22, - 1.41825e+01, 5.71780e-07, 2.37109e-14, 1.01008e-21, - 2.28419e+01, 9.20892e-07, 3.81880e-14, 1.62680e-21, - 3.71178e+01, 1.49644e-06, 6.20550e-14, 2.64353e-21, - 6.14272e+01, 2.47649e-06, 1.02696e-13, 4.37486e-21, - 1.03847e+02, 4.18667e-06, 1.73615e-13, 7.39597e-21, - 1.75507e+02, 7.07570e-06, 2.93419e-13, 1.24996e-20, - 2.82060e+02, 1.13715e-05, 4.71559e-13, 2.00884e-20, - 4.14519e+02, 1.67117e-05, 6.93009e-13, 2.95221e-20, - 5.59961e+02, 2.25753e-05, 9.36165e-13, 3.98805e-20, - 7.11024e+02, 2.86656e-05, 1.18872e-12, 5.06393e-20, - 8.40805e+02, 3.38978e-05, 1.40569e-12, 5.98823e-20, - 8.95312e+02, 3.60953e-05, 1.49682e-12, 6.37643e-20, - 8.40415e+02, 3.38821e-05, 1.40504e-12, 5.98544e-20, - 6.96693e+02, 2.80878e-05, 1.16476e-12, 4.96186e-20, - 5.18202e+02, 2.08918e-05, 8.66351e-13, 3.69065e-20, - 3.52864e+02, 1.42260e-05, 5.89932e-13, 2.51310e-20, - 2.24210e+02, 9.03922e-06, 3.74843e-13, 1.59683e-20, - 1.35138e+02, 5.44820e-06, 2.25929e-13, 9.62454e-21, - 7.83119e+01, 3.15721e-06, 1.30925e-13, 5.57739e-21, - 4.41553e+01, 1.78016e-06, 7.38206e-14, 3.14475e-21, - 2.45888e+01, 9.91321e-07, 4.11086e-14, 1.75122e-21 }; - - double F15_kpFe3O4[] = - { 1.47700e-02, 5.95675e-10, 2.47138e-17, 1.05350e-24, - 2.47694e-02, 9.98953e-10, 4.14453e-17, 1.76673e-24, - 3.73580e-02, 1.50665e-09, 6.25090e-17, 2.66463e-24, - 5.32060e-02, 2.14580e-09, 8.90266e-17, 3.79502e-24, - 8.50036e-02, 3.42820e-09, 1.42232e-16, 6.06304e-24, - 1.29213e-01, 5.21117e-09, 2.16205e-16, 9.21636e-24, - 2.00170e-01, 8.07286e-09, 3.34932e-16, 1.42775e-23, - 3.15560e-01, 1.27266e-08, 5.28008e-16, 2.25079e-23, - 5.01384e-01, 2.02209e-08, 8.38937e-16, 3.57622e-23, - 7.88907e-01, 3.18167e-08, 1.32003e-15, 5.62703e-23, - 1.24250e+00, 5.01101e-08, 2.07900e-15, 8.86237e-23, - 1.95225e+00, 7.87342e-08, 3.26658e-15, 1.39248e-22, - 3.04002e+00, 1.22604e-07, 5.08669e-15, 2.16835e-22, - 4.68918e+00, 1.89115e-07, 7.84613e-15, 3.34465e-22, - 7.12599e+00, 2.87392e-07, 1.19235e-14, 5.08275e-22, - 1.05834e+01, 4.26829e-07, 1.77086e-14, 7.54881e-22, - 1.52356e+01, 6.14453e-07, 2.54928e-14, 1.08671e-21, - 2.13345e+01, 8.60424e-07, 3.56978e-14, 1.52173e-21, - 2.98061e+01, 1.20208e-06, 4.98728e-14, 2.12597e-21, - 4.27642e+01, 1.72468e-06, 7.15548e-14, 3.05024e-21, - 6.30370e+01, 2.54229e-06, 1.05476e-13, 4.49623e-21, - 9.29361e+01, 3.74812e-06, 1.55505e-13, 6.62884e-21, - 1.32987e+02, 5.36337e-06, 2.22519e-13, 9.48555e-21, - 1.82150e+02, 7.34614e-06, 3.04782e-13, 1.29922e-20, - 2.40388e+02, 9.69485e-06, 4.02226e-13, 1.71461e-20, - 3.12065e+02, 1.25856e-05, 5.22160e-13, 2.22586e-20, - 4.08414e+02, 1.64714e-05, 6.83375e-13, 2.91309e-20, - 5.49591e+02, 2.21650e-05, 9.19598e-13, 3.92006e-20, - 7.67451e+02, 3.09514e-05, 1.28413e-12, 5.47399e-20, - 1.10725e+03, 4.46557e-05, 1.85271e-12, 7.89771e-20, - 1.62060e+03, 6.53589e-05, 2.71166e-12, 1.15592e-19, - 2.33999e+03, 9.43719e-05, 3.91537e-12, 1.66904e-19, - 3.24367e+03, 1.30818e-04, 5.42745e-12, 2.31361e-19, - 4.25716e+03, 1.71692e-04, 7.12327e-12, 3.03651e-19, - 5.34010e+03, 2.15367e-04, 8.93529e-12, 3.80893e-19 }; - - double F15_kpAC[] = - { 3.27956e-01, 3.75639e-06, 5.26403e-11, 8.37270e-16, - 4.38770e-01, 5.02579e-06, 7.04309e-11, 1.12026e-15, - 5.78277e-01, 6.62387e-06, 9.28278e-11, 1.47653e-15, - 7.53906e-01, 8.63573e-06, 1.21024e-10, 1.92505e-15, - 1.04036e+00, 1.19174e-05, 1.67020e-10, 2.65676e-15, - 1.41778e+00, 1.62414e-05, 2.27626e-10, 3.62091e-15, - 1.95366e+00, 2.23811e-05, 3.13688e-10, 4.99012e-15, - 2.71664e+00, 3.11237e-05, 4.36248e-10, 6.94018e-15, - 3.79935e+00, 4.35320e-05, 6.10219e-10, 9.70860e-15, - 5.30234e+00, 6.07596e-05, 8.51798e-10, 1.35534e-14, - 7.38743e+00, 8.46654e-05, 1.18710e-09, 1.88910e-14, - 1.02340e+01, 1.17314e-04, 1.64516e-09, 2.61851e-14, - 1.40739e+01, 1.61376e-04, 2.26365e-09, 3.60378e-14, - 1.92619e+01, 2.20951e-04, 3.10040e-09, 4.93757e-14, - 2.62735e+01, 3.01546e-04, 4.23341e-09, 6.74511e-14, - 3.57407e+01, 4.10519e-04, 5.76727e-09, 9.19507e-14, - 4.85587e+01, 5.58361e-04, 7.85200e-09, 1.25306e-13, - 6.60737e+01, 7.60948e-04, 1.07159e-08, 1.71237e-13, - 9.02145e+01, 1.04125e-03, 1.46920e-08, 2.35213e-13, - 1.23479e+02, 1.42959e-03, 2.02271e-08, 3.24675e-13, - 1.68976e+02, 1.96503e-03, 2.79128e-08, 4.49723e-13, - 2.30962e+02, 2.70317e-03, 3.86182e-08, 6.25581e-13, - 3.16043e+02, 3.73154e-03, 5.37252e-08, 8.76701e-13, - 4.33583e+02, 5.17180e-03, 7.51313e-08, 1.23638e-12, - 5.93567e+02, 7.14700e-03, 1.04677e-07, 1.73582e-12, - 8.03334e+02, 9.73553e-03, 1.43375e-07, 2.38969e-12, - 1.06890e+03, 1.29850e-02, 1.91575e-07, 3.19823e-12, - 1.40232e+03, 1.70036e-02, 2.50333e-07, 4.17041e-12, - 1.82952e+03, 2.20557e-02, 3.22829e-07, 5.34792e-12, - 2.39537e+03, 2.86193e-02, 4.15124e-07, 6.81663e-12, - 3.17137e+03, 3.74648e-02, 5.37088e-07, 8.71845e-12, - 4.27121e+03, 4.98190e-02, 7.04376e-07, 1.12776e-11, - 5.87303e+03, 6.75884e-02, 9.40996e-07, 1.48329e-11, - 8.22455e+03, 9.33574e-02, 1.27863e-06, 1.98186e-11, - 1.15719e+04, 1.29494e-01, 1.74429e-06, 2.65764e-11 }; - - double F15_kpSiO2D[] = - { 7.60360e-02, 3.06536e-09, 1.27110e-16, 5.41456e-24, - 9.07207e-02, 3.65737e-09, 1.51659e-16, 6.46027e-24, - 1.09208e-01, 4.40266e-09, 1.82564e-16, 7.77673e-24, - 1.32481e-01, 5.34093e-09, 2.21471e-16, 9.43407e-24, - 1.58907e-01, 6.40629e-09, 2.65648e-16, 1.13159e-23, - 1.91565e-01, 7.72285e-09, 3.20241e-16, 1.36414e-23, - 2.30490e-01, 9.29212e-09, 3.85313e-16, 1.64133e-23, - 2.76795e-01, 1.11589e-08, 4.62722e-16, 1.97107e-23, - 3.33074e-01, 1.34277e-08, 5.56804e-16, 2.37184e-23, - 4.05325e-01, 1.63405e-08, 6.77586e-16, 2.88634e-23, - 5.08160e-01, 2.04863e-08, 8.49498e-16, 3.61864e-23, - 6.72472e-01, 2.71105e-08, 1.12418e-15, 4.78871e-23, - 9.48549e-01, 3.82404e-08, 1.58570e-15, 6.75467e-23, - 1.41787e+00, 5.71610e-08, 2.37028e-15, 1.00968e-22, - 2.19502e+00, 8.84912e-08, 3.66944e-15, 1.56308e-22, - 3.46719e+00, 1.39778e-07, 5.79615e-15, 2.46901e-22, - 5.76852e+00, 2.32556e-07, 9.64331e-15, 4.10780e-22, - 1.17194e+01, 4.72463e-07, 1.95915e-14, 8.34544e-22, - 3.16449e+01, 1.27575e-06, 5.29013e-14, 2.25345e-21, - 8.68296e+01, 3.50050e-06, 1.45154e-13, 6.18318e-21, - 1.92300e+02, 7.75250e-06, 3.21470e-13, 1.36938e-20, - 3.36231e+02, 1.35550e-05, 5.62081e-13, 2.39432e-20, - 5.05825e+02, 2.03921e-05, 8.45594e-13, 3.60201e-20, - 7.20624e+02, 2.90517e-05, 1.20468e-12, 5.13160e-20, - 9.77376e+02, 3.94025e-05, 1.63389e-12, 6.95995e-20, - 1.18646e+03, 4.78315e-05, 1.98341e-12, 8.44881e-20, - 1.23845e+03, 4.99275e-05, 2.07033e-12, 8.81904e-20, - 1.11188e+03, 4.48251e-05, 1.85875e-12, 7.91777e-20, - 8.76396e+02, 3.53316e-05, 1.46508e-12, 6.24086e-20, - 6.22207e+02, 2.50840e-05, 1.04015e-12, 4.43077e-20, - 4.07290e+02, 1.64197e-05, 6.80872e-13, 2.90033e-20, - 2.50573e+02, 1.01017e-05, 4.18886e-13, 1.78434e-20, - 1.47073e+02, 5.92921e-06, 2.45865e-13, 1.04732e-20, - 8.33122e+01, 3.35870e-06, 1.39274e-13, 5.93271e-21, - 4.59585e+01, 1.85280e-06, 7.68295e-14, 3.27273e-21 }; - - double F15_kpAl2O3[] = - { 9.93250e-04, 4.00425e-11, 1.66043e-18, 7.07299e-26, - 1.81240e-03, 7.30662e-11, 3.02981e-18, 1.29062e-25, - 2.84365e-03, 1.14641e-10, 4.75376e-18, 2.02498e-25, - 4.14191e-03, 1.66980e-10, 6.92409e-18, 2.94948e-25, - 7.18271e-03, 2.89568e-10, 1.20074e-17, 5.11485e-25, - 1.13364e-02, 4.57021e-10, 1.89512e-17, 8.07269e-25, - 1.77361e-02, 7.15022e-10, 2.96496e-17, 1.26300e-24, - 2.59477e-02, 1.04607e-09, 4.33772e-17, 1.84775e-24, - 3.45425e-02, 1.39257e-09, 5.77452e-17, 2.45979e-24, - 4.22006e-02, 1.70130e-09, 7.05474e-17, 3.00513e-24, - 4.71420e-02, 1.90051e-09, 7.88079e-17, 3.35701e-24, - 4.91934e-02, 1.98321e-09, 8.22373e-17, 3.50309e-24, - 5.05162e-02, 2.03654e-09, 8.44486e-17, 3.59729e-24, - 5.78201e-02, 2.33100e-09, 9.66587e-17, 4.11741e-24, - 8.84237e-02, 3.56477e-09, 1.47819e-16, 6.29670e-24, - 1.78786e-01, 7.20769e-09, 2.98879e-16, 1.27315e-23, - 4.36404e-01, 1.75935e-08, 7.29542e-16, 3.10766e-23, - 1.63796e+00, 6.60337e-08, 2.73820e-15, 1.16640e-22, - 8.50817e+00, 3.43004e-07, 1.42232e-14, 6.05872e-22, - 3.92751e+01, 1.58336e-06, 6.56567e-14, 2.79680e-21, - 1.41436e+02, 5.70194e-06, 2.36441e-13, 1.00718e-20, - 3.83709e+02, 1.54691e-05, 6.41451e-13, 2.73241e-20, - 7.70411e+02, 3.10588e-05, 1.28791e-12, 5.48614e-20, - 1.16399e+03, 4.69258e-05, 1.94586e-12, 8.28883e-20, - 1.37566e+03, 5.54594e-05, 2.29972e-12, 9.79619e-20, - 1.33070e+03, 5.36466e-05, 2.22455e-12, 9.47599e-20, - 1.09978e+03, 4.43371e-05, 1.83851e-12, 7.83159e-20, - 8.05638e+02, 3.24790e-05, 1.34680e-12, 5.73700e-20, - 5.38690e+02, 2.17171e-05, 9.00535e-13, 3.83604e-20, - 3.36338e+02, 1.35593e-05, 5.62261e-13, 2.39508e-20, - 1.99460e+02, 8.04115e-06, 3.33440e-13, 1.42037e-20, - 1.13787e+02, 4.58728e-06, 1.90220e-13, 8.10285e-21, - 6.30411e+01, 2.54148e-06, 1.05387e-13, 4.48919e-21, - 3.41529e+01, 1.37686e-06, 5.70939e-14, 2.43205e-21, - 1.81893e+01, 7.33293e-07, 3.04073e-14, 1.29527e-21 }; - - - itab0 = Nmom * NTd * iSN; - itab = 0; - for(imom = 0; imom < Nmom; imom++) { - for(iTd = 0; iTd < NTd; iTd++) { - my_rates->SN0_kpFeM [itab0] = F15_kpFeM [itab]; - my_rates->SN0_kpMg2SiO4 [itab0] = F15_kpMg2SiO4 [itab]; - my_rates->SN0_kpMgSiO3 [itab0] = F15_kpMgSiO3 [itab]; - my_rates->SN0_kpFe3O4 [itab0] = F15_kpFe3O4 [itab]; - my_rates->SN0_kpAC [itab0] = F15_kpAC [itab]; - my_rates->SN0_kpSiO2D [itab0] = F15_kpSiO2D [itab]; - my_rates->SN0_kpAl2O3 [itab0] = F15_kpAl2O3 [itab]; - itab0++; - itab ++; - } - } - - return SUCCESS; -} - -int calc_rates_dust_F50(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates) -{ - - int NTd, Nmom; - int iTd, imom, itab0, itab; - - grackle::impl::GrainMetalInjectPathways* inject_pathway_props - = my_rates->opaque_storage->inject_pathway_props; - - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 2.33171e-24; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 2.62486e-10; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN] = 1.21446e-09; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Fe3O4_dust] [iSN] = 2.41799e-13; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust] [iSN] = 1.09849e-04; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust] [iSN] = 3.41863e-11; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Al2O3_dust] [iSN] = 2.53950e-17; - - itab0 = 3 * iSN; - my_rates->SN0_r0FeM [itab0 + 0] = 4.02891e-08; - my_rates->SN0_r0Mg2SiO4 [itab0 + 0] = 1.68491e-07; - my_rates->SN0_r0MgSiO3 [itab0 + 0] = 1.33003e-07; - my_rates->SN0_r0Fe3O4 [itab0 + 0] = 5.89806e-08; - my_rates->SN0_r0AC [itab0 + 0] = 6.81790e-07; - my_rates->SN0_r0SiO2D [itab0 + 0] = 9.81613e-08; - my_rates->SN0_r0Al2O3 [itab0 + 0] = 4.03146e-08; - - my_rates->SN0_r0FeM [itab0 + 1] = 1.67016e-15; - my_rates->SN0_r0Mg2SiO4 [itab0 + 1] = 3.02634e-14; - my_rates->SN0_r0MgSiO3 [itab0 + 1] = 1.84568e-14; - my_rates->SN0_r0Fe3O4 [itab0 + 1] = 3.51732e-15; - my_rates->SN0_r0AC [itab0 + 1] = 6.53175e-13; - my_rates->SN0_r0SiO2D [itab0 + 1] = 9.72845e-15; - my_rates->SN0_r0Al2O3 [itab0 + 1] = 1.67172e-15; - - my_rates->SN0_r0FeM [itab0 + 2] = 7.11339e-23; - my_rates->SN0_r0Mg2SiO4 [itab0 + 2] = 5.60369e-21; - my_rates->SN0_r0MgSiO3 [itab0 + 2] = 2.62630e-21; - my_rates->SN0_r0Fe3O4 [itab0 + 2] = 2.11807e-22; - my_rates->SN0_r0AC [itab0 + 2] = 7.65748e-19; - my_rates->SN0_r0SiO2D [itab0 + 2] = 9.68327e-22; - my_rates->SN0_r0Al2O3 [itab0 + 2] = 7.12107e-23; - - NTd = 35; - Nmom = 4; - - double F50_kpFeM[] = - { 1.23620e-05, 4.98882e-13, 2.07138e-20, 8.83538e-28, - 2.19537e-05, 8.85960e-13, 3.67854e-20, 1.56906e-27, - 3.40288e-05, 1.37326e-12, 5.70184e-20, 2.43208e-27, - 4.92305e-05, 1.98674e-12, 8.24901e-20, 3.51856e-27, - 8.08507e-05, 3.26278e-12, 1.35471e-19, 5.77841e-27, - 1.25019e-04, 5.04514e-12, 2.09472e-19, 8.93477e-27, - 1.96584e-04, 7.93293e-12, 3.29363e-19, 1.40481e-26, - 3.14489e-04, 1.26902e-11, 5.26848e-19, 2.24703e-26, - 5.06846e-04, 2.04508e-11, 8.48987e-19, 3.62076e-26, - 8.07280e-04, 3.25711e-11, 1.35207e-18, 5.76597e-26, - 1.28667e-03, 5.19094e-11, 2.15469e-18, 9.18830e-26, - 2.05240e-03, 8.27959e-11, 3.43651e-18, 1.46534e-25, - 3.27023e-03, 1.31912e-10, 5.47463e-18, 2.33420e-25, - 5.23895e-03, 2.11300e-10, 8.76840e-18, 3.73817e-25, - 8.45019e-03, 3.40772e-10, 1.41393e-17, 6.02717e-25, - 1.37157e-02, 5.53037e-10, 2.29434e-17, 9.77885e-25, - 2.24099e-02, 9.03468e-10, 3.74764e-17, 1.59710e-24, - 3.70041e-02, 1.49164e-09, 6.18661e-17, 2.63618e-24, - 6.21584e-02, 2.50530e-09, 1.03896e-16, 4.42660e-24, - 1.07033e-01, 4.31351e-09, 1.78864e-16, 7.62000e-24, - 1.90089e-01, 7.66007e-09, 3.17606e-16, 1.35297e-23, - 3.49470e-01, 1.40818e-08, 5.83831e-16, 2.48691e-23, - 6.64947e-01, 2.67926e-08, 1.11077e-15, 4.73128e-23, - 1.30413e+00, 5.25455e-08, 2.17837e-15, 9.27841e-23, - 2.61640e+00, 1.05417e-07, 4.37015e-15, 1.86136e-22, - 5.31790e+00, 2.14259e-07, 8.88223e-15, 3.78313e-22, - 1.08366e+01, 4.36604e-07, 1.80995e-14, 7.70889e-22, - 2.19132e+01, 8.82874e-07, 3.65995e-14, 1.55883e-21, - 4.35354e+01, 1.75402e-06, 7.27125e-14, 3.09693e-21, - 8.42362e+01, 3.39383e-06, 1.40690e-13, 5.99219e-21, - 1.57704e+02, 6.35380e-06, 2.63395e-13, 1.12183e-20, - 2.84822e+02, 1.14753e-05, 4.75704e-13, 2.02608e-20, - 4.96653e+02, 2.00098e-05, 8.29500e-13, 3.53294e-20, - 8.39966e+02, 3.38417e-05, 1.40289e-12, 5.97510e-20, - 1.38932e+03, 5.59749e-05, 2.32042e-12, 9.88295e-20 }; - - double F50_kpMg2SiO4[] = - { 1.05240e-01, 1.77320e-08, 3.18492e-15, 5.89732e-22, - 1.32588e-01, 2.23399e-08, 4.01256e-15, 7.42980e-22, - 1.67016e-01, 2.81408e-08, 5.05449e-15, 9.35908e-22, - 2.10360e-01, 3.54438e-08, 6.36620e-15, 1.17879e-21, - 2.71887e-01, 4.58106e-08, 8.22824e-15, 1.52357e-21, - 3.55694e-01, 5.99313e-08, 1.07645e-14, 1.99320e-21, - 4.84932e-01, 8.17069e-08, 1.46757e-14, 2.71741e-21, - 6.99767e-01, 1.17905e-07, 2.11774e-14, 3.92128e-21, - 1.05860e+00, 1.78364e-07, 3.20367e-14, 5.93204e-21, - 1.62902e+00, 2.74475e-07, 4.92997e-14, 9.12851e-21, - 2.54260e+00, 4.28406e-07, 7.69478e-14, 1.42479e-20, - 3.96488e+00, 6.68047e-07, 1.19991e-13, 2.22179e-20, - 6.10630e+00, 1.02886e-06, 1.84797e-13, 3.42178e-20, - 9.28766e+00, 1.56489e-06, 2.81076e-13, 5.20451e-20, - 1.39265e+01, 2.34649e-06, 4.21463e-13, 7.80396e-20, - 2.05382e+01, 3.46051e-06, 6.21558e-13, 1.15090e-19, - 3.00649e+01, 5.06568e-06, 9.09868e-13, 1.68475e-19, - 4.55102e+01, 7.66807e-06, 1.37729e-12, 2.55025e-19, - 7.47839e+01, 1.26004e-05, 2.26322e-12, 4.19065e-19, - 1.29621e+02, 2.18400e-05, 3.92277e-12, 7.26354e-19, - 2.14820e+02, 3.61953e-05, 6.50119e-12, 1.20378e-18, - 3.20002e+02, 5.39175e-05, 9.68435e-12, 1.79319e-18, - 4.29768e+02, 7.24122e-05, 1.30063e-11, 2.40829e-18, - 5.30829e+02, 8.94401e-05, 1.60647e-11, 2.97460e-18, - 5.99696e+02, 1.01044e-04, 1.81489e-11, 3.36051e-18, - 6.06539e+02, 1.02197e-04, 1.83560e-11, 3.39886e-18, - 5.43264e+02, 9.15353e-05, 1.64410e-11, 3.04428e-18, - 4.33547e+02, 7.30489e-05, 1.31206e-11, 2.42946e-18, - 3.13324e+02, 5.27923e-05, 9.48225e-12, 1.75577e-18, - 2.09008e+02, 3.52161e-05, 6.32532e-12, 1.17122e-18, - 1.31150e+02, 2.20976e-05, 3.96905e-12, 7.34924e-19, - 7.90692e+01, 1.33225e-05, 2.39291e-12, 4.43080e-19, - 4.73403e+01, 7.97645e-06, 1.43269e-12, 2.65282e-19, - 2.96433e+01, 4.99469e-06, 8.97122e-13, 1.66115e-19, - 2.04754e+01, 3.45001e-06, 6.19680e-13, 1.14743e-19 }; - - double F50_kpMgSiO3[] = - { 2.19890e-02, 2.92460e-09, 4.05846e-16, 5.77498e-23, - 3.90612e-02, 5.19526e-09, 7.20944e-16, 1.02587e-22, - 6.05539e-02, 8.05385e-09, 1.11763e-15, 1.59033e-22, - 8.76116e-02, 1.16526e-08, 1.61703e-15, 2.30095e-22, - 1.43288e-01, 1.90577e-08, 2.64462e-15, 3.76317e-22, - 2.19266e-01, 2.91631e-08, 4.04694e-15, 5.75860e-22, - 3.36256e-01, 4.47230e-08, 6.20619e-15, 8.83109e-22, - 5.14336e-01, 6.84082e-08, 9.49297e-15, 1.35080e-21, - 7.97216e-01, 1.06032e-07, 1.47140e-14, 2.09373e-21, - 1.25414e+00, 1.66804e-07, 2.31474e-14, 3.29375e-21, - 2.03450e+00, 2.70594e-07, 3.75503e-14, 5.34322e-21, - 3.34648e+00, 4.45091e-07, 6.17651e-14, 8.78886e-21, - 5.45893e+00, 7.26054e-07, 1.00754e-13, 1.43368e-20, - 8.82117e+00, 1.17324e-06, 1.62810e-13, 2.31671e-20, - 1.41825e+01, 1.88631e-06, 2.61763e-13, 3.72475e-20, - 2.28419e+01, 3.03804e-06, 4.21588e-13, 5.99898e-20, - 3.71178e+01, 4.93677e-06, 6.85074e-13, 9.74826e-20, - 6.14273e+01, 8.17002e-06, 1.13375e-12, 1.61327e-19, - 1.03847e+02, 1.38119e-05, 1.91667e-12, 2.72733e-19, - 1.75507e+02, 2.33429e-05, 3.23928e-12, 4.60933e-19, - 2.82060e+02, 3.75148e-05, 5.20591e-12, 7.40775e-19, - 4.14519e+02, 5.51322e-05, 7.65067e-12, 1.08865e-18, - 5.59962e+02, 7.44767e-05, 1.03351e-11, 1.47063e-18, - 7.11026e+02, 9.45685e-05, 1.31232e-11, 1.86737e-18, - 8.40809e+02, 1.11830e-04, 1.55186e-11, 2.20822e-18, - 8.95315e+02, 1.19080e-04, 1.65246e-11, 2.35137e-18, - 8.40416e+02, 1.11778e-04, 1.55114e-11, 2.20719e-18, - 6.96694e+02, 9.26624e-05, 1.28587e-11, 1.82973e-18, - 5.18204e+02, 6.89226e-05, 9.56436e-12, 1.36096e-18, - 3.52865e+02, 4.69321e-05, 6.51275e-12, 9.26731e-19, - 2.24211e+02, 2.98208e-05, 4.13822e-12, 5.88848e-19, - 1.35138e+02, 1.79738e-05, 2.49421e-12, 3.54913e-19, - 7.83122e+01, 1.04158e-05, 1.44539e-12, 2.05672e-19, - 4.41556e+01, 5.87282e-06, 8.14969e-13, 1.15966e-19, - 2.45896e+01, 3.27050e-06, 4.53847e-13, 6.45802e-20 }; - - double F50_kpFe3O4[] = - { 1.47700e-02, 8.71144e-10, 5.19508e-17, 3.12839e-24, - 2.47694e-02, 1.46092e-09, 8.71220e-17, 5.24635e-24, - 3.73580e-02, 2.20340e-09, 1.31400e-16, 7.91270e-24, - 5.32060e-02, 3.13813e-09, 1.87143e-16, 1.12694e-23, - 8.50036e-02, 5.01357e-09, 2.98985e-16, 1.80044e-23, - 1.29213e-01, 7.62106e-09, 4.54483e-16, 2.73683e-23, - 2.00170e-01, 1.18061e-08, 7.04061e-16, 4.23974e-23, - 3.15560e-01, 1.86119e-08, 1.10993e-15, 6.68379e-23, - 5.01384e-01, 2.95719e-08, 1.76353e-15, 1.06197e-22, - 7.88907e-01, 4.65303e-08, 2.77484e-15, 1.67096e-22, - 1.24250e+00, 7.32834e-08, 4.37027e-15, 2.63171e-22, - 1.95225e+00, 1.15145e-07, 6.86667e-15, 4.13500e-22, - 3.04002e+00, 1.79302e-07, 1.06927e-14, 6.43899e-22, - 4.68918e+00, 2.76571e-07, 1.64933e-14, 9.93203e-22, - 7.12599e+00, 4.20295e-07, 2.50644e-14, 1.50934e-21, - 1.05834e+01, 6.24215e-07, 3.72252e-14, 2.24164e-21, - 1.52356e+01, 8.98605e-07, 5.35885e-14, 3.22701e-21, - 2.13345e+01, 1.25832e-06, 7.50404e-14, 4.51881e-21, - 2.98061e+01, 1.75798e-06, 1.04837e-13, 6.31314e-21, - 4.27642e+01, 2.52226e-06, 1.50415e-13, 9.05777e-21, - 6.30370e+01, 3.71796e-06, 2.21721e-13, 1.33517e-20, - 9.29361e+01, 5.48143e-06, 3.26886e-13, 1.96845e-20, - 1.32987e+02, 7.84365e-06, 4.67758e-13, 2.81676e-20, - 1.82150e+02, 1.07433e-05, 6.40681e-13, 3.85808e-20, - 2.40388e+02, 1.41782e-05, 8.45520e-13, 5.09158e-20, - 3.12065e+02, 1.84058e-05, 1.09763e-12, 6.60977e-20, - 4.08414e+02, 2.40885e-05, 1.43652e-12, 8.65051e-20, - 5.49591e+02, 3.24152e-05, 1.93309e-12, 1.16407e-19, - 7.67451e+02, 4.52647e-05, 2.69937e-12, 1.62552e-19, - 1.10725e+03, 6.53066e-05, 3.89457e-12, 2.34525e-19, - 1.62060e+03, 9.55840e-05, 5.70017e-12, 3.43255e-19, - 2.33999e+03, 1.38014e-04, 8.23049e-12, 4.95627e-19, - 3.24369e+03, 1.91315e-04, 1.14091e-11, 6.87037e-19, - 4.25718e+03, 2.51091e-04, 1.49739e-11, 9.01702e-19, - 5.34014e+03, 3.14965e-04, 1.87830e-11, 1.13108e-18 }; - - double F50_kpAC[] = - { 3.27960e-01, 2.23600e-07, 2.14215e-13, 2.51135e-19, - 4.38752e-01, 2.99136e-07, 2.86582e-13, 3.35973e-19, - 5.78230e-01, 3.94231e-07, 3.77685e-13, 4.42778e-19, - 7.53823e-01, 5.13949e-07, 4.92378e-13, 5.77238e-19, - 1.04013e+00, 7.09149e-07, 6.79388e-13, 7.96479e-19, - 1.41735e+00, 9.66336e-07, 9.25781e-13, 1.08534e-18, - 1.95292e+00, 1.33148e-06, 1.27560e-12, 1.49545e-18, - 2.71530e+00, 1.85127e-06, 1.77357e-12, 2.07925e-18, - 3.79675e+00, 2.58859e-06, 2.47995e-12, 2.90737e-18, - 5.29742e+00, 3.61173e-06, 3.46016e-12, 4.05652e-18, - 7.37832e+00, 5.03048e-06, 4.81937e-12, 5.65000e-18, - 1.02167e+01, 6.96570e-06, 6.67339e-12, 7.82359e-18, - 1.40420e+01, 9.57377e-06, 9.17203e-12, 1.07529e-17, - 1.92020e+01, 1.30918e-05, 1.25425e-11, 1.47044e-17, - 2.61614e+01, 1.78368e-05, 1.70885e-11, 2.00340e-17, - 3.55303e+01, 2.42246e-05, 2.32084e-11, 2.72089e-17, - 4.81604e+01, 3.28360e-05, 3.14588e-11, 3.68819e-17, - 6.53156e+01, 4.45330e-05, 4.26657e-11, 5.00213e-17, - 8.87641e+01, 6.05213e-05, 5.79846e-11, 6.79824e-17, - 1.20700e+02, 8.22973e-05, 7.88495e-11, 9.24471e-17, - 1.63611e+02, 1.11558e-04, 1.06888e-10, 1.25326e-16, - 2.20556e+02, 1.50393e-04, 1.44104e-10, 1.68969e-16, - 2.96069e+02, 2.01894e-04, 1.93464e-10, 2.26864e-16, - 3.96959e+02, 2.70713e-04, 2.59434e-10, 3.04254e-16, - 5.31398e+02, 3.62437e-04, 3.47381e-10, 4.07456e-16, - 7.06744e+02, 4.82105e-04, 4.62166e-10, 5.42204e-16, - 9.30503e+02, 6.34887e-04, 6.08797e-10, 7.14450e-16, - 1.21574e+03, 8.29802e-04, 7.96038e-10, 9.34622e-16, - 1.58603e+03, 1.08311e-03, 1.03970e-09, 1.22157e-15, - 2.07753e+03, 1.41988e-03, 1.36429e-09, 1.60466e-15, - 2.74067e+03, 1.87531e-03, 1.80443e-09, 2.12568e-15, - 3.64502e+03, 2.49832e-03, 2.40876e-09, 2.84400e-15, - 4.89065e+03, 3.35972e-03, 3.24810e-09, 3.84654e-15, - 6.62881e+03, 4.56615e-03, 4.42856e-09, 5.26292e-15, - 9.09708e+03, 6.28233e-03, 6.11057e-09, 7.28448e-15 }; - - double F50_kpSiO2D[] = - { 7.60360e-02, 7.46380e-09, 7.39712e-16, 7.36277e-23, - 9.07207e-02, 8.90526e-09, 8.82572e-16, 8.78473e-23, - 1.09208e-01, 1.07200e-08, 1.06242e-15, 1.05749e-22, - 1.32481e-01, 1.30045e-08, 1.28884e-15, 1.28285e-22, - 1.58907e-01, 1.55986e-08, 1.54592e-15, 1.53874e-22, - 1.91565e-01, 1.88042e-08, 1.86363e-15, 1.85497e-22, - 2.30490e-01, 2.26252e-08, 2.24231e-15, 2.23190e-22, - 2.76795e-01, 2.71706e-08, 2.69279e-15, 2.68028e-22, - 3.33074e-01, 3.26950e-08, 3.24029e-15, 3.22524e-22, - 4.05325e-01, 3.97872e-08, 3.94318e-15, 3.92487e-22, - 5.08160e-01, 4.98817e-08, 4.94361e-15, 4.92065e-22, - 6.72472e-01, 6.60108e-08, 6.54211e-15, 6.51173e-22, - 9.48549e-01, 9.31109e-08, 9.22792e-15, 9.18506e-22, - 1.41787e+00, 1.39180e-07, 1.37937e-14, 1.37297e-21, - 2.19502e+00, 2.15466e-07, 2.13541e-14, 2.12549e-21, - 3.46719e+00, 3.40344e-07, 3.37304e-14, 3.35738e-21, - 5.76852e+00, 5.66246e-07, 5.61188e-14, 5.58582e-21, - 1.17194e+01, 1.15039e-06, 1.14012e-13, 1.13482e-20, - 3.16449e+01, 3.10631e-06, 3.07856e-13, 3.06426e-20, - 8.68296e+01, 8.52331e-06, 8.44717e-13, 8.40795e-20, - 1.92300e+02, 1.88764e-05, 1.87078e-12, 1.86209e-19, - 3.36231e+02, 3.30049e-05, 3.27100e-12, 3.25581e-19, - 5.05825e+02, 4.96525e-05, 4.92089e-12, 4.89804e-19, - 7.20624e+02, 7.07374e-05, 7.01055e-12, 6.97800e-19, - 9.77376e+02, 9.59406e-05, 9.50836e-12, 9.46420e-19, - 1.18646e+03, 1.16464e-04, 1.15424e-11, 1.14888e-18, - 1.23845e+03, 1.21568e-04, 1.20482e-11, 1.19922e-18, - 1.11188e+03, 1.09144e-04, 1.08169e-11, 1.07667e-18, - 8.76396e+02, 8.60282e-05, 8.52597e-12, 8.48638e-19, - 6.22207e+02, 6.10766e-05, 6.05311e-12, 6.02500e-19, - 4.07290e+02, 3.99801e-05, 3.96230e-12, 3.94390e-19, - 2.50573e+02, 2.45966e-05, 2.43769e-12, 2.42636e-19, - 1.47073e+02, 1.44369e-05, 1.43080e-12, 1.42415e-19, - 8.33122e+01, 8.17804e-06, 8.10499e-13, 8.06735e-20, - 4.59586e+01, 4.51135e-06, 4.47106e-13, 4.45029e-20 }; - - double F50_kpAl2O3[] = - { 9.93250e-04, 4.00425e-11, 1.66043e-18, 7.07300e-26, - 1.81240e-03, 7.30662e-11, 3.02982e-18, 1.29062e-25, - 2.84365e-03, 1.14641e-10, 4.75377e-18, 2.02498e-25, - 4.14191e-03, 1.66980e-10, 6.92410e-18, 2.94948e-25, - 7.18271e-03, 2.89568e-10, 1.20074e-17, 5.11486e-25, - 1.13364e-02, 4.57021e-10, 1.89512e-17, 8.07270e-25, - 1.77361e-02, 7.15022e-10, 2.96496e-17, 1.26300e-24, - 2.59477e-02, 1.04607e-09, 4.33772e-17, 1.84776e-24, - 3.45425e-02, 1.39257e-09, 5.77453e-17, 2.45980e-24, - 4.22006e-02, 1.70130e-09, 7.05475e-17, 3.00514e-24, - 4.71420e-02, 1.90051e-09, 7.88080e-17, 3.35701e-24, - 4.91934e-02, 1.98321e-09, 8.22374e-17, 3.50310e-24, - 5.05162e-02, 2.03654e-09, 8.44487e-17, 3.59729e-24, - 5.78201e-02, 2.33100e-09, 9.66588e-17, 4.11741e-24, - 8.84237e-02, 3.56477e-09, 1.47819e-16, 6.29671e-24, - 1.78786e-01, 7.20770e-09, 2.98880e-16, 1.27315e-23, - 4.36404e-01, 1.75935e-08, 7.29543e-16, 3.10766e-23, - 1.63796e+00, 6.60337e-08, 2.73820e-15, 1.16640e-22, - 8.50817e+00, 3.43004e-07, 1.42232e-14, 6.05873e-22, - 3.92751e+01, 1.58336e-06, 6.56568e-14, 2.79681e-21, - 1.41436e+02, 5.70194e-06, 2.36441e-13, 1.00718e-20, - 3.83709e+02, 1.54691e-05, 6.41452e-13, 2.73242e-20, - 7.70411e+02, 3.10588e-05, 1.28791e-12, 5.48615e-20, - 1.16399e+03, 4.69258e-05, 1.94586e-12, 8.28885e-20, - 1.37566e+03, 5.54594e-05, 2.29972e-12, 9.79620e-20, - 1.33070e+03, 5.36466e-05, 2.22455e-12, 9.47600e-20, - 1.09978e+03, 4.43372e-05, 1.83852e-12, 7.83160e-20, - 8.05638e+02, 3.24790e-05, 1.34680e-12, 5.73701e-20, - 5.38690e+02, 2.17171e-05, 9.00536e-13, 3.83605e-20, - 3.36338e+02, 1.35593e-05, 5.62261e-13, 2.39509e-20, - 1.99460e+02, 8.04115e-06, 3.33440e-13, 1.42037e-20, - 1.13787e+02, 4.58729e-06, 1.90220e-13, 8.10286e-21, - 6.30411e+01, 2.54148e-06, 1.05387e-13, 4.48920e-21, - 3.41529e+01, 1.37686e-06, 5.70940e-14, 2.43205e-21, - 1.81893e+01, 7.33294e-07, 3.04073e-14, 1.29527e-21 }; - - - itab0 = Nmom * NTd * iSN; - itab = 0; - for(imom = 0; imom < Nmom; imom++) { - for(iTd = 0; iTd < NTd; iTd++) { - my_rates->SN0_kpFeM [itab0] = F50_kpFeM [itab]; - my_rates->SN0_kpMg2SiO4 [itab0] = F50_kpMg2SiO4 [itab]; - my_rates->SN0_kpMgSiO3 [itab0] = F50_kpMgSiO3 [itab]; - my_rates->SN0_kpFe3O4 [itab0] = F50_kpFe3O4 [itab]; - my_rates->SN0_kpAC [itab0] = F50_kpAC [itab]; - my_rates->SN0_kpSiO2D [itab0] = F50_kpSiO2D [itab]; - my_rates->SN0_kpAl2O3 [itab0] = F50_kpAl2O3 [itab]; - itab0++; - itab ++; - } - } - - return SUCCESS; -} - -int calc_rates_dust_F80(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates) -{ - - int NTd, Nmom; - int iTd, imom, itab0, itab; - - grackle::impl::GrainMetalInjectPathways* inject_pathway_props - = my_rates->opaque_storage->inject_pathway_props; - - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 3.87590e-26; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 2.36180e-13; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN] = 2.48190e-12; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Fe3O4_dust] [iSN] = 3.01120e-15; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust] [iSN] = 8.68025e-03; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust] [iSN] = 3.70132e-14; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Al2O3_dust] [iSN] = 3.77811e-18; - - itab0 = 3 * iSN; - my_rates->SN0_r0FeM [itab0 + 0] = 4.02891e-08; - my_rates->SN0_r0Mg2SiO4 [itab0 + 0] = 5.88698e-08; - my_rates->SN0_r0MgSiO3 [itab0 + 0] = 5.87709e-08; - my_rates->SN0_r0Fe3O4 [itab0 + 0] = 4.03342e-08; - my_rates->SN0_r0AC [itab0 + 0] = 4.22607e-06; - my_rates->SN0_r0SiO2D [itab0 + 0] = 4.03439e-08; - my_rates->SN0_r0Al2O3 [itab0 + 0] = 4.03146e-08; - - my_rates->SN0_r0FeM [itab0 + 1] = 1.67016e-15; - my_rates->SN0_r0Mg2SiO4 [itab0 + 1] = 3.50624e-15; - my_rates->SN0_r0MgSiO3 [itab0 + 1] = 3.49547e-15; - my_rates->SN0_r0Fe3O4 [itab0 + 1] = 1.67365e-15; - my_rates->SN0_r0AC [itab0 + 1] = 2.30435e-11; - my_rates->SN0_r0SiO2D [itab0 + 1] = 1.67461e-15; - my_rates->SN0_r0Al2O3 [itab0 + 1] = 1.67171e-15; - - my_rates->SN0_r0FeM [itab0 + 2] = 7.11339e-23; - my_rates->SN0_r0Mg2SiO4 [itab0 + 2] = 2.10950e-22; - my_rates->SN0_r0MgSiO3 [itab0 + 2] = 2.10029e-22; - my_rates->SN0_r0Fe3O4 [itab0 + 2] = 7.13577e-23; - my_rates->SN0_r0AC [itab0 + 2] = 1.46801e-16; - my_rates->SN0_r0SiO2D [itab0 + 2] = 7.14309e-23; - my_rates->SN0_r0Al2O3 [itab0 + 2] = 7.12106e-23; - - NTd = 35; - Nmom = 4; - - double F80_kpFeM[] = - { 1.23620e-05, 4.98882e-13, 2.07138e-20, 8.83538e-28, - 2.19537e-05, 8.85960e-13, 3.67854e-20, 1.56906e-27, - 3.40288e-05, 1.37326e-12, 5.70184e-20, 2.43208e-27, - 4.92305e-05, 1.98674e-12, 8.24901e-20, 3.51856e-27, - 8.08507e-05, 3.26278e-12, 1.35471e-19, 5.77841e-27, - 1.25019e-04, 5.04514e-12, 2.09472e-19, 8.93477e-27, - 1.96584e-04, 7.93293e-12, 3.29363e-19, 1.40481e-26, - 3.14489e-04, 1.26902e-11, 5.26848e-19, 2.24703e-26, - 5.06846e-04, 2.04508e-11, 8.48987e-19, 3.62076e-26, - 8.07280e-04, 3.25711e-11, 1.35207e-18, 5.76597e-26, - 1.28667e-03, 5.19094e-11, 2.15469e-18, 9.18830e-26, - 2.05240e-03, 8.27959e-11, 3.43651e-18, 1.46534e-25, - 3.27023e-03, 1.31912e-10, 5.47463e-18, 2.33420e-25, - 5.23895e-03, 2.11300e-10, 8.76840e-18, 3.73817e-25, - 8.45019e-03, 3.40772e-10, 1.41393e-17, 6.02717e-25, - 1.37157e-02, 5.53037e-10, 2.29434e-17, 9.77885e-25, - 2.24099e-02, 9.03468e-10, 3.74764e-17, 1.59710e-24, - 3.70041e-02, 1.49164e-09, 6.18661e-17, 2.63618e-24, - 6.21584e-02, 2.50530e-09, 1.03896e-16, 4.42660e-24, - 1.07033e-01, 4.31351e-09, 1.78864e-16, 7.62000e-24, - 1.90089e-01, 7.66007e-09, 3.17606e-16, 1.35297e-23, - 3.49470e-01, 1.40818e-08, 5.83831e-16, 2.48691e-23, - 6.64947e-01, 2.67926e-08, 1.11077e-15, 4.73128e-23, - 1.30413e+00, 5.25455e-08, 2.17837e-15, 9.27841e-23, - 2.61640e+00, 1.05417e-07, 4.37015e-15, 1.86136e-22, - 5.31790e+00, 2.14259e-07, 8.88223e-15, 3.78313e-22, - 1.08366e+01, 4.36604e-07, 1.80995e-14, 7.70889e-22, - 2.19132e+01, 8.82874e-07, 3.65995e-14, 1.55883e-21, - 4.35354e+01, 1.75402e-06, 7.27125e-14, 3.09693e-21, - 8.42362e+01, 3.39383e-06, 1.40690e-13, 5.99219e-21, - 1.57704e+02, 6.35380e-06, 2.63395e-13, 1.12183e-20, - 2.84822e+02, 1.14753e-05, 4.75704e-13, 2.02608e-20, - 4.96653e+02, 2.00098e-05, 8.29500e-13, 3.53294e-20, - 8.39966e+02, 3.38417e-05, 1.40289e-12, 5.97510e-20, - 1.38932e+03, 5.59749e-05, 2.32042e-12, 9.88295e-20 }; - - double F80_kpMg2SiO4[] = - { 1.05240e-01, 6.19546e-09, 3.68996e-16, 2.22004e-23, - 1.32588e-01, 7.80541e-09, 4.64884e-16, 2.79694e-23, - 1.67016e-01, 9.83223e-09, 5.85599e-16, 3.52321e-23, - 2.10360e-01, 1.23838e-08, 7.37570e-16, 4.43753e-23, - 2.71887e-01, 1.60059e-08, 9.53300e-16, 5.73545e-23, - 3.55694e-01, 2.09396e-08, 1.24715e-15, 7.50336e-23, - 4.84932e-01, 2.85479e-08, 1.70029e-15, 1.02296e-22, - 6.99767e-01, 4.11952e-08, 2.45355e-15, 1.47616e-22, - 1.05860e+00, 6.23193e-08, 3.71169e-15, 2.23311e-22, - 1.62902e+00, 9.59000e-08, 5.71172e-15, 3.43641e-22, - 2.54260e+00, 1.49682e-07, 8.91495e-15, 5.36361e-22, - 3.96488e+00, 2.33412e-07, 1.39018e-14, 8.36390e-22, - 6.10630e+00, 3.59476e-07, 2.14101e-14, 1.28812e-21, - 9.28766e+00, 5.46763e-07, 3.25647e-14, 1.95923e-21, - 1.39265e+01, 8.19849e-07, 4.88295e-14, 2.93779e-21, - 2.05382e+01, 1.20908e-06, 7.20119e-14, 4.33254e-21, - 3.00649e+01, 1.76992e-06, 1.05415e-13, 6.34219e-21, - 4.55102e+01, 2.67918e-06, 1.59569e-13, 9.60036e-21, - 7.47839e+01, 4.40251e-06, 2.62210e-13, 1.57756e-20, - 1.29621e+02, 7.63075e-06, 4.54481e-13, 2.73435e-20, - 2.14820e+02, 1.26464e-05, 7.53210e-13, 4.53162e-20, - 3.20002e+02, 1.88384e-05, 1.12200e-12, 6.75043e-20, - 4.29768e+02, 2.53004e-05, 1.50687e-12, 9.06596e-20, - 5.30827e+02, 3.12497e-05, 1.86120e-12, 1.11978e-19, - 5.99694e+02, 3.53039e-05, 2.10267e-12, 1.26505e-19, - 6.06537e+02, 3.57067e-05, 2.12666e-12, 1.27949e-19, - 5.43262e+02, 3.19817e-05, 1.90480e-12, 1.14601e-19, - 4.33545e+02, 2.55227e-05, 1.52011e-12, 9.14563e-20, - 3.13324e+02, 1.84453e-05, 1.09859e-12, 6.60956e-20, - 2.09006e+02, 1.23041e-05, 7.32824e-13, 4.40898e-20, - 1.31150e+02, 7.72078e-06, 4.59843e-13, 2.76661e-20, - 7.90683e+01, 4.65474e-06, 2.77232e-13, 1.66794e-20, - 4.73389e+01, 2.78683e-06, 1.65981e-13, 9.98614e-21, - 2.96409e+01, 1.74496e-06, 1.03928e-13, 6.25275e-21, - 2.04709e+01, 1.20512e-06, 7.17759e-14, 4.31834e-21 }; - - double F80_kpMgSiO3[] = - { 2.19890e-02, 1.29231e-09, 7.68620e-17, 4.61833e-24, - 3.90612e-02, 2.29567e-09, 1.36538e-16, 8.20401e-24, - 6.05539e-02, 3.55881e-09, 2.11665e-16, 1.27181e-23, - 8.76116e-02, 5.14902e-09, 3.06244e-16, 1.84010e-23, - 1.43288e-01, 8.42115e-09, 5.00858e-16, 3.00946e-23, - 2.19266e-01, 1.28865e-08, 7.66440e-16, 4.60523e-23, - 3.36256e-01, 1.97621e-08, 1.17537e-15, 7.06235e-23, - 5.14336e-01, 3.02280e-08, 1.79785e-15, 1.08026e-22, - 7.97216e-01, 4.68532e-08, 2.78665e-15, 1.67439e-22, - 1.25414e+00, 7.37070e-08, 4.38381e-15, 2.63406e-22, - 2.03450e+00, 1.19569e-07, 7.11154e-15, 4.27305e-22, - 3.34648e+00, 1.96676e-07, 1.16975e-14, 7.02858e-22, - 5.45893e+00, 3.20827e-07, 1.90816e-14, 1.14654e-21, - 8.82117e+00, 5.18428e-07, 3.08342e-14, 1.85270e-21, - 1.41825e+01, 8.33519e-07, 4.95746e-14, 2.97874e-21, - 2.28419e+01, 1.34244e-06, 7.98433e-14, 4.79747e-21, - 3.71178e+01, 2.18145e-06, 1.29744e-13, 7.79582e-21, - 6.14272e+01, 3.61014e-06, 2.14717e-13, 1.29015e-20, - 1.03847e+02, 6.10317e-06, 3.62993e-13, 2.18108e-20, - 1.75507e+02, 1.03147e-05, 6.13479e-13, 3.68615e-20, - 2.82060e+02, 1.65769e-05, 9.85934e-13, 5.92409e-20, - 4.14519e+02, 2.43617e-05, 1.44894e-12, 8.70611e-20, - 5.59961e+02, 3.29094e-05, 1.95733e-12, 1.17608e-19, - 7.11024e+02, 4.17876e-05, 2.48537e-12, 1.49336e-19, - 8.40806e+02, 4.94150e-05, 2.93902e-12, 1.76594e-19, - 8.95312e+02, 5.26183e-05, 3.12954e-12, 1.88042e-19, - 8.40415e+02, 4.93920e-05, 2.93765e-12, 1.76512e-19, - 6.96693e+02, 4.09453e-05, 2.43527e-12, 1.46326e-19, - 5.18202e+02, 3.04552e-05, 1.81136e-12, 1.08838e-19, - 3.52864e+02, 2.07382e-05, 1.23343e-12, 7.41118e-20, - 2.24210e+02, 1.31770e-05, 7.83720e-13, 4.70907e-20, - 1.35138e+02, 7.94218e-06, 4.72371e-13, 2.83829e-20, - 7.83119e+01, 4.60247e-06, 2.73737e-13, 1.64478e-20, - 4.41553e+01, 2.59505e-06, 1.54344e-13, 9.27391e-21, - 2.45888e+01, 1.44511e-06, 8.59497e-14, 5.16438e-21 }; - - double F80_kpFe3O4[] = - { 1.47700e-02, 5.95736e-10, 2.47198e-17, 1.05395e-24, - 2.47694e-02, 9.99055e-10, 4.14553e-17, 1.76749e-24, - 3.73580e-02, 1.50680e-09, 6.25240e-17, 2.66578e-24, - 5.32060e-02, 2.14602e-09, 8.90481e-17, 3.79666e-24, - 8.50036e-02, 3.42855e-09, 1.42266e-16, 6.06566e-24, - 1.29213e-01, 5.21170e-09, 2.16257e-16, 9.22034e-24, - 2.00170e-01, 8.07368e-09, 3.35013e-16, 1.42836e-23, - 3.15560e-01, 1.27279e-08, 5.28136e-16, 2.25176e-23, - 5.01384e-01, 2.02229e-08, 8.39139e-16, 3.57776e-23, - 7.88907e-01, 3.18199e-08, 1.32035e-15, 5.62946e-23, - 1.24250e+00, 5.01152e-08, 2.07951e-15, 8.86619e-23, - 1.95225e+00, 7.87422e-08, 3.26737e-15, 1.39308e-22, - 3.04002e+00, 1.22617e-07, 5.08792e-15, 2.16929e-22, - 4.68918e+00, 1.89134e-07, 7.84803e-15, 3.34609e-22, - 7.12599e+00, 2.87421e-07, 1.19264e-14, 5.08494e-22, - 1.05834e+01, 4.26872e-07, 1.77129e-14, 7.55206e-22, - 1.52356e+01, 6.14515e-07, 2.54990e-14, 1.08718e-21, - 2.13345e+01, 8.60511e-07, 3.57065e-14, 1.52238e-21, - 2.98061e+01, 1.20220e-06, 4.98848e-14, 2.12689e-21, - 4.27642e+01, 1.72486e-06, 7.15721e-14, 3.05155e-21, - 6.30370e+01, 2.54254e-06, 1.05502e-13, 4.49817e-21, - 9.29361e+01, 3.74850e-06, 1.55542e-13, 6.63170e-21, - 1.32987e+02, 5.36392e-06, 2.22573e-13, 9.48964e-21, - 1.82150e+02, 7.34689e-06, 3.04855e-13, 1.29978e-20, - 2.40388e+02, 9.69583e-06, 4.02324e-13, 1.71535e-20, - 3.12065e+02, 1.25869e-05, 5.22286e-13, 2.22682e-20, - 4.08414e+02, 1.64730e-05, 6.83540e-13, 2.91435e-20, - 5.49591e+02, 2.21673e-05, 9.19821e-13, 3.92175e-20, - 7.67451e+02, 3.09545e-05, 1.28444e-12, 5.47635e-20, - 1.10725e+03, 4.46602e-05, 1.85315e-12, 7.90111e-20, - 1.62060e+03, 6.53655e-05, 2.71231e-12, 1.15642e-19, - 2.33999e+03, 9.43815e-05, 3.91631e-12, 1.66976e-19, - 3.24367e+03, 1.30831e-04, 5.42876e-12, 2.31461e-19, - 4.25716e+03, 1.71709e-04, 7.12499e-12, 3.03781e-19, - 5.34010e+03, 2.15389e-04, 8.93744e-12, 3.81058e-19 }; - - double F80_kpAC[] = - { 3.27960e-01, 1.38598e-06, 7.55735e-12, 4.81450e-17, - 4.38752e-01, 1.85420e-06, 1.01104e-11, 6.44096e-17, - 5.78230e-01, 2.44365e-06, 1.33245e-11, 8.48855e-17, - 7.53823e-01, 3.18572e-06, 1.73708e-11, 1.10663e-16, - 1.04016e+00, 4.39581e-06, 2.39692e-11, 1.52700e-16, - 1.41740e+00, 5.99012e-06, 3.26627e-11, 2.08084e-16, - 1.95298e+00, 8.25351e-06, 4.50044e-11, 2.86710e-16, - 2.71536e+00, 1.14754e-05, 6.25729e-11, 3.98636e-16, - 3.79688e+00, 1.60461e-05, 8.74963e-11, 5.57421e-16, - 5.29770e+00, 2.23889e-05, 1.22083e-10, 7.77774e-16, - 7.37879e+00, 3.11841e-05, 1.70043e-10, 1.08333e-15, - 1.02177e+01, 4.31826e-05, 2.35472e-10, 1.50021e-15, - 1.40437e+01, 5.93525e-05, 3.23651e-10, 2.06204e-15, - 1.92054e+01, 8.11692e-05, 4.42628e-10, 2.82017e-15, - 2.61678e+01, 1.10598e-04, 6.03124e-10, 3.84293e-15, - 3.55420e+01, 1.50223e-04, 8.19247e-10, 5.22035e-15, - 4.81826e+01, 2.03661e-04, 1.11074e-09, 7.07845e-15, - 6.53571e+01, 2.76274e-04, 1.50689e-09, 9.60430e-15, - 8.88432e+01, 3.75591e-04, 2.04885e-09, 1.30610e-14, - 1.20848e+02, 5.10965e-04, 2.78778e-09, 1.77762e-14, - 1.63896e+02, 6.93122e-04, 3.78255e-09, 2.41285e-14, - 2.21094e+02, 9.35280e-04, 5.10587e-09, 3.25877e-14, - 2.97091e+02, 1.25728e-03, 6.86710e-09, 4.38623e-14, - 3.98900e+02, 1.68904e-03, 9.23101e-09, 5.90159e-14, - 5.35045e+02, 2.26701e-03, 1.23979e-08, 7.93362e-14, - 7.13531e+02, 3.02568e-03, 1.65576e-08, 1.06036e-13, - 9.43152e+02, 4.00348e-03, 2.19225e-08, 1.40472e-13, - 1.23958e+03, 5.26932e-03, 2.88749e-08, 1.85093e-13, - 1.63174e+03, 6.95105e-03, 3.81274e-08, 2.44493e-13, - 2.16646e+03, 9.25803e-03, 5.08543e-08, 3.26274e-13, - 2.91544e+03, 1.25164e-02, 6.89019e-08, 4.42468e-13, - 3.98965e+03, 1.72412e-02, 9.52155e-08, 6.12399e-13, - 5.56191e+03, 2.42454e-02, 1.34481e-07, 8.66957e-13, - 7.88390e+03, 3.47095e-02, 1.93494e-07, 1.25089e-12, - 1.12585e+04, 4.99889e-02, 2.79860e-07, 1.81329e-12 }; - - double F80_kpSiO2D[] = - { 7.60360e-02, 3.06759e-09, 1.27330e-16, 5.43132e-24, - 9.07207e-02, 3.66003e-09, 1.51922e-16, 6.48026e-24, - 1.09208e-01, 4.40586e-09, 1.82880e-16, 7.80079e-24, - 1.32481e-01, 5.34481e-09, 2.21854e-16, 9.46325e-24, - 1.58907e-01, 6.41094e-09, 2.66108e-16, 1.13509e-23, - 1.91565e-01, 7.72847e-09, 3.20796e-16, 1.36836e-23, - 2.30490e-01, 9.29887e-09, 3.85981e-16, 1.64641e-23, - 2.76795e-01, 1.11670e-08, 4.63523e-16, 1.97717e-23, - 3.33074e-01, 1.34375e-08, 5.57768e-16, 2.37917e-23, - 4.05325e-01, 1.63524e-08, 6.78759e-16, 2.89527e-23, - 5.08160e-01, 2.05012e-08, 8.50969e-16, 3.62983e-23, - 6.72472e-01, 2.71301e-08, 1.12613e-15, 4.80353e-23, - 9.48549e-01, 3.82682e-08, 1.58845e-15, 6.77557e-23, - 1.41787e+00, 5.72025e-08, 2.37438e-15, 1.01280e-22, - 2.19502e+00, 8.85555e-08, 3.67579e-15, 1.56792e-22, - 3.46719e+00, 1.39880e-07, 5.80619e-15, 2.47665e-22, - 5.76852e+00, 2.32725e-07, 9.66001e-15, 4.12050e-22, - 1.17194e+01, 4.72806e-07, 1.96254e-14, 8.37126e-22, - 3.16449e+01, 1.27668e-06, 5.29928e-14, 2.26042e-21, - 8.68296e+01, 3.50304e-06, 1.45406e-13, 6.20231e-21, - 1.92300e+02, 7.75813e-06, 3.22027e-13, 1.37362e-20, - 3.36231e+02, 1.35649e-05, 5.63055e-13, 2.40173e-20, - 5.05825e+02, 2.04070e-05, 8.47058e-13, 3.61315e-20, - 7.20624e+02, 2.90728e-05, 1.20676e-12, 5.14748e-20, - 9.77376e+02, 3.94312e-05, 1.63672e-12, 6.98148e-20, - 1.18646e+03, 4.78662e-05, 1.98685e-12, 8.47495e-20, - 1.23845e+03, 4.99638e-05, 2.07391e-12, 8.84633e-20, - 1.11188e+03, 4.48576e-05, 1.86197e-12, 7.94227e-20, - 8.76396e+02, 3.53572e-05, 1.46762e-12, 6.26017e-20, - 6.22207e+02, 2.51022e-05, 1.04195e-12, 4.44448e-20, - 4.07290e+02, 1.64317e-05, 6.82051e-13, 2.90931e-20, - 2.50573e+02, 1.01091e-05, 4.19611e-13, 1.78986e-20, - 1.47073e+02, 5.93352e-06, 2.46290e-13, 1.05056e-20, - 8.33122e+01, 3.36114e-06, 1.39515e-13, 5.95106e-21, - 4.59585e+01, 1.85415e-06, 7.69625e-14, 3.28286e-21 }; - - double F80_kpAl2O3[] = - { 9.93250e-04, 4.00425e-11, 1.66043e-18, 7.07300e-26, - 1.81240e-03, 7.30662e-11, 3.02981e-18, 1.29062e-25, - 2.84365e-03, 1.14641e-10, 4.75377e-18, 2.02498e-25, - 4.14191e-03, 1.66980e-10, 6.92409e-18, 2.94948e-25, - 7.18271e-03, 2.89568e-10, 1.20074e-17, 5.11485e-25, - 1.13364e-02, 4.57021e-10, 1.89512e-17, 8.07269e-25, - 1.77361e-02, 7.15022e-10, 2.96496e-17, 1.26300e-24, - 2.59477e-02, 1.04607e-09, 4.33772e-17, 1.84775e-24, - 3.45425e-02, 1.39257e-09, 5.77452e-17, 2.45980e-24, - 4.22006e-02, 1.70130e-09, 7.05474e-17, 3.00513e-24, - 4.71420e-02, 1.90051e-09, 7.88080e-17, 3.35701e-24, - 4.91934e-02, 1.98321e-09, 8.22373e-17, 3.50309e-24, - 5.05162e-02, 2.03654e-09, 8.44486e-17, 3.59729e-24, - 5.78201e-02, 2.33100e-09, 9.66587e-17, 4.11741e-24, - 8.84237e-02, 3.56477e-09, 1.47819e-16, 6.29671e-24, - 1.78786e-01, 7.20770e-09, 2.98879e-16, 1.27315e-23, - 4.36404e-01, 1.75935e-08, 7.29543e-16, 3.10766e-23, - 1.63796e+00, 6.60337e-08, 2.73820e-15, 1.16640e-22, - 8.50817e+00, 3.43004e-07, 1.42232e-14, 6.05872e-22, - 3.92751e+01, 1.58336e-06, 6.56567e-14, 2.79680e-21, - 1.41436e+02, 5.70194e-06, 2.36441e-13, 1.00718e-20, - 3.83709e+02, 1.54691e-05, 6.41451e-13, 2.73241e-20, - 7.70411e+02, 3.10588e-05, 1.28791e-12, 5.48615e-20, - 1.16399e+03, 4.69258e-05, 1.94586e-12, 8.28884e-20, - 1.37566e+03, 5.54594e-05, 2.29972e-12, 9.79619e-20, - 1.33070e+03, 5.36466e-05, 2.22455e-12, 9.47599e-20, - 1.09978e+03, 4.43371e-05, 1.83852e-12, 7.83159e-20, - 8.05638e+02, 3.24790e-05, 1.34680e-12, 5.73700e-20, - 5.38690e+02, 2.17171e-05, 9.00536e-13, 3.83605e-20, - 3.36338e+02, 1.35593e-05, 5.62261e-13, 2.39508e-20, - 1.99460e+02, 8.04115e-06, 3.33440e-13, 1.42037e-20, - 1.13787e+02, 4.58729e-06, 1.90220e-13, 8.10285e-21, - 6.30411e+01, 2.54148e-06, 1.05387e-13, 4.48920e-21, - 3.41529e+01, 1.37686e-06, 5.70939e-14, 2.43205e-21, - 1.81893e+01, 7.33293e-07, 3.04073e-14, 1.29527e-21 }; - - - itab0 = Nmom * NTd * iSN; - itab = 0; - for(imom = 0; imom < Nmom; imom++) { - for(iTd = 0; iTd < NTd; iTd++) { - my_rates->SN0_kpFeM [itab0] = F80_kpFeM [itab]; - my_rates->SN0_kpMg2SiO4 [itab0] = F80_kpMg2SiO4 [itab]; - my_rates->SN0_kpMgSiO3 [itab0] = F80_kpMgSiO3 [itab]; - my_rates->SN0_kpFe3O4 [itab0] = F80_kpFe3O4 [itab]; - my_rates->SN0_kpAC [itab0] = F80_kpAC [itab]; - my_rates->SN0_kpSiO2D [itab0] = F80_kpSiO2D [itab]; - my_rates->SN0_kpAl2O3 [itab0] = F80_kpAl2O3 [itab]; - itab0++; - itab ++; - } - } - - return SUCCESS; -} - -int calc_rates_dust_P170(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates) -{ - - int NTd, Nmom; - int iTd, imom, itab0, itab; - - grackle::impl::GrainMetalInjectPathways* inject_pathway_props - = my_rates->opaque_storage->inject_pathway_props; - - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust] [iSN] = 1.31079e-02; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 3.34688e-05; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 2.84952e-13; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN] = 7.72302e-25; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust] [iSN] = 4.47758e-05; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust] [iSN] = 1.23405e-04; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgO_dust] [iSN] = 1.41247e-07; - - itab0 = 3 * iSN; - my_rates->SN0_r0SiM [itab0 + 0] = 2.72050e-06; - my_rates->SN0_r0FeM [itab0 + 0] = 1.08069e-05; - my_rates->SN0_r0Mg2SiO4 [itab0 + 0] = 1.79010e-05; - my_rates->SN0_r0MgSiO3 [itab0 + 0] = 2.51189e-05; - my_rates->SN0_r0AC [itab0 + 0] = 8.32266e-07; - my_rates->SN0_r0SiO2D [itab0 + 0] = 2.12560e-05; - my_rates->SN0_r0MgO [itab0 + 0] = 1.60812e-05; - - my_rates->SN0_r0SiM [itab0 + 1] = 2.87427e-11; - my_rates->SN0_r0FeM [itab0 + 1] = 1.19634e-10; - my_rates->SN0_r0Mg2SiO4 [itab0 + 1] = 3.24658e-10; - my_rates->SN0_r0MgSiO3 [itab0 + 1] = 6.30957e-10; - my_rates->SN0_r0AC [itab0 + 1] = 1.33383e-12; - my_rates->SN0_r0SiO2D [itab0 + 1] = 4.59721e-10; - my_rates->SN0_r0MgO [itab0 + 1] = 2.65603e-10; - - my_rates->SN0_r0SiM [itab0 + 2] = 7.09270e-16; - my_rates->SN0_r0FeM [itab0 + 2] = 1.36724e-15; - my_rates->SN0_r0Mg2SiO4 [itab0 + 2] = 5.96244e-15; - my_rates->SN0_r0MgSiO3 [itab0 + 2] = 1.58489e-14; - my_rates->SN0_r0AC [itab0 + 2] = 4.37739e-18; - my_rates->SN0_r0SiO2D [itab0 + 2] = 1.01590e-14; - my_rates->SN0_r0MgO [itab0 + 2] = 4.50188e-15; - - NTd = 35; - Nmom = 4; - - double P170_kpSiM[] = - { 1.54566e-01, 4.18815e-07, 4.38802e-12, 1.07634e-16, - 1.94597e-01, 5.27516e-07, 5.53200e-12, 1.35785e-16, - 2.44992e-01, 6.64362e-07, 6.97216e-12, 1.71223e-16, - 3.08437e-01, 8.36640e-07, 8.78521e-12, 2.15837e-16, - 3.88320e-01, 1.05373e-06, 1.10736e-11, 2.72217e-16, - 4.88890e-01, 1.32707e-06, 1.39559e-11, 3.43241e-16, - 6.15507e-01, 1.67134e-06, 1.75891e-11, 4.32825e-16, - 7.74906e-01, 2.10492e-06, 2.21686e-11, 5.45804e-16, - 9.75270e-01, 2.65013e-06, 2.79315e-11, 6.88059e-16, - 1.22485e+00, 3.32948e-06, 3.51169e-11, 8.65513e-16, - 1.52110e+00, 4.13615e-06, 4.36560e-11, 1.07652e-15, - 1.83679e+00, 4.99624e-06, 5.27698e-11, 1.30190e-15, - 2.15666e+00, 5.86838e-06, 6.20278e-11, 1.53115e-15, - 2.55518e+00, 6.95661e-06, 7.36137e-11, 1.81866e-15, - 3.22834e+00, 8.79676e-06, 9.32496e-11, 2.30667e-15, - 4.33225e+00, 1.18177e-05, 1.25559e-10, 3.11092e-15, - 5.81697e+00, 1.58892e-05, 1.69288e-10, 4.20258e-15, - 7.48671e+00, 2.04890e-05, 2.19146e-10, 5.45508e-15, - 9.22042e+00, 2.53165e-05, 2.72602e-10, 6.81745e-15, - 1.12094e+01, 3.09883e-05, 3.38326e-10, 8.54226e-15, - 1.40327e+01, 3.92793e-05, 4.39589e-10, 1.12871e-14, - 1.79556e+01, 5.11182e-05, 5.91090e-10, 1.55105e-14, - 2.19076e+01, 6.38759e-05, 7.72200e-10, 2.08556e-14, - 2.40396e+01, 7.32505e-05, 9.56570e-10, 2.71081e-14, - 2.35050e+01, 7.74606e-05, 1.14341e-09, 3.48207e-14, - 2.10698e+01, 7.75334e-05, 1.32500e-09, 4.37333e-14, - 1.81145e+01, 7.52350e-05, 1.46962e-09, 5.20115e-14, - 1.55283e+01, 7.16932e-05, 1.54535e-09, 5.74821e-14, - 1.35973e+01, 6.77513e-05, 1.55041e-09, 5.93660e-14, - 1.28568e+01, 6.72854e-05, 1.57294e-09, 6.05730e-14, - 1.62414e+01, 9.03391e-05, 2.02876e-09, 7.45675e-14, - 3.62078e+01, 2.25165e-04, 4.46960e-09, 1.44123e-13, - 1.13353e+02, 7.52538e-04, 1.29670e-08, 3.61005e-13, - 3.52139e+02, 2.31091e-03, 3.53205e-08, 8.74277e-13, - 9.61671e+02, 5.84143e-03, 8.01724e-08, 1.81153e-12 }; - - double P170_kpFeM[] = - { 1.89038e-02, 2.14190e-07, 2.52372e-12, 3.12761e-17, - 3.29962e-02, 3.72180e-07, 4.35946e-12, 5.36210e-17, - 5.06585e-02, 5.69928e-07, 6.65321e-12, 8.14803e-17, - 7.28477e-02, 8.18206e-07, 9.53077e-12, 1.16395e-16, - 1.17388e-01, 1.31311e-06, 1.52141e-11, 1.84531e-16, - 1.77851e-01, 1.98324e-06, 2.28841e-11, 2.76089e-16, - 2.70459e-01, 3.00576e-06, 3.45287e-11, 4.14188e-16, - 4.11194e-01, 4.55413e-06, 5.20790e-11, 6.21046e-16, - 6.23355e-01, 6.88052e-06, 7.83314e-11, 9.28691e-16, - 9.33206e-01, 1.02680e-05, 1.16407e-10, 1.37259e-15, - 1.38665e+00, 1.52105e-05, 1.71743e-10, 2.01438e-15, - 2.02921e+00, 2.21948e-05, 2.49647e-10, 2.91351e-15, - 2.90114e+00, 3.16481e-05, 3.54739e-10, 4.12109e-15, - 4.04178e+00, 4.39869e-05, 4.91497e-10, 5.68634e-15, - 5.48102e+00, 5.95254e-05, 6.63275e-10, 7.64576e-15, - 7.23953e+00, 7.84801e-05, 8.72371e-10, 1.00241e-14, - 9.32332e+00, 1.00911e-04, 1.11939e-09, 1.28274e-14, - 1.17250e+01, 1.26738e-04, 1.40342e-09, 1.60451e-14, - 1.44493e+01, 1.56015e-04, 1.72511e-09, 1.96853e-14, - 1.75655e+01, 1.89497e-04, 2.09290e-09, 2.38454e-14, - 2.12689e+01, 2.29295e-04, 2.53020e-09, 2.87941e-14, - 2.59441e+01, 2.79574e-04, 3.08321e-09, 3.50603e-14, - 3.22597e+01, 3.47571e-04, 3.83222e-09, 4.35643e-14, - 4.13113e+01, 4.45148e-04, 4.90883e-09, 5.58148e-14, - 5.48617e+01, 5.91330e-04, 6.52336e-09, 7.42101e-14, - 7.57474e+01, 8.16590e-04, 9.01042e-09, 1.02534e-13, - 1.08611e+02, 1.17059e-03, 1.29124e-08, 1.46875e-13, - 1.61171e+02, 1.73570e-03, 1.91260e-08, 2.17252e-13, - 2.46323e+02, 2.64930e-03, 2.91428e-08, 3.30280e-13, - 3.85260e+02, 4.13661e-03, 4.54013e-08, 5.13015e-13, - 6.12075e+02, 6.55899e-03, 7.17997e-08, 8.08495e-13, - 9.79548e+02, 1.04742e-02, 1.14330e-07, 1.28253e-12, - 1.56260e+03, 1.66712e-02, 1.81431e-07, 2.02722e-12, - 2.44258e+03, 2.60024e-02, 2.82158e-07, 3.14054e-12, - 3.65611e+03, 3.88442e-02, 4.20404e-07, 4.66303e-12 }; - - double P170_kpMg2SiO4[] = - { 1.05240e-01, 1.88391e-06, 3.41670e-11, 6.27487e-16, - 1.32588e-01, 2.37346e-06, 4.30456e-11, 7.90546e-16, - 1.67016e-01, 2.98977e-06, 5.42231e-11, 9.95825e-16, - 2.10360e-01, 3.76566e-06, 6.82948e-11, 1.25426e-15, - 2.71891e-01, 4.86713e-06, 8.82715e-11, 1.62113e-15, - 3.55703e-01, 6.36747e-06, 1.15482e-10, 2.12086e-15, - 4.84952e-01, 8.68116e-06, 1.57444e-10, 2.89150e-15, - 6.99815e-01, 1.25274e-05, 2.27201e-10, 4.17262e-15, - 1.05872e+00, 1.89523e-05, 3.43724e-10, 6.31261e-15, - 1.62931e+00, 2.91665e-05, 5.28972e-10, 9.71478e-15, - 2.54332e+00, 4.55285e-05, 8.25720e-10, 1.51647e-14, - 3.96674e+00, 7.10095e-05, 1.28786e-09, 2.36521e-14, - 6.11063e+00, 1.09388e-04, 1.98392e-09, 3.64359e-14, - 9.29771e+00, 1.66443e-04, 3.01871e-09, 5.54408e-14, - 1.39496e+01, 2.49721e-04, 4.52916e-09, 8.31823e-14, - 2.05907e+01, 3.68616e-04, 6.68568e-09, 1.22791e-13, - 3.01907e+01, 5.40495e-04, 9.80342e-09, 1.80058e-13, - 4.58362e+01, 8.20646e-04, 1.48857e-08, 2.73420e-13, - 7.56329e+01, 1.35424e-03, 2.45668e-08, 4.51281e-13, - 1.31563e+02, 2.35588e-03, 4.27405e-08, 7.85179e-13, - 2.18570e+02, 3.91412e-03, 7.10137e-08, 1.30465e-12, - 3.26293e+02, 5.84347e-03, 1.06022e-07, 1.94790e-12, - 4.39310e+02, 7.86786e-03, 1.42760e-07, 2.62299e-12, - 5.43909e+02, 9.74168e-03, 1.76768e-07, 3.24798e-12, - 6.15422e+02, 1.10228e-02, 2.00021e-07, 3.67534e-12, - 6.22866e+02, 1.11563e-02, 2.02446e-07, 3.71993e-12, - 5.58030e+02, 9.99504e-03, 1.81374e-07, 3.33274e-12, - 4.45434e+02, 7.97833e-03, 1.44778e-07, 2.66031e-12, - 3.22068e+02, 5.76874e-03, 1.04683e-07, 1.92357e-12, - 2.15071e+02, 3.85233e-03, 6.99082e-08, 1.28461e-12, - 1.35309e+02, 2.42376e-03, 4.39862e-08, 8.08311e-13, - 8.22952e+01, 1.47437e-03, 2.67608e-08, 4.91842e-13, - 5.06858e+01, 9.08497e-04, 1.64974e-08, 3.03339e-13, - 3.39204e+01, 6.08602e-04, 1.10623e-08, 2.03592e-13, - 2.60778e+01, 4.68473e-04, 8.52552e-09, 1.57083e-13 }; - - double P170_kpMgSiO3[] = - { 2.19890e-02, 5.52339e-07, 1.38741e-11, 3.48502e-16, - 3.90618e-02, 9.81187e-07, 2.46463e-11, 6.19087e-16, - 6.05551e-02, 1.52108e-06, 3.82077e-11, 9.59734e-16, - 8.76136e-02, 2.20075e-06, 5.52805e-11, 1.38858e-15, - 1.43295e-01, 3.59940e-06, 9.04128e-11, 2.27107e-15, - 2.19281e-01, 5.50809e-06, 1.38357e-10, 3.47537e-15, - 3.36283e-01, 8.44705e-06, 2.12180e-10, 5.32973e-15, - 5.14405e-01, 1.29213e-05, 3.24567e-10, 8.15276e-15, - 7.97396e-01, 2.00297e-05, 5.03123e-10, 1.26379e-14, - 1.25461e+00, 3.15143e-05, 7.91604e-10, 1.98842e-14, - 2.03570e+00, 5.11345e-05, 1.28444e-09, 3.22637e-14, - 3.34964e+00, 8.41390e-05, 2.11348e-09, 5.30881e-14, - 5.46697e+00, 1.37324e-04, 3.44942e-09, 8.66456e-14, - 8.84149e+00, 2.22088e-04, 5.57860e-09, 1.40128e-13, - 1.42340e+01, 3.57543e-04, 8.98107e-09, 2.25594e-13, - 2.29730e+01, 5.77056e-04, 1.44950e-08, 3.64097e-13, - 3.74525e+01, 9.40765e-04, 2.36310e-08, 5.93583e-13, - 6.22721e+01, 1.56420e-03, 3.92910e-08, 9.86946e-13, - 1.05860e+02, 2.65909e-03, 6.67934e-08, 1.67777e-12, - 1.79797e+02, 4.51630e-03, 1.13444e-07, 2.84959e-12, - 2.89938e+02, 7.28291e-03, 1.82938e-07, 4.59521e-12, - 4.27133e+02, 1.07291e-02, 2.69503e-07, 6.76961e-12, - 5.77898e+02, 1.45162e-02, 3.64629e-07, 9.15907e-12, - 7.33244e+02, 1.84183e-02, 4.62646e-07, 1.16211e-11, - 8.63989e+02, 2.17024e-02, 5.45140e-07, 1.36933e-11, - 9.15488e+02, 2.29960e-02, 5.77634e-07, 1.45095e-11, - 8.55336e+02, 2.14851e-02, 5.39680e-07, 1.35562e-11, - 7.06445e+02, 1.77451e-02, 4.45737e-07, 1.11964e-11, - 5.24103e+02, 1.31649e-02, 3.30686e-07, 8.30647e-12, - 3.56328e+02, 8.95056e-03, 2.24828e-07, 5.64742e-12, - 2.26296e+02, 5.68431e-03, 1.42783e-07, 3.58656e-12, - 1.36494e+02, 3.42857e-03, 8.61218e-08, 2.16328e-12, - 7.93347e+01, 1.99280e-03, 5.00568e-08, 1.25737e-12, - 4.50672e+01, 1.13204e-03, 2.84355e-08, 7.14267e-13, - 2.56082e+01, 6.43249e-04, 1.61577e-08, 4.05863e-13 }; - - double P170_kpAC[] = - { 3.27960e-01, 2.72950e-07, 4.37442e-13, 1.43560e-18, - 4.38752e-01, 3.65158e-07, 5.85222e-13, 1.92064e-18, - 5.78230e-01, 4.81242e-07, 7.71265e-13, 2.53127e-18, - 7.53823e-01, 6.27382e-07, 1.00548e-12, 3.30001e-18, - 1.04013e+00, 8.65671e-07, 1.38740e-12, 4.55369e-18, - 1.41735e+00, 1.17963e-06, 1.89059e-12, 6.20550e-18, - 1.95292e+00, 1.62537e-06, 2.60499e-12, 8.55074e-18, - 2.71531e+00, 2.25988e-06, 3.62196e-12, 1.18896e-17, - 3.79676e+00, 3.15995e-06, 5.06464e-12, 1.66270e-17, - 5.29743e+00, 4.40895e-06, 7.06667e-12, 2.32024e-17, - 7.37835e+00, 6.14088e-06, 9.84291e-12, 3.23229e-17, - 1.02168e+01, 8.50337e-06, 1.36303e-11, 4.47703e-17, - 1.40421e+01, 1.16873e-05, 1.87349e-11, 6.15552e-17, - 1.92022e+01, 1.59823e-05, 2.56223e-11, 8.42199e-17, - 2.61618e+01, 2.17754e-05, 3.49137e-11, 1.14828e-16, - 3.55310e+01, 2.95745e-05, 4.74267e-11, 1.56111e-16, - 4.81618e+01, 4.00896e-05, 6.43047e-11, 2.11918e-16, - 6.53182e+01, 5.43738e-05, 8.72469e-11, 2.88010e-16, - 8.87691e+01, 7.39018e-05, 1.18639e-10, 3.92576e-16, - 1.20709e+02, 1.00504e-04, 1.61458e-10, 5.36074e-16, - 1.63629e+02, 1.36264e-04, 2.19128e-10, 7.31160e-16, - 2.20590e+02, 1.83746e-04, 2.95924e-10, 9.94659e-16, - 2.96134e+02, 2.46760e-04, 3.98255e-10, 1.35250e-15, - 3.97082e+02, 3.31036e-04, 5.35697e-10, 1.84221e-15, - 5.31629e+02, 4.43468e-04, 7.19648e-10, 2.50526e-15, - 7.07172e+02, 5.90324e-04, 9.60341e-10, 3.37390e-15, - 9.31294e+02, 7.78129e-04, 1.26840e-09, 4.47614e-15, - 1.21722e+03, 1.01834e-03, 1.66280e-09, 5.86569e-15, - 1.58885e+03, 1.33177e-03, 2.17875e-09, 7.65284e-15, - 2.08299e+03, 1.75095e-03, 2.87268e-09, 1.00241e-14, - 2.75132e+03, 2.32265e-03, 3.82862e-09, 1.32680e-14, - 3.66587e+03, 3.11403e-03, 5.17218e-09, 1.78307e-14, - 4.93093e+03, 4.22440e-03, 7.09398e-09, 2.43990e-14, - 6.70346e+03, 5.80132e-03, 9.87242e-09, 3.39492e-14, - 9.22475e+03, 8.05642e-03, 1.38679e-08, 4.76003e-14 }; - - double P170_kpSiO2D[] = - { 7.60055e-02, 1.61556e-06, 3.49407e-11, 7.72118e-16, - 9.06897e-02, 1.92769e-06, 4.16913e-11, 9.21295e-16, - 1.09176e-01, 2.32063e-06, 5.01898e-11, 1.10910e-15, - 1.32449e-01, 2.81532e-06, 6.08888e-11, 1.34553e-15, - 1.58880e-01, 3.37714e-06, 7.30398e-11, 1.61404e-15, - 1.91543e-01, 4.07143e-06, 8.80558e-11, 1.94587e-15, - 2.30474e-01, 4.89894e-06, 1.05953e-10, 2.34138e-15, - 2.76789e-01, 5.88341e-06, 1.27245e-10, 2.81190e-15, - 3.33087e-01, 7.08010e-06, 1.53127e-10, 3.38385e-15, - 4.05372e-01, 8.61660e-06, 1.86359e-10, 4.11822e-15, - 5.08264e-01, 1.08037e-05, 2.33661e-10, 5.16354e-15, - 6.72714e-01, 1.42993e-05, 3.09265e-10, 6.83430e-15, - 9.49132e-01, 2.01750e-05, 4.36348e-10, 9.64271e-15, - 1.41935e+00, 3.01704e-05, 6.52536e-10, 1.44204e-14, - 2.19866e+00, 4.67362e-05, 1.01084e-09, 2.23390e-14, - 3.47731e+00, 7.39180e-05, 1.59880e-09, 3.53339e-14, - 5.80454e+00, 1.23397e-04, 2.66922e-09, 5.89965e-14, - 1.18802e+01, 2.52595e-04, 5.46495e-09, 1.20817e-13, - 3.22814e+01, 6.86446e-04, 1.48537e-08, 3.28442e-13, - 8.86792e+01, 1.88575e-03, 4.08062e-08, 9.02327e-13, - 1.96255e+02, 4.17327e-03, 9.03045e-08, 1.99681e-12, - 3.42549e+02, 7.28388e-03, 1.57607e-07, 3.48479e-12, - 5.11736e+02, 1.08798e-02, 2.35370e-07, 5.20299e-12, - 7.16479e+02, 1.52272e-02, 3.29269e-07, 7.27459e-12, - 9.48899e+02, 2.01568e-02, 4.35598e-07, 9.61645e-12, - 1.12707e+03, 2.39309e-02, 5.16871e-07, 1.14029e-11, - 1.15762e+03, 2.45716e-02, 5.30490e-07, 1.16974e-11, - 1.02786e+03, 2.18125e-02, 4.70793e-07, 1.03775e-11, - 8.04358e+02, 1.70671e-02, 3.68303e-07, 8.11658e-12, - 5.68400e+02, 1.20593e-02, 2.60207e-07, 5.73357e-12, - 3.70952e+02, 7.86976e-03, 1.69795e-07, 3.74103e-12, - 2.27785e+02, 4.83229e-03, 1.04255e-07, 2.29687e-12, - 1.33544e+02, 2.83297e-03, 6.11184e-08, 1.34647e-12, - 7.56194e+01, 1.60416e-03, 3.46077e-08, 7.62416e-13, - 4.17402e+01, 8.85464e-04, 1.91029e-08, 4.20847e-13 }; - - double P170_kpMgO[] = - { 2.25358e-04, 3.62400e-09, 5.98548e-14, 1.01451e-18, - 4.04933e-04, 6.51178e-09, 1.07551e-13, 1.82293e-18, - 6.31005e-04, 1.01473e-08, 1.67596e-13, 2.84068e-18, - 9.15612e-04, 1.47241e-08, 2.43188e-13, 4.12194e-18, - 1.52196e-03, 2.44750e-08, 4.04238e-13, 6.85169e-18, - 2.37413e-03, 3.81788e-08, 6.30577e-13, 1.06881e-17, - 3.77230e-03, 6.06633e-08, 1.00194e-12, 1.69826e-17, - 6.14410e-03, 9.88050e-08, 1.63191e-12, 2.76605e-17, - 1.01925e-02, 1.63910e-07, 2.70723e-12, 4.58870e-17, - 1.68946e-02, 2.71691e-07, 4.48743e-12, 7.60616e-17, - 2.96294e-02, 4.76492e-07, 7.87018e-12, 1.33401e-16, - 6.11307e-02, 9.83118e-07, 1.62386e-11, 2.75255e-16, - 1.43660e-01, 2.31047e-06, 3.81646e-11, 6.46939e-16, - 3.28203e-01, 5.27865e-06, 8.71964e-11, 1.47815e-15, - 6.41613e-01, 1.03199e-05, 1.70479e-10, 2.89009e-15, - 1.05901e+00, 1.70371e-05, 2.81505e-10, 4.77324e-15, - 1.60722e+00, 2.58913e-05, 4.28363e-10, 7.27252e-15, - 3.19739e+00, 5.16560e-05, 8.57040e-10, 1.45895e-14, - 1.40905e+01, 2.27322e-04, 3.76636e-09, 6.40310e-14, - 7.15093e+01, 1.15025e-03, 1.90029e-08, 3.22170e-13, - 2.48952e+02, 3.99764e-03, 6.59323e-08, 1.11600e-12, - 5.77048e+02, 9.25757e-03, 1.52545e-07, 2.57979e-12, - 9.46693e+02, 1.51796e-02, 2.49995e-07, 4.22569e-12, - 1.17600e+03, 1.88501e-02, 3.10343e-07, 5.24410e-12, - 1.17447e+03, 1.88215e-02, 3.09806e-07, 5.23395e-12, - 9.91612e+02, 1.58888e-02, 2.61497e-07, 4.41720e-12, - 7.37095e+02, 1.18095e-02, 1.94341e-07, 3.28252e-12, - 4.97965e+02, 7.97772e-03, 1.31276e-07, 2.21717e-12, - 3.13212e+02, 5.01764e-03, 8.25631e-08, 1.39438e-12, - 1.86742e+02, 2.99150e-03, 4.92223e-08, 8.31277e-13, - 1.06960e+02, 1.71340e-03, 2.81918e-08, 4.76098e-13, - 5.94287e+01, 9.51978e-04, 1.56633e-08, 2.64516e-13, - 3.22675e+01, 5.16881e-04, 8.50437e-09, 1.43617e-13, - 1.72142e+01, 2.75746e-04, 4.53688e-09, 7.66156e-14, - 9.06015e+00, 1.45130e-04, 2.38782e-09, 4.03237e-14 }; - - - itab0 = Nmom * NTd * iSN; - itab = 0; - for(imom = 0; imom < Nmom; imom++) { - for(iTd = 0; iTd < NTd; iTd++) { - my_rates->SN0_kpSiM [itab0] = P170_kpSiM [itab]; - my_rates->SN0_kpFeM [itab0] = P170_kpFeM [itab]; - my_rates->SN0_kpMg2SiO4 [itab0] = P170_kpMg2SiO4 [itab]; - my_rates->SN0_kpMgSiO3 [itab0] = P170_kpMgSiO3 [itab]; - my_rates->SN0_kpAC [itab0] = P170_kpAC [itab]; - my_rates->SN0_kpSiO2D [itab0] = P170_kpSiO2D [itab]; - my_rates->SN0_kpMgO [itab0] = P170_kpMgO [itab]; - itab0++; - itab ++; - } - } - - return SUCCESS; -} - -int calc_rates_dust_P200(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates) -{ - - int NTd, Nmom; - int iTd, imom, itab0, itab; - - grackle::impl::GrainMetalInjectPathways* inject_pathway_props - = my_rates->opaque_storage->inject_pathway_props; - - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust] [iSN] = 5.90622e-05; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = 4.26809e-04; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = 4.08246e-15; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust] [iSN] = 3.72287e-05; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust] [iSN] = 4.59330e-04; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgO_dust] [iSN] = 5.38389e-09; - - itab0 = 3 * iSN; - my_rates->SN0_r0SiM [itab0 + 0] = 8.86269e-07; - my_rates->SN0_r0FeM [itab0 + 0] = 2.02272e-06; - my_rates->SN0_r0Mg2SiO4 [itab0 + 0] = 1.42189e-05; - my_rates->SN0_r0AC [itab0 + 0] = 7.46096e-07; - my_rates->SN0_r0SiO2D [itab0 + 0] = 1.73471e-05; - my_rates->SN0_r0MgO [itab0 + 0] = 1.26307e-05; - - my_rates->SN0_r0SiM [itab0 + 1] = 1.71166e-12; - my_rates->SN0_r0FeM [itab0 + 1] = 5.41308e-12; - my_rates->SN0_r0Mg2SiO4 [itab0 + 1] = 2.04834e-10; - my_rates->SN0_r0AC [itab0 + 1] = 9.32091e-13; - my_rates->SN0_r0SiO2D [itab0 + 1] = 3.08556e-10; - my_rates->SN0_r0MgO [itab0 + 1] = 1.59673e-10; - - my_rates->SN0_r0SiM [itab0 + 2] = 5.46663e-18; - my_rates->SN0_r0FeM [itab0 + 2] = 2.06248e-17; - my_rates->SN0_r0Mg2SiO4 [itab0 + 2] = 2.98805e-15; - my_rates->SN0_r0AC [itab0 + 2] = 1.99556e-18; - my_rates->SN0_r0SiO2D [itab0 + 2] = 5.66409e-15; - my_rates->SN0_r0MgO [itab0 + 2] = 2.02075e-15; - - NTd = 35; - Nmom = 4; - - double P200_kpSiM[] = - { 1.54645e-01, 1.37048e-07, 2.64662e-13, 8.45209e-19, - 1.94685e-01, 1.72534e-07, 3.33193e-13, 1.06408e-18, - 2.45092e-01, 2.17207e-07, 4.19469e-13, 1.33961e-18, - 3.08551e-01, 2.73447e-07, 5.28084e-13, 1.68649e-18, - 3.88446e-01, 3.44254e-07, 6.64830e-13, 2.12322e-18, - 4.89028e-01, 4.33396e-07, 8.36986e-13, 2.67303e-18, - 6.15654e-01, 5.45619e-07, 1.05372e-12, 3.36522e-18, - 7.75056e-01, 6.86892e-07, 1.32656e-12, 4.23661e-18, - 9.75414e-01, 8.64464e-07, 1.66951e-12, 5.33191e-18, - 1.22498e+00, 1.08564e-06, 2.09668e-12, 6.69620e-18, - 1.52119e+00, 1.34817e-06, 2.60370e-12, 8.31550e-18, - 1.83682e+00, 1.62792e-06, 3.14401e-12, 1.00412e-17, - 2.15660e+00, 1.91133e-06, 3.69138e-12, 1.17894e-17, - 2.55494e+00, 2.26439e-06, 4.37331e-12, 1.39675e-17, - 3.22768e+00, 2.86067e-06, 5.52501e-12, 1.76460e-17, - 4.33077e+00, 3.83839e-06, 7.41349e-12, 2.36779e-17, - 5.81399e+00, 5.15308e-06, 9.95292e-12, 3.17892e-17, - 7.48107e+00, 6.63084e-06, 1.28076e-11, 4.09082e-17, - 9.20965e+00, 8.16336e-06, 1.57686e-11, 5.03682e-17, - 1.11868e+01, 9.91669e-06, 1.91573e-11, 6.11981e-17, - 1.39824e+01, 1.23969e-05, 2.39531e-11, 7.65315e-17, - 1.78531e+01, 1.58317e-05, 3.05972e-11, 9.77803e-17, - 2.17179e+01, 1.92624e-05, 3.72355e-11, 1.19020e-16, - 2.37018e+01, 2.10255e-05, 4.06526e-11, 1.29977e-16, - 2.29438e+01, 2.03578e-05, 3.93739e-11, 1.25940e-16, - 2.02577e+01, 1.79829e-05, 3.48015e-11, 1.11389e-16, - 1.70972e+01, 1.51927e-05, 2.94374e-11, 9.43240e-17, - 1.43876e+01, 1.28090e-05, 2.48736e-11, 7.98414e-17, - 1.23927e+01, 1.10758e-05, 2.16034e-11, 6.95714e-17, - 1.14807e+01, 1.03984e-05, 2.05890e-11, 6.70125e-17, - 1.34941e+01, 1.30878e-05, 2.78918e-11, 9.54730e-17, - 2.46530e+01, 2.87907e-05, 7.29927e-11, 2.79411e-16, - 6.22628e+01, 8.83029e-05, 2.60128e-10, 1.09021e-15, - 1.73608e+02, 2.73721e-04, 8.65552e-10, 3.78030e-15, - 4.81453e+02, 7.67244e-04, 2.43830e-09, 1.06714e-14 }; - - double P200_kpFeM[] = - { 9.09085e-04, 3.41941e-09, 1.80920e-14, 1.27369e-19, - 1.61039e-03, 6.04845e-09, 3.18823e-14, 2.22622e-19, - 2.49320e-03, 9.35673e-09, 4.92187e-14, 3.42113e-19, - 3.60452e-03, 1.35207e-08, 7.10297e-14, 4.92299e-19, - 5.89215e-03, 2.20677e-08, 1.15535e-13, 7.95087e-19, - 9.02912e-03, 3.37737e-08, 1.76355e-13, 1.20713e-18, - 1.39130e-02, 5.19580e-08, 2.70494e-13, 1.84076e-18, - 2.14719e-02, 8.00206e-08, 4.15192e-13, 2.80850e-18, - 3.30912e-02, 1.23012e-07, 6.35936e-13, 4.27570e-18, - 5.03917e-02, 1.86799e-07, 9.62098e-13, 6.43127e-18, - 7.63291e-02, 2.81960e-07, 1.44615e-12, 9.61004e-18, - 1.14179e-01, 4.19929e-07, 2.14346e-12, 1.41576e-17, - 1.67303e-01, 6.12055e-07, 3.10728e-12, 2.03974e-17, - 2.39689e-01, 8.71248e-07, 4.39580e-12, 2.86715e-17, - 3.35470e-01, 1.21013e-06, 6.06256e-12, 3.92787e-17, - 4.59119e-01, 1.64148e-06, 8.15789e-12, 5.24812e-17, - 6.15407e-01, 2.17768e-06, 1.07246e-11, 6.84719e-17, - 8.10332e-01, 2.83301e-06, 1.38055e-11, 8.74075e-17, - 1.05438e+00, 3.63322e-06, 1.74835e-11, 1.09639e-16, - 1.37021e+00, 4.63773e-06, 2.19726e-11, 1.36212e-16, - 1.80496e+00, 5.97282e-06, 2.77433e-11, 1.69529e-16, - 2.45118e+00, 7.88356e-06, 3.57016e-11, 2.14206e-16, - 3.48432e+00, 1.08228e-05, 4.74799e-11, 2.78412e-16, - 5.23381e+00, 1.56143e-05, 6.59474e-11, 3.76121e-16, - 8.31585e+00, 2.37506e-05, 9.61230e-11, 5.31044e-16, - 1.38802e+01, 3.79407e-05, 1.46823e-10, 7.83600e-16, - 2.40529e+01, 6.30826e-05, 2.33568e-10, 1.20322e-15, - 4.26908e+01, 1.07918e-04, 3.83527e-10, 1.90929e-15, - 7.65687e+01, 1.87651e-04, 6.43418e-10, 3.10502e-15, - 1.37077e+02, 3.27739e-04, 1.09108e-09, 5.12746e-15, - 2.42517e+02, 5.69117e-04, 1.85185e-09, 8.51948e-15, - 4.21112e+02, 9.75067e-04, 3.11997e-09, 1.41236e-14, - 7.14738e+02, 1.63904e-03, 5.18038e-09, 2.31656e-14, - 1.18235e+03, 2.68818e-03, 8.40281e-09, 3.71602e-14, - 1.90342e+03, 4.27908e-03, 1.31829e-08, 5.74720e-14 }; - - double P200_kpMg2SiO4[] = - { 1.05240e-01, 1.49640e-06, 2.15567e-11, 3.14463e-16, - 1.32588e-01, 1.88525e-06, 2.71584e-11, 3.96179e-16, - 1.67016e-01, 2.37479e-06, 3.42106e-11, 4.99054e-16, - 2.10360e-01, 2.99108e-06, 4.30887e-11, 6.28566e-16, - 2.71889e-01, 3.86597e-06, 5.56922e-11, 8.12421e-16, - 3.55700e-01, 5.05766e-06, 7.28594e-11, 1.06285e-15, - 4.84944e-01, 6.89538e-06, 9.93331e-11, 1.44904e-15, - 6.99796e-01, 9.95035e-06, 1.43342e-10, 2.09104e-15, - 1.05867e+00, 1.50532e-05, 2.16853e-10, 3.16340e-15, - 1.62919e+00, 2.31655e-05, 3.33717e-10, 4.86818e-15, - 2.54303e+00, 3.61594e-05, 5.20906e-10, 7.59887e-15, - 3.96603e+00, 5.63932e-05, 8.12393e-10, 1.18511e-14, - 6.10897e+00, 8.68643e-05, 1.25136e-09, 1.82548e-14, - 9.29384e+00, 1.32151e-04, 1.90378e-09, 2.77724e-14, - 1.39407e+01, 1.98229e-04, 2.85574e-09, 4.16600e-14, - 2.05705e+01, 2.92507e-04, 4.21400e-09, 6.14759e-14, - 3.01423e+01, 4.28630e-04, 6.17529e-09, 9.00909e-14, - 4.57104e+01, 6.50055e-04, 9.36595e-09, 1.36648e-13, - 7.53064e+01, 1.07104e-03, 1.54328e-08, 2.25181e-13, - 1.30815e+02, 1.86065e-03, 2.68126e-08, 3.91253e-13, - 2.17127e+02, 3.08849e-03, 4.45083e-08, 6.49502e-13, - 3.23880e+02, 4.60717e-03, 6.63972e-08, 9.68963e-13, - 4.35662e+02, 6.19759e-03, 8.93224e-08, 1.30358e-12, - 5.38932e+02, 7.66706e-03, 1.10506e-07, 1.61282e-12, - 6.09467e+02, 8.67078e-03, 1.24977e-07, 1.82406e-12, - 6.16707e+02, 8.77390e-03, 1.26464e-07, 1.84580e-12, - 5.52479e+02, 7.86016e-03, 1.13294e-07, 1.65358e-12, - 4.40975e+02, 6.27379e-03, 9.04293e-08, 1.31986e-12, - 3.18791e+02, 4.53552e-03, 6.53747e-08, 9.54183e-13, - 2.12803e+02, 3.02766e-03, 4.36414e-08, 6.36986e-13, - 1.33761e+02, 1.90318e-03, 2.74344e-08, 4.00448e-13, - 8.11305e+01, 1.15453e-03, 1.66451e-08, 2.42996e-13, - 4.95598e+01, 7.05594e-04, 1.01773e-08, 1.48640e-13, - 3.25906e+01, 4.64465e-04, 6.70585e-09, 9.80294e-14, - 2.45153e+01, 3.49814e-04, 5.05664e-09, 7.40047e-14 }; - - double P200_kpAC[] = - { 3.27960e-01, 2.44690e-07, 3.05689e-13, 6.54462e-19, - 4.38752e-01, 3.27351e-07, 4.08957e-13, 8.75569e-19, - 5.78230e-01, 4.31415e-07, 5.38965e-13, 1.15393e-18, - 7.53823e-01, 5.62424e-07, 7.02635e-13, 1.50436e-18, - 1.04013e+00, 7.76039e-07, 9.69511e-13, 2.07581e-18, - 1.41735e+00, 1.05749e-06, 1.32113e-12, 2.82873e-18, - 1.95292e+00, 1.45707e-06, 1.82034e-12, 3.89771e-18, - 2.71531e+00, 2.02589e-06, 2.53098e-12, 5.41951e-18, - 3.79675e+00, 2.83276e-06, 3.53905e-12, 7.57851e-18, - 5.29742e+00, 3.95242e-06, 4.93793e-12, 1.05749e-17, - 7.37833e+00, 5.50501e-06, 6.87773e-12, 1.47304e-17, - 1.02168e+01, 7.62282e-06, 9.52385e-12, 2.04006e-17, - 1.40421e+01, 1.04770e-05, 1.30901e-11, 2.80446e-17, - 1.92021e+01, 1.43270e-05, 1.79012e-11, 3.83618e-17, - 2.61616e+01, 1.95199e-05, 2.43907e-11, 5.22874e-17, - 3.55307e+01, 2.65108e-05, 3.31285e-11, 7.10543e-17, - 4.81611e+01, 3.59357e-05, 4.49107e-11, 9.63939e-17, - 6.53170e+01, 4.87382e-05, 6.09196e-11, 1.30888e-16, - 8.87668e+01, 6.62390e-05, 8.28118e-11, 1.78181e-16, - 1.20705e+02, 9.00772e-05, 1.12647e-10, 2.42873e-16, - 1.63621e+02, 1.22115e-04, 1.52778e-10, 3.30388e-16, - 2.20575e+02, 1.64642e-04, 2.06114e-10, 4.47715e-16, - 2.96104e+02, 2.21060e-04, 2.76991e-10, 6.05473e-16, - 3.97026e+02, 2.96479e-04, 3.71917e-10, 8.19263e-16, - 5.31526e+02, 3.97049e-04, 4.98696e-10, 1.10695e-15, - 7.06983e+02, 5.28345e-04, 6.64405e-10, 1.48343e-15, - 9.30949e+02, 6.96139e-04, 8.76417e-10, 1.96294e-15, - 1.21659e+03, 9.10536e-04, 1.14776e-09, 2.57160e-15, - 1.58765e+03, 1.18982e-03, 1.50225e-09, 3.36001e-15, - 2.08069e+03, 1.56242e-03, 1.97748e-09, 4.41103e-15, - 2.74685e+03, 2.06876e-03, 2.62823e-09, 5.84923e-15, - 3.65712e+03, 2.76611e-03, 3.53431e-09, 7.86205e-15, - 4.91402e+03, 3.73838e-03, 4.81486e-09, 1.07337e-14, - 6.67206e+03, 5.11081e-03, 6.64539e-09, 1.48739e-14, - 9.17096e+03, 7.06881e-03, 9.26820e-09, 2.07940e-14 }; - - double P200_kpSiO2D[] = - { 7.60136e-02, 1.31860e-06, 2.34539e-11, 4.30529e-16, - 9.06981e-02, 1.57333e-06, 2.79848e-11, 5.13702e-16, - 1.09185e-01, 1.89402e-06, 3.36890e-11, 6.18411e-16, - 1.32458e-01, 2.29774e-06, 4.08700e-11, 7.50232e-16, - 1.58888e-01, 2.75623e-06, 4.90252e-11, 8.99935e-16, - 1.91549e-01, 3.32281e-06, 5.91032e-11, 1.08494e-15, - 2.30478e-01, 3.99813e-06, 7.11152e-11, 1.30544e-15, - 2.76790e-01, 4.80151e-06, 8.54053e-11, 1.56776e-15, - 3.33085e-01, 5.77806e-06, 1.02776e-10, 1.88663e-15, - 4.05362e-01, 7.03188e-06, 1.25078e-10, 2.29603e-15, - 5.08238e-01, 8.81651e-06, 1.56822e-10, 2.87877e-15, - 6.72650e-01, 1.16686e-05, 2.07555e-10, 3.81010e-15, - 9.48976e-01, 1.64623e-05, 2.92824e-10, 5.37545e-15, - 1.41897e+00, 2.46158e-05, 4.37862e-10, 8.03808e-15, - 2.19768e+00, 3.81252e-05, 6.78181e-10, 1.24501e-14, - 3.47459e+00, 6.02792e-05, 1.07231e-09, 1.96868e-14, - 5.79486e+00, 1.00542e-04, 1.78877e-09, 3.28453e-14, - 1.18370e+01, 2.05418e-04, 3.65563e-09, 6.71473e-14, - 3.21108e+01, 5.57348e-04, 9.92083e-09, 1.82279e-13, - 8.81851e+01, 1.53068e-03, 2.72473e-08, 5.00649e-13, - 1.95201e+02, 3.38815e-03, 6.03099e-08, 1.10811e-12, - 3.40883e+02, 5.91645e-03, 1.05307e-07, 1.93471e-12, - 5.10268e+02, 8.85442e-03, 1.57557e-07, 2.89365e-12, - 7.17917e+02, 1.24511e-02, 2.21410e-07, 4.06297e-12, - 9.57120e+02, 1.65879e-02, 2.94709e-07, 5.40198e-12, - 1.14369e+03, 1.98088e-02, 3.51649e-07, 6.43917e-12, - 1.17995e+03, 2.04271e-02, 3.62410e-07, 6.63127e-12, - 1.05086e+03, 1.81866e-02, 3.22531e-07, 5.89860e-12, - 8.23986e+02, 1.42573e-02, 2.52780e-07, 4.62145e-12, - 5.83014e+02, 1.00864e-02, 1.78801e-07, 3.26825e-12, - 3.80801e+02, 6.58750e-03, 1.16763e-07, 2.13399e-12, - 2.33954e+02, 4.04697e-03, 7.17275e-08, 1.31079e-12, - 1.37203e+02, 2.37328e-03, 4.20617e-08, 7.68622e-13, - 7.77017e+01, 1.34403e-03, 2.38199e-08, 4.35268e-13, - 4.28856e+01, 7.41814e-04, 1.31471e-08, 2.40245e-13 }; - - double P200_kpMgO[] = - { 2.25374e-04, 2.84663e-09, 3.59861e-14, 4.55424e-19, - 4.04950e-04, 5.11481e-09, 6.46597e-14, 8.18303e-19, - 6.31024e-04, 7.97028e-09, 1.00758e-13, 1.27514e-18, - 9.15633e-04, 1.15651e-08, 1.46202e-13, 1.85026e-18, - 1.52197e-03, 1.92235e-08, 2.43017e-13, 3.07552e-18, - 2.37410e-03, 2.99866e-08, 3.79080e-13, 4.79746e-18, - 3.77219e-03, 4.76455e-08, 6.02318e-13, 7.62266e-18, - 6.14378e-03, 7.76004e-08, 9.80998e-13, 1.24151e-17, - 1.01916e-02, 1.28728e-07, 1.62733e-12, 2.05948e-17, - 1.68921e-02, 2.13360e-07, 2.69722e-12, 3.41348e-17, - 2.96213e-02, 3.74139e-07, 4.72974e-12, 5.98574e-17, - 6.10970e-02, 7.71701e-07, 9.75560e-12, 1.23463e-16, - 1.43533e-01, 1.81293e-06, 2.29185e-11, 2.90047e-16, - 3.27806e-01, 4.14044e-06, 5.23423e-11, 6.62424e-16, - 6.40565e-01, 8.09084e-06, 1.02282e-10, 1.29445e-15, - 1.05534e+00, 1.33298e-05, 1.68513e-10, 2.13267e-15, - 1.58348e+00, 2.00015e-05, 2.52868e-10, 3.20044e-15, - 3.07310e+00, 3.88206e-05, 4.90841e-10, 6.21320e-15, - 1.37089e+01, 1.73169e-04, 2.18940e-09, 2.77122e-14, - 7.13521e+01, 9.01235e-04, 1.13932e-08, 1.44189e-13, - 2.52035e+02, 3.18325e-03, 4.02394e-08, 5.09217e-13, - 5.88759e+02, 7.43595e-03, 9.39947e-08, 1.18943e-12, - 9.70270e+02, 1.22542e-02, 1.54897e-07, 1.96005e-12, - 1.20866e+03, 1.52648e-02, 1.92951e-07, 2.44153e-12, - 1.20927e+03, 1.52725e-02, 1.93046e-07, 2.44272e-12, - 1.02223e+03, 1.29102e-02, 1.63185e-07, 2.06485e-12, - 7.60460e+02, 9.60416e-03, 1.21396e-07, 1.53608e-12, - 5.14029e+02, 6.49187e-03, 8.20570e-08, 1.03830e-12, - 3.23438e+02, 4.08481e-03, 5.16318e-08, 6.53316e-13, - 1.92889e+02, 2.43607e-03, 3.07917e-08, 3.89618e-13, - 1.10502e+02, 1.39557e-03, 1.76399e-08, 2.23204e-13, - 6.14046e+01, 7.75500e-04, 9.80225e-09, 1.24031e-13, - 3.33434e+01, 4.21106e-04, 5.32274e-09, 6.73503e-14, - 1.77894e+01, 2.24668e-04, 2.83978e-09, 3.59327e-14, - 9.36317e+00, 1.18251e-04, 1.49468e-09, 1.89126e-14 }; - - - itab0 = Nmom * NTd * iSN; - itab = 0; - for(imom = 0; imom < Nmom; imom++) { - for(iTd = 0; iTd < NTd; iTd++) { - my_rates->SN0_kpSiM [itab0] = P200_kpSiM [itab]; - my_rates->SN0_kpFeM [itab0] = P200_kpFeM [itab]; - my_rates->SN0_kpMg2SiO4 [itab0] = P200_kpMg2SiO4 [itab]; - my_rates->SN0_kpAC [itab0] = P200_kpAC [itab]; - my_rates->SN0_kpSiO2D [itab0] = P200_kpSiO2D [itab]; - my_rates->SN0_kpMgO [itab0] = P200_kpMgO [itab]; - itab0++; - itab ++; - } - } - - return SUCCESS; -} - -int calc_rates_dust_Y19(int iSN, chemistry_data *my_chemistry, chemistry_data_storage *my_rates) -{ - - int NTd, Nmom; - int iTd, imom, itab0, itab; - - grackle::impl::GrainMetalInjectPathways* inject_pathway_props - = my_rates->opaque_storage->inject_pathway_props; - - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust][iSN] = 2.50000e-01; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust] [iSN] = 2.50000e-01; - - itab0 = 3 * iSN; - my_rates->SN0_r0MgSiO3 [itab0 + 0] = 1.00000e-05; - my_rates->SN0_r0AC [itab0 + 0] = 1.00000e-05; - - my_rates->SN0_r0MgSiO3 [itab0 + 1] = 1.00000e-10; - my_rates->SN0_r0AC [itab0 + 1] = 1.00000e-10; - - my_rates->SN0_r0MgSiO3 [itab0 + 2] = 1.00000e-15; - my_rates->SN0_r0AC [itab0 + 2] = 1.00000e-15; - - NTd = 35; - Nmom = 4; - - double Y19_kpMgSiO3[] = - { 2.19890e-02, 2.19890e-07, 2.19890e-12, 2.19890e-17, - 3.90612e-02, 3.90612e-07, 3.90612e-12, 3.90612e-17, - 6.05539e-02, 6.05539e-07, 6.05539e-12, 6.05539e-17, - 8.76116e-02, 8.76116e-07, 8.76116e-12, 8.76116e-17, - 1.43288e-01, 1.43288e-06, 1.43288e-11, 1.43288e-16, - 2.19266e-01, 2.19266e-06, 2.19266e-11, 2.19266e-16, - 3.36256e-01, 3.36256e-06, 3.36256e-11, 3.36256e-16, - 5.14336e-01, 5.14336e-06, 5.14336e-11, 5.14336e-16, - 7.97216e-01, 7.97216e-06, 7.97216e-11, 7.97216e-16, - 1.25414e+00, 1.25414e-05, 1.25414e-10, 1.25414e-15, - 2.03450e+00, 2.03450e-05, 2.03450e-10, 2.03450e-15, - 3.34654e+00, 3.34654e-05, 3.34654e-10, 3.34654e-15, - 5.45913e+00, 5.45913e-05, 5.45913e-10, 5.45913e-15, - 8.82166e+00, 8.82166e-05, 8.82166e-10, 8.82166e-15, - 1.41836e+01, 1.41836e-04, 1.41836e-09, 1.41836e-14, - 2.28449e+01, 2.28449e-04, 2.28449e-09, 2.28449e-14, - 3.71258e+01, 3.71258e-04, 3.71258e-09, 3.71258e-14, - 6.14485e+01, 6.14485e-04, 6.14485e-09, 6.14485e-14, - 1.03898e+02, 1.03898e-03, 1.03898e-08, 1.03898e-13, - 1.75627e+02, 1.75627e-03, 1.75627e-08, 1.75627e-13, - 2.82290e+02, 2.82290e-03, 2.82290e-08, 2.82290e-13, - 4.14908e+02, 4.14908e-03, 4.14908e-08, 4.14908e-13, - 5.60606e+02, 5.60606e-03, 5.60606e-08, 5.60606e-13, - 7.12020e+02, 7.12020e-03, 7.12020e-08, 7.12020e-13, - 8.42130e+02, 8.42130e-03, 8.42130e-08, 8.42130e-13, - 8.96812e+02, 8.96812e-03, 8.96812e-08, 8.96812e-13, - 8.41845e+02, 8.41845e-03, 8.41845e-08, 8.41845e-13, - 6.97883e+02, 6.97883e-03, 6.97883e-08, 6.97883e-13, - 5.19082e+02, 5.19082e-03, 5.19082e-08, 5.19082e-13, - 3.53464e+02, 3.53464e-03, 3.53464e-08, 3.53464e-13, - 2.24610e+02, 2.24610e-03, 2.24610e-08, 2.24610e-13, - 1.35389e+02, 1.35389e-03, 1.35389e-08, 1.35389e-13, - 7.84898e+01, 7.84898e-04, 7.84898e-09, 7.84898e-14, - 4.43113e+01, 4.43113e-04, 4.43113e-09, 4.43113e-14, - 2.49396e+01, 2.49396e-04, 2.49396e-09, 2.49396e-14 }; - - double Y19_kpAC[] = - { 6.76020e-02, 6.76020e-07, 6.76020e-12, 6.76020e-17, - 1.20181e-01, 1.20181e-06, 1.20181e-11, 1.20181e-16, - 1.86375e-01, 1.86375e-06, 1.86375e-11, 1.86375e-16, - 2.69708e-01, 2.69708e-06, 2.69708e-11, 2.69708e-16, - 4.44368e-01, 4.44368e-06, 4.44368e-11, 4.44368e-16, - 6.87406e-01, 6.87406e-06, 6.87406e-11, 6.87406e-16, - 1.07797e+00, 1.07797e-05, 1.07797e-10, 1.07797e-15, - 1.71241e+00, 1.71241e-05, 1.71241e-10, 1.71241e-15, - 2.74163e+00, 2.74163e-05, 2.74163e-10, 2.74163e-15, - 4.35812e+00, 4.35812e-05, 4.35812e-10, 4.35812e-15, - 6.98720e+00, 6.98720e-05, 6.98720e-10, 6.98720e-15, - 1.13206e+01, 1.13206e-04, 1.13206e-09, 1.13206e-14, - 1.85159e+01, 1.85159e-04, 1.85159e-09, 1.85159e-14, - 3.09414e+01, 3.09414e-04, 3.09414e-09, 3.09414e-14, - 5.34575e+01, 5.34575e-04, 5.34575e-09, 5.34575e-14, - 9.60912e+01, 9.60912e-04, 9.60912e-09, 9.60912e-14, - 1.76000e+02, 1.76000e-03, 1.76000e-08, 1.76000e-13, - 3.10598e+02, 3.10598e-03, 3.10598e-08, 3.10598e-13, - 4.95502e+02, 4.95502e-03, 4.95502e-08, 4.95502e-13, - 6.87389e+02, 6.87389e-03, 6.87389e-08, 6.87389e-13, - 8.21760e+02, 8.21760e-03, 8.21760e-08, 8.21760e-13, - 8.55209e+02, 8.55209e-03, 8.55209e-08, 8.55209e-13, - 7.90315e+02, 7.90315e-03, 7.90315e-08, 7.90315e-13, - 6.63814e+02, 6.63814e-03, 6.63814e-08, 6.63814e-13, - 5.19410e+02, 5.19410e-03, 5.19410e-08, 5.19410e-13, - 3.88956e+02, 3.88956e-03, 3.88956e-08, 3.88956e-13, - 2.88141e+02, 2.88141e-03, 2.88141e-08, 2.88141e-13, - 2.20698e+02, 2.20698e-03, 2.20698e-08, 2.20698e-13, - 1.84716e+02, 1.84716e-03, 1.84716e-08, 1.84716e-13, - 1.78316e+02, 1.78316e-03, 1.78316e-08, 1.78316e-13, - 2.05010e+02, 2.05010e-03, 2.05010e-08, 2.05010e-13, - 2.82760e+02, 2.82760e-03, 2.82760e-08, 2.82760e-13, - 4.70437e+02, 4.70437e-03, 4.70437e-08, 4.70437e-13, - 9.49808e+02, 9.49808e-03, 9.49808e-08, 9.49808e-13, - 2.18634e+03, 2.18634e-02, 2.18634e-07, 2.18634e-12 }; - - - itab0 = Nmom * NTd * iSN; - itab = 0; - for(imom = 0; imom < Nmom; imom++) { - for(iTd = 0; iTd < NTd; iTd++) { - my_rates->SN0_kpMgSiO3 [itab0] = Y19_kpMgSiO3 [itab]; - my_rates->SN0_kpAC [itab0] = Y19_kpAC [itab]; - itab0++; - itab ++; - } - } - - return SUCCESS; -} - -} // anonymous namespace From 8af2e5e0cd35ec13b5075ee11711bb96ca26c386 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sun, 7 Dec 2025 15:59:56 -0500 Subject: [PATCH 038/175] finish replacing my_rates->SN0_[fX] --- src/clib/initialize_chemistry_data.cpp | 7 --- src/clib/initialize_dust_yields.cpp | 26 ++-------- src/clib/make_consistent.cpp | 72 +++++++++++++++----------- src/include/grackle_chemistry_data.h | 1 - 4 files changed, 45 insertions(+), 61 deletions(-) diff --git a/src/clib/initialize_chemistry_data.cpp b/src/clib/initialize_chemistry_data.cpp index 462d5d59a..4279aab75 100644 --- a/src/clib/initialize_chemistry_data.cpp +++ b/src/clib/initialize_chemistry_data.cpp @@ -154,13 +154,6 @@ static void initialize_empty_chemistry_data_storage_struct(chemistry_data_storag my_rates->gr_dT = 0.; my_rates->gr_Td = NULL; my_rates->SN0_N = 0; - my_rates->SN0_XC = nullptr; - my_rates->SN0_XO = nullptr; - my_rates->SN0_XMg = nullptr; - my_rates->SN0_XAl = nullptr; - my_rates->SN0_XSi = nullptr; - my_rates->SN0_XS = nullptr; - my_rates->SN0_XFe = nullptr; my_rates->SN0_fC = nullptr; my_rates->SN0_fO = nullptr; my_rates->SN0_fMg = nullptr; diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index 9643b8391..22f666df5 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -334,17 +334,7 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, int NSN = n_pathways; // todo: delete me! my_rates->SN0_N = n_pathways; - // crude hack (until we delete all of chemistry_data_storage's SN0_X* and - // SN0_f* members -- this has to wait until after we merge in the - // transcription of make_consistent) - my_rates->SN0_XC = inject_pathway_props->total_metal_nuclide_yields.C; - my_rates->SN0_XO = inject_pathway_props->total_metal_nuclide_yields.O; - my_rates->SN0_XMg = inject_pathway_props->total_metal_nuclide_yields.Mg; - my_rates->SN0_XAl = inject_pathway_props->total_metal_nuclide_yields.Al; - my_rates->SN0_XSi = inject_pathway_props->total_metal_nuclide_yields.Si; - my_rates->SN0_XS = inject_pathway_props->total_metal_nuclide_yields.S; - my_rates->SN0_XFe = inject_pathway_props->total_metal_nuclide_yields.Fe; - + // crude hack (holding onto this momentarily) my_rates->SN0_fC = inject_pathway_props->gas_metal_nuclide_yields.C; my_rates->SN0_fO = inject_pathway_props->gas_metal_nuclide_yields.O; my_rates->SN0_fMg = inject_pathway_props->gas_metal_nuclide_yields.Mg; @@ -442,18 +432,8 @@ int grackle::impl::free_dust_yields(chemistry_data *my_chemistry, if (my_chemistry->metal_chemistry == 0) return SUCCESS; - // reminder: we have adopted a crude hack (until we delete all of - // chemistry_data_storage's SN0_X* and SN0_f* members -- this has to wait - // until after we merge in the transcription of make_consistent), where - // the yield fraction for each metal nuclide is an alias to a pointer - my_rates->SN0_XC = nullptr; - my_rates->SN0_XO = nullptr; - my_rates->SN0_XMg = nullptr; - my_rates->SN0_XAl = nullptr; - my_rates->SN0_XSi = nullptr; - my_rates->SN0_XS = nullptr; - my_rates->SN0_XFe = nullptr; - + // reminder: we are holding on to SN0_f as a crude hack (we will + // delete them later) my_rates->SN0_fC = nullptr; my_rates->SN0_fO = nullptr; my_rates->SN0_fMg = nullptr; diff --git a/src/clib/make_consistent.cpp b/src/clib/make_consistent.cpp index 701606036..980e9d37d 100644 --- a/src/clib/make_consistent.cpp +++ b/src/clib/make_consistent.cpp @@ -18,6 +18,8 @@ #include "grackle.h" #include "fortran_func_decls.h" +#include "inject_model/grain_metal_inject_pathways.hpp" +#include "opaque_storage.hpp" #include "utils-cpp.hpp" #include "make_consistent.hpp" @@ -267,6 +269,9 @@ void make_consistent(int imetal, double dom, chemistry_data* my_chemistry, std::vector Sd(my_fields->grid_dimension[0]); std::vector Fed(my_fields->grid_dimension[0]); + const grackle::impl::GrainMetalInjectPathways* inject_pathway_props = + my_rates->opaque_storage->inject_pathway_props; + // Loop over all zones for (k = my_fields->grid_start[2]; k <= my_fields->grid_end[2]; k++) { @@ -337,27 +342,34 @@ void make_consistent(int imetal, double dom, chemistry_data* my_chemistry, // endif if (my_chemistry->metal_chemistry > 0) { - if (my_chemistry->multi_metals == 0) { + // compute the expected mass density for each metal nuclide using the + // yields from every injection pathway + const grackle::impl::yields::MetalTables& total_metal_yields = + inject_pathway_props->total_metal_nuclide_yields; + const grackle::impl::yields::MetalTables& onlygas_metal_yields = + inject_pathway_props->gas_metal_nuclide_yields; + + if (my_chemistry->multi_metals == 0) { // case with 1 injection pathway iSN0 = my_chemistry->metal_abundances; for (i = my_fields->grid_start[0]; i <= my_fields->grid_end[0]; i++) { - Ct[i] = my_rates->SN0_XC[iSN0] * metal(i, j, k); - Ot[i] = my_rates->SN0_XO[iSN0] * metal(i, j, k); - Mgt[i] = my_rates->SN0_XMg[iSN0] * metal(i, j, k); - Alt[i] = my_rates->SN0_XAl[iSN0] * metal(i, j, k); - Sit[i] = my_rates->SN0_XSi[iSN0] * metal(i, j, k); - St[i] = my_rates->SN0_XS[iSN0] * metal(i, j, k); - Fet[i] = my_rates->SN0_XFe[iSN0] * metal(i, j, k); + Ct[i] = total_metal_yields.C[iSN0] * metal(i, j, k); + Ot[i] = total_metal_yields.O[iSN0] * metal(i, j, k); + Mgt[i] = total_metal_yields.Mg[iSN0] * metal(i, j, k); + Alt[i] = total_metal_yields.Al[iSN0] * metal(i, j, k); + Sit[i] = total_metal_yields.Si[iSN0] * metal(i, j, k); + St[i] = total_metal_yields.S[iSN0] * metal(i, j, k); + Fet[i] = total_metal_yields.Fe[iSN0] * metal(i, j, k); - Cg[i] = my_rates->SN0_fC[iSN0] * metal(i, j, k); - Og[i] = my_rates->SN0_fO[iSN0] * metal(i, j, k); - Mgg[i] = my_rates->SN0_fMg[iSN0] * metal(i, j, k); - Alg[i] = my_rates->SN0_fAl[iSN0] * metal(i, j, k); - Sig[i] = my_rates->SN0_fSi[iSN0] * metal(i, j, k); - Sg[i] = my_rates->SN0_fS[iSN0] * metal(i, j, k); - Feg[i] = my_rates->SN0_fFe[iSN0] * metal(i, j, k); + Cg[i] = onlygas_metal_yields.C[iSN0] * metal(i, j, k); + Og[i] = onlygas_metal_yields.O[iSN0] * metal(i, j, k); + Mgg[i] = onlygas_metal_yields.Mg[iSN0] * metal(i, j, k); + Alg[i] = onlygas_metal_yields.Al[iSN0] * metal(i, j, k); + Sig[i] = onlygas_metal_yields.Si[iSN0] * metal(i, j, k); + Sg[i] = onlygas_metal_yields.S[iSN0] * metal(i, j, k); + Feg[i] = onlygas_metal_yields.Fe[iSN0] * metal(i, j, k); } - } else { + } else { // case with multiple injection pathways // do i = is+1, ie+1 // totalZ = metal_loc(i,j,k) // & + metal_C13(i,j,k) + metal_C20(i,j,k) @@ -413,21 +425,21 @@ void make_consistent(int imetal, double dom, chemistry_data* my_chemistry, Fet[i] = 0.; Feg[i] = 0.; for (iSN = 0; iSN < nSN; iSN++) { - Ct[i] = Ct[i] + my_rates->SN0_XC[iSN] * SN_metal(i, iSN); - Ot[i] = Ot[i] + my_rates->SN0_XO[iSN] * SN_metal(i, iSN); - Mgt[i] = Mgt[i] + my_rates->SN0_XMg[iSN] * SN_metal(i, iSN); - Alt[i] = Alt[i] + my_rates->SN0_XAl[iSN] * SN_metal(i, iSN); - Sit[i] = Sit[i] + my_rates->SN0_XSi[iSN] * SN_metal(i, iSN); - St[i] = St[i] + my_rates->SN0_XS[iSN] * SN_metal(i, iSN); - Fet[i] = Fet[i] + my_rates->SN0_XFe[iSN] * SN_metal(i, iSN); + Ct[i] = Ct[i] + total_metal_yields.C[iSN] * SN_metal(i, iSN); + Ot[i] = Ot[i] + total_metal_yields.O[iSN] * SN_metal(i, iSN); + Mgt[i] = Mgt[i] + total_metal_yields.Mg[iSN] * SN_metal(i, iSN); + Alt[i] = Alt[i] + total_metal_yields.Al[iSN] * SN_metal(i, iSN); + Sit[i] = Sit[i] + total_metal_yields.Si[iSN] * SN_metal(i, iSN); + St[i] = St[i] + total_metal_yields.S[iSN] * SN_metal(i, iSN); + Fet[i] = Fet[i] + total_metal_yields.Fe[iSN] * SN_metal(i, iSN); - Cg[i] = Cg[i] + my_rates->SN0_fC[iSN] * SN_metal(i, iSN); - Og[i] = Og[i] + my_rates->SN0_fO[iSN] * SN_metal(i, iSN); - Mgg[i] = Mgg[i] + my_rates->SN0_fMg[iSN] * SN_metal(i, iSN); - Alg[i] = Alg[i] + my_rates->SN0_fAl[iSN] * SN_metal(i, iSN); - Sig[i] = Sig[i] + my_rates->SN0_fSi[iSN] * SN_metal(i, iSN); - Sg[i] = Sg[i] + my_rates->SN0_fS[iSN] * SN_metal(i, iSN); - Feg[i] = Feg[i] + my_rates->SN0_fFe[iSN] * SN_metal(i, iSN); + Cg[i] = Cg[i] + onlygas_metal_yields.C[iSN] * SN_metal(i, iSN); + Og[i] = Og[i] + onlygas_metal_yields.O[iSN] * SN_metal(i, iSN); + Mgg[i] = Mgg[i] + onlygas_metal_yields.Mg[iSN] * SN_metal(i, iSN); + Alg[i] = Alg[i] + onlygas_metal_yields.Al[iSN] * SN_metal(i, iSN); + Sig[i] = Sig[i] + onlygas_metal_yields.Si[iSN] * SN_metal(i, iSN); + Sg[i] = Sg[i] + onlygas_metal_yields.S[iSN] * SN_metal(i, iSN); + Feg[i] = Feg[i] + onlygas_metal_yields.Fe[iSN] * SN_metal(i, iSN); } } } diff --git a/src/include/grackle_chemistry_data.h b/src/include/grackle_chemistry_data.h index d34a1e323..f18cfe928 100644 --- a/src/include/grackle_chemistry_data.h +++ b/src/include/grackle_chemistry_data.h @@ -609,7 +609,6 @@ typedef struct int *gr_N, gr_Size; double gr_dT, *gr_Td; int SN0_N; - double *SN0_XC , *SN0_XO , *SN0_XMg, *SN0_XAl, *SN0_XSi, *SN0_XS , *SN0_XFe; double *SN0_fC , *SN0_fO , *SN0_fMg, *SN0_fAl, *SN0_fSi, *SN0_fS , *SN0_fFe; double *SN0_r0SiM, *SN0_r0FeM, *SN0_r0Mg2SiO4, *SN0_r0MgSiO3, *SN0_r0Fe3O4 , *SN0_r0AC, *SN0_r0SiO2D, *SN0_r0MgO, *SN0_r0FeS, *SN0_r0Al2O3 From 7a61b34ccebda6562ed3e5b8b574bd8c72fe9695 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sun, 7 Dec 2025 17:17:57 -0500 Subject: [PATCH 039/175] incremental commit --- src/clib/initialize_dust_yields.cpp | 119 +++++++++++----------------- 1 file changed, 47 insertions(+), 72 deletions(-) diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index 22f666df5..093ac9a24 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -125,61 +125,47 @@ extern "C" int setup_yield_table_callback( input->initial_grain_props[yield_idx]; int grain_species_idx = -1; - double* size_mom_table = nullptr; double* opac_coef_table = nullptr; // with a little refactoring, this will get a lot more concise if (std::strcmp("MgSiO3_dust", yield_info.name) == 0) { grain_species_idx = OnlyGrainSpLUT::MgSiO3_dust; - size_mom_table = my_rates->SN0_r0MgSiO3; opac_coef_table = my_rates->SN0_kpMgSiO3; } else if (std::strcmp("AC_dust", yield_info.name) == 0) { grain_species_idx = OnlyGrainSpLUT::AC_dust; - size_mom_table = my_rates->SN0_r0AC; opac_coef_table = my_rates->SN0_kpAC; } else if (std::strcmp("SiM_dust", yield_info.name) == 0) { grain_species_idx = OnlyGrainSpLUT::SiM_dust; - size_mom_table = my_rates->SN0_r0SiM; opac_coef_table = my_rates->SN0_kpSiM; } else if (std::strcmp("FeM_dust", yield_info.name) == 0) { grain_species_idx = OnlyGrainSpLUT::FeM_dust; - size_mom_table = my_rates->SN0_r0FeM; opac_coef_table = my_rates->SN0_kpFeM; } else if (std::strcmp("Mg2SiO4_dust", yield_info.name) == 0) { grain_species_idx = OnlyGrainSpLUT::Mg2SiO4_dust; - size_mom_table = my_rates->SN0_r0Mg2SiO4; opac_coef_table = my_rates->SN0_kpMg2SiO4; } else if (std::strcmp("Fe3O4_dust", yield_info.name) == 0) { grain_species_idx = OnlyGrainSpLUT::Fe3O4_dust; - size_mom_table = my_rates->SN0_r0Fe3O4; opac_coef_table = my_rates->SN0_kpFe3O4; } else if (std::strcmp("SiO2_dust", yield_info.name) == 0) { grain_species_idx = OnlyGrainSpLUT::SiO2_dust; - size_mom_table = my_rates->SN0_r0SiO2D; opac_coef_table = my_rates->SN0_kpSiO2D; } else if (std::strcmp("MgO_dust", yield_info.name) == 0) { grain_species_idx = OnlyGrainSpLUT::MgO_dust; - size_mom_table = my_rates->SN0_r0MgO; opac_coef_table = my_rates->SN0_kpMgO; } else if (std::strcmp("FeS_dust", yield_info.name) == 0) { grain_species_idx = OnlyGrainSpLUT::FeS_dust; - size_mom_table = my_rates->SN0_r0FeS; opac_coef_table = my_rates->SN0_kpFeS; } else if (std::strcmp("Al2O3_dust", yield_info.name) == 0) { grain_species_idx = OnlyGrainSpLUT::Al2O3_dust; - size_mom_table = my_rates->SN0_r0Al2O3; opac_coef_table = my_rates->SN0_kpAl2O3; } else if (std::strcmp("ref_org_dust", yield_info.name) == 0) { grain_species_idx = OnlyGrainSpLUT::ref_org_dust; - size_mom_table = my_rates->SN0_r0reforg; opac_coef_table = my_rates->SN0_kpreforg; } else if (std::strcmp("vol_org_dust", yield_info.name) == 0) { grain_species_idx = OnlyGrainSpLUT::vol_org_dust; - size_mom_table = my_rates->SN0_r0volorg; opac_coef_table = my_rates->SN0_kpvolorg; } else if (std::strcmp("H2O_ice_dust", yield_info.name) == 0) { grain_species_idx = OnlyGrainSpLUT::H2O_ice_dust; - size_mom_table = my_rates->SN0_r0H2Oice; opac_coef_table = my_rates->SN0_kpH2Oice; } else { return GrPrintAndReturnErr( @@ -192,6 +178,8 @@ extern "C" int setup_yield_table_callback( // copy the 1st, 2nd, and 3rd moments of the size distribution // (the 0th moment isn't recorded anywhere + double* size_mom_table = + inject_pathway_props->size_moments.data[grain_species_idx]; for (int i = 0; i < 3; i++) { size_mom_table[pathway_idx*3+i] = yield_info.size_moments[i]; } @@ -251,44 +239,31 @@ void override_dust_inject_props(chemistry_data_storage *my_rates, grackle::impl::GrainMetalInjectPathways* inject_pathway_props = my_rates->opaque_storage->inject_pathway_props; - if (inject_pathway_props != nullptr) { - // handle the grain yields + GRIMPL_REQUIRE(inject_pathway_props != nullptr, + "sanity check -- should never ever fail!"); + + const int n_grain_species = OnlyGrainSpLUT::NUM_ENTRIES; + + // handle the grain yields + for (int grain_species_idx = 0; grain_species_idx < n_grain_species; + grain_species_idx++){ + double* arr = inject_pathway_props->grain_yields.data[grain_species_idx]; for(int iSN = 0; iSN < n_pathways; iSN++) { - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust] [iSN] = value; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN] = value; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN] = value; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN] = value; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Fe3O4_dust] [iSN] = value; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust] [iSN] = value; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust] [iSN] = value; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgO_dust] [iSN] = value; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeS_dust] [iSN] = value; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Al2O3_dust] [iSN] = value; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::ref_org_dust] [iSN] = value; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::vol_org_dust] [iSN] = value; - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::H2O_ice_dust] [iSN] = value; + arr[iSN] = value; } } - if (true) { // NOLINT(readability-simplify-boolean-expr) - - // handle the size moments - int moment_table_len = n_pathways * 3; // there are 3 size moments + // handle the size moments + int moment_table_len = n_pathways * 3; // there are 3 size moments + for (int grain_species_idx = 0; grain_species_idx < n_grain_species; + grain_species_idx++){ + double* arr = inject_pathway_props->size_moments.data[grain_species_idx]; for(int i = 0; i < moment_table_len; i++) { - my_rates->SN0_r0SiM [i] = value; - my_rates->SN0_r0FeM [i] = value; - my_rates->SN0_r0Mg2SiO4 [i] = value; - my_rates->SN0_r0MgSiO3 [i] = value; - my_rates->SN0_r0Fe3O4 [i] = value; - my_rates->SN0_r0AC [i] = value; - my_rates->SN0_r0SiO2D [i] = value; - my_rates->SN0_r0MgO [i] = value; - my_rates->SN0_r0FeS [i] = value; - my_rates->SN0_r0Al2O3 [i] = value; - my_rates->SN0_r0reforg [i] = value; - my_rates->SN0_r0volorg [i] = value; - my_rates->SN0_r0H2Oice [i] = value; + arr[i] = value; } + } + + if (true) { // NOLINT(readability-simplify-boolean-expr) // handle the opacity coefficient table int opac_table_len = n_pathways * my_rates->gr_Size; @@ -343,19 +318,19 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, my_rates->SN0_fS = inject_pathway_props->gas_metal_nuclide_yields.S; my_rates->SN0_fFe = inject_pathway_props->gas_metal_nuclide_yields.Fe; - my_rates->SN0_r0SiM = (double*)malloc(NSN * 3 * sizeof(double)); - my_rates->SN0_r0FeM = (double*)malloc(NSN * 3 * sizeof(double)); - my_rates->SN0_r0Mg2SiO4 = (double*)malloc(NSN * 3 * sizeof(double)); - my_rates->SN0_r0MgSiO3 = (double*)malloc(NSN * 3 * sizeof(double)); - my_rates->SN0_r0Fe3O4 = (double*)malloc(NSN * 3 * sizeof(double)); - my_rates->SN0_r0AC = (double*)malloc(NSN * 3 * sizeof(double)); - my_rates->SN0_r0SiO2D = (double*)malloc(NSN * 3 * sizeof(double)); - my_rates->SN0_r0MgO = (double*)malloc(NSN * 3 * sizeof(double)); - my_rates->SN0_r0FeS = (double*)malloc(NSN * 3 * sizeof(double)); - my_rates->SN0_r0Al2O3 = (double*)malloc(NSN * 3 * sizeof(double)); - my_rates->SN0_r0reforg = (double*)malloc(NSN * 3 * sizeof(double)); - my_rates->SN0_r0volorg = (double*)malloc(NSN * 3 * sizeof(double)); - my_rates->SN0_r0H2Oice = (double*)malloc(NSN * 3 * sizeof(double)); + my_rates->SN0_r0SiM = inject_pathway_props->size_moments.data[OnlyGrainSpLUT::SiM_dust]; + my_rates->SN0_r0FeM = inject_pathway_props->size_moments.data[OnlyGrainSpLUT::FeM_dust]; + my_rates->SN0_r0Mg2SiO4 = inject_pathway_props->size_moments.data[OnlyGrainSpLUT::Mg2SiO4_dust]; + my_rates->SN0_r0MgSiO3 = inject_pathway_props->size_moments.data[OnlyGrainSpLUT::MgSiO3_dust]; + my_rates->SN0_r0Fe3O4 = inject_pathway_props->size_moments.data[OnlyGrainSpLUT::Fe3O4_dust]; + my_rates->SN0_r0AC = inject_pathway_props->size_moments.data[OnlyGrainSpLUT::AC_dust]; + my_rates->SN0_r0SiO2D = inject_pathway_props->size_moments.data[OnlyGrainSpLUT::SiO2_dust]; + my_rates->SN0_r0MgO = inject_pathway_props->size_moments.data[OnlyGrainSpLUT::MgO_dust]; + my_rates->SN0_r0FeS = inject_pathway_props->size_moments.data[OnlyGrainSpLUT::FeS_dust]; + my_rates->SN0_r0Al2O3 = inject_pathway_props->size_moments.data[OnlyGrainSpLUT::Al2O3_dust]; + my_rates->SN0_r0reforg = inject_pathway_props->size_moments.data[OnlyGrainSpLUT::ref_org_dust]; + my_rates->SN0_r0volorg = inject_pathway_props->size_moments.data[OnlyGrainSpLUT::vol_org_dust]; + my_rates->SN0_r0H2Oice = inject_pathway_props->size_moments.data[OnlyGrainSpLUT::H2O_ice_dust]; // write out the opacity related quantities @@ -442,19 +417,19 @@ int grackle::impl::free_dust_yields(chemistry_data *my_chemistry, my_rates->SN0_fS = nullptr; my_rates->SN0_fFe = nullptr; - GRACKLE_FREE(my_rates->SN0_r0SiM); - GRACKLE_FREE(my_rates->SN0_r0FeM); - GRACKLE_FREE(my_rates->SN0_r0Mg2SiO4); - GRACKLE_FREE(my_rates->SN0_r0MgSiO3); - GRACKLE_FREE(my_rates->SN0_r0Fe3O4); - GRACKLE_FREE(my_rates->SN0_r0AC); - GRACKLE_FREE(my_rates->SN0_r0SiO2D); - GRACKLE_FREE(my_rates->SN0_r0MgO); - GRACKLE_FREE(my_rates->SN0_r0FeS); - GRACKLE_FREE(my_rates->SN0_r0Al2O3); - GRACKLE_FREE(my_rates->SN0_r0reforg); - GRACKLE_FREE(my_rates->SN0_r0volorg); - GRACKLE_FREE(my_rates->SN0_r0H2Oice); + my_rates->SN0_r0SiM = nullptr; + my_rates->SN0_r0FeM = nullptr; + my_rates->SN0_r0Mg2SiO4 = nullptr; + my_rates->SN0_r0MgSiO3 = nullptr; + my_rates->SN0_r0Fe3O4 = nullptr; + my_rates->SN0_r0AC = nullptr; + my_rates->SN0_r0SiO2D = nullptr; + my_rates->SN0_r0MgO = nullptr; + my_rates->SN0_r0FeS = nullptr; + my_rates->SN0_r0Al2O3 = nullptr; + my_rates->SN0_r0reforg = nullptr; + my_rates->SN0_r0volorg = nullptr; + my_rates->SN0_r0H2Oice = nullptr; GRACKLE_FREE(my_rates->gr_Td); From d5cac76200bc0c649c482b03bcb4620756a45936 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Mon, 8 Dec 2025 14:49:52 -0500 Subject: [PATCH 040/175] rm erroneous docstring comment (Basically, I forgot to remove the comment sooner) --- src/clib/inject_model/grain_metal_inject_pathways.hpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/clib/inject_model/grain_metal_inject_pathways.hpp b/src/clib/inject_model/grain_metal_inject_pathways.hpp index 1fb39e9e5..e7460f527 100644 --- a/src/clib/inject_model/grain_metal_inject_pathways.hpp +++ b/src/clib/inject_model/grain_metal_inject_pathways.hpp @@ -141,9 +141,6 @@ struct GrainMetalInjectPathways { /// when injected by pathway ``j``. The value has units of centimeters /// cubed. /// - /// @todo - /// What are the units of each quantity? (the dimensionality is obvious) - /// /// where \f$\langle r^2 \rangle_j=\int_0^\infty r^p \Phi_j(r)\, {\rm d}r\f$ /// is an abbreviation for the ``p``th moment of the \f$\Phi_j(r)\f$, or the /// initial differential grain size distribution for pathway ``j`` (this From 1d49a4258d8249dc19ff11f84ca42b939a10b92d Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Mon, 8 Dec 2025 16:36:14 -0500 Subject: [PATCH 041/175] introduce all remaining members GrainMetalInjectPathways (they aren't actually used yet) --- src/clib/initialize_dust_yields.cpp | 13 +- .../grain_metal_inject_pathways.hpp | 149 ++++++++++++++++-- 2 files changed, 150 insertions(+), 12 deletions(-) diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index 093ac9a24..026ae42b0 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -297,14 +297,21 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, } int n_pathways = 12; + int n_log10Tdust_vals = grackle::impl::inj_model_input::N_Tdust_Opacity_Table; + int n_opac_poly_coef = grackle::impl::inj_model_input::N_Opacity_Coef; my_rates->opaque_storage->inject_pathway_props = new grackle::impl::GrainMetalInjectPathways; *(my_rates->opaque_storage->inject_pathway_props) = - new_GrainMetalInjectPathways(n_pathways); + new_GrainMetalInjectPathways(n_pathways, n_log10Tdust_vals, + n_opac_poly_coef); grackle::impl::GrainMetalInjectPathways* inject_pathway_props = my_rates->opaque_storage->inject_pathway_props; + if (!GrainMetalInjectPathways_is_valid(inject_pathway_props)) { + return GR_FAIL; + } + int NSN = n_pathways; // todo: delete me! my_rates->SN0_N = n_pathways; @@ -335,7 +342,7 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, // write out the opacity related quantities // todo: consider renaming Nmom -> Ncoef - int Nmom = 4; // todo: remove me! + int Nmom = n_opac_poly_coef; // todo: remove me! // todo: more this into GrainMetalInjectPathways // - essentially, each SN0_kpGRSP array is a 3D array of shape // (n_pathways, NTd, Nmom). This shape uses numpy conventions (i.e. Nmom is @@ -354,7 +361,7 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, // - δr(t) refers to the derived "size increment" (it is a central // quantity in the model) // - I **think** the resulting quantity is the optical cross-section - double NTd = grackle::impl::inj_model_input::N_Tdust_Opacity_Table; + double NTd = n_log10Tdust_vals; double Td0 = 0.0000000; // todo: remove me! double dTd = 0.1000000; // todo: remove me! diff --git a/src/clib/inject_model/grain_metal_inject_pathways.hpp b/src/clib/inject_model/grain_metal_inject_pathways.hpp index e7460f527..27e0da85f 100644 --- a/src/clib/inject_model/grain_metal_inject_pathways.hpp +++ b/src/clib/inject_model/grain_metal_inject_pathways.hpp @@ -12,9 +12,12 @@ #ifndef GRAIN_METAL_INJECT_PATHWAYS_HPP #define GRAIN_METAL_INJECT_PATHWAYS_HPP -#include "LUT.hpp" -#include "internal_types.hpp" -#include "visitor/common.hpp" +#include "grackle.h" // gr_interp_grid_props +#include "../LUT.hpp" +#include "../internal_types.hpp" +#include "../interp_table_utils.hpp" +#include "../status_reporting.h" +#include "../visitor/common.hpp" // this is a separate namespace because we are probably going to delete the // contents (when we deal with GH Issue #446) @@ -155,30 +158,158 @@ struct GrainMetalInjectPathways { /// functions to the narrative docs and refer the reader to the appropriate /// section of documentation GrainSpeciesCollection size_moments; + + /// Tracks 1D grid constant-spaced log10(Tdust) values used for interpolation + /// in opacity calculations. + /// + /// @note + /// Using a full #gr_interp_grid_props seems like it's a little overkill for + /// holding values for 1D interpolation, but it may be worthwhile that this + /// datatype is **ONLY** used for interpolation. Maybe in the future, we + /// should make a specialized version for 1D data? + gr_interp_grid_props log10Tdust_interp_props; + + /// the number of polynomial coefficients that will be computed from the + /// opacity_coef_table. They are used in a polynomial of degree + /// `(n_opac_poly_coef-1)` + int n_opac_poly_coef; + + /// tables of values for opacity calculations. + /// + /// This holds a 3D array for each grain species. Each array has the shape + /// `(n_pathways, nTd, n_opac_poly_coef)`, where + /// - `nTd` is `log10Tdust_interp_props.dimension[0]` + /// - the axis follows numpy conventions (i.e. `n_opac_poly_coef` is the + /// contiguous axis). + /// + /// What the data means + /// =================== + /// + /// To be more concrete, consider a grain species that maps to data at an + /// index `grsp_i` and an injection pathway that maps to data at an index + /// `injp_i`. Then, let's consider `p`, which is given by + /// `p = opacity_coef_table.data[grsp_i] + (injp_i * nTd * n_opac_poly_coef)`. + /// In this scenario, `p` points to a 2D array that holds `n_opac_poly_coef` + /// coefficients for each dust temperatures in `log10Tdust_interp_props`. + /// + /// In practice, we construct a vector, `vec`, of values for all `nTd` dust + /// temperatures. The value computed for dust temperature `j` is: + /// + /// `vec[j] = 4πζ/3 * ∑ᵢ₌₀ ( p[j * n_opac_poly_coef + i] * δrⁱ(t) )` + /// + /// where: + /// - the summation runs from `i=0` through `i = n_opac_poly_coef - 1`. + /// - `ζ` is the "bulk density" of the considered grain species (in g/cm³). + /// In other words, it's the mass density of a single grain. + /// - `δr(t)` refers to the derived "size increment", in units of cm, + /// computed at the current time `t`. Recall that Grackle's multi-grain + /// species dust model involves the initial size distribution functions for + /// grain species when they are initially injected. This is allowed to vary + /// across injection pathway and grain species (in fact, moments of these + /// functions are stored by `GrainMetalInjectPathways::size_moments`). If + /// grains undergo growth, the model assumes that the distribution function + /// is simply translated by the size increment, `δr` (the shape doesn't + /// change). Thus, a `δr` of `0` means that there's been no growth. + /// + /// `vec[j]` holds a quantity related to computing opacity. I, MWA, **THINK** + /// that `vec[j]`: + /// - it directly stores opacity, in units of `cm^2/g`. + /// - is "per unit grain mass." If my understanding of this quantity and + /// related logic is indeed correct, this is noteworthy because subsequent + /// calculations appear use values deriving from `vec[j]` to compute + /// opacity measured "per unit gas mass." + /// + /// @todo + /// Determine whether my statements in the preceeding paragraphs are indeed + /// correct. More generally, what kind of weighted opacity is this? (e.g. a + /// a Rosseland mean opacity or a Planck mean opacity?)? Does it describe a + /// restricted wavelength range? + /// + /// The resulting vector of values is subsequently interpolated with respect + /// to log10Tdust_interp_props + /// + /// @todo + /// Ideally, we would move some of this description to the narrative docs and + /// then refer the reader to the appropriate section of the documentation. + /// (This could certainly be done for the description of the size increment) + GrainSpeciesCollection opacity_coef_table; }; /// allocates the contents of a new GrainMetalInjectPathways /// -/// @param n_pathways The number of modeled injection pathways -inline GrainMetalInjectPathways new_GrainMetalInjectPathways(int n_pathways) { +/// @param[in] n_pathways Number of modelled injection pathways +/// @param[in] n_log10Tdust_vals Number of log10(Tdust) values that are relevant +/// for the opacity coefficient table. +/// @param[in] n_opac_poly_coef Number of opacity coefficients that are +/// computed from the opacity coefficient table. +inline GrainMetalInjectPathways new_GrainMetalInjectPathways( + int n_pathways, int n_log10Tdust_vals, int n_opac_poly_coef) { + + bool err = false; + + if (n_pathways <= 0) { + GrPrintErrMsg("n_pathways must be positive\n"); + err = true; + } else if (n_log10Tdust_vals <= 1) { + GrPrintErrMsg("n_log10Tdust_vals must exceed 1\n"); + err = true; + } else if (n_opac_poly_coef != 4) { + GrPrintErrMsg( + "the logic that uses the opacity table is hardcoded to assume that " + "the number of opacity polynomial coefficients is exactly 4\n"); + err = true; + } + GrainMetalInjectPathways out; + + if (err) { + out.n_pathways = -1; + return out; + } + out.n_pathways = n_pathways; + out.total_metal_nuclide_yields = yields::new_MetalTables(n_pathways); out.gas_metal_nuclide_yields = yields::new_MetalTables(n_pathways); + out.grain_yields = new_GrainSpeciesCollection(n_pathways); out.size_moments = new_GrainSpeciesCollection(3 * n_pathways); + init_empty_interp_grid_props_(&out.log10Tdust_interp_props); + out.log10Tdust_interp_props.rank = 1LL; + long long n_log10Tdust_vals_LL = static_cast(n_log10Tdust_vals); + out.log10Tdust_interp_props.dimension[0] = n_log10Tdust_vals_LL; + out.log10Tdust_interp_props.data_size = n_log10Tdust_vals_LL; + out.log10Tdust_interp_props.parameters[0] = new double[n_log10Tdust_vals]; + + out.n_opac_poly_coef = n_opac_poly_coef; + + out.opacity_coef_table = new_GrainSpeciesCollection( + n_pathways * n_log10Tdust_vals * n_opac_poly_coef); + return out; } +/// Checks whether the GrainMetalInjectPathways that is returned by +/// new_GrainMetalInjectPathways is valid +inline bool GrainMetalInjectPathways_is_valid(const GrainMetalInjectPathways* ptr) { + return ptr->n_pathways != -1; +} + + /// performs cleanup of the contents of GrainMetalInjectPathways /// /// This effectively invokes a destructor inline void drop_GrainMetalInjectPathways(GrainMetalInjectPathways* ptr) { - yields::drop_MetalTables(&ptr->total_metal_nuclide_yields); - yields::drop_MetalTables(&ptr->gas_metal_nuclide_yields); - drop_GrainSpeciesCollection(&ptr->grain_yields); - drop_GrainSpeciesCollection(&ptr->size_moments); + if (GrainMetalInjectPathways_is_valid(ptr)){ + yields::drop_MetalTables(&ptr->total_metal_nuclide_yields); + yields::drop_MetalTables(&ptr->gas_metal_nuclide_yields); + drop_GrainSpeciesCollection(&ptr->grain_yields); + drop_GrainSpeciesCollection(&ptr->size_moments); + free_interp_grid_props_(&ptr->log10Tdust_interp_props, + /* use_delete = */ true); + drop_GrainSpeciesCollection(&ptr->opacity_coef_table); + } } } // namespace grackle::impl From 4766aa7c72b5bbcb5ebbf362d63584cfd1f2c252 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Mon, 8 Dec 2025 16:55:33 -0500 Subject: [PATCH 042/175] a large step towards changing how opacity coefficients get stored --- src/clib/initialize_dust_yields.cpp | 98 ++++++++++++----------------- 1 file changed, 39 insertions(+), 59 deletions(-) diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index 026ae42b0..22f6bc49c 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -125,48 +125,34 @@ extern "C" int setup_yield_table_callback( input->initial_grain_props[yield_idx]; int grain_species_idx = -1; - double* opac_coef_table = nullptr; // with a little refactoring, this will get a lot more concise if (std::strcmp("MgSiO3_dust", yield_info.name) == 0) { grain_species_idx = OnlyGrainSpLUT::MgSiO3_dust; - opac_coef_table = my_rates->SN0_kpMgSiO3; } else if (std::strcmp("AC_dust", yield_info.name) == 0) { grain_species_idx = OnlyGrainSpLUT::AC_dust; - opac_coef_table = my_rates->SN0_kpAC; } else if (std::strcmp("SiM_dust", yield_info.name) == 0) { grain_species_idx = OnlyGrainSpLUT::SiM_dust; - opac_coef_table = my_rates->SN0_kpSiM; } else if (std::strcmp("FeM_dust", yield_info.name) == 0) { grain_species_idx = OnlyGrainSpLUT::FeM_dust; - opac_coef_table = my_rates->SN0_kpFeM; } else if (std::strcmp("Mg2SiO4_dust", yield_info.name) == 0) { grain_species_idx = OnlyGrainSpLUT::Mg2SiO4_dust; - opac_coef_table = my_rates->SN0_kpMg2SiO4; } else if (std::strcmp("Fe3O4_dust", yield_info.name) == 0) { grain_species_idx = OnlyGrainSpLUT::Fe3O4_dust; - opac_coef_table = my_rates->SN0_kpFe3O4; } else if (std::strcmp("SiO2_dust", yield_info.name) == 0) { grain_species_idx = OnlyGrainSpLUT::SiO2_dust; - opac_coef_table = my_rates->SN0_kpSiO2D; } else if (std::strcmp("MgO_dust", yield_info.name) == 0) { grain_species_idx = OnlyGrainSpLUT::MgO_dust; - opac_coef_table = my_rates->SN0_kpMgO; } else if (std::strcmp("FeS_dust", yield_info.name) == 0) { grain_species_idx = OnlyGrainSpLUT::FeS_dust; - opac_coef_table = my_rates->SN0_kpFeS; } else if (std::strcmp("Al2O3_dust", yield_info.name) == 0) { grain_species_idx = OnlyGrainSpLUT::Al2O3_dust; - opac_coef_table = my_rates->SN0_kpAl2O3; } else if (std::strcmp("ref_org_dust", yield_info.name) == 0) { grain_species_idx = OnlyGrainSpLUT::ref_org_dust; - opac_coef_table = my_rates->SN0_kpreforg; } else if (std::strcmp("vol_org_dust", yield_info.name) == 0) { grain_species_idx = OnlyGrainSpLUT::vol_org_dust; - opac_coef_table = my_rates->SN0_kpvolorg; } else if (std::strcmp("H2O_ice_dust", yield_info.name) == 0) { grain_species_idx = OnlyGrainSpLUT::H2O_ice_dust; - opac_coef_table = my_rates->SN0_kpH2Oice; } else { return GrPrintAndReturnErr( "`%s` not a known grain species", yield_info.name); @@ -186,6 +172,8 @@ extern "C" int setup_yield_table_callback( // copy over the opacity coefficients table { + double* opac_coef_table = + inject_pathway_props->opacity_coef_table.data[grain_species_idx]; int n_Td = grackle::impl::inj_model_input::N_Tdust_Opacity_Table; int n_coef = grackle::impl::inj_model_input::N_Opacity_Coef; @@ -232,7 +220,7 @@ void override_metal_inject_props( /// @note /// to start, this only handles the grain yields void override_dust_inject_props(chemistry_data_storage *my_rates, - double value, int n_pathways) { + double value) { GRIMPL_REQUIRE(my_rates != nullptr && my_rates->opaque_storage != nullptr, "sanity check -- should never ever fail!"); @@ -244,6 +232,8 @@ void override_dust_inject_props(chemistry_data_storage *my_rates, const int n_grain_species = OnlyGrainSpLUT::NUM_ENTRIES; + int n_pathways = inject_pathway_props->n_pathways; + // handle the grain yields for (int grain_species_idx = 0; grain_species_idx < n_grain_species; grain_species_idx++){ @@ -263,24 +253,14 @@ void override_dust_inject_props(chemistry_data_storage *my_rates, } } - if (true) { // NOLINT(readability-simplify-boolean-expr) - - // handle the opacity coefficient table - int opac_table_len = n_pathways * my_rates->gr_Size; + // handle the opacity coefficient table + int opac_table_len = n_pathways * my_rates->gr_Size; + for (int grain_species_idx = 0; grain_species_idx < n_grain_species; + grain_species_idx++){ + double* arr = + inject_pathway_props->opacity_coef_table.data[grain_species_idx]; for(int i = 0; i < opac_table_len; i++) { - my_rates->SN0_kpSiM [i] = value; - my_rates->SN0_kpFeM [i] = value; - my_rates->SN0_kpMg2SiO4 [i] = value; - my_rates->SN0_kpMgSiO3 [i] = value; - my_rates->SN0_kpFe3O4 [i] = value; - my_rates->SN0_kpAC [i] = value; - my_rates->SN0_kpSiO2D [i] = value; - my_rates->SN0_kpMgO [i] = value; - my_rates->SN0_kpFeS [i] = value; - my_rates->SN0_kpAl2O3 [i] = value; - my_rates->SN0_kpreforg [i] = value; - my_rates->SN0_kpvolorg [i] = value; - my_rates->SN0_kpH2Oice [i] = value; + arr[i] = value; } } } @@ -375,24 +355,24 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, my_rates->gr_Td[iTd] = Td0 + (double)iTd * dTd; } - my_rates->SN0_kpSiM = (double*)malloc(NSN * Nmom * NTd * sizeof(double)); - my_rates->SN0_kpFeM = (double*)malloc(NSN * Nmom * NTd * sizeof(double)); - my_rates->SN0_kpMg2SiO4 = (double*)malloc(NSN * Nmom * NTd * sizeof(double)); - my_rates->SN0_kpMgSiO3 = (double*)malloc(NSN * Nmom * NTd * sizeof(double)); - my_rates->SN0_kpFe3O4 = (double*)malloc(NSN * Nmom * NTd * sizeof(double)); - my_rates->SN0_kpAC = (double*)malloc(NSN * Nmom * NTd * sizeof(double)); - my_rates->SN0_kpSiO2D = (double*)malloc(NSN * Nmom * NTd * sizeof(double)); - my_rates->SN0_kpMgO = (double*)malloc(NSN * Nmom * NTd * sizeof(double)); - my_rates->SN0_kpFeS = (double*)malloc(NSN * Nmom * NTd * sizeof(double)); - my_rates->SN0_kpAl2O3 = (double*)malloc(NSN * Nmom * NTd * sizeof(double)); - my_rates->SN0_kpreforg = (double*)malloc(NSN * Nmom * NTd * sizeof(double)); - my_rates->SN0_kpvolorg = (double*)malloc(NSN * Nmom * NTd * sizeof(double)); - my_rates->SN0_kpH2Oice = (double*)malloc(NSN * Nmom * NTd * sizeof(double)); + my_rates->SN0_kpSiM = inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::SiM_dust]; + my_rates->SN0_kpFeM = inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::FeM_dust]; + my_rates->SN0_kpMg2SiO4 = inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Mg2SiO4_dust]; + my_rates->SN0_kpMgSiO3 = inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::MgSiO3_dust]; + my_rates->SN0_kpFe3O4 = inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Fe3O4_dust]; + my_rates->SN0_kpAC = inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::AC_dust]; + my_rates->SN0_kpSiO2D = inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::SiO2_dust]; + my_rates->SN0_kpMgO = inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::MgO_dust]; + my_rates->SN0_kpFeS = inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::FeS_dust]; + my_rates->SN0_kpAl2O3 = inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Al2O3_dust]; + my_rates->SN0_kpreforg = inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::ref_org_dust]; + my_rates->SN0_kpvolorg = inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::vol_org_dust]; + my_rates->SN0_kpH2Oice = inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::H2O_ice_dust]; // zero-out all metal injection yield fractions and dust grain properties override_metal_inject_props(inject_pathway_props, 0.0, n_pathways); - override_dust_inject_props(my_rates, 0.0, n_pathways); + override_dust_inject_props(my_rates, 0.0); SetupCallbackCtx ctx = {my_rates, 0}; @@ -440,19 +420,19 @@ int grackle::impl::free_dust_yields(chemistry_data *my_chemistry, GRACKLE_FREE(my_rates->gr_Td); - GRACKLE_FREE(my_rates->SN0_kpSiM); - GRACKLE_FREE(my_rates->SN0_kpFeM); - GRACKLE_FREE(my_rates->SN0_kpMg2SiO4); - GRACKLE_FREE(my_rates->SN0_kpMgSiO3); - GRACKLE_FREE(my_rates->SN0_kpFe3O4); - GRACKLE_FREE(my_rates->SN0_kpAC); - GRACKLE_FREE(my_rates->SN0_kpSiO2D); - GRACKLE_FREE(my_rates->SN0_kpMgO); - GRACKLE_FREE(my_rates->SN0_kpFeS); - GRACKLE_FREE(my_rates->SN0_kpAl2O3); - GRACKLE_FREE(my_rates->SN0_kpreforg); - GRACKLE_FREE(my_rates->SN0_kpvolorg); - GRACKLE_FREE(my_rates->SN0_kpH2Oice); + my_rates->SN0_kpSiM = nullptr; + my_rates->SN0_kpFeM = nullptr; + my_rates->SN0_kpMg2SiO4 = nullptr; + my_rates->SN0_kpMgSiO3 = nullptr; + my_rates->SN0_kpFe3O4 = nullptr; + my_rates->SN0_kpAC = nullptr; + my_rates->SN0_kpSiO2D = nullptr; + my_rates->SN0_kpMgO = nullptr; + my_rates->SN0_kpFeS = nullptr; + my_rates->SN0_kpAl2O3 = nullptr; + my_rates->SN0_kpreforg = nullptr; + my_rates->SN0_kpvolorg = nullptr; + my_rates->SN0_kpH2Oice = nullptr; return SUCCESS; } From 6468b3bca6fdae3342d86ba80d7a5047d969eaad Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Mon, 8 Dec 2025 17:04:00 -0500 Subject: [PATCH 043/175] another massive step towards removing SN0_kp and SN0_r0 --- src/clib/fortran_func_wrappers.hpp | 34 +++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/src/clib/fortran_func_wrappers.hpp b/src/clib/fortran_func_wrappers.hpp index d6d893edc..c92c24fec 100644 --- a/src/clib/fortran_func_wrappers.hpp +++ b/src/clib/fortran_func_wrappers.hpp @@ -122,15 +122,33 @@ inline void calc_grain_size_increment_1d ( my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::ref_org_dust], my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::vol_org_dust], my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::H2O_ice_dust], - my_rates->SN0_r0SiM, my_rates->SN0_r0FeM, my_rates->SN0_r0Mg2SiO4, my_rates->SN0_r0MgSiO3, - my_rates->SN0_r0Fe3O4, my_rates->SN0_r0AC, my_rates->SN0_r0SiO2D, my_rates->SN0_r0MgO, - my_rates->SN0_r0FeS, my_rates->SN0_r0Al2O3, - my_rates->SN0_r0reforg, my_rates->SN0_r0volorg, my_rates->SN0_r0H2Oice, + my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::SiM_dust], + my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::FeM_dust], + my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::Mg2SiO4_dust], + my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::MgSiO3_dust], + my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::Fe3O4_dust], + my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::AC_dust], + my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::SiO2_dust], + my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::MgO_dust], + my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::FeS_dust], + my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::Al2O3_dust], + my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::ref_org_dust], + my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::vol_org_dust], + my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::H2O_ice_dust], my_rates->gr_N, &my_rates->gr_Size, &my_rates->gr_dT, my_rates->gr_Td, - my_rates->SN0_kpSiM, my_rates->SN0_kpFeM, my_rates->SN0_kpMg2SiO4, my_rates->SN0_kpMgSiO3, - my_rates->SN0_kpFe3O4, my_rates->SN0_kpAC, my_rates->SN0_kpSiO2D, my_rates->SN0_kpMgO, - my_rates->SN0_kpFeS, my_rates->SN0_kpAl2O3, - my_rates->SN0_kpreforg, my_rates->SN0_kpvolorg, my_rates->SN0_kpH2Oice, + my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::SiM_dust], + my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::FeM_dust], + my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Mg2SiO4_dust], + my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::MgSiO3_dust], + my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Fe3O4_dust], + my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::AC_dust], + my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::SiO2_dust], + my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::MgO_dust], + my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::FeS_dust], + my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Al2O3_dust], + my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::ref_org_dust], + my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::vol_org_dust], + my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::H2O_ice_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiM_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeM_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Mg2SiO4_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgSiO3_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Fe3O4_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::AC_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiO2_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgO_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeS_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Al2O3_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::ref_org_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::vol_org_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::H2O_ice_dust], internal_dust_prop_buf.sigma_per_gas_mass_tot, From 4eee4ee47860a7051ffcc64beeb56f4d8837d31b Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Mon, 8 Dec 2025 17:37:42 -0500 Subject: [PATCH 044/175] finish removing SN0_kp and SN0_r0 --- src/clib/initialize_chemistry_data.cpp | 26 ------------ src/clib/initialize_dust_yields.cpp | 56 -------------------------- src/include/grackle_chemistry_data.h | 6 --- 3 files changed, 88 deletions(-) diff --git a/src/clib/initialize_chemistry_data.cpp b/src/clib/initialize_chemistry_data.cpp index 4279aab75..e42e07896 100644 --- a/src/clib/initialize_chemistry_data.cpp +++ b/src/clib/initialize_chemistry_data.cpp @@ -161,32 +161,6 @@ static void initialize_empty_chemistry_data_storage_struct(chemistry_data_storag my_rates->SN0_fSi = nullptr; my_rates->SN0_fS = nullptr; my_rates->SN0_fFe = nullptr; - my_rates->SN0_r0SiM = NULL; - my_rates->SN0_r0FeM = NULL; - my_rates->SN0_r0Mg2SiO4 = NULL; - my_rates->SN0_r0MgSiO3 = NULL; - my_rates->SN0_r0Fe3O4 = NULL; - my_rates->SN0_r0AC = NULL; - my_rates->SN0_r0SiO2D = NULL; - my_rates->SN0_r0MgO = NULL; - my_rates->SN0_r0FeS = NULL; - my_rates->SN0_r0Al2O3 = NULL; - my_rates->SN0_r0reforg = NULL; - my_rates->SN0_r0volorg = NULL; - my_rates->SN0_r0H2Oice = NULL; - my_rates->SN0_kpSiM = NULL; - my_rates->SN0_kpFeM = NULL; - my_rates->SN0_kpMg2SiO4 = NULL; - my_rates->SN0_kpMgSiO3 = NULL; - my_rates->SN0_kpFe3O4 = NULL; - my_rates->SN0_kpAC = NULL; - my_rates->SN0_kpSiO2D = NULL; - my_rates->SN0_kpMgO = NULL; - my_rates->SN0_kpFeS = NULL; - my_rates->SN0_kpAl2O3 = NULL; - my_rates->SN0_kpreforg = NULL; - my_rates->SN0_kpvolorg = NULL; - my_rates->SN0_kpH2Oice = NULL; my_rates->cloudy_data_new = -1; diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index 22f6bc49c..3594d098b 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -305,20 +305,6 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, my_rates->SN0_fS = inject_pathway_props->gas_metal_nuclide_yields.S; my_rates->SN0_fFe = inject_pathway_props->gas_metal_nuclide_yields.Fe; - my_rates->SN0_r0SiM = inject_pathway_props->size_moments.data[OnlyGrainSpLUT::SiM_dust]; - my_rates->SN0_r0FeM = inject_pathway_props->size_moments.data[OnlyGrainSpLUT::FeM_dust]; - my_rates->SN0_r0Mg2SiO4 = inject_pathway_props->size_moments.data[OnlyGrainSpLUT::Mg2SiO4_dust]; - my_rates->SN0_r0MgSiO3 = inject_pathway_props->size_moments.data[OnlyGrainSpLUT::MgSiO3_dust]; - my_rates->SN0_r0Fe3O4 = inject_pathway_props->size_moments.data[OnlyGrainSpLUT::Fe3O4_dust]; - my_rates->SN0_r0AC = inject_pathway_props->size_moments.data[OnlyGrainSpLUT::AC_dust]; - my_rates->SN0_r0SiO2D = inject_pathway_props->size_moments.data[OnlyGrainSpLUT::SiO2_dust]; - my_rates->SN0_r0MgO = inject_pathway_props->size_moments.data[OnlyGrainSpLUT::MgO_dust]; - my_rates->SN0_r0FeS = inject_pathway_props->size_moments.data[OnlyGrainSpLUT::FeS_dust]; - my_rates->SN0_r0Al2O3 = inject_pathway_props->size_moments.data[OnlyGrainSpLUT::Al2O3_dust]; - my_rates->SN0_r0reforg = inject_pathway_props->size_moments.data[OnlyGrainSpLUT::ref_org_dust]; - my_rates->SN0_r0volorg = inject_pathway_props->size_moments.data[OnlyGrainSpLUT::vol_org_dust]; - my_rates->SN0_r0H2Oice = inject_pathway_props->size_moments.data[OnlyGrainSpLUT::H2O_ice_dust]; - // write out the opacity related quantities // todo: consider renaming Nmom -> Ncoef @@ -355,20 +341,6 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, my_rates->gr_Td[iTd] = Td0 + (double)iTd * dTd; } - my_rates->SN0_kpSiM = inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::SiM_dust]; - my_rates->SN0_kpFeM = inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::FeM_dust]; - my_rates->SN0_kpMg2SiO4 = inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Mg2SiO4_dust]; - my_rates->SN0_kpMgSiO3 = inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::MgSiO3_dust]; - my_rates->SN0_kpFe3O4 = inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Fe3O4_dust]; - my_rates->SN0_kpAC = inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::AC_dust]; - my_rates->SN0_kpSiO2D = inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::SiO2_dust]; - my_rates->SN0_kpMgO = inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::MgO_dust]; - my_rates->SN0_kpFeS = inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::FeS_dust]; - my_rates->SN0_kpAl2O3 = inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Al2O3_dust]; - my_rates->SN0_kpreforg = inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::ref_org_dust]; - my_rates->SN0_kpvolorg = inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::vol_org_dust]; - my_rates->SN0_kpH2Oice = inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::H2O_ice_dust]; - // zero-out all metal injection yield fractions and dust grain properties override_metal_inject_props(inject_pathway_props, 0.0, n_pathways); @@ -404,36 +376,8 @@ int grackle::impl::free_dust_yields(chemistry_data *my_chemistry, my_rates->SN0_fS = nullptr; my_rates->SN0_fFe = nullptr; - my_rates->SN0_r0SiM = nullptr; - my_rates->SN0_r0FeM = nullptr; - my_rates->SN0_r0Mg2SiO4 = nullptr; - my_rates->SN0_r0MgSiO3 = nullptr; - my_rates->SN0_r0Fe3O4 = nullptr; - my_rates->SN0_r0AC = nullptr; - my_rates->SN0_r0SiO2D = nullptr; - my_rates->SN0_r0MgO = nullptr; - my_rates->SN0_r0FeS = nullptr; - my_rates->SN0_r0Al2O3 = nullptr; - my_rates->SN0_r0reforg = nullptr; - my_rates->SN0_r0volorg = nullptr; - my_rates->SN0_r0H2Oice = nullptr; - GRACKLE_FREE(my_rates->gr_Td); - my_rates->SN0_kpSiM = nullptr; - my_rates->SN0_kpFeM = nullptr; - my_rates->SN0_kpMg2SiO4 = nullptr; - my_rates->SN0_kpMgSiO3 = nullptr; - my_rates->SN0_kpFe3O4 = nullptr; - my_rates->SN0_kpAC = nullptr; - my_rates->SN0_kpSiO2D = nullptr; - my_rates->SN0_kpMgO = nullptr; - my_rates->SN0_kpFeS = nullptr; - my_rates->SN0_kpAl2O3 = nullptr; - my_rates->SN0_kpreforg = nullptr; - my_rates->SN0_kpvolorg = nullptr; - my_rates->SN0_kpH2Oice = nullptr; - return SUCCESS; } diff --git a/src/include/grackle_chemistry_data.h b/src/include/grackle_chemistry_data.h index f18cfe928..91d989186 100644 --- a/src/include/grackle_chemistry_data.h +++ b/src/include/grackle_chemistry_data.h @@ -610,12 +610,6 @@ typedef struct double gr_dT, *gr_Td; int SN0_N; double *SN0_fC , *SN0_fO , *SN0_fMg, *SN0_fAl, *SN0_fSi, *SN0_fS , *SN0_fFe; - double *SN0_r0SiM, *SN0_r0FeM, *SN0_r0Mg2SiO4, *SN0_r0MgSiO3, *SN0_r0Fe3O4 - , *SN0_r0AC, *SN0_r0SiO2D, *SN0_r0MgO, *SN0_r0FeS, *SN0_r0Al2O3 - , *SN0_r0reforg , *SN0_r0volorg , *SN0_r0H2Oice; - double *SN0_kpSiM, *SN0_kpFeM, *SN0_kpMg2SiO4, *SN0_kpMgSiO3, *SN0_kpFe3O4 - , *SN0_kpAC, *SN0_kpSiO2D, *SN0_kpMgO, *SN0_kpFeS, *SN0_kpAl2O3 - , *SN0_kpreforg , *SN0_kpvolorg , *SN0_kpH2Oice; /* UV background data */ UVBtable UVbackground_table; From 762e53c5c41423e7548697e011af3ad233e2bf93 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Mon, 8 Dec 2025 17:41:30 -0500 Subject: [PATCH 045/175] remove SN0_f --- src/clib/initialize_chemistry_data.cpp | 7 ------- src/clib/initialize_dust_yields.cpp | 21 --------------------- src/include/grackle_chemistry_data.h | 1 - 3 files changed, 29 deletions(-) diff --git a/src/clib/initialize_chemistry_data.cpp b/src/clib/initialize_chemistry_data.cpp index e42e07896..3b956779f 100644 --- a/src/clib/initialize_chemistry_data.cpp +++ b/src/clib/initialize_chemistry_data.cpp @@ -154,13 +154,6 @@ static void initialize_empty_chemistry_data_storage_struct(chemistry_data_storag my_rates->gr_dT = 0.; my_rates->gr_Td = NULL; my_rates->SN0_N = 0; - my_rates->SN0_fC = nullptr; - my_rates->SN0_fO = nullptr; - my_rates->SN0_fMg = nullptr; - my_rates->SN0_fAl = nullptr; - my_rates->SN0_fSi = nullptr; - my_rates->SN0_fS = nullptr; - my_rates->SN0_fFe = nullptr; my_rates->cloudy_data_new = -1; diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index 3594d098b..74d67a75b 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -296,17 +296,6 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, int NSN = n_pathways; // todo: delete me! my_rates->SN0_N = n_pathways; - // crude hack (holding onto this momentarily) - my_rates->SN0_fC = inject_pathway_props->gas_metal_nuclide_yields.C; - my_rates->SN0_fO = inject_pathway_props->gas_metal_nuclide_yields.O; - my_rates->SN0_fMg = inject_pathway_props->gas_metal_nuclide_yields.Mg; - my_rates->SN0_fAl = inject_pathway_props->gas_metal_nuclide_yields.Al; - my_rates->SN0_fSi = inject_pathway_props->gas_metal_nuclide_yields.Si; - my_rates->SN0_fS = inject_pathway_props->gas_metal_nuclide_yields.S; - my_rates->SN0_fFe = inject_pathway_props->gas_metal_nuclide_yields.Fe; - - // write out the opacity related quantities - // todo: consider renaming Nmom -> Ncoef int Nmom = n_opac_poly_coef; // todo: remove me! // todo: more this into GrainMetalInjectPathways @@ -366,16 +355,6 @@ int grackle::impl::free_dust_yields(chemistry_data *my_chemistry, if (my_chemistry->metal_chemistry == 0) return SUCCESS; - // reminder: we are holding on to SN0_f as a crude hack (we will - // delete them later) - my_rates->SN0_fC = nullptr; - my_rates->SN0_fO = nullptr; - my_rates->SN0_fMg = nullptr; - my_rates->SN0_fAl = nullptr; - my_rates->SN0_fSi = nullptr; - my_rates->SN0_fS = nullptr; - my_rates->SN0_fFe = nullptr; - GRACKLE_FREE(my_rates->gr_Td); return SUCCESS; diff --git a/src/include/grackle_chemistry_data.h b/src/include/grackle_chemistry_data.h index 91d989186..24839baed 100644 --- a/src/include/grackle_chemistry_data.h +++ b/src/include/grackle_chemistry_data.h @@ -609,7 +609,6 @@ typedef struct int *gr_N, gr_Size; double gr_dT, *gr_Td; int SN0_N; - double *SN0_fC , *SN0_fO , *SN0_fMg, *SN0_fAl, *SN0_fSi, *SN0_fS , *SN0_fFe; /* UV background data */ UVBtable UVbackground_table; From 57caed782deea8c7fb02f18451fabf94d451dc20 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Mon, 8 Dec 2025 17:50:56 -0500 Subject: [PATCH 046/175] remove gr_dT --- src/clib/fortran_func_wrappers.hpp | 7 +++++-- src/clib/initialize_chemistry_data.cpp | 1 - src/clib/initialize_dust_yields.cpp | 8 ++++---- src/include/grackle_chemistry_data.h | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/clib/fortran_func_wrappers.hpp b/src/clib/fortran_func_wrappers.hpp index c92c24fec..469445a56 100644 --- a/src/clib/fortran_func_wrappers.hpp +++ b/src/clib/fortran_func_wrappers.hpp @@ -56,7 +56,8 @@ inline void calc_all_tdust_gasgr_1d_g( &trad, my_rates->gas_grain, logTlininterp_buf.indixe, logTlininterp_buf.tdef, tgas, tdust, metallicity, dust2gas, nh, gasgr_tdust, itmask_metal, - &my_chemistry->dust_species, &my_chemistry->use_multiple_dust_temperatures, my_rates->gr_N, &my_rates->gr_Size, &my_rates->gr_dT, + &my_chemistry->dust_species, &my_chemistry->use_multiple_dust_temperatures, my_rates->gr_N, &my_rates->gr_Size, + &my_rates->opaque_storage->inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], my_rates->gr_Td, grain_temperatures.data[OnlyGrainSpLUT::SiM_dust], grain_temperatures.data[OnlyGrainSpLUT::FeM_dust], grain_temperatures.data[OnlyGrainSpLUT::Mg2SiO4_dust], grain_temperatures.data[OnlyGrainSpLUT::MgSiO3_dust], grain_temperatures.data[OnlyGrainSpLUT::Fe3O4_dust], grain_temperatures.data[OnlyGrainSpLUT::AC_dust], grain_temperatures.data[OnlyGrainSpLUT::SiO2_dust], grain_temperatures.data[OnlyGrainSpLUT::MgO_dust], grain_temperatures.data[OnlyGrainSpLUT::FeS_dust], grain_temperatures.data[OnlyGrainSpLUT::Al2O3_dust], grain_temperatures.data[OnlyGrainSpLUT::ref_org_dust], grain_temperatures.data[OnlyGrainSpLUT::vol_org_dust], grain_temperatures.data[OnlyGrainSpLUT::H2O_ice_dust], my_rates->gas_grain2, &my_rates->gamma_isrf2, @@ -135,7 +136,9 @@ inline void calc_grain_size_increment_1d ( my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::ref_org_dust], my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::vol_org_dust], my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::H2O_ice_dust], - my_rates->gr_N, &my_rates->gr_Size, &my_rates->gr_dT, my_rates->gr_Td, + my_rates->gr_N, &my_rates->gr_Size, + &my_rates->opaque_storage->inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], + my_rates->gr_Td, my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::SiM_dust], my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::FeM_dust], my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Mg2SiO4_dust], diff --git a/src/clib/initialize_chemistry_data.cpp b/src/clib/initialize_chemistry_data.cpp index 3b956779f..5e484581d 100644 --- a/src/clib/initialize_chemistry_data.cpp +++ b/src/clib/initialize_chemistry_data.cpp @@ -151,7 +151,6 @@ static void initialize_empty_chemistry_data_storage_struct(chemistry_data_storag my_rates->gr_N = NULL; my_rates->gr_Size = 0; - my_rates->gr_dT = 0.; my_rates->gr_Td = NULL; my_rates->SN0_N = 0; diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index 74d67a75b..f5f35c61d 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -321,14 +321,14 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, double dTd = 0.1000000; // todo: remove me! // todo: rename gr_Td, dTd since they are related to log10(Tdust) or ln(Tdust) + inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0] = dTd; my_rates->gr_Td = (double*)malloc(NTd * Nmom * sizeof(double)); my_rates->gr_Size = NTd * Nmom; my_rates->gr_N[0] = Nmom; my_rates->gr_N[1] = NTd; - my_rates->gr_dT = dTd; - for(int iTd = 0; iTd < NTd; iTd++) { - my_rates->gr_Td[iTd] = Td0 + (double)iTd * dTd; - } + for(int iTd = 0; iTd < NTd; iTd++) { + my_rates->gr_Td[iTd] = Td0 + (double)iTd * dTd; + } // zero-out all metal injection yield fractions and dust grain properties diff --git a/src/include/grackle_chemistry_data.h b/src/include/grackle_chemistry_data.h index 24839baed..9cc3dc1e5 100644 --- a/src/include/grackle_chemistry_data.h +++ b/src/include/grackle_chemistry_data.h @@ -607,7 +607,7 @@ typedef struct /* metal/dust abundance */ int *gr_N, gr_Size; - double gr_dT, *gr_Td; + double *gr_Td; int SN0_N; /* UV background data */ From d0a37483c57bb42dc809ef7ada9218fea1daae6e Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Mon, 8 Dec 2025 19:06:16 -0500 Subject: [PATCH 047/175] Some steps towards removing gr_N and gr_Size It turns out that `gr_N[1]` is accessed in a lot of places! --- src/clib/fortran_func_wrappers.hpp | 41 +++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/src/clib/fortran_func_wrappers.hpp b/src/clib/fortran_func_wrappers.hpp index 469445a56..95ca7d0df 100644 --- a/src/clib/fortran_func_wrappers.hpp +++ b/src/clib/fortran_func_wrappers.hpp @@ -50,14 +50,36 @@ inline void calc_all_tdust_gasgr_1d_g( grackle::impl::InternalDustPropBuf internal_dust_prop_buf ) { + // after transcription, we should obviously move this logic inside of + // the transcribed function + grackle::impl::GrainMetalInjectPathways* inject_pathway_props = + my_rates->opaque_storage->inject_pathway_props; + + double dlog10Tdust = 0.0; + + // NOTE: gr_N and gr_Size are historical names + // -> they are pretty uninformative and should be changed! + int gr_N[2] = {0, 0}; + int gr_Size = 0; + if (inject_pathway_props != nullptr) { + dlog10Tdust = + inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0]; + + gr_N[0] = inject_pathway_props->n_opac_poly_coef; + gr_N[1] = static_cast( + inject_pathway_props->log10Tdust_interp_props.dimension[0]); + }; + gr_Size = gr_N[0] * gr_N[1]; + + FORTRAN_NAME(calc_all_tdust_gasgr_1d_g)( &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &my_chemistry->NumberOfTemperatureBins, &my_chemistry->use_dust_density_field, &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &my_chemistry->local_dust_to_gas_ratio, &my_rates->gamma_isrf, &trad, my_rates->gas_grain, logTlininterp_buf.indixe, logTlininterp_buf.tdef, tgas, tdust, metallicity, dust2gas, nh, gasgr_tdust, itmask_metal, - &my_chemistry->dust_species, &my_chemistry->use_multiple_dust_temperatures, my_rates->gr_N, &my_rates->gr_Size, - &my_rates->opaque_storage->inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], + &my_chemistry->dust_species, &my_chemistry->use_multiple_dust_temperatures, + gr_N, &gr_Size, &dlog10Tdust, my_rates->gr_Td, grain_temperatures.data[OnlyGrainSpLUT::SiM_dust], grain_temperatures.data[OnlyGrainSpLUT::FeM_dust], grain_temperatures.data[OnlyGrainSpLUT::Mg2SiO4_dust], grain_temperatures.data[OnlyGrainSpLUT::MgSiO3_dust], grain_temperatures.data[OnlyGrainSpLUT::Fe3O4_dust], grain_temperatures.data[OnlyGrainSpLUT::AC_dust], grain_temperatures.data[OnlyGrainSpLUT::SiO2_dust], grain_temperatures.data[OnlyGrainSpLUT::MgO_dust], grain_temperatures.data[OnlyGrainSpLUT::FeS_dust], grain_temperatures.data[OnlyGrainSpLUT::Al2O3_dust], grain_temperatures.data[OnlyGrainSpLUT::ref_org_dust], grain_temperatures.data[OnlyGrainSpLUT::vol_org_dust], grain_temperatures.data[OnlyGrainSpLUT::H2O_ice_dust], my_rates->gas_grain2, &my_rates->gamma_isrf2, @@ -99,6 +121,19 @@ inline void calc_grain_size_increment_1d ( grackle::impl::InternalDustPropBuf internal_dust_prop_buf ) { + // we can be VERY confident that inject_pathway_props is not a nullptr + grackle::impl::GrainMetalInjectPathways* inject_pathway_props = + my_rates->opaque_storage->inject_pathway_props; + + // NOTE: gr_N and gr_Size are historical names + // -> they are pretty uninformative and should be changed! + int gr_N[2] = { + inject_pathway_props->n_opac_poly_coef, + static_cast(inject_pathway_props->log10Tdust_interp_props.dimension[0]) + }; + int gr_Size = gr_N[0] * gr_N[1]; + + FORTRAN_NAME(calc_grain_size_increment_1d)( &my_chemistry->multi_metals, &my_chemistry->metal_abundances, &my_chemistry->dust_species, &my_chemistry->grain_growth, itmask_metal, &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, @@ -136,7 +171,7 @@ inline void calc_grain_size_increment_1d ( my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::ref_org_dust], my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::vol_org_dust], my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::H2O_ice_dust], - my_rates->gr_N, &my_rates->gr_Size, + gr_N, &gr_Size, &my_rates->opaque_storage->inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], my_rates->gr_Td, my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::SiM_dust], From 30fee62f43fdcc9d433bf63763cc83950bba01a0 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Mon, 8 Dec 2025 19:18:36 -0500 Subject: [PATCH 048/175] finish removing gr_N and gr_Size --- src/clib/calc_tdust_3d.cpp | 6 ++++- src/clib/cool1d_multi_g.cpp | 11 +++++--- src/clib/initialize_chemistry_data.cpp | 4 --- src/clib/initialize_dust_yields.cpp | 25 +++++++------------ src/clib/initialize_rates.cpp | 3 --- .../grain_metal_inject_pathways.hpp | 18 +++++++++++++ src/clib/solve_rate_cool_g-cpp.cpp | 9 +++++-- src/clib/step_rate_newton_raphson.hpp | 8 +++++- src/include/grackle_chemistry_data.h | 1 - 9 files changed, 54 insertions(+), 31 deletions(-) diff --git a/src/clib/calc_tdust_3d.cpp b/src/clib/calc_tdust_3d.cpp index 282e89175..82955483b 100644 --- a/src/clib/calc_tdust_3d.cpp +++ b/src/clib/calc_tdust_3d.cpp @@ -21,6 +21,7 @@ #include "fortran_func_wrappers.hpp" #include "grackle.h" #include "index_helper.h" +#include "inject_model/grain_metal_inject_pathways.hpp" #include "internal_types.hpp" #include "scale_fields.hpp" #include "utils-cpp.hpp" @@ -111,7 +112,10 @@ void calc_tdust_3d_g( grackle::impl::InternalDustPropBuf internal_dust_prop_buf = grackle::impl::new_InternalDustPropBuf( - my_fields->grid_dimension[0], my_rates->gr_N[1] + my_fields->grid_dimension[0], + grackle::impl::GrainMetalInjectPathways_get_n_log10Tdust_vals( + my_rates->opaque_storage->inject_pathway_props + ) ); // these next buffer variables hold values that are computed as side-effect diff --git a/src/clib/cool1d_multi_g.cpp b/src/clib/cool1d_multi_g.cpp index 02793cc90..b4295c6be 100644 --- a/src/clib/cool1d_multi_g.cpp +++ b/src/clib/cool1d_multi_g.cpp @@ -22,6 +22,7 @@ #include "fortran_func_decls.h" #include "fortran_func_wrappers.hpp" #include "dust_props.hpp" +#include "inject_model/grain_metal_inject_pathways.hpp" #include "internal_types.hpp" #include "utils-cpp.hpp" @@ -184,8 +185,12 @@ void grackle::impl::cool1d_multi_g( // buffers of intermediate quantities used within dust-routines (for // calculating quantites related to heating/cooling) grackle::impl::InternalDustPropBuf internal_dust_prop_buf = - grackle::impl::new_InternalDustPropBuf(my_fields->grid_dimension[0], - my_rates->gr_N[1]); + grackle::impl::new_InternalDustPropBuf( + my_fields->grid_dimension[0], + GrainMetalInjectPathways_get_n_log10Tdust_vals( + my_rates->opaque_storage->inject_pathway_props + ) + ); // opacity coefficients for each dust grain (the product of opacity // coefficient & gas mass density is the linear absortpion coefficient) grackle::impl::GrainSpeciesCollection grain_kappa = @@ -1969,4 +1974,4 @@ void grackle::impl::cool1d_multi_g( grackle::impl::drop_GrainSpeciesCollection(&gas_grainsp_heatrate); return; -} \ No newline at end of file +} diff --git a/src/clib/initialize_chemistry_data.cpp b/src/clib/initialize_chemistry_data.cpp index 5e484581d..90097ef0a 100644 --- a/src/clib/initialize_chemistry_data.cpp +++ b/src/clib/initialize_chemistry_data.cpp @@ -149,8 +149,6 @@ static void initialize_empty_chemistry_data_storage_struct(chemistry_data_storag grackle::impl::initialize_empty_interp_grid_(&my_rates->alphap); - my_rates->gr_N = NULL; - my_rates->gr_Size = 0; my_rates->gr_Td = NULL; my_rates->SN0_N = 0; @@ -513,8 +511,6 @@ extern "C" int local_free_chemistry_data(chemistry_data *my_chemistry, grackle::impl::free_interp_grid_(&my_rates->alphap); - GRACKLE_FREE(my_rates->gr_N); - GRACKLE_FREE(my_rates->k13dd); GRACKLE_FREE(my_rates->h2dust); GRACKLE_FREE(my_rates->n_cr_n); diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index f5f35c61d..3672d230a 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -219,16 +219,9 @@ void override_metal_inject_props( /// /// @note /// to start, this only handles the grain yields -void override_dust_inject_props(chemistry_data_storage *my_rates, - double value) { - - GRIMPL_REQUIRE(my_rates != nullptr && my_rates->opaque_storage != nullptr, - "sanity check -- should never ever fail!"); - grackle::impl::GrainMetalInjectPathways* inject_pathway_props - = my_rates->opaque_storage->inject_pathway_props; - - GRIMPL_REQUIRE(inject_pathway_props != nullptr, - "sanity check -- should never ever fail!"); +void override_dust_inject_props( + grackle::impl::GrainMetalInjectPathways* inject_pathway_props, + double value) { const int n_grain_species = OnlyGrainSpLUT::NUM_ENTRIES; @@ -254,12 +247,15 @@ void override_dust_inject_props(chemistry_data_storage *my_rates, } // handle the opacity coefficient table - int opac_table_len = n_pathways * my_rates->gr_Size; + long long opac_table_len = ( + static_cast(n_pathways) * + static_cast(inject_pathway_props->n_opac_poly_coef) * + inject_pathway_props->log10Tdust_interp_props.dimension[0]); for (int grain_species_idx = 0; grain_species_idx < n_grain_species; grain_species_idx++){ double* arr = inject_pathway_props->opacity_coef_table.data[grain_species_idx]; - for(int i = 0; i < opac_table_len; i++) { + for(long long i = 0LL; i < opac_table_len; i++) { arr[i] = value; } } @@ -323,9 +319,6 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, // todo: rename gr_Td, dTd since they are related to log10(Tdust) or ln(Tdust) inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0] = dTd; my_rates->gr_Td = (double*)malloc(NTd * Nmom * sizeof(double)); - my_rates->gr_Size = NTd * Nmom; - my_rates->gr_N[0] = Nmom; - my_rates->gr_N[1] = NTd; for(int iTd = 0; iTd < NTd; iTd++) { my_rates->gr_Td[iTd] = Td0 + (double)iTd * dTd; } @@ -333,7 +326,7 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, // zero-out all metal injection yield fractions and dust grain properties override_metal_inject_props(inject_pathway_props, 0.0, n_pathways); - override_dust_inject_props(my_rates, 0.0); + override_dust_inject_props(inject_pathway_props, 0.0); SetupCallbackCtx ctx = {my_rates, 0}; diff --git a/src/clib/initialize_rates.cpp b/src/clib/initialize_rates.cpp index 18909b011..4a3d6c1c2 100644 --- a/src/clib/initialize_rates.cpp +++ b/src/clib/initialize_rates.cpp @@ -471,9 +471,6 @@ int grackle::impl::initialize_rates( double coolingUnits = (pow(my_units->a_units, 5) * pow(lengthBase1, 2) * pow(mh, 2)) / (densityBase1 * pow(timeBase1, 3)); - // These always need to be allocated since we define other variables by them. - my_rates->gr_N = (int*)calloc(2, sizeof(int)); - if (my_chemistry->use_primordial_continuum_opacity == 1) { initialize_primordial_opacity(my_chemistry, my_rates); } diff --git a/src/clib/inject_model/grain_metal_inject_pathways.hpp b/src/clib/inject_model/grain_metal_inject_pathways.hpp index 27e0da85f..9bd59c8fe 100644 --- a/src/clib/inject_model/grain_metal_inject_pathways.hpp +++ b/src/clib/inject_model/grain_metal_inject_pathways.hpp @@ -296,6 +296,24 @@ inline bool GrainMetalInjectPathways_is_valid(const GrainMetalInjectPathways* pt return ptr->n_pathways != -1; } +/// Queries the specified GrainMetalInjectPathways instance for the number of +/// log10(Tdust) values that are relevant for the opacity coefficient table. +/// +/// This function is intended to be called whenever we construct a new +/// InternalDustPropBuf instance. +/// +/// @param[in] ptr The instance to query. It is ok for this to be a `nullptr`, +/// however the result is undefined if GrainMetalInjectPathways_is_valid +/// would return false. +/// +/// @note +/// Frankly, this is intended to be short-term solution until we have a chance +/// to reduce the number of places where InternalDustPropBuf is constructed +inline int GrainMetalInjectPathways_get_n_log10Tdust_vals + (const GrainMetalInjectPathways* ptr) { + return (ptr == nullptr) ? 0 : ptr->log10Tdust_interp_props.dimension[0]; +} + /// performs cleanup of the contents of GrainMetalInjectPathways /// diff --git a/src/clib/solve_rate_cool_g-cpp.cpp b/src/clib/solve_rate_cool_g-cpp.cpp index c7305d6aa..8936c736b 100644 --- a/src/clib/solve_rate_cool_g-cpp.cpp +++ b/src/clib/solve_rate_cool_g-cpp.cpp @@ -21,6 +21,7 @@ #include "grackle.h" #include "fortran_func_wrappers.hpp" #include "index_helper.h" +#include "inject_model/grain_metal_inject_pathways.hpp" #include "internal_types.hpp" #include "internal_units.h" #include "lookup_cool_rates1d.hpp" @@ -712,8 +713,12 @@ int solve_rate_cool_g( // (we can't do it right now since we need to pass in 2 arguments to the // factory function) grackle::impl::InternalDustPropBuf internal_dust_prop_scratch_buf = - grackle::impl::new_InternalDustPropBuf(my_fields->grid_dimension[0], - my_rates->gr_N[1]); + grackle::impl::new_InternalDustPropBuf( + my_fields->grid_dimension[0], + grackle::impl::GrainMetalInjectPathways_get_n_log10Tdust_vals( + my_rates->opaque_storage->inject_pathway_props + ) + ); // holds buffers exclusively used for solving species rate equations // (i.e. in the future, we could have the constructor skip allocations of diff --git a/src/clib/step_rate_newton_raphson.hpp b/src/clib/step_rate_newton_raphson.hpp index e97d5cc68..1d51dac25 100644 --- a/src/clib/step_rate_newton_raphson.hpp +++ b/src/clib/step_rate_newton_raphson.hpp @@ -15,8 +15,10 @@ #include "fortran_func_decls.h" // gr_mask_int #include "fortran_func_wrappers.hpp" // grackle::impl::fortran_wrapper::gaussj_g #include "index_helper.h" +#include "inject_model/grain_metal_inject_pathways.hpp" #include "internal_types.hpp" #include "internal_units.h" +#include "opaque_storage.hpp" #include "utils-cpp.hpp" #include "utils-field.hpp" @@ -212,7 +214,11 @@ inline void step_rate_newton_raphson( // forward the buffers passed into this routine as arguments rather than // allocating separate buffers t_deriv::MainScratchBuf main_scratch_buf = - t_deriv::new_MainScratchBuf(my_rates->gr_N[1]); + t_deriv::new_MainScratchBuf( + grackle::impl::GrainMetalInjectPathways_get_n_log10Tdust_vals( + my_rates->opaque_storage->inject_pathway_props + ) + ); // collect args that are forwarded to the time-derivative calculation and are // effectively frozen between various calls diff --git a/src/include/grackle_chemistry_data.h b/src/include/grackle_chemistry_data.h index 9cc3dc1e5..c3bec8011 100644 --- a/src/include/grackle_chemistry_data.h +++ b/src/include/grackle_chemistry_data.h @@ -606,7 +606,6 @@ typedef struct gr_interp_grid alphap; /* metal/dust abundance */ - int *gr_N, gr_Size; double *gr_Td; int SN0_N; From b9f7893a03dc21f3646104defe384687318cacdc Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Mon, 8 Dec 2025 19:53:46 -0500 Subject: [PATCH 049/175] remove SN0_N --- src/clib/fortran_func_wrappers.hpp | 2 +- src/clib/initialize_chemistry_data.cpp | 1 - src/clib/initialize_dust_yields.cpp | 21 --------------------- src/clib/make_consistent.cpp | 22 +++++++++++++--------- src/include/grackle_chemistry_data.h | 1 - 5 files changed, 14 insertions(+), 33 deletions(-) diff --git a/src/clib/fortran_func_wrappers.hpp b/src/clib/fortran_func_wrappers.hpp index 95ca7d0df..c1c6a1e94 100644 --- a/src/clib/fortran_func_wrappers.hpp +++ b/src/clib/fortran_func_wrappers.hpp @@ -144,7 +144,7 @@ inline void calc_grain_size_increment_1d ( my_fields->ccsn13_metal_density, my_fields->ccsn20_metal_density, my_fields->ccsn25_metal_density, my_fields->ccsn30_metal_density, my_fields->fsn13_metal_density, my_fields->fsn15_metal_density, my_fields->fsn50_metal_density, my_fields->fsn80_metal_density, my_fields->pisn170_metal_density, my_fields->pisn200_metal_density, my_fields->y19_metal_density, - &my_rates->SN0_N, + &inject_pathway_props->n_pathways, my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust], my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust], my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust], diff --git a/src/clib/initialize_chemistry_data.cpp b/src/clib/initialize_chemistry_data.cpp index 90097ef0a..46cf4020d 100644 --- a/src/clib/initialize_chemistry_data.cpp +++ b/src/clib/initialize_chemistry_data.cpp @@ -150,7 +150,6 @@ static void initialize_empty_chemistry_data_storage_struct(chemistry_data_storag grackle::impl::initialize_empty_interp_grid_(&my_rates->alphap); my_rates->gr_Td = NULL; - my_rates->SN0_N = 0; my_rates->cloudy_data_new = -1; diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index 3672d230a..ef85692d7 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -289,29 +289,8 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, } - int NSN = n_pathways; // todo: delete me! - my_rates->SN0_N = n_pathways; - // todo: consider renaming Nmom -> Ncoef int Nmom = n_opac_poly_coef; // todo: remove me! - // todo: more this into GrainMetalInjectPathways - // - essentially, each SN0_kpGRSP array is a 3D array of shape - // (n_pathways, NTd, Nmom). This shape uses numpy conventions (i.e. Nmom is - // the fast-axis). - // - In more detail: - // - n_pathways is the number of injection pathways - // - NTd corresponds to the number of dust temperatures we consider - // - Nmom corresponds to the number of coefficients that we track for - // computing an opacity related quantity. This quantity is given by - // 4πζ/3 * ( SN0_kpGRSP[path_j, iTd, 3] + - // SN0_kpGRSP[path_j, iTd, 2] * δr(t) + - // SN0_kpGRSP[path_j, iTd, 1] * δr²(t) + - // SN0_kpGRSP[path_j, iTd, 0] * δr³(t)) - // where - // - ζ is the mass density of a single grain (in g/cm³) - // - δr(t) refers to the derived "size increment" (it is a central - // quantity in the model) - // - I **think** the resulting quantity is the optical cross-section double NTd = n_log10Tdust_vals; double Td0 = 0.0000000; // todo: remove me! double dTd = 0.1000000; // todo: remove me! diff --git a/src/clib/make_consistent.cpp b/src/clib/make_consistent.cpp index 980e9d37d..b5f5eed89 100644 --- a/src/clib/make_consistent.cpp +++ b/src/clib/make_consistent.cpp @@ -242,11 +242,19 @@ void make_consistent(int imetal, double dom, chemistry_data* my_chemistry, correctFe; gr_float correctCg, correctOg, correctMgg, correctSig, correctFeg; gr_float correctCd, correctOd, correctMgd, correctSid, correctFed; - int iSN, nSN, iSN0; + int iSN, iSN0; + + const grackle::impl::GrainMetalInjectPathways* inject_pathway_props = + my_rates->opaque_storage->inject_pathway_props; + const int n_pathways = (inject_pathway_props == nullptr) ? 0 : + inject_pathway_props->n_pathways; std::vector SN_metal_data_(my_fields->grid_dimension[0] * - my_rates->SN0_N); - grackle::impl::View SN_metal( - SN_metal_data_.data(), my_fields->grid_dimension[0], my_rates->SN0_N); + n_pathways); + grackle::impl::View SN_metal; + if (n_pathways > 0) { + SN_metal = grackle::impl::View( + SN_metal_data_.data(), my_fields->grid_dimension[0], n_pathways); + } std::vector Ct(my_fields->grid_dimension[0]); std::vector Ot(my_fields->grid_dimension[0]); std::vector Mgt(my_fields->grid_dimension[0]); @@ -269,9 +277,6 @@ void make_consistent(int imetal, double dom, chemistry_data* my_chemistry, std::vector Sd(my_fields->grid_dimension[0]); std::vector Fed(my_fields->grid_dimension[0]); - const grackle::impl::GrainMetalInjectPathways* inject_pathway_props = - my_rates->opaque_storage->inject_pathway_props; - // Loop over all zones for (k = my_fields->grid_start[2]; k <= my_fields->grid_end[2]; k++) { @@ -393,7 +398,6 @@ void make_consistent(int imetal, double dom, chemistry_data* my_chemistry, // metal_Y19(i,j,k) = metal_Y19(i,j,k) * correctZ // enddo - nSN = 12; for (i = my_fields->grid_start[0]; i <= my_fields->grid_end[0]; i++) { SN_metal(i, 0) = metal_loc(i, j, k); SN_metal(i, 1) = metal_C13(i, j, k); @@ -424,7 +428,7 @@ void make_consistent(int imetal, double dom, chemistry_data* my_chemistry, Sg[i] = 0.; Fet[i] = 0.; Feg[i] = 0.; - for (iSN = 0; iSN < nSN; iSN++) { + for (iSN = 0; iSN < n_pathways; iSN++) { Ct[i] = Ct[i] + total_metal_yields.C[iSN] * SN_metal(i, iSN); Ot[i] = Ot[i] + total_metal_yields.O[iSN] * SN_metal(i, iSN); Mgt[i] = Mgt[i] + total_metal_yields.Mg[iSN] * SN_metal(i, iSN); diff --git a/src/include/grackle_chemistry_data.h b/src/include/grackle_chemistry_data.h index c3bec8011..c7b059b5f 100644 --- a/src/include/grackle_chemistry_data.h +++ b/src/include/grackle_chemistry_data.h @@ -607,7 +607,6 @@ typedef struct /* metal/dust abundance */ double *gr_Td; - int SN0_N; /* UV background data */ UVBtable UVbackground_table; From 8dccc0e7d27cb817a754f9bb3b0c01a0d1fd67a1 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Mon, 8 Dec 2025 20:11:05 -0500 Subject: [PATCH 050/175] remove gr_Td --- src/clib/fortran_func_wrappers.hpp | 9 ++++++--- src/clib/initialize_chemistry_data.cpp | 2 -- src/clib/initialize_dust_yields.cpp | 27 +++++++++----------------- src/include/grackle_chemistry_data.h | 3 --- 4 files changed, 15 insertions(+), 26 deletions(-) diff --git a/src/clib/fortran_func_wrappers.hpp b/src/clib/fortran_func_wrappers.hpp index c1c6a1e94..e02cc9eed 100644 --- a/src/clib/fortran_func_wrappers.hpp +++ b/src/clib/fortran_func_wrappers.hpp @@ -56,6 +56,7 @@ inline void calc_all_tdust_gasgr_1d_g( my_rates->opaque_storage->inject_pathway_props; double dlog10Tdust = 0.0; + double* log10Tdust_vals = nullptr; // NOTE: gr_N and gr_Size are historical names // -> they are pretty uninformative and should be changed! @@ -64,6 +65,8 @@ inline void calc_all_tdust_gasgr_1d_g( if (inject_pathway_props != nullptr) { dlog10Tdust = inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0]; + log10Tdust_vals = + inject_pathway_props->log10Tdust_interp_props.parameters[0]; gr_N[0] = inject_pathway_props->n_opac_poly_coef; gr_N[1] = static_cast( @@ -79,8 +82,8 @@ inline void calc_all_tdust_gasgr_1d_g( metallicity, dust2gas, nh, gasgr_tdust, itmask_metal, &my_chemistry->dust_species, &my_chemistry->use_multiple_dust_temperatures, - gr_N, &gr_Size, &dlog10Tdust, - my_rates->gr_Td, grain_temperatures.data[OnlyGrainSpLUT::SiM_dust], grain_temperatures.data[OnlyGrainSpLUT::FeM_dust], grain_temperatures.data[OnlyGrainSpLUT::Mg2SiO4_dust], grain_temperatures.data[OnlyGrainSpLUT::MgSiO3_dust], grain_temperatures.data[OnlyGrainSpLUT::Fe3O4_dust], + gr_N, &gr_Size, &dlog10Tdust, log10Tdust_vals, + grain_temperatures.data[OnlyGrainSpLUT::SiM_dust], grain_temperatures.data[OnlyGrainSpLUT::FeM_dust], grain_temperatures.data[OnlyGrainSpLUT::Mg2SiO4_dust], grain_temperatures.data[OnlyGrainSpLUT::MgSiO3_dust], grain_temperatures.data[OnlyGrainSpLUT::Fe3O4_dust], grain_temperatures.data[OnlyGrainSpLUT::AC_dust], grain_temperatures.data[OnlyGrainSpLUT::SiO2_dust], grain_temperatures.data[OnlyGrainSpLUT::MgO_dust], grain_temperatures.data[OnlyGrainSpLUT::FeS_dust], grain_temperatures.data[OnlyGrainSpLUT::Al2O3_dust], grain_temperatures.data[OnlyGrainSpLUT::ref_org_dust], grain_temperatures.data[OnlyGrainSpLUT::vol_org_dust], grain_temperatures.data[OnlyGrainSpLUT::H2O_ice_dust], my_rates->gas_grain2, &my_rates->gamma_isrf2, &coolunit, gasgr, myisrf, internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiM_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeM_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Mg2SiO4_dust], @@ -173,7 +176,7 @@ inline void calc_grain_size_increment_1d ( my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::H2O_ice_dust], gr_N, &gr_Size, &my_rates->opaque_storage->inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], - my_rates->gr_Td, + inject_pathway_props->log10Tdust_interp_props.parameters[0], my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::SiM_dust], my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::FeM_dust], my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Mg2SiO4_dust], diff --git a/src/clib/initialize_chemistry_data.cpp b/src/clib/initialize_chemistry_data.cpp index 46cf4020d..f3c266c7d 100644 --- a/src/clib/initialize_chemistry_data.cpp +++ b/src/clib/initialize_chemistry_data.cpp @@ -149,8 +149,6 @@ static void initialize_empty_chemistry_data_storage_struct(chemistry_data_storag grackle::impl::initialize_empty_interp_grid_(&my_rates->alphap); - my_rates->gr_Td = NULL; - my_rates->cloudy_data_new = -1; my_rates->opaque_storage = NULL; diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index ef85692d7..4f1acdaa1 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -288,18 +288,15 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, return GR_FAIL; } - - // todo: consider renaming Nmom -> Ncoef - int Nmom = n_opac_poly_coef; // todo: remove me! - double NTd = n_log10Tdust_vals; - double Td0 = 0.0000000; // todo: remove me! - double dTd = 0.1000000; // todo: remove me! - - // todo: rename gr_Td, dTd since they are related to log10(Tdust) or ln(Tdust) - inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0] = dTd; - my_rates->gr_Td = (double*)malloc(NTd * Nmom * sizeof(double)); - for(int iTd = 0; iTd < NTd; iTd++) { - my_rates->gr_Td[iTd] = Td0 + (double)iTd * dTd; + double log10Tdust_lo = 0.0; + double log10Tdust_step = 0.1; + + inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0] + = log10Tdust_step; + double* log10Tdust_vals = + inject_pathway_props->log10Tdust_interp_props.parameters[0]; + for(int iTd = 0; iTd < n_log10Tdust_vals; iTd++) { + log10Tdust_vals[iTd] = log10Tdust_lo + (double)iTd * log10Tdust_step; } @@ -323,12 +320,6 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, int grackle::impl::free_dust_yields(chemistry_data *my_chemistry, chemistry_data_storage *my_rates) { - - if (my_chemistry->metal_chemistry == 0) - return SUCCESS; - - GRACKLE_FREE(my_rates->gr_Td); - return SUCCESS; } diff --git a/src/include/grackle_chemistry_data.h b/src/include/grackle_chemistry_data.h index c7b059b5f..0881952b3 100644 --- a/src/include/grackle_chemistry_data.h +++ b/src/include/grackle_chemistry_data.h @@ -605,9 +605,6 @@ typedef struct * -> alphap.parameters[1] is log10(temperature) */ gr_interp_grid alphap; - /* metal/dust abundance */ - double *gr_Td; - /* UV background data */ UVBtable UVbackground_table; From 24748cbd83b9a67e940c5404e0509c3822d8094b Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Mon, 8 Dec 2025 20:37:20 -0500 Subject: [PATCH 051/175] tweak signature of f_wrap::calc_grain_size_increment_1d --- src/clib/calc_tdust_3d.cpp | 3 +- src/clib/cool1d_multi_g.cpp | 3 +- src/clib/fortran_func_wrappers.hpp | 90 +++++++++++++++--------------- src/clib/lookup_cool_rates1d.hpp | 4 +- 4 files changed, 51 insertions(+), 49 deletions(-) diff --git a/src/clib/calc_tdust_3d.cpp b/src/clib/calc_tdust_3d.cpp index 82955483b..27dbc6e54 100644 --- a/src/clib/calc_tdust_3d.cpp +++ b/src/clib/calc_tdust_3d.cpp @@ -165,7 +165,8 @@ void calc_tdust_3d_g( if ( (my_chemistry->use_dust_density_field > 0) && (my_chemistry->dust_species > 0) ) { f_wrap::calc_grain_size_increment_1d ( - dom, idx_range, itmask_metal.data(), my_chemistry, my_rates, + dom, idx_range, itmask_metal.data(), my_chemistry, + my_rates->opaque_storage->inject_pathway_props, my_fields, internal_dust_prop_buf ); diff --git a/src/clib/cool1d_multi_g.cpp b/src/clib/cool1d_multi_g.cpp index b4295c6be..5bf09eb77 100644 --- a/src/clib/cool1d_multi_g.cpp +++ b/src/clib/cool1d_multi_g.cpp @@ -1107,7 +1107,8 @@ void grackle::impl::cool1d_multi_g( if ((my_chemistry->use_dust_density_field > 0) && (my_chemistry->dust_species > 0)) { grackle::impl::fortran_wrapper::calc_grain_size_increment_1d( - dom, idx_range, itmask_metal, my_chemistry, my_rates, my_fields, + dom, idx_range, itmask_metal, my_chemistry, + my_rates->opaque_storage->inject_pathway_props, my_fields, internal_dust_prop_buf); } diff --git a/src/clib/fortran_func_wrappers.hpp b/src/clib/fortran_func_wrappers.hpp index e02cc9eed..bf84c665d 100644 --- a/src/clib/fortran_func_wrappers.hpp +++ b/src/clib/fortran_func_wrappers.hpp @@ -113,21 +113,19 @@ inline void calc_all_tdust_gasgr_1d_g( /// @param[in] idx_range Specifies the current index-range /// @param[in] itmask_metal Specifies the `idx_range`'s iteration-mask /// @param[in] my_chemistry holds a number of configuration parameters -/// @param[in] my_rates holds assorted rate data. +/// @param[in] inject_pathway_props holds data about the modelled injection +/// pathways for all of the grain species. /// @param[in] my_fields specifies the field data /// @param[in,out] internal_dust_prop_buf Holds dust-specific information that /// gets updated by this function inline void calc_grain_size_increment_1d ( double dom, IndexRange idx_range, const gr_mask_type* itmask_metal, - chemistry_data* my_chemistry, chemistry_data_storage* my_rates, + chemistry_data* my_chemistry, + grackle::impl::GrainMetalInjectPathways* inject_pathway_props, grackle_field_data* my_fields, grackle::impl::InternalDustPropBuf internal_dust_prop_buf ) { - // we can be VERY confident that inject_pathway_props is not a nullptr - grackle::impl::GrainMetalInjectPathways* inject_pathway_props = - my_rates->opaque_storage->inject_pathway_props; - // NOTE: gr_N and gr_Size are historical names // -> they are pretty uninformative and should be changed! int gr_N[2] = { @@ -148,48 +146,48 @@ inline void calc_grain_size_increment_1d ( my_fields->fsn13_metal_density, my_fields->fsn15_metal_density, my_fields->fsn50_metal_density, my_fields->fsn80_metal_density, my_fields->pisn170_metal_density, my_fields->pisn200_metal_density, my_fields->y19_metal_density, &inject_pathway_props->n_pathways, - my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust], - my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust], - my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust], - my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust], - my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Fe3O4_dust], - my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust], - my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust], - my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgO_dust], - my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeS_dust], - my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Al2O3_dust], - my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::ref_org_dust], - my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::vol_org_dust], - my_rates->opaque_storage->inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::H2O_ice_dust], - my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::SiM_dust], - my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::FeM_dust], - my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::Mg2SiO4_dust], - my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::MgSiO3_dust], - my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::Fe3O4_dust], - my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::AC_dust], - my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::SiO2_dust], - my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::MgO_dust], - my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::FeS_dust], - my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::Al2O3_dust], - my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::ref_org_dust], - my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::vol_org_dust], - my_rates->opaque_storage->inject_pathway_props->size_moments.data[OnlyGrainSpLUT::H2O_ice_dust], + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust], + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust], + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust], + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust], + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Fe3O4_dust], + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust], + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust], + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgO_dust], + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeS_dust], + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Al2O3_dust], + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::ref_org_dust], + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::vol_org_dust], + inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::H2O_ice_dust], + inject_pathway_props->size_moments.data[OnlyGrainSpLUT::SiM_dust], + inject_pathway_props->size_moments.data[OnlyGrainSpLUT::FeM_dust], + inject_pathway_props->size_moments.data[OnlyGrainSpLUT::Mg2SiO4_dust], + inject_pathway_props->size_moments.data[OnlyGrainSpLUT::MgSiO3_dust], + inject_pathway_props->size_moments.data[OnlyGrainSpLUT::Fe3O4_dust], + inject_pathway_props->size_moments.data[OnlyGrainSpLUT::AC_dust], + inject_pathway_props->size_moments.data[OnlyGrainSpLUT::SiO2_dust], + inject_pathway_props->size_moments.data[OnlyGrainSpLUT::MgO_dust], + inject_pathway_props->size_moments.data[OnlyGrainSpLUT::FeS_dust], + inject_pathway_props->size_moments.data[OnlyGrainSpLUT::Al2O3_dust], + inject_pathway_props->size_moments.data[OnlyGrainSpLUT::ref_org_dust], + inject_pathway_props->size_moments.data[OnlyGrainSpLUT::vol_org_dust], + inject_pathway_props->size_moments.data[OnlyGrainSpLUT::H2O_ice_dust], gr_N, &gr_Size, - &my_rates->opaque_storage->inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], + &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], - my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::SiM_dust], - my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::FeM_dust], - my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Mg2SiO4_dust], - my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::MgSiO3_dust], - my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Fe3O4_dust], - my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::AC_dust], - my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::SiO2_dust], - my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::MgO_dust], - my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::FeS_dust], - my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Al2O3_dust], - my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::ref_org_dust], - my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::vol_org_dust], - my_rates->opaque_storage->inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::H2O_ice_dust], + inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::SiM_dust], + inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::FeM_dust], + inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Mg2SiO4_dust], + inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::MgSiO3_dust], + inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Fe3O4_dust], + inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::AC_dust], + inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::SiO2_dust], + inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::MgO_dust], + inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::FeS_dust], + inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Al2O3_dust], + inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::ref_org_dust], + inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::vol_org_dust], + inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::H2O_ice_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiM_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeM_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Mg2SiO4_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgSiO3_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Fe3O4_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::AC_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiO2_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgO_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeS_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Al2O3_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::ref_org_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::vol_org_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::H2O_ice_dust], internal_dust_prop_buf.sigma_per_gas_mass_tot, diff --git a/src/clib/lookup_cool_rates1d.hpp b/src/clib/lookup_cool_rates1d.hpp index 299f8e1f9..b3387e3a1 100644 --- a/src/clib/lookup_cool_rates1d.hpp +++ b/src/clib/lookup_cool_rates1d.hpp @@ -810,7 +810,9 @@ inline void lookup_cool_rates1d( if ((anydust != MASK_FALSE) && (my_chemistry->dust_species > 0)) { f_wrap::calc_grain_size_increment_1d(dom, idx_range, itmask_metal, - my_chemistry, my_rates, my_fields, + my_chemistry, + my_rates->opaque_storage->inject_pathway_props, + my_fields, internal_dust_prop_scratch_buf); } From 3825dc776e8d9b1f7183810416aff01d37d3535c Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Mon, 8 Dec 2025 20:48:59 -0500 Subject: [PATCH 052/175] tweak signature of make_consistent --- src/clib/make_consistent.cpp | 4 +--- src/clib/make_consistent.hpp | 15 ++++++++++++--- src/clib/solve_rate_cool_g-cpp.cpp | 4 +++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/clib/make_consistent.cpp b/src/clib/make_consistent.cpp index b5f5eed89..2734ed35a 100644 --- a/src/clib/make_consistent.cpp +++ b/src/clib/make_consistent.cpp @@ -27,7 +27,7 @@ namespace grackle::impl { void make_consistent(int imetal, double dom, chemistry_data* my_chemistry, - chemistry_data_storage* my_rates, + const grackle::impl::GrainMetalInjectPathways* inject_pathway_props, grackle_field_data* my_fields) { // Arguments @@ -244,8 +244,6 @@ void make_consistent(int imetal, double dom, chemistry_data* my_chemistry, gr_float correctCd, correctOd, correctMgd, correctSid, correctFed; int iSN, iSN0; - const grackle::impl::GrainMetalInjectPathways* inject_pathway_props = - my_rates->opaque_storage->inject_pathway_props; const int n_pathways = (inject_pathway_props == nullptr) ? 0 : inject_pathway_props->n_pathways; std::vector SN_metal_data_(my_fields->grid_dimension[0] * diff --git a/src/clib/make_consistent.hpp b/src/clib/make_consistent.hpp index 3d0c6bd60..2edb6c91f 100644 --- a/src/clib/make_consistent.hpp +++ b/src/clib/make_consistent.hpp @@ -16,13 +16,22 @@ #ifndef MAKE_CONSISTENT_HPP #define MAKE_CONSISTENT_HPP -#include "grackle.h" // gr_float -#include "fortran_func_decls.h" // gr_mask_int +#include "grackle.h" +#include "inject_model/grain_metal_inject_pathways.hpp" namespace grackle::impl { +/// Enforces consistency of species fields with expected total abundances +/// +/// @param[in] imetal specifies whether or not the caller provided a metal +/// field (0 = no, 1 = yes) +/// @param[in] dom +/// @param[in] my_chemistry holds a number of configuration parameters +/// @param[in] inject_pathway_props holds data about the modelled injection +/// pathways for all metals and grain species +/// @param[in] my_fields specifies the field data void make_consistent(int imetal, double dom, chemistry_data* my_chemistry, - chemistry_data_storage* my_rates, + const grackle::impl::GrainMetalInjectPathways* inject_pathway_props, grackle_field_data* my_fields); } // namespace grackle::impl diff --git a/src/clib/solve_rate_cool_g-cpp.cpp b/src/clib/solve_rate_cool_g-cpp.cpp index 8936c736b..b6a6101eb 100644 --- a/src/clib/solve_rate_cool_g-cpp.cpp +++ b/src/clib/solve_rate_cool_g-cpp.cpp @@ -1014,7 +1014,9 @@ int solve_rate_cool_g( // Correct the species to ensure consistency (i.e. type conservation) - grackle::impl::make_consistent(imetal, dom, my_chemistry, my_rates, my_fields); + grackle::impl::make_consistent( + imetal, dom, my_chemistry, + my_rates->opaque_storage->inject_pathway_props, my_fields); } From bb6cec672b58174d1db26251f0d585e03ab9c636 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Mon, 8 Dec 2025 20:53:05 -0500 Subject: [PATCH 053/175] delete grackle::impl::free_dust_yields --- src/clib/initialize_chemistry_data.cpp | 6 ------ src/clib/initialize_dust_yields.cpp | 7 ------- src/clib/initialize_dust_yields.hpp | 3 --- 3 files changed, 16 deletions(-) diff --git a/src/clib/initialize_chemistry_data.cpp b/src/clib/initialize_chemistry_data.cpp index f3c266c7d..f0ab4f7a9 100644 --- a/src/clib/initialize_chemistry_data.cpp +++ b/src/clib/initialize_chemistry_data.cpp @@ -23,7 +23,6 @@ #include "interp_table_utils.hpp" #include "init_misc_species_cool_rates.hpp" // free_misc_species_cool_rates #include "initialize_cloudy_data.h" -#include "initialize_dust_yields.hpp" // free_dust_yields #include "initialize_rates.hpp" #include "initialize_UVbackground_data.h" #include "internal_types.hpp" // drop_CollisionalRxnRateCollection @@ -549,11 +548,6 @@ extern "C" int local_free_chemistry_data(chemistry_data *my_chemistry, return GR_FAIL; } - if (grackle::impl::free_dust_yields(my_chemistry, my_rates) == FAIL) { - fprintf(stderr, "Error in local_free_dust_yields.\n"); - return FAIL; - } - // start freeing memory associated with opaque storage // --------------------------------------------------- if (my_rates->opaque_storage->kcol_rate_tables != nullptr) { diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index 4f1acdaa1..e5e73fa42 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -316,10 +316,3 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, return GR_SUCCESS; } - -int grackle::impl::free_dust_yields(chemistry_data *my_chemistry, - chemistry_data_storage *my_rates) -{ - return SUCCESS; -} - diff --git a/src/clib/initialize_dust_yields.hpp b/src/clib/initialize_dust_yields.hpp index 2c66f63fe..c8f53609e 100644 --- a/src/clib/initialize_dust_yields.hpp +++ b/src/clib/initialize_dust_yields.hpp @@ -21,9 +21,6 @@ int initialize_dust_yields(chemistry_data* my_chemistry, chemistry_data_storage* my_rates, code_units* my_units); -int free_dust_yields(chemistry_data* my_chemistry, - chemistry_data_storage* my_rates); - } // namespace grackle::impl #endif /* INITIALIZE_DUST_YIELDS_HPP */ From 9e9bcfd9bb40569a8850ac704ae708e0ffb4dab2 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Mon, 8 Dec 2025 21:03:42 -0500 Subject: [PATCH 054/175] slightly simplify zero-out logic --- src/clib/initialize_dust_yields.cpp | 42 +++++-------------- .../grain_metal_inject_pathways.hpp | 13 ++++++ 2 files changed, 23 insertions(+), 32 deletions(-) diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index e5e73fa42..b831f91c2 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -191,37 +191,12 @@ extern "C" int setup_yield_table_callback( return GR_SUCCESS; } -/// a helper function override the values of all metal injection properties -void override_metal_inject_props( - grackle::impl::GrainMetalInjectPathways* inject_pathway_props, - double value, int n_pathways) -{ - for(int iSN = 0; iSN < n_pathways; iSN++) { - inject_pathway_props->total_metal_nuclide_yields.C [iSN] = value; - inject_pathway_props->total_metal_nuclide_yields.O [iSN] = value; - inject_pathway_props->total_metal_nuclide_yields.Mg[iSN] = value; - inject_pathway_props->total_metal_nuclide_yields.Al[iSN] = value; - inject_pathway_props->total_metal_nuclide_yields.Si[iSN] = value; - inject_pathway_props->total_metal_nuclide_yields.S [iSN] = value; - inject_pathway_props->total_metal_nuclide_yields.Fe[iSN] = value; - - inject_pathway_props->gas_metal_nuclide_yields.C [iSN] = value; - inject_pathway_props->gas_metal_nuclide_yields.O [iSN] = value; - inject_pathway_props->gas_metal_nuclide_yields.Mg[iSN] = value; - inject_pathway_props->gas_metal_nuclide_yields.Al[iSN] = value; - inject_pathway_props->gas_metal_nuclide_yields.Si[iSN] = value; - inject_pathway_props->gas_metal_nuclide_yields.S [iSN] = value; - inject_pathway_props->gas_metal_nuclide_yields.Fe[iSN] = value; - } -} - /// a helper function to override the values of all dust inject properties /// /// @note /// to start, this only handles the grain yields -void override_dust_inject_props( - grackle::impl::GrainMetalInjectPathways* inject_pathway_props, - double value) { +void zero_out_dust_inject_props( + grackle::impl::GrainMetalInjectPathways* inject_pathway_props) { const int n_grain_species = OnlyGrainSpLUT::NUM_ENTRIES; @@ -232,7 +207,7 @@ void override_dust_inject_props( grain_species_idx++){ double* arr = inject_pathway_props->grain_yields.data[grain_species_idx]; for(int iSN = 0; iSN < n_pathways; iSN++) { - arr[iSN] = value; + arr[iSN] = 0.0; } } @@ -242,7 +217,7 @@ void override_dust_inject_props( grain_species_idx++){ double* arr = inject_pathway_props->size_moments.data[grain_species_idx]; for(int i = 0; i < moment_table_len; i++) { - arr[i] = value; + arr[i] = 0.0; } } @@ -256,7 +231,7 @@ void override_dust_inject_props( double* arr = inject_pathway_props->opacity_coef_table.data[grain_species_idx]; for(long long i = 0LL; i < opac_table_len; i++) { - arr[i] = value; + arr[i] = 0.0; } } } @@ -301,8 +276,11 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, // zero-out all metal injection yield fractions and dust grain properties - override_metal_inject_props(inject_pathway_props, 0.0, n_pathways); - override_dust_inject_props(inject_pathway_props, 0.0); + yields::MetalTables_zero_out( + &inject_pathway_props->total_metal_nuclide_yields, n_pathways); + yields::MetalTables_zero_out( + &inject_pathway_props->gas_metal_nuclide_yields, n_pathways); + zero_out_dust_inject_props(inject_pathway_props); SetupCallbackCtx ctx = {my_rates, 0}; diff --git a/src/clib/inject_model/grain_metal_inject_pathways.hpp b/src/clib/inject_model/grain_metal_inject_pathways.hpp index 9bd59c8fe..2da3da2ec 100644 --- a/src/clib/inject_model/grain_metal_inject_pathways.hpp +++ b/src/clib/inject_model/grain_metal_inject_pathways.hpp @@ -73,6 +73,19 @@ inline void drop_MetalTables(MetalTables* ptr) { delete[] ptr->Fe; } +/// fills elements with zeros +inline void MetalTables_zero_out(MetalTables* ptr, int nelem) { + for (int i = 0; i < nelem; i++) { + ptr->C [i] = 0.0; + ptr->O [i] = 0.0; + ptr->Mg[i] = 0.0; + ptr->Al[i] = 0.0; + ptr->Si[i] = 0.0; + ptr->S [i] = 0.0; + ptr->Fe[i] = 0.0; + } +} + } // namespace grackle::impl::yields namespace grackle::impl { From b79ba758720fd0d1a66e6b66a6c8225b29a0c710 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Mon, 8 Dec 2025 21:32:34 -0500 Subject: [PATCH 055/175] start using FrozenKeyIdxBiMap for model names --- src/clib/initialize_dust_yields.cpp | 105 ++++++++++++++++++++------- src/clib/utils/FrozenKeyIdxBiMap.hpp | 2 +- 2 files changed, 80 insertions(+), 27 deletions(-) diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index b831f91c2..9fe8fd63c 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -22,27 +22,53 @@ #include "LUT.hpp" #include "opaque_storage.hpp" #include "status_reporting.h" // GrPrintAndReturnErr +#include "utils/FrozenKeyIdxBiMap.hpp" namespace { // stuff inside an anonymous namespace is local to this file -int lookup_pathway_idx(const char* name) { - const char * known_names[12] = { - "local_ISM", "ccsn13", "ccsn20", "ccsn25", "ccsn30", "fsn13", - "fsn15", "fsn50", "fsn80", "pisn170", "pisn200", "y19", - }; - - for (int i = 0; i < 12; i++){ - if (std::strcmp(known_names[i], name) == 0){ - return i; - } - } - return -1; -} +/// names of all injection pathways known to grackle listed in the order +/// in other parts of the codebase +/// +/// @see SetupCallbackCtx::inj_path_names - The entity that is initialized with +/// the values in this variable. Its docstring provides more details. +constexpr const char * const known_inj_path_names[] = { + "local_ISM", "ccsn13", "ccsn20", "ccsn25", "ccsn30", "fsn13", + "fsn15", "fsn50", "fsn80", "pisn170", "pisn200", "y19", +}; /// the context object for setup_yield_table_callback struct SetupCallbackCtx{ - chemistry_data_storage *my_rates; + /// The object that gets updated by the values that the callback loads + grackle::impl::GrainMetalInjectPathways* inject_pathway_props; + + /// a counter that is incremented every time setup_yield_table_callback loads + /// data from an injection pathway int counter; + + /// maps the names of known injection pathways to a unique index + /// + /// The callback function reports an error if an injection is encountered + /// that has a name that isn't included in this map. Furthermore, data is + /// organized within GrainMetalInjectPathways according to the order of keys + /// in this map. + /// + /// @par Why This Is Needed + /// For some background context: + /// - to make use of the injection pathway information, Grackle requires + /// users to provide mass densities fields specifying the total amount of + /// injected metals by each pathway + /// - currently, the names of the user accessed fields have hard-coded names + /// - currently, Grackle loops over the data specified by these fields in a + /// standardized order and assumes data within an instance of + /// grackle::impl::GrainMetalInjectPathways has the same order + /// + /// @par How this should change + /// Before any functionality involving injection pathways is included in a + /// public release of Grackle, the plan is to stop hard-coding the names of + /// injection pathway density fields, and to load in injection pathway data + /// from HDF5 files. At that point, we'll need to tweak the callback function + /// to load in data for models with arbitrary names. + const grackle::impl::FrozenKeyIdxBiMap* inj_path_names; }; /// a callback function that sets up the appropriate parts of @@ -62,19 +88,23 @@ extern "C" int setup_yield_table_callback( { namespace inj_input = ::grackle::impl::inj_model_input; + SetupCallbackCtx* my_ctx = static_cast(ctx); - int pathway_idx = lookup_pathway_idx(name); - - if (pathway_idx < 0) { + // lookup the pathway associated with the current injection pathway name + // and report an error if there is one + // -> see the docstring for SetupCallbackCtx::inj_path_names for how this + // behavior will change when we start loading data from HDF5 files + int pathway_idx = static_cast( + FrozenKeyIdxBiMap_idx_from_key(my_ctx->inj_path_names, name) + ); + if (pathway_idx == static_cast(grackle::impl::bimap::invalid_val)) { return GrPrintAndReturnErr( "`%s` is an unexpected injection pathway name", name); } - chemistry_data_storage *my_rates = - static_cast(ctx)->my_rates; - + // load the object that we update with the data we read grackle::impl::GrainMetalInjectPathways* inject_pathway_props - = my_rates->opaque_storage->inject_pathway_props; + = my_ctx->inject_pathway_props; // record each metal nuclide yield // -> there is less value to using string keys in this case, but it makes @@ -186,7 +216,7 @@ extern "C" int setup_yield_table_callback( } } - (static_cast(ctx)->counter)++; + (my_ctx->counter)++; return GR_SUCCESS; } @@ -244,10 +274,23 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, { if (my_chemistry->metal_chemistry == 0) { - return SUCCESS; + return GR_SUCCESS; + } + + // construct a mapping of all known models + // -> in the future, we are going to move away from this hardcoded approach + // -> since the strings are statically allocates, the map won't make copies + // of the strings + constexpr int n_pathways = static_cast( + sizeof(known_inj_path_names) / sizeof(char*)); + + FrozenKeyIdxBiMap inj_path_names = new_FrozenKeyIdxBiMap( + known_inj_path_names, n_pathways, BiMapMode::REFS_KEYDATA); + if (!FrozenKeyIdxBiMap_is_ok(&inj_path_names)) { + return GrPrintAndReturnErr( + "there was a problem building the map of model names"); } - int n_pathways = 12; int n_log10Tdust_vals = grackle::impl::inj_model_input::N_Tdust_Opacity_Table; int n_opac_poly_coef = grackle::impl::inj_model_input::N_Opacity_Coef; my_rates->opaque_storage->inject_pathway_props = @@ -260,6 +303,7 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, = my_rates->opaque_storage->inject_pathway_props; if (!GrainMetalInjectPathways_is_valid(inject_pathway_props)) { + drop_FrozenKeyIdxBiMap(&inj_path_names); return GR_FAIL; } @@ -282,12 +326,21 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, &inject_pathway_props->gas_metal_nuclide_yields, n_pathways); zero_out_dust_inject_props(inject_pathway_props); - SetupCallbackCtx ctx = {my_rates, 0}; + // actually load in the data for each injection pathway + SetupCallbackCtx ctx = { + /* inject_pathway_props = */ my_rates->opaque_storage->inject_pathway_props, + /* counter = */ 0, + /* inj_path_names = */ &inj_path_names, + }; int ret = grackle::impl::inj_model_input::input_inject_model_iterate( &setup_yield_table_callback, static_cast(&ctx)); + + drop_FrozenKeyIdxBiMap(&inj_path_names); if (ret != GR_SUCCESS) { - return GR_FAIL; + return GrPrintAndReturnErr( + "some kind of unspecified error occured when loading data from each " + "injection pathway"); } GR_INTERNAL_REQUIRE(ctx.counter == 12, "sanity-checking"); diff --git a/src/clib/utils/FrozenKeyIdxBiMap.hpp b/src/clib/utils/FrozenKeyIdxBiMap.hpp index a9537a5c0..4b3fe6114 100644 --- a/src/clib/utils/FrozenKeyIdxBiMap.hpp +++ b/src/clib/utils/FrozenKeyIdxBiMap.hpp @@ -117,7 +117,7 @@ struct FrozenKeyIdxBiMap { /// > This is pretty ugly/clunky, but its the only practical way to achieve /// > comparable behavior to other internal datatypes (ideally, we would make /// > this a simple C++ class instead) -inline FrozenKeyIdxBiMap new_FrozenKeyIdxBiMap(const char* keys[], +inline FrozenKeyIdxBiMap new_FrozenKeyIdxBiMap(const char* const keys[], int key_count, BiMapMode mode) { // this will be returned if there is an error FrozenKeyIdxBiMap erroneous_obj{0, nullptr, BiMapMode::REFS_KEYDATA}; From 51610dd330f989ac7d63285e1f774b553da13250 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Tue, 9 Dec 2025 10:11:34 -0500 Subject: [PATCH 056/175] lightly refactor loading of metal nuclide yields --- src/clib/initialize_dust_yields.cpp | 68 ++++++++++++++++------------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index 9fe8fd63c..0ba707f2a 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -36,6 +36,40 @@ constexpr const char * const known_inj_path_names[] = { "fsn15", "fsn50", "fsn80", "pisn170", "pisn200", "y19", }; +/// a crude map-like function +bool lookup_metal_yield_ptrs( + grackle::impl::GrainMetalInjectPathways* inject_pathway_props, + const char* metal_nuclide_name, double** total_yield_ptr, + double** gasonly_yield_ptr +) { + if (std::strcmp("C", metal_nuclide_name) == 0) { + (*total_yield_ptr) = inject_pathway_props->total_metal_nuclide_yields.C; + (*gasonly_yield_ptr) = inject_pathway_props->gas_metal_nuclide_yields.C; + } else if (std::strcmp("O", metal_nuclide_name) == 0) { + (*total_yield_ptr) = inject_pathway_props->total_metal_nuclide_yields.O; + (*gasonly_yield_ptr) = inject_pathway_props->gas_metal_nuclide_yields.O; + } else if (std::strcmp("Mg", metal_nuclide_name) == 0) { + (*total_yield_ptr) = inject_pathway_props->total_metal_nuclide_yields.Mg; + (*gasonly_yield_ptr) = inject_pathway_props->gas_metal_nuclide_yields.Mg; + } else if (std::strcmp("Al", metal_nuclide_name) == 0) { + (*total_yield_ptr) = inject_pathway_props->total_metal_nuclide_yields.Al; + (*gasonly_yield_ptr) = inject_pathway_props->gas_metal_nuclide_yields.Al; + } else if (std::strcmp("Si", metal_nuclide_name) == 0) { + (*total_yield_ptr) = inject_pathway_props->total_metal_nuclide_yields.Si; + (*gasonly_yield_ptr) = inject_pathway_props->gas_metal_nuclide_yields.Si; + } else if (std::strcmp("S", metal_nuclide_name) == 0) { + (*total_yield_ptr) = inject_pathway_props->total_metal_nuclide_yields.S; + (*gasonly_yield_ptr) = inject_pathway_props->gas_metal_nuclide_yields.S; + } else if (std::strcmp("Fe", metal_nuclide_name) == 0) { + (*total_yield_ptr) = inject_pathway_props->total_metal_nuclide_yields.Fe; + (*gasonly_yield_ptr) = inject_pathway_props->gas_metal_nuclide_yields.Fe; + } else { + return false; + } + return true; + +} + /// the context object for setup_yield_table_callback struct SetupCallbackCtx{ /// The object that gets updated by the values that the callback loads @@ -106,40 +140,14 @@ extern "C" int setup_yield_table_callback( grackle::impl::GrainMetalInjectPathways* inject_pathway_props = my_ctx->inject_pathway_props; - // record each metal nuclide yield - // -> there is less value to using string keys in this case, but it makes - // some sense to be semi-consistent with the handling of the dust species - // yields + // record the yields for each metal nuclide for (int i = 0; i < input->n_metal_nuclide_yields; i++) { const inj_input::MetalNuclideYieldProps& yield_info = input->metal_nuclide_yields[i]; - double* total_yield = nullptr; - double* gas_yield = nullptr; - - // todo: refactor to use a map (I have a rough plan) - if (std::strcmp("C", yield_info.name) == 0) { - total_yield = inject_pathway_props->total_metal_nuclide_yields.C; - gas_yield = inject_pathway_props->gas_metal_nuclide_yields.C; - } else if (std::strcmp("O", yield_info.name) == 0) { - total_yield = inject_pathway_props->total_metal_nuclide_yields.O; - gas_yield = inject_pathway_props->gas_metal_nuclide_yields.O; - } else if (std::strcmp("Mg", yield_info.name) == 0) { - total_yield = inject_pathway_props->total_metal_nuclide_yields.Mg; - gas_yield = inject_pathway_props->gas_metal_nuclide_yields.Mg; - } else if (std::strcmp("Al", yield_info.name) == 0) { - total_yield = inject_pathway_props->total_metal_nuclide_yields.Al; - gas_yield = inject_pathway_props->gas_metal_nuclide_yields.Al; - } else if (std::strcmp("Si", yield_info.name) == 0) { - total_yield = inject_pathway_props->total_metal_nuclide_yields.Si; - gas_yield = inject_pathway_props->gas_metal_nuclide_yields.Si; - } else if (std::strcmp("S", yield_info.name) == 0) { - total_yield = inject_pathway_props->total_metal_nuclide_yields.S; - gas_yield = inject_pathway_props->gas_metal_nuclide_yields.S; - } else if (std::strcmp("Fe", yield_info.name) == 0) { - total_yield = inject_pathway_props->total_metal_nuclide_yields.Fe; - gas_yield = inject_pathway_props->gas_metal_nuclide_yields.Fe; - } else { + double *total_yield, *gas_yield; + if (!lookup_metal_yield_ptrs(inject_pathway_props, yield_info.name, + &total_yield, &gas_yield)){ return GrPrintAndReturnErr( "`%s` not a known metal nuclide", yield_info.name); } From 24ff4cec7d57b91d56c2779ab6a0d8463c8db929 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Tue, 9 Dec 2025 10:16:22 -0500 Subject: [PATCH 057/175] confirm that just loading the relevant dust species produces the correct results --- src/clib/initialize_dust_yields.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index 0ba707f2a..bc2d8d1b4 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -15,6 +15,7 @@ #include #include #include +#include "dust/grain_species_info.hpp" #include "grackle_macros.h" #include "grackle_chemistry_data.h" #include "initialize_dust_yields.hpp" // forward declarations @@ -79,6 +80,9 @@ struct SetupCallbackCtx{ /// data from an injection pathway int counter; + /// the number of dust grain species + const int n_grain_species; + /// maps the names of known injection pathways to a unique index /// /// The callback function reports an error if an injection is encountered @@ -196,6 +200,10 @@ extern "C" int setup_yield_table_callback( "`%s` not a known grain species", yield_info.name); } + if (grain_species_idx >= my_ctx->n_grain_species) { + continue; + } + // copy the nonprimordial yield fraction inject_pathway_props->grain_yields.data[grain_species_idx][pathway_idx] = yield_info.nonprimoridal_yield_frac; @@ -338,6 +346,7 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, SetupCallbackCtx ctx = { /* inject_pathway_props = */ my_rates->opaque_storage->inject_pathway_props, /* counter = */ 0, + /* n_grain_species = */ get_n_grain_species(my_chemistry->dust_species), /* inj_path_names = */ &inj_path_names, }; From 18020b69fcab5710bbda52223d3355d07fd9375c Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Tue, 9 Dec 2025 19:37:25 -0500 Subject: [PATCH 058/175] use FrozenKeyIdxBiMap within GrainSpeciesInfo (1/3) One minor change involved formally making it illegal to construct a GrainSpeciesInfo instance that holds 0 dust species. That's perfectly fine. `GrainSpeciesInfo` holds some redundant info that we will remove in the a subsequent commit --- src/clib/dust/grain_species_info.cpp | 68 ++++++++++++++++++-------- src/clib/dust/grain_species_info.hpp | 12 +++++ src/clib/utils/FrozenKeyIdxBiMap.hpp | 21 ++++---- tests/unit/test_grain_species_info.cpp | 12 +---- 4 files changed, 73 insertions(+), 40 deletions(-) diff --git a/src/clib/dust/grain_species_info.cpp b/src/clib/dust/grain_species_info.cpp index 3a6a76f80..d60eef6c4 100644 --- a/src/clib/dust/grain_species_info.cpp +++ b/src/clib/dust/grain_species_info.cpp @@ -15,6 +15,7 @@ #include "LUT.hpp" #include "grain_species_info.hpp" +#include "../utils/FrozenKeyIdxBiMap.hpp" // The following logic effectively does 2 (related things): // 1. it serves as a human-readable registry of all known grain species and @@ -85,18 +86,23 @@ grackle::impl::GrainSpeciesInfoEntry mk_gsp_info_entry_helper_( out_ingredient_ptr}; } +// ugh, I don't like this... +grackle::impl::GrainSpeciesInfo mk_invalid_GrainSpeciesInfo() { + return {-1, nullptr, grackle::impl::mk_invalid_FrozenKeyIdxBiMap()}; +} + } // anonymous namespace grackle::impl::GrainSpeciesInfo grackle::impl::new_GrainSpeciesInfo( int dust_species_parameter) { - GrainSpeciesInfo out{-1, nullptr}; // indicates an error - out.n_species = get_n_grain_species(dust_species_parameter); - - if (out.n_species <= 0) { - return out; + int n_species = get_n_grain_species(dust_species_parameter); + if (n_species <= 0) { + return mk_invalid_GrainSpeciesInfo(); } - out.species_info = new GrainSpeciesInfoEntry[out.n_species]; + // names is allocated with the max number of known grain species + const char* names[OnlyGrainSpLUT::NUM_ENTRIES]; + GrainSpeciesInfoEntry* species_info = new GrainSpeciesInfoEntry[n_species]; // At the time of writing: // - we **only** use h2rate_carbonaceous_coef_table for the AC_dust @@ -126,7 +132,8 @@ grackle::impl::GrainSpeciesInfo grackle::impl::new_GrainSpeciesInfo( {1, SpLUT::SiOI, 44.}, {2, SpLUT::H2O, 18.}, GRIMPL_INGREDIENT_LIST_SENTINEL}; - out.species_info[0] = mk_gsp_info_entry_helper_( + names[0] = "MgSiO3_dust"; + species_info[0] = mk_gsp_info_entry_helper_( /* species_idx = */ SpLUT::MgSiO3_dust, /* onlygrainsp_idx = */ OnlyGrainSpLUT::MgSiO3_dust, /* name = */ "MgSiO3_dust", @@ -140,7 +147,8 @@ grackle::impl::GrainSpeciesInfo grackle::impl::new_GrainSpeciesInfo( // {coef, species_idx, particle mass} {1, SpLUT::CI, 12.}, GRIMPL_INGREDIENT_LIST_SENTINEL}; - out.species_info[1] = mk_gsp_info_entry_helper_( + names[1] = "AC_dust"; + species_info[1] = mk_gsp_info_entry_helper_( /* species_idx = */ SpLUT::AC_dust, /* onlygrainsp_idx = */ OnlyGrainSpLUT::AC_dust, /* name = */ "AC_dust", @@ -156,7 +164,8 @@ grackle::impl::GrainSpeciesInfo grackle::impl::new_GrainSpeciesInfo( // {coef, species_idx, particle mass} {1, SpLUT::SiI, 28.}, GRIMPL_INGREDIENT_LIST_SENTINEL}; - out.species_info[2] = mk_gsp_info_entry_helper_( + names[2] = "SiM_dust"; + species_info[2] = mk_gsp_info_entry_helper_( /* species_idx = */ SpLUT::SiM_dust, /* onlygrainsp_idx = */ OnlyGrainSpLUT::SiM_dust, /* name = */ "SiM_dust", @@ -170,7 +179,8 @@ grackle::impl::GrainSpeciesInfo grackle::impl::new_GrainSpeciesInfo( // {coef, species_idx, particle mass} {1, SpLUT::Fe, 56.}, GRIMPL_INGREDIENT_LIST_SENTINEL}; - out.species_info[3] = mk_gsp_info_entry_helper_( + names[3] = "FeM_dust"; + species_info[3] = mk_gsp_info_entry_helper_( /* species_idx = */ SpLUT::FeM_dust, /* onlygrainsp_idx = */ OnlyGrainSpLUT::FeM_dust, /* name = */ "FeM_dust", @@ -186,7 +196,8 @@ grackle::impl::GrainSpeciesInfo grackle::impl::new_GrainSpeciesInfo( {1, SpLUT::SiOI, 44.}, {3, SpLUT::H2O, 18.}, GRIMPL_INGREDIENT_LIST_SENTINEL}; - out.species_info[4] = mk_gsp_info_entry_helper_( + names[4] = "Mg2SiO4_dust"; + species_info[4] = mk_gsp_info_entry_helper_( /* species_idx = */ SpLUT::Mg2SiO4_dust, /* onlygrainsp_idx = */ OnlyGrainSpLUT::Mg2SiO4_dust, /* name = */ "Mg2SiO4_dust", @@ -201,7 +212,8 @@ grackle::impl::GrainSpeciesInfo grackle::impl::new_GrainSpeciesInfo( {3, SpLUT::Fe, 56.}, {4, SpLUT::H2O, 18.}, GRIMPL_INGREDIENT_LIST_SENTINEL}; - out.species_info[5] = mk_gsp_info_entry_helper_( + names[5] = "Fe3O4_dust"; + species_info[5] = mk_gsp_info_entry_helper_( /* species_idx = */ SpLUT::Fe3O4_dust, /* onlygrainsp_idx = */ OnlyGrainSpLUT::Fe3O4_dust, /* name = */ "Fe3O4_dust", @@ -215,7 +227,8 @@ grackle::impl::GrainSpeciesInfo grackle::impl::new_GrainSpeciesInfo( // {coef, species_idx, particle mass} {1, SpLUT::SiO2I, 60.}, GRIMPL_INGREDIENT_LIST_SENTINEL}; - out.species_info[6] = mk_gsp_info_entry_helper_( + names[6] = "SiO2_dust"; + species_info[6] = mk_gsp_info_entry_helper_( /* species_idx = */ SpLUT::SiO2_dust, /* onlygrainsp_idx = */ OnlyGrainSpLUT::SiO2_dust, /* name = */ "SiO2_dust", @@ -230,7 +243,8 @@ grackle::impl::GrainSpeciesInfo grackle::impl::new_GrainSpeciesInfo( {1, SpLUT::Mg, 24.}, {1, SpLUT::H2O, 18.}, GRIMPL_INGREDIENT_LIST_SENTINEL}; - out.species_info[7] = mk_gsp_info_entry_helper_( + names[7] = "MgO_dust"; + species_info[7] = mk_gsp_info_entry_helper_( /* species_idx = */ SpLUT::MgO_dust, /* onlygrainsp_idx = */ OnlyGrainSpLUT::MgO_dust, /* name = */ "MgO_dust", @@ -245,7 +259,8 @@ grackle::impl::GrainSpeciesInfo grackle::impl::new_GrainSpeciesInfo( {1, SpLUT::Fe, 56.}, {1, SpLUT::S, 32.}, GRIMPL_INGREDIENT_LIST_SENTINEL}; - out.species_info[8] = mk_gsp_info_entry_helper_( + names[8] = "FeS_dust"; + species_info[8] = mk_gsp_info_entry_helper_( /* species_idx = */ SpLUT::FeS_dust, /* onlygrainsp_idx = */ OnlyGrainSpLUT::FeS_dust, /* name = */ "FeS_dust", @@ -260,7 +275,8 @@ grackle::impl::GrainSpeciesInfo grackle::impl::new_GrainSpeciesInfo( {2, SpLUT::Al, 27.}, {3, SpLUT::H2O, 18.}, GRIMPL_INGREDIENT_LIST_SENTINEL}; - out.species_info[9] = mk_gsp_info_entry_helper_( + names[9] = "Al2O3_dust"; + species_info[9] = mk_gsp_info_entry_helper_( /* species_idx = */ SpLUT::Al2O3_dust, /* onlygrainsp_idx = */ OnlyGrainSpLUT::Al2O3_dust, /* name = */ "Al2O3_dust", @@ -277,7 +293,8 @@ grackle::impl::GrainSpeciesInfo grackle::impl::new_GrainSpeciesInfo( // nominal growth rxn: "0.5CO + 0.5CH2 + 1.2N -> ref_org_dust" // nuclide ratios: C:H:O:N = 1:1:0.5:1.2 - out.species_info[10] = mk_gsp_info_entry_helper_( + names[10] = "ref_org_dust"; + species_info[10] = mk_gsp_info_entry_helper_( /* species_idx = */ SpLUT::ref_org_dust, /* onlygrainsp_idx = */ OnlyGrainSpLUT::ref_org_dust, /* name = */ "ref_org_dust", @@ -288,7 +305,8 @@ grackle::impl::GrainSpeciesInfo grackle::impl::new_GrainSpeciesInfo( // nominal growth rxn: "CO + 2H2I -> vol_org_dust" // effective formula: CH3OH - out.species_info[11] = mk_gsp_info_entry_helper_( + names[11] = "vol_org_dust"; + species_info[11] = mk_gsp_info_entry_helper_( /* species_idx = */ SpLUT::vol_org_dust, /* onlygrainsp_idx = */ OnlyGrainSpLUT::vol_org_dust, /* name = */ "vol_org_dust", @@ -298,7 +316,8 @@ grackle::impl::GrainSpeciesInfo grackle::impl::new_GrainSpeciesInfo( /* growth_ingredients = */ nullptr); // nominal growth rxn: "H2O -> H2O_ice_dust" - out.species_info[12] = mk_gsp_info_entry_helper_( + names[12] = "H2O_ice_dust"; + species_info[12] = mk_gsp_info_entry_helper_( /* species_idx = */ SpLUT::H2O_ice_dust, /* onlygrainsp_idx = */ OnlyGrainSpLUT::H2O_ice_dust, /* name = */ "H2O_ice_dust", @@ -308,7 +327,16 @@ grackle::impl::GrainSpeciesInfo grackle::impl::new_GrainSpeciesInfo( /* growth_ingredients = */ nullptr); } - return out; + GrainSpeciesInfo out{ + n_species, species_info, + new_FrozenKeyIdxBiMap(names, n_species, BiMapMode::COPIES_KEYDATA)}; + + if (FrozenKeyIdxBiMap_is_ok(&out.name_map)) { + return out; + } else { + drop_GrainSpeciesInfo(&out); + return mk_invalid_GrainSpeciesInfo(); + } } #undef GRIMPL_INGREDIENT_LIST_SENTINEL diff --git a/src/clib/dust/grain_species_info.hpp b/src/clib/dust/grain_species_info.hpp index 1f20c52ea..6785624d9 100644 --- a/src/clib/dust/grain_species_info.hpp +++ b/src/clib/dust/grain_species_info.hpp @@ -13,6 +13,8 @@ #ifndef GRAIN_SPECIES_INFO_HPP #define GRAIN_SPECIES_INFO_HPP +#include "../utils/FrozenKeyIdxBiMap.hpp" + namespace grackle::impl { /// holds information about a single gas species that is an ingredient for @@ -116,6 +118,15 @@ struct GrainSpeciesInfo { /// an out.species_infoay of length of length @ref n_species where each entry /// holds info about a separate grain species GrainSpeciesInfoEntry* species_info; + + /// maps between grain species names and the associated index. The mapping is + /// **ALWAYS** consistent with ``OnlyGrainSpLUT``. + /// + /// @note + /// An argument could be made for storing this separately from the rest of + /// the struct since the core grackle calculations don't (or at least + /// shouldn't) use this data structure during the calculation. + FrozenKeyIdxBiMap name_map; }; /// return the number of grain species @@ -164,6 +175,7 @@ inline void drop_GrainSpeciesInfo(GrainSpeciesInfo* ptr) { } } delete[] ptr->species_info; + drop_FrozenKeyIdxBiMap(&ptr->name_map); // the following 2 lines are not strictly necessary, but they may help us // avoid a double-free and a dangling pointer ptr->n_species = 0; diff --git a/src/clib/utils/FrozenKeyIdxBiMap.hpp b/src/clib/utils/FrozenKeyIdxBiMap.hpp index a9537a5c0..bdb3537a2 100644 --- a/src/clib/utils/FrozenKeyIdxBiMap.hpp +++ b/src/clib/utils/FrozenKeyIdxBiMap.hpp @@ -103,6 +103,12 @@ struct FrozenKeyIdxBiMap { BiMapMode mode; }; +// ugh, it's unfortunate that we need to make this... but for now its useful. +// Ideally, we would refactor so that we can get rid of this function. +inline FrozenKeyIdxBiMap mk_invalid_FrozenKeyIdxBiMap() { + return FrozenKeyIdxBiMap{0, nullptr, BiMapMode::REFS_KEYDATA}; +} + /// Constructs a new FrozenKeyIdxBiMap /// /// @param[in] keys Sequence of 1 or more unique strings. Each string must @@ -119,18 +125,15 @@ struct FrozenKeyIdxBiMap { /// > this a simple C++ class instead) inline FrozenKeyIdxBiMap new_FrozenKeyIdxBiMap(const char* keys[], int key_count, BiMapMode mode) { - // this will be returned if there is an error - FrozenKeyIdxBiMap erroneous_obj{0, nullptr, BiMapMode::REFS_KEYDATA}; - // check the specified keys long long max_keys = static_cast(bimap::invalid_val) - 1LL; if (key_count < 1 || static_cast(key_count) > max_keys) { GrPrintErrMsg("key_count must be positive and cannot exceed %lld", max_keys); - return erroneous_obj; + return mk_invalid_FrozenKeyIdxBiMap(); } else if (keys == nullptr) { GrPrintErrMsg("keys must not be a nullptr"); - return erroneous_obj; + return mk_invalid_FrozenKeyIdxBiMap(); } for (int i = 0; i < key_count; i++) { GR_INTERNAL_REQUIRE(keys[i] != nullptr, "Can't specify a nullptr key"); @@ -140,13 +143,13 @@ inline FrozenKeyIdxBiMap new_FrozenKeyIdxBiMap(const char* keys[], "calling strlen on \"%s\", the key @ index %d, yields 0 or a length " "exceeding %d", keys[i], i, bimap::keylen_max); - return erroneous_obj; + return mk_invalid_FrozenKeyIdxBiMap(); } // check uniqueness for (int j = 0; j < i; j++) { if (strcmp(keys[i], keys[j]) == 0) { GrPrintErrMsg("\"%s\" key repeats", keys[i]); - return erroneous_obj; + return mk_invalid_FrozenKeyIdxBiMap(); } } } @@ -173,7 +176,7 @@ inline FrozenKeyIdxBiMap new_FrozenKeyIdxBiMap(const char* keys[], } default: { GrPrintErrMsg("unknown mode"); - return erroneous_obj; + return mk_invalid_FrozenKeyIdxBiMap(); } } @@ -208,7 +211,7 @@ inline void drop_FrozenKeyIdxBiMap(FrozenKeyIdxBiMap* ptr) { /// > This is pretty ugly/clunky, but its the only practical way to achieve /// > comparable behavior to other internal datatypes (ideally, we would make /// > this a simple C++ class instead) -FrozenKeyIdxBiMap FrozenKeyIdxBiMap_clone(const FrozenKeyIdxBiMap* ptr) { +inline FrozenKeyIdxBiMap FrozenKeyIdxBiMap_clone(const FrozenKeyIdxBiMap* ptr) { return new_FrozenKeyIdxBiMap(ptr->keys, ptr->length, ptr->mode); }; diff --git a/tests/unit/test_grain_species_info.cpp b/tests/unit/test_grain_species_info.cpp index 19bd87f4e..c09e7ccbf 100644 --- a/tests/unit/test_grain_species_info.cpp +++ b/tests/unit/test_grain_species_info.cpp @@ -194,17 +194,7 @@ INSTANTIATE_TEST_SUITE_P( // check the GrainSpeciesInfo object when constructed from dust_species // parameters that hold extreme values TEST(GrainSpeciesInfoTestMisc, DustSpeciesExtremeValues) { - { - unique_GrainSpeciesInfo_ptr ptr = make_unique_GrainSpeciesInfo(0); - EXPECT_EQ(ptr->n_species, 0) - << "GrainSpeciesInfo::n_species should be 0 when the dust_species " - << "parameter is 0."; - EXPECT_EQ(ptr->species_info, nullptr) - << "GrainSpeciesInfo::species_info should be a nullptr when " - << "dust_species parameter is 0."; - } - - int invalid_dust_species_values[2] = {-42423, MAX_dust_species_VAL + 1}; + int invalid_dust_species_values[3] = {-42423, 0, MAX_dust_species_VAL + 1}; for (auto dust_species_param : invalid_dust_species_values) { unique_GrainSpeciesInfo_ptr ptr = make_unique_GrainSpeciesInfo(dust_species_param); From 00865dd5ffe9af1b3729ab04a09997adc8d3df72 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Tue, 9 Dec 2025 20:23:00 -0500 Subject: [PATCH 059/175] use FrozenKeyIdxBiMap within GrainSpeciesInfo (2/3) Modify tests to start using `FrozenKeyIdxBiMap` rather than `GrainSpeciesInfoEntry::onlygrainsp_idx` and `GrainSpeciesInfoEntry::name`. In the next commit, we'll remove these members from `GrainSpeciesInfoEntry` --- tests/unit/test_grain_species_info.cpp | 53 ++++++++++++++++++-------- 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/tests/unit/test_grain_species_info.cpp b/tests/unit/test_grain_species_info.cpp index c09e7ccbf..b941d55a0 100644 --- a/tests/unit/test_grain_species_info.cpp +++ b/tests/unit/test_grain_species_info.cpp @@ -17,6 +17,7 @@ #include "LUT.hpp" #include "dust/grain_species_info.hpp" +#include "utils/FrozenKeyIdxBiMap.hpp" namespace { // stuff in an anonymous namespace is local to this file @@ -130,27 +131,48 @@ class GrainSpeciesInfoTest : public testing::TestWithParam { unique_GrainSpeciesInfo_ptr grain_species_info_; }; +// the following test is somewhat redundant with the SpeciesLUTCompare tests +// and is more work to maintain TEST_P(GrainSpeciesInfoTest, CheckOnlyGrainSpeciesLUTConsistency) { + // construct a vector with an element for each entry in OnlyGrainSpeciesLUT + std::vector ref_l{ + {"MgSiO3_dust", OnlyGrainSpLUT::MgSiO3_dust}, + {"AC_dust", OnlyGrainSpLUT::AC_dust}, + {"SiM_dust", OnlyGrainSpLUT::SiM_dust}, + {"FeM_dust", OnlyGrainSpLUT::FeM_dust}, + {"Mg2SiO4_dust", OnlyGrainSpLUT::Mg2SiO4_dust}, + {"Fe3O4_dust", OnlyGrainSpLUT::Fe3O4_dust}, + {"SiO2_dust", OnlyGrainSpLUT::SiO2_dust}, + {"MgO_dust", OnlyGrainSpLUT::MgO_dust}, + {"FeS_dust", OnlyGrainSpLUT::FeS_dust}, + {"Al2O3_dust", OnlyGrainSpLUT::Al2O3_dust}, + {"ref_org_dust", OnlyGrainSpLUT::ref_org_dust}, + {"vol_org_dust", OnlyGrainSpLUT::vol_org_dust}, + {"H2O_ice_dust", OnlyGrainSpLUT::H2O_ice_dust}, + }; + const int n_species = grain_species_info_->n_species; for (int i = 0; i < n_species; i++) { - // sanity check! - ASSERT_NE(grain_species_info_->species_info[i].name, nullptr); - // actual check! - EXPECT_EQ(i, grain_species_info_->species_info[i].onlygrainsp_idx) - << "element " << i << " of the GrainSpeciesInfo::species_info array " - << "doesn't seem to be synchronized with the OnlyGrainSpeciesLUT " - << "enumeration. At face value (there aren't other related bugs), " - << "OnlyGrainSpeciesLUT::" << grain_species_info_->species_info[i].name - << " seems to have a value of " - << grain_species_info_->species_info[i].onlygrainsp_idx; + const char* name = grackle::impl::FrozenKeyIdxBiMap_key_from_idx( + &grain_species_info_->name_map, static_cast(i)); + + ASSERT_NE(name, nullptr); // sanity check! + EXPECT_EQ(i, ref_l[i].index); // sanity check! + + // actual check: + EXPECT_EQ(std::string(name), ref_l[i].name) + << "the grain species associated with index " << i << " in the " + << "GrainSpeciesInfo instance doesn't seem to be synchronized with " + << "the OnlyGrainSpeciesLUT enumeration."; } } TEST_P(GrainSpeciesInfoTest, SublimationTemperature) { const int n_species = grain_species_info_->n_species; for (int i = 0; i < n_species; i++) { - // sanity check! - ASSERT_NE(grain_species_info_->species_info[i].name, nullptr); + const char* name = grackle::impl::FrozenKeyIdxBiMap_key_from_idx( + &grain_species_info_->name_map, static_cast(i)); + ASSERT_NE(name, nullptr); // sanity check! // actual check! EXPECT_GT(grain_species_info_->species_info[i].sublimation_temperature, 0) << "element " << i << " of the GrainSpeciesInfo::species_info array " @@ -165,10 +187,11 @@ TEST_P(GrainSpeciesInfoTest, SpeciesLUTCompare) { const int n_species = grain_species_info_->n_species; for (int i = 0; i < n_species; i++) { - // sanity check! - ASSERT_NE(grain_species_info_->species_info[i].name, nullptr); + const char* name_cstr = grackle::impl::FrozenKeyIdxBiMap_key_from_idx( + &grain_species_info_->name_map, static_cast(i)); + ASSERT_NE(name_cstr, nullptr); // sanity check! // actual check! - std::string actual_name(grain_species_info_->species_info[i].name); + std::string actual_name(name_cstr); EXPECT_EQ(actual_name, ref_list[i].name) << "according to the reference list, the grain species at index " << i << " should be `" << ref_list[i].name << "` (not `" << actual_name From fa08c26c6c74d98a4c90c5f38181a3a28fad3b8c Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Tue, 9 Dec 2025 20:28:26 -0500 Subject: [PATCH 060/175] use FrozenKeyIdxBiMap within GrainSpeciesInfo (3/3) Delete `GrainSpeciesInfoEntry::onlygrainsp_idx` and `GrainSpeciesInfoEntry::name`. --- src/clib/dust/grain_species_info.cpp | 33 ++-------------------------- src/clib/dust/grain_species_info.hpp | 13 ----------- 2 files changed, 2 insertions(+), 44 deletions(-) diff --git a/src/clib/dust/grain_species_info.cpp b/src/clib/dust/grain_species_info.cpp index d60eef6c4..d82aa4340 100644 --- a/src/clib/dust/grain_species_info.cpp +++ b/src/clib/dust/grain_species_info.cpp @@ -52,9 +52,8 @@ namespace { // stuff inside an anonymous namespace is local to this file /// - the ingredient list in the returned instance is **NOT** terminated by /// the sentinel grackle::impl::GrainSpeciesInfoEntry mk_gsp_info_entry_helper_( - int species_idx, int onlygrainsp_idx, const char* name, - bool h2dust_uses_carbonaceous_table, double sublimation_temperature, - double bulk_density_cgs, + int species_idx, bool h2dust_uses_carbonaceous_table, + double sublimation_temperature, double bulk_density_cgs, const grackle::impl::GrainGrowthIngredient* growth_ingredients) { using grackle::impl::GrainGrowthIngredient; @@ -77,8 +76,6 @@ grackle::impl::GrainSpeciesInfoEntry mk_gsp_info_entry_helper_( } return grackle::impl::GrainSpeciesInfoEntry{species_idx, - onlygrainsp_idx, - name, h2dust_uses_carbonaceous_table, sublimation_temperature, bulk_density_cgs, @@ -135,8 +132,6 @@ grackle::impl::GrainSpeciesInfo grackle::impl::new_GrainSpeciesInfo( names[0] = "MgSiO3_dust"; species_info[0] = mk_gsp_info_entry_helper_( /* species_idx = */ SpLUT::MgSiO3_dust, - /* onlygrainsp_idx = */ OnlyGrainSpLUT::MgSiO3_dust, - /* name = */ "MgSiO3_dust", /* h2dust_uses_carbonaceous_table = */ false, /* sublimation_temperature = */ 1222.0, /* bulk_density_cgs = */ 3.20185, @@ -150,8 +145,6 @@ grackle::impl::GrainSpeciesInfo grackle::impl::new_GrainSpeciesInfo( names[1] = "AC_dust"; species_info[1] = mk_gsp_info_entry_helper_( /* species_idx = */ SpLUT::AC_dust, - /* onlygrainsp_idx = */ OnlyGrainSpLUT::AC_dust, - /* name = */ "AC_dust", /* h2dust_uses_carbonaceous_table = */ true, /* sublimation_temperature = */ 1800.0, /* bulk_density_cgs = */ 2.27949, @@ -167,8 +160,6 @@ grackle::impl::GrainSpeciesInfo grackle::impl::new_GrainSpeciesInfo( names[2] = "SiM_dust"; species_info[2] = mk_gsp_info_entry_helper_( /* species_idx = */ SpLUT::SiM_dust, - /* onlygrainsp_idx = */ OnlyGrainSpLUT::SiM_dust, - /* name = */ "SiM_dust", /* h2dust_uses_carbonaceous_table = */ false, /* sublimation_temperature = */ 1500.0, /* bulk_density_cgs = */ 2.34118, @@ -182,8 +173,6 @@ grackle::impl::GrainSpeciesInfo grackle::impl::new_GrainSpeciesInfo( names[3] = "FeM_dust"; species_info[3] = mk_gsp_info_entry_helper_( /* species_idx = */ SpLUT::FeM_dust, - /* onlygrainsp_idx = */ OnlyGrainSpLUT::FeM_dust, - /* name = */ "FeM_dust", /* h2dust_uses_carbonaceous_table = */ false, /* sublimation_temperature = */ 1500.0, /* bulk_density_cgs = */ 7.95995, @@ -199,8 +188,6 @@ grackle::impl::GrainSpeciesInfo grackle::impl::new_GrainSpeciesInfo( names[4] = "Mg2SiO4_dust"; species_info[4] = mk_gsp_info_entry_helper_( /* species_idx = */ SpLUT::Mg2SiO4_dust, - /* onlygrainsp_idx = */ OnlyGrainSpLUT::Mg2SiO4_dust, - /* name = */ "Mg2SiO4_dust", /* h2dust_uses_carbonaceous_table = */ false, /* sublimation_temperature = */ 1277.0, /* bulk_density_cgs = */ 3.22133, @@ -215,8 +202,6 @@ grackle::impl::GrainSpeciesInfo grackle::impl::new_GrainSpeciesInfo( names[5] = "Fe3O4_dust"; species_info[5] = mk_gsp_info_entry_helper_( /* species_idx = */ SpLUT::Fe3O4_dust, - /* onlygrainsp_idx = */ OnlyGrainSpLUT::Fe3O4_dust, - /* name = */ "Fe3O4_dust", /* h2dust_uses_carbonaceous_table = */ false, /* sublimation_temperature = */ 1500.0, /* bulk_density_cgs = */ 5.25096, @@ -230,8 +215,6 @@ grackle::impl::GrainSpeciesInfo grackle::impl::new_GrainSpeciesInfo( names[6] = "SiO2_dust"; species_info[6] = mk_gsp_info_entry_helper_( /* species_idx = */ SpLUT::SiO2_dust, - /* onlygrainsp_idx = */ OnlyGrainSpLUT::SiO2_dust, - /* name = */ "SiO2_dust", /* h2dust_uses_carbonaceous_table = */ false, /* sublimation_temperature = */ 1500.0, /* bulk_density_cgs = */ 2.66235, @@ -246,8 +229,6 @@ grackle::impl::GrainSpeciesInfo grackle::impl::new_GrainSpeciesInfo( names[7] = "MgO_dust"; species_info[7] = mk_gsp_info_entry_helper_( /* species_idx = */ SpLUT::MgO_dust, - /* onlygrainsp_idx = */ OnlyGrainSpLUT::MgO_dust, - /* name = */ "MgO_dust", /* h2dust_uses_carbonaceous_table = */ false, /* sublimation_temperature = */ 1500.0, /* bulk_density_cgs = */ 3.58157, @@ -262,8 +243,6 @@ grackle::impl::GrainSpeciesInfo grackle::impl::new_GrainSpeciesInfo( names[8] = "FeS_dust"; species_info[8] = mk_gsp_info_entry_helper_( /* species_idx = */ SpLUT::FeS_dust, - /* onlygrainsp_idx = */ OnlyGrainSpLUT::FeS_dust, - /* name = */ "FeS_dust", /* h2dust_uses_carbonaceous_table = */ false, /* sublimation_temperature = */ 680.0, /* bulk_density_cgs = */ 4.87265, @@ -278,8 +257,6 @@ grackle::impl::GrainSpeciesInfo grackle::impl::new_GrainSpeciesInfo( names[9] = "Al2O3_dust"; species_info[9] = mk_gsp_info_entry_helper_( /* species_idx = */ SpLUT::Al2O3_dust, - /* onlygrainsp_idx = */ OnlyGrainSpLUT::Al2O3_dust, - /* name = */ "Al2O3_dust", /* h2dust_uses_carbonaceous_table = */ false, /* sublimation_temperature = */ 1500.0, /* bulk_density_cgs = */ 4.01610, @@ -296,8 +273,6 @@ grackle::impl::GrainSpeciesInfo grackle::impl::new_GrainSpeciesInfo( names[10] = "ref_org_dust"; species_info[10] = mk_gsp_info_entry_helper_( /* species_idx = */ SpLUT::ref_org_dust, - /* onlygrainsp_idx = */ OnlyGrainSpLUT::ref_org_dust, - /* name = */ "ref_org_dust", /* h2dust_uses_carbonaceous_table = */ false, /* sublimation_temperature = */ 575.0, /* bulk_density_cgs = */ 1.5, @@ -308,8 +283,6 @@ grackle::impl::GrainSpeciesInfo grackle::impl::new_GrainSpeciesInfo( names[11] = "vol_org_dust"; species_info[11] = mk_gsp_info_entry_helper_( /* species_idx = */ SpLUT::vol_org_dust, - /* onlygrainsp_idx = */ OnlyGrainSpLUT::vol_org_dust, - /* name = */ "vol_org_dust", /* h2dust_uses_carbonaceous_table = */ false, /* sublimation_temperature = */ 375.0, /* bulk_density_cgs = */ 1.0, @@ -319,8 +292,6 @@ grackle::impl::GrainSpeciesInfo grackle::impl::new_GrainSpeciesInfo( names[12] = "H2O_ice_dust"; species_info[12] = mk_gsp_info_entry_helper_( /* species_idx = */ SpLUT::H2O_ice_dust, - /* onlygrainsp_idx = */ OnlyGrainSpLUT::H2O_ice_dust, - /* name = */ "H2O_ice_dust", /* h2dust_uses_carbonaceous_table = */ false, /* sublimation_temperature = */ 153.0, /* bulk_density_cgs = */ 0.92, diff --git a/src/clib/dust/grain_species_info.hpp b/src/clib/dust/grain_species_info.hpp index 6785624d9..b306c154e 100644 --- a/src/clib/dust/grain_species_info.hpp +++ b/src/clib/dust/grain_species_info.hpp @@ -41,19 +41,6 @@ struct GrainSpeciesInfoEntry { /// the species index of the grain in the #GrainSpLUT lookup table int species_idx; - /// the species index of the grain in the #OnlyGrainSpLUT lookup table - /// - /// @note - /// It's frankly a little redundant to track this information (since an - /// instance of this struct is found at this index of an out.species_infoay) - int onlygrainsp_idx; - - /// name of the dust species - /// - /// @note - /// This primarily exists for debuging purposes - const char* name; - /// indicates whether to use the carbonaceous or silicate coefficient table /// to computing contributions of the grain species to the total h2dust rate /// (or the rate of H2 formation) From 89f3f35ba2cd0208ce3a939b322288375ee6c550 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Tue, 9 Dec 2025 21:09:30 -0500 Subject: [PATCH 061/175] switch to using a map of grain species --- src/clib/initialize_dust_yields.cpp | 100 +++++++++++----------------- 1 file changed, 40 insertions(+), 60 deletions(-) diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index bc2d8d1b4..0ca8b7c41 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -80,9 +80,6 @@ struct SetupCallbackCtx{ /// data from an injection pathway int counter; - /// the number of dust grain species - const int n_grain_species; - /// maps the names of known injection pathways to a unique index /// /// The callback function reports an error if an injection is encountered @@ -107,6 +104,10 @@ struct SetupCallbackCtx{ /// from HDF5 files. At that point, we'll need to tweak the callback function /// to load in data for models with arbitrary names. const grackle::impl::FrozenKeyIdxBiMap* inj_path_names; + + /// maps the names of the grain species for which data will be loaded to the + /// appropriate grain species index + const grackle::impl::FrozenKeyIdxBiMap* grain_species_names; }; /// a callback function that sets up the appropriate parts of @@ -125,6 +126,7 @@ extern "C" int setup_yield_table_callback( void* ctx) { namespace inj_input = ::grackle::impl::inj_model_input; + namespace bimap = ::grackle::impl::bimap; SetupCallbackCtx* my_ctx = static_cast(ctx); @@ -135,7 +137,7 @@ extern "C" int setup_yield_table_callback( int pathway_idx = static_cast( FrozenKeyIdxBiMap_idx_from_key(my_ctx->inj_path_names, name) ); - if (pathway_idx == static_cast(grackle::impl::bimap::invalid_val)) { + if (pathway_idx == static_cast(bimap::invalid_val)) { return GrPrintAndReturnErr( "`%s` is an unexpected injection pathway name", name); } @@ -160,64 +162,35 @@ extern "C" int setup_yield_table_callback( gas_yield[pathway_idx] = yield_info.gas_yield; } - // record each grain species yield - for (int yield_idx = 0; yield_idx < input->n_injected_grain_species; - yield_idx++) { - const inj_input::GrainSpeciesYieldProps& yield_info = - input->initial_grain_props[yield_idx]; - - int grain_species_idx = -1; - - // with a little refactoring, this will get a lot more concise - if (std::strcmp("MgSiO3_dust", yield_info.name) == 0) { - grain_species_idx = OnlyGrainSpLUT::MgSiO3_dust; - } else if (std::strcmp("AC_dust", yield_info.name) == 0) { - grain_species_idx = OnlyGrainSpLUT::AC_dust; - } else if (std::strcmp("SiM_dust", yield_info.name) == 0) { - grain_species_idx = OnlyGrainSpLUT::SiM_dust; - } else if (std::strcmp("FeM_dust", yield_info.name) == 0) { - grain_species_idx = OnlyGrainSpLUT::FeM_dust; - } else if (std::strcmp("Mg2SiO4_dust", yield_info.name) == 0) { - grain_species_idx = OnlyGrainSpLUT::Mg2SiO4_dust; - } else if (std::strcmp("Fe3O4_dust", yield_info.name) == 0) { - grain_species_idx = OnlyGrainSpLUT::Fe3O4_dust; - } else if (std::strcmp("SiO2_dust", yield_info.name) == 0) { - grain_species_idx = OnlyGrainSpLUT::SiO2_dust; - } else if (std::strcmp("MgO_dust", yield_info.name) == 0) { - grain_species_idx = OnlyGrainSpLUT::MgO_dust; - } else if (std::strcmp("FeS_dust", yield_info.name) == 0) { - grain_species_idx = OnlyGrainSpLUT::FeS_dust; - } else if (std::strcmp("Al2O3_dust", yield_info.name) == 0) { - grain_species_idx = OnlyGrainSpLUT::Al2O3_dust; - } else if (std::strcmp("ref_org_dust", yield_info.name) == 0) { - grain_species_idx = OnlyGrainSpLUT::ref_org_dust; - } else if (std::strcmp("vol_org_dust", yield_info.name) == 0) { - grain_species_idx = OnlyGrainSpLUT::vol_org_dust; - } else if (std::strcmp("H2O_ice_dust", yield_info.name) == 0) { - grain_species_idx = OnlyGrainSpLUT::H2O_ice_dust; - } else { - return GrPrintAndReturnErr( - "`%s` not a known grain species", yield_info.name); - } - - if (grain_species_idx >= my_ctx->n_grain_species) { - continue; - } + if (my_ctx->grain_species_names != nullptr) { + // loop over chunks of yield data. Each chunk holds data for the current + // pathway that corresponds to a distinct grain species + for (int yield_idx = 0; yield_idx < input->n_injected_grain_species; + yield_idx++) { + const inj_input::GrainSpeciesYieldProps& yield_info = + input->initial_grain_props[yield_idx]; + + int grain_species_idx = static_cast( + FrozenKeyIdxBiMap_idx_from_key(my_ctx->grain_species_names, + yield_info.name) + ); + if (grain_species_idx == static_cast(bimap::invalid_val)) { + continue; + } - // copy the nonprimordial yield fraction - inject_pathway_props->grain_yields.data[grain_species_idx][pathway_idx] - = yield_info.nonprimoridal_yield_frac; + // copy the nonprimordial yield fraction + inject_pathway_props->grain_yields.data[grain_species_idx][pathway_idx] + = yield_info.nonprimoridal_yield_frac; - // copy the 1st, 2nd, and 3rd moments of the size distribution - // (the 0th moment isn't recorded anywhere - double* size_mom_table = - inject_pathway_props->size_moments.data[grain_species_idx]; - for (int i = 0; i < 3; i++) { - size_mom_table[pathway_idx*3+i] = yield_info.size_moments[i]; - } + // copy the 1st, 2nd, and 3rd moments of the size distribution + // (the 0th moment isn't recorded anywhere + double* size_mom_table = + inject_pathway_props->size_moments.data[grain_species_idx]; + for (int i = 0; i < 3; i++) { + size_mom_table[pathway_idx*3+i] = yield_info.size_moments[i]; + } - // copy over the opacity coefficients table - { + // copy over the opacity coefficients table double* opac_coef_table = inject_pathway_props->opacity_coef_table.data[grain_species_idx]; int n_Td = grackle::impl::inj_model_input::N_Tdust_Opacity_Table; @@ -229,7 +202,9 @@ extern "C" int setup_yield_table_callback( opac_coef_table[i] = yield_info.opacity_coef_table[i_Td][i_coef]; } } + } + } (my_ctx->counter)++; @@ -343,11 +318,16 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, zero_out_dust_inject_props(inject_pathway_props); // actually load in the data for each injection pathway + GrainSpeciesInfo* grain_species_info = + my_rates->opaque_storage->grain_species_info; + const FrozenKeyIdxBiMap* grain_species_names = + (grain_species_info == nullptr) ? nullptr : &grain_species_info->name_map; + SetupCallbackCtx ctx = { /* inject_pathway_props = */ my_rates->opaque_storage->inject_pathway_props, /* counter = */ 0, - /* n_grain_species = */ get_n_grain_species(my_chemistry->dust_species), /* inj_path_names = */ &inj_path_names, + /* grain_species_names = */ grain_species_names, }; int ret = grackle::impl::inj_model_input::input_inject_model_iterate( From 45d2d14e1d547f0104a6f1773c854d533e88be0c Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Tue, 9 Dec 2025 21:33:53 -0500 Subject: [PATCH 062/175] add a few comments and a little assorted refactoring --- src/clib/initialize_dust_yields.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/initialize_dust_yields.cpp index 0ca8b7c41..b59598f91 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/initialize_dust_yields.cpp @@ -282,6 +282,7 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, "there was a problem building the map of model names"); } + // initialize the object that will hold the loaded data int n_log10Tdust_vals = grackle::impl::inj_model_input::N_Tdust_Opacity_Table; int n_opac_poly_coef = grackle::impl::inj_model_input::N_Opacity_Coef; my_rates->opaque_storage->inject_pathway_props = @@ -298,6 +299,7 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, return GR_FAIL; } + // initialize the grid of dust temperatures associated with the opacity table double log10Tdust_lo = 0.0; double log10Tdust_step = 0.1; @@ -309,7 +311,6 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, log10Tdust_vals[iTd] = log10Tdust_lo + (double)iTd * log10Tdust_step; } - // zero-out all metal injection yield fractions and dust grain properties yields::MetalTables_zero_out( &inject_pathway_props->total_metal_nuclide_yields, n_pathways); @@ -337,10 +338,12 @@ int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, if (ret != GR_SUCCESS) { return GrPrintAndReturnErr( "some kind of unspecified error occured when loading data from each " - "injection pathway"); + "injection pathway\n"); + } else if (ctx.counter != n_pathways) { + return GrPrintAndReturnErr( + "Only loaded data for %d of the %d available pathways\n", + ctx.counter, n_pathways); } - GR_INTERNAL_REQUIRE(ctx.counter == 12, "sanity-checking"); - return GR_SUCCESS; } From d0d8a92a493798633eb370461765ec244bef27ed Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 10 Dec 2025 09:22:55 -0500 Subject: [PATCH 063/175] rename initialize_dust_yields -> load_data --- .clang-format-ignore | 1 - src/clib/CMakeLists.txt | 2 +- src/clib/Make.config.objects | 3 ++- src/clib/initialize_rates.cpp | 10 ++++---- .../load_data.cpp} | 24 +++++++++++-------- .../load_data.hpp} | 17 +++++++------ 6 files changed, 32 insertions(+), 25 deletions(-) rename src/clib/{initialize_dust_yields.cpp => inject_model/load_data.cpp} (95%) rename src/clib/{initialize_dust_yields.hpp => inject_model/load_data.hpp} (51%) diff --git a/.clang-format-ignore b/.clang-format-ignore index d15536e08..1ee1005f9 100644 --- a/.clang-format-ignore +++ b/.clang-format-ignore @@ -32,7 +32,6 @@ src/clib/init_misc_species_cool_rates.cpp src/clib/initialize_UVbackground_data.c src/clib/initialize_chemistry_data.cpp src/clib/initialize_cloudy_data.c -src/clib/initialize_dust_yields.cpp src/clib/initialize_rates.cpp src/clib/internal_types.hpp src/clib/internal_units.h diff --git a/src/clib/CMakeLists.txt b/src/clib/CMakeLists.txt index 67f545d74..f96e50882 100644 --- a/src/clib/CMakeLists.txt +++ b/src/clib/CMakeLists.txt @@ -115,9 +115,9 @@ add_library(Grackle_Grackle dust/grain_species_info.cpp dust/grain_species_info.hpp init_misc_species_cool_rates.cpp init_misc_species_cool_rates.hpp initialize_chemistry_data.cpp - initialize_dust_yields.cpp initialize_dust_yields.hpp initialize_rates.cpp initialize_rates.hpp inject_model/grain_metal_inject_pathways.hpp + inject_model/load_data.cpp inject_model/load_data.hpp inject_model/raw_data.cpp inject_model/raw_data.hpp internal_types.cpp internal_types.hpp interp_table_utils.hpp diff --git a/src/clib/Make.config.objects b/src/clib/Make.config.objects index 7a4bb87af..372724187 100644 --- a/src/clib/Make.config.objects +++ b/src/clib/Make.config.objects @@ -31,10 +31,11 @@ OBJS_CONFIG_LIB = \ index_helper.lo \ initialize_chemistry_data.lo \ initialize_cloudy_data.lo \ - initialize_dust_yields.lo \ init_misc_species_cool_rates.lo \ initialize_rates.lo \ initialize_UVbackground_data.lo \ + inject_model/load_data.lo \ + inject_model/raw_data.lo \ interpolators_g.lo \ make_consistent.lo \ scale_fields.lo \ diff --git a/src/clib/initialize_rates.cpp b/src/clib/initialize_rates.cpp index 4a3d6c1c2..f9ee8708e 100644 --- a/src/clib/initialize_rates.cpp +++ b/src/clib/initialize_rates.cpp @@ -47,7 +47,7 @@ #include "collisional_rate_props.hpp" // init_extra_collisional_rates #include "dust/grain_species_info.hpp" #include "init_misc_species_cool_rates.hpp" // init_misc_species_cool_rates -#include "initialize_dust_yields.hpp" // initialize_dust_yields +#include "inject_model/load_data.hpp" // load_inject_path_data #include "initialize_rates.hpp" #include "internal_types.hpp" // new_CollisionalRxnRateCollection #include "LUT.hpp" // CollisionalRxnLUT @@ -653,10 +653,10 @@ int grackle::impl::initialize_rates( grackle::impl::new_GrainSpeciesInfo(my_chemistry->dust_species); } - // Dust rates - if (grackle::impl::initialize_dust_yields(my_chemistry, my_rates, my_units) == FAIL) { - fprintf(stderr, "Error in initialize_dust_yields.\n"); - return FAIL; + // Load injection pathway data + if (grackle::impl::load_inject_path_data(my_chemistry, my_rates) + != GR_SUCCESS) { + return GrPrintAndReturnErr("Error in load_inject_path_data."); } return SUCCESS; diff --git a/src/clib/initialize_dust_yields.cpp b/src/clib/inject_model/load_data.cpp similarity index 95% rename from src/clib/initialize_dust_yields.cpp rename to src/clib/inject_model/load_data.cpp index b59598f91..71c3ea642 100644 --- a/src/clib/initialize_dust_yields.cpp +++ b/src/clib/inject_model/load_data.cpp @@ -6,7 +6,7 @@ //===----------------------------------------------------------------------===// /// /// @file -/// Implements the functions to initialize the dust yields +/// Implments the function for loading injection pathway data /// //===----------------------------------------------------------------------===// @@ -16,13 +16,13 @@ #include #include #include "dust/grain_species_info.hpp" -#include "grackle_macros.h" +#include "../grackle_macros.h" #include "grackle_chemistry_data.h" -#include "initialize_dust_yields.hpp" // forward declarations -#include "inject_model/raw_data.hpp" -#include "LUT.hpp" -#include "opaque_storage.hpp" -#include "status_reporting.h" // GrPrintAndReturnErr +#include "load_data.hpp" // forward declarations +#include "raw_data.hpp" +#include "../LUT.hpp" +#include "../opaque_storage.hpp" +#include "../status_reporting.h" // GrPrintAndReturnErr #include "utils/FrozenKeyIdxBiMap.hpp" namespace { // stuff inside an anonymous namespace is local to this file @@ -259,10 +259,14 @@ void zero_out_dust_inject_props( } // anonymous namespace -int grackle::impl::initialize_dust_yields(chemistry_data *my_chemistry, - chemistry_data_storage *my_rates, - code_units *my_units) +int grackle::impl::load_inject_path_data(const chemistry_data *my_chemistry, + chemistry_data_storage *my_rates) { + // Currently, this function "loads" injection pathway data from data that is + // directly embedded as part of the Grackle library in a manner controlled + // by raw_data.hpp and raw_data.cpp + // + // Longer term, the goal is to "load" the data from an external HDF5 file if (my_chemistry->metal_chemistry == 0) { return GR_SUCCESS; diff --git a/src/clib/initialize_dust_yields.hpp b/src/clib/inject_model/load_data.hpp similarity index 51% rename from src/clib/initialize_dust_yields.hpp rename to src/clib/inject_model/load_data.hpp index c8f53609e..4ab8a0eed 100644 --- a/src/clib/initialize_dust_yields.hpp +++ b/src/clib/inject_model/load_data.hpp @@ -6,21 +6,24 @@ //===----------------------------------------------------------------------===// /// /// @file -/// Declares the function to initialize the dust yields +/// Declares the function for loading injection pathway data /// //===----------------------------------------------------------------------===// -#ifndef INITIALIZE_DUST_YIELDS_HPP -#define INITIALIZE_DUST_YIELDS_HPP +#ifndef INJECT_MODEL_LOAD_DATA_HPP +#define INJECT_MODEL_LOAD_DATA_HPP #include "grackle.h" namespace grackle::impl { -int initialize_dust_yields(chemistry_data* my_chemistry, - chemistry_data_storage* my_rates, - code_units* my_units); +/// loads the model data for the various injection pathways and update +/// @p my_rates, accordingly +/// +/// @returns GR_SUCCESS if successful +int load_inject_path_data(const chemistry_data* my_chemistry, + chemistry_data_storage* my_rates); } // namespace grackle::impl -#endif /* INITIALIZE_DUST_YIELDS_HPP */ +#endif /* INJECT_MODEL_LOAD_DATA_HPP */ From 51a55733bd4153ff9bcef45462aacb446f3b0722 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 10 Dec 2025 09:26:56 -0500 Subject: [PATCH 064/175] some light cleanup of inject_model/load_data.cpp --- src/clib/inject_model/load_data.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/clib/inject_model/load_data.cpp b/src/clib/inject_model/load_data.cpp index 71c3ea642..37eb58f6a 100644 --- a/src/clib/inject_model/load_data.cpp +++ b/src/clib/inject_model/load_data.cpp @@ -10,20 +10,15 @@ /// //===----------------------------------------------------------------------===// -#include -#include -#include -#include -#include -#include "dust/grain_species_info.hpp" -#include "../grackle_macros.h" +#include // std::strcmp +#include "../dust/grain_species_info.hpp" #include "grackle_chemistry_data.h" #include "load_data.hpp" // forward declarations #include "raw_data.hpp" #include "../LUT.hpp" #include "../opaque_storage.hpp" #include "../status_reporting.h" // GrPrintAndReturnErr -#include "utils/FrozenKeyIdxBiMap.hpp" +#include "../utils/FrozenKeyIdxBiMap.hpp" namespace { // stuff inside an anonymous namespace is local to this file @@ -342,10 +337,10 @@ int grackle::impl::load_inject_path_data(const chemistry_data *my_chemistry, if (ret != GR_SUCCESS) { return GrPrintAndReturnErr( "some kind of unspecified error occured when loading data from each " - "injection pathway\n"); + "injection pathway"); } else if (ctx.counter != n_pathways) { return GrPrintAndReturnErr( - "Only loaded data for %d of the %d available pathways\n", + "Only loaded data for %d of the %d available pathways", ctx.counter, n_pathways); } From 947faabc353c0daafacb390d5332b2beb5adc3a1 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 10 Dec 2025 09:31:37 -0500 Subject: [PATCH 065/175] apply clang-format --- src/clib/cool1d_multi_g.cpp | 4 +- .../grain_metal_inject_pathways.hpp | 17 +-- src/clib/inject_model/load_data.cpp | 141 ++++++++---------- src/clib/lookup_cool_rates1d.hpp | 9 +- src/clib/make_consistent.cpp | 11 +- src/clib/make_consistent.hpp | 7 +- 6 files changed, 89 insertions(+), 100 deletions(-) diff --git a/src/clib/cool1d_multi_g.cpp b/src/clib/cool1d_multi_g.cpp index 5bf09eb77..d787ece1a 100644 --- a/src/clib/cool1d_multi_g.cpp +++ b/src/clib/cool1d_multi_g.cpp @@ -188,9 +188,7 @@ void grackle::impl::cool1d_multi_g( grackle::impl::new_InternalDustPropBuf( my_fields->grid_dimension[0], GrainMetalInjectPathways_get_n_log10Tdust_vals( - my_rates->opaque_storage->inject_pathway_props - ) - ); + my_rates->opaque_storage->inject_pathway_props)); // opacity coefficients for each dust grain (the product of opacity // coefficient & gas mass density is the linear absortpion coefficient) grackle::impl::GrainSpeciesCollection grain_kappa = diff --git a/src/clib/inject_model/grain_metal_inject_pathways.hpp b/src/clib/inject_model/grain_metal_inject_pathways.hpp index 2da3da2ec..7bfaa24a0 100644 --- a/src/clib/inject_model/grain_metal_inject_pathways.hpp +++ b/src/clib/inject_model/grain_metal_inject_pathways.hpp @@ -76,12 +76,12 @@ inline void drop_MetalTables(MetalTables* ptr) { /// fills elements with zeros inline void MetalTables_zero_out(MetalTables* ptr, int nelem) { for (int i = 0; i < nelem; i++) { - ptr->C [i] = 0.0; - ptr->O [i] = 0.0; + ptr->C[i] = 0.0; + ptr->O[i] = 0.0; ptr->Mg[i] = 0.0; ptr->Al[i] = 0.0; ptr->Si[i] = 0.0; - ptr->S [i] = 0.0; + ptr->S[i] = 0.0; ptr->Fe[i] = 0.0; } } @@ -257,7 +257,6 @@ struct GrainMetalInjectPathways { /// computed from the opacity coefficient table. inline GrainMetalInjectPathways new_GrainMetalInjectPathways( int n_pathways, int n_log10Tdust_vals, int n_opac_poly_coef) { - bool err = false; if (n_pathways <= 0) { @@ -305,7 +304,8 @@ inline GrainMetalInjectPathways new_GrainMetalInjectPathways( /// Checks whether the GrainMetalInjectPathways that is returned by /// new_GrainMetalInjectPathways is valid -inline bool GrainMetalInjectPathways_is_valid(const GrainMetalInjectPathways* ptr) { +inline bool GrainMetalInjectPathways_is_valid( + const GrainMetalInjectPathways* ptr) { return ptr->n_pathways != -1; } @@ -322,17 +322,16 @@ inline bool GrainMetalInjectPathways_is_valid(const GrainMetalInjectPathways* pt /// @note /// Frankly, this is intended to be short-term solution until we have a chance /// to reduce the number of places where InternalDustPropBuf is constructed -inline int GrainMetalInjectPathways_get_n_log10Tdust_vals - (const GrainMetalInjectPathways* ptr) { +inline int GrainMetalInjectPathways_get_n_log10Tdust_vals( + const GrainMetalInjectPathways* ptr) { return (ptr == nullptr) ? 0 : ptr->log10Tdust_interp_props.dimension[0]; } - /// performs cleanup of the contents of GrainMetalInjectPathways /// /// This effectively invokes a destructor inline void drop_GrainMetalInjectPathways(GrainMetalInjectPathways* ptr) { - if (GrainMetalInjectPathways_is_valid(ptr)){ + if (GrainMetalInjectPathways_is_valid(ptr)) { yields::drop_MetalTables(&ptr->total_metal_nuclide_yields); yields::drop_MetalTables(&ptr->gas_metal_nuclide_yields); drop_GrainSpeciesCollection(&ptr->grain_yields); diff --git a/src/clib/inject_model/load_data.cpp b/src/clib/inject_model/load_data.cpp index 37eb58f6a..ca13dc6ce 100644 --- a/src/clib/inject_model/load_data.cpp +++ b/src/clib/inject_model/load_data.cpp @@ -17,7 +17,7 @@ #include "raw_data.hpp" #include "../LUT.hpp" #include "../opaque_storage.hpp" -#include "../status_reporting.h" // GrPrintAndReturnErr +#include "../status_reporting.h" // GrPrintAndReturnErr #include "../utils/FrozenKeyIdxBiMap.hpp" namespace { // stuff inside an anonymous namespace is local to this file @@ -27,17 +27,16 @@ namespace { // stuff inside an anonymous namespace is local to this file /// /// @see SetupCallbackCtx::inj_path_names - The entity that is initialized with /// the values in this variable. Its docstring provides more details. -constexpr const char * const known_inj_path_names[] = { - "local_ISM", "ccsn13", "ccsn20", "ccsn25", "ccsn30", "fsn13", - "fsn15", "fsn50", "fsn80", "pisn170", "pisn200", "y19", +constexpr const char* const known_inj_path_names[] = { + "local_ISM", "ccsn13", "ccsn20", "ccsn25", "ccsn30", "fsn13", + "fsn15", "fsn50", "fsn80", "pisn170", "pisn200", "y19", }; /// a crude map-like function bool lookup_metal_yield_ptrs( - grackle::impl::GrainMetalInjectPathways* inject_pathway_props, - const char* metal_nuclide_name, double** total_yield_ptr, - double** gasonly_yield_ptr -) { + grackle::impl::GrainMetalInjectPathways* inject_pathway_props, + const char* metal_nuclide_name, double** total_yield_ptr, + double** gasonly_yield_ptr) { if (std::strcmp("C", metal_nuclide_name) == 0) { (*total_yield_ptr) = inject_pathway_props->total_metal_nuclide_yields.C; (*gasonly_yield_ptr) = inject_pathway_props->gas_metal_nuclide_yields.C; @@ -63,11 +62,10 @@ bool lookup_metal_yield_ptrs( return false; } return true; - } /// the context object for setup_yield_table_callback -struct SetupCallbackCtx{ +struct SetupCallbackCtx { /// The object that gets updated by the values that the callback loads grackle::impl::GrainMetalInjectPathways* inject_pathway_props; @@ -117,9 +115,8 @@ struct SetupCallbackCtx{ /// receiving this callback extern "C" int setup_yield_table_callback( const char* name, - const grackle::impl::inj_model_input::InjectionPathwayInputData *input, - void* ctx) -{ + const grackle::impl::inj_model_input::InjectionPathwayInputData* input, + void* ctx) { namespace inj_input = ::grackle::impl::inj_model_input; namespace bimap = ::grackle::impl::bimap; @@ -130,27 +127,26 @@ extern "C" int setup_yield_table_callback( // -> see the docstring for SetupCallbackCtx::inj_path_names for how this // behavior will change when we start loading data from HDF5 files int pathway_idx = static_cast( - FrozenKeyIdxBiMap_idx_from_key(my_ctx->inj_path_names, name) - ); + FrozenKeyIdxBiMap_idx_from_key(my_ctx->inj_path_names, name)); if (pathway_idx == static_cast(bimap::invalid_val)) { - return GrPrintAndReturnErr( - "`%s` is an unexpected injection pathway name", name); + return GrPrintAndReturnErr("`%s` is an unexpected injection pathway name", + name); } // load the object that we update with the data we read - grackle::impl::GrainMetalInjectPathways* inject_pathway_props - = my_ctx->inject_pathway_props; + grackle::impl::GrainMetalInjectPathways* inject_pathway_props = + my_ctx->inject_pathway_props; // record the yields for each metal nuclide for (int i = 0; i < input->n_metal_nuclide_yields; i++) { const inj_input::MetalNuclideYieldProps& yield_info = - input->metal_nuclide_yields[i]; + input->metal_nuclide_yields[i]; double *total_yield, *gas_yield; - if (!lookup_metal_yield_ptrs(inject_pathway_props, yield_info.name, - &total_yield, &gas_yield)){ - return GrPrintAndReturnErr( - "`%s` not a known metal nuclide", yield_info.name); + if (!lookup_metal_yield_ptrs(inject_pathway_props, yield_info.name, + &total_yield, &gas_yield)) { + return GrPrintAndReturnErr("`%s` not a known metal nuclide", + yield_info.name); } total_yield[pathway_idx] = yield_info.total_yield; @@ -163,31 +159,29 @@ extern "C" int setup_yield_table_callback( for (int yield_idx = 0; yield_idx < input->n_injected_grain_species; yield_idx++) { const inj_input::GrainSpeciesYieldProps& yield_info = - input->initial_grain_props[yield_idx]; + input->initial_grain_props[yield_idx]; - int grain_species_idx = static_cast( - FrozenKeyIdxBiMap_idx_from_key(my_ctx->grain_species_names, - yield_info.name) - ); + int grain_species_idx = static_cast(FrozenKeyIdxBiMap_idx_from_key( + my_ctx->grain_species_names, yield_info.name)); if (grain_species_idx == static_cast(bimap::invalid_val)) { continue; } // copy the nonprimordial yield fraction - inject_pathway_props->grain_yields.data[grain_species_idx][pathway_idx] - = yield_info.nonprimoridal_yield_frac; + inject_pathway_props->grain_yields.data[grain_species_idx][pathway_idx] = + yield_info.nonprimoridal_yield_frac; // copy the 1st, 2nd, and 3rd moments of the size distribution // (the 0th moment isn't recorded anywhere double* size_mom_table = - inject_pathway_props->size_moments.data[grain_species_idx]; + inject_pathway_props->size_moments.data[grain_species_idx]; for (int i = 0; i < 3; i++) { - size_mom_table[pathway_idx*3+i] = yield_info.size_moments[i]; + size_mom_table[pathway_idx * 3 + i] = yield_info.size_moments[i]; } // copy over the opacity coefficients table double* opac_coef_table = - inject_pathway_props->opacity_coef_table.data[grain_species_idx]; + inject_pathway_props->opacity_coef_table.data[grain_species_idx]; int n_Td = grackle::impl::inj_model_input::N_Tdust_Opacity_Table; int n_coef = grackle::impl::inj_model_input::N_Opacity_Coef; @@ -197,9 +191,7 @@ extern "C" int setup_yield_table_callback( opac_coef_table[i] = yield_info.opacity_coef_table[i_Td][i_coef]; } } - } - } (my_ctx->counter)++; @@ -213,40 +205,39 @@ extern "C" int setup_yield_table_callback( /// to start, this only handles the grain yields void zero_out_dust_inject_props( grackle::impl::GrainMetalInjectPathways* inject_pathway_props) { - const int n_grain_species = OnlyGrainSpLUT::NUM_ENTRIES; int n_pathways = inject_pathway_props->n_pathways; // handle the grain yields for (int grain_species_idx = 0; grain_species_idx < n_grain_species; - grain_species_idx++){ + grain_species_idx++) { double* arr = inject_pathway_props->grain_yields.data[grain_species_idx]; - for(int iSN = 0; iSN < n_pathways; iSN++) { + for (int iSN = 0; iSN < n_pathways; iSN++) { arr[iSN] = 0.0; } } // handle the size moments - int moment_table_len = n_pathways * 3; // there are 3 size moments + int moment_table_len = n_pathways * 3; // there are 3 size moments for (int grain_species_idx = 0; grain_species_idx < n_grain_species; - grain_species_idx++){ + grain_species_idx++) { double* arr = inject_pathway_props->size_moments.data[grain_species_idx]; - for(int i = 0; i < moment_table_len; i++) { + for (int i = 0; i < moment_table_len; i++) { arr[i] = 0.0; } } // handle the opacity coefficient table - long long opac_table_len = ( - static_cast(n_pathways) * - static_cast(inject_pathway_props->n_opac_poly_coef) * - inject_pathway_props->log10Tdust_interp_props.dimension[0]); + long long opac_table_len = + (static_cast(n_pathways) * + static_cast(inject_pathway_props->n_opac_poly_coef) * + inject_pathway_props->log10Tdust_interp_props.dimension[0]); for (int grain_species_idx = 0; grain_species_idx < n_grain_species; - grain_species_idx++){ + grain_species_idx++) { double* arr = - inject_pathway_props->opacity_coef_table.data[grain_species_idx]; - for(long long i = 0LL; i < opac_table_len; i++) { + inject_pathway_props->opacity_coef_table.data[grain_species_idx]; + for (long long i = 0LL; i < opac_table_len; i++) { arr[i] = 0.0; } } @@ -254,9 +245,8 @@ void zero_out_dust_inject_props( } // anonymous namespace -int grackle::impl::load_inject_path_data(const chemistry_data *my_chemistry, - chemistry_data_storage *my_rates) -{ +int grackle::impl::load_inject_path_data(const chemistry_data* my_chemistry, + chemistry_data_storage* my_rates) { // Currently, this function "loads" injection pathway data from data that is // directly embedded as part of the Grackle library in a manner controlled // by raw_data.hpp and raw_data.cpp @@ -271,27 +261,27 @@ int grackle::impl::load_inject_path_data(const chemistry_data *my_chemistry, // -> in the future, we are going to move away from this hardcoded approach // -> since the strings are statically allocates, the map won't make copies // of the strings - constexpr int n_pathways = static_cast( - sizeof(known_inj_path_names) / sizeof(char*)); + constexpr int n_pathways = + static_cast(sizeof(known_inj_path_names) / sizeof(char*)); FrozenKeyIdxBiMap inj_path_names = new_FrozenKeyIdxBiMap( known_inj_path_names, n_pathways, BiMapMode::REFS_KEYDATA); if (!FrozenKeyIdxBiMap_is_ok(&inj_path_names)) { return GrPrintAndReturnErr( - "there was a problem building the map of model names"); + "there was a problem building the map of model names"); } // initialize the object that will hold the loaded data int n_log10Tdust_vals = grackle::impl::inj_model_input::N_Tdust_Opacity_Table; int n_opac_poly_coef = grackle::impl::inj_model_input::N_Opacity_Coef; my_rates->opaque_storage->inject_pathway_props = - new grackle::impl::GrainMetalInjectPathways; + new grackle::impl::GrainMetalInjectPathways; *(my_rates->opaque_storage->inject_pathway_props) = - new_GrainMetalInjectPathways(n_pathways, n_log10Tdust_vals, - n_opac_poly_coef); + new_GrainMetalInjectPathways(n_pathways, n_log10Tdust_vals, + n_opac_poly_coef); - grackle::impl::GrainMetalInjectPathways* inject_pathway_props - = my_rates->opaque_storage->inject_pathway_props; + grackle::impl::GrainMetalInjectPathways* inject_pathway_props = + my_rates->opaque_storage->inject_pathway_props; if (!GrainMetalInjectPathways_is_valid(inject_pathway_props)) { drop_FrozenKeyIdxBiMap(&inj_path_names); @@ -302,32 +292,33 @@ int grackle::impl::load_inject_path_data(const chemistry_data *my_chemistry, double log10Tdust_lo = 0.0; double log10Tdust_step = 0.1; - inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0] - = log10Tdust_step; + inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0] = + log10Tdust_step; double* log10Tdust_vals = - inject_pathway_props->log10Tdust_interp_props.parameters[0]; - for(int iTd = 0; iTd < n_log10Tdust_vals; iTd++) { + inject_pathway_props->log10Tdust_interp_props.parameters[0]; + for (int iTd = 0; iTd < n_log10Tdust_vals; iTd++) { log10Tdust_vals[iTd] = log10Tdust_lo + (double)iTd * log10Tdust_step; } // zero-out all metal injection yield fractions and dust grain properties yields::MetalTables_zero_out( &inject_pathway_props->total_metal_nuclide_yields, n_pathways); - yields::MetalTables_zero_out( - &inject_pathway_props->gas_metal_nuclide_yields, n_pathways); + yields::MetalTables_zero_out(&inject_pathway_props->gas_metal_nuclide_yields, + n_pathways); zero_out_dust_inject_props(inject_pathway_props); // actually load in the data for each injection pathway - GrainSpeciesInfo* grain_species_info = - my_rates->opaque_storage->grain_species_info; + GrainSpeciesInfo* grain_species_info = + my_rates->opaque_storage->grain_species_info; const FrozenKeyIdxBiMap* grain_species_names = - (grain_species_info == nullptr) ? nullptr : &grain_species_info->name_map; + (grain_species_info == nullptr) ? nullptr : &grain_species_info->name_map; SetupCallbackCtx ctx = { - /* inject_pathway_props = */ my_rates->opaque_storage->inject_pathway_props, - /* counter = */ 0, - /* inj_path_names = */ &inj_path_names, - /* grain_species_names = */ grain_species_names, + /* inject_pathway_props = */ my_rates->opaque_storage + ->inject_pathway_props, + /* counter = */ 0, + /* inj_path_names = */ &inj_path_names, + /* grain_species_names = */ grain_species_names, }; int ret = grackle::impl::inj_model_input::input_inject_model_iterate( @@ -340,8 +331,8 @@ int grackle::impl::load_inject_path_data(const chemistry_data *my_chemistry, "injection pathway"); } else if (ctx.counter != n_pathways) { return GrPrintAndReturnErr( - "Only loaded data for %d of the %d available pathways", - ctx.counter, n_pathways); + "Only loaded data for %d of the %d available pathways", ctx.counter, + n_pathways); } return GR_SUCCESS; diff --git a/src/clib/lookup_cool_rates1d.hpp b/src/clib/lookup_cool_rates1d.hpp index b3387e3a1..fb041799f 100644 --- a/src/clib/lookup_cool_rates1d.hpp +++ b/src/clib/lookup_cool_rates1d.hpp @@ -809,11 +809,10 @@ inline void lookup_cool_rates1d( // Compute grain size increment if ((anydust != MASK_FALSE) && (my_chemistry->dust_species > 0)) { - f_wrap::calc_grain_size_increment_1d(dom, idx_range, itmask_metal, - my_chemistry, - my_rates->opaque_storage->inject_pathway_props, - my_fields, - internal_dust_prop_scratch_buf); + f_wrap::calc_grain_size_increment_1d( + dom, idx_range, itmask_metal, my_chemistry, + my_rates->opaque_storage->inject_pathway_props, my_fields, + internal_dust_prop_scratch_buf); } // Look-up rate for H2 formation on dust & (when relevant) grain growth rates diff --git a/src/clib/make_consistent.cpp b/src/clib/make_consistent.cpp index 2734ed35a..5363c2fea 100644 --- a/src/clib/make_consistent.cpp +++ b/src/clib/make_consistent.cpp @@ -26,9 +26,10 @@ namespace grackle::impl { -void make_consistent(int imetal, double dom, chemistry_data* my_chemistry, - const grackle::impl::GrainMetalInjectPathways* inject_pathway_props, - grackle_field_data* my_fields) { +void make_consistent( + int imetal, double dom, chemistry_data* my_chemistry, + const grackle::impl::GrainMetalInjectPathways* inject_pathway_props, + grackle_field_data* my_fields) { // Arguments grackle::impl::View de( @@ -244,8 +245,8 @@ void make_consistent(int imetal, double dom, chemistry_data* my_chemistry, gr_float correctCd, correctOd, correctMgd, correctSid, correctFed; int iSN, iSN0; - const int n_pathways = (inject_pathway_props == nullptr) ? 0 : - inject_pathway_props->n_pathways; + const int n_pathways = + (inject_pathway_props == nullptr) ? 0 : inject_pathway_props->n_pathways; std::vector SN_metal_data_(my_fields->grid_dimension[0] * n_pathways); grackle::impl::View SN_metal; diff --git a/src/clib/make_consistent.hpp b/src/clib/make_consistent.hpp index 2edb6c91f..d571b0428 100644 --- a/src/clib/make_consistent.hpp +++ b/src/clib/make_consistent.hpp @@ -30,9 +30,10 @@ namespace grackle::impl { /// @param[in] inject_pathway_props holds data about the modelled injection /// pathways for all metals and grain species /// @param[in] my_fields specifies the field data -void make_consistent(int imetal, double dom, chemistry_data* my_chemistry, - const grackle::impl::GrainMetalInjectPathways* inject_pathway_props, - grackle_field_data* my_fields); +void make_consistent( + int imetal, double dom, chemistry_data* my_chemistry, + const grackle::impl::GrainMetalInjectPathways* inject_pathway_props, + grackle_field_data* my_fields); } // namespace grackle::impl From d8137d6af7689a8a5ef5d4d0fbe686144aa5d02b Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 10 Dec 2025 09:47:37 -0500 Subject: [PATCH 066/175] update Makefile to remove object files in subdirectories --- src/clib/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/clib/Makefile b/src/clib/Makefile index 9a5563757..d7866478e 100644 --- a/src/clib/Makefile +++ b/src/clib/Makefile @@ -338,7 +338,8 @@ install: #----------------------------------------------------------------------- clean: - -@rm -f *.la .libs/* *.o *.lo DEPEND.bak *~ $(OUTPUT) *.exe DEPEND out.make.DEPEND + -@rm -f *.la .libs/* DEPEND.bak *~ $(OUTPUT) *.exe DEPEND out.make.DEPEND + -@find . \( -name '*.o' -o -name '*.lo' \) -exec rm '{}' \; -@rm -rf $(AUTOGEN_DIR) -@touch DEPEND From eca5fb0f00d65b99392c22b63f56c92e5c1fb30f Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 10 Dec 2025 10:39:18 -0500 Subject: [PATCH 067/175] another tweak to `make clean` --- src/clib/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/clib/Makefile b/src/clib/Makefile index d7866478e..10800b9ab 100644 --- a/src/clib/Makefile +++ b/src/clib/Makefile @@ -338,9 +338,10 @@ install: #----------------------------------------------------------------------- clean: - -@rm -f *.la .libs/* DEPEND.bak *~ $(OUTPUT) *.exe DEPEND out.make.DEPEND - -@find . \( -name '*.o' -o -name '*.lo' \) -exec rm '{}' \; + -@rm -f *.la DEPEND.bak *~ $(OUTPUT) *.exe DEPEND out.make.DEPEND -@rm -rf $(AUTOGEN_DIR) + -@find . -type d -name '.libs' -exec rm -rf '{}' + + -@find . \( -name '*.o' -o -name '*.lo' \) -exec rm -f '{}' \; -@touch DEPEND #----------------------------------------------------------------------- From 38a1685fa87830f271098933a446e4f57f7f4b13 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 10 Dec 2025 14:54:22 -0500 Subject: [PATCH 068/175] Introduce ``InjectPathFieldPack`` 1/3 Essentially, this type holds pointers to the various injection pathway fields in the order that is implicitly assumed throughout the codebase. This change helps simplify make_consistent and it will also simplify `calc_grain_size_increment_1d` (once transcribed). Longer term, I have a plan that will let use dispose of this ``InjectPathFieldPack`` type (but, we need to make a few changes before we get to that). --- src/clib/CMakeLists.txt | 1 + .../inject_model/inject_path_field_pack.hpp | 60 +++++++++++ src/clib/inject_model/load_data.cpp | 8 +- src/clib/inject_model/raw_data.hpp | 3 + src/clib/make_consistent.cpp | 100 ++++++------------ 5 files changed, 101 insertions(+), 71 deletions(-) create mode 100644 src/clib/inject_model/inject_path_field_pack.hpp diff --git a/src/clib/CMakeLists.txt b/src/clib/CMakeLists.txt index f96e50882..5ac458b1d 100644 --- a/src/clib/CMakeLists.txt +++ b/src/clib/CMakeLists.txt @@ -117,6 +117,7 @@ add_library(Grackle_Grackle initialize_chemistry_data.cpp initialize_rates.cpp initialize_rates.hpp inject_model/grain_metal_inject_pathways.hpp + inject_model/inject_path_field_pack.hpp inject_model/load_data.cpp inject_model/load_data.hpp inject_model/raw_data.cpp inject_model/raw_data.hpp internal_types.cpp internal_types.hpp diff --git a/src/clib/inject_model/inject_path_field_pack.hpp b/src/clib/inject_model/inject_path_field_pack.hpp new file mode 100644 index 000000000..67e05fcb5 --- /dev/null +++ b/src/clib/inject_model/inject_path_field_pack.hpp @@ -0,0 +1,60 @@ +//===----------------------------------------------------------------------===// +// +// See the LICENSE file for license and copyright information +// SPDX-License-Identifier: NCSA AND BSD-3-Clause +// +//===----------------------------------------------------------------------===// +/// +/// @file +/// Declares the InjectPathFieldPack type +/// +//===----------------------------------------------------------------------===// +#ifndef INJECT_MODEL_INJECT_PATH_FIELD_PACK_HPP +#define INJECT_MODEL_INJECT_PATH_FIELD_PACK_HPP + +#include "raw_data.hpp" // grackle::impl::inj_model_input::N_Injection_Pathways + +namespace grackle::impl { + +/// A temporary type that is used to collect the injection pathway metal +/// density fields in the order that is assumed throughout Grackle +/// +/// I have some ideas that will let us dispose of this type in the near future. +struct InjectPathFieldPack { + const gr_float* fields[inj_model_input::N_Injection_Pathways]; +}; + +/// Setup an InjectPathFieldPack instance +inline InjectPathFieldPack setup_InjectPathFieldPack( + const chemistry_data* my_chem, const grackle_field_data* my_fields) { + if ((my_chem->metal_chemistry > 0) && (my_chem->multi_metals == 1)) { + return InjectPathFieldPack{{ + my_fields->local_ISM_metal_density, + my_fields->ccsn13_metal_density, + my_fields->ccsn20_metal_density, + my_fields->ccsn25_metal_density, + my_fields->ccsn30_metal_density, + my_fields->fsn13_metal_density, + my_fields->fsn15_metal_density, + my_fields->fsn50_metal_density, + my_fields->fsn80_metal_density, + my_fields->pisn170_metal_density, + my_fields->pisn200_metal_density, + my_fields->y19_metal_density, + }}; + } + + InjectPathFieldPack out; + for (int i = 0; i < inj_model_input::N_Injection_Pathways; i++) { + out.fields[i] = nullptr; + } + + if ((my_chem->metal_chemistry > 0) && (my_chem->multi_metals == 0)) { + out.fields[my_chem->metal_abundances] = my_fields->metal_density; + } + return out; +} + +} // namespace grackle::impl + +#endif /* INJECT_MODEL_INJECT_PATH_FIELD_PACK_HPP */ diff --git a/src/clib/inject_model/load_data.cpp b/src/clib/inject_model/load_data.cpp index ca13dc6ce..ed3af2408 100644 --- a/src/clib/inject_model/load_data.cpp +++ b/src/clib/inject_model/load_data.cpp @@ -23,7 +23,7 @@ namespace { // stuff inside an anonymous namespace is local to this file /// names of all injection pathways known to grackle listed in the order -/// in other parts of the codebase +/// consistent with the logic for implementing InjectPathFieldPack /// /// @see SetupCallbackCtx::inj_path_names - The entity that is initialized with /// the values in this variable. Its docstring provides more details. @@ -32,6 +32,12 @@ constexpr const char* const known_inj_path_names[] = { "fsn15", "fsn50", "fsn80", "pisn170", "pisn200", "y19", }; +static_assert(sizeof(known_inj_path_names) == + (sizeof(char*) * + grackle::impl::inj_model_input::N_Injection_Pathways), + "inconsistency b/t number of entries in known_inj_path_names and " + "grackle::impl::inj_model_input::N_Injection_Pathways"); + /// a crude map-like function bool lookup_metal_yield_ptrs( grackle::impl::GrainMetalInjectPathways* inject_pathway_props, diff --git a/src/clib/inject_model/raw_data.hpp b/src/clib/inject_model/raw_data.hpp index c1e2ddc03..6486b5602 100644 --- a/src/clib/inject_model/raw_data.hpp +++ b/src/clib/inject_model/raw_data.hpp @@ -36,6 +36,9 @@ static constexpr int N_Opacity_Coef = 4; /// and injection pathway. For each Tdust, there are N_Opacity_Coef coefficients static constexpr int N_Tdust_Opacity_Table = 35; +/// the number of hard-coded injection pathways +static constexpr int N_Injection_Pathways = 12; + struct MetalNuclideYieldProps; struct GrainSpeciesYieldProps; diff --git a/src/clib/make_consistent.cpp b/src/clib/make_consistent.cpp index 5363c2fea..6e78e22c0 100644 --- a/src/clib/make_consistent.cpp +++ b/src/clib/make_consistent.cpp @@ -19,6 +19,7 @@ #include "grackle.h" #include "fortran_func_decls.h" #include "inject_model/grain_metal_inject_pathways.hpp" +#include "inject_model/inject_path_field_pack.hpp" #include "opaque_storage.hpp" #include "utils-cpp.hpp" @@ -191,42 +192,6 @@ void make_consistent( grackle::impl::View H2Oice( my_fields->H2O_ice_dust_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_loc( - my_fields->local_ISM_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_C13( - my_fields->ccsn13_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_C20( - my_fields->ccsn20_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_C25( - my_fields->ccsn25_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_C30( - my_fields->ccsn30_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_F13( - my_fields->fsn13_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_F15( - my_fields->fsn15_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_F50( - my_fields->fsn50_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_F80( - my_fields->fsn80_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_P170( - my_fields->pisn170_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_P200( - my_fields->pisn200_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_Y19( - my_fields->y19_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); // locals @@ -249,10 +214,18 @@ void make_consistent( (inject_pathway_props == nullptr) ? 0 : inject_pathway_props->n_pathways; std::vector SN_metal_data_(my_fields->grid_dimension[0] * n_pathways); - grackle::impl::View SN_metal; - if (n_pathways > 0) { - SN_metal = grackle::impl::View( - SN_metal_data_.data(), my_fields->grid_dimension[0], n_pathways); + + grackle::impl::View + SN_metal_arr[inj_model_input::N_Injection_Pathways]; + if ((my_chemistry->metal_chemistry > 0) && + (my_chemistry->multi_metals == 1)) { + InjectPathFieldPack tmp = + setup_InjectPathFieldPack(my_chemistry, my_fields); + for (int i = 0; i < n_pathways; i++) { + SN_metal_arr[i] = grackle::impl::View( + tmp.fields[i], my_fields->grid_dimension[0], + my_fields->grid_dimension[1], my_fields->grid_dimension[2]); + } } std::vector Ct(my_fields->grid_dimension[0]); std::vector Ot(my_fields->grid_dimension[0]); @@ -397,21 +370,6 @@ void make_consistent( // metal_Y19(i,j,k) = metal_Y19(i,j,k) * correctZ // enddo - for (i = my_fields->grid_start[0]; i <= my_fields->grid_end[0]; i++) { - SN_metal(i, 0) = metal_loc(i, j, k); - SN_metal(i, 1) = metal_C13(i, j, k); - SN_metal(i, 2) = metal_C20(i, j, k); - SN_metal(i, 3) = metal_C25(i, j, k); - SN_metal(i, 4) = metal_C30(i, j, k); - SN_metal(i, 5) = metal_F13(i, j, k); - SN_metal(i, 6) = metal_F15(i, j, k); - SN_metal(i, 7) = metal_F50(i, j, k); - SN_metal(i, 8) = metal_F80(i, j, k); - SN_metal(i, 9) = metal_P170(i, j, k); - SN_metal(i, 10) = metal_P200(i, j, k); - SN_metal(i, 11) = metal_Y19(i, j, k); - } - for (i = my_fields->grid_start[0]; i <= my_fields->grid_end[0]; i++) { Ct[i] = 0.; Cg[i] = 0.; @@ -428,21 +386,23 @@ void make_consistent( Fet[i] = 0.; Feg[i] = 0.; for (iSN = 0; iSN < n_pathways; iSN++) { - Ct[i] = Ct[i] + total_metal_yields.C[iSN] * SN_metal(i, iSN); - Ot[i] = Ot[i] + total_metal_yields.O[iSN] * SN_metal(i, iSN); - Mgt[i] = Mgt[i] + total_metal_yields.Mg[iSN] * SN_metal(i, iSN); - Alt[i] = Alt[i] + total_metal_yields.Al[iSN] * SN_metal(i, iSN); - Sit[i] = Sit[i] + total_metal_yields.Si[iSN] * SN_metal(i, iSN); - St[i] = St[i] + total_metal_yields.S[iSN] * SN_metal(i, iSN); - Fet[i] = Fet[i] + total_metal_yields.Fe[iSN] * SN_metal(i, iSN); - - Cg[i] = Cg[i] + onlygas_metal_yields.C[iSN] * SN_metal(i, iSN); - Og[i] = Og[i] + onlygas_metal_yields.O[iSN] * SN_metal(i, iSN); - Mgg[i] = Mgg[i] + onlygas_metal_yields.Mg[iSN] * SN_metal(i, iSN); - Alg[i] = Alg[i] + onlygas_metal_yields.Al[iSN] * SN_metal(i, iSN); - Sig[i] = Sig[i] + onlygas_metal_yields.Si[iSN] * SN_metal(i, iSN); - Sg[i] = Sg[i] + onlygas_metal_yields.S[iSN] * SN_metal(i, iSN); - Feg[i] = Feg[i] + onlygas_metal_yields.Fe[iSN] * SN_metal(i, iSN); + gr_float cur_val = SN_metal_arr[iSN](i, j, k); + + Ct[i] = Ct[i] + total_metal_yields.C[iSN] * cur_val; + Ot[i] = Ot[i] + total_metal_yields.O[iSN] * cur_val; + Mgt[i] = Mgt[i] + total_metal_yields.Mg[iSN] * cur_val; + Alt[i] = Alt[i] + total_metal_yields.Al[iSN] * cur_val; + Sit[i] = Sit[i] + total_metal_yields.Si[iSN] * cur_val; + St[i] = St[i] + total_metal_yields.S[iSN] * cur_val; + Fet[i] = Fet[i] + total_metal_yields.Fe[iSN] * cur_val; + + Cg[i] = Cg[i] + onlygas_metal_yields.C[iSN] * cur_val; + Og[i] = Og[i] + onlygas_metal_yields.O[iSN] * cur_val; + Mgg[i] = Mgg[i] + onlygas_metal_yields.Mg[iSN] * cur_val; + Alg[i] = Alg[i] + onlygas_metal_yields.Al[iSN] * cur_val; + Sig[i] = Sig[i] + onlygas_metal_yields.Si[iSN] * cur_val; + Sg[i] = Sg[i] + onlygas_metal_yields.S[iSN] * cur_val; + Feg[i] = Feg[i] + onlygas_metal_yields.Fe[iSN] * cur_val; } } } From 530aae34956dd7443f231cd58a6c9825240dafd7 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 10 Dec 2025 15:58:11 -0500 Subject: [PATCH 069/175] Introduce ``InjectPathFieldPack`` 2/3 Introduce the start_idx and stop_idx members to the struct --- .../inject_model/inject_path_field_pack.hpp | 47 +++++++++++++------ src/clib/make_consistent.cpp | 33 ++++++++----- 2 files changed, 53 insertions(+), 27 deletions(-) diff --git a/src/clib/inject_model/inject_path_field_pack.hpp b/src/clib/inject_model/inject_path_field_pack.hpp index 67e05fcb5..0dd2526fd 100644 --- a/src/clib/inject_model/inject_path_field_pack.hpp +++ b/src/clib/inject_model/inject_path_field_pack.hpp @@ -21,6 +21,15 @@ namespace grackle::impl { /// /// I have some ideas that will let us dispose of this type in the near future. struct InjectPathFieldPack { + /// Specifies the bounds for a for-loop that you would use to iterate over + /// all relevant injection model density fields that are present in fields + /// + /// @todo + /// Some changes are required before we can safely assume that start_idx is + /// always 0 + int start_idx, stop_idx; + + /// holds pointers to the various injection model density fields const gr_float* fields[inj_model_input::N_Injection_Pathways]; }; @@ -28,20 +37,24 @@ struct InjectPathFieldPack { inline InjectPathFieldPack setup_InjectPathFieldPack( const chemistry_data* my_chem, const grackle_field_data* my_fields) { if ((my_chem->metal_chemistry > 0) && (my_chem->multi_metals == 1)) { - return InjectPathFieldPack{{ - my_fields->local_ISM_metal_density, - my_fields->ccsn13_metal_density, - my_fields->ccsn20_metal_density, - my_fields->ccsn25_metal_density, - my_fields->ccsn30_metal_density, - my_fields->fsn13_metal_density, - my_fields->fsn15_metal_density, - my_fields->fsn50_metal_density, - my_fields->fsn80_metal_density, - my_fields->pisn170_metal_density, - my_fields->pisn200_metal_density, - my_fields->y19_metal_density, - }}; + return InjectPathFieldPack{ + /* start_idx = */ 0, + /* stop_idx = */ inj_model_input::N_Injection_Pathways, + /* fields = */ + { + my_fields->local_ISM_metal_density, + my_fields->ccsn13_metal_density, + my_fields->ccsn20_metal_density, + my_fields->ccsn25_metal_density, + my_fields->ccsn30_metal_density, + my_fields->fsn13_metal_density, + my_fields->fsn15_metal_density, + my_fields->fsn50_metal_density, + my_fields->fsn80_metal_density, + my_fields->pisn170_metal_density, + my_fields->pisn200_metal_density, + my_fields->y19_metal_density, + }}; } InjectPathFieldPack out; @@ -50,8 +63,14 @@ inline InjectPathFieldPack setup_InjectPathFieldPack( } if ((my_chem->metal_chemistry > 0) && (my_chem->multi_metals == 0)) { + out.start_idx = my_chem->metal_abundances; + out.stop_idx = out.start_idx + 1; out.fields[my_chem->metal_abundances] = my_fields->metal_density; + } else { + out.start_idx = 0; + out.stop_idx = out.start_idx; } + return out; } diff --git a/src/clib/make_consistent.cpp b/src/clib/make_consistent.cpp index 6e78e22c0..cbd4dca47 100644 --- a/src/clib/make_consistent.cpp +++ b/src/clib/make_consistent.cpp @@ -208,25 +208,32 @@ void make_consistent( correctFe; gr_float correctCg, correctOg, correctMgg, correctSig, correctFeg; gr_float correctCd, correctOd, correctMgd, correctSid, correctFed; - int iSN, iSN0; - - const int n_pathways = - (inject_pathway_props == nullptr) ? 0 : inject_pathway_props->n_pathways; - std::vector SN_metal_data_(my_fields->grid_dimension[0] * - n_pathways); + // when relevant, each view within SN_metal_arr wraps a field specifying the + // total metal density that corresponds to an injection pathway grackle::impl::View SN_metal_arr[inj_model_input::N_Injection_Pathways]; + // declare variables used to hold bounds for iterating over SN_metal_arr + int inj_path_idx_start, inj_path_idx_stop; + + // construct view of each specified injection pathway metal density field if ((my_chemistry->metal_chemistry > 0) && (my_chemistry->multi_metals == 1)) { - InjectPathFieldPack tmp = - setup_InjectPathFieldPack(my_chemistry, my_fields); - for (int i = 0; i < n_pathways; i++) { - SN_metal_arr[i] = grackle::impl::View( - tmp.fields[i], my_fields->grid_dimension[0], + InjectPathFieldPack p = setup_InjectPathFieldPack(my_chemistry, my_fields); + + inj_path_idx_start = p.start_idx; + inj_path_idx_stop = p.stop_idx; + + for (int iSN = inj_path_idx_start; iSN < inj_path_idx_stop; iSN++) { + SN_metal_arr[iSN] = grackle::impl::View( + p.fields[iSN], my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); } + } else { + inj_path_idx_start = 0; + inj_path_idx_stop = 0; } + std::vector Ct(my_fields->grid_dimension[0]); std::vector Ot(my_fields->grid_dimension[0]); std::vector Mgt(my_fields->grid_dimension[0]); @@ -327,7 +334,7 @@ void make_consistent( inject_pathway_props->gas_metal_nuclide_yields; if (my_chemistry->multi_metals == 0) { // case with 1 injection pathway - iSN0 = my_chemistry->metal_abundances; + int iSN0 = my_chemistry->metal_abundances; for (i = my_fields->grid_start[0]; i <= my_fields->grid_end[0]; i++) { Ct[i] = total_metal_yields.C[iSN0] * metal(i, j, k); Ot[i] = total_metal_yields.O[iSN0] * metal(i, j, k); @@ -385,7 +392,7 @@ void make_consistent( Sg[i] = 0.; Fet[i] = 0.; Feg[i] = 0.; - for (iSN = 0; iSN < n_pathways; iSN++) { + for (int iSN = inj_path_idx_start; iSN < inj_path_idx_stop; iSN++) { gr_float cur_val = SN_metal_arr[iSN](i, j, k); Ct[i] = Ct[i] + total_metal_yields.C[iSN] * cur_val; From f6bf2460eeec38e32d4205545627a033ef492961 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 10 Dec 2025 16:36:40 -0500 Subject: [PATCH 070/175] Introduce ``InjectPathFieldPack`` 3/3 Use the start_idx and stop_idx members to simplify make_consistent --- src/clib/make_consistent.cpp | 132 ++++++++++++----------------------- 1 file changed, 46 insertions(+), 86 deletions(-) diff --git a/src/clib/make_consistent.cpp b/src/clib/make_consistent.cpp index cbd4dca47..8d520497e 100644 --- a/src/clib/make_consistent.cpp +++ b/src/clib/make_consistent.cpp @@ -51,12 +51,14 @@ void make_consistent( grackle::impl::View HeIII( my_fields->HeIII_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View d( - my_fields->density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal( - my_fields->metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); + grackle::impl::View d( + const_cast(my_fields->density), + my_fields->grid_dimension[0], my_fields->grid_dimension[1], + my_fields->grid_dimension[2]); + grackle::impl::View metal( + const_cast(my_fields->metal_density), + my_fields->grid_dimension[0], my_fields->grid_dimension[1], + my_fields->grid_dimension[2]); grackle::impl::View HM( my_fields->HM_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); @@ -217,8 +219,11 @@ void make_consistent( int inj_path_idx_start, inj_path_idx_stop; // construct view of each specified injection pathway metal density field - if ((my_chemistry->metal_chemistry > 0) && - (my_chemistry->multi_metals == 1)) { + if (my_chemistry->metal_chemistry > 0) { + // note: when (my_chemistry->multi_metals == 0) a view within + // SN_metal_arr will wrap my_fields->metal_density. In other words, + // that view will be an alias of the `metal` view. This is ok because + // my_fields->metal_density is **NOT** mutated by this function. InjectPathFieldPack p = setup_InjectPathFieldPack(my_chemistry, my_fields); inj_path_idx_start = p.start_idx; @@ -333,84 +338,39 @@ void make_consistent( const grackle::impl::yields::MetalTables& onlygas_metal_yields = inject_pathway_props->gas_metal_nuclide_yields; - if (my_chemistry->multi_metals == 0) { // case with 1 injection pathway - int iSN0 = my_chemistry->metal_abundances; - for (i = my_fields->grid_start[0]; i <= my_fields->grid_end[0]; i++) { - Ct[i] = total_metal_yields.C[iSN0] * metal(i, j, k); - Ot[i] = total_metal_yields.O[iSN0] * metal(i, j, k); - Mgt[i] = total_metal_yields.Mg[iSN0] * metal(i, j, k); - Alt[i] = total_metal_yields.Al[iSN0] * metal(i, j, k); - Sit[i] = total_metal_yields.Si[iSN0] * metal(i, j, k); - St[i] = total_metal_yields.S[iSN0] * metal(i, j, k); - Fet[i] = total_metal_yields.Fe[iSN0] * metal(i, j, k); - - Cg[i] = onlygas_metal_yields.C[iSN0] * metal(i, j, k); - Og[i] = onlygas_metal_yields.O[iSN0] * metal(i, j, k); - Mgg[i] = onlygas_metal_yields.Mg[iSN0] * metal(i, j, k); - Alg[i] = onlygas_metal_yields.Al[iSN0] * metal(i, j, k); - Sig[i] = onlygas_metal_yields.Si[iSN0] * metal(i, j, k); - Sg[i] = onlygas_metal_yields.S[iSN0] * metal(i, j, k); - Feg[i] = onlygas_metal_yields.Fe[iSN0] * metal(i, j, k); - } - - } else { // case with multiple injection pathways - // do i = is+1, ie+1 - // totalZ = metal_loc(i,j,k) - // & + metal_C13(i,j,k) + metal_C20(i,j,k) - // & + metal_C25(i,j,k) + metal_C30(i,j,k) - // & + metal_F13(i,j,k) + metal_F15(i,j,k) - // & + metal_F50(i,j,k) + metal_F80(i,j,k) - // & + metal_P170(i,j,k)+ metal_P200(i,j,k) - // & + metal_Y19(i,j,k) - // correctZ = metal(i,j,k) / totalZ - // metal_loc(i,j,k) = metal_loc(i,j,k) * correctZ - // metal_C13(i,j,k) = metal_C13(i,j,k) * correctZ - // metal_C20(i,j,k) = metal_C20(i,j,k) * correctZ - // metal_C25(i,j,k) = metal_C25(i,j,k) * correctZ - // metal_C30(i,j,k) = metal_C30(i,j,k) * correctZ - // metal_F13(i,j,k) = metal_F13(i,j,k) * correctZ - // metal_F15(i,j,k) = metal_F15(i,j,k) * correctZ - // metal_F50(i,j,k) = metal_F50(i,j,k) * correctZ - // metal_F80(i,j,k) = metal_F80(i,j,k) * correctZ - // metal_P170(i,j,k)= metal_P170(i,j,k)* correctZ - // metal_P200(i,j,k)= metal_P200(i,j,k)* correctZ - // metal_Y19(i,j,k) = metal_Y19(i,j,k) * correctZ - // enddo - - for (i = my_fields->grid_start[0]; i <= my_fields->grid_end[0]; i++) { - Ct[i] = 0.; - Cg[i] = 0.; - Ot[i] = 0.; - Og[i] = 0.; - Mgt[i] = 0.; - Mgg[i] = 0.; - Alt[i] = 0.; - Alg[i] = 0.; - Sit[i] = 0.; - Sig[i] = 0.; - St[i] = 0.; - Sg[i] = 0.; - Fet[i] = 0.; - Feg[i] = 0.; - for (int iSN = inj_path_idx_start; iSN < inj_path_idx_stop; iSN++) { - gr_float cur_val = SN_metal_arr[iSN](i, j, k); - - Ct[i] = Ct[i] + total_metal_yields.C[iSN] * cur_val; - Ot[i] = Ot[i] + total_metal_yields.O[iSN] * cur_val; - Mgt[i] = Mgt[i] + total_metal_yields.Mg[iSN] * cur_val; - Alt[i] = Alt[i] + total_metal_yields.Al[iSN] * cur_val; - Sit[i] = Sit[i] + total_metal_yields.Si[iSN] * cur_val; - St[i] = St[i] + total_metal_yields.S[iSN] * cur_val; - Fet[i] = Fet[i] + total_metal_yields.Fe[iSN] * cur_val; - - Cg[i] = Cg[i] + onlygas_metal_yields.C[iSN] * cur_val; - Og[i] = Og[i] + onlygas_metal_yields.O[iSN] * cur_val; - Mgg[i] = Mgg[i] + onlygas_metal_yields.Mg[iSN] * cur_val; - Alg[i] = Alg[i] + onlygas_metal_yields.Al[iSN] * cur_val; - Sig[i] = Sig[i] + onlygas_metal_yields.Si[iSN] * cur_val; - Sg[i] = Sg[i] + onlygas_metal_yields.S[iSN] * cur_val; - Feg[i] = Feg[i] + onlygas_metal_yields.Fe[iSN] * cur_val; - } + for (i = my_fields->grid_start[0]; i <= my_fields->grid_end[0]; i++) { + Ct[i] = 0.; + Cg[i] = 0.; + Ot[i] = 0.; + Og[i] = 0.; + Mgt[i] = 0.; + Mgg[i] = 0.; + Alt[i] = 0.; + Alg[i] = 0.; + Sit[i] = 0.; + Sig[i] = 0.; + St[i] = 0.; + Sg[i] = 0.; + Fet[i] = 0.; + Feg[i] = 0.; + for (int iSN = inj_path_idx_start; iSN < inj_path_idx_stop; iSN++) { + gr_float cur_val = SN_metal_arr[iSN](i, j, k); + + Ct[i] = Ct[i] + total_metal_yields.C[iSN] * cur_val; + Ot[i] = Ot[i] + total_metal_yields.O[iSN] * cur_val; + Mgt[i] = Mgt[i] + total_metal_yields.Mg[iSN] * cur_val; + Alt[i] = Alt[i] + total_metal_yields.Al[iSN] * cur_val; + Sit[i] = Sit[i] + total_metal_yields.Si[iSN] * cur_val; + St[i] = St[i] + total_metal_yields.S[iSN] * cur_val; + Fet[i] = Fet[i] + total_metal_yields.Fe[iSN] * cur_val; + + Cg[i] = Cg[i] + onlygas_metal_yields.C[iSN] * cur_val; + Og[i] = Og[i] + onlygas_metal_yields.O[iSN] * cur_val; + Mgg[i] = Mgg[i] + onlygas_metal_yields.Mg[iSN] * cur_val; + Alg[i] = Alg[i] + onlygas_metal_yields.Al[iSN] * cur_val; + Sig[i] = Sig[i] + onlygas_metal_yields.Si[iSN] * cur_val; + Sg[i] = Sg[i] + onlygas_metal_yields.S[iSN] * cur_val; + Feg[i] = Feg[i] + onlygas_metal_yields.Fe[iSN] * cur_val; } } From 522b412d8491ae672abd41155e2c218cc16d496f Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 10 Dec 2025 17:48:43 -0500 Subject: [PATCH 071/175] calc_grain_size_increment: replace some array operations with explicit for-loops --- src/clib/calc_grain_size_increment_1d.F | 53 +++++++++++++++++++------ 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/src/clib/calc_grain_size_increment_1d.F b/src/clib/calc_grain_size_increment_1d.F index 89dce70e0..a00bfc7a2 100644 --- a/src/clib/calc_grain_size_increment_1d.F +++ b/src/clib/calc_grain_size_increment_1d.F @@ -141,68 +141,95 @@ subroutine calc_grain_size_increment_1d( if (immulti .eq. 0) then nSN = 1 SN_i(1) = imabund + 1 - SN_metal(:,1) = metal(:,j,k) + + do i = is+1, ie+1 + SN_metal(i,1) = metal(i,j,k) + enddo else nSN = 0 if(maxval(metal_loc(:,j,k) /metal(:,j,k)) .gt. 0.01_DKIND) then nSN = nSN + 1 SN_i(nSN) = 1 - SN_metal(:,nSN) = metal_loc(:,j,k) + do i = is+1, ie+1 + SN_metal(i,nSN) = metal_loc(i,j,k) + enddo endif if(maxval(metal_C13(:,j,k) /metal(:,j,k)) .gt. 0.01_DKIND) then nSN = nSN + 1 SN_i(nSN) = 2 - SN_metal(:,nSN) = metal_C13(:,j,k) + do i = is+1, ie+1 + SN_metal(i,nSN) = metal_C13(i,j,k) + enddo endif if(maxval(metal_C20(:,j,k) /metal(:,j,k)) .gt. 0.01_DKIND) then nSN = nSN + 1 SN_i(nSN) = 3 - SN_metal(:,nSN) = metal_C20(:,j,k) + do i = is+1, ie+1 + SN_metal(i,nSN) = metal_C20(i,j,k) + enddo endif if(maxval(metal_C25(:,j,k) /metal(:,j,k)) .gt. 0.01_DKIND) then nSN = nSN + 1 SN_i(nSN) = 4 - SN_metal(:,nSN) = metal_C25(:,j,k) + do i = is+1, ie+1 + SN_metal(i,nSN) = metal_C25(i,j,k) + enddo endif if(maxval(metal_C30(:,j,k) /metal(:,j,k)) .gt. 0.01_DKIND) then nSN = nSN + 1 SN_i(nSN) = 5 - SN_metal(:,nSN) = metal_C30(:,j,k) + do i = is+1, ie+1 + SN_metal(i,nSN) = metal_C30(i,j,k) + enddo endif if(maxval(metal_F13(:,j,k) /metal(:,j,k)) .gt. 0.01_DKIND) then nSN = nSN + 1 SN_i(nSN) = 6 - SN_metal(:,nSN) = metal_F13(:,j,k) + do i = is+1, ie+1 + SN_metal(i,nSN) = metal_F13(i,j,k) + enddo endif if(maxval(metal_F15(:,j,k) /metal(:,j,k)) .gt. 0.01_DKIND) then nSN = nSN + 1 SN_i(nSN) = 7 - SN_metal(:,nSN) = metal_F15(:,j,k) + do i = is+1, ie+1 + SN_metal(i,nSN) = metal_F15(i,j,k) + enddo endif if(maxval(metal_F50(:,j,k) /metal(:,j,k)) .gt. 0.01_DKIND) then nSN = nSN + 1 SN_i(nSN) = 8 - SN_metal(:,nSN) = metal_F50(:,j,k) + do i = is+1, ie+1 + SN_metal(i,nSN) = metal_F50(i,j,k) + enddo endif if(maxval(metal_F80(:,j,k) /metal(:,j,k)) .gt. 0.01_DKIND) then nSN = nSN + 1 SN_i(nSN) = 9 - SN_metal(:,nSN) = metal_F80(:,j,k) + do i = is+1, ie+1 + SN_metal(i,nSN) = metal_F80(i,j,k) + enddo endif if(maxval(metal_P170(:,j,k)/metal(:,j,k)) .gt. 0.01_DKIND) then nSN = nSN + 1 SN_i(nSN) = 10 - SN_metal(:,nSN) = metal_P170(:,j,k) + do i = is+1, ie+1 + SN_metal(i,nSN) = metal_P170(i,j,k) + enddo endif if(maxval(metal_P200(:,j,k)/metal(:,j,k)) .gt. 0.01_DKIND) then nSN = nSN + 1 SN_i(nSN) = 11 - SN_metal(:,nSN) = metal_P200(:,j,k) + do i = is+1, ie+1 + SN_metal(i,nSN) = metal_P200(i,j,k) + enddo endif if(maxval(metal_Y19(:,j,k) /metal(:,j,k)) .gt. 0.01_DKIND) then nSN = nSN + 1 SN_i(nSN) = 12 - SN_metal(:,nSN) = metal_Y19(:,j,k) + do i = is+1, ie+1 + SN_metal(i,nSN) = metal_Y19(i,j,k) + enddo endif endif From ebc95d557bc75dca39cff3fa115ef439d5229495 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 10 Dec 2025 18:02:15 -0500 Subject: [PATCH 072/175] calc_grain_size_increment: replace some array operations with explicit for-loops PART 2 --- src/clib/calc_grain_size_increment_1d.F | 69 +++++++++++++++---------- 1 file changed, 42 insertions(+), 27 deletions(-) diff --git a/src/clib/calc_grain_size_increment_1d.F b/src/clib/calc_grain_size_increment_1d.F index a00bfc7a2..b0cc17a5e 100644 --- a/src/clib/calc_grain_size_increment_1d.F +++ b/src/clib/calc_grain_size_increment_1d.F @@ -122,7 +122,7 @@ subroutine calc_grain_size_increment_1d( & , SN_kpreforg(gr_Size,SN0_N) & , SN_kpvolorg(gr_Size,SN0_N), SN_kpH2Oice(gr_Size,SN0_N) ! local - integer i + integer i, idx !! integer iTd, iTd0 !! iSN0 = 2 @@ -238,10 +238,15 @@ subroutine calc_grain_size_increment_1d( if ( idspecies .gt. 0 ) then SN_fMgSiO3 (iSN) = SN0_fMgSiO3 (iSN0) SN_fAC (iSN) = SN0_fAC (iSN0) - SN_r0MgSiO3 (:,iSN) = SN0_r0MgSiO3 (:,iSN0) - SN_r0AC (:,iSN) = SN0_r0AC (:,iSN0) - SN_kpMgSiO3 (:,iSN) = SN0_kpMgSiO3 (:,iSN0) - SN_kpAC (:,iSN) = SN0_kpAC (:,iSN0) + + do idx = 1, 3 + SN_r0MgSiO3 (idx,iSN) = SN0_r0MgSiO3 (idx,iSN0) + SN_r0AC (idx,iSN) = SN0_r0AC (idx,iSN0) + enddo + do idx = 1, gr_Size + SN_kpMgSiO3 (idx,iSN) = SN0_kpMgSiO3 (idx,iSN0) + SN_kpAC (idx,iSN) = SN0_kpAC (idx,iSN0) + enddo endif if ( idspecies .gt. 1 ) then SN_fSiM (iSN) = SN0_fSiM (iSN0) @@ -252,33 +257,43 @@ subroutine calc_grain_size_increment_1d( SN_fMgO (iSN) = SN0_fMgO (iSN0) SN_fFeS (iSN) = SN0_fFeS (iSN0) SN_fAl2O3 (iSN) = SN0_fAl2O3 (iSN0) - SN_r0SiM (:,iSN) = SN0_r0SiM (:,iSN0) - SN_r0FeM (:,iSN) = SN0_r0FeM (:,iSN0) - SN_r0Mg2SiO4 (:,iSN) = SN0_r0Mg2SiO4 (:,iSN0) - SN_r0Fe3O4 (:,iSN) = SN0_r0Fe3O4 (:,iSN0) - SN_r0SiO2D (:,iSN) = SN0_r0SiO2D (:,iSN0) - SN_r0MgO (:,iSN) = SN0_r0MgO (:,iSN0) - SN_r0FeS (:,iSN) = SN0_r0FeS (:,iSN0) - SN_r0Al2O3 (:,iSN) = SN0_r0Al2O3 (:,iSN0) - SN_kpSiM (:,iSN) = SN0_kpSiM (:,iSN0) - SN_kpFeM (:,iSN) = SN0_kpFeM (:,iSN0) - SN_kpMg2SiO4 (:,iSN) = SN0_kpMg2SiO4 (:,iSN0) - SN_kpFe3O4 (:,iSN) = SN0_kpFe3O4 (:,iSN0) - SN_kpSiO2D (:,iSN) = SN0_kpSiO2D (:,iSN0) - SN_kpMgO (:,iSN) = SN0_kpMgO (:,iSN0) - SN_kpFeS (:,iSN) = SN0_kpFeS (:,iSN0) - SN_kpAl2O3 (:,iSN) = SN0_kpAl2O3 (:,iSN0) + + do idx = 1, 3 + SN_r0SiM (idx,iSN) = SN0_r0SiM (idx,iSN0) + SN_r0FeM (idx,iSN) = SN0_r0FeM (idx,iSN0) + SN_r0Mg2SiO4 (idx,iSN) = SN0_r0Mg2SiO4 (idx,iSN0) + SN_r0Fe3O4 (idx,iSN) = SN0_r0Fe3O4 (idx,iSN0) + SN_r0SiO2D (idx,iSN) = SN0_r0SiO2D (idx,iSN0) + SN_r0MgO (idx,iSN) = SN0_r0MgO (idx,iSN0) + SN_r0FeS (idx,iSN) = SN0_r0FeS (idx,iSN0) + SN_r0Al2O3 (idx,iSN) = SN0_r0Al2O3 (idx,iSN0) + enddo + do idx = 1, gr_Size + SN_kpSiM (idx,iSN) = SN0_kpSiM (idx,iSN0) + SN_kpFeM (idx,iSN) = SN0_kpFeM (idx,iSN0) + SN_kpMg2SiO4 (idx,iSN) = SN0_kpMg2SiO4 (idx,iSN0) + SN_kpFe3O4 (idx,iSN) = SN0_kpFe3O4 (idx,iSN0) + SN_kpSiO2D (idx,iSN) = SN0_kpSiO2D (idx,iSN0) + SN_kpMgO (idx,iSN) = SN0_kpMgO (idx,iSN0) + SN_kpFeS (idx,iSN) = SN0_kpFeS (idx,iSN0) + SN_kpAl2O3 (idx,iSN) = SN0_kpAl2O3 (idx,iSN0) + enddo endif if ( idspecies .gt. 2 ) then SN_freforg (iSN) = SN0_freforg (iSN0) SN_fvolorg (iSN) = SN0_fvolorg (iSN0) SN_fH2Oice (iSN) = SN0_fH2Oice (iSN0) - SN_r0reforg (:,iSN) = SN0_r0reforg (:,iSN0) - SN_r0volorg (:,iSN) = SN0_r0volorg (:,iSN0) - SN_r0H2Oice (:,iSN) = SN0_r0H2Oice (:,iSN0) - SN_kpreforg (:,iSN) = SN0_kpreforg (:,iSN0) - SN_kpvolorg (:,iSN) = SN0_kpvolorg (:,iSN0) - SN_kpH2Oice (:,iSN) = SN0_kpH2Oice (:,iSN0) + + do idx = 1, 3 + SN_r0reforg (idx,iSN) = SN0_r0reforg (idx,iSN0) + SN_r0volorg (idx,iSN) = SN0_r0volorg (idx,iSN0) + SN_r0H2Oice (idx,iSN) = SN0_r0H2Oice (idx,iSN0) + enddo + do idx = 1, gr_Size + SN_kpreforg (idx,iSN) = SN0_kpreforg (idx,iSN0) + SN_kpvolorg (idx,iSN) = SN0_kpvolorg (idx,iSN0) + SN_kpH2Oice (idx,iSN) = SN0_kpH2Oice (idx,iSN0) + enddo endif enddo From 1c7b5bbb515e2f181938e514c7e81596327ac235 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 10 Dec 2025 18:08:30 -0500 Subject: [PATCH 073/175] calc_grain_size_increment: replace some array operations with explicit for-loops PART 3 --- src/clib/calc_grain_size_increment_1d.F | 44 +++++++++++++------------ 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/src/clib/calc_grain_size_increment_1d.F b/src/clib/calc_grain_size_increment_1d.F index b0cc17a5e..3203d121a 100644 --- a/src/clib/calc_grain_size_increment_1d.F +++ b/src/clib/calc_grain_size_increment_1d.F @@ -447,27 +447,29 @@ subroutine calc_grain_size_increment_1d( & + sgH2Oice (i) endif - if (idspecies .gt. 0) then - altot(:,i) = alMgSiO3 (:,i) - & + alAC (:,i) - endif - if (idspecies .gt. 1) then - altot(:,i) = altot (:,i) - & + alSiM (:,i) - & + alFeM (:,i) - & + alMg2SiO4 (:,i) - & + alFe3O4 (:,i) - & + alSiO2D (:,i) - & + alMgO (:,i) - & + alFeS (:,i) - & + alAl2O3 (:,i) - endif - if (idspecies .gt. 2) then - altot(:,i) = altot (:,i) - & + alreforg (:,i) - & + alvolorg (:,i) - & + alH2Oice (:,i) - endif + do idx = 1, gr_N(2) + if (idspecies .gt. 0) then + altot(idx,i) = alMgSiO3 (idx,i) + & + alAC (idx,i) + endif + if (idspecies .gt. 1) then + altot(idx,i) = altot (idx,i) + & + alSiM (idx,i) + & + alFeM (idx,i) + & + alMg2SiO4 (idx,i) + & + alFe3O4 (idx,i) + & + alSiO2D (idx,i) + & + alMgO (idx,i) + & + alFeS (idx,i) + & + alAl2O3 (idx,i) + endif + if (idspecies .gt. 2) then + altot(idx,i) = altot (idx,i) + & + alreforg (idx,i) + & + alvolorg (idx,i) + & + alH2Oice (idx,i) + endif + enddo endif enddo From 70c13f4aa93e9544ed68445ae49ebc4f2f4f08d1 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 10 Dec 2025 19:06:42 -0500 Subject: [PATCH 074/175] initial commit of transcribed calc_grain_size_increment_1d.hpp --- .../calc_grain_size_increment_1d.hpp | 553 ++++++++++++++++++ src/clib/fortran_func_decls.h | 2 +- src/clib/fortran_func_wrappers.hpp | 10 +- 3 files changed, 563 insertions(+), 2 deletions(-) create mode 100644 src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp diff --git a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp new file mode 100644 index 000000000..d6c2bb245 --- /dev/null +++ b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp @@ -0,0 +1,553 @@ +//===----------------------------------------------------------------------===// +// +// See the LICENSE file for license and copyright information +// SPDX-License-Identifier: NCSA AND BSD-3-Clause +// +//===----------------------------------------------------------------------===// +/// +/// @file +/// Declares signature of calc_grain_size_increment_1d +/// +//===----------------------------------------------------------------------===// + +// This file was initially generated automatically during conversion of the +// calc_grain_size_increment_1d function from FORTRAN to C++ + +#include +#include +#include + +#include "grackle.h" +#include "dust_props.hpp" +#include "fortran_func_decls.h" +#include "index_helper.h" +#include "inject_model/grain_metal_inject_pathways.hpp" +#include "LUT.hpp" +#include "phys_constants.h" +#include "utils-cpp.hpp" + +namespace grackle::impl { + +inline void calc_grain_size_increment_1d( + const gr_mask_type* itmask, double* dom, int* gr_N, int* gr_Size, + const chemistry_data* my_chemistry, grackle_field_data* my_fields, + IndexRange idx_range, + grackle::impl::InternalDustPropBuf internal_dust_prop_buf, + grackle::impl::GrainMetalInjectPathways* inject_pathway_props +) +{ + + grackle::impl::View metal(my_fields->metal_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); + grackle::impl::View metal_loc(my_fields->local_ISM_metal_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); + grackle::impl::View metal_C13(my_fields->ccsn13_metal_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); + grackle::impl::View metal_C20(my_fields->ccsn20_metal_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); + grackle::impl::View metal_C25(my_fields->ccsn25_metal_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); + grackle::impl::View metal_C30(my_fields->ccsn30_metal_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); + grackle::impl::View metal_F13(my_fields->fsn13_metal_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); + grackle::impl::View metal_F15(my_fields->fsn15_metal_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); + grackle::impl::View metal_F50(my_fields->fsn50_metal_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); + grackle::impl::View metal_F80(my_fields->fsn80_metal_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); + grackle::impl::View metal_P170(my_fields->pisn170_metal_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); + grackle::impl::View metal_P200(my_fields->pisn200_metal_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); + grackle::impl::View metal_Y19(my_fields->y19_metal_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); + // table + grackle::impl::View SN0_r0SiM(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::SiM_dust], 3, inject_pathway_props->n_pathways); + grackle::impl::View SN0_r0FeM(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::FeM_dust], 3, inject_pathway_props->n_pathways); + grackle::impl::View SN0_r0Mg2SiO4(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::Mg2SiO4_dust], 3, inject_pathway_props->n_pathways); + grackle::impl::View SN0_r0MgSiO3(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::MgSiO3_dust], 3, inject_pathway_props->n_pathways); + grackle::impl::View SN0_r0Fe3O4(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::Fe3O4_dust], 3, inject_pathway_props->n_pathways); + grackle::impl::View SN0_r0AC(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::AC_dust], 3, inject_pathway_props->n_pathways); + grackle::impl::View SN0_r0SiO2D(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::SiO2_dust], 3, inject_pathway_props->n_pathways); + grackle::impl::View SN0_r0MgO(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::MgO_dust], 3, inject_pathway_props->n_pathways); + grackle::impl::View SN0_r0FeS(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::FeS_dust], 3, inject_pathway_props->n_pathways); + grackle::impl::View SN0_r0Al2O3(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::Al2O3_dust], 3, inject_pathway_props->n_pathways); + grackle::impl::View SN0_r0reforg(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::ref_org_dust], 3, inject_pathway_props->n_pathways); + grackle::impl::View SN0_r0volorg(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::vol_org_dust], 3, inject_pathway_props->n_pathways); + grackle::impl::View SN0_r0H2Oice(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::H2O_ice_dust], 3, inject_pathway_props->n_pathways); + // opacity table + grackle::impl::View SN0_kpSiM(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::SiM_dust], (*gr_Size), inject_pathway_props->n_pathways); + grackle::impl::View SN0_kpFeM(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::FeM_dust], (*gr_Size), inject_pathway_props->n_pathways); + grackle::impl::View SN0_kpMg2SiO4(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Mg2SiO4_dust], (*gr_Size), inject_pathway_props->n_pathways); + grackle::impl::View SN0_kpMgSiO3(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::MgSiO3_dust], (*gr_Size), inject_pathway_props->n_pathways); + grackle::impl::View SN0_kpFe3O4(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Fe3O4_dust], (*gr_Size), inject_pathway_props->n_pathways); + grackle::impl::View SN0_kpAC(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::AC_dust], (*gr_Size), inject_pathway_props->n_pathways); + grackle::impl::View SN0_kpSiO2D(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::SiO2_dust], (*gr_Size), inject_pathway_props->n_pathways); + grackle::impl::View SN0_kpMgO(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::MgO_dust], (*gr_Size), inject_pathway_props->n_pathways); + grackle::impl::View SN0_kpFeS(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::FeS_dust], (*gr_Size), inject_pathway_props->n_pathways); + grackle::impl::View SN0_kpAl2O3(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Al2O3_dust], (*gr_Size), inject_pathway_props->n_pathways); + grackle::impl::View SN0_kpreforg(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::ref_org_dust], (*gr_Size), inject_pathway_props->n_pathways); + grackle::impl::View SN0_kpvolorg(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::vol_org_dust], (*gr_Size), inject_pathway_props->n_pathways); + grackle::impl::View SN0_kpH2Oice(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::H2O_ice_dust], (*gr_Size), inject_pathway_props->n_pathways); + // out + grackle::impl::View alSiM(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::SiM_dust], gr_N[2-1], my_fields->grid_dimension[0]); + grackle::impl::View alFeM(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::FeM_dust], gr_N[2-1], my_fields->grid_dimension[0]); + grackle::impl::View alMg2SiO4(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Mg2SiO4_dust], gr_N[2-1], my_fields->grid_dimension[0]); + grackle::impl::View alMgSiO3(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::MgSiO3_dust], gr_N[2-1], my_fields->grid_dimension[0]); + grackle::impl::View alFe3O4(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Fe3O4_dust], gr_N[2-1], my_fields->grid_dimension[0]); + grackle::impl::View alAC(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::AC_dust], gr_N[2-1], my_fields->grid_dimension[0]); + grackle::impl::View alSiO2D(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::SiO2_dust], gr_N[2-1], my_fields->grid_dimension[0]); + grackle::impl::View alMgO(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::MgO_dust], gr_N[2-1], my_fields->grid_dimension[0]); + grackle::impl::View alFeS(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::FeS_dust], gr_N[2-1], my_fields->grid_dimension[0]); + grackle::impl::View alAl2O3(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Al2O3_dust], gr_N[2-1], my_fields->grid_dimension[0]); + grackle::impl::View alreforg(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::ref_org_dust], gr_N[2-1], my_fields->grid_dimension[0]); + grackle::impl::View alvolorg(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::vol_org_dust], gr_N[2-1], my_fields->grid_dimension[0]); + grackle::impl::View alH2Oice(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::H2O_ice_dust], gr_N[2-1], my_fields->grid_dimension[0]); + grackle::impl::View altot(internal_dust_prop_buf.dyntab_kappa_tot, gr_N[2-1], my_fields->grid_dimension[0]); + // array + int iSN, nSN, iSN0; + std::vector SN_i(inject_pathway_props->n_pathways); + std::vector SN_metal_data_(my_fields->grid_dimension[0] * inject_pathway_props->n_pathways); + grackle::impl::View SN_metal(SN_metal_data_.data(), my_fields->grid_dimension[0], inject_pathway_props->n_pathways); + std::vector SN_fSiM(inject_pathway_props->n_pathways); + std::vector SN_fFeM(inject_pathway_props->n_pathways); + std::vector SN_fMg2SiO4(inject_pathway_props->n_pathways); + std::vector SN_fMgSiO3(inject_pathway_props->n_pathways); + std::vector SN_fFe3O4(inject_pathway_props->n_pathways); + std::vector SN_fAC(inject_pathway_props->n_pathways); + std::vector SN_fSiO2D(inject_pathway_props->n_pathways); + std::vector SN_fMgO(inject_pathway_props->n_pathways); + std::vector SN_fFeS(inject_pathway_props->n_pathways); + std::vector SN_fAl2O3(inject_pathway_props->n_pathways); + std::vector SN_freforg(inject_pathway_props->n_pathways); + std::vector SN_fvolorg(inject_pathway_props->n_pathways); + std::vector SN_fH2Oice(inject_pathway_props->n_pathways); + std::vector SN_r0SiM_data_(3 * inject_pathway_props->n_pathways); + grackle::impl::View SN_r0SiM(SN_r0SiM_data_.data(), 3, inject_pathway_props->n_pathways); + std::vector SN_r0FeM_data_(3 * inject_pathway_props->n_pathways); + grackle::impl::View SN_r0FeM(SN_r0FeM_data_.data(), 3, inject_pathway_props->n_pathways); + std::vector SN_r0Mg2SiO4_data_(3 * inject_pathway_props->n_pathways); + grackle::impl::View SN_r0Mg2SiO4(SN_r0Mg2SiO4_data_.data(), 3, inject_pathway_props->n_pathways); + std::vector SN_r0MgSiO3_data_(3 * inject_pathway_props->n_pathways); + grackle::impl::View SN_r0MgSiO3(SN_r0MgSiO3_data_.data(), 3, inject_pathway_props->n_pathways); + std::vector SN_r0Fe3O4_data_(3 * inject_pathway_props->n_pathways); + grackle::impl::View SN_r0Fe3O4(SN_r0Fe3O4_data_.data(), 3, inject_pathway_props->n_pathways); + std::vector SN_r0AC_data_(3 * inject_pathway_props->n_pathways); + grackle::impl::View SN_r0AC(SN_r0AC_data_.data(), 3, inject_pathway_props->n_pathways); + std::vector SN_r0SiO2D_data_(3 * inject_pathway_props->n_pathways); + grackle::impl::View SN_r0SiO2D(SN_r0SiO2D_data_.data(), 3, inject_pathway_props->n_pathways); + std::vector SN_r0MgO_data_(3 * inject_pathway_props->n_pathways); + grackle::impl::View SN_r0MgO(SN_r0MgO_data_.data(), 3, inject_pathway_props->n_pathways); + std::vector SN_r0FeS_data_(3 * inject_pathway_props->n_pathways); + grackle::impl::View SN_r0FeS(SN_r0FeS_data_.data(), 3, inject_pathway_props->n_pathways); + std::vector SN_r0Al2O3_data_(3 * inject_pathway_props->n_pathways); + grackle::impl::View SN_r0Al2O3(SN_r0Al2O3_data_.data(), 3, inject_pathway_props->n_pathways); + std::vector SN_r0reforg_data_(3 * inject_pathway_props->n_pathways); + grackle::impl::View SN_r0reforg(SN_r0reforg_data_.data(), 3, inject_pathway_props->n_pathways); + std::vector SN_r0volorg_data_(3 * inject_pathway_props->n_pathways); + grackle::impl::View SN_r0volorg(SN_r0volorg_data_.data(), 3, inject_pathway_props->n_pathways); + std::vector SN_r0H2Oice_data_(3 * inject_pathway_props->n_pathways); + grackle::impl::View SN_r0H2Oice(SN_r0H2Oice_data_.data(), 3, inject_pathway_props->n_pathways); + std::vector SN_kpSiM_data_((*gr_Size) * inject_pathway_props->n_pathways); + grackle::impl::View SN_kpSiM(SN_kpSiM_data_.data(), (*gr_Size), inject_pathway_props->n_pathways); + std::vector SN_kpFeM_data_((*gr_Size) * inject_pathway_props->n_pathways); + grackle::impl::View SN_kpFeM(SN_kpFeM_data_.data(), (*gr_Size), inject_pathway_props->n_pathways); + std::vector SN_kpMg2SiO4_data_((*gr_Size) * inject_pathway_props->n_pathways); + grackle::impl::View SN_kpMg2SiO4(SN_kpMg2SiO4_data_.data(), (*gr_Size), inject_pathway_props->n_pathways); + std::vector SN_kpMgSiO3_data_((*gr_Size) * inject_pathway_props->n_pathways); + grackle::impl::View SN_kpMgSiO3(SN_kpMgSiO3_data_.data(), (*gr_Size), inject_pathway_props->n_pathways); + std::vector SN_kpFe3O4_data_((*gr_Size) * inject_pathway_props->n_pathways); + grackle::impl::View SN_kpFe3O4(SN_kpFe3O4_data_.data(), (*gr_Size), inject_pathway_props->n_pathways); + std::vector SN_kpAC_data_((*gr_Size) * inject_pathway_props->n_pathways); + grackle::impl::View SN_kpAC(SN_kpAC_data_.data(), (*gr_Size), inject_pathway_props->n_pathways); + std::vector SN_kpSiO2D_data_((*gr_Size) * inject_pathway_props->n_pathways); + grackle::impl::View SN_kpSiO2D(SN_kpSiO2D_data_.data(), (*gr_Size), inject_pathway_props->n_pathways); + std::vector SN_kpMgO_data_((*gr_Size) * inject_pathway_props->n_pathways); + grackle::impl::View SN_kpMgO(SN_kpMgO_data_.data(), (*gr_Size), inject_pathway_props->n_pathways); + std::vector SN_kpFeS_data_((*gr_Size) * inject_pathway_props->n_pathways); + grackle::impl::View SN_kpFeS(SN_kpFeS_data_.data(), (*gr_Size), inject_pathway_props->n_pathways); + std::vector SN_kpAl2O3_data_((*gr_Size) * inject_pathway_props->n_pathways); + grackle::impl::View SN_kpAl2O3(SN_kpAl2O3_data_.data(), (*gr_Size), inject_pathway_props->n_pathways); + std::vector SN_kpreforg_data_((*gr_Size) * inject_pathway_props->n_pathways); + grackle::impl::View SN_kpreforg(SN_kpreforg_data_.data(), (*gr_Size), inject_pathway_props->n_pathways); + std::vector SN_kpvolorg_data_((*gr_Size) * inject_pathway_props->n_pathways); + grackle::impl::View SN_kpvolorg(SN_kpvolorg_data_.data(), (*gr_Size), inject_pathway_props->n_pathways); + std::vector SN_kpH2Oice_data_((*gr_Size) * inject_pathway_props->n_pathways); + grackle::impl::View SN_kpH2Oice(SN_kpH2Oice_data_.data(), (*gr_Size), inject_pathway_props->n_pathways); + + // this is a stopgap solution + auto max_ratio_fn = [&](grackle::impl::View inj_path_metal_dens) { + gr_float max_ratio = std::numeric_limits::lowest(); + + for (int i = idx_range.i_start; i < idx_range.i_stop; i++) { + gr_float cur_ratio = ( + inj_path_metal_dens(i, idx_range.j, idx_range.k) / + metal(i, idx_range.j, idx_range.k)); + max_ratio = std::fmax(cur_ratio, max_ratio); + } + return static_cast(max_ratio); + }; + + // local + int i, idx; + + + // make arrays + if (my_chemistry->multi_metals == 0) { + nSN = 1; + SN_i[1-1] = my_chemistry->metal_abundances + 1; + + for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { + SN_metal(i-1,1-1) = metal(i-1,idx_range.jp1-1,idx_range.kp1-1); + } + } else { + nSN = 0; + + if(max_ratio_fn(metal_loc) > 0.01) { + nSN = nSN + 1; + SN_i[nSN-1] = 1; + for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { + SN_metal(i-1,nSN-1) = metal_loc(i-1,idx_range.jp1-1,idx_range.kp1-1); + } + } + + if (max_ratio_fn(metal_C13) > 0.01) { + nSN = nSN + 1; + SN_i[nSN-1] = 2; + for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { + SN_metal(i-1,nSN-1) = metal_C13(i-1,idx_range.jp1-1,idx_range.kp1-1); + } + } + + if (max_ratio_fn(metal_C20) > 0.01) { + nSN = nSN + 1; + SN_i[nSN-1] = 3; + for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { + SN_metal(i-1,nSN-1) = metal_C20(i-1,idx_range.jp1-1,idx_range.kp1-1); + } + } + + if (max_ratio_fn(metal_C25) > 0.01) { + nSN = nSN + 1; + SN_i[nSN-1] = 4; + for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { + SN_metal(i-1,nSN-1) = metal_C25(i-1,idx_range.jp1-1,idx_range.kp1-1); + } + } + + if (max_ratio_fn(metal_C30) > 0.01) { + nSN = nSN + 1; + SN_i[nSN-1] = 5; + for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { + SN_metal(i-1,nSN-1) = metal_C30(i-1,idx_range.jp1-1,idx_range.kp1-1); + } + } + + if (max_ratio_fn(metal_F13) > 0.01) { + nSN = nSN + 1; + SN_i[nSN-1] = 6; + for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { + SN_metal(i-1,nSN-1) = metal_F13(i-1,idx_range.jp1-1,idx_range.kp1-1); + } + } + + if (max_ratio_fn(metal_F15) > 0.01) { + nSN = nSN + 1; + SN_i[nSN-1] = 7; + for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { + SN_metal(i-1,nSN-1) = metal_F15(i-1,idx_range.jp1-1,idx_range.kp1-1); + } + } + + if (max_ratio_fn(metal_F50) > 0.01) { + nSN = nSN + 1; + SN_i[nSN-1] = 8; + for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { + SN_metal(i-1,nSN-1) = metal_F50(i-1,idx_range.jp1-1,idx_range.kp1-1); + } + } + + if (max_ratio_fn(metal_F80) > 0.01) { + nSN = nSN + 1; + SN_i[nSN-1] = 9; + for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { + SN_metal(i-1,nSN-1) = metal_F80(i-1,idx_range.jp1-1,idx_range.kp1-1); + } + } + + if (max_ratio_fn(metal_P170) > 0.01) { + nSN = nSN + 1; + SN_i[nSN-1] = 10; + for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { + SN_metal(i-1,nSN-1) = metal_P170(i-1,idx_range.jp1-1,idx_range.kp1-1); + } + } + + if (max_ratio_fn(metal_P200) > 0.01) { + nSN = nSN + 1; + SN_i[nSN-1] = 11; + for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { + SN_metal(i-1,nSN-1) = metal_P200(i-1,idx_range.jp1-1,idx_range.kp1-1); + } + } + + if (max_ratio_fn(metal_Y19) > 0.01) { + nSN = nSN + 1; + SN_i[nSN-1] = 12; + for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { + SN_metal(i-1,nSN-1) = metal_Y19(i-1,idx_range.jp1-1,idx_range.kp1-1); + } + } + } + + for (iSN = 1; iSN<=(nSN); iSN++) { + iSN0 = SN_i[iSN-1]; + if ( my_chemistry->dust_species > 0 ) { + SN_fMgSiO3 [iSN-1] = inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN0-1]; + SN_fAC [iSN-1] = inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust] [iSN0-1]; + + for (idx = 1; idx<=(3); idx++) { + SN_r0MgSiO3 (idx-1,iSN-1) = SN0_r0MgSiO3 (idx-1,iSN0-1); + SN_r0AC (idx-1,iSN-1) = SN0_r0AC (idx-1,iSN0-1); + } + for (idx = 1; idx<=((*gr_Size)); idx++) { + SN_kpMgSiO3 (idx-1,iSN-1) = SN0_kpMgSiO3 (idx-1,iSN0-1); + SN_kpAC (idx-1,iSN-1) = SN0_kpAC (idx-1,iSN0-1); + } + } + if ( my_chemistry->dust_species > 1 ) { + SN_fSiM [iSN-1] = inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust] [iSN0-1]; + SN_fFeM [iSN-1] = inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN0-1]; + SN_fMg2SiO4 [iSN-1] = inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN0-1]; + SN_fFe3O4 [iSN-1] = inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Fe3O4_dust] [iSN0-1]; + SN_fSiO2D [iSN-1] = inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust] [iSN0-1]; + SN_fMgO [iSN-1] = inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgO_dust] [iSN0-1]; + SN_fFeS [iSN-1] = inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeS_dust] [iSN0-1]; + SN_fAl2O3 [iSN-1] = inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Al2O3_dust] [iSN0-1]; + + for (idx = 1; idx<=(3); idx++) { + SN_r0SiM (idx-1,iSN-1) = SN0_r0SiM (idx-1,iSN0-1); + SN_r0FeM (idx-1,iSN-1) = SN0_r0FeM (idx-1,iSN0-1); + SN_r0Mg2SiO4 (idx-1,iSN-1) = SN0_r0Mg2SiO4 (idx-1,iSN0-1); + SN_r0Fe3O4 (idx-1,iSN-1) = SN0_r0Fe3O4 (idx-1,iSN0-1); + SN_r0SiO2D (idx-1,iSN-1) = SN0_r0SiO2D (idx-1,iSN0-1); + SN_r0MgO (idx-1,iSN-1) = SN0_r0MgO (idx-1,iSN0-1); + SN_r0FeS (idx-1,iSN-1) = SN0_r0FeS (idx-1,iSN0-1); + SN_r0Al2O3 (idx-1,iSN-1) = SN0_r0Al2O3 (idx-1,iSN0-1); + } + for (idx = 1; idx<=((*gr_Size)); idx++) { + SN_kpSiM (idx-1,iSN-1) = SN0_kpSiM (idx-1,iSN0-1); + SN_kpFeM (idx-1,iSN-1) = SN0_kpFeM (idx-1,iSN0-1); + SN_kpMg2SiO4 (idx-1,iSN-1) = SN0_kpMg2SiO4 (idx-1,iSN0-1); + SN_kpFe3O4 (idx-1,iSN-1) = SN0_kpFe3O4 (idx-1,iSN0-1); + SN_kpSiO2D (idx-1,iSN-1) = SN0_kpSiO2D (idx-1,iSN0-1); + SN_kpMgO (idx-1,iSN-1) = SN0_kpMgO (idx-1,iSN0-1); + SN_kpFeS (idx-1,iSN-1) = SN0_kpFeS (idx-1,iSN0-1); + SN_kpAl2O3 (idx-1,iSN-1) = SN0_kpAl2O3 (idx-1,iSN0-1); + } + } + if ( my_chemistry->dust_species > 2 ) { + SN_freforg [iSN-1] = inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::ref_org_dust] [iSN0-1]; + SN_fvolorg [iSN-1] = inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::vol_org_dust] [iSN0-1]; + SN_fH2Oice [iSN-1] = inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::H2O_ice_dust] [iSN0-1]; + + for (idx = 1; idx<=(3); idx++) { + SN_r0reforg (idx-1,iSN-1) = SN0_r0reforg (idx-1,iSN0-1); + SN_r0volorg (idx-1,iSN-1) = SN0_r0volorg (idx-1,iSN0-1); + SN_r0H2Oice (idx-1,iSN-1) = SN0_r0H2Oice (idx-1,iSN0-1); + } + for (idx = 1; idx<=((*gr_Size)); idx++) { + SN_kpreforg (idx-1,iSN-1) = SN0_kpreforg (idx-1,iSN0-1); + SN_kpvolorg (idx-1,iSN-1) = SN0_kpvolorg (idx-1,iSN0-1); + SN_kpH2Oice (idx-1,iSN-1) = SN0_kpH2Oice (idx-1,iSN0-1); + } + } + } + + double bulk_densities[OnlyGrainSpLUT::NUM_ENTRIES] = { + sMgSiO3, + sAC, + sSiM, + sFeM, + sMg2SiO4, + sFe3O4, + sSiO2D, + sMgO, + sFeS, + sAl2O3, + sreforg, + svolorg, + sH2Oice, + }; + + + // ! calculate size increment + + if (my_chemistry->dust_species > 0) { + // ! write(*,*) 'MgSiO3' + FORTRAN_NAME(calc_grain_size_increment_species_1d)( + &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, + &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, dom, my_fields->density, + &nSN, my_fields->MgSiO3_dust_density, SN_metal.data(), SN_fMgSiO3.data(), SN_r0MgSiO3.data(), + &bulk_densities[OnlyGrainSpLUT::MgSiO3_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgSiO3_dust], alMgSiO3.data(), + gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpMgSiO3.data() + ); + + // ! write(*,*) 'AC' + FORTRAN_NAME(calc_grain_size_increment_species_1d)( + &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, + &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, dom, my_fields->density, + &nSN, my_fields->AC_dust_density, SN_metal.data(), SN_fAC.data(), SN_r0AC.data(), + &bulk_densities[OnlyGrainSpLUT::AC_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::AC_dust], alAC.data(), + gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpAC.data() + ); + } + + if (my_chemistry->dust_species > 1) { + // ! write(*,*) 'SiM' + FORTRAN_NAME(calc_grain_size_increment_species_1d)( + &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, + &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, dom, my_fields->density, + &nSN, my_fields->SiM_dust_density, SN_metal.data(), SN_fSiM.data(), SN_r0SiM.data(), + &bulk_densities[OnlyGrainSpLUT::SiM_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiM_dust], alSiM.data(), + gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpSiM.data() + ); + + // ! write(*,*) 'FeM' + FORTRAN_NAME(calc_grain_size_increment_species_1d)( + &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, + &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, dom, my_fields->density, + &nSN, my_fields->FeM_dust_density, SN_metal.data(), SN_fFeM.data(), SN_r0FeM.data(), + &bulk_densities[OnlyGrainSpLUT::FeM_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeM_dust], alFeM.data(), + gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpFeM.data() + ); + + // ! write(*,*) 'Mg2SiO4' + FORTRAN_NAME(calc_grain_size_increment_species_1d)( + &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, + &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, dom, my_fields->density, + &nSN, my_fields->Mg2SiO4_dust_density, SN_metal.data(), SN_fMg2SiO4.data(), SN_r0Mg2SiO4.data(), + &bulk_densities[OnlyGrainSpLUT::Mg2SiO4_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Mg2SiO4_dust], alMg2SiO4.data(), + gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpMg2SiO4.data() + ); + + // ! write(*,*) 'Fe3O4' + FORTRAN_NAME(calc_grain_size_increment_species_1d)( + &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, + &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, dom, my_fields->density, + &nSN, my_fields->Fe3O4_dust_density, SN_metal.data(), SN_fFe3O4.data(), SN_r0Fe3O4.data(), + &bulk_densities[OnlyGrainSpLUT::Fe3O4_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Fe3O4_dust], alFe3O4.data(), + gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpFe3O4.data() + ); + + // ! write(*,*) 'SiO2D' + FORTRAN_NAME(calc_grain_size_increment_species_1d)( + &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, + &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, dom, my_fields->density, + &nSN, my_fields->SiO2_dust_density, SN_metal.data(), SN_fSiO2D.data(), SN_r0SiO2D.data(), + &bulk_densities[OnlyGrainSpLUT::SiO2_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiO2_dust], alSiO2D.data(), + gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpSiO2D.data() + ); + + // ! write(*,*) 'MgO' + FORTRAN_NAME(calc_grain_size_increment_species_1d)( + &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, + &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, dom, my_fields->density, + &nSN, my_fields->MgO_dust_density, SN_metal.data(), SN_fMgO.data(), SN_r0MgO.data(), + &bulk_densities[OnlyGrainSpLUT::MgO_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgO_dust], alMgO.data(), + gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpMgO.data() + ); + + // ! write(*,*) 'FeS' + FORTRAN_NAME(calc_grain_size_increment_species_1d)( + &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, + &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, dom, my_fields->density, + &nSN, my_fields->FeS_dust_density, SN_metal.data(), SN_fFeS.data(), SN_r0FeS.data(), + &bulk_densities[OnlyGrainSpLUT::FeS_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeS_dust], alFeS.data(), + gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpFeS.data() + ); + + // ! write(*,*) 'Al2O3' + FORTRAN_NAME(calc_grain_size_increment_species_1d)( + &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, + &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, dom, my_fields->density, + &nSN, my_fields->Al2O3_dust_density, SN_metal.data(), SN_fAl2O3.data(), SN_r0Al2O3.data(), + &bulk_densities[OnlyGrainSpLUT::Al2O3_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Al2O3_dust], alAl2O3.data(), + gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpAl2O3.data() + ); + } + + if (my_chemistry->dust_species > 2) { + // ! write(*,*) 'reforg' + FORTRAN_NAME(calc_grain_size_increment_species_1d)( + &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, + &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, dom, my_fields->density, + &nSN, my_fields->ref_org_dust_density, SN_metal.data(), SN_freforg.data(), SN_r0reforg.data(), + &bulk_densities[OnlyGrainSpLUT::ref_org_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::ref_org_dust], alreforg.data(), + gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpreforg.data() + ); + + // ! write(*,*) 'volorg' + FORTRAN_NAME(calc_grain_size_increment_species_1d)( + &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, + &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, dom, my_fields->density, + &nSN, my_fields->vol_org_dust_density, SN_metal.data(), SN_fvolorg.data(), SN_r0volorg.data(), + &bulk_densities[OnlyGrainSpLUT::vol_org_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::vol_org_dust], alvolorg.data(), + gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpvolorg.data() + ); + + // ! write(*,*) 'H2Oice' + FORTRAN_NAME(calc_grain_size_increment_species_1d)( + &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, + &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, dom, my_fields->density, + &nSN, my_fields->H2O_ice_dust_density, SN_metal.data(), SN_fH2Oice.data(), SN_r0H2Oice.data(), + &bulk_densities[OnlyGrainSpLUT::H2O_ice_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::H2O_ice_dust], alH2Oice.data(), + gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpH2Oice.data() + ); + } + + for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { + if ( itmask[i-1] != MASK_FALSE ) { + + if (my_chemistry->dust_species > 0) { + internal_dust_prop_buf.sigma_per_gas_mass_tot [i-1] = internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgSiO3_dust] [i-1] + + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::AC_dust] [i-1]; + } + if (my_chemistry->dust_species > 1) { + internal_dust_prop_buf.sigma_per_gas_mass_tot [i-1] = internal_dust_prop_buf.sigma_per_gas_mass_tot [i-1] + + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiM_dust] [i-1] + + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeM_dust] [i-1] + + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Mg2SiO4_dust] [i-1] + + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Fe3O4_dust] [i-1] + + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiO2_dust] [i-1] + + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgO_dust] [i-1] + + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeS_dust] [i-1] + + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Al2O3_dust] [i-1]; + } + if (my_chemistry->dust_species > 2) { + internal_dust_prop_buf.sigma_per_gas_mass_tot [i-1] = internal_dust_prop_buf.sigma_per_gas_mass_tot[i-1] + + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::ref_org_dust] [i-1] + + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::vol_org_dust] [i-1] + + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::H2O_ice_dust] [i-1]; + } + + for (idx = 1; idx<=(gr_N [ 2-1 ]); idx++) { + if (my_chemistry->dust_species > 0) { + altot(idx-1,i-1) = alMgSiO3 (idx-1,i-1) + + alAC (idx-1,i-1); + } + if (my_chemistry->dust_species > 1) { + altot(idx-1,i-1) = altot (idx-1,i-1) + + alSiM (idx-1,i-1) + + alFeM (idx-1,i-1) + + alMg2SiO4 (idx-1,i-1) + + alFe3O4 (idx-1,i-1) + + alSiO2D (idx-1,i-1) + + alMgO (idx-1,i-1) + + alFeS (idx-1,i-1) + + alAl2O3 (idx-1,i-1); + } + if (my_chemistry->dust_species > 2) { + altot(idx-1,i-1) = altot (idx-1,i-1) + + alreforg (idx-1,i-1) + + alvolorg (idx-1,i-1) + + alH2Oice (idx-1,i-1); + } + } + + } + } + + return; +} + +} // namespace grackle::impl diff --git a/src/clib/fortran_func_decls.h b/src/clib/fortran_func_decls.h index ff6fd5755..76109e992 100644 --- a/src/clib/fortran_func_decls.h +++ b/src/clib/fortran_func_decls.h @@ -90,7 +90,7 @@ void FORTRAN_NAME(calc_grain_size_increment_1d)( ); void FORTRAN_NAME(calc_grain_size_increment_species_1d)( - int* igrgr, gr_mask_type* itmask, int* SN0_N, int* in, int* jn, int* kn, + const int* igrgr, const gr_mask_type* itmask, int* SN0_N, int* in, int* jn, int* kn, int* is, int* ie, int* j, int* k, double* dom, gr_float* d_data_ptr, int* nSN, gr_float* dsp_data_ptr, gr_float* SN_metal_data_ptr, double* SN_fsp, double* SN_r0sp_data_ptr, double* ssp, double* sgsp, double* alsp_data_ptr, diff --git a/src/clib/fortran_func_wrappers.hpp b/src/clib/fortran_func_wrappers.hpp index bf84c665d..89a583350 100644 --- a/src/clib/fortran_func_wrappers.hpp +++ b/src/clib/fortran_func_wrappers.hpp @@ -22,6 +22,9 @@ #error "This file must be read by a c++ compiler" #endif + +#include "dust/multi_grain_species/calc_grain_size_increment_1d.hpp" + #include "grackle.h" #include "dust_props.hpp" #include "fortran_func_decls.h" @@ -134,7 +137,11 @@ inline void calc_grain_size_increment_1d ( }; int gr_Size = gr_N[0] * gr_N[1]; - + ::grackle::impl::calc_grain_size_increment_1d( + itmask_metal, &dom, gr_N, &gr_Size, my_chemistry, my_fields, idx_range, + internal_dust_prop_buf, inject_pathway_props + ); + /* FORTRAN_NAME(calc_grain_size_increment_1d)( &my_chemistry->multi_metals, &my_chemistry->metal_abundances, &my_chemistry->dust_species, &my_chemistry->grain_growth, itmask_metal, &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, @@ -195,6 +202,7 @@ inline void calc_grain_size_increment_1d ( internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::SiO2_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::MgO_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::FeS_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Al2O3_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::ref_org_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::vol_org_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::H2O_ice_dust], internal_dust_prop_buf.dyntab_kappa_tot ); + */ } inline void calc_temp1d_cloudy_g( From 7b39ac697c9fc96711bb93b8f97b59a698ea124c Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 10 Dec 2025 19:25:34 -0500 Subject: [PATCH 075/175] remove the original fortran version of calc_grain_size_increment_1d --- src/clib/CMakeLists.txt | 1 - src/clib/calc_grain_size_increment_1d.F | 477 ------------------------ src/clib/dust_const.def | 14 - src/clib/fortran_func_decls.h | 42 --- src/clib/fortran_func_wrappers.hpp | 62 --- 5 files changed, 596 deletions(-) delete mode 100644 src/clib/dust_const.def diff --git a/src/clib/CMakeLists.txt b/src/clib/CMakeLists.txt index 5ac458b1d..5ffe057cb 100644 --- a/src/clib/CMakeLists.txt +++ b/src/clib/CMakeLists.txt @@ -181,7 +181,6 @@ add_library(Grackle_Grackle phys_constants.h collisional_rxn_rate_members.def # <-- acts as a C header utils.h - dust_const.def # Fortran public headers ../include/grackle.def diff --git a/src/clib/calc_grain_size_increment_1d.F b/src/clib/calc_grain_size_increment_1d.F index 3203d121a..61c7d2604 100644 --- a/src/clib/calc_grain_size_increment_1d.F +++ b/src/clib/calc_grain_size_increment_1d.F @@ -1,482 +1,5 @@ #include "phys_const.def" -! Compute grain size increment - - subroutine calc_grain_size_increment_1d( - & immulti, imabund, idspecies, igrgr, itmask - & , in, jn, kn, is, ie, j, k, dom, d - & , SiM, FeM, Mg2SiO4, MgSiO3, Fe3O4 - & , AC, SiO2D, MgO, FeS, Al2O3 - & , reforg, volorg, H2Oice - & , metal, metal_loc - & , metal_C13, metal_C20, metal_C25, metal_C30 - & , metal_F13, metal_F15, metal_F50, metal_F80 - & , metal_P170, metal_P200, metal_Y19 - & , SN0_N - & , SN0_fSiM, SN0_fFeM, SN0_fMg2SiO4, SN0_fMgSiO3 - & , SN0_fFe3O4, SN0_fAC, SN0_fSiO2D, SN0_fMgO - & , SN0_fFeS, SN0_fAl2O3 - & , SN0_freforg, SN0_fvolorg, SN0_fH2Oice - & , SN0_r0SiM, SN0_r0FeM, SN0_r0Mg2SiO4, SN0_r0MgSiO3 - & , SN0_r0Fe3O4, SN0_r0AC, SN0_r0SiO2D, SN0_r0MgO - & , SN0_r0FeS, SN0_r0Al2O3 - & , SN0_r0reforg, SN0_r0volorg, SN0_r0H2Oice - & , gr_N, gr_Size, gr_dT, gr_Td - & , SN0_kpSiM, SN0_kpFeM, SN0_kpMg2SiO4, SN0_kpMgSiO3 - & , SN0_kpFe3O4, SN0_kpAC, SN0_kpSiO2D, SN0_kpMgO - & , SN0_kpFeS, SN0_kpAl2O3 - & , SN0_kpreforg, SN0_kpvolorg, SN0_kpH2Oice - & , sgSiM, sgFeM, sgMg2SiO4, sgMgSiO3, sgFe3O4, sgAC - & , sgSiO2D, sgMgO, sgFeS, sgAl2O3 - & , sgreforg, sgvolorg, sgH2Oice, sgtot - & , alSiM, alFeM, alMg2SiO4, alMgSiO3, alFe3O4, alAC - & , alSiO2D, alMgO, alFeS, alAl2O3 - & , alreforg, alvolorg, alH2Oice, altot - & ) - - implicit NONE -#include "grackle_fortran_types.def" -#include "dust_const.def" - -! in - integer in, jn, kn, is, ie, j, k - MASK_TYPE itmask(in) - integer immulti, imabund, idspecies, igrgr - real*8 dom - R_PREC d(in,jn,kn) - R_PREC SiM(in,jn,kn), FeM(in,jn,kn), Mg2SiO4(in,jn,kn) - & , MgSiO3(in,jn,kn), Fe3O4(in,jn,kn), AC(in,jn,kn) - & , SiO2D(in,jn,kn), MgO(in,jn,kn), FeS(in,jn,kn) - & , Al2O3(in,jn,kn) - & , reforg(in,jn,kn), volorg(in,jn,kn), H2Oice(in,jn,kn) - R_PREC metal(in,jn,kn) - & , metal_loc(in,jn,kn) - & , metal_C13(in,jn,kn), metal_C20(in,jn,kn) - & , metal_C25(in,jn,kn), metal_C30(in,jn,kn) - & , metal_F13(in,jn,kn), metal_F15(in,jn,kn) - & , metal_F50(in,jn,kn), metal_F80(in,jn,kn) - & , metal_P170(in,jn,kn), metal_P200(in,jn,kn) - & , metal_Y19(in,jn,kn) -! table - integer SN0_N - real*8 SN0_fSiM(SN0_N), SN0_fFeM(SN0_N), SN0_fMg2SiO4(SN0_N) - & , SN0_fMgSiO3(SN0_N), SN0_fFe3O4(SN0_N), SN0_fAC(SN0_N) - & , SN0_fSiO2D(SN0_N), SN0_fMgO(SN0_N), SN0_fFeS(SN0_N) - & , SN0_fAl2O3(SN0_N) - & , SN0_freforg(SN0_N), SN0_fvolorg(SN0_N), SN0_fH2Oice(SN0_N) - real*8 SN0_r0SiM(3,SN0_N), SN0_r0FeM(3,SN0_N) - & , SN0_r0Mg2SiO4(3,SN0_N), SN0_r0MgSiO3(3,SN0_N) - & , SN0_r0Fe3O4(3,SN0_N), SN0_r0AC(3,SN0_N) - & , SN0_r0SiO2D(3,SN0_N), SN0_r0MgO(3,SN0_N) - & , SN0_r0FeS(3,SN0_N), SN0_r0Al2O3(3,SN0_N) - & , SN0_r0reforg(3,SN0_N) - & , SN0_r0volorg(3,SN0_N), SN0_r0H2Oice(3,SN0_N) -! opacity table - integer gr_N(2), gr_Size - real*8 gr_dT, gr_Td(gr_N(2)) - real*8 SN0_kpSiM(gr_Size,SN0_N), SN0_kpFeM(gr_Size,SN0_N) - & , SN0_kpMg2SiO4(gr_Size,SN0_N), SN0_kpMgSiO3(gr_Size,SN0_N) - & , SN0_kpFe3O4(gr_Size,SN0_N), SN0_kpAC(gr_Size,SN0_N) - & , SN0_kpSiO2D(gr_Size,SN0_N), SN0_kpMgO(gr_Size,SN0_N) - & , SN0_kpFeS(gr_Size,SN0_N), SN0_kpAl2O3(gr_Size,SN0_N) - & , SN0_kpreforg(gr_Size,SN0_N) - & , SN0_kpvolorg(gr_Size,SN0_N), SN0_kpH2Oice(gr_Size,SN0_N) -! out - real*8 sgSiM(in), sgFeM(in), sgMg2SiO4(in) - & , sgMgSiO3(in), sgFe3O4(in), sgAC(in) - & , sgSiO2D(in), sgMgO(in), sgFeS(in) - & , sgAl2O3(in) - & , sgreforg(in), sgvolorg(in), sgH2Oice(in) - & , sgtot(in) - real*8 alSiM(gr_N(2),in), alFeM(gr_N(2),in) - & , alMg2SiO4(gr_N(2),in), alMgSiO3(gr_N(2),in) - & , alFe3O4(gr_N(2),in), alAC(gr_N(2),in) - & , alSiO2D(gr_N(2),in), alMgO(gr_N(2),in) - & , alFeS(gr_N(2),in), alAl2O3(gr_N(2),in) - & , alreforg(gr_N(2),in) - & , alvolorg(gr_N(2),in), alH2Oice(gr_N(2),in) - & , altot(gr_N(2),in) -! array - integer iSN, nSN, iSN0 - integer SN_i(SN0_N) - R_PREC SN_metal(in, SN0_N) - real*8 SN_fSiM(SN0_N), SN_fFeM(SN0_N) - & , SN_fMg2SiO4(SN0_N), SN_fMgSiO3(SN0_N) - & , SN_fFe3O4(SN0_N), SN_fAC(SN0_N) - & , SN_fSiO2D(SN0_N), SN_fMgO(SN0_N) - & , SN_fFeS(SN0_N), SN_fAl2O3(SN0_N) - & , SN_freforg(SN0_N) - & , SN_fvolorg(SN0_N), SN_fH2Oice(SN0_N) - real*8 SN_r0SiM(3,SN0_N), SN_r0FeM(3,SN0_N) - & , SN_r0Mg2SiO4(3,SN0_N), SN_r0MgSiO3(3,SN0_N) - & , SN_r0Fe3O4(3,SN0_N), SN_r0AC(3,SN0_N) - & , SN_r0SiO2D(3,SN0_N), SN_r0MgO(3,SN0_N) - & , SN_r0FeS(3,SN0_N), SN_r0Al2O3(3,SN0_N) - & , SN_r0reforg(3,SN0_N) - & , SN_r0volorg(3,SN0_N), SN_r0H2Oice(3,SN0_N) - real*8 SN_kpSiM(gr_Size,SN0_N), SN_kpFeM(gr_Size,SN0_N) - & , SN_kpMg2SiO4(gr_Size,SN0_N), SN_kpMgSiO3(gr_Size,SN0_N) - & , SN_kpFe3O4(gr_Size,SN0_N), SN_kpAC(gr_Size,SN0_N) - & , SN_kpSiO2D(gr_Size,SN0_N), SN_kpMgO(gr_Size,SN0_N) - & , SN_kpFeS(gr_Size,SN0_N), SN_kpAl2O3(gr_Size,SN0_N) - & , SN_kpreforg(gr_Size,SN0_N) - & , SN_kpvolorg(gr_Size,SN0_N), SN_kpH2Oice(gr_Size,SN0_N) -! local - integer i, idx -!! integer iTd, iTd0 - -!! iSN0 = 2 -!! write(*,*) SN0_fMgSiO3(iSN0) -!! write(*,*) SN0_r0MgSiO3 (:,iSN0) -!! do iTd = 1, gr_N(2) -!! iTd0 = (iTd - 1) * gr_N(1) -!! write(*,*) SN0_kpMgSiO3 (iTd0+1,iSN0) -!! & , SN0_kpMgSiO3 (iTd0+2,iSN0) -!! & , SN0_kpMgSiO3 (iTd0+3,iSN0) -!! & , SN0_kpMgSiO3 (iTd0+4,iSN0) -!! enddo -!! stop - - ! make arrays - if (immulti .eq. 0) then - nSN = 1 - SN_i(1) = imabund + 1 - - do i = is+1, ie+1 - SN_metal(i,1) = metal(i,j,k) - enddo - else - nSN = 0 - if(maxval(metal_loc(:,j,k) /metal(:,j,k)) .gt. 0.01_DKIND) then - nSN = nSN + 1 - SN_i(nSN) = 1 - do i = is+1, ie+1 - SN_metal(i,nSN) = metal_loc(i,j,k) - enddo - endif - if(maxval(metal_C13(:,j,k) /metal(:,j,k)) .gt. 0.01_DKIND) then - nSN = nSN + 1 - SN_i(nSN) = 2 - do i = is+1, ie+1 - SN_metal(i,nSN) = metal_C13(i,j,k) - enddo - endif - if(maxval(metal_C20(:,j,k) /metal(:,j,k)) .gt. 0.01_DKIND) then - nSN = nSN + 1 - SN_i(nSN) = 3 - do i = is+1, ie+1 - SN_metal(i,nSN) = metal_C20(i,j,k) - enddo - endif - if(maxval(metal_C25(:,j,k) /metal(:,j,k)) .gt. 0.01_DKIND) then - nSN = nSN + 1 - SN_i(nSN) = 4 - do i = is+1, ie+1 - SN_metal(i,nSN) = metal_C25(i,j,k) - enddo - endif - if(maxval(metal_C30(:,j,k) /metal(:,j,k)) .gt. 0.01_DKIND) then - nSN = nSN + 1 - SN_i(nSN) = 5 - do i = is+1, ie+1 - SN_metal(i,nSN) = metal_C30(i,j,k) - enddo - endif - if(maxval(metal_F13(:,j,k) /metal(:,j,k)) .gt. 0.01_DKIND) then - nSN = nSN + 1 - SN_i(nSN) = 6 - do i = is+1, ie+1 - SN_metal(i,nSN) = metal_F13(i,j,k) - enddo - endif - if(maxval(metal_F15(:,j,k) /metal(:,j,k)) .gt. 0.01_DKIND) then - nSN = nSN + 1 - SN_i(nSN) = 7 - do i = is+1, ie+1 - SN_metal(i,nSN) = metal_F15(i,j,k) - enddo - endif - if(maxval(metal_F50(:,j,k) /metal(:,j,k)) .gt. 0.01_DKIND) then - nSN = nSN + 1 - SN_i(nSN) = 8 - do i = is+1, ie+1 - SN_metal(i,nSN) = metal_F50(i,j,k) - enddo - endif - if(maxval(metal_F80(:,j,k) /metal(:,j,k)) .gt. 0.01_DKIND) then - nSN = nSN + 1 - SN_i(nSN) = 9 - do i = is+1, ie+1 - SN_metal(i,nSN) = metal_F80(i,j,k) - enddo - endif - if(maxval(metal_P170(:,j,k)/metal(:,j,k)) .gt. 0.01_DKIND) then - nSN = nSN + 1 - SN_i(nSN) = 10 - do i = is+1, ie+1 - SN_metal(i,nSN) = metal_P170(i,j,k) - enddo - endif - if(maxval(metal_P200(:,j,k)/metal(:,j,k)) .gt. 0.01_DKIND) then - nSN = nSN + 1 - SN_i(nSN) = 11 - do i = is+1, ie+1 - SN_metal(i,nSN) = metal_P200(i,j,k) - enddo - endif - if(maxval(metal_Y19(:,j,k) /metal(:,j,k)) .gt. 0.01_DKIND) then - nSN = nSN + 1 - SN_i(nSN) = 12 - do i = is+1, ie+1 - SN_metal(i,nSN) = metal_Y19(i,j,k) - enddo - endif - endif - - do iSN = 1, nSN - iSN0 = SN_i(iSN) - if ( idspecies .gt. 0 ) then - SN_fMgSiO3 (iSN) = SN0_fMgSiO3 (iSN0) - SN_fAC (iSN) = SN0_fAC (iSN0) - - do idx = 1, 3 - SN_r0MgSiO3 (idx,iSN) = SN0_r0MgSiO3 (idx,iSN0) - SN_r0AC (idx,iSN) = SN0_r0AC (idx,iSN0) - enddo - do idx = 1, gr_Size - SN_kpMgSiO3 (idx,iSN) = SN0_kpMgSiO3 (idx,iSN0) - SN_kpAC (idx,iSN) = SN0_kpAC (idx,iSN0) - enddo - endif - if ( idspecies .gt. 1 ) then - SN_fSiM (iSN) = SN0_fSiM (iSN0) - SN_fFeM (iSN) = SN0_fFeM (iSN0) - SN_fMg2SiO4 (iSN) = SN0_fMg2SiO4 (iSN0) - SN_fFe3O4 (iSN) = SN0_fFe3O4 (iSN0) - SN_fSiO2D (iSN) = SN0_fSiO2D (iSN0) - SN_fMgO (iSN) = SN0_fMgO (iSN0) - SN_fFeS (iSN) = SN0_fFeS (iSN0) - SN_fAl2O3 (iSN) = SN0_fAl2O3 (iSN0) - - do idx = 1, 3 - SN_r0SiM (idx,iSN) = SN0_r0SiM (idx,iSN0) - SN_r0FeM (idx,iSN) = SN0_r0FeM (idx,iSN0) - SN_r0Mg2SiO4 (idx,iSN) = SN0_r0Mg2SiO4 (idx,iSN0) - SN_r0Fe3O4 (idx,iSN) = SN0_r0Fe3O4 (idx,iSN0) - SN_r0SiO2D (idx,iSN) = SN0_r0SiO2D (idx,iSN0) - SN_r0MgO (idx,iSN) = SN0_r0MgO (idx,iSN0) - SN_r0FeS (idx,iSN) = SN0_r0FeS (idx,iSN0) - SN_r0Al2O3 (idx,iSN) = SN0_r0Al2O3 (idx,iSN0) - enddo - do idx = 1, gr_Size - SN_kpSiM (idx,iSN) = SN0_kpSiM (idx,iSN0) - SN_kpFeM (idx,iSN) = SN0_kpFeM (idx,iSN0) - SN_kpMg2SiO4 (idx,iSN) = SN0_kpMg2SiO4 (idx,iSN0) - SN_kpFe3O4 (idx,iSN) = SN0_kpFe3O4 (idx,iSN0) - SN_kpSiO2D (idx,iSN) = SN0_kpSiO2D (idx,iSN0) - SN_kpMgO (idx,iSN) = SN0_kpMgO (idx,iSN0) - SN_kpFeS (idx,iSN) = SN0_kpFeS (idx,iSN0) - SN_kpAl2O3 (idx,iSN) = SN0_kpAl2O3 (idx,iSN0) - enddo - endif - if ( idspecies .gt. 2 ) then - SN_freforg (iSN) = SN0_freforg (iSN0) - SN_fvolorg (iSN) = SN0_fvolorg (iSN0) - SN_fH2Oice (iSN) = SN0_fH2Oice (iSN0) - - do idx = 1, 3 - SN_r0reforg (idx,iSN) = SN0_r0reforg (idx,iSN0) - SN_r0volorg (idx,iSN) = SN0_r0volorg (idx,iSN0) - SN_r0H2Oice (idx,iSN) = SN0_r0H2Oice (idx,iSN0) - enddo - do idx = 1, gr_Size - SN_kpreforg (idx,iSN) = SN0_kpreforg (idx,iSN0) - SN_kpvolorg (idx,iSN) = SN0_kpvolorg (idx,iSN0) - SN_kpH2Oice (idx,iSN) = SN0_kpH2Oice (idx,iSN0) - enddo - endif - enddo - - !! calculate size increment - - if (idspecies .gt. 0) then -!! write(*,*) 'MgSiO3' - call calc_grain_size_increment_species_1d( - & igrgr, itmask, SN0_N - & , in, jn, kn, is, ie, j, k, dom, d - & , nSN, MgSiO3 , SN_metal, SN_fMgSiO3 , SN_r0MgSiO3 - & , sMgSiO3 , sgMgSiO3 , alMgSiO3 - & , gr_N, gr_Size, gr_dT, gr_Td, SN_kpMgSiO3 - & ) - -!! write(*,*) 'AC' - call calc_grain_size_increment_species_1d( - & igrgr, itmask, SN0_N - & , in, jn, kn, is, ie, j, k, dom, d - & , nSN, AC , SN_metal, SN_fAC , SN_r0AC - & , sAC , sgAC , alAC - & , gr_N, gr_Size, gr_dT, gr_Td, SN_kpAC - & ) - endif - - if (idspecies .gt. 1) then -!! write(*,*) 'SiM' - call calc_grain_size_increment_species_1d( - & igrgr, itmask, SN0_N - & , in, jn, kn, is, ie, j, k, dom, d - & , nSN, SiM , SN_metal, SN_fSiM , SN_r0SiM - & , sSiM , sgSiM , alSiM - & , gr_N, gr_Size, gr_dT, gr_Td, SN_kpSiM - & ) - -!! write(*,*) 'FeM' - call calc_grain_size_increment_species_1d( - & igrgr, itmask, SN0_N - & , in, jn, kn, is, ie, j, k, dom, d - & , nSN, FeM , SN_metal, SN_fFeM , SN_r0FeM - & , sFeM , sgFeM , alFeM - & , gr_N, gr_Size, gr_dT, gr_Td, SN_kpFeM - & ) - -!! write(*,*) 'Mg2SiO4' - call calc_grain_size_increment_species_1d( - & igrgr, itmask, SN0_N - & , in, jn, kn, is, ie, j, k, dom, d - & , nSN, Mg2SiO4 , SN_metal, SN_fMg2SiO4 , SN_r0Mg2SiO4 - & , sMg2SiO4 , sgMg2SiO4 , alMg2SiO4 - & , gr_N, gr_Size, gr_dT, gr_Td, SN_kpMg2SiO4 - & ) - -!! write(*,*) 'Fe3O4' - call calc_grain_size_increment_species_1d( - & igrgr, itmask, SN0_N - & , in, jn, kn, is, ie, j, k, dom, d - & , nSN, Fe3O4 , SN_metal, SN_fFe3O4 , SN_r0Fe3O4 - & , sFe3O4 , sgFe3O4 , alFe3O4 - & , gr_N, gr_Size, gr_dT, gr_Td, SN_kpFe3O4 - & ) - -!! write(*,*) 'SiO2D' - call calc_grain_size_increment_species_1d( - & igrgr, itmask, SN0_N - & , in, jn, kn, is, ie, j, k, dom, d - & , nSN, SiO2D , SN_metal, SN_fSiO2D , SN_r0SiO2D - & , sSiO2D , sgSiO2D , alSiO2D - & , gr_N, gr_Size, gr_dT, gr_Td, SN_kpSiO2D - & ) - -!! write(*,*) 'MgO' - call calc_grain_size_increment_species_1d( - & igrgr, itmask, SN0_N - & , in, jn, kn, is, ie, j, k, dom, d - & , nSN, MgO , SN_metal, SN_fMgO , SN_r0MgO - & , sMgO , sgMgO , alMgO - & , gr_N, gr_Size, gr_dT, gr_Td, SN_kpMgO - & ) - -!! write(*,*) 'FeS' - call calc_grain_size_increment_species_1d( - & igrgr, itmask, SN0_N - & , in, jn, kn, is, ie, j, k, dom, d - & , nSN, FeS , SN_metal, SN_fFeS , SN_r0FeS - & , sFeS , sgFeS , alFeS - & , gr_N, gr_Size, gr_dT, gr_Td, SN_kpFeS - & ) - -!! write(*,*) 'Al2O3' - call calc_grain_size_increment_species_1d( - & igrgr, itmask, SN0_N - & , in, jn, kn, is, ie, j, k, dom, d - & , nSN, Al2O3 , SN_metal, SN_fAl2O3 , SN_r0Al2O3 - & , sAl2O3 , sgAl2O3 , alAl2O3 - & , gr_N, gr_Size, gr_dT, gr_Td, SN_kpAl2O3 - & ) - endif - - if (idspecies .gt. 2) then -!! write(*,*) 'reforg' - call calc_grain_size_increment_species_1d( - & igrgr, itmask, SN0_N - & , in, jn, kn, is, ie, j, k, dom, d - & , nSN, reforg , SN_metal, SN_freforg , SN_r0reforg - & , sreforg , sgreforg , alreforg - & , gr_N, gr_Size, gr_dT, gr_Td, SN_kpreforg - & ) - -!! write(*,*) 'volorg' - call calc_grain_size_increment_species_1d( - & igrgr, itmask, SN0_N - & , in, jn, kn, is, ie, j, k, dom, d - & , nSN, volorg , SN_metal, SN_fvolorg , SN_r0volorg - & , svolorg , sgvolorg , alvolorg - & , gr_N, gr_Size, gr_dT, gr_Td, SN_kpvolorg - & ) - -!! write(*,*) 'H2Oice' - call calc_grain_size_increment_species_1d( - & igrgr, itmask, SN0_N - & , in, jn, kn, is, ie, j, k, dom, d - & , nSN, H2Oice , SN_metal, SN_fH2Oice , SN_r0H2Oice - & , sH2Oice , sgH2Oice , alH2Oice - & , gr_N, gr_Size, gr_dT, gr_Td, SN_kpH2Oice - & ) - endif - - do i = is+1, ie+1 - if ( itmask(i) .ne. MASK_FALSE ) then - - if (idspecies .gt. 0) then - sgtot (i) = sgMgSiO3 (i) - & + sgAC (i) - endif - if (idspecies .gt. 1) then - sgtot (i) = sgtot (i) - & + sgSiM (i) - & + sgFeM (i) - & + sgMg2SiO4 (i) - & + sgFe3O4 (i) - & + sgSiO2D (i) - & + sgMgO (i) - & + sgFeS (i) - & + sgAl2O3 (i) - endif - if (idspecies .gt. 2) then - sgtot (i) = sgtot(i) - & + sgreforg (i) - & + sgvolorg (i) - & + sgH2Oice (i) - endif - - do idx = 1, gr_N(2) - if (idspecies .gt. 0) then - altot(idx,i) = alMgSiO3 (idx,i) - & + alAC (idx,i) - endif - if (idspecies .gt. 1) then - altot(idx,i) = altot (idx,i) - & + alSiM (idx,i) - & + alFeM (idx,i) - & + alMg2SiO4 (idx,i) - & + alFe3O4 (idx,i) - & + alSiO2D (idx,i) - & + alMgO (idx,i) - & + alFeS (idx,i) - & + alAl2O3 (idx,i) - endif - if (idspecies .gt. 2) then - altot(idx,i) = altot (idx,i) - & + alreforg (idx,i) - & + alvolorg (idx,i) - & + alH2Oice (idx,i) - endif - enddo - - endif - enddo - - return - end - !======================================================================= !////////////// CALC_GRAIN_SIZE_INCREMENT_SPECIES_1D \\\\\\\\\\\\\\\\\\ diff --git a/src/clib/dust_const.def b/src/clib/dust_const.def deleted file mode 100644 index 24fdd2c9a..000000000 --- a/src/clib/dust_const.def +++ /dev/null @@ -1,14 +0,0 @@ - -#define sSiM 2.34118d0 -#define sFeM 7.95995d0 -#define sMg2SiO4 3.22133d0 -#define sMgSiO3 3.20185d0 -#define sFe3O4 5.25096d0 -#define sAC 2.27949d0 -#define sSiO2D 2.66235d0 -#define sMgO 3.58157d0 -#define sFeS 4.87265d0 -#define sAl2O3 4.01610d0 -#define sreforg 1.5d0 -#define svolorg 1.0d0 -#define sH2Oice 0.92d0 diff --git a/src/clib/fortran_func_decls.h b/src/clib/fortran_func_decls.h index 76109e992..099797e2a 100644 --- a/src/clib/fortran_func_decls.h +++ b/src/clib/fortran_func_decls.h @@ -47,48 +47,6 @@ void FORTRAN_NAME(calc_all_tdust_gasgr_1d_g)( double* gasvolorg, double* gasH2Oice ); -void FORTRAN_NAME(calc_grain_size_increment_1d)( - int* immulti, int* imabund, int* idspecies, int* igrgr, - const gr_mask_type* itmask, int* in, int* jn, int* kn, int* is, int* ie, - int* j, int* k, double* dom, gr_float* d_data_ptr, gr_float* SiM_data_ptr, - gr_float* FeM_data_ptr, gr_float* Mg2SiO4_data_ptr, gr_float* MgSiO3_data_ptr, - gr_float* Fe3O4_data_ptr, gr_float* AC_data_ptr, gr_float* SiO2D_data_ptr, - gr_float* MgO_data_ptr, gr_float* FeS_data_ptr, gr_float* Al2O3_data_ptr, - gr_float* reforg_data_ptr, gr_float* volorg_data_ptr, - gr_float* H2Oice_data_ptr, gr_float* metal_data_ptr, - gr_float* metal_loc_data_ptr, gr_float* metal_C13_data_ptr, - gr_float* metal_C20_data_ptr, gr_float* metal_C25_data_ptr, - gr_float* metal_C30_data_ptr, gr_float* metal_F13_data_ptr, - gr_float* metal_F15_data_ptr, gr_float* metal_F50_data_ptr, - gr_float* metal_F80_data_ptr, gr_float* metal_P170_data_ptr, - gr_float* metal_P200_data_ptr, gr_float* metal_Y19_data_ptr, int* SN0_N, - double* SN0_fSiM, double* SN0_fFeM, double* SN0_fMg2SiO4, double* SN0_fMgSiO3, - double* SN0_fFe3O4, double* SN0_fAC, double* SN0_fSiO2D, double* SN0_fMgO, - double* SN0_fFeS, double* SN0_fAl2O3, double* SN0_freforg, - double* SN0_fvolorg, double* SN0_fH2Oice, double* SN0_r0SiM_data_ptr, - double* SN0_r0FeM_data_ptr, double* SN0_r0Mg2SiO4_data_ptr, - double* SN0_r0MgSiO3_data_ptr, double* SN0_r0Fe3O4_data_ptr, - double* SN0_r0AC_data_ptr, double* SN0_r0SiO2D_data_ptr, - double* SN0_r0MgO_data_ptr, double* SN0_r0FeS_data_ptr, - double* SN0_r0Al2O3_data_ptr, double* SN0_r0reforg_data_ptr, - double* SN0_r0volorg_data_ptr, double* SN0_r0H2Oice_data_ptr, int* gr_N, - int* gr_Size, double* gr_dT, double* gr_Td, double* SN0_kpSiM_data_ptr, - double* SN0_kpFeM_data_ptr, double* SN0_kpMg2SiO4_data_ptr, - double* SN0_kpMgSiO3_data_ptr, double* SN0_kpFe3O4_data_ptr, - double* SN0_kpAC_data_ptr, double* SN0_kpSiO2D_data_ptr, - double* SN0_kpMgO_data_ptr, double* SN0_kpFeS_data_ptr, - double* SN0_kpAl2O3_data_ptr, double* SN0_kpreforg_data_ptr, - double* SN0_kpvolorg_data_ptr, double* SN0_kpH2Oice_data_ptr, double* sgSiM, - double* sgFeM, double* sgMg2SiO4, double* sgMgSiO3, double* sgFe3O4, - double* sgAC, double* sgSiO2D, double* sgMgO, double* sgFeS, double* sgAl2O3, - double* sgreforg, double* sgvolorg, double* sgH2Oice, double* sgtot, - double* alSiM_data_ptr, double* alFeM_data_ptr, double* alMg2SiO4_data_ptr, - double* alMgSiO3_data_ptr, double* alFe3O4_data_ptr, double* alAC_data_ptr, - double* alSiO2D_data_ptr, double* alMgO_data_ptr, double* alFeS_data_ptr, - double* alAl2O3_data_ptr, double* alreforg_data_ptr, - double* alvolorg_data_ptr, double* alH2Oice_data_ptr, double* altot_data_ptr -); - void FORTRAN_NAME(calc_grain_size_increment_species_1d)( const int* igrgr, const gr_mask_type* itmask, int* SN0_N, int* in, int* jn, int* kn, int* is, int* ie, int* j, int* k, double* dom, gr_float* d_data_ptr, int* nSN, diff --git a/src/clib/fortran_func_wrappers.hpp b/src/clib/fortran_func_wrappers.hpp index 89a583350..baada879f 100644 --- a/src/clib/fortran_func_wrappers.hpp +++ b/src/clib/fortran_func_wrappers.hpp @@ -141,68 +141,6 @@ inline void calc_grain_size_increment_1d ( itmask_metal, &dom, gr_N, &gr_Size, my_chemistry, my_fields, idx_range, internal_dust_prop_buf, inject_pathway_props ); - /* - FORTRAN_NAME(calc_grain_size_increment_1d)( - &my_chemistry->multi_metals, &my_chemistry->metal_abundances, &my_chemistry->dust_species, &my_chemistry->grain_growth, itmask_metal, - &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, - my_fields->SiM_dust_density, my_fields->FeM_dust_density, my_fields->Mg2SiO4_dust_density, my_fields->MgSiO3_dust_density, my_fields->Fe3O4_dust_density, - my_fields->AC_dust_density, my_fields->SiO2_dust_density, my_fields->MgO_dust_density, my_fields->FeS_dust_density, my_fields->Al2O3_dust_density, - my_fields->ref_org_dust_density, my_fields->vol_org_dust_density, my_fields->H2O_ice_dust_density, - my_fields->metal_density, my_fields->local_ISM_metal_density, - my_fields->ccsn13_metal_density, my_fields->ccsn20_metal_density, my_fields->ccsn25_metal_density, my_fields->ccsn30_metal_density, - my_fields->fsn13_metal_density, my_fields->fsn15_metal_density, my_fields->fsn50_metal_density, my_fields->fsn80_metal_density, - my_fields->pisn170_metal_density, my_fields->pisn200_metal_density, my_fields->y19_metal_density, - &inject_pathway_props->n_pathways, - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust], - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust], - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust], - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust], - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Fe3O4_dust], - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust], - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust], - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgO_dust], - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeS_dust], - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Al2O3_dust], - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::ref_org_dust], - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::vol_org_dust], - inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::H2O_ice_dust], - inject_pathway_props->size_moments.data[OnlyGrainSpLUT::SiM_dust], - inject_pathway_props->size_moments.data[OnlyGrainSpLUT::FeM_dust], - inject_pathway_props->size_moments.data[OnlyGrainSpLUT::Mg2SiO4_dust], - inject_pathway_props->size_moments.data[OnlyGrainSpLUT::MgSiO3_dust], - inject_pathway_props->size_moments.data[OnlyGrainSpLUT::Fe3O4_dust], - inject_pathway_props->size_moments.data[OnlyGrainSpLUT::AC_dust], - inject_pathway_props->size_moments.data[OnlyGrainSpLUT::SiO2_dust], - inject_pathway_props->size_moments.data[OnlyGrainSpLUT::MgO_dust], - inject_pathway_props->size_moments.data[OnlyGrainSpLUT::FeS_dust], - inject_pathway_props->size_moments.data[OnlyGrainSpLUT::Al2O3_dust], - inject_pathway_props->size_moments.data[OnlyGrainSpLUT::ref_org_dust], - inject_pathway_props->size_moments.data[OnlyGrainSpLUT::vol_org_dust], - inject_pathway_props->size_moments.data[OnlyGrainSpLUT::H2O_ice_dust], - gr_N, &gr_Size, - &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], - inject_pathway_props->log10Tdust_interp_props.parameters[0], - inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::SiM_dust], - inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::FeM_dust], - inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Mg2SiO4_dust], - inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::MgSiO3_dust], - inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Fe3O4_dust], - inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::AC_dust], - inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::SiO2_dust], - inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::MgO_dust], - inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::FeS_dust], - inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Al2O3_dust], - inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::ref_org_dust], - inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::vol_org_dust], - inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::H2O_ice_dust], - internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiM_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeM_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Mg2SiO4_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgSiO3_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Fe3O4_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::AC_dust], - internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiO2_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgO_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeS_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Al2O3_dust], - internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::ref_org_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::vol_org_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::H2O_ice_dust], internal_dust_prop_buf.sigma_per_gas_mass_tot, - internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::SiM_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::FeM_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Mg2SiO4_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::MgSiO3_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Fe3O4_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::AC_dust], - internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::SiO2_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::MgO_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::FeS_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Al2O3_dust], - internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::ref_org_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::vol_org_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::H2O_ice_dust], internal_dust_prop_buf.dyntab_kappa_tot - ); - */ } inline void calc_temp1d_cloudy_g( From b97ec42575704d3e84a839f5b0a400ed7180c7b4 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 10 Dec 2025 19:54:34 -0500 Subject: [PATCH 076/175] significantly simplify src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp --- src/clib/CMakeLists.txt | 1 + .../calc_grain_size_increment_1d.hpp | 154 ++++-------------- 2 files changed, 33 insertions(+), 122 deletions(-) diff --git a/src/clib/CMakeLists.txt b/src/clib/CMakeLists.txt index 5ffe057cb..a74c85955 100644 --- a/src/clib/CMakeLists.txt +++ b/src/clib/CMakeLists.txt @@ -113,6 +113,7 @@ add_library(Grackle_Grackle cool_multi_time_g.cpp cool_multi_time_g.h dust_props.hpp dust/grain_species_info.cpp dust/grain_species_info.hpp + dust/multi_grain_species/calc_grain_size_increment_1d.hpp init_misc_species_cool_rates.cpp init_misc_species_cool_rates.hpp initialize_chemistry_data.cpp initialize_rates.cpp initialize_rates.hpp diff --git a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp index d6c2bb245..1c5b12ab8 100644 --- a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp +++ b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp @@ -22,6 +22,7 @@ #include "fortran_func_decls.h" #include "index_helper.h" #include "inject_model/grain_metal_inject_pathways.hpp" +#include "inject_model/inject_path_field_pack.hpp" #include "LUT.hpp" #include "phys_constants.h" #include "utils-cpp.hpp" @@ -37,19 +38,11 @@ inline void calc_grain_size_increment_1d( ) { - grackle::impl::View metal(my_fields->metal_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_loc(my_fields->local_ISM_metal_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_C13(my_fields->ccsn13_metal_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_C20(my_fields->ccsn20_metal_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_C25(my_fields->ccsn25_metal_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_C30(my_fields->ccsn30_metal_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_F13(my_fields->fsn13_metal_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_F15(my_fields->fsn15_metal_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_F50(my_fields->fsn50_metal_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_F80(my_fields->fsn80_metal_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_P170(my_fields->pisn170_metal_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_P200(my_fields->pisn200_metal_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_Y19(my_fields->y19_metal_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); + grackle::impl::View metal( + const_cast(my_fields->metal_density), + my_fields->grid_dimension[0], my_fields->grid_dimension[1], + my_fields->grid_dimension[2]); + // table grackle::impl::View SN0_r0SiM(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::SiM_dust], 3, inject_pathway_props->n_pathways); grackle::impl::View SN0_r0FeM(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::FeM_dust], 3, inject_pathway_props->n_pathways); @@ -94,7 +87,7 @@ inline void calc_grain_size_increment_1d( grackle::impl::View alH2Oice(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::H2O_ice_dust], gr_N[2-1], my_fields->grid_dimension[0]); grackle::impl::View altot(internal_dust_prop_buf.dyntab_kappa_tot, gr_N[2-1], my_fields->grid_dimension[0]); // array - int iSN, nSN, iSN0; + int iSN, iSN0; std::vector SN_i(inject_pathway_props->n_pathways); std::vector SN_metal_data_(my_fields->grid_dimension[0] * inject_pathway_props->n_pathways); grackle::impl::View SN_metal(SN_metal_data_.data(), my_fields->grid_dimension[0], inject_pathway_props->n_pathways); @@ -164,130 +157,47 @@ inline void calc_grain_size_increment_1d( std::vector SN_kpH2Oice_data_((*gr_Size) * inject_pathway_props->n_pathways); grackle::impl::View SN_kpH2Oice(SN_kpH2Oice_data_.data(), (*gr_Size), inject_pathway_props->n_pathways); - // this is a stopgap solution - auto max_ratio_fn = [&](grackle::impl::View inj_path_metal_dens) { - gr_float max_ratio = std::numeric_limits::lowest(); - - for (int i = idx_range.i_start; i < idx_range.i_stop; i++) { - gr_float cur_ratio = ( - inj_path_metal_dens(i, idx_range.j, idx_range.k) / - metal(i, idx_range.j, idx_range.k)); - max_ratio = std::fmax(cur_ratio, max_ratio); - } - return static_cast(max_ratio); - }; - // local int i, idx; + InjectPathFieldPack inject_path_metal_densities = setup_InjectPathFieldPack( + my_chemistry, my_fields); - // make arrays - if (my_chemistry->multi_metals == 0) { - nSN = 1; - SN_i[1-1] = my_chemistry->metal_abundances + 1; - - for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { - SN_metal(i-1,1-1) = metal(i-1,idx_range.jp1-1,idx_range.kp1-1); - } - } else { - nSN = 0; - - if(max_ratio_fn(metal_loc) > 0.01) { - nSN = nSN + 1; - SN_i[nSN-1] = 1; - for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { - SN_metal(i-1,nSN-1) = metal_loc(i-1,idx_range.jp1-1,idx_range.kp1-1); - } - } - - if (max_ratio_fn(metal_C13) > 0.01) { - nSN = nSN + 1; - SN_i[nSN-1] = 2; - for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { - SN_metal(i-1,nSN-1) = metal_C13(i-1,idx_range.jp1-1,idx_range.kp1-1); - } - } - - if (max_ratio_fn(metal_C20) > 0.01) { - nSN = nSN + 1; - SN_i[nSN-1] = 3; - for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { - SN_metal(i-1,nSN-1) = metal_C20(i-1,idx_range.jp1-1,idx_range.kp1-1); - } - } - - if (max_ratio_fn(metal_C25) > 0.01) { - nSN = nSN + 1; - SN_i[nSN-1] = 4; - for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { - SN_metal(i-1,nSN-1) = metal_C25(i-1,idx_range.jp1-1,idx_range.kp1-1); - } - } + int start = inject_path_metal_densities.start_idx; + int stop = inject_path_metal_densities.stop_idx; - if (max_ratio_fn(metal_C30) > 0.01) { - nSN = nSN + 1; - SN_i[nSN-1] = 5; - for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { - SN_metal(i-1,nSN-1) = metal_C30(i-1,idx_range.jp1-1,idx_range.kp1-1); - } - } + // make arrays + int nSN = 0; + for (int count = start; count < stop; count++) { + // when my_chemistry->multi_metals == 0, inj_path_metal_dens wraps + // the same pointer as `metal` - if (max_ratio_fn(metal_F13) > 0.01) { - nSN = nSN + 1; - SN_i[nSN-1] = 6; - for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { - SN_metal(i-1,nSN-1) = metal_F13(i-1,idx_range.jp1-1,idx_range.kp1-1); - } - } + grackle::impl::View inj_path_metal_dens( + inject_path_metal_densities.fields[count], + my_fields->grid_dimension[0], my_fields->grid_dimension[1], + my_fields->grid_dimension[2]); - if (max_ratio_fn(metal_F15) > 0.01) { - nSN = nSN + 1; - SN_i[nSN-1] = 7; - for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { - SN_metal(i-1,nSN-1) = metal_F15(i-1,idx_range.jp1-1,idx_range.kp1-1); - } + // calculate the max ratio between inj_path_metal_dens and metal + gr_float max_ratio = std::numeric_limits::lowest(); + for (int i = idx_range.i_start; i < idx_range.i_stop; i++) { + gr_float cur_ratio = ( + inj_path_metal_dens(i, idx_range.j, idx_range.k) / + metal(i, idx_range.j, idx_range.k)); + max_ratio = std::fmax(cur_ratio, max_ratio); } - if (max_ratio_fn(metal_F50) > 0.01) { - nSN = nSN + 1; - SN_i[nSN-1] = 8; - for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { - SN_metal(i-1,nSN-1) = metal_F50(i-1,idx_range.jp1-1,idx_range.kp1-1); - } - } + if (max_ratio > 0.01) { + nSN++; - if (max_ratio_fn(metal_F80) > 0.01) { - nSN = nSN + 1; - SN_i[nSN-1] = 9; + SN_i[nSN-1] = count + 1; for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { - SN_metal(i-1,nSN-1) = metal_F80(i-1,idx_range.jp1-1,idx_range.kp1-1); + SN_metal(i-1,nSN-1) = inj_path_metal_dens(i-1,idx_range.jp1-1,idx_range.kp1-1); } } + } - if (max_ratio_fn(metal_P170) > 0.01) { - nSN = nSN + 1; - SN_i[nSN-1] = 10; - for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { - SN_metal(i-1,nSN-1) = metal_P170(i-1,idx_range.jp1-1,idx_range.kp1-1); - } - } - if (max_ratio_fn(metal_P200) > 0.01) { - nSN = nSN + 1; - SN_i[nSN-1] = 11; - for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { - SN_metal(i-1,nSN-1) = metal_P200(i-1,idx_range.jp1-1,idx_range.kp1-1); - } - } - if (max_ratio_fn(metal_Y19) > 0.01) { - nSN = nSN + 1; - SN_i[nSN-1] = 12; - for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { - SN_metal(i-1,nSN-1) = metal_Y19(i-1,idx_range.jp1-1,idx_range.kp1-1); - } - } - } for (iSN = 1; iSN<=(nSN); iSN++) { iSN0 = SN_i[iSN-1]; From 5572b101e7baac0e6f7667eae7750cb8aac182f6 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 10 Dec 2025 19:59:55 -0500 Subject: [PATCH 077/175] adjusting interface of calc_grain_size_increment_1d.hpp --- .../calc_grain_size_increment_1d.hpp | 30 +++++++++---------- src/clib/fortran_func_wrappers.hpp | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp index 1c5b12ab8..014bb7c57 100644 --- a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp +++ b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp @@ -30,9 +30,9 @@ namespace grackle::impl { inline void calc_grain_size_increment_1d( - const gr_mask_type* itmask, double* dom, int* gr_N, int* gr_Size, + double dom, IndexRange idx_range, + const gr_mask_type* itmask, int* gr_N, int* gr_Size, const chemistry_data* my_chemistry, grackle_field_data* my_fields, - IndexRange idx_range, grackle::impl::InternalDustPropBuf internal_dust_prop_buf, grackle::impl::GrainMetalInjectPathways* inject_pathway_props ) @@ -286,7 +286,7 @@ inline void calc_grain_size_increment_1d( // ! write(*,*) 'MgSiO3' FORTRAN_NAME(calc_grain_size_increment_species_1d)( &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, - &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, dom, my_fields->density, + &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->MgSiO3_dust_density, SN_metal.data(), SN_fMgSiO3.data(), SN_r0MgSiO3.data(), &bulk_densities[OnlyGrainSpLUT::MgSiO3_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgSiO3_dust], alMgSiO3.data(), gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpMgSiO3.data() @@ -295,7 +295,7 @@ inline void calc_grain_size_increment_1d( // ! write(*,*) 'AC' FORTRAN_NAME(calc_grain_size_increment_species_1d)( &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, - &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, dom, my_fields->density, + &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->AC_dust_density, SN_metal.data(), SN_fAC.data(), SN_r0AC.data(), &bulk_densities[OnlyGrainSpLUT::AC_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::AC_dust], alAC.data(), gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpAC.data() @@ -306,7 +306,7 @@ inline void calc_grain_size_increment_1d( // ! write(*,*) 'SiM' FORTRAN_NAME(calc_grain_size_increment_species_1d)( &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, - &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, dom, my_fields->density, + &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->SiM_dust_density, SN_metal.data(), SN_fSiM.data(), SN_r0SiM.data(), &bulk_densities[OnlyGrainSpLUT::SiM_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiM_dust], alSiM.data(), gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpSiM.data() @@ -315,7 +315,7 @@ inline void calc_grain_size_increment_1d( // ! write(*,*) 'FeM' FORTRAN_NAME(calc_grain_size_increment_species_1d)( &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, - &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, dom, my_fields->density, + &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->FeM_dust_density, SN_metal.data(), SN_fFeM.data(), SN_r0FeM.data(), &bulk_densities[OnlyGrainSpLUT::FeM_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeM_dust], alFeM.data(), gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpFeM.data() @@ -324,7 +324,7 @@ inline void calc_grain_size_increment_1d( // ! write(*,*) 'Mg2SiO4' FORTRAN_NAME(calc_grain_size_increment_species_1d)( &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, - &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, dom, my_fields->density, + &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->Mg2SiO4_dust_density, SN_metal.data(), SN_fMg2SiO4.data(), SN_r0Mg2SiO4.data(), &bulk_densities[OnlyGrainSpLUT::Mg2SiO4_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Mg2SiO4_dust], alMg2SiO4.data(), gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpMg2SiO4.data() @@ -333,7 +333,7 @@ inline void calc_grain_size_increment_1d( // ! write(*,*) 'Fe3O4' FORTRAN_NAME(calc_grain_size_increment_species_1d)( &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, - &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, dom, my_fields->density, + &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->Fe3O4_dust_density, SN_metal.data(), SN_fFe3O4.data(), SN_r0Fe3O4.data(), &bulk_densities[OnlyGrainSpLUT::Fe3O4_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Fe3O4_dust], alFe3O4.data(), gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpFe3O4.data() @@ -342,7 +342,7 @@ inline void calc_grain_size_increment_1d( // ! write(*,*) 'SiO2D' FORTRAN_NAME(calc_grain_size_increment_species_1d)( &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, - &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, dom, my_fields->density, + &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->SiO2_dust_density, SN_metal.data(), SN_fSiO2D.data(), SN_r0SiO2D.data(), &bulk_densities[OnlyGrainSpLUT::SiO2_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiO2_dust], alSiO2D.data(), gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpSiO2D.data() @@ -351,7 +351,7 @@ inline void calc_grain_size_increment_1d( // ! write(*,*) 'MgO' FORTRAN_NAME(calc_grain_size_increment_species_1d)( &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, - &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, dom, my_fields->density, + &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->MgO_dust_density, SN_metal.data(), SN_fMgO.data(), SN_r0MgO.data(), &bulk_densities[OnlyGrainSpLUT::MgO_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgO_dust], alMgO.data(), gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpMgO.data() @@ -360,7 +360,7 @@ inline void calc_grain_size_increment_1d( // ! write(*,*) 'FeS' FORTRAN_NAME(calc_grain_size_increment_species_1d)( &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, - &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, dom, my_fields->density, + &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->FeS_dust_density, SN_metal.data(), SN_fFeS.data(), SN_r0FeS.data(), &bulk_densities[OnlyGrainSpLUT::FeS_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeS_dust], alFeS.data(), gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpFeS.data() @@ -369,7 +369,7 @@ inline void calc_grain_size_increment_1d( // ! write(*,*) 'Al2O3' FORTRAN_NAME(calc_grain_size_increment_species_1d)( &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, - &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, dom, my_fields->density, + &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->Al2O3_dust_density, SN_metal.data(), SN_fAl2O3.data(), SN_r0Al2O3.data(), &bulk_densities[OnlyGrainSpLUT::Al2O3_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Al2O3_dust], alAl2O3.data(), gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpAl2O3.data() @@ -380,7 +380,7 @@ inline void calc_grain_size_increment_1d( // ! write(*,*) 'reforg' FORTRAN_NAME(calc_grain_size_increment_species_1d)( &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, - &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, dom, my_fields->density, + &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->ref_org_dust_density, SN_metal.data(), SN_freforg.data(), SN_r0reforg.data(), &bulk_densities[OnlyGrainSpLUT::ref_org_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::ref_org_dust], alreforg.data(), gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpreforg.data() @@ -389,7 +389,7 @@ inline void calc_grain_size_increment_1d( // ! write(*,*) 'volorg' FORTRAN_NAME(calc_grain_size_increment_species_1d)( &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, - &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, dom, my_fields->density, + &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->vol_org_dust_density, SN_metal.data(), SN_fvolorg.data(), SN_r0volorg.data(), &bulk_densities[OnlyGrainSpLUT::vol_org_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::vol_org_dust], alvolorg.data(), gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpvolorg.data() @@ -398,7 +398,7 @@ inline void calc_grain_size_increment_1d( // ! write(*,*) 'H2Oice' FORTRAN_NAME(calc_grain_size_increment_species_1d)( &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, - &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, dom, my_fields->density, + &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->H2O_ice_dust_density, SN_metal.data(), SN_fH2Oice.data(), SN_r0H2Oice.data(), &bulk_densities[OnlyGrainSpLUT::H2O_ice_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::H2O_ice_dust], alH2Oice.data(), gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpH2Oice.data() diff --git a/src/clib/fortran_func_wrappers.hpp b/src/clib/fortran_func_wrappers.hpp index baada879f..842b916c3 100644 --- a/src/clib/fortran_func_wrappers.hpp +++ b/src/clib/fortran_func_wrappers.hpp @@ -138,7 +138,7 @@ inline void calc_grain_size_increment_1d ( int gr_Size = gr_N[0] * gr_N[1]; ::grackle::impl::calc_grain_size_increment_1d( - itmask_metal, &dom, gr_N, &gr_Size, my_chemistry, my_fields, idx_range, + dom, idx_range, itmask_metal, gr_N, &gr_Size, my_chemistry, my_fields, internal_dust_prop_buf, inject_pathway_props ); } From b12e22e88b82671c5b4729dfe194b165fb4af51d Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 10 Dec 2025 20:04:37 -0500 Subject: [PATCH 078/175] another interface adjustment --- .../calc_grain_size_increment_1d.hpp | 112 +++++++++--------- src/clib/fortran_func_wrappers.hpp | 2 +- 2 files changed, 57 insertions(+), 57 deletions(-) diff --git a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp index 014bb7c57..2c8e81712 100644 --- a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp +++ b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp @@ -31,7 +31,7 @@ namespace grackle::impl { inline void calc_grain_size_increment_1d( double dom, IndexRange idx_range, - const gr_mask_type* itmask, int* gr_N, int* gr_Size, + const gr_mask_type* itmask, int* gr_N, int gr_Size, const chemistry_data* my_chemistry, grackle_field_data* my_fields, grackle::impl::InternalDustPropBuf internal_dust_prop_buf, grackle::impl::GrainMetalInjectPathways* inject_pathway_props @@ -58,19 +58,19 @@ inline void calc_grain_size_increment_1d( grackle::impl::View SN0_r0volorg(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::vol_org_dust], 3, inject_pathway_props->n_pathways); grackle::impl::View SN0_r0H2Oice(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::H2O_ice_dust], 3, inject_pathway_props->n_pathways); // opacity table - grackle::impl::View SN0_kpSiM(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::SiM_dust], (*gr_Size), inject_pathway_props->n_pathways); - grackle::impl::View SN0_kpFeM(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::FeM_dust], (*gr_Size), inject_pathway_props->n_pathways); - grackle::impl::View SN0_kpMg2SiO4(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Mg2SiO4_dust], (*gr_Size), inject_pathway_props->n_pathways); - grackle::impl::View SN0_kpMgSiO3(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::MgSiO3_dust], (*gr_Size), inject_pathway_props->n_pathways); - grackle::impl::View SN0_kpFe3O4(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Fe3O4_dust], (*gr_Size), inject_pathway_props->n_pathways); - grackle::impl::View SN0_kpAC(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::AC_dust], (*gr_Size), inject_pathway_props->n_pathways); - grackle::impl::View SN0_kpSiO2D(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::SiO2_dust], (*gr_Size), inject_pathway_props->n_pathways); - grackle::impl::View SN0_kpMgO(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::MgO_dust], (*gr_Size), inject_pathway_props->n_pathways); - grackle::impl::View SN0_kpFeS(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::FeS_dust], (*gr_Size), inject_pathway_props->n_pathways); - grackle::impl::View SN0_kpAl2O3(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Al2O3_dust], (*gr_Size), inject_pathway_props->n_pathways); - grackle::impl::View SN0_kpreforg(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::ref_org_dust], (*gr_Size), inject_pathway_props->n_pathways); - grackle::impl::View SN0_kpvolorg(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::vol_org_dust], (*gr_Size), inject_pathway_props->n_pathways); - grackle::impl::View SN0_kpH2Oice(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::H2O_ice_dust], (*gr_Size), inject_pathway_props->n_pathways); + grackle::impl::View SN0_kpSiM(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::SiM_dust], gr_Size, inject_pathway_props->n_pathways); + grackle::impl::View SN0_kpFeM(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::FeM_dust], gr_Size, inject_pathway_props->n_pathways); + grackle::impl::View SN0_kpMg2SiO4(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Mg2SiO4_dust], gr_Size, inject_pathway_props->n_pathways); + grackle::impl::View SN0_kpMgSiO3(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::MgSiO3_dust], gr_Size, inject_pathway_props->n_pathways); + grackle::impl::View SN0_kpFe3O4(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Fe3O4_dust], gr_Size, inject_pathway_props->n_pathways); + grackle::impl::View SN0_kpAC(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::AC_dust], gr_Size, inject_pathway_props->n_pathways); + grackle::impl::View SN0_kpSiO2D(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::SiO2_dust], gr_Size, inject_pathway_props->n_pathways); + grackle::impl::View SN0_kpMgO(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::MgO_dust], gr_Size, inject_pathway_props->n_pathways); + grackle::impl::View SN0_kpFeS(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::FeS_dust], gr_Size, inject_pathway_props->n_pathways); + grackle::impl::View SN0_kpAl2O3(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Al2O3_dust], gr_Size, inject_pathway_props->n_pathways); + grackle::impl::View SN0_kpreforg(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::ref_org_dust], gr_Size, inject_pathway_props->n_pathways); + grackle::impl::View SN0_kpvolorg(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::vol_org_dust], gr_Size, inject_pathway_props->n_pathways); + grackle::impl::View SN0_kpH2Oice(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::H2O_ice_dust], gr_Size, inject_pathway_props->n_pathways); // out grackle::impl::View alSiM(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::SiM_dust], gr_N[2-1], my_fields->grid_dimension[0]); grackle::impl::View alFeM(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::FeM_dust], gr_N[2-1], my_fields->grid_dimension[0]); @@ -130,32 +130,32 @@ inline void calc_grain_size_increment_1d( grackle::impl::View SN_r0volorg(SN_r0volorg_data_.data(), 3, inject_pathway_props->n_pathways); std::vector SN_r0H2Oice_data_(3 * inject_pathway_props->n_pathways); grackle::impl::View SN_r0H2Oice(SN_r0H2Oice_data_.data(), 3, inject_pathway_props->n_pathways); - std::vector SN_kpSiM_data_((*gr_Size) * inject_pathway_props->n_pathways); - grackle::impl::View SN_kpSiM(SN_kpSiM_data_.data(), (*gr_Size), inject_pathway_props->n_pathways); - std::vector SN_kpFeM_data_((*gr_Size) * inject_pathway_props->n_pathways); - grackle::impl::View SN_kpFeM(SN_kpFeM_data_.data(), (*gr_Size), inject_pathway_props->n_pathways); - std::vector SN_kpMg2SiO4_data_((*gr_Size) * inject_pathway_props->n_pathways); - grackle::impl::View SN_kpMg2SiO4(SN_kpMg2SiO4_data_.data(), (*gr_Size), inject_pathway_props->n_pathways); - std::vector SN_kpMgSiO3_data_((*gr_Size) * inject_pathway_props->n_pathways); - grackle::impl::View SN_kpMgSiO3(SN_kpMgSiO3_data_.data(), (*gr_Size), inject_pathway_props->n_pathways); - std::vector SN_kpFe3O4_data_((*gr_Size) * inject_pathway_props->n_pathways); - grackle::impl::View SN_kpFe3O4(SN_kpFe3O4_data_.data(), (*gr_Size), inject_pathway_props->n_pathways); - std::vector SN_kpAC_data_((*gr_Size) * inject_pathway_props->n_pathways); - grackle::impl::View SN_kpAC(SN_kpAC_data_.data(), (*gr_Size), inject_pathway_props->n_pathways); - std::vector SN_kpSiO2D_data_((*gr_Size) * inject_pathway_props->n_pathways); - grackle::impl::View SN_kpSiO2D(SN_kpSiO2D_data_.data(), (*gr_Size), inject_pathway_props->n_pathways); - std::vector SN_kpMgO_data_((*gr_Size) * inject_pathway_props->n_pathways); - grackle::impl::View SN_kpMgO(SN_kpMgO_data_.data(), (*gr_Size), inject_pathway_props->n_pathways); - std::vector SN_kpFeS_data_((*gr_Size) * inject_pathway_props->n_pathways); - grackle::impl::View SN_kpFeS(SN_kpFeS_data_.data(), (*gr_Size), inject_pathway_props->n_pathways); - std::vector SN_kpAl2O3_data_((*gr_Size) * inject_pathway_props->n_pathways); - grackle::impl::View SN_kpAl2O3(SN_kpAl2O3_data_.data(), (*gr_Size), inject_pathway_props->n_pathways); - std::vector SN_kpreforg_data_((*gr_Size) * inject_pathway_props->n_pathways); - grackle::impl::View SN_kpreforg(SN_kpreforg_data_.data(), (*gr_Size), inject_pathway_props->n_pathways); - std::vector SN_kpvolorg_data_((*gr_Size) * inject_pathway_props->n_pathways); - grackle::impl::View SN_kpvolorg(SN_kpvolorg_data_.data(), (*gr_Size), inject_pathway_props->n_pathways); - std::vector SN_kpH2Oice_data_((*gr_Size) * inject_pathway_props->n_pathways); - grackle::impl::View SN_kpH2Oice(SN_kpH2Oice_data_.data(), (*gr_Size), inject_pathway_props->n_pathways); + std::vector SN_kpSiM_data_(gr_Size * inject_pathway_props->n_pathways); + grackle::impl::View SN_kpSiM(SN_kpSiM_data_.data(), gr_Size, inject_pathway_props->n_pathways); + std::vector SN_kpFeM_data_(gr_Size * inject_pathway_props->n_pathways); + grackle::impl::View SN_kpFeM(SN_kpFeM_data_.data(), gr_Size, inject_pathway_props->n_pathways); + std::vector SN_kpMg2SiO4_data_(gr_Size * inject_pathway_props->n_pathways); + grackle::impl::View SN_kpMg2SiO4(SN_kpMg2SiO4_data_.data(), gr_Size, inject_pathway_props->n_pathways); + std::vector SN_kpMgSiO3_data_(gr_Size * inject_pathway_props->n_pathways); + grackle::impl::View SN_kpMgSiO3(SN_kpMgSiO3_data_.data(), gr_Size, inject_pathway_props->n_pathways); + std::vector SN_kpFe3O4_data_(gr_Size * inject_pathway_props->n_pathways); + grackle::impl::View SN_kpFe3O4(SN_kpFe3O4_data_.data(), gr_Size, inject_pathway_props->n_pathways); + std::vector SN_kpAC_data_(gr_Size * inject_pathway_props->n_pathways); + grackle::impl::View SN_kpAC(SN_kpAC_data_.data(), gr_Size, inject_pathway_props->n_pathways); + std::vector SN_kpSiO2D_data_(gr_Size * inject_pathway_props->n_pathways); + grackle::impl::View SN_kpSiO2D(SN_kpSiO2D_data_.data(), gr_Size, inject_pathway_props->n_pathways); + std::vector SN_kpMgO_data_(gr_Size * inject_pathway_props->n_pathways); + grackle::impl::View SN_kpMgO(SN_kpMgO_data_.data(), gr_Size, inject_pathway_props->n_pathways); + std::vector SN_kpFeS_data_(gr_Size * inject_pathway_props->n_pathways); + grackle::impl::View SN_kpFeS(SN_kpFeS_data_.data(), gr_Size, inject_pathway_props->n_pathways); + std::vector SN_kpAl2O3_data_(gr_Size * inject_pathway_props->n_pathways); + grackle::impl::View SN_kpAl2O3(SN_kpAl2O3_data_.data(), gr_Size, inject_pathway_props->n_pathways); + std::vector SN_kpreforg_data_(gr_Size * inject_pathway_props->n_pathways); + grackle::impl::View SN_kpreforg(SN_kpreforg_data_.data(), gr_Size, inject_pathway_props->n_pathways); + std::vector SN_kpvolorg_data_(gr_Size * inject_pathway_props->n_pathways); + grackle::impl::View SN_kpvolorg(SN_kpvolorg_data_.data(), gr_Size, inject_pathway_props->n_pathways); + std::vector SN_kpH2Oice_data_(gr_Size * inject_pathway_props->n_pathways); + grackle::impl::View SN_kpH2Oice(SN_kpH2Oice_data_.data(), gr_Size, inject_pathway_props->n_pathways); // local int i, idx; @@ -209,7 +209,7 @@ inline void calc_grain_size_increment_1d( SN_r0MgSiO3 (idx-1,iSN-1) = SN0_r0MgSiO3 (idx-1,iSN0-1); SN_r0AC (idx-1,iSN-1) = SN0_r0AC (idx-1,iSN0-1); } - for (idx = 1; idx<=((*gr_Size)); idx++) { + for (idx = 1; idx<=(gr_Size); idx++) { SN_kpMgSiO3 (idx-1,iSN-1) = SN0_kpMgSiO3 (idx-1,iSN0-1); SN_kpAC (idx-1,iSN-1) = SN0_kpAC (idx-1,iSN0-1); } @@ -234,7 +234,7 @@ inline void calc_grain_size_increment_1d( SN_r0FeS (idx-1,iSN-1) = SN0_r0FeS (idx-1,iSN0-1); SN_r0Al2O3 (idx-1,iSN-1) = SN0_r0Al2O3 (idx-1,iSN0-1); } - for (idx = 1; idx<=((*gr_Size)); idx++) { + for (idx = 1; idx<=(gr_Size); idx++) { SN_kpSiM (idx-1,iSN-1) = SN0_kpSiM (idx-1,iSN0-1); SN_kpFeM (idx-1,iSN-1) = SN0_kpFeM (idx-1,iSN0-1); SN_kpMg2SiO4 (idx-1,iSN-1) = SN0_kpMg2SiO4 (idx-1,iSN0-1); @@ -255,7 +255,7 @@ inline void calc_grain_size_increment_1d( SN_r0volorg (idx-1,iSN-1) = SN0_r0volorg (idx-1,iSN0-1); SN_r0H2Oice (idx-1,iSN-1) = SN0_r0H2Oice (idx-1,iSN0-1); } - for (idx = 1; idx<=((*gr_Size)); idx++) { + for (idx = 1; idx<=(gr_Size); idx++) { SN_kpreforg (idx-1,iSN-1) = SN0_kpreforg (idx-1,iSN0-1); SN_kpvolorg (idx-1,iSN-1) = SN0_kpvolorg (idx-1,iSN0-1); SN_kpH2Oice (idx-1,iSN-1) = SN0_kpH2Oice (idx-1,iSN0-1); @@ -289,7 +289,7 @@ inline void calc_grain_size_increment_1d( &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->MgSiO3_dust_density, SN_metal.data(), SN_fMgSiO3.data(), SN_r0MgSiO3.data(), &bulk_densities[OnlyGrainSpLUT::MgSiO3_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgSiO3_dust], alMgSiO3.data(), - gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpMgSiO3.data() + gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpMgSiO3.data() ); // ! write(*,*) 'AC' @@ -298,7 +298,7 @@ inline void calc_grain_size_increment_1d( &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->AC_dust_density, SN_metal.data(), SN_fAC.data(), SN_r0AC.data(), &bulk_densities[OnlyGrainSpLUT::AC_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::AC_dust], alAC.data(), - gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpAC.data() + gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpAC.data() ); } @@ -309,7 +309,7 @@ inline void calc_grain_size_increment_1d( &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->SiM_dust_density, SN_metal.data(), SN_fSiM.data(), SN_r0SiM.data(), &bulk_densities[OnlyGrainSpLUT::SiM_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiM_dust], alSiM.data(), - gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpSiM.data() + gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpSiM.data() ); // ! write(*,*) 'FeM' @@ -318,7 +318,7 @@ inline void calc_grain_size_increment_1d( &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->FeM_dust_density, SN_metal.data(), SN_fFeM.data(), SN_r0FeM.data(), &bulk_densities[OnlyGrainSpLUT::FeM_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeM_dust], alFeM.data(), - gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpFeM.data() + gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpFeM.data() ); // ! write(*,*) 'Mg2SiO4' @@ -327,7 +327,7 @@ inline void calc_grain_size_increment_1d( &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->Mg2SiO4_dust_density, SN_metal.data(), SN_fMg2SiO4.data(), SN_r0Mg2SiO4.data(), &bulk_densities[OnlyGrainSpLUT::Mg2SiO4_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Mg2SiO4_dust], alMg2SiO4.data(), - gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpMg2SiO4.data() + gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpMg2SiO4.data() ); // ! write(*,*) 'Fe3O4' @@ -336,7 +336,7 @@ inline void calc_grain_size_increment_1d( &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->Fe3O4_dust_density, SN_metal.data(), SN_fFe3O4.data(), SN_r0Fe3O4.data(), &bulk_densities[OnlyGrainSpLUT::Fe3O4_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Fe3O4_dust], alFe3O4.data(), - gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpFe3O4.data() + gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpFe3O4.data() ); // ! write(*,*) 'SiO2D' @@ -345,7 +345,7 @@ inline void calc_grain_size_increment_1d( &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->SiO2_dust_density, SN_metal.data(), SN_fSiO2D.data(), SN_r0SiO2D.data(), &bulk_densities[OnlyGrainSpLUT::SiO2_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiO2_dust], alSiO2D.data(), - gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpSiO2D.data() + gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpSiO2D.data() ); // ! write(*,*) 'MgO' @@ -354,7 +354,7 @@ inline void calc_grain_size_increment_1d( &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->MgO_dust_density, SN_metal.data(), SN_fMgO.data(), SN_r0MgO.data(), &bulk_densities[OnlyGrainSpLUT::MgO_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgO_dust], alMgO.data(), - gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpMgO.data() + gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpMgO.data() ); // ! write(*,*) 'FeS' @@ -363,7 +363,7 @@ inline void calc_grain_size_increment_1d( &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->FeS_dust_density, SN_metal.data(), SN_fFeS.data(), SN_r0FeS.data(), &bulk_densities[OnlyGrainSpLUT::FeS_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeS_dust], alFeS.data(), - gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpFeS.data() + gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpFeS.data() ); // ! write(*,*) 'Al2O3' @@ -372,7 +372,7 @@ inline void calc_grain_size_increment_1d( &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->Al2O3_dust_density, SN_metal.data(), SN_fAl2O3.data(), SN_r0Al2O3.data(), &bulk_densities[OnlyGrainSpLUT::Al2O3_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Al2O3_dust], alAl2O3.data(), - gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpAl2O3.data() + gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpAl2O3.data() ); } @@ -383,7 +383,7 @@ inline void calc_grain_size_increment_1d( &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->ref_org_dust_density, SN_metal.data(), SN_freforg.data(), SN_r0reforg.data(), &bulk_densities[OnlyGrainSpLUT::ref_org_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::ref_org_dust], alreforg.data(), - gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpreforg.data() + gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpreforg.data() ); // ! write(*,*) 'volorg' @@ -392,7 +392,7 @@ inline void calc_grain_size_increment_1d( &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->vol_org_dust_density, SN_metal.data(), SN_fvolorg.data(), SN_r0volorg.data(), &bulk_densities[OnlyGrainSpLUT::vol_org_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::vol_org_dust], alvolorg.data(), - gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpvolorg.data() + gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpvolorg.data() ); // ! write(*,*) 'H2Oice' @@ -401,7 +401,7 @@ inline void calc_grain_size_increment_1d( &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->H2O_ice_dust_density, SN_metal.data(), SN_fH2Oice.data(), SN_r0H2Oice.data(), &bulk_densities[OnlyGrainSpLUT::H2O_ice_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::H2O_ice_dust], alH2Oice.data(), - gr_N, gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpH2Oice.data() + gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpH2Oice.data() ); } diff --git a/src/clib/fortran_func_wrappers.hpp b/src/clib/fortran_func_wrappers.hpp index 842b916c3..d12e6653a 100644 --- a/src/clib/fortran_func_wrappers.hpp +++ b/src/clib/fortran_func_wrappers.hpp @@ -138,7 +138,7 @@ inline void calc_grain_size_increment_1d ( int gr_Size = gr_N[0] * gr_N[1]; ::grackle::impl::calc_grain_size_increment_1d( - dom, idx_range, itmask_metal, gr_N, &gr_Size, my_chemistry, my_fields, + dom, idx_range, itmask_metal, gr_N, gr_Size, my_chemistry, my_fields, internal_dust_prop_buf, inject_pathway_props ); } From d86f7e56e795ecac32aa8af45a239f7f0d3ef677 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 10 Dec 2025 20:07:11 -0500 Subject: [PATCH 079/175] a third interface adjustment --- .../calc_grain_size_increment_1d.hpp | 18 +++++++++++++----- src/clib/fortran_func_wrappers.hpp | 12 +++--------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp index 2c8e81712..70ba33605 100644 --- a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp +++ b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp @@ -30,13 +30,21 @@ namespace grackle::impl { inline void calc_grain_size_increment_1d( - double dom, IndexRange idx_range, - const gr_mask_type* itmask, int* gr_N, int gr_Size, - const chemistry_data* my_chemistry, grackle_field_data* my_fields, - grackle::impl::InternalDustPropBuf internal_dust_prop_buf, - grackle::impl::GrainMetalInjectPathways* inject_pathway_props + double dom, IndexRange idx_range, const gr_mask_type* itmask, + const chemistry_data* my_chemistry, + grackle::impl::GrainMetalInjectPathways* inject_pathway_props, + grackle_field_data* my_fields, + grackle::impl::InternalDustPropBuf internal_dust_prop_buf ) { + // NOTE: gr_N and gr_Size are historical names + // -> they are pretty uninformative and should be changed! + int gr_N[2] = { + inject_pathway_props->n_opac_poly_coef, + static_cast(inject_pathway_props->log10Tdust_interp_props.dimension[0]) + }; + int gr_Size = gr_N[0] * gr_N[1]; + grackle::impl::View metal( const_cast(my_fields->metal_density), diff --git a/src/clib/fortran_func_wrappers.hpp b/src/clib/fortran_func_wrappers.hpp index d12e6653a..63ffe4473 100644 --- a/src/clib/fortran_func_wrappers.hpp +++ b/src/clib/fortran_func_wrappers.hpp @@ -129,17 +129,11 @@ inline void calc_grain_size_increment_1d ( grackle::impl::InternalDustPropBuf internal_dust_prop_buf ) { - // NOTE: gr_N and gr_Size are historical names - // -> they are pretty uninformative and should be changed! - int gr_N[2] = { - inject_pathway_props->n_opac_poly_coef, - static_cast(inject_pathway_props->log10Tdust_interp_props.dimension[0]) - }; - int gr_Size = gr_N[0] * gr_N[1]; ::grackle::impl::calc_grain_size_increment_1d( - dom, idx_range, itmask_metal, gr_N, gr_Size, my_chemistry, my_fields, - internal_dust_prop_buf, inject_pathway_props + dom, idx_range, itmask_metal, + my_chemistry, inject_pathway_props, my_fields, + internal_dust_prop_buf ); } From 43aa1c2698a687e3a9f59f32acb901014fb216ca Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 10 Dec 2025 21:01:11 -0500 Subject: [PATCH 080/175] remove the old wrapper for calc_grain_size_increment_1d.hpp --- src/clib/calc_tdust_3d.cpp | 3 +- src/clib/cool1d_multi_g.cpp | 3 +- .../calc_grain_size_increment_1d.hpp | 38 +++++++++++++++++++ src/clib/fortran_func_wrappers.hpp | 32 ---------------- src/clib/lookup_cool_rates1d.hpp | 3 +- 5 files changed, 44 insertions(+), 35 deletions(-) diff --git a/src/clib/calc_tdust_3d.cpp b/src/clib/calc_tdust_3d.cpp index 27dbc6e54..0d0865b74 100644 --- a/src/clib/calc_tdust_3d.cpp +++ b/src/clib/calc_tdust_3d.cpp @@ -18,6 +18,7 @@ #include "calc_tdust_3d.h" #include "dust_props.hpp" +#include "dust/multi_grain_species/calc_grain_size_increment_1d.hpp" #include "fortran_func_wrappers.hpp" #include "grackle.h" #include "index_helper.h" @@ -164,7 +165,7 @@ void calc_tdust_3d_g( if ( (my_chemistry->use_dust_density_field > 0) && (my_chemistry->dust_species > 0) ) { - f_wrap::calc_grain_size_increment_1d ( + grackle::impl::calc_grain_size_increment_1d ( dom, idx_range, itmask_metal.data(), my_chemistry, my_rates->opaque_storage->inject_pathway_props, my_fields, internal_dust_prop_buf diff --git a/src/clib/cool1d_multi_g.cpp b/src/clib/cool1d_multi_g.cpp index d787ece1a..41c05ee8d 100644 --- a/src/clib/cool1d_multi_g.cpp +++ b/src/clib/cool1d_multi_g.cpp @@ -22,6 +22,7 @@ #include "fortran_func_decls.h" #include "fortran_func_wrappers.hpp" #include "dust_props.hpp" +#include "dust/multi_grain_species/calc_grain_size_increment_1d.hpp" #include "inject_model/grain_metal_inject_pathways.hpp" #include "internal_types.hpp" #include "utils-cpp.hpp" @@ -1104,7 +1105,7 @@ void grackle::impl::cool1d_multi_g( // Compute grain size increment if ((my_chemistry->use_dust_density_field > 0) && (my_chemistry->dust_species > 0)) { - grackle::impl::fortran_wrapper::calc_grain_size_increment_1d( + grackle::impl::calc_grain_size_increment_1d( dom, idx_range, itmask_metal, my_chemistry, my_rates->opaque_storage->inject_pathway_props, my_fields, internal_dust_prop_buf); diff --git a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp index 70ba33605..6c8ce61bc 100644 --- a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp +++ b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp @@ -10,6 +10,9 @@ /// //===----------------------------------------------------------------------===// +#ifndef CALC_GRAIN_SIZE_INCREMENT_1D_HPP +#define CALC_GRAIN_SIZE_INCREMENT_1D_HPP + // This file was initially generated automatically during conversion of the // calc_grain_size_increment_1d function from FORTRAN to C++ @@ -29,6 +32,38 @@ namespace grackle::impl { +/// For each grain species, compute quantities pertaining to the size +/// distribution along the specified index range. +/// +/// In slightly more detail, our model assumes that the a grain species's +/// current differential size distribution is the weighted sum of the +/// initial differential size distributions from each of the injection +/// pathways that is translated by a value known as the "size increment." +/// Internally, this function computes the size increment based on the amount +/// of amount of mass that has been transferred to the grain species (compared +/// to the initial injected amount) via grain growth. For context, if there +/// hasn't been growth, the size increment is zero. +/// +/// This function computes the size increment as an intermediate quantity. +/// Then, it uses that information to compute +/// - the current cross-section +/// - a 1D table of opacity-related values (for various possible dust +/// Temperatures). +/// +/// @todo +/// Consider writing some narrative documentation about the detailed model of +/// the multi-grain species dust model and revising this docstring so that its +/// less dense (and points the reader to the narrative docs for more details) +/// +/// @param[in] dom a standard quantity used throughout the codebase +/// @param[in] idx_range Specifies the current index-range +/// @param[in] itmask_metal Specifies the `idx_range`'s iteration-mask +/// @param[in] my_chemistry holds a number of configuration parameters +/// @param[in] inject_pathway_props holds data about the modelled injection +/// pathways for all of the grain species. +/// @param[in] my_fields specifies the field data +/// @param[in,out] internal_dust_prop_buf Holds dust-specific information that +/// gets updated by this function inline void calc_grain_size_increment_1d( double dom, IndexRange idx_range, const gr_mask_type* itmask, const chemistry_data* my_chemistry, @@ -469,3 +504,6 @@ inline void calc_grain_size_increment_1d( } } // namespace grackle::impl + + +#endif // CALC_GRAIN_SIZE_INCREMENT_1D_HPP diff --git a/src/clib/fortran_func_wrappers.hpp b/src/clib/fortran_func_wrappers.hpp index 63ffe4473..0a25cd27c 100644 --- a/src/clib/fortran_func_wrappers.hpp +++ b/src/clib/fortran_func_wrappers.hpp @@ -105,38 +105,6 @@ inline void calc_all_tdust_gasgr_1d_g( } -/// Compute grain size increment -/// -/// @note -/// The description could obviously be improved! My general sense is that we -/// are computing dust-properties in each zone. Among other things, this -/// computes size and precomputes the dust opacity table -/// -/// @param[in] dom a standard quantity used throughout the codebase -/// @param[in] idx_range Specifies the current index-range -/// @param[in] itmask_metal Specifies the `idx_range`'s iteration-mask -/// @param[in] my_chemistry holds a number of configuration parameters -/// @param[in] inject_pathway_props holds data about the modelled injection -/// pathways for all of the grain species. -/// @param[in] my_fields specifies the field data -/// @param[in,out] internal_dust_prop_buf Holds dust-specific information that -/// gets updated by this function -inline void calc_grain_size_increment_1d ( - double dom, IndexRange idx_range, const gr_mask_type* itmask_metal, - chemistry_data* my_chemistry, - grackle::impl::GrainMetalInjectPathways* inject_pathway_props, - grackle_field_data* my_fields, - grackle::impl::InternalDustPropBuf internal_dust_prop_buf -) { - - - ::grackle::impl::calc_grain_size_increment_1d( - dom, idx_range, itmask_metal, - my_chemistry, inject_pathway_props, my_fields, - internal_dust_prop_buf - ); -} - inline void calc_temp1d_cloudy_g( double* rhoH, IndexRange idx_range, double* tgas, double* mmw, double dom, double zr, int imetal, cloudy_data cloudy_primordial, gr_mask_type* itmask, diff --git a/src/clib/lookup_cool_rates1d.hpp b/src/clib/lookup_cool_rates1d.hpp index fb041799f..9c015da76 100644 --- a/src/clib/lookup_cool_rates1d.hpp +++ b/src/clib/lookup_cool_rates1d.hpp @@ -21,6 +21,7 @@ #include "grackle.h" #include "dust_props.hpp" #include "dust/grain_species_info.hpp" +#include "dust/multi_grain_species/calc_grain_size_increment_1d.hpp" #include "fortran_func_decls.h" #include "fortran_func_wrappers.hpp" #include "internal_types.hpp" @@ -809,7 +810,7 @@ inline void lookup_cool_rates1d( // Compute grain size increment if ((anydust != MASK_FALSE) && (my_chemistry->dust_species > 0)) { - f_wrap::calc_grain_size_increment_1d( + calc_grain_size_increment_1d( dom, idx_range, itmask_metal, my_chemistry, my_rates->opaque_storage->inject_pathway_props, my_fields, internal_dust_prop_scratch_buf); From 35aebcff895cfebf34cb9bd2d7217f57573ae645 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 10 Dec 2025 21:19:14 -0500 Subject: [PATCH 081/175] replace constants with GrainSpeciesInfoEntry::bulk_density_cgs --- src/clib/calc_tdust_3d.cpp | 1 + src/clib/cool1d_multi_g.cpp | 5 +-- .../calc_grain_size_increment_1d.hpp | 26 +++++---------- src/clib/fortran_func_decls.h | 4 +-- src/clib/lookup_cool_rates1d.hpp | 5 +-- src/clib/phys_constants.h | 32 ------------------- 6 files changed, 17 insertions(+), 56 deletions(-) diff --git a/src/clib/calc_tdust_3d.cpp b/src/clib/calc_tdust_3d.cpp index 0d0865b74..2035b424d 100644 --- a/src/clib/calc_tdust_3d.cpp +++ b/src/clib/calc_tdust_3d.cpp @@ -167,6 +167,7 @@ void calc_tdust_3d_g( grackle::impl::calc_grain_size_increment_1d ( dom, idx_range, itmask_metal.data(), my_chemistry, + my_rates->opaque_storage->grain_species_info, my_rates->opaque_storage->inject_pathway_props, my_fields, internal_dust_prop_buf ); diff --git a/src/clib/cool1d_multi_g.cpp b/src/clib/cool1d_multi_g.cpp index 41c05ee8d..d3d10bc83 100644 --- a/src/clib/cool1d_multi_g.cpp +++ b/src/clib/cool1d_multi_g.cpp @@ -1107,8 +1107,9 @@ void grackle::impl::cool1d_multi_g( (my_chemistry->dust_species > 0)) { grackle::impl::calc_grain_size_increment_1d( dom, idx_range, itmask_metal, my_chemistry, - my_rates->opaque_storage->inject_pathway_props, my_fields, - internal_dust_prop_buf); + my_rates->opaque_storage->grain_species_info, + my_rates->opaque_storage->inject_pathway_props, + my_fields, internal_dust_prop_buf); } // Calculate dust to gas ratio AND interstellar radiation field diff --git a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp index 6c8ce61bc..e43860156 100644 --- a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp +++ b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp @@ -22,12 +22,12 @@ #include "grackle.h" #include "dust_props.hpp" +#include "dust/grain_species_info.hpp" #include "fortran_func_decls.h" #include "index_helper.h" #include "inject_model/grain_metal_inject_pathways.hpp" #include "inject_model/inject_path_field_pack.hpp" #include "LUT.hpp" -#include "phys_constants.h" #include "utils-cpp.hpp" namespace grackle::impl { @@ -59,6 +59,7 @@ namespace grackle::impl { /// @param[in] idx_range Specifies the current index-range /// @param[in] itmask_metal Specifies the `idx_range`'s iteration-mask /// @param[in] my_chemistry holds a number of configuration parameters +/// @param[in] grain_species_info holds information about each grain species /// @param[in] inject_pathway_props holds data about the modelled injection /// pathways for all of the grain species. /// @param[in] my_fields specifies the field data @@ -67,7 +68,8 @@ namespace grackle::impl { inline void calc_grain_size_increment_1d( double dom, IndexRange idx_range, const gr_mask_type* itmask, const chemistry_data* my_chemistry, - grackle::impl::GrainMetalInjectPathways* inject_pathway_props, + const GrainSpeciesInfo* grain_species_info, + const GrainMetalInjectPathways* inject_pathway_props, grackle_field_data* my_fields, grackle::impl::InternalDustPropBuf internal_dust_prop_buf ) @@ -306,22 +308,10 @@ inline void calc_grain_size_increment_1d( } } - double bulk_densities[OnlyGrainSpLUT::NUM_ENTRIES] = { - sMgSiO3, - sAC, - sSiM, - sFeM, - sMg2SiO4, - sFe3O4, - sSiO2D, - sMgO, - sFeS, - sAl2O3, - sreforg, - svolorg, - sH2Oice, - }; - + double bulk_densities[OnlyGrainSpLUT::NUM_ENTRIES]; + for (int grsp_i = 0; grsp_i < grain_species_info->n_species; grsp_i++) { + bulk_densities[grsp_i] = grain_species_info->species_info[grsp_i].bulk_density_cgs; + } // ! calculate size increment diff --git a/src/clib/fortran_func_decls.h b/src/clib/fortran_func_decls.h index 099797e2a..4c0a14e87 100644 --- a/src/clib/fortran_func_decls.h +++ b/src/clib/fortran_func_decls.h @@ -48,11 +48,11 @@ void FORTRAN_NAME(calc_all_tdust_gasgr_1d_g)( ); void FORTRAN_NAME(calc_grain_size_increment_species_1d)( - const int* igrgr, const gr_mask_type* itmask, int* SN0_N, int* in, int* jn, int* kn, + const int* igrgr, const gr_mask_type* itmask, const int* SN0_N, int* in, int* jn, int* kn, int* is, int* ie, int* j, int* k, double* dom, gr_float* d_data_ptr, int* nSN, gr_float* dsp_data_ptr, gr_float* SN_metal_data_ptr, double* SN_fsp, double* SN_r0sp_data_ptr, double* ssp, double* sgsp, double* alsp_data_ptr, - int* gr_N, int* gr_Size, double* gr_dT, double* gr_Td, + const int* gr_N, const int* gr_Size, const double* gr_dT, const double* gr_Td, double* SN_kp0sp_data_ptr ); diff --git a/src/clib/lookup_cool_rates1d.hpp b/src/clib/lookup_cool_rates1d.hpp index 9c015da76..3f4b20028 100644 --- a/src/clib/lookup_cool_rates1d.hpp +++ b/src/clib/lookup_cool_rates1d.hpp @@ -812,8 +812,9 @@ inline void lookup_cool_rates1d( if ((anydust != MASK_FALSE) && (my_chemistry->dust_species > 0)) { calc_grain_size_increment_1d( dom, idx_range, itmask_metal, my_chemistry, - my_rates->opaque_storage->inject_pathway_props, my_fields, - internal_dust_prop_scratch_buf); + my_rates->opaque_storage->grain_species_info, + my_rates->opaque_storage->inject_pathway_props, + my_fields, internal_dust_prop_scratch_buf); } // Look-up rate for H2 formation on dust & (when relevant) grain growth rates diff --git a/src/clib/phys_constants.h b/src/clib/phys_constants.h index 5121d314e..918a52f90 100644 --- a/src/clib/phys_constants.h +++ b/src/clib/phys_constants.h @@ -109,36 +109,4 @@ #define ev2erg_grflt GRFLOAT_C(1.60217653e-12) #define sigma_sb_grflt GRFLOAT_C(5.670373e-5) -/************************************************/ - -/* dust constants (taken from dust_const.def) */ - -/************************************************/ - -/* TODO: After we finish transcribe calc_grain_size_increment_1d to C++, we - * should remove these constants and instead use the values stored by - * `GrainSpeciesInfoEntry::bulk_density_cgs` - * -> to be clear, the values within GrainSpeciesInfoEntry::bulk_density_cgs - * are hardcoded based on the values currently held by these constants. - */ - -// these constants are give the intrinsic density of an individual grain for -// each grain species in units of g/cm^3. -// - Equation A1 of Chiaki & Wise 2019 represents these quantities using the -// zeta_i variable. Equation 2 of Chiaki+15 denotes the variable as s_i - -#define sSiM 2.34118e0 -#define sFeM 7.95995e0 -#define sMg2SiO4 3.22133e0 -#define sMgSiO3 3.20185e0 -#define sFe3O4 5.25096e0 -#define sAC 2.27949e0 -#define sSiO2D 2.66235e0 -#define sMgO 3.58157e0 -#define sFeS 4.87265e0 -#define sAl2O3 4.01610e0 -#define sreforg 1.5e0 -#define svolorg 1.0e0 -#define sH2Oice 0.92e0 - #endif From 6bbcda781a4230ee4ef63ce256f23cb644c0966e Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 10 Dec 2025 22:09:46 -0500 Subject: [PATCH 082/175] grain_size_incr: a step towards aggregating allocations --- .../calc_grain_size_increment_1d.hpp | 94 +++++++++++++------ 1 file changed, 63 insertions(+), 31 deletions(-) diff --git a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp index e43860156..b3ff9fb90 100644 --- a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp +++ b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp @@ -74,12 +74,14 @@ inline void calc_grain_size_increment_1d( grackle::impl::InternalDustPropBuf internal_dust_prop_buf ) { + const int n_pathways = inject_pathway_props->n_pathways; + const int n_log10Tdust_vals = static_cast( + inject_pathway_props->log10Tdust_interp_props.dimension[0]); + const int n_opac_poly_coef = inject_pathway_props->n_opac_poly_coef; + // NOTE: gr_N and gr_Size are historical names // -> they are pretty uninformative and should be changed! - int gr_N[2] = { - inject_pathway_props->n_opac_poly_coef, - static_cast(inject_pathway_props->log10Tdust_interp_props.dimension[0]) - }; + int gr_N[2] = {n_opac_poly_coef, n_log10Tdust_vals}; int gr_Size = gr_N[0] * gr_N[1]; @@ -136,19 +138,23 @@ inline void calc_grain_size_increment_1d( std::vector SN_i(inject_pathway_props->n_pathways); std::vector SN_metal_data_(my_fields->grid_dimension[0] * inject_pathway_props->n_pathways); grackle::impl::View SN_metal(SN_metal_data_.data(), my_fields->grid_dimension[0], inject_pathway_props->n_pathways); - std::vector SN_fSiM(inject_pathway_props->n_pathways); - std::vector SN_fFeM(inject_pathway_props->n_pathways); - std::vector SN_fMg2SiO4(inject_pathway_props->n_pathways); - std::vector SN_fMgSiO3(inject_pathway_props->n_pathways); - std::vector SN_fFe3O4(inject_pathway_props->n_pathways); - std::vector SN_fAC(inject_pathway_props->n_pathways); - std::vector SN_fSiO2D(inject_pathway_props->n_pathways); - std::vector SN_fMgO(inject_pathway_props->n_pathways); - std::vector SN_fFeS(inject_pathway_props->n_pathways); - std::vector SN_fAl2O3(inject_pathway_props->n_pathways); - std::vector SN_freforg(inject_pathway_props->n_pathways); - std::vector SN_fvolorg(inject_pathway_props->n_pathways); - std::vector SN_fH2Oice(inject_pathway_props->n_pathways); + + GrainMetalInjectPathways reduced_inject_paths = new_GrainMetalInjectPathways( + n_pathways, n_log10Tdust_vals, n_opac_poly_coef); + + double* SN_fSiM = reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::SiM_dust]; + double* SN_fFeM = reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::FeM_dust]; + double* SN_fMg2SiO4 = reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust]; + double* SN_fMgSiO3 = reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust]; + double* SN_fFe3O4 = reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::Fe3O4_dust]; + double* SN_fAC = reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::AC_dust]; + double* SN_fSiO2D = reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::SiO2_dust]; + double* SN_fMgO = reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::MgO_dust]; + double* SN_fFeS = reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::FeS_dust]; + double* SN_fAl2O3 = reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::Al2O3_dust]; + double* SN_freforg = reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::ref_org_dust]; + double* SN_fvolorg = reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::vol_org_dust]; + double* SN_fH2Oice = reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::H2O_ice_dust]; std::vector SN_r0SiM_data_(3 * inject_pathway_props->n_pathways); grackle::impl::View SN_r0SiM(SN_r0SiM_data_.data(), 3, inject_pathway_props->n_pathways); std::vector SN_r0FeM_data_(3 * inject_pathway_props->n_pathways); @@ -320,7 +326,9 @@ inline void calc_grain_size_increment_1d( FORTRAN_NAME(calc_grain_size_increment_species_1d)( &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, - &nSN, my_fields->MgSiO3_dust_density, SN_metal.data(), SN_fMgSiO3.data(), SN_r0MgSiO3.data(), + &nSN, my_fields->MgSiO3_dust_density, SN_metal.data(), + reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust], + SN_r0MgSiO3.data(), &bulk_densities[OnlyGrainSpLUT::MgSiO3_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgSiO3_dust], alMgSiO3.data(), gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpMgSiO3.data() ); @@ -329,7 +337,9 @@ inline void calc_grain_size_increment_1d( FORTRAN_NAME(calc_grain_size_increment_species_1d)( &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, - &nSN, my_fields->AC_dust_density, SN_metal.data(), SN_fAC.data(), SN_r0AC.data(), + &nSN, my_fields->AC_dust_density, SN_metal.data(), + reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::AC_dust], + SN_r0AC.data(), &bulk_densities[OnlyGrainSpLUT::AC_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::AC_dust], alAC.data(), gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpAC.data() ); @@ -340,7 +350,9 @@ inline void calc_grain_size_increment_1d( FORTRAN_NAME(calc_grain_size_increment_species_1d)( &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, - &nSN, my_fields->SiM_dust_density, SN_metal.data(), SN_fSiM.data(), SN_r0SiM.data(), + &nSN, my_fields->SiM_dust_density, SN_metal.data(), + reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::SiM_dust], + SN_r0SiM.data(), &bulk_densities[OnlyGrainSpLUT::SiM_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiM_dust], alSiM.data(), gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpSiM.data() ); @@ -349,7 +361,9 @@ inline void calc_grain_size_increment_1d( FORTRAN_NAME(calc_grain_size_increment_species_1d)( &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, - &nSN, my_fields->FeM_dust_density, SN_metal.data(), SN_fFeM.data(), SN_r0FeM.data(), + &nSN, my_fields->FeM_dust_density, SN_metal.data(), + reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::FeM_dust], + SN_r0FeM.data(), &bulk_densities[OnlyGrainSpLUT::FeM_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeM_dust], alFeM.data(), gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpFeM.data() ); @@ -358,7 +372,9 @@ inline void calc_grain_size_increment_1d( FORTRAN_NAME(calc_grain_size_increment_species_1d)( &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, - &nSN, my_fields->Mg2SiO4_dust_density, SN_metal.data(), SN_fMg2SiO4.data(), SN_r0Mg2SiO4.data(), + &nSN, my_fields->Mg2SiO4_dust_density, SN_metal.data(), + reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust], + SN_r0Mg2SiO4.data(), &bulk_densities[OnlyGrainSpLUT::Mg2SiO4_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Mg2SiO4_dust], alMg2SiO4.data(), gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpMg2SiO4.data() ); @@ -367,7 +383,9 @@ inline void calc_grain_size_increment_1d( FORTRAN_NAME(calc_grain_size_increment_species_1d)( &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, - &nSN, my_fields->Fe3O4_dust_density, SN_metal.data(), SN_fFe3O4.data(), SN_r0Fe3O4.data(), + &nSN, my_fields->Fe3O4_dust_density, SN_metal.data(), + reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::Fe3O4_dust], + SN_r0Fe3O4.data(), &bulk_densities[OnlyGrainSpLUT::Fe3O4_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Fe3O4_dust], alFe3O4.data(), gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpFe3O4.data() ); @@ -376,7 +394,9 @@ inline void calc_grain_size_increment_1d( FORTRAN_NAME(calc_grain_size_increment_species_1d)( &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, - &nSN, my_fields->SiO2_dust_density, SN_metal.data(), SN_fSiO2D.data(), SN_r0SiO2D.data(), + &nSN, my_fields->SiO2_dust_density, SN_metal.data(), + reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::SiO2_dust], + SN_r0SiO2D.data(), &bulk_densities[OnlyGrainSpLUT::SiO2_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiO2_dust], alSiO2D.data(), gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpSiO2D.data() ); @@ -385,7 +405,9 @@ inline void calc_grain_size_increment_1d( FORTRAN_NAME(calc_grain_size_increment_species_1d)( &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, - &nSN, my_fields->MgO_dust_density, SN_metal.data(), SN_fMgO.data(), SN_r0MgO.data(), + &nSN, my_fields->MgO_dust_density, SN_metal.data(), + reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::MgO_dust], + SN_r0MgO.data(), &bulk_densities[OnlyGrainSpLUT::MgO_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgO_dust], alMgO.data(), gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpMgO.data() ); @@ -394,7 +416,9 @@ inline void calc_grain_size_increment_1d( FORTRAN_NAME(calc_grain_size_increment_species_1d)( &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, - &nSN, my_fields->FeS_dust_density, SN_metal.data(), SN_fFeS.data(), SN_r0FeS.data(), + &nSN, my_fields->FeS_dust_density, SN_metal.data(), + reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::FeS_dust], + SN_r0FeS.data(), &bulk_densities[OnlyGrainSpLUT::FeS_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeS_dust], alFeS.data(), gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpFeS.data() ); @@ -403,7 +427,9 @@ inline void calc_grain_size_increment_1d( FORTRAN_NAME(calc_grain_size_increment_species_1d)( &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, - &nSN, my_fields->Al2O3_dust_density, SN_metal.data(), SN_fAl2O3.data(), SN_r0Al2O3.data(), + &nSN, my_fields->Al2O3_dust_density, SN_metal.data(), + reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::Al2O3_dust], + SN_r0Al2O3.data(), &bulk_densities[OnlyGrainSpLUT::Al2O3_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Al2O3_dust], alAl2O3.data(), gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpAl2O3.data() ); @@ -414,7 +440,9 @@ inline void calc_grain_size_increment_1d( FORTRAN_NAME(calc_grain_size_increment_species_1d)( &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, - &nSN, my_fields->ref_org_dust_density, SN_metal.data(), SN_freforg.data(), SN_r0reforg.data(), + &nSN, my_fields->ref_org_dust_density, SN_metal.data(), + reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::ref_org_dust], + SN_r0reforg.data(), &bulk_densities[OnlyGrainSpLUT::ref_org_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::ref_org_dust], alreforg.data(), gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpreforg.data() ); @@ -423,7 +451,9 @@ inline void calc_grain_size_increment_1d( FORTRAN_NAME(calc_grain_size_increment_species_1d)( &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, - &nSN, my_fields->vol_org_dust_density, SN_metal.data(), SN_fvolorg.data(), SN_r0volorg.data(), + &nSN, my_fields->vol_org_dust_density, SN_metal.data(), + reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::vol_org_dust], + SN_r0volorg.data(), &bulk_densities[OnlyGrainSpLUT::vol_org_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::vol_org_dust], alvolorg.data(), gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpvolorg.data() ); @@ -432,7 +462,9 @@ inline void calc_grain_size_increment_1d( FORTRAN_NAME(calc_grain_size_increment_species_1d)( &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, - &nSN, my_fields->H2O_ice_dust_density, SN_metal.data(), SN_fH2Oice.data(), SN_r0H2Oice.data(), + &nSN, my_fields->H2O_ice_dust_density, SN_metal.data(), + reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::H2O_ice_dust], + SN_r0H2Oice.data(), &bulk_densities[OnlyGrainSpLUT::H2O_ice_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::H2O_ice_dust], alH2Oice.data(), gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpH2Oice.data() ); @@ -490,7 +522,7 @@ inline void calc_grain_size_increment_1d( } } - return; + drop_GrainMetalInjectPathways(&reduced_inject_paths); } } // namespace grackle::impl From db4bb63d98a829fb1746a702c82f9db9b7ced9f4 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 10 Dec 2025 22:20:06 -0500 Subject: [PATCH 083/175] grain_size_incr: another step towards aggregating allocations --- .../calc_grain_size_increment_1d.hpp | 65 ++++++++----------- 1 file changed, 26 insertions(+), 39 deletions(-) diff --git a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp index b3ff9fb90..45c08a17b 100644 --- a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp +++ b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp @@ -155,32 +155,19 @@ inline void calc_grain_size_increment_1d( double* SN_freforg = reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::ref_org_dust]; double* SN_fvolorg = reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::vol_org_dust]; double* SN_fH2Oice = reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::H2O_ice_dust]; - std::vector SN_r0SiM_data_(3 * inject_pathway_props->n_pathways); - grackle::impl::View SN_r0SiM(SN_r0SiM_data_.data(), 3, inject_pathway_props->n_pathways); - std::vector SN_r0FeM_data_(3 * inject_pathway_props->n_pathways); - grackle::impl::View SN_r0FeM(SN_r0FeM_data_.data(), 3, inject_pathway_props->n_pathways); - std::vector SN_r0Mg2SiO4_data_(3 * inject_pathway_props->n_pathways); - grackle::impl::View SN_r0Mg2SiO4(SN_r0Mg2SiO4_data_.data(), 3, inject_pathway_props->n_pathways); - std::vector SN_r0MgSiO3_data_(3 * inject_pathway_props->n_pathways); - grackle::impl::View SN_r0MgSiO3(SN_r0MgSiO3_data_.data(), 3, inject_pathway_props->n_pathways); - std::vector SN_r0Fe3O4_data_(3 * inject_pathway_props->n_pathways); - grackle::impl::View SN_r0Fe3O4(SN_r0Fe3O4_data_.data(), 3, inject_pathway_props->n_pathways); - std::vector SN_r0AC_data_(3 * inject_pathway_props->n_pathways); - grackle::impl::View SN_r0AC(SN_r0AC_data_.data(), 3, inject_pathway_props->n_pathways); - std::vector SN_r0SiO2D_data_(3 * inject_pathway_props->n_pathways); - grackle::impl::View SN_r0SiO2D(SN_r0SiO2D_data_.data(), 3, inject_pathway_props->n_pathways); - std::vector SN_r0MgO_data_(3 * inject_pathway_props->n_pathways); - grackle::impl::View SN_r0MgO(SN_r0MgO_data_.data(), 3, inject_pathway_props->n_pathways); - std::vector SN_r0FeS_data_(3 * inject_pathway_props->n_pathways); - grackle::impl::View SN_r0FeS(SN_r0FeS_data_.data(), 3, inject_pathway_props->n_pathways); - std::vector SN_r0Al2O3_data_(3 * inject_pathway_props->n_pathways); - grackle::impl::View SN_r0Al2O3(SN_r0Al2O3_data_.data(), 3, inject_pathway_props->n_pathways); - std::vector SN_r0reforg_data_(3 * inject_pathway_props->n_pathways); - grackle::impl::View SN_r0reforg(SN_r0reforg_data_.data(), 3, inject_pathway_props->n_pathways); - std::vector SN_r0volorg_data_(3 * inject_pathway_props->n_pathways); - grackle::impl::View SN_r0volorg(SN_r0volorg_data_.data(), 3, inject_pathway_props->n_pathways); - std::vector SN_r0H2Oice_data_(3 * inject_pathway_props->n_pathways); - grackle::impl::View SN_r0H2Oice(SN_r0H2Oice_data_.data(), 3, inject_pathway_props->n_pathways); + grackle::impl::View SN_r0SiM(reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::SiM_dust], 3, inject_pathway_props->n_pathways); + grackle::impl::View SN_r0FeM(reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::FeM_dust], 3, inject_pathway_props->n_pathways); + grackle::impl::View SN_r0Mg2SiO4(reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::Mg2SiO4_dust], 3, inject_pathway_props->n_pathways); + grackle::impl::View SN_r0MgSiO3(reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::MgSiO3_dust], 3, inject_pathway_props->n_pathways); + grackle::impl::View SN_r0Fe3O4(reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::Fe3O4_dust], 3, inject_pathway_props->n_pathways); + grackle::impl::View SN_r0AC(reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::AC_dust], 3, inject_pathway_props->n_pathways); + grackle::impl::View SN_r0SiO2D(reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::SiO2_dust], 3, inject_pathway_props->n_pathways); + grackle::impl::View SN_r0MgO(reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::MgO_dust], 3, inject_pathway_props->n_pathways); + grackle::impl::View SN_r0FeS(reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::FeS_dust], 3, inject_pathway_props->n_pathways); + grackle::impl::View SN_r0Al2O3(reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::Al2O3_dust], 3, inject_pathway_props->n_pathways); + grackle::impl::View SN_r0reforg(reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::ref_org_dust], 3, inject_pathway_props->n_pathways); + grackle::impl::View SN_r0volorg(reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::vol_org_dust], 3, inject_pathway_props->n_pathways); + grackle::impl::View SN_r0H2Oice(reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::H2O_ice_dust], 3, inject_pathway_props->n_pathways); std::vector SN_kpSiM_data_(gr_Size * inject_pathway_props->n_pathways); grackle::impl::View SN_kpSiM(SN_kpSiM_data_.data(), gr_Size, inject_pathway_props->n_pathways); std::vector SN_kpFeM_data_(gr_Size * inject_pathway_props->n_pathways); @@ -328,7 +315,7 @@ inline void calc_grain_size_increment_1d( &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->MgSiO3_dust_density, SN_metal.data(), reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust], - SN_r0MgSiO3.data(), + reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::MgSiO3_dust], &bulk_densities[OnlyGrainSpLUT::MgSiO3_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgSiO3_dust], alMgSiO3.data(), gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpMgSiO3.data() ); @@ -339,7 +326,7 @@ inline void calc_grain_size_increment_1d( &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->AC_dust_density, SN_metal.data(), reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::AC_dust], - SN_r0AC.data(), + reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::AC_dust], &bulk_densities[OnlyGrainSpLUT::AC_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::AC_dust], alAC.data(), gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpAC.data() ); @@ -352,7 +339,7 @@ inline void calc_grain_size_increment_1d( &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->SiM_dust_density, SN_metal.data(), reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::SiM_dust], - SN_r0SiM.data(), + reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::SiM_dust], &bulk_densities[OnlyGrainSpLUT::SiM_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiM_dust], alSiM.data(), gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpSiM.data() ); @@ -363,7 +350,7 @@ inline void calc_grain_size_increment_1d( &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->FeM_dust_density, SN_metal.data(), reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::FeM_dust], - SN_r0FeM.data(), + reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::FeM_dust], &bulk_densities[OnlyGrainSpLUT::FeM_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeM_dust], alFeM.data(), gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpFeM.data() ); @@ -374,7 +361,7 @@ inline void calc_grain_size_increment_1d( &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->Mg2SiO4_dust_density, SN_metal.data(), reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust], - SN_r0Mg2SiO4.data(), + reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::Mg2SiO4_dust], &bulk_densities[OnlyGrainSpLUT::Mg2SiO4_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Mg2SiO4_dust], alMg2SiO4.data(), gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpMg2SiO4.data() ); @@ -385,7 +372,7 @@ inline void calc_grain_size_increment_1d( &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->Fe3O4_dust_density, SN_metal.data(), reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::Fe3O4_dust], - SN_r0Fe3O4.data(), + reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::Fe3O4_dust], &bulk_densities[OnlyGrainSpLUT::Fe3O4_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Fe3O4_dust], alFe3O4.data(), gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpFe3O4.data() ); @@ -396,7 +383,7 @@ inline void calc_grain_size_increment_1d( &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->SiO2_dust_density, SN_metal.data(), reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::SiO2_dust], - SN_r0SiO2D.data(), + reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::SiO2_dust], &bulk_densities[OnlyGrainSpLUT::SiO2_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiO2_dust], alSiO2D.data(), gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpSiO2D.data() ); @@ -407,7 +394,7 @@ inline void calc_grain_size_increment_1d( &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->MgO_dust_density, SN_metal.data(), reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::MgO_dust], - SN_r0MgO.data(), + reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::MgO_dust], &bulk_densities[OnlyGrainSpLUT::MgO_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgO_dust], alMgO.data(), gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpMgO.data() ); @@ -418,7 +405,7 @@ inline void calc_grain_size_increment_1d( &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->FeS_dust_density, SN_metal.data(), reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::FeS_dust], - SN_r0FeS.data(), + reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::FeS_dust], &bulk_densities[OnlyGrainSpLUT::FeS_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeS_dust], alFeS.data(), gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpFeS.data() ); @@ -429,7 +416,7 @@ inline void calc_grain_size_increment_1d( &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->Al2O3_dust_density, SN_metal.data(), reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::Al2O3_dust], - SN_r0Al2O3.data(), + reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::Al2O3_dust], &bulk_densities[OnlyGrainSpLUT::Al2O3_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Al2O3_dust], alAl2O3.data(), gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpAl2O3.data() ); @@ -442,7 +429,7 @@ inline void calc_grain_size_increment_1d( &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->ref_org_dust_density, SN_metal.data(), reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::ref_org_dust], - SN_r0reforg.data(), + reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::ref_org_dust], &bulk_densities[OnlyGrainSpLUT::ref_org_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::ref_org_dust], alreforg.data(), gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpreforg.data() ); @@ -453,7 +440,7 @@ inline void calc_grain_size_increment_1d( &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->vol_org_dust_density, SN_metal.data(), reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::vol_org_dust], - SN_r0volorg.data(), + reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::vol_org_dust], &bulk_densities[OnlyGrainSpLUT::vol_org_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::vol_org_dust], alvolorg.data(), gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpvolorg.data() ); @@ -464,7 +451,7 @@ inline void calc_grain_size_increment_1d( &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, my_fields->H2O_ice_dust_density, SN_metal.data(), reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::H2O_ice_dust], - SN_r0H2Oice.data(), + reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::H2O_ice_dust], &bulk_densities[OnlyGrainSpLUT::H2O_ice_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::H2O_ice_dust], alH2Oice.data(), gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpH2Oice.data() ); From 9bfe7c161bc40be1b95dd3a3bf83159a90e1619b Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 10 Dec 2025 22:38:45 -0500 Subject: [PATCH 084/175] grain_size_incr: a 3rd step towards aggregating allocations --- .../calc_grain_size_increment_1d.hpp | 78 +++++++++---------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp index 45c08a17b..312d3ab21 100644 --- a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp +++ b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp @@ -168,32 +168,19 @@ inline void calc_grain_size_increment_1d( grackle::impl::View SN_r0reforg(reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::ref_org_dust], 3, inject_pathway_props->n_pathways); grackle::impl::View SN_r0volorg(reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::vol_org_dust], 3, inject_pathway_props->n_pathways); grackle::impl::View SN_r0H2Oice(reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::H2O_ice_dust], 3, inject_pathway_props->n_pathways); - std::vector SN_kpSiM_data_(gr_Size * inject_pathway_props->n_pathways); - grackle::impl::View SN_kpSiM(SN_kpSiM_data_.data(), gr_Size, inject_pathway_props->n_pathways); - std::vector SN_kpFeM_data_(gr_Size * inject_pathway_props->n_pathways); - grackle::impl::View SN_kpFeM(SN_kpFeM_data_.data(), gr_Size, inject_pathway_props->n_pathways); - std::vector SN_kpMg2SiO4_data_(gr_Size * inject_pathway_props->n_pathways); - grackle::impl::View SN_kpMg2SiO4(SN_kpMg2SiO4_data_.data(), gr_Size, inject_pathway_props->n_pathways); - std::vector SN_kpMgSiO3_data_(gr_Size * inject_pathway_props->n_pathways); - grackle::impl::View SN_kpMgSiO3(SN_kpMgSiO3_data_.data(), gr_Size, inject_pathway_props->n_pathways); - std::vector SN_kpFe3O4_data_(gr_Size * inject_pathway_props->n_pathways); - grackle::impl::View SN_kpFe3O4(SN_kpFe3O4_data_.data(), gr_Size, inject_pathway_props->n_pathways); - std::vector SN_kpAC_data_(gr_Size * inject_pathway_props->n_pathways); - grackle::impl::View SN_kpAC(SN_kpAC_data_.data(), gr_Size, inject_pathway_props->n_pathways); - std::vector SN_kpSiO2D_data_(gr_Size * inject_pathway_props->n_pathways); - grackle::impl::View SN_kpSiO2D(SN_kpSiO2D_data_.data(), gr_Size, inject_pathway_props->n_pathways); - std::vector SN_kpMgO_data_(gr_Size * inject_pathway_props->n_pathways); - grackle::impl::View SN_kpMgO(SN_kpMgO_data_.data(), gr_Size, inject_pathway_props->n_pathways); - std::vector SN_kpFeS_data_(gr_Size * inject_pathway_props->n_pathways); - grackle::impl::View SN_kpFeS(SN_kpFeS_data_.data(), gr_Size, inject_pathway_props->n_pathways); - std::vector SN_kpAl2O3_data_(gr_Size * inject_pathway_props->n_pathways); - grackle::impl::View SN_kpAl2O3(SN_kpAl2O3_data_.data(), gr_Size, inject_pathway_props->n_pathways); - std::vector SN_kpreforg_data_(gr_Size * inject_pathway_props->n_pathways); - grackle::impl::View SN_kpreforg(SN_kpreforg_data_.data(), gr_Size, inject_pathway_props->n_pathways); - std::vector SN_kpvolorg_data_(gr_Size * inject_pathway_props->n_pathways); - grackle::impl::View SN_kpvolorg(SN_kpvolorg_data_.data(), gr_Size, inject_pathway_props->n_pathways); - std::vector SN_kpH2Oice_data_(gr_Size * inject_pathway_props->n_pathways); - grackle::impl::View SN_kpH2Oice(SN_kpH2Oice_data_.data(), gr_Size, inject_pathway_props->n_pathways); + grackle::impl::View SN_kpSiM(reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::SiM_dust], gr_Size, inject_pathway_props->n_pathways); + grackle::impl::View SN_kpFeM(reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::FeM_dust], gr_Size, inject_pathway_props->n_pathways); + grackle::impl::View SN_kpMg2SiO4(reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::Mg2SiO4_dust], gr_Size, inject_pathway_props->n_pathways); + grackle::impl::View SN_kpMgSiO3(reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::MgSiO3_dust], gr_Size, inject_pathway_props->n_pathways); + grackle::impl::View SN_kpFe3O4(reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::Fe3O4_dust], gr_Size, inject_pathway_props->n_pathways); + grackle::impl::View SN_kpAC(reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::AC_dust], gr_Size, inject_pathway_props->n_pathways); + grackle::impl::View SN_kpSiO2D(reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::SiO2_dust], gr_Size, inject_pathway_props->n_pathways); + grackle::impl::View SN_kpMgO(reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::MgO_dust], gr_Size, inject_pathway_props->n_pathways); + grackle::impl::View SN_kpFeS(reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::FeS_dust], gr_Size, inject_pathway_props->n_pathways); + grackle::impl::View SN_kpAl2O3(reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::Al2O3_dust], gr_Size, inject_pathway_props->n_pathways); + grackle::impl::View SN_kpreforg(reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::ref_org_dust], gr_Size, inject_pathway_props->n_pathways); + grackle::impl::View SN_kpvolorg(reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::vol_org_dust], gr_Size, inject_pathway_props->n_pathways); + grackle::impl::View SN_kpH2Oice(reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::H2O_ice_dust], gr_Size, inject_pathway_props->n_pathways); // local int i, idx; @@ -317,7 +304,8 @@ inline void calc_grain_size_increment_1d( reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust], reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::MgSiO3_dust], &bulk_densities[OnlyGrainSpLUT::MgSiO3_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgSiO3_dust], alMgSiO3.data(), - gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpMgSiO3.data() + gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], + reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::MgSiO3_dust] ); // ! write(*,*) 'AC' @@ -328,7 +316,8 @@ inline void calc_grain_size_increment_1d( reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::AC_dust], reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::AC_dust], &bulk_densities[OnlyGrainSpLUT::AC_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::AC_dust], alAC.data(), - gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpAC.data() + gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], + reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::AC_dust] ); } @@ -341,7 +330,8 @@ inline void calc_grain_size_increment_1d( reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::SiM_dust], reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::SiM_dust], &bulk_densities[OnlyGrainSpLUT::SiM_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiM_dust], alSiM.data(), - gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpSiM.data() + gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], + reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::SiM_dust] ); // ! write(*,*) 'FeM' @@ -352,7 +342,8 @@ inline void calc_grain_size_increment_1d( reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::FeM_dust], reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::FeM_dust], &bulk_densities[OnlyGrainSpLUT::FeM_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeM_dust], alFeM.data(), - gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpFeM.data() + gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], + reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::FeM_dust] ); // ! write(*,*) 'Mg2SiO4' @@ -363,7 +354,8 @@ inline void calc_grain_size_increment_1d( reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust], reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::Mg2SiO4_dust], &bulk_densities[OnlyGrainSpLUT::Mg2SiO4_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Mg2SiO4_dust], alMg2SiO4.data(), - gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpMg2SiO4.data() + gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], + reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::Mg2SiO4_dust] ); // ! write(*,*) 'Fe3O4' @@ -374,7 +366,8 @@ inline void calc_grain_size_increment_1d( reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::Fe3O4_dust], reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::Fe3O4_dust], &bulk_densities[OnlyGrainSpLUT::Fe3O4_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Fe3O4_dust], alFe3O4.data(), - gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpFe3O4.data() + gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], + reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::Fe3O4_dust] ); // ! write(*,*) 'SiO2D' @@ -385,7 +378,8 @@ inline void calc_grain_size_increment_1d( reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::SiO2_dust], reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::SiO2_dust], &bulk_densities[OnlyGrainSpLUT::SiO2_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiO2_dust], alSiO2D.data(), - gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpSiO2D.data() + gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], + reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::SiO2_dust] ); // ! write(*,*) 'MgO' @@ -396,7 +390,8 @@ inline void calc_grain_size_increment_1d( reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::MgO_dust], reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::MgO_dust], &bulk_densities[OnlyGrainSpLUT::MgO_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgO_dust], alMgO.data(), - gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpMgO.data() + gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], + reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::MgO_dust] ); // ! write(*,*) 'FeS' @@ -407,7 +402,8 @@ inline void calc_grain_size_increment_1d( reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::FeS_dust], reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::FeS_dust], &bulk_densities[OnlyGrainSpLUT::FeS_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeS_dust], alFeS.data(), - gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpFeS.data() + gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], + reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::FeS_dust] ); // ! write(*,*) 'Al2O3' @@ -418,7 +414,8 @@ inline void calc_grain_size_increment_1d( reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::Al2O3_dust], reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::Al2O3_dust], &bulk_densities[OnlyGrainSpLUT::Al2O3_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Al2O3_dust], alAl2O3.data(), - gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpAl2O3.data() + gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], + reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::Al2O3_dust] ); } @@ -431,7 +428,8 @@ inline void calc_grain_size_increment_1d( reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::ref_org_dust], reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::ref_org_dust], &bulk_densities[OnlyGrainSpLUT::ref_org_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::ref_org_dust], alreforg.data(), - gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpreforg.data() + gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], + reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::ref_org_dust] ); // ! write(*,*) 'volorg' @@ -442,7 +440,8 @@ inline void calc_grain_size_increment_1d( reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::vol_org_dust], reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::vol_org_dust], &bulk_densities[OnlyGrainSpLUT::vol_org_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::vol_org_dust], alvolorg.data(), - gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpvolorg.data() + gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], + reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::vol_org_dust] ); // ! write(*,*) 'H2Oice' @@ -453,7 +452,8 @@ inline void calc_grain_size_increment_1d( reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::H2O_ice_dust], reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::H2O_ice_dust], &bulk_densities[OnlyGrainSpLUT::H2O_ice_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::H2O_ice_dust], alH2Oice.data(), - gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], SN_kpH2Oice.data() + gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], + reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::H2O_ice_dust] ); } From 2cc450bc0111d2fe30d4a41de7a3e00f1bc67590 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 10 Dec 2025 23:00:08 -0500 Subject: [PATCH 085/175] grain_size_incr: more massaging --- .../calc_grain_size_increment_1d.hpp | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp index 312d3ab21..80b66bba3 100644 --- a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp +++ b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp @@ -29,6 +29,7 @@ #include "inject_model/inject_path_field_pack.hpp" #include "LUT.hpp" #include "utils-cpp.hpp" +#include "utils-field.hpp" namespace grackle::impl { @@ -90,6 +91,8 @@ inline void calc_grain_size_increment_1d( my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); + grackle::impl::SpeciesLUTFieldAdaptor field_data_adaptor{*my_fields}; + // table grackle::impl::View SN0_r0SiM(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::SiM_dust], 3, inject_pathway_props->n_pathways); grackle::impl::View SN0_r0FeM(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::FeM_dust], 3, inject_pathway_props->n_pathways); @@ -303,7 +306,7 @@ inline void calc_grain_size_increment_1d( &nSN, my_fields->MgSiO3_dust_density, SN_metal.data(), reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust], reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::MgSiO3_dust], - &bulk_densities[OnlyGrainSpLUT::MgSiO3_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgSiO3_dust], alMgSiO3.data(), + &bulk_densities[OnlyGrainSpLUT::MgSiO3_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgSiO3_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::MgSiO3_dust], gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::MgSiO3_dust] ); @@ -315,7 +318,7 @@ inline void calc_grain_size_increment_1d( &nSN, my_fields->AC_dust_density, SN_metal.data(), reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::AC_dust], reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::AC_dust], - &bulk_densities[OnlyGrainSpLUT::AC_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::AC_dust], alAC.data(), + &bulk_densities[OnlyGrainSpLUT::AC_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::AC_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::AC_dust], gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::AC_dust] ); @@ -329,7 +332,7 @@ inline void calc_grain_size_increment_1d( &nSN, my_fields->SiM_dust_density, SN_metal.data(), reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::SiM_dust], reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::SiM_dust], - &bulk_densities[OnlyGrainSpLUT::SiM_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiM_dust], alSiM.data(), + &bulk_densities[OnlyGrainSpLUT::SiM_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiM_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::SiM_dust], gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::SiM_dust] ); @@ -341,7 +344,7 @@ inline void calc_grain_size_increment_1d( &nSN, my_fields->FeM_dust_density, SN_metal.data(), reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::FeM_dust], reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::FeM_dust], - &bulk_densities[OnlyGrainSpLUT::FeM_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeM_dust], alFeM.data(), + &bulk_densities[OnlyGrainSpLUT::FeM_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeM_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::FeM_dust], gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::FeM_dust] ); @@ -353,7 +356,7 @@ inline void calc_grain_size_increment_1d( &nSN, my_fields->Mg2SiO4_dust_density, SN_metal.data(), reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust], reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::Mg2SiO4_dust], - &bulk_densities[OnlyGrainSpLUT::Mg2SiO4_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Mg2SiO4_dust], alMg2SiO4.data(), + &bulk_densities[OnlyGrainSpLUT::Mg2SiO4_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Mg2SiO4_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Mg2SiO4_dust], gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::Mg2SiO4_dust] ); @@ -365,7 +368,7 @@ inline void calc_grain_size_increment_1d( &nSN, my_fields->Fe3O4_dust_density, SN_metal.data(), reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::Fe3O4_dust], reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::Fe3O4_dust], - &bulk_densities[OnlyGrainSpLUT::Fe3O4_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Fe3O4_dust], alFe3O4.data(), + &bulk_densities[OnlyGrainSpLUT::Fe3O4_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Fe3O4_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Fe3O4_dust], gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::Fe3O4_dust] ); @@ -377,7 +380,7 @@ inline void calc_grain_size_increment_1d( &nSN, my_fields->SiO2_dust_density, SN_metal.data(), reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::SiO2_dust], reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::SiO2_dust], - &bulk_densities[OnlyGrainSpLUT::SiO2_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiO2_dust], alSiO2D.data(), + &bulk_densities[OnlyGrainSpLUT::SiO2_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiO2_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::SiO2_dust], gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::SiO2_dust] ); @@ -389,7 +392,7 @@ inline void calc_grain_size_increment_1d( &nSN, my_fields->MgO_dust_density, SN_metal.data(), reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::MgO_dust], reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::MgO_dust], - &bulk_densities[OnlyGrainSpLUT::MgO_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgO_dust], alMgO.data(), + &bulk_densities[OnlyGrainSpLUT::MgO_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgO_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::MgO_dust], gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::MgO_dust] ); @@ -401,7 +404,7 @@ inline void calc_grain_size_increment_1d( &nSN, my_fields->FeS_dust_density, SN_metal.data(), reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::FeS_dust], reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::FeS_dust], - &bulk_densities[OnlyGrainSpLUT::FeS_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeS_dust], alFeS.data(), + &bulk_densities[OnlyGrainSpLUT::FeS_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeS_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::FeS_dust], gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::FeS_dust] ); @@ -413,7 +416,7 @@ inline void calc_grain_size_increment_1d( &nSN, my_fields->Al2O3_dust_density, SN_metal.data(), reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::Al2O3_dust], reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::Al2O3_dust], - &bulk_densities[OnlyGrainSpLUT::Al2O3_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Al2O3_dust], alAl2O3.data(), + &bulk_densities[OnlyGrainSpLUT::Al2O3_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Al2O3_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Al2O3_dust], gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::Al2O3_dust] ); @@ -427,7 +430,7 @@ inline void calc_grain_size_increment_1d( &nSN, my_fields->ref_org_dust_density, SN_metal.data(), reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::ref_org_dust], reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::ref_org_dust], - &bulk_densities[OnlyGrainSpLUT::ref_org_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::ref_org_dust], alreforg.data(), + &bulk_densities[OnlyGrainSpLUT::ref_org_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::ref_org_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::ref_org_dust], gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::ref_org_dust] ); @@ -439,7 +442,7 @@ inline void calc_grain_size_increment_1d( &nSN, my_fields->vol_org_dust_density, SN_metal.data(), reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::vol_org_dust], reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::vol_org_dust], - &bulk_densities[OnlyGrainSpLUT::vol_org_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::vol_org_dust], alvolorg.data(), + &bulk_densities[OnlyGrainSpLUT::vol_org_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::vol_org_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::vol_org_dust], gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::vol_org_dust] ); @@ -451,7 +454,7 @@ inline void calc_grain_size_increment_1d( &nSN, my_fields->H2O_ice_dust_density, SN_metal.data(), reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::H2O_ice_dust], reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::H2O_ice_dust], - &bulk_densities[OnlyGrainSpLUT::H2O_ice_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::H2O_ice_dust], alH2Oice.data(), + &bulk_densities[OnlyGrainSpLUT::H2O_ice_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::H2O_ice_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::H2O_ice_dust], gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::H2O_ice_dust] ); From 17df793550ee2d4055d84e787a57df431c54c3f5 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 10 Dec 2025 23:12:32 -0500 Subject: [PATCH 086/175] grain_size_incr: fold all calls to actually compute increment into for-loop --- .../calc_grain_size_increment_1d.hpp | 189 +++--------------- src/clib/fortran_func_decls.h | 2 +- 2 files changed, 24 insertions(+), 167 deletions(-) diff --git a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp index 80b66bba3..d3a5232c9 100644 --- a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp +++ b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp @@ -291,173 +291,30 @@ inline void calc_grain_size_increment_1d( } } - double bulk_densities[OnlyGrainSpLUT::NUM_ENTRIES]; + // actually calculate the size increment and subsequent quantities for (int grsp_i = 0; grsp_i < grain_species_info->n_species; grsp_i++) { - bulk_densities[grsp_i] = grain_species_info->species_info[grsp_i].bulk_density_cgs; - } - - // ! calculate size increment - - if (my_chemistry->dust_species > 0) { - // ! write(*,*) 'MgSiO3' - FORTRAN_NAME(calc_grain_size_increment_species_1d)( - &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, - &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, - &nSN, my_fields->MgSiO3_dust_density, SN_metal.data(), - reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust], - reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::MgSiO3_dust], - &bulk_densities[OnlyGrainSpLUT::MgSiO3_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgSiO3_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::MgSiO3_dust], - gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], - reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::MgSiO3_dust] - ); - - // ! write(*,*) 'AC' - FORTRAN_NAME(calc_grain_size_increment_species_1d)( - &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, - &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, - &nSN, my_fields->AC_dust_density, SN_metal.data(), - reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::AC_dust], - reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::AC_dust], - &bulk_densities[OnlyGrainSpLUT::AC_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::AC_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::AC_dust], - gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], - reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::AC_dust] - ); - } - - if (my_chemistry->dust_species > 1) { - // ! write(*,*) 'SiM' - FORTRAN_NAME(calc_grain_size_increment_species_1d)( - &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, - &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, - &nSN, my_fields->SiM_dust_density, SN_metal.data(), - reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::SiM_dust], - reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::SiM_dust], - &bulk_densities[OnlyGrainSpLUT::SiM_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiM_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::SiM_dust], - gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], - reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::SiM_dust] - ); - - // ! write(*,*) 'FeM' - FORTRAN_NAME(calc_grain_size_increment_species_1d)( - &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, - &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, - &nSN, my_fields->FeM_dust_density, SN_metal.data(), - reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::FeM_dust], - reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::FeM_dust], - &bulk_densities[OnlyGrainSpLUT::FeM_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeM_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::FeM_dust], - gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], - reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::FeM_dust] - ); - - // ! write(*,*) 'Mg2SiO4' - FORTRAN_NAME(calc_grain_size_increment_species_1d)( - &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, - &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, - &nSN, my_fields->Mg2SiO4_dust_density, SN_metal.data(), - reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust], - reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::Mg2SiO4_dust], - &bulk_densities[OnlyGrainSpLUT::Mg2SiO4_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Mg2SiO4_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Mg2SiO4_dust], - gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], - reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::Mg2SiO4_dust] - ); - - // ! write(*,*) 'Fe3O4' - FORTRAN_NAME(calc_grain_size_increment_species_1d)( - &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, - &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, - &nSN, my_fields->Fe3O4_dust_density, SN_metal.data(), - reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::Fe3O4_dust], - reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::Fe3O4_dust], - &bulk_densities[OnlyGrainSpLUT::Fe3O4_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Fe3O4_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Fe3O4_dust], - gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], - reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::Fe3O4_dust] - ); - - // ! write(*,*) 'SiO2D' - FORTRAN_NAME(calc_grain_size_increment_species_1d)( - &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, - &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, - &nSN, my_fields->SiO2_dust_density, SN_metal.data(), - reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::SiO2_dust], - reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::SiO2_dust], - &bulk_densities[OnlyGrainSpLUT::SiO2_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiO2_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::SiO2_dust], - gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], - reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::SiO2_dust] - ); - - // ! write(*,*) 'MgO' - FORTRAN_NAME(calc_grain_size_increment_species_1d)( - &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, - &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, - &nSN, my_fields->MgO_dust_density, SN_metal.data(), - reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::MgO_dust], - reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::MgO_dust], - &bulk_densities[OnlyGrainSpLUT::MgO_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgO_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::MgO_dust], - gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], - reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::MgO_dust] - ); - - // ! write(*,*) 'FeS' - FORTRAN_NAME(calc_grain_size_increment_species_1d)( - &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, - &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, - &nSN, my_fields->FeS_dust_density, SN_metal.data(), - reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::FeS_dust], - reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::FeS_dust], - &bulk_densities[OnlyGrainSpLUT::FeS_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeS_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::FeS_dust], - gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], - reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::FeS_dust] - ); - - // ! write(*,*) 'Al2O3' - FORTRAN_NAME(calc_grain_size_increment_species_1d)( - &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, - &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, - &nSN, my_fields->Al2O3_dust_density, SN_metal.data(), - reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::Al2O3_dust], - reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::Al2O3_dust], - &bulk_densities[OnlyGrainSpLUT::Al2O3_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Al2O3_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Al2O3_dust], - gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], - reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::Al2O3_dust] - ); - } - - if (my_chemistry->dust_species > 2) { - // ! write(*,*) 'reforg' - FORTRAN_NAME(calc_grain_size_increment_species_1d)( - &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, - &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, - &nSN, my_fields->ref_org_dust_density, SN_metal.data(), - reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::ref_org_dust], - reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::ref_org_dust], - &bulk_densities[OnlyGrainSpLUT::ref_org_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::ref_org_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::ref_org_dust], - gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], - reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::ref_org_dust] - ); - - // ! write(*,*) 'volorg' - FORTRAN_NAME(calc_grain_size_increment_species_1d)( - &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, - &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, - &nSN, my_fields->vol_org_dust_density, SN_metal.data(), - reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::vol_org_dust], - reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::vol_org_dust], - &bulk_densities[OnlyGrainSpLUT::vol_org_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::vol_org_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::vol_org_dust], - gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], - reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::vol_org_dust] - ); - - // ! write(*,*) 'H2Oice' - FORTRAN_NAME(calc_grain_size_increment_species_1d)( - &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, - &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, - &nSN, my_fields->H2O_ice_dust_density, SN_metal.data(), - reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::H2O_ice_dust], - reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::H2O_ice_dust], - &bulk_densities[OnlyGrainSpLUT::H2O_ice_dust], internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::H2O_ice_dust], internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::H2O_ice_dust], - gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], - reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::H2O_ice_dust] - ); + const GrainSpeciesInfoEntry& cur_grsp_info = + grain_species_info->species_info[grsp_i]; + double bulk_density = cur_grsp_info.bulk_density_cgs; + + const gr_float* grsp_density = + field_data_adaptor.get_ptr_dynamic(cur_grsp_info.species_idx); + + FORTRAN_NAME(calc_grain_size_increment_species_1d)( + &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, + &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], + &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, + &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, + &nSN, grsp_density, SN_metal.data(), + reduced_inject_paths.grain_yields.data[grsp_i], + reduced_inject_paths.size_moments.data[grsp_i], + &bulk_density, + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[grsp_i], + internal_dust_prop_buf.grain_dyntab_kappa.data[grsp_i], + gr_N, &gr_Size, + &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], + inject_pathway_props->log10Tdust_interp_props.parameters[0], + reduced_inject_paths.opacity_coef_table.data[grsp_i]); } for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { diff --git a/src/clib/fortran_func_decls.h b/src/clib/fortran_func_decls.h index 4c0a14e87..75705410a 100644 --- a/src/clib/fortran_func_decls.h +++ b/src/clib/fortran_func_decls.h @@ -50,7 +50,7 @@ void FORTRAN_NAME(calc_all_tdust_gasgr_1d_g)( void FORTRAN_NAME(calc_grain_size_increment_species_1d)( const int* igrgr, const gr_mask_type* itmask, const int* SN0_N, int* in, int* jn, int* kn, int* is, int* ie, int* j, int* k, double* dom, gr_float* d_data_ptr, int* nSN, - gr_float* dsp_data_ptr, gr_float* SN_metal_data_ptr, double* SN_fsp, + const gr_float* dsp_data_ptr, gr_float* SN_metal_data_ptr, double* SN_fsp, double* SN_r0sp_data_ptr, double* ssp, double* sgsp, double* alsp_data_ptr, const int* gr_N, const int* gr_Size, const double* gr_dT, const double* gr_Td, double* SN_kp0sp_data_ptr From 0588e021e3dcb79b3d778c430d25a8eb9d5da659 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 10 Dec 2025 23:38:02 -0500 Subject: [PATCH 087/175] incremental commit --- .../calc_grain_size_increment_1d.hpp | 48 +++++++++++++++++-- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp index d3a5232c9..3f4fa0f7f 100644 --- a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp +++ b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp @@ -226,7 +226,7 @@ inline void calc_grain_size_increment_1d( - + /* for (iSN = 1; iSN<=(nSN); iSN++) { iSN0 = SN_i[iSN-1]; if ( my_chemistry->dust_species > 0 ) { @@ -290,9 +290,43 @@ inline void calc_grain_size_increment_1d( } } } + */ + + std::vector repacked_yields(n_pathways); + + std::vector repacked_size_moments_data_(n_pathways * 3); + grackle::impl::View repacked_size_moments( + repacked_size_moments_data_.data(), 3, n_pathways); + + std::vector repacked_opac_table_data_(n_pathways * gr_Size); + grackle::impl::View repacked_opac_table( + repacked_opac_table_data_.data(), gr_Size, n_pathways); - // actually calculate the size increment and subsequent quantities for (int grsp_i = 0; grsp_i < grain_species_info->n_species; grsp_i++) { + + // here, we repack the injection pathway for the current grain species + double* cur_yields = SN_fMgSiO3; + grackle::impl::View& cur_size_moments = SN_r0MgSiO3; + grackle::impl::View& cur_opac_table = SN_kpMgSiO3; + + grackle::impl::View orig_size_moments( + inject_pathway_props->size_moments.data[grsp_i], 3, n_pathways); + grackle::impl::View orig_opac_table( + inject_pathway_props->opacity_coef_table.data[grsp_i], gr_Size, + n_pathways); + + for (iSN = 1; iSN<=(nSN); iSN++) { + iSN0 = SN_i[iSN-1]; + repacked_yields[iSN-1] = inject_pathway_props->grain_yields.data[grsp_i][iSN0-1]; + for (idx = 1; idx<=(3); idx++) { + repacked_size_moments(idx-1,iSN-1) = orig_size_moments(idx-1,iSN0-1); + } + for (idx = 1; idx<=(gr_Size); idx++) { + repacked_opac_table(idx-1,iSN-1) = orig_opac_table(idx-1,iSN0-1); + } + } + + // actually calculate the size increment and subsequent quantities const GrainSpeciesInfoEntry& cur_grsp_info = grain_species_info->species_info[grsp_i]; double bulk_density = cur_grsp_info.bulk_density_cgs; @@ -306,15 +340,19 @@ inline void calc_grain_size_increment_1d( &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, grsp_density, SN_metal.data(), - reduced_inject_paths.grain_yields.data[grsp_i], - reduced_inject_paths.size_moments.data[grsp_i], + repacked_yields.data(), + //reduced_inject_paths.grain_yields.data[grsp_i], + repacked_size_moments.data(), + //reduced_inject_paths.size_moments.data[grsp_i], &bulk_density, internal_dust_prop_buf.grain_sigma_per_gas_mass.data[grsp_i], internal_dust_prop_buf.grain_dyntab_kappa.data[grsp_i], gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], - reduced_inject_paths.opacity_coef_table.data[grsp_i]); + //reduced_inject_paths.opacity_coef_table.data[grsp_i], + repacked_opac_table.data() + ); } for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { From c5b2cfd54b5c741ad382ecfa1fa5d5a40c24a654 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 10 Dec 2025 23:41:43 -0500 Subject: [PATCH 088/175] another step --- .../calc_grain_size_increment_1d.hpp | 119 +----------------- 1 file changed, 2 insertions(+), 117 deletions(-) diff --git a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp index 3f4fa0f7f..14db36021 100644 --- a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp +++ b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp @@ -142,49 +142,6 @@ inline void calc_grain_size_increment_1d( std::vector SN_metal_data_(my_fields->grid_dimension[0] * inject_pathway_props->n_pathways); grackle::impl::View SN_metal(SN_metal_data_.data(), my_fields->grid_dimension[0], inject_pathway_props->n_pathways); - GrainMetalInjectPathways reduced_inject_paths = new_GrainMetalInjectPathways( - n_pathways, n_log10Tdust_vals, n_opac_poly_coef); - - double* SN_fSiM = reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::SiM_dust]; - double* SN_fFeM = reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::FeM_dust]; - double* SN_fMg2SiO4 = reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust]; - double* SN_fMgSiO3 = reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust]; - double* SN_fFe3O4 = reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::Fe3O4_dust]; - double* SN_fAC = reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::AC_dust]; - double* SN_fSiO2D = reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::SiO2_dust]; - double* SN_fMgO = reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::MgO_dust]; - double* SN_fFeS = reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::FeS_dust]; - double* SN_fAl2O3 = reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::Al2O3_dust]; - double* SN_freforg = reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::ref_org_dust]; - double* SN_fvolorg = reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::vol_org_dust]; - double* SN_fH2Oice = reduced_inject_paths.grain_yields.data[OnlyGrainSpLUT::H2O_ice_dust]; - grackle::impl::View SN_r0SiM(reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::SiM_dust], 3, inject_pathway_props->n_pathways); - grackle::impl::View SN_r0FeM(reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::FeM_dust], 3, inject_pathway_props->n_pathways); - grackle::impl::View SN_r0Mg2SiO4(reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::Mg2SiO4_dust], 3, inject_pathway_props->n_pathways); - grackle::impl::View SN_r0MgSiO3(reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::MgSiO3_dust], 3, inject_pathway_props->n_pathways); - grackle::impl::View SN_r0Fe3O4(reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::Fe3O4_dust], 3, inject_pathway_props->n_pathways); - grackle::impl::View SN_r0AC(reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::AC_dust], 3, inject_pathway_props->n_pathways); - grackle::impl::View SN_r0SiO2D(reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::SiO2_dust], 3, inject_pathway_props->n_pathways); - grackle::impl::View SN_r0MgO(reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::MgO_dust], 3, inject_pathway_props->n_pathways); - grackle::impl::View SN_r0FeS(reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::FeS_dust], 3, inject_pathway_props->n_pathways); - grackle::impl::View SN_r0Al2O3(reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::Al2O3_dust], 3, inject_pathway_props->n_pathways); - grackle::impl::View SN_r0reforg(reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::ref_org_dust], 3, inject_pathway_props->n_pathways); - grackle::impl::View SN_r0volorg(reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::vol_org_dust], 3, inject_pathway_props->n_pathways); - grackle::impl::View SN_r0H2Oice(reduced_inject_paths.size_moments.data[OnlyGrainSpLUT::H2O_ice_dust], 3, inject_pathway_props->n_pathways); - grackle::impl::View SN_kpSiM(reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::SiM_dust], gr_Size, inject_pathway_props->n_pathways); - grackle::impl::View SN_kpFeM(reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::FeM_dust], gr_Size, inject_pathway_props->n_pathways); - grackle::impl::View SN_kpMg2SiO4(reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::Mg2SiO4_dust], gr_Size, inject_pathway_props->n_pathways); - grackle::impl::View SN_kpMgSiO3(reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::MgSiO3_dust], gr_Size, inject_pathway_props->n_pathways); - grackle::impl::View SN_kpFe3O4(reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::Fe3O4_dust], gr_Size, inject_pathway_props->n_pathways); - grackle::impl::View SN_kpAC(reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::AC_dust], gr_Size, inject_pathway_props->n_pathways); - grackle::impl::View SN_kpSiO2D(reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::SiO2_dust], gr_Size, inject_pathway_props->n_pathways); - grackle::impl::View SN_kpMgO(reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::MgO_dust], gr_Size, inject_pathway_props->n_pathways); - grackle::impl::View SN_kpFeS(reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::FeS_dust], gr_Size, inject_pathway_props->n_pathways); - grackle::impl::View SN_kpAl2O3(reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::Al2O3_dust], gr_Size, inject_pathway_props->n_pathways); - grackle::impl::View SN_kpreforg(reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::ref_org_dust], gr_Size, inject_pathway_props->n_pathways); - grackle::impl::View SN_kpvolorg(reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::vol_org_dust], gr_Size, inject_pathway_props->n_pathways); - grackle::impl::View SN_kpH2Oice(reduced_inject_paths.opacity_coef_table.data[OnlyGrainSpLUT::H2O_ice_dust], gr_Size, inject_pathway_props->n_pathways); - // local int i, idx; @@ -224,74 +181,7 @@ inline void calc_grain_size_increment_1d( } } - - - /* - for (iSN = 1; iSN<=(nSN); iSN++) { - iSN0 = SN_i[iSN-1]; - if ( my_chemistry->dust_species > 0 ) { - SN_fMgSiO3 [iSN-1] = inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgSiO3_dust] [iSN0-1]; - SN_fAC [iSN-1] = inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::AC_dust] [iSN0-1]; - - for (idx = 1; idx<=(3); idx++) { - SN_r0MgSiO3 (idx-1,iSN-1) = SN0_r0MgSiO3 (idx-1,iSN0-1); - SN_r0AC (idx-1,iSN-1) = SN0_r0AC (idx-1,iSN0-1); - } - for (idx = 1; idx<=(gr_Size); idx++) { - SN_kpMgSiO3 (idx-1,iSN-1) = SN0_kpMgSiO3 (idx-1,iSN0-1); - SN_kpAC (idx-1,iSN-1) = SN0_kpAC (idx-1,iSN0-1); - } - } - if ( my_chemistry->dust_species > 1 ) { - SN_fSiM [iSN-1] = inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiM_dust] [iSN0-1]; - SN_fFeM [iSN-1] = inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeM_dust] [iSN0-1]; - SN_fMg2SiO4 [iSN-1] = inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Mg2SiO4_dust] [iSN0-1]; - SN_fFe3O4 [iSN-1] = inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Fe3O4_dust] [iSN0-1]; - SN_fSiO2D [iSN-1] = inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::SiO2_dust] [iSN0-1]; - SN_fMgO [iSN-1] = inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::MgO_dust] [iSN0-1]; - SN_fFeS [iSN-1] = inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::FeS_dust] [iSN0-1]; - SN_fAl2O3 [iSN-1] = inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::Al2O3_dust] [iSN0-1]; - - for (idx = 1; idx<=(3); idx++) { - SN_r0SiM (idx-1,iSN-1) = SN0_r0SiM (idx-1,iSN0-1); - SN_r0FeM (idx-1,iSN-1) = SN0_r0FeM (idx-1,iSN0-1); - SN_r0Mg2SiO4 (idx-1,iSN-1) = SN0_r0Mg2SiO4 (idx-1,iSN0-1); - SN_r0Fe3O4 (idx-1,iSN-1) = SN0_r0Fe3O4 (idx-1,iSN0-1); - SN_r0SiO2D (idx-1,iSN-1) = SN0_r0SiO2D (idx-1,iSN0-1); - SN_r0MgO (idx-1,iSN-1) = SN0_r0MgO (idx-1,iSN0-1); - SN_r0FeS (idx-1,iSN-1) = SN0_r0FeS (idx-1,iSN0-1); - SN_r0Al2O3 (idx-1,iSN-1) = SN0_r0Al2O3 (idx-1,iSN0-1); - } - for (idx = 1; idx<=(gr_Size); idx++) { - SN_kpSiM (idx-1,iSN-1) = SN0_kpSiM (idx-1,iSN0-1); - SN_kpFeM (idx-1,iSN-1) = SN0_kpFeM (idx-1,iSN0-1); - SN_kpMg2SiO4 (idx-1,iSN-1) = SN0_kpMg2SiO4 (idx-1,iSN0-1); - SN_kpFe3O4 (idx-1,iSN-1) = SN0_kpFe3O4 (idx-1,iSN0-1); - SN_kpSiO2D (idx-1,iSN-1) = SN0_kpSiO2D (idx-1,iSN0-1); - SN_kpMgO (idx-1,iSN-1) = SN0_kpMgO (idx-1,iSN0-1); - SN_kpFeS (idx-1,iSN-1) = SN0_kpFeS (idx-1,iSN0-1); - SN_kpAl2O3 (idx-1,iSN-1) = SN0_kpAl2O3 (idx-1,iSN0-1); - } - } - if ( my_chemistry->dust_species > 2 ) { - SN_freforg [iSN-1] = inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::ref_org_dust] [iSN0-1]; - SN_fvolorg [iSN-1] = inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::vol_org_dust] [iSN0-1]; - SN_fH2Oice [iSN-1] = inject_pathway_props->grain_yields.data[OnlyGrainSpLUT::H2O_ice_dust] [iSN0-1]; - - for (idx = 1; idx<=(3); idx++) { - SN_r0reforg (idx-1,iSN-1) = SN0_r0reforg (idx-1,iSN0-1); - SN_r0volorg (idx-1,iSN-1) = SN0_r0volorg (idx-1,iSN0-1); - SN_r0H2Oice (idx-1,iSN-1) = SN0_r0H2Oice (idx-1,iSN0-1); - } - for (idx = 1; idx<=(gr_Size); idx++) { - SN_kpreforg (idx-1,iSN-1) = SN0_kpreforg (idx-1,iSN0-1); - SN_kpvolorg (idx-1,iSN-1) = SN0_kpvolorg (idx-1,iSN0-1); - SN_kpH2Oice (idx-1,iSN-1) = SN0_kpH2Oice (idx-1,iSN0-1); - } - } - } - */ - + // allocate some buffers std::vector repacked_yields(n_pathways); std::vector repacked_size_moments_data_(n_pathways * 3); @@ -302,13 +192,10 @@ inline void calc_grain_size_increment_1d( grackle::impl::View repacked_opac_table( repacked_opac_table_data_.data(), gr_Size, n_pathways); + // loop over grain species for (int grsp_i = 0; grsp_i < grain_species_info->n_species; grsp_i++) { // here, we repack the injection pathway for the current grain species - double* cur_yields = SN_fMgSiO3; - grackle::impl::View& cur_size_moments = SN_r0MgSiO3; - grackle::impl::View& cur_opac_table = SN_kpMgSiO3; - grackle::impl::View orig_size_moments( inject_pathway_props->size_moments.data[grsp_i], 3, n_pathways); grackle::impl::View orig_opac_table( @@ -406,8 +293,6 @@ inline void calc_grain_size_increment_1d( } } - - drop_GrainMetalInjectPathways(&reduced_inject_paths); } } // namespace grackle::impl From 08fbb8eb75014c5c6b92cac0ca92514fa88ea749 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 10 Dec 2025 23:58:40 -0500 Subject: [PATCH 089/175] some extra changes --- .../calc_grain_size_increment_1d.hpp | 65 +++++-------------- 1 file changed, 18 insertions(+), 47 deletions(-) diff --git a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp index 14db36021..5dc15fef3 100644 --- a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp +++ b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp @@ -93,49 +93,6 @@ inline void calc_grain_size_increment_1d( grackle::impl::SpeciesLUTFieldAdaptor field_data_adaptor{*my_fields}; - // table - grackle::impl::View SN0_r0SiM(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::SiM_dust], 3, inject_pathway_props->n_pathways); - grackle::impl::View SN0_r0FeM(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::FeM_dust], 3, inject_pathway_props->n_pathways); - grackle::impl::View SN0_r0Mg2SiO4(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::Mg2SiO4_dust], 3, inject_pathway_props->n_pathways); - grackle::impl::View SN0_r0MgSiO3(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::MgSiO3_dust], 3, inject_pathway_props->n_pathways); - grackle::impl::View SN0_r0Fe3O4(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::Fe3O4_dust], 3, inject_pathway_props->n_pathways); - grackle::impl::View SN0_r0AC(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::AC_dust], 3, inject_pathway_props->n_pathways); - grackle::impl::View SN0_r0SiO2D(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::SiO2_dust], 3, inject_pathway_props->n_pathways); - grackle::impl::View SN0_r0MgO(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::MgO_dust], 3, inject_pathway_props->n_pathways); - grackle::impl::View SN0_r0FeS(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::FeS_dust], 3, inject_pathway_props->n_pathways); - grackle::impl::View SN0_r0Al2O3(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::Al2O3_dust], 3, inject_pathway_props->n_pathways); - grackle::impl::View SN0_r0reforg(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::ref_org_dust], 3, inject_pathway_props->n_pathways); - grackle::impl::View SN0_r0volorg(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::vol_org_dust], 3, inject_pathway_props->n_pathways); - grackle::impl::View SN0_r0H2Oice(inject_pathway_props->size_moments.data[OnlyGrainSpLUT::H2O_ice_dust], 3, inject_pathway_props->n_pathways); - // opacity table - grackle::impl::View SN0_kpSiM(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::SiM_dust], gr_Size, inject_pathway_props->n_pathways); - grackle::impl::View SN0_kpFeM(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::FeM_dust], gr_Size, inject_pathway_props->n_pathways); - grackle::impl::View SN0_kpMg2SiO4(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Mg2SiO4_dust], gr_Size, inject_pathway_props->n_pathways); - grackle::impl::View SN0_kpMgSiO3(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::MgSiO3_dust], gr_Size, inject_pathway_props->n_pathways); - grackle::impl::View SN0_kpFe3O4(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Fe3O4_dust], gr_Size, inject_pathway_props->n_pathways); - grackle::impl::View SN0_kpAC(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::AC_dust], gr_Size, inject_pathway_props->n_pathways); - grackle::impl::View SN0_kpSiO2D(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::SiO2_dust], gr_Size, inject_pathway_props->n_pathways); - grackle::impl::View SN0_kpMgO(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::MgO_dust], gr_Size, inject_pathway_props->n_pathways); - grackle::impl::View SN0_kpFeS(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::FeS_dust], gr_Size, inject_pathway_props->n_pathways); - grackle::impl::View SN0_kpAl2O3(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::Al2O3_dust], gr_Size, inject_pathway_props->n_pathways); - grackle::impl::View SN0_kpreforg(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::ref_org_dust], gr_Size, inject_pathway_props->n_pathways); - grackle::impl::View SN0_kpvolorg(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::vol_org_dust], gr_Size, inject_pathway_props->n_pathways); - grackle::impl::View SN0_kpH2Oice(inject_pathway_props->opacity_coef_table.data[OnlyGrainSpLUT::H2O_ice_dust], gr_Size, inject_pathway_props->n_pathways); - // out - grackle::impl::View alSiM(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::SiM_dust], gr_N[2-1], my_fields->grid_dimension[0]); - grackle::impl::View alFeM(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::FeM_dust], gr_N[2-1], my_fields->grid_dimension[0]); - grackle::impl::View alMg2SiO4(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Mg2SiO4_dust], gr_N[2-1], my_fields->grid_dimension[0]); - grackle::impl::View alMgSiO3(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::MgSiO3_dust], gr_N[2-1], my_fields->grid_dimension[0]); - grackle::impl::View alFe3O4(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Fe3O4_dust], gr_N[2-1], my_fields->grid_dimension[0]); - grackle::impl::View alAC(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::AC_dust], gr_N[2-1], my_fields->grid_dimension[0]); - grackle::impl::View alSiO2D(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::SiO2_dust], gr_N[2-1], my_fields->grid_dimension[0]); - grackle::impl::View alMgO(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::MgO_dust], gr_N[2-1], my_fields->grid_dimension[0]); - grackle::impl::View alFeS(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::FeS_dust], gr_N[2-1], my_fields->grid_dimension[0]); - grackle::impl::View alAl2O3(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Al2O3_dust], gr_N[2-1], my_fields->grid_dimension[0]); - grackle::impl::View alreforg(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::ref_org_dust], gr_N[2-1], my_fields->grid_dimension[0]); - grackle::impl::View alvolorg(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::vol_org_dust], gr_N[2-1], my_fields->grid_dimension[0]); - grackle::impl::View alH2Oice(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::H2O_ice_dust], gr_N[2-1], my_fields->grid_dimension[0]); - grackle::impl::View altot(internal_dust_prop_buf.dyntab_kappa_tot, gr_N[2-1], my_fields->grid_dimension[0]); // array int iSN, iSN0; std::vector SN_i(inject_pathway_props->n_pathways); @@ -213,7 +170,7 @@ inline void calc_grain_size_increment_1d( } } - // actually calculate the size increment and subsequent quantities + // now, actually calculate the size increment and subsequent quantities const GrainSpeciesInfoEntry& cur_grsp_info = grain_species_info->species_info[grsp_i]; double bulk_density = cur_grsp_info.bulk_density_cgs; @@ -228,20 +185,34 @@ inline void calc_grain_size_increment_1d( &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &nSN, grsp_density, SN_metal.data(), repacked_yields.data(), - //reduced_inject_paths.grain_yields.data[grsp_i], repacked_size_moments.data(), - //reduced_inject_paths.size_moments.data[grsp_i], &bulk_density, internal_dust_prop_buf.grain_sigma_per_gas_mass.data[grsp_i], internal_dust_prop_buf.grain_dyntab_kappa.data[grsp_i], gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], inject_pathway_props->log10Tdust_interp_props.parameters[0], - //reduced_inject_paths.opacity_coef_table.data[grsp_i], repacked_opac_table.data() ); } + + // out + grackle::impl::View alSiM(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::SiM_dust], gr_N[2-1], my_fields->grid_dimension[0]); + grackle::impl::View alFeM(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::FeM_dust], gr_N[2-1], my_fields->grid_dimension[0]); + grackle::impl::View alMg2SiO4(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Mg2SiO4_dust], gr_N[2-1], my_fields->grid_dimension[0]); + grackle::impl::View alMgSiO3(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::MgSiO3_dust], gr_N[2-1], my_fields->grid_dimension[0]); + grackle::impl::View alFe3O4(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Fe3O4_dust], gr_N[2-1], my_fields->grid_dimension[0]); + grackle::impl::View alAC(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::AC_dust], gr_N[2-1], my_fields->grid_dimension[0]); + grackle::impl::View alSiO2D(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::SiO2_dust], gr_N[2-1], my_fields->grid_dimension[0]); + grackle::impl::View alMgO(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::MgO_dust], gr_N[2-1], my_fields->grid_dimension[0]); + grackle::impl::View alFeS(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::FeS_dust], gr_N[2-1], my_fields->grid_dimension[0]); + grackle::impl::View alAl2O3(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Al2O3_dust], gr_N[2-1], my_fields->grid_dimension[0]); + grackle::impl::View alreforg(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::ref_org_dust], gr_N[2-1], my_fields->grid_dimension[0]); + grackle::impl::View alvolorg(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::vol_org_dust], gr_N[2-1], my_fields->grid_dimension[0]); + grackle::impl::View alH2Oice(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::H2O_ice_dust], gr_N[2-1], my_fields->grid_dimension[0]); + grackle::impl::View altot(internal_dust_prop_buf.dyntab_kappa_tot, gr_N[2-1], my_fields->grid_dimension[0]); + for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { if ( itmask[i-1] != MASK_FALSE ) { From 2708a54c96ed3c7a998cd4b420cc34d9ae91e0a9 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Thu, 11 Dec 2025 00:00:51 -0500 Subject: [PATCH 090/175] grain_size_incr: cleanup indexing 1/3 --- .../calc_grain_size_increment_1d.hpp | 108 +++++++++--------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp index 5dc15fef3..e5ed14bbe 100644 --- a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp +++ b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp @@ -132,8 +132,8 @@ inline void calc_grain_size_increment_1d( nSN++; SN_i[nSN-1] = count + 1; - for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { - SN_metal(i-1,nSN-1) = inj_path_metal_dens(i-1,idx_range.jp1-1,idx_range.kp1-1); + for (int i = idx_range.i_start; i < idx_range.i_stop; i++) { + SN_metal(i,nSN-1) = inj_path_metal_dens(i,idx_range.j,idx_range.k); } } } @@ -162,11 +162,11 @@ inline void calc_grain_size_increment_1d( for (iSN = 1; iSN<=(nSN); iSN++) { iSN0 = SN_i[iSN-1]; repacked_yields[iSN-1] = inject_pathway_props->grain_yields.data[grsp_i][iSN0-1]; - for (idx = 1; idx<=(3); idx++) { - repacked_size_moments(idx-1,iSN-1) = orig_size_moments(idx-1,iSN0-1); + for (idx = 0; idx < 3; idx++) { + repacked_size_moments(idx,iSN-1) = orig_size_moments(idx,iSN0-1); } - for (idx = 1; idx<=(gr_Size); idx++) { - repacked_opac_table(idx-1,iSN-1) = orig_opac_table(idx-1,iSN0-1); + for (idx = 0; idx < gr_Size; idx++) { + repacked_opac_table(idx,iSN-1) = orig_opac_table(idx,iSN0-1); } } @@ -198,67 +198,67 @@ inline void calc_grain_size_increment_1d( // out - grackle::impl::View alSiM(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::SiM_dust], gr_N[2-1], my_fields->grid_dimension[0]); - grackle::impl::View alFeM(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::FeM_dust], gr_N[2-1], my_fields->grid_dimension[0]); - grackle::impl::View alMg2SiO4(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Mg2SiO4_dust], gr_N[2-1], my_fields->grid_dimension[0]); - grackle::impl::View alMgSiO3(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::MgSiO3_dust], gr_N[2-1], my_fields->grid_dimension[0]); - grackle::impl::View alFe3O4(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Fe3O4_dust], gr_N[2-1], my_fields->grid_dimension[0]); - grackle::impl::View alAC(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::AC_dust], gr_N[2-1], my_fields->grid_dimension[0]); - grackle::impl::View alSiO2D(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::SiO2_dust], gr_N[2-1], my_fields->grid_dimension[0]); - grackle::impl::View alMgO(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::MgO_dust], gr_N[2-1], my_fields->grid_dimension[0]); - grackle::impl::View alFeS(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::FeS_dust], gr_N[2-1], my_fields->grid_dimension[0]); - grackle::impl::View alAl2O3(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Al2O3_dust], gr_N[2-1], my_fields->grid_dimension[0]); - grackle::impl::View alreforg(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::ref_org_dust], gr_N[2-1], my_fields->grid_dimension[0]); - grackle::impl::View alvolorg(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::vol_org_dust], gr_N[2-1], my_fields->grid_dimension[0]); - grackle::impl::View alH2Oice(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::H2O_ice_dust], gr_N[2-1], my_fields->grid_dimension[0]); - grackle::impl::View altot(internal_dust_prop_buf.dyntab_kappa_tot, gr_N[2-1], my_fields->grid_dimension[0]); - - for (i = idx_range.i_start + 1; i<=(idx_range.i_end + 1); i++) { - if ( itmask[i-1] != MASK_FALSE ) { + grackle::impl::View alSiM(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::SiM_dust], gr_N[1], my_fields->grid_dimension[0]); + grackle::impl::View alFeM(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::FeM_dust], gr_N[1], my_fields->grid_dimension[0]); + grackle::impl::View alMg2SiO4(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Mg2SiO4_dust], gr_N[1], my_fields->grid_dimension[0]); + grackle::impl::View alMgSiO3(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::MgSiO3_dust], gr_N[1], my_fields->grid_dimension[0]); + grackle::impl::View alFe3O4(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Fe3O4_dust], gr_N[1], my_fields->grid_dimension[0]); + grackle::impl::View alAC(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::AC_dust], gr_N[1], my_fields->grid_dimension[0]); + grackle::impl::View alSiO2D(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::SiO2_dust], gr_N[1], my_fields->grid_dimension[0]); + grackle::impl::View alMgO(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::MgO_dust], gr_N[1], my_fields->grid_dimension[0]); + grackle::impl::View alFeS(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::FeS_dust], gr_N[1], my_fields->grid_dimension[0]); + grackle::impl::View alAl2O3(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Al2O3_dust], gr_N[1], my_fields->grid_dimension[0]); + grackle::impl::View alreforg(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::ref_org_dust], gr_N[1], my_fields->grid_dimension[0]); + grackle::impl::View alvolorg(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::vol_org_dust], gr_N[1], my_fields->grid_dimension[0]); + grackle::impl::View alH2Oice(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::H2O_ice_dust], gr_N[1], my_fields->grid_dimension[0]); + grackle::impl::View altot(internal_dust_prop_buf.dyntab_kappa_tot, gr_N[1], my_fields->grid_dimension[0]); + + for (i = idx_range.i_start; i < idx_range.i_stop; i++) { + if ( itmask[i] != MASK_FALSE ) { if (my_chemistry->dust_species > 0) { - internal_dust_prop_buf.sigma_per_gas_mass_tot [i-1] = internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgSiO3_dust] [i-1] - + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::AC_dust] [i-1]; + internal_dust_prop_buf.sigma_per_gas_mass_tot [i] = internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgSiO3_dust] [i] + + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::AC_dust] [i]; } if (my_chemistry->dust_species > 1) { - internal_dust_prop_buf.sigma_per_gas_mass_tot [i-1] = internal_dust_prop_buf.sigma_per_gas_mass_tot [i-1] - + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiM_dust] [i-1] - + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeM_dust] [i-1] - + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Mg2SiO4_dust] [i-1] - + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Fe3O4_dust] [i-1] - + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiO2_dust] [i-1] - + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgO_dust] [i-1] - + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeS_dust] [i-1] - + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Al2O3_dust] [i-1]; + internal_dust_prop_buf.sigma_per_gas_mass_tot [i] = internal_dust_prop_buf.sigma_per_gas_mass_tot [i] + + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiM_dust] [i] + + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeM_dust] [i] + + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Mg2SiO4_dust] [i] + + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Fe3O4_dust] [i] + + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiO2_dust] [i] + + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgO_dust] [i] + + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeS_dust] [i] + + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Al2O3_dust] [i]; } if (my_chemistry->dust_species > 2) { - internal_dust_prop_buf.sigma_per_gas_mass_tot [i-1] = internal_dust_prop_buf.sigma_per_gas_mass_tot[i-1] - + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::ref_org_dust] [i-1] - + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::vol_org_dust] [i-1] - + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::H2O_ice_dust] [i-1]; + internal_dust_prop_buf.sigma_per_gas_mass_tot [i] = internal_dust_prop_buf.sigma_per_gas_mass_tot[i] + + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::ref_org_dust] [i] + + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::vol_org_dust] [i] + + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::H2O_ice_dust] [i]; } - for (idx = 1; idx<=(gr_N [ 2-1 ]); idx++) { + for (idx = 0; idx < gr_N[1]; idx++) { if (my_chemistry->dust_species > 0) { - altot(idx-1,i-1) = alMgSiO3 (idx-1,i-1) - + alAC (idx-1,i-1); + altot(idx,i) = alMgSiO3 (idx,i) + + alAC (idx,i); } if (my_chemistry->dust_species > 1) { - altot(idx-1,i-1) = altot (idx-1,i-1) - + alSiM (idx-1,i-1) - + alFeM (idx-1,i-1) - + alMg2SiO4 (idx-1,i-1) - + alFe3O4 (idx-1,i-1) - + alSiO2D (idx-1,i-1) - + alMgO (idx-1,i-1) - + alFeS (idx-1,i-1) - + alAl2O3 (idx-1,i-1); + altot(idx,i) = altot (idx,i) + + alSiM (idx,i) + + alFeM (idx,i) + + alMg2SiO4 (idx,i) + + alFe3O4 (idx,i) + + alSiO2D (idx,i) + + alMgO (idx,i) + + alFeS (idx,i) + + alAl2O3 (idx,i); } if (my_chemistry->dust_species > 2) { - altot(idx-1,i-1) = altot (idx-1,i-1) - + alreforg (idx-1,i-1) - + alvolorg (idx-1,i-1) - + alH2Oice (idx-1,i-1); + altot(idx,i) = altot (idx,i) + + alreforg (idx,i) + + alvolorg (idx,i) + + alH2Oice (idx,i); } } From 8d60001af6b4cda16742233242d00e79d077262c Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Thu, 11 Dec 2025 00:06:10 -0500 Subject: [PATCH 091/175] grain_size_incr: cleanup indexing 2/3 --- .../calc_grain_size_increment_1d.hpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp index e5ed14bbe..415a396c0 100644 --- a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp +++ b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp @@ -129,12 +129,11 @@ inline void calc_grain_size_increment_1d( } if (max_ratio > 0.01) { - nSN++; - - SN_i[nSN-1] = count + 1; + SN_i[nSN] = count; for (int i = idx_range.i_start; i < idx_range.i_stop; i++) { - SN_metal(i,nSN-1) = inj_path_metal_dens(i,idx_range.j,idx_range.k); + SN_metal(i,nSN) = inj_path_metal_dens(i,idx_range.j,idx_range.k); } + nSN++; } } @@ -159,14 +158,14 @@ inline void calc_grain_size_increment_1d( inject_pathway_props->opacity_coef_table.data[grsp_i], gr_Size, n_pathways); - for (iSN = 1; iSN<=(nSN); iSN++) { - iSN0 = SN_i[iSN-1]; - repacked_yields[iSN-1] = inject_pathway_props->grain_yields.data[grsp_i][iSN0-1]; + for (iSN = 0; iSNgrain_yields.data[grsp_i][iSN0]; for (idx = 0; idx < 3; idx++) { - repacked_size_moments(idx,iSN-1) = orig_size_moments(idx,iSN0-1); + repacked_size_moments(idx,iSN) = orig_size_moments(idx,iSN0); } for (idx = 0; idx < gr_Size; idx++) { - repacked_opac_table(idx,iSN-1) = orig_opac_table(idx,iSN0-1); + repacked_opac_table(idx,iSN) = orig_opac_table(idx,iSN0); } } From f2e36fcc1f2dd15e67ab5b017d5705ec08f8019f Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Thu, 11 Dec 2025 00:06:22 -0500 Subject: [PATCH 092/175] grain_size_incr: cleanup indexing 3/3 --- .../calc_grain_size_increment_1d.hpp | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp index 415a396c0..16d2d0bd0 100644 --- a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp +++ b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp @@ -94,14 +94,10 @@ inline void calc_grain_size_increment_1d( grackle::impl::SpeciesLUTFieldAdaptor field_data_adaptor{*my_fields}; // array - int iSN, iSN0; std::vector SN_i(inject_pathway_props->n_pathways); std::vector SN_metal_data_(my_fields->grid_dimension[0] * inject_pathway_props->n_pathways); grackle::impl::View SN_metal(SN_metal_data_.data(), my_fields->grid_dimension[0], inject_pathway_props->n_pathways); - // local - int i, idx; - InjectPathFieldPack inject_path_metal_densities = setup_InjectPathFieldPack( my_chemistry, my_fields); @@ -158,13 +154,13 @@ inline void calc_grain_size_increment_1d( inject_pathway_props->opacity_coef_table.data[grsp_i], gr_Size, n_pathways); - for (iSN = 0; iSNgrain_yields.data[grsp_i][iSN0]; - for (idx = 0; idx < 3; idx++) { + for (int idx = 0; idx < 3; idx++) { repacked_size_moments(idx,iSN) = orig_size_moments(idx,iSN0); } - for (idx = 0; idx < gr_Size; idx++) { + for (int idx = 0; idx < gr_Size; idx++) { repacked_opac_table(idx,iSN) = orig_opac_table(idx,iSN0); } } @@ -196,7 +192,9 @@ inline void calc_grain_size_increment_1d( } - // out + // todo: clean this up so that we don't need to explicitly mention grain + // species names + // -> doing this will probably require an update to the gold standard grackle::impl::View alSiM(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::SiM_dust], gr_N[1], my_fields->grid_dimension[0]); grackle::impl::View alFeM(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::FeM_dust], gr_N[1], my_fields->grid_dimension[0]); grackle::impl::View alMg2SiO4(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Mg2SiO4_dust], gr_N[1], my_fields->grid_dimension[0]); @@ -212,7 +210,7 @@ inline void calc_grain_size_increment_1d( grackle::impl::View alH2Oice(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::H2O_ice_dust], gr_N[1], my_fields->grid_dimension[0]); grackle::impl::View altot(internal_dust_prop_buf.dyntab_kappa_tot, gr_N[1], my_fields->grid_dimension[0]); - for (i = idx_range.i_start; i < idx_range.i_stop; i++) { + for (int i = idx_range.i_start; i < idx_range.i_stop; i++) { if ( itmask[i] != MASK_FALSE ) { if (my_chemistry->dust_species > 0) { @@ -237,7 +235,7 @@ inline void calc_grain_size_increment_1d( + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::H2O_ice_dust] [i]; } - for (idx = 0; idx < gr_N[1]; idx++) { + for (int idx = 0; idx < gr_N[1]; idx++) { if (my_chemistry->dust_species > 0) { altot(idx,i) = alMgSiO3 (idx,i) + alAC (idx,i); From 989b14a6eae94a7b1c63fe77935ad368ce46a3a1 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Thu, 11 Dec 2025 09:17:14 -0500 Subject: [PATCH 093/175] add a bunch of commentary --- .../calc_grain_size_increment_1d.hpp | 124 ++++++++++++------ 1 file changed, 83 insertions(+), 41 deletions(-) diff --git a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp index 16d2d0bd0..718cf7728 100644 --- a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp +++ b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp @@ -85,51 +85,90 @@ inline void calc_grain_size_increment_1d( int gr_N[2] = {n_opac_poly_coef, n_log10Tdust_vals}; int gr_Size = gr_N[0] * gr_N[1]; + // Step 1: Identify the set of pathways for which the max ratio b/t the + // pathway's metal density and the total metal density exceeds a threshold. + // + // -> the max ratio is taken along idx_range + // -> we repack the selected metal densities into a temporary buffer + // + // TODO: refactor calc_grain_size_increment_species_1d to directly accept the + // list of selected injection pathway indices so that we can skip the process + // of repacking. + // -> repacking is mostly done for historical reasons (i.e. this logic was + // originally written in a Fortran dialect that didn't use pointers) + // + // TODO: for bitwise reproducibility, we should really be doing the same + // threshold checking within calc_grain_size_increment_species_1d. + // -> We want to ensure that a Grackle calculation **NEVER** gives + // different results whether it process a bunch of zones or one zone at + // a time. + // -> yes, for a low enough threshold, there won't be a physically meaningful + // difference in the results, but we don't want Grackle to give slightly + // different numbers based on how its called for a few reasons: + // 1. It can be EXTREMELY frustrating for someone trying to debug an error + // in a simulation code. + // 2. It can be annoying for constructing automated Grackle tests + // 3. Slight differences in a calculation can be a fantasitc heuristic for + // discovering memory errors and other bugs. But, that requires our + // logic to provide bitwise reproducible results. + + constexpr gr_float threshold = 0.01; + constexpr int max_num_pathways = inj_model_input::N_Injection_Pathways; + + // to be filled with the indices of selected injection pathways + int selected_inj_path_idx_l[max_num_pathways]; + + // to be updated with the number of selected injection pathways + int n_selected_inj_paths = 0; + + // to be filled with the metal densities for the selected injection paths + std::vector repacked_inj_path_metal_densities( + my_fields->grid_dimension[0] * n_pathways); + + // do the work + { + grackle::impl::View SN_metal( + repacked_inj_path_metal_densities.data(), my_fields->grid_dimension[0], + inject_pathway_props->n_pathways); + + grackle::impl::View metal( + const_cast(my_fields->metal_density), + my_fields->grid_dimension[0], my_fields->grid_dimension[1], + my_fields->grid_dimension[2]); - grackle::impl::View metal( - const_cast(my_fields->metal_density), - my_fields->grid_dimension[0], my_fields->grid_dimension[1], - my_fields->grid_dimension[2]); - - grackle::impl::SpeciesLUTFieldAdaptor field_data_adaptor{*my_fields}; - - // array - std::vector SN_i(inject_pathway_props->n_pathways); - std::vector SN_metal_data_(my_fields->grid_dimension[0] * inject_pathway_props->n_pathways); - grackle::impl::View SN_metal(SN_metal_data_.data(), my_fields->grid_dimension[0], inject_pathway_props->n_pathways); - - InjectPathFieldPack inject_path_metal_densities = setup_InjectPathFieldPack( - my_chemistry, my_fields); + InjectPathFieldPack inject_path_metal_densities = setup_InjectPathFieldPack( + my_chemistry, my_fields); - int start = inject_path_metal_densities.start_idx; - int stop = inject_path_metal_densities.stop_idx; + int start = inject_path_metal_densities.start_idx; + int stop = inject_path_metal_densities.stop_idx; - // make arrays - int nSN = 0; - for (int count = start; count < stop; count++) { - // when my_chemistry->multi_metals == 0, inj_path_metal_dens wraps - // the same pointer as `metal` + // make arrays + for (int count = start; count < stop; count++) { + // when my_chemistry->multi_metals == 0, inj_path_metal_dens wraps + // the same pointer as `metal` - grackle::impl::View inj_path_metal_dens( - inject_path_metal_densities.fields[count], - my_fields->grid_dimension[0], my_fields->grid_dimension[1], - my_fields->grid_dimension[2]); + grackle::impl::View inj_path_metal_dens( + inject_path_metal_densities.fields[count], + my_fields->grid_dimension[0], my_fields->grid_dimension[1], + my_fields->grid_dimension[2]); - // calculate the max ratio between inj_path_metal_dens and metal - gr_float max_ratio = std::numeric_limits::lowest(); - for (int i = idx_range.i_start; i < idx_range.i_stop; i++) { - gr_float cur_ratio = ( - inj_path_metal_dens(i, idx_range.j, idx_range.k) / - metal(i, idx_range.j, idx_range.k)); - max_ratio = std::fmax(cur_ratio, max_ratio); - } - - if (max_ratio > 0.01) { - SN_i[nSN] = count; + // calculate the max ratio between inj_path_metal_dens and metal + gr_float max_ratio = std::numeric_limits::lowest(); for (int i = idx_range.i_start; i < idx_range.i_stop; i++) { - SN_metal(i,nSN) = inj_path_metal_dens(i,idx_range.j,idx_range.k); + gr_float cur_ratio = ( + inj_path_metal_dens(i, idx_range.j, idx_range.k) / + metal(i, idx_range.j, idx_range.k)); + max_ratio = std::fmax(cur_ratio, max_ratio); + } + + if (max_ratio > threshold) { + selected_inj_path_idx_l[n_selected_inj_paths] = count; + for (int i = idx_range.i_start; i < idx_range.i_stop; i++) { + SN_metal(i,n_selected_inj_paths) = + inj_path_metal_dens(i,idx_range.j,idx_range.k); + } + n_selected_inj_paths++; } - nSN++; } } @@ -144,6 +183,8 @@ inline void calc_grain_size_increment_1d( grackle::impl::View repacked_opac_table( repacked_opac_table_data_.data(), gr_Size, n_pathways); + grackle::impl::SpeciesLUTFieldAdaptor field_data_adaptor{*my_fields}; + // loop over grain species for (int grsp_i = 0; grsp_i < grain_species_info->n_species; grsp_i++) { @@ -154,8 +195,8 @@ inline void calc_grain_size_increment_1d( inject_pathway_props->opacity_coef_table.data[grsp_i], gr_Size, n_pathways); - for (int iSN = 0; iSN < nSN; iSN++) { - int iSN0 = SN_i[iSN]; + for (int iSN = 0; iSN < n_selected_inj_paths; iSN++) { + int iSN0 = selected_inj_path_idx_l[iSN]; repacked_yields[iSN] = inject_pathway_props->grain_yields.data[grsp_i][iSN0]; for (int idx = 0; idx < 3; idx++) { repacked_size_moments(idx,iSN) = orig_size_moments(idx,iSN0); @@ -178,7 +219,8 @@ inline void calc_grain_size_increment_1d( &my_fields->grid_dimension[0], &my_fields->grid_dimension[1], &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, - &nSN, grsp_density, SN_metal.data(), + &n_selected_inj_paths, grsp_density, + repacked_inj_path_metal_densities.data(), repacked_yields.data(), repacked_size_moments.data(), &bulk_density, From 2fe019cb6c3f22fcd096dba5af55f6baacb4ed18 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Thu, 11 Dec 2025 09:23:05 -0500 Subject: [PATCH 094/175] add a little more commentary --- .../calc_grain_size_increment_1d.hpp | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp index 718cf7728..c3505d501 100644 --- a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp +++ b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp @@ -80,11 +80,6 @@ inline void calc_grain_size_increment_1d( inject_pathway_props->log10Tdust_interp_props.dimension[0]); const int n_opac_poly_coef = inject_pathway_props->n_opac_poly_coef; - // NOTE: gr_N and gr_Size are historical names - // -> they are pretty uninformative and should be changed! - int gr_N[2] = {n_opac_poly_coef, n_log10Tdust_vals}; - int gr_Size = gr_N[0] * gr_N[1]; - // Step 1: Identify the set of pathways for which the max ratio b/t the // pathway's metal density and the total metal density exceeds a threshold. // @@ -172,7 +167,13 @@ inline void calc_grain_size_increment_1d( } } - // allocate some buffers + // Step 2: Compute the output quantities for each individual species + + // NOTE: gr_N and gr_Size are historical names + // -> they are pretty uninformative and should be changed! + int gr_N[2] = {n_opac_poly_coef, n_log10Tdust_vals}; + int gr_Size = gr_N[0] * gr_N[1]; + std::vector repacked_yields(n_pathways); std::vector repacked_size_moments_data_(n_pathways * 3); @@ -188,7 +189,7 @@ inline void calc_grain_size_increment_1d( // loop over grain species for (int grsp_i = 0; grsp_i < grain_species_info->n_species; grsp_i++) { - // here, we repack the injection pathway for the current grain species + // repack the selected injection pathways for the current grain species grackle::impl::View orig_size_moments( inject_pathway_props->size_moments.data[grsp_i], 3, n_pathways); grackle::impl::View orig_opac_table( @@ -197,7 +198,8 @@ inline void calc_grain_size_increment_1d( for (int iSN = 0; iSN < n_selected_inj_paths; iSN++) { int iSN0 = selected_inj_path_idx_l[iSN]; - repacked_yields[iSN] = inject_pathway_props->grain_yields.data[grsp_i][iSN0]; + repacked_yields[iSN] = + inject_pathway_props->grain_yields.data[grsp_i][iSN0]; for (int idx = 0; idx < 3; idx++) { repacked_size_moments(idx,iSN) = orig_size_moments(idx,iSN0); } @@ -210,7 +212,6 @@ inline void calc_grain_size_increment_1d( const GrainSpeciesInfoEntry& cur_grsp_info = grain_species_info->species_info[grsp_i]; double bulk_density = cur_grsp_info.bulk_density_cgs; - const gr_float* grsp_density = field_data_adaptor.get_ptr_dynamic(cur_grsp_info.species_idx); @@ -233,9 +234,13 @@ inline void calc_grain_size_increment_1d( ); } + // step 3: calculate the total cross-section and the total opacity table + // (i.e. that include contributions from all grain species) + + // todo: can we skip this when my_chemistry->use_multiple_dust_temperatures + // is not 0? - // todo: clean this up so that we don't need to explicitly mention grain - // species names + // todo: clean up to avoid explicitly mention grain species names // -> doing this will probably require an update to the gold standard grackle::impl::View alSiM(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::SiM_dust], gr_N[1], my_fields->grid_dimension[0]); grackle::impl::View alFeM(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::FeM_dust], gr_N[1], my_fields->grid_dimension[0]); From ba2009b986cf5d80e0e4d60d3dba5ebf01cfd6de Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Thu, 11 Dec 2025 09:23:24 -0500 Subject: [PATCH 095/175] apply clang-format --- src/clib/cool1d_multi_g.cpp | 4 +- .../calc_grain_size_increment_1d.hpp | 203 ++++++++++-------- src/clib/lookup_cool_rates1d.hpp | 9 +- 3 files changed, 123 insertions(+), 93 deletions(-) diff --git a/src/clib/cool1d_multi_g.cpp b/src/clib/cool1d_multi_g.cpp index d3d10bc83..5201681f7 100644 --- a/src/clib/cool1d_multi_g.cpp +++ b/src/clib/cool1d_multi_g.cpp @@ -1108,8 +1108,8 @@ void grackle::impl::cool1d_multi_g( grackle::impl::calc_grain_size_increment_1d( dom, idx_range, itmask_metal, my_chemistry, my_rates->opaque_storage->grain_species_info, - my_rates->opaque_storage->inject_pathway_props, - my_fields, internal_dust_prop_buf); + my_rates->opaque_storage->inject_pathway_props, my_fields, + internal_dust_prop_buf); } // Calculate dust to gas ratio AND interstellar radiation field diff --git a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp index c3505d501..5f45aaecf 100644 --- a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp +++ b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp @@ -67,14 +67,12 @@ namespace grackle::impl { /// @param[in,out] internal_dust_prop_buf Holds dust-specific information that /// gets updated by this function inline void calc_grain_size_increment_1d( - double dom, IndexRange idx_range, const gr_mask_type* itmask, - const chemistry_data* my_chemistry, - const GrainSpeciesInfo* grain_species_info, - const GrainMetalInjectPathways* inject_pathway_props, - grackle_field_data* my_fields, - grackle::impl::InternalDustPropBuf internal_dust_prop_buf -) -{ + double dom, IndexRange idx_range, const gr_mask_type* itmask, + const chemistry_data* my_chemistry, + const GrainSpeciesInfo* grain_species_info, + const GrainMetalInjectPathways* inject_pathway_props, + grackle_field_data* my_fields, + grackle::impl::InternalDustPropBuf internal_dust_prop_buf) { const int n_pathways = inject_pathway_props->n_pathways; const int n_log10Tdust_vals = static_cast( inject_pathway_props->log10Tdust_interp_props.dimension[0]); @@ -131,8 +129,8 @@ inline void calc_grain_size_increment_1d( my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - InjectPathFieldPack inject_path_metal_densities = setup_InjectPathFieldPack( - my_chemistry, my_fields); + InjectPathFieldPack inject_path_metal_densities = + setup_InjectPathFieldPack(my_chemistry, my_fields); int start = inject_path_metal_densities.start_idx; int stop = inject_path_metal_densities.stop_idx; @@ -150,17 +148,16 @@ inline void calc_grain_size_increment_1d( // calculate the max ratio between inj_path_metal_dens and metal gr_float max_ratio = std::numeric_limits::lowest(); for (int i = idx_range.i_start; i < idx_range.i_stop; i++) { - gr_float cur_ratio = ( - inj_path_metal_dens(i, idx_range.j, idx_range.k) / - metal(i, idx_range.j, idx_range.k)); + gr_float cur_ratio = (inj_path_metal_dens(i, idx_range.j, idx_range.k) / + metal(i, idx_range.j, idx_range.k)); max_ratio = std::fmax(cur_ratio, max_ratio); } if (max_ratio > threshold) { - selected_inj_path_idx_l[n_selected_inj_paths] = count; + selected_inj_path_idx_l[n_selected_inj_paths] = count; for (int i = idx_range.i_start; i < idx_range.i_stop; i++) { - SN_metal(i,n_selected_inj_paths) = - inj_path_metal_dens(i,idx_range.j,idx_range.k); + SN_metal(i, n_selected_inj_paths) = + inj_path_metal_dens(i, idx_range.j, idx_range.k); } n_selected_inj_paths++; } @@ -188,7 +185,6 @@ inline void calc_grain_size_increment_1d( // loop over grain species for (int grsp_i = 0; grsp_i < grain_species_info->n_species; grsp_i++) { - // repack the selected injection pathways for the current grain species grackle::impl::View orig_size_moments( inject_pathway_props->size_moments.data[grsp_i], 3, n_pathways); @@ -199,21 +195,21 @@ inline void calc_grain_size_increment_1d( for (int iSN = 0; iSN < n_selected_inj_paths; iSN++) { int iSN0 = selected_inj_path_idx_l[iSN]; repacked_yields[iSN] = - inject_pathway_props->grain_yields.data[grsp_i][iSN0]; + inject_pathway_props->grain_yields.data[grsp_i][iSN0]; for (int idx = 0; idx < 3; idx++) { - repacked_size_moments(idx,iSN) = orig_size_moments(idx,iSN0); + repacked_size_moments(idx, iSN) = orig_size_moments(idx, iSN0); } for (int idx = 0; idx < gr_Size; idx++) { - repacked_opac_table(idx,iSN) = orig_opac_table(idx,iSN0); + repacked_opac_table(idx, iSN) = orig_opac_table(idx, iSN0); } } // now, actually calculate the size increment and subsequent quantities const GrainSpeciesInfoEntry& cur_grsp_info = - grain_species_info->species_info[grsp_i]; + grain_species_info->species_info[grsp_i]; double bulk_density = cur_grsp_info.bulk_density_cgs; const gr_float* grsp_density = - field_data_adaptor.get_ptr_dynamic(cur_grsp_info.species_idx); + field_data_adaptor.get_ptr_dynamic(cur_grsp_info.species_idx); FORTRAN_NAME(calc_grain_size_increment_species_1d)( &my_chemistry->grain_growth, itmask, &inject_pathway_props->n_pathways, @@ -221,17 +217,13 @@ inline void calc_grain_size_increment_1d( &my_fields->grid_dimension[2], &idx_range.i_start, &idx_range.i_end, &idx_range.jp1, &idx_range.kp1, &dom, my_fields->density, &n_selected_inj_paths, grsp_density, - repacked_inj_path_metal_densities.data(), - repacked_yields.data(), - repacked_size_moments.data(), - &bulk_density, + repacked_inj_path_metal_densities.data(), repacked_yields.data(), + repacked_size_moments.data(), &bulk_density, internal_dust_prop_buf.grain_sigma_per_gas_mass.data[grsp_i], - internal_dust_prop_buf.grain_dyntab_kappa.data[grsp_i], - gr_N, &gr_Size, + internal_dust_prop_buf.grain_dyntab_kappa.data[grsp_i], gr_N, &gr_Size, &inject_pathway_props->log10Tdust_interp_props.parameter_spacing[0], - inject_pathway_props->log10Tdust_interp_props.parameters[0], - repacked_opac_table.data() - ); + inject_pathway_props->log10Tdust_interp_props.parameters[0], + repacked_opac_table.data()); } // step 3: calculate the total cross-section and the total opacity table @@ -242,75 +234,114 @@ inline void calc_grain_size_increment_1d( // todo: clean up to avoid explicitly mention grain species names // -> doing this will probably require an update to the gold standard - grackle::impl::View alSiM(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::SiM_dust], gr_N[1], my_fields->grid_dimension[0]); - grackle::impl::View alFeM(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::FeM_dust], gr_N[1], my_fields->grid_dimension[0]); - grackle::impl::View alMg2SiO4(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Mg2SiO4_dust], gr_N[1], my_fields->grid_dimension[0]); - grackle::impl::View alMgSiO3(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::MgSiO3_dust], gr_N[1], my_fields->grid_dimension[0]); - grackle::impl::View alFe3O4(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Fe3O4_dust], gr_N[1], my_fields->grid_dimension[0]); - grackle::impl::View alAC(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::AC_dust], gr_N[1], my_fields->grid_dimension[0]); - grackle::impl::View alSiO2D(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::SiO2_dust], gr_N[1], my_fields->grid_dimension[0]); - grackle::impl::View alMgO(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::MgO_dust], gr_N[1], my_fields->grid_dimension[0]); - grackle::impl::View alFeS(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::FeS_dust], gr_N[1], my_fields->grid_dimension[0]); - grackle::impl::View alAl2O3(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Al2O3_dust], gr_N[1], my_fields->grid_dimension[0]); - grackle::impl::View alreforg(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::ref_org_dust], gr_N[1], my_fields->grid_dimension[0]); - grackle::impl::View alvolorg(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::vol_org_dust], gr_N[1], my_fields->grid_dimension[0]); - grackle::impl::View alH2Oice(internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::H2O_ice_dust], gr_N[1], my_fields->grid_dimension[0]); - grackle::impl::View altot(internal_dust_prop_buf.dyntab_kappa_tot, gr_N[1], my_fields->grid_dimension[0]); + grackle::impl::View alSiM( + internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::SiM_dust], + gr_N[1], my_fields->grid_dimension[0]); + grackle::impl::View alFeM( + internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::FeM_dust], + gr_N[1], my_fields->grid_dimension[0]); + grackle::impl::View alMg2SiO4( + internal_dust_prop_buf.grain_dyntab_kappa + .data[OnlyGrainSpLUT::Mg2SiO4_dust], + gr_N[1], my_fields->grid_dimension[0]); + grackle::impl::View alMgSiO3( + internal_dust_prop_buf.grain_dyntab_kappa + .data[OnlyGrainSpLUT::MgSiO3_dust], + gr_N[1], my_fields->grid_dimension[0]); + grackle::impl::View alFe3O4( + internal_dust_prop_buf.grain_dyntab_kappa + .data[OnlyGrainSpLUT::Fe3O4_dust], + gr_N[1], my_fields->grid_dimension[0]); + grackle::impl::View alAC( + internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::AC_dust], + gr_N[1], my_fields->grid_dimension[0]); + grackle::impl::View alSiO2D( + internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::SiO2_dust], + gr_N[1], my_fields->grid_dimension[0]); + grackle::impl::View alMgO( + internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::MgO_dust], + gr_N[1], my_fields->grid_dimension[0]); + grackle::impl::View alFeS( + internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::FeS_dust], + gr_N[1], my_fields->grid_dimension[0]); + grackle::impl::View alAl2O3( + internal_dust_prop_buf.grain_dyntab_kappa + .data[OnlyGrainSpLUT::Al2O3_dust], + gr_N[1], my_fields->grid_dimension[0]); + grackle::impl::View alreforg( + internal_dust_prop_buf.grain_dyntab_kappa + .data[OnlyGrainSpLUT::ref_org_dust], + gr_N[1], my_fields->grid_dimension[0]); + grackle::impl::View alvolorg( + internal_dust_prop_buf.grain_dyntab_kappa + .data[OnlyGrainSpLUT::vol_org_dust], + gr_N[1], my_fields->grid_dimension[0]); + grackle::impl::View alH2Oice( + internal_dust_prop_buf.grain_dyntab_kappa + .data[OnlyGrainSpLUT::H2O_ice_dust], + gr_N[1], my_fields->grid_dimension[0]); + grackle::impl::View altot(internal_dust_prop_buf.dyntab_kappa_tot, + gr_N[1], my_fields->grid_dimension[0]); for (int i = idx_range.i_start; i < idx_range.i_stop; i++) { - if ( itmask[i] != MASK_FALSE ) { - - if (my_chemistry->dust_species > 0) { - internal_dust_prop_buf.sigma_per_gas_mass_tot [i] = internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgSiO3_dust] [i] - + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::AC_dust] [i]; + if (itmask[i] != MASK_FALSE) { + if (my_chemistry->dust_species > 0) { + internal_dust_prop_buf.sigma_per_gas_mass_tot[i] = + internal_dust_prop_buf.grain_sigma_per_gas_mass + .data[OnlyGrainSpLUT::MgSiO3_dust][i] + + internal_dust_prop_buf.grain_sigma_per_gas_mass + .data[OnlyGrainSpLUT::AC_dust][i]; } - if (my_chemistry->dust_species > 1) { - internal_dust_prop_buf.sigma_per_gas_mass_tot [i] = internal_dust_prop_buf.sigma_per_gas_mass_tot [i] - + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiM_dust] [i] - + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeM_dust] [i] - + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Mg2SiO4_dust] [i] - + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Fe3O4_dust] [i] - + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiO2_dust] [i] - + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgO_dust] [i] - + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeS_dust] [i] - + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Al2O3_dust] [i]; + if (my_chemistry->dust_species > 1) { + internal_dust_prop_buf.sigma_per_gas_mass_tot[i] = + internal_dust_prop_buf.sigma_per_gas_mass_tot[i] + + internal_dust_prop_buf.grain_sigma_per_gas_mass + .data[OnlyGrainSpLUT::SiM_dust][i] + + internal_dust_prop_buf.grain_sigma_per_gas_mass + .data[OnlyGrainSpLUT::FeM_dust][i] + + internal_dust_prop_buf.grain_sigma_per_gas_mass + .data[OnlyGrainSpLUT::Mg2SiO4_dust][i] + + internal_dust_prop_buf.grain_sigma_per_gas_mass + .data[OnlyGrainSpLUT::Fe3O4_dust][i] + + internal_dust_prop_buf.grain_sigma_per_gas_mass + .data[OnlyGrainSpLUT::SiO2_dust][i] + + internal_dust_prop_buf.grain_sigma_per_gas_mass + .data[OnlyGrainSpLUT::MgO_dust][i] + + internal_dust_prop_buf.grain_sigma_per_gas_mass + .data[OnlyGrainSpLUT::FeS_dust][i] + + internal_dust_prop_buf.grain_sigma_per_gas_mass + .data[OnlyGrainSpLUT::Al2O3_dust][i]; } - if (my_chemistry->dust_species > 2) { - internal_dust_prop_buf.sigma_per_gas_mass_tot [i] = internal_dust_prop_buf.sigma_per_gas_mass_tot[i] - + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::ref_org_dust] [i] - + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::vol_org_dust] [i] - + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::H2O_ice_dust] [i]; + if (my_chemistry->dust_species > 2) { + internal_dust_prop_buf.sigma_per_gas_mass_tot[i] = + internal_dust_prop_buf.sigma_per_gas_mass_tot[i] + + internal_dust_prop_buf.grain_sigma_per_gas_mass + .data[OnlyGrainSpLUT::ref_org_dust][i] + + internal_dust_prop_buf.grain_sigma_per_gas_mass + .data[OnlyGrainSpLUT::vol_org_dust][i] + + internal_dust_prop_buf.grain_sigma_per_gas_mass + .data[OnlyGrainSpLUT::H2O_ice_dust][i]; } - + for (int idx = 0; idx < gr_N[1]; idx++) { - if (my_chemistry->dust_species > 0) { - altot(idx,i) = alMgSiO3 (idx,i) - + alAC (idx,i); + if (my_chemistry->dust_species > 0) { + altot(idx, i) = alMgSiO3(idx, i) + alAC(idx, i); } - if (my_chemistry->dust_species > 1) { - altot(idx,i) = altot (idx,i) - + alSiM (idx,i) - + alFeM (idx,i) - + alMg2SiO4 (idx,i) - + alFe3O4 (idx,i) - + alSiO2D (idx,i) - + alMgO (idx,i) - + alFeS (idx,i) - + alAl2O3 (idx,i); + if (my_chemistry->dust_species > 1) { + altot(idx, i) = altot(idx, i) + alSiM(idx, i) + alFeM(idx, i) + + alMg2SiO4(idx, i) + alFe3O4(idx, i) + + alSiO2D(idx, i) + alMgO(idx, i) + alFeS(idx, i) + + alAl2O3(idx, i); } - if (my_chemistry->dust_species > 2) { - altot(idx,i) = altot (idx,i) - + alreforg (idx,i) - + alvolorg (idx,i) - + alH2Oice (idx,i); + if (my_chemistry->dust_species > 2) { + altot(idx, i) = altot(idx, i) + alreforg(idx, i) + alvolorg(idx, i) + + alH2Oice(idx, i); } } - } } } } // namespace grackle::impl - #endif // CALC_GRAIN_SIZE_INCREMENT_1D_HPP diff --git a/src/clib/lookup_cool_rates1d.hpp b/src/clib/lookup_cool_rates1d.hpp index 3f4b20028..a989b70fb 100644 --- a/src/clib/lookup_cool_rates1d.hpp +++ b/src/clib/lookup_cool_rates1d.hpp @@ -810,11 +810,10 @@ inline void lookup_cool_rates1d( // Compute grain size increment if ((anydust != MASK_FALSE) && (my_chemistry->dust_species > 0)) { - calc_grain_size_increment_1d( - dom, idx_range, itmask_metal, my_chemistry, - my_rates->opaque_storage->grain_species_info, - my_rates->opaque_storage->inject_pathway_props, - my_fields, internal_dust_prop_scratch_buf); + calc_grain_size_increment_1d(dom, idx_range, itmask_metal, my_chemistry, + my_rates->opaque_storage->grain_species_info, + my_rates->opaque_storage->inject_pathway_props, + my_fields, internal_dust_prop_scratch_buf); } // Look-up rate for H2 formation on dust & (when relevant) grain growth rates From 1671ee3657c184341126cf8c236865750f0f5f08 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Thu, 11 Dec 2025 11:11:21 -0500 Subject: [PATCH 096/175] Refactor last part of calc_grain_size_increment_1d I was expecting this to cause gold-standard drift (but that doesn't seem to be the case) --- .../calc_grain_size_increment_1d.hpp | 128 ++++-------------- 1 file changed, 28 insertions(+), 100 deletions(-) diff --git a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp index 5f45aaecf..238a2f304 100644 --- a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp +++ b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp @@ -232,110 +232,38 @@ inline void calc_grain_size_increment_1d( // todo: can we skip this when my_chemistry->use_multiple_dust_temperatures // is not 0? - // todo: clean up to avoid explicitly mention grain species names - // -> doing this will probably require an update to the gold standard - grackle::impl::View alSiM( - internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::SiM_dust], - gr_N[1], my_fields->grid_dimension[0]); - grackle::impl::View alFeM( - internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::FeM_dust], - gr_N[1], my_fields->grid_dimension[0]); - grackle::impl::View alMg2SiO4( - internal_dust_prop_buf.grain_dyntab_kappa - .data[OnlyGrainSpLUT::Mg2SiO4_dust], - gr_N[1], my_fields->grid_dimension[0]); - grackle::impl::View alMgSiO3( - internal_dust_prop_buf.grain_dyntab_kappa - .data[OnlyGrainSpLUT::MgSiO3_dust], - gr_N[1], my_fields->grid_dimension[0]); - grackle::impl::View alFe3O4( - internal_dust_prop_buf.grain_dyntab_kappa - .data[OnlyGrainSpLUT::Fe3O4_dust], - gr_N[1], my_fields->grid_dimension[0]); - grackle::impl::View alAC( - internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::AC_dust], - gr_N[1], my_fields->grid_dimension[0]); - grackle::impl::View alSiO2D( - internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::SiO2_dust], - gr_N[1], my_fields->grid_dimension[0]); - grackle::impl::View alMgO( - internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::MgO_dust], - gr_N[1], my_fields->grid_dimension[0]); - grackle::impl::View alFeS( - internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::FeS_dust], - gr_N[1], my_fields->grid_dimension[0]); - grackle::impl::View alAl2O3( - internal_dust_prop_buf.grain_dyntab_kappa - .data[OnlyGrainSpLUT::Al2O3_dust], - gr_N[1], my_fields->grid_dimension[0]); - grackle::impl::View alreforg( - internal_dust_prop_buf.grain_dyntab_kappa - .data[OnlyGrainSpLUT::ref_org_dust], - gr_N[1], my_fields->grid_dimension[0]); - grackle::impl::View alvolorg( - internal_dust_prop_buf.grain_dyntab_kappa - .data[OnlyGrainSpLUT::vol_org_dust], - gr_N[1], my_fields->grid_dimension[0]); - grackle::impl::View alH2Oice( - internal_dust_prop_buf.grain_dyntab_kappa - .data[OnlyGrainSpLUT::H2O_ice_dust], - gr_N[1], my_fields->grid_dimension[0]); - grackle::impl::View altot(internal_dust_prop_buf.dyntab_kappa_tot, - gr_N[1], my_fields->grid_dimension[0]); + double* sigma_tot = internal_dust_prop_buf.sigma_per_gas_mass_tot; + View kappa_tab_tot(internal_dust_prop_buf.dyntab_kappa_tot, + n_log10Tdust_vals, my_fields->grid_dimension[0]); + // zero-out the current value for (int i = idx_range.i_start; i < idx_range.i_stop; i++) { - if (itmask[i] != MASK_FALSE) { - if (my_chemistry->dust_species > 0) { - internal_dust_prop_buf.sigma_per_gas_mass_tot[i] = - internal_dust_prop_buf.grain_sigma_per_gas_mass - .data[OnlyGrainSpLUT::MgSiO3_dust][i] + - internal_dust_prop_buf.grain_sigma_per_gas_mass - .data[OnlyGrainSpLUT::AC_dust][i]; - } - if (my_chemistry->dust_species > 1) { - internal_dust_prop_buf.sigma_per_gas_mass_tot[i] = - internal_dust_prop_buf.sigma_per_gas_mass_tot[i] + - internal_dust_prop_buf.grain_sigma_per_gas_mass - .data[OnlyGrainSpLUT::SiM_dust][i] + - internal_dust_prop_buf.grain_sigma_per_gas_mass - .data[OnlyGrainSpLUT::FeM_dust][i] + - internal_dust_prop_buf.grain_sigma_per_gas_mass - .data[OnlyGrainSpLUT::Mg2SiO4_dust][i] + - internal_dust_prop_buf.grain_sigma_per_gas_mass - .data[OnlyGrainSpLUT::Fe3O4_dust][i] + - internal_dust_prop_buf.grain_sigma_per_gas_mass - .data[OnlyGrainSpLUT::SiO2_dust][i] + - internal_dust_prop_buf.grain_sigma_per_gas_mass - .data[OnlyGrainSpLUT::MgO_dust][i] + - internal_dust_prop_buf.grain_sigma_per_gas_mass - .data[OnlyGrainSpLUT::FeS_dust][i] + - internal_dust_prop_buf.grain_sigma_per_gas_mass - .data[OnlyGrainSpLUT::Al2O3_dust][i]; - } - if (my_chemistry->dust_species > 2) { - internal_dust_prop_buf.sigma_per_gas_mass_tot[i] = - internal_dust_prop_buf.sigma_per_gas_mass_tot[i] + - internal_dust_prop_buf.grain_sigma_per_gas_mass - .data[OnlyGrainSpLUT::ref_org_dust][i] + - internal_dust_prop_buf.grain_sigma_per_gas_mass - .data[OnlyGrainSpLUT::vol_org_dust][i] + - internal_dust_prop_buf.grain_sigma_per_gas_mass - .data[OnlyGrainSpLUT::H2O_ice_dust][i]; + sigma_tot[i] = 0.0; + } + + for (int i = idx_range.i_start; i < idx_range.i_stop; i++) { + for (int idx = 0; idx < n_log10Tdust_vals; idx++) { + kappa_tab_tot(idx, i) = 0.0; + } + } + + // todo: get rid of the itmask check (it shouldn't be necessary here) + for (int grsp_i = 0; grsp_i < grain_species_info->n_species; grsp_i++) { + const double* cur_grsp_sigma = + internal_dust_prop_buf.grain_sigma_per_gas_mass.data[grsp_i]; + for (int i = idx_range.i_start; i < idx_range.i_stop; i++) { + if (itmask[i] != MASK_FALSE) { + sigma_tot[i] += cur_grsp_sigma[i]; } + } - for (int idx = 0; idx < gr_N[1]; idx++) { - if (my_chemistry->dust_species > 0) { - altot(idx, i) = alMgSiO3(idx, i) + alAC(idx, i); - } - if (my_chemistry->dust_species > 1) { - altot(idx, i) = altot(idx, i) + alSiM(idx, i) + alFeM(idx, i) + - alMg2SiO4(idx, i) + alFe3O4(idx, i) + - alSiO2D(idx, i) + alMgO(idx, i) + alFeS(idx, i) + - alAl2O3(idx, i); - } - if (my_chemistry->dust_species > 2) { - altot(idx, i) = altot(idx, i) + alreforg(idx, i) + alvolorg(idx, i) + - alH2Oice(idx, i); + const double* tmp = internal_dust_prop_buf.grain_dyntab_kappa.data[grsp_i]; + View cur_grsp_kappa_tab(tmp, n_log10Tdust_vals, + my_fields->grid_dimension[0]); + for (int i = idx_range.i_start; i < idx_range.i_stop; i++) { + if (itmask[i] != MASK_FALSE) { + for (int idx = 0; idx < n_log10Tdust_vals; idx++) { + kappa_tab_tot(idx, i) += cur_grsp_kappa_tab(idx, i); } } } From c2b7da0c7835f9bbdf9c718cfcde600b86220e73 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Thu, 11 Dec 2025 12:02:08 -0500 Subject: [PATCH 097/175] Only load needed injection pathway data Previously, if we used metal chemistry, we loaded all injection pathway data. Now we just load what we need. Relatedly, when we index into an array and each member corresponds to a distinct injection pathway, index 0 is now always valid. For context, when my_chemistry->multi_metals is 0, we would historically need to access the relvant data at the index specified by my_chemistry->metal_abundances. --- .../calc_grain_size_increment_1d.hpp | 5 +- .../inject_model/inject_path_field_pack.hpp | 52 +++++++---------- src/clib/inject_model/load_data.cpp | 56 +++++++++++++------ src/clib/make_consistent.cpp | 14 ++--- 4 files changed, 67 insertions(+), 60 deletions(-) diff --git a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp index 238a2f304..a0a1976e5 100644 --- a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp +++ b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp @@ -132,11 +132,8 @@ inline void calc_grain_size_increment_1d( InjectPathFieldPack inject_path_metal_densities = setup_InjectPathFieldPack(my_chemistry, my_fields); - int start = inject_path_metal_densities.start_idx; - int stop = inject_path_metal_densities.stop_idx; - // make arrays - for (int count = start; count < stop; count++) { + for (int count = 0; count < n_pathways; count++) { // when my_chemistry->multi_metals == 0, inj_path_metal_dens wraps // the same pointer as `metal` diff --git a/src/clib/inject_model/inject_path_field_pack.hpp b/src/clib/inject_model/inject_path_field_pack.hpp index 0dd2526fd..4992045db 100644 --- a/src/clib/inject_model/inject_path_field_pack.hpp +++ b/src/clib/inject_model/inject_path_field_pack.hpp @@ -21,13 +21,9 @@ namespace grackle::impl { /// /// I have some ideas that will let us dispose of this type in the near future. struct InjectPathFieldPack { - /// Specifies the bounds for a for-loop that you would use to iterate over - /// all relevant injection model density fields that are present in fields - /// - /// @todo - /// Some changes are required before we can safely assume that start_idx is - /// always 0 - int start_idx, stop_idx; + /// Specifies the number of injection pathways that should have data in + /// the fields member. + int n_fields; /// holds pointers to the various injection model density fields const gr_float* fields[inj_model_input::N_Injection_Pathways]; @@ -37,38 +33,32 @@ struct InjectPathFieldPack { inline InjectPathFieldPack setup_InjectPathFieldPack( const chemistry_data* my_chem, const grackle_field_data* my_fields) { if ((my_chem->metal_chemistry > 0) && (my_chem->multi_metals == 1)) { - return InjectPathFieldPack{ - /* start_idx = */ 0, - /* stop_idx = */ inj_model_input::N_Injection_Pathways, - /* fields = */ - { - my_fields->local_ISM_metal_density, - my_fields->ccsn13_metal_density, - my_fields->ccsn20_metal_density, - my_fields->ccsn25_metal_density, - my_fields->ccsn30_metal_density, - my_fields->fsn13_metal_density, - my_fields->fsn15_metal_density, - my_fields->fsn50_metal_density, - my_fields->fsn80_metal_density, - my_fields->pisn170_metal_density, - my_fields->pisn200_metal_density, - my_fields->y19_metal_density, - }}; + return InjectPathFieldPack{inj_model_input::N_Injection_Pathways, + { + my_fields->local_ISM_metal_density, + my_fields->ccsn13_metal_density, + my_fields->ccsn20_metal_density, + my_fields->ccsn25_metal_density, + my_fields->ccsn30_metal_density, + my_fields->fsn13_metal_density, + my_fields->fsn15_metal_density, + my_fields->fsn50_metal_density, + my_fields->fsn80_metal_density, + my_fields->pisn170_metal_density, + my_fields->pisn200_metal_density, + my_fields->y19_metal_density, + }}; } InjectPathFieldPack out; + out.n_fields = 0; for (int i = 0; i < inj_model_input::N_Injection_Pathways; i++) { out.fields[i] = nullptr; } if ((my_chem->metal_chemistry > 0) && (my_chem->multi_metals == 0)) { - out.start_idx = my_chem->metal_abundances; - out.stop_idx = out.start_idx + 1; - out.fields[my_chem->metal_abundances] = my_fields->metal_density; - } else { - out.start_idx = 0; - out.stop_idx = out.start_idx; + out.n_fields = 1; + out.fields[0] = my_fields->metal_density; } return out; diff --git a/src/clib/inject_model/load_data.cpp b/src/clib/inject_model/load_data.cpp index ed3af2408..b39768da7 100644 --- a/src/clib/inject_model/load_data.cpp +++ b/src/clib/inject_model/load_data.cpp @@ -81,11 +81,6 @@ struct SetupCallbackCtx { /// maps the names of known injection pathways to a unique index /// - /// The callback function reports an error if an injection is encountered - /// that has a name that isn't included in this map. Furthermore, data is - /// organized within GrainMetalInjectPathways according to the order of keys - /// in this map. - /// /// @par Why This Is Needed /// For some background context: /// - to make use of the injection pathway information, Grackle requires @@ -100,8 +95,12 @@ struct SetupCallbackCtx { /// Before any functionality involving injection pathways is included in a /// public release of Grackle, the plan is to stop hard-coding the names of /// injection pathway density fields, and to load in injection pathway data - /// from HDF5 files. At that point, we'll need to tweak the callback function - /// to load in data for models with arbitrary names. + /// from HDF5 files. + /// - At that point, we'll need to tweak the callback function to load in + /// data for models with arbitrary names. + /// - I suspect that we'll want to adopt a policy for ensuring that the order + /// of models is well-defined (to make results bitwise reproducible). In + /// that scenario, we might use this to enforce an alphanumberic ordering const grackle::impl::FrozenKeyIdxBiMap* inj_path_names; /// maps the names of the grain species for which data will be loaded to the @@ -135,8 +134,7 @@ extern "C" int setup_yield_table_callback( int pathway_idx = static_cast( FrozenKeyIdxBiMap_idx_from_key(my_ctx->inj_path_names, name)); if (pathway_idx == static_cast(bimap::invalid_val)) { - return GrPrintAndReturnErr("`%s` is an unexpected injection pathway name", - name); + return GR_SUCCESS; } // load the object that we update with the data we read @@ -263,15 +261,41 @@ int grackle::impl::load_inject_path_data(const chemistry_data* my_chemistry, return GR_SUCCESS; } - // construct a mapping of all known models - // -> in the future, we are going to move away from this hardcoded approach - // -> since the strings are statically allocates, the map won't make copies - // of the strings - constexpr int n_pathways = - static_cast(sizeof(known_inj_path_names) / sizeof(char*)); + // an upper bound on the number of allowed injection pathways + int max_n_pathways = grackle::impl::inj_model_input::N_Injection_Pathways; + + // get the list of injection pathways + // -> currently this requires us to look at the my_chemistry->multi_metals + // and my_chemstry->metal_abundances variables. + // -> when we move away from hardcoded names and start loading from HDF5, + // we'll remove these variables + const char* const* inj_path_name_l = nullptr; + int n_pathways = 0; + bool valid_metal_abundances = + ((0 <= my_chemistry->metal_abundances) && + (my_chemistry->metal_abundances < max_n_pathways)); + + if ((my_chemistry->multi_metals == 0) && !valid_metal_abundances) { + return GrPrintAndReturnErr( + "the metal_abundances parameter must not be negative or exceed %d", + max_n_pathways - 1); + } else if (my_chemistry->multi_metals == 0) { + inj_path_name_l = known_inj_path_names + my_chemistry->metal_abundances; + n_pathways = 1; + } else if (my_chemistry->multi_metals == 1) { + inj_path_name_l = known_inj_path_names; + n_pathways = max_n_pathways; + } else { + return GrPrintAndReturnErr("the multi_metals parameter isn't 0 or 1"); + } + // construct a mapping of the injection pathway names + // -> right now, since the strings are statically allocated, we use + // BiMapMode::REFS_KEYDATA to instruct the map to avoid making copies. + // -> In the future, when model names are dynamically specified by an HDF5 + // file, we'll need to use BiMapMode::COPIES_KEYDATA. FrozenKeyIdxBiMap inj_path_names = new_FrozenKeyIdxBiMap( - known_inj_path_names, n_pathways, BiMapMode::REFS_KEYDATA); + inj_path_name_l, n_pathways, BiMapMode::REFS_KEYDATA); if (!FrozenKeyIdxBiMap_is_ok(&inj_path_names)) { return GrPrintAndReturnErr( "there was a problem building the map of model names"); diff --git a/src/clib/make_consistent.cpp b/src/clib/make_consistent.cpp index 8d520497e..10fa44741 100644 --- a/src/clib/make_consistent.cpp +++ b/src/clib/make_consistent.cpp @@ -215,8 +215,8 @@ void make_consistent( // total metal density that corresponds to an injection pathway grackle::impl::View SN_metal_arr[inj_model_input::N_Injection_Pathways]; - // declare variables used to hold bounds for iterating over SN_metal_arr - int inj_path_idx_start, inj_path_idx_stop; + + int n_pathways = 0; // construct view of each specified injection pathway metal density field if (my_chemistry->metal_chemistry > 0) { @@ -226,17 +226,13 @@ void make_consistent( // my_fields->metal_density is **NOT** mutated by this function. InjectPathFieldPack p = setup_InjectPathFieldPack(my_chemistry, my_fields); - inj_path_idx_start = p.start_idx; - inj_path_idx_stop = p.stop_idx; + n_pathways = inject_pathway_props->n_pathways; - for (int iSN = inj_path_idx_start; iSN < inj_path_idx_stop; iSN++) { + for (int iSN = 0; iSN < n_pathways; iSN++) { SN_metal_arr[iSN] = grackle::impl::View( p.fields[iSN], my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); } - } else { - inj_path_idx_start = 0; - inj_path_idx_stop = 0; } std::vector Ct(my_fields->grid_dimension[0]); @@ -353,7 +349,7 @@ void make_consistent( Sg[i] = 0.; Fet[i] = 0.; Feg[i] = 0.; - for (int iSN = inj_path_idx_start; iSN < inj_path_idx_stop; iSN++) { + for (int iSN = 0; iSN < n_pathways; iSN++) { gr_float cur_val = SN_metal_arr[iSN](i, j, k); Ct[i] = Ct[i] + total_metal_yields.C[iSN] * cur_val; From e4df3f914b2dc47af7ab79e7c6530d3d0a2f9e1c Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Fri, 19 Dec 2025 08:22:14 -0500 Subject: [PATCH 098/175] address compiler warning in chemistry_solver_funcs.hppp --- src/clib/chemistry_solver_funcs.hpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/clib/chemistry_solver_funcs.hpp b/src/clib/chemistry_solver_funcs.hpp index f36db0a7f..ad3f8a760 100644 --- a/src/clib/chemistry_solver_funcs.hpp +++ b/src/clib/chemistry_solver_funcs.hpp @@ -1,6 +1,11 @@ -// See LICENSE file for license and copyright information - -/// @file chemistry_solver_funcs.hpp +//===----------------------------------------------------------------------===// +// +// See the LICENSE file for license and copyright information +// SPDX-License-Identifier: NCSA AND BSD-3-Clause +// +//===----------------------------------------------------------------------===// +/// +/// @file /// @brief Defines chemistry reaction related functions invoked by the /// grackle solver in order to integrate the species densities over time. /// @@ -14,6 +19,8 @@ /// be decoupled from the derivative calculation for primoridial species /// - it may also make sense to further divide logic by the kinds of species /// that are affected (e.g. primordial vs grains) +/// +//===----------------------------------------------------------------------===// #ifndef CHEMISTRY_SOLVER_FUNCS_HPP #define CHEMISTRY_SOLVER_FUNCS_HPP @@ -579,7 +586,9 @@ inline void species_density_updates_gauss_seidel( if ( (my_chemistry->metal_chemistry == 1) && (itmask_metal[i] != MASK_FALSE) ) { - scoef = scoef; + // we comment out the following line that assigns scoef to itself since + // it has no practical impact and produces a compiler warning + // scoef = scoef; acoef = acoef + kcol_buf.data[CollisionalRxnLUT::kz44][i] * CII(i,j,k) / 12. + kcol_buf.data[CollisionalRxnLUT::kz45][i] * OII(i,j,k) / 16. @@ -1932,7 +1941,9 @@ inline void species_density_derivatives_0d( if ((my_chemistry->metal_chemistry == 1) && (itmask_metal[0] != MASK_FALSE)) { - scoef = scoef; + // we comment out the following line that assigns scoef to itself since + // it has no practical impact and produces a compiler warning + // scoef = scoef; acoef = acoef + kcr_buf.data[CollisionalRxnLUT::kz44][0] * CII / 12. + kcr_buf.data[CollisionalRxnLUT::kz45][0] * OII / 16. From e2ea0d925f6ec099cb9348fbb9675eeb5cc1f263 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Fri, 19 Dec 2025 08:23:58 -0500 Subject: [PATCH 099/175] address warning about uninitialized variables in solve_rate_cool_g-cpp.cpp --- src/clib/solve_rate_cool_g-cpp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clib/solve_rate_cool_g-cpp.cpp b/src/clib/solve_rate_cool_g-cpp.cpp index f96243f58..bde08114e 100644 --- a/src/clib/solve_rate_cool_g-cpp.cpp +++ b/src/clib/solve_rate_cool_g-cpp.cpp @@ -791,7 +791,7 @@ int solve_rate_cool_g( // declare 2 variables (primarily used for subcycling, but also used in // error reporting) int iter; - double ttmin; + double ttmin = huge8; // ------------------ Loop over subcycles ---------------- From 9ff4b3ad7d13286bdb3141560969044dae6ac145 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Thu, 18 Dec 2025 11:00:53 -0500 Subject: [PATCH 100/175] mv testing utility library from tests/unit to tests/grtestutils --- .clang-format-ignore | 14 +-- tests/CMakeLists.txt | 1 + tests/grtestutils/CMakeLists.txt | 108 ++++++++++++++++++ tests/grtestutils/README.md | 3 + .../grtest_cmd.cpp => grtestutils/cmd.cpp} | 2 +- .../grtest_cmd.hpp => grtestutils/cmd.hpp} | 0 .../googletest/check_allclose.hpp} | 0 .../grtest_os.cpp => grtestutils/os.cpp} | 2 +- .../grtest_os.hpp => grtestutils/os.hpp} | 0 .../utils.cpp} | 2 +- .../utils.hpp} | 0 tests/unit/CMakeLists.txt | 60 +--------- tests/unit/test_chemistry_struct_synced.cpp | 2 +- tests/unit/test_ghost_zone.cpp | 2 +- tests/unit/test_linalg.cpp | 2 +- tests/unit/test_status_reporting.cpp | 2 +- 16 files changed, 132 insertions(+), 68 deletions(-) create mode 100644 tests/grtestutils/CMakeLists.txt create mode 100644 tests/grtestutils/README.md rename tests/{unit/grtest_cmd.cpp => grtestutils/cmd.cpp} (98%) rename tests/{unit/grtest_cmd.hpp => grtestutils/cmd.hpp} (100%) rename tests/{unit/utest_helpers.hpp => grtestutils/googletest/check_allclose.hpp} (100%) rename tests/{unit/grtest_os.cpp => grtestutils/os.cpp} (99%) rename tests/{unit/grtest_os.hpp => grtestutils/os.hpp} (100%) rename tests/{unit/grtest_utils.cpp => grtestutils/utils.cpp} (98%) rename tests/{unit/grtest_utils.hpp => grtestutils/utils.hpp} (100%) diff --git a/.clang-format-ignore b/.clang-format-ignore index f6fca214f..0072faee9 100644 --- a/.clang-format-ignore +++ b/.clang-format-ignore @@ -64,17 +64,17 @@ src/include/grackle_float.h.in src/include/grackle_misc.h src/include/grackle_rate_functions.h src/include/grackle_types.h -tests/unit/grtest_cmd.cpp -tests/unit/grtest_cmd.hpp -tests/unit/grtest_os.cpp -tests/unit/grtest_os.hpp -tests/unit/grtest_utils.cpp -tests/unit/grtest_utils.hpp +tests/grtestutils/cmd.cpp +tests/grtestutils/cmd.hpp +tests/grtestutils/os.cpp +tests/grtestutils/os.hpp +tests/grtestutils/utils.cpp +tests/grtestutils/utils.hpp +tests/grtestutils/googletest/check_allclose.hpp tests/unit/test_chemistry_struct_synced.cpp tests/unit/test_ghost_zone.cpp tests/unit/test_interpolators_comparisons.cpp tests/unit/test_linalg.cpp tests/unit/test_status_reporting.cpp tests/unit/test_unit_interpolators_g.cpp -tests/unit/utest_helpers.hpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0af865f10..2320c1c58 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,3 +1,4 @@ +add_subdirectory(grtestutils) add_subdirectory(unit) # down below, we add tests for various code-examples diff --git a/tests/grtestutils/CMakeLists.txt b/tests/grtestutils/CMakeLists.txt new file mode 100644 index 000000000..cd21e6065 --- /dev/null +++ b/tests/grtestutils/CMakeLists.txt @@ -0,0 +1,108 @@ +# Purpose: Defines 2 "libraries" to aid with the testing of Grackle +# ================================================================= + +# 1. testdeps: bundles dependencies used by all tests +# =================================================== +# - this is an interface library (i.e. nothing is compiled) that ONLY exists +# to aggregate dependencies, include directories and compile definitions +# - in other words, a basic unit test (that doesn't require logic from +# grtestutils can list this as its sole dependency) + +add_library(testdeps INTERFACE) +target_link_libraries(testdeps INTERFACE Grackle::Grackle GTest::gtest_main) + +# compiler defs are short-term hacks to help tests invoke internal functions +# from Grackle (both of these will become unnecessary in the near future) +target_compile_definitions(testdeps + # currently needed to invoke the fortran function wrappers from within clib + INTERFACE "$<$:LINUX>" + # suppresses warnings about C internal headers using our deprecated public + # headers (the files should include grackle.h instead). We're currently + # holding off on properly fixing this to minimize conflicts with pending PRs + # on the newchem-cpp branch + INTERFACE GRIMPL_PUBLIC_INCLUDE=1 +) + +# needed to let tests call internal functions from src/clib +target_include_directories(testdeps INTERFACE ${PROJECT_SOURCE_DIR}/src/clib) +target_compile_features(testdeps INTERFACE cxx_std_17) + + +# 2. grtestutils: testing utility library +# ======================================= +# - this is an internal library that defines reusable testing utilities +# - Frankly, I don't love the name. Originally I called it grtest, but I'm a +# a little concerned that may look a little too much like gtest (i.e. the +# shorthand that googletest uses. + +# Code Organization +# ----------------- +# This code in this directory is organized in a slightly peculiar manner +# - code in the main directory should not depend upon googletest +# - the googletest subdirectory is intended to define custom googletest +# assertions and fixtures. This subdirectory should **ONLY** include +# headers (so that, at most, this internal library has a transitive +# dependence on googletest) +# +# RATIONALE: +# - over time, the idea has been floated to introducing C++ logic to +# accelerate certain calculations provided by the python wrapper: +# - PR #343 proposed creating a C++ accelerated harness for performing +# certain kinds of semi-analytic calculations (like freefall or evolving +# constant density) +# - PR #370 proposed introducing a function to infer the internal energy at +# a desired temperature (yes, the PR proposes it as a python function, but +# it would be faster as a C++ function). +# - Relatedly, it would also be useful to be able to directly compute +# temperature or chemical equilibrium +# - in each case this functionality would also be extremely useful for the +# googletest framework or for writing simple C++-only benchmarking programs +# - this is extremely useful if you want to use tools like valgrind or +# compiler sanitizers. While it's generally possible to use these tools in +# a python extension module, it may require compiling CPython itself from +# source. Moreover it can be extremely slow (these tools introduce to +# basic C/C++ operations and that overhead will be apply to the Python +# interpretter) +# - this is important if we want to test grackle when compiled with various +# backends. Historically, the python bindings have never been able to use +# Grackle with the OpenMP backend. While we can and will address this, +# there will additional challenges as we introduce GPU acceleration +# - this library is intended as a location where that kind of hypothetical +# functionality can be introduced, and organization strategy ensures that +# it will be straightforward to provide this hypothetical functionality to +# the python bindings without it depending upon googletest (i.e. we may +# treat the googletest subdirectory as a distinct interface library) + +add_library(grtestutils + cmd.hpp cmd.cpp + utils.hpp utils.cpp + os.hpp os.cpp + + # REMINDER: the googletest subdirectory should only contain headers + googletest/check_allclose.hpp +) + +# we are being a little lazy with our usage of testdeps right here +target_link_libraries(grtestutils PUBLIC testdeps) +target_compile_features(grtestutils PUBLIC cxx_std_17) + +# configure the grtestutils target so that when a file outside of this +# directory includes a header from within this directory, the include +# directive looks something like: +# #include "grtestutils/.hpp" +# OR +# #include "grtestutils/googletest/.hpp +target_include_directories(grtestutils INTERFACE ${PROJECT_SOURCE_DIR}/tests) + +# these compile-definitions act as short-term hacks +target_compile_definitions(grtestutils + # this hack helps us get the path to the directory holding data files (we can + # remove it once we introduce automatic file management in PR 235, PR 237, + # and PR 246) + PRIVATE GR_DATADIR=${CMAKE_CURRENT_SOURCE_DIR}/../../grackle_data_files/input/ + + # this hack lets us use Operating-system specific functionality (Once PR #237 + # is merged, we should make use of the machinery introduced by that PR for + # enabling/disabling os-specific features) + PRIVATE "$<$:PLATFORM_GENERIC_UNIX>" +) diff --git a/tests/grtestutils/README.md b/tests/grtestutils/README.md new file mode 100644 index 000000000..d7d59171f --- /dev/null +++ b/tests/grtestutils/README.md @@ -0,0 +1,3 @@ +Defines a simple testing utility library. + +See the CMakeLists.txt for a discussion of code organization. diff --git a/tests/unit/grtest_cmd.cpp b/tests/grtestutils/cmd.cpp similarity index 98% rename from tests/unit/grtest_cmd.cpp rename to tests/grtestutils/cmd.cpp index 131fa158b..700cafa01 100644 --- a/tests/unit/grtest_cmd.cpp +++ b/tests/grtestutils/cmd.cpp @@ -1,4 +1,4 @@ -#include "grtest_cmd.hpp" +#include "cmd.hpp" #include // FILE, fgets, fprintf, stderr, (popen/pclose on POSIX) diff --git a/tests/unit/grtest_cmd.hpp b/tests/grtestutils/cmd.hpp similarity index 100% rename from tests/unit/grtest_cmd.hpp rename to tests/grtestutils/cmd.hpp diff --git a/tests/unit/utest_helpers.hpp b/tests/grtestutils/googletest/check_allclose.hpp similarity index 100% rename from tests/unit/utest_helpers.hpp rename to tests/grtestutils/googletest/check_allclose.hpp diff --git a/tests/unit/grtest_os.cpp b/tests/grtestutils/os.cpp similarity index 99% rename from tests/unit/grtest_os.cpp rename to tests/grtestutils/os.cpp index eba65b404..bbcd4538e 100644 --- a/tests/unit/grtest_os.cpp +++ b/tests/grtestutils/os.cpp @@ -1,4 +1,4 @@ -#include "grtest_os.hpp" +#include "os.hpp" // the following 2 headers are the c versions of the headers (rather than the // C++ versions) since it seems more likely that posix-specific functions are diff --git a/tests/unit/grtest_os.hpp b/tests/grtestutils/os.hpp similarity index 100% rename from tests/unit/grtest_os.hpp rename to tests/grtestutils/os.hpp diff --git a/tests/unit/grtest_utils.cpp b/tests/grtestutils/utils.cpp similarity index 98% rename from tests/unit/grtest_utils.cpp rename to tests/grtestutils/utils.cpp index 85557d7af..d4781249f 100644 --- a/tests/unit/grtest_utils.cpp +++ b/tests/grtestutils/utils.cpp @@ -1,4 +1,4 @@ -#include "grtest_utils.hpp" +#include "utils.hpp" #include diff --git a/tests/unit/grtest_utils.hpp b/tests/grtestutils/utils.hpp similarity index 100% rename from tests/unit/grtest_utils.hpp rename to tests/grtestutils/utils.hpp diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index f1018e3ca..6bac6b918 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -1,60 +1,12 @@ -# declare testdeps to bundle together dependencies used by all tests -# ------------------------------------------------------------------ -add_library(testdeps INTERFACE) -target_link_libraries(testdeps INTERFACE Grackle::Grackle GTest::gtest_main) +# NOTE: the grtestutils and testdeps library targets are both defined within +# ../grtestutils/CMakeLists.txt -# compiler defs are short-term hacks to help tests invoke internal functions -# from Grackle (both of these will become unnecessary in the near future) -target_compile_definitions(testdeps - # needed to invoke Fortran functions from C - INTERFACE "$<$:LINUX>" - # suppresses warnings about C internal headers using our deprecated public - # headers (the files should include grackle.h instead). We're currently - # holding off on properly fixing this to minimize conflicts with pending PRs - # on the newchem-cpp branch - INTERFACE GRIMPL_PUBLIC_INCLUDE=1 -) - -# needed to let tests call internal functions from C -target_include_directories(testdeps INTERFACE ${PROJECT_SOURCE_DIR}/src/clib) -target_compile_features(testdeps INTERFACE cxx_std_17) - -# declare the grtest utility library -# ---------------------------------- -# -> this is an internal library that defines reusable testing utilities -# -> if we add more files to this library, we should consider relocating the -# library to a different directory - -add_library(grtest_utils - grtest_cmd.hpp grtest_cmd.cpp - grtest_utils.hpp grtest_utils.cpp - grtest_os.hpp grtest_os.cpp -) -# we are being a little lazy with our usage of testdeps right here -target_link_libraries(grtest_utils PUBLIC testdeps) -target_compile_features(grtest_utils PUBLIC cxx_std_17) - -# these compile-definitions act as short-term hacks -target_compile_definitions(grtest_utils - # this hack helps us get path input-file directory (we can remove it once we - # introduce automatic file management in PR 235, PR 237, and PR 246) - PRIVATE GR_DATADIR=${CMAKE_CURRENT_SOURCE_DIR}/../../grackle_data_files/input/ - - # this hack lets us use Operating-system specific functionality (Once PR #237 - # is merged, we should make use of the machinery introduced by that PR for - # enabling/disabling os-specific features) - PRIVATE "$<$:PLATFORM_GENERIC_UNIX>" -) - -# start declaring targets for tests -# --------------------------------- add_executable(runInterpolationTests test_unit_interpolators_g.cpp) target_link_libraries(runInterpolationTests testdeps) - gtest_discover_tests(runInterpolationTests) add_executable(runLinAlgTests test_linalg.cpp) -target_link_libraries(runLinAlgTests testdeps) +target_link_libraries(runLinAlgTests grtestutils) gtest_discover_tests(runLinAlgTests) add_executable(runGrainSpeciesIntoTests test_grain_species_info.cpp) @@ -62,7 +14,7 @@ target_link_libraries(runGrainSpeciesIntoTests testdeps) gtest_discover_tests(runGrainSpeciesIntoTests) add_executable(runStatusReporting test_status_reporting.cpp) -target_link_libraries(runStatusReporting grtest_utils) +target_link_libraries(runStatusReporting grtestutils) gtest_discover_tests(runStatusReporting) # one might argue that the following is more of an integration or end-to-end @@ -74,7 +26,7 @@ gtest_discover_tests(runVisitorTests) # one might argue that the following is more of an integration or end-to-end # test than a unit-test add_executable(runGhostZoneTests test_ghost_zone.cpp) -target_link_libraries(runGhostZoneTests grtest_utils testdeps) +target_link_libraries(runGhostZoneTests grtestutils testdeps) gtest_discover_tests(runGhostZoneTests) # this target tests that the members of the chemistry_data struct can be @@ -84,7 +36,7 @@ gtest_discover_tests(runGhostZoneTests) # problems for "death-tests", so these test-cases should remain separate from # the rest of the gtest framework add_executable(runSyncedChemistryData test_chemistry_struct_synced.cpp) -target_link_libraries(runSyncedChemistryData grtest_utils testdeps) +target_link_libraries(runSyncedChemistryData grtestutils testdeps) target_compile_definitions(runSyncedChemistryData PRIVATE READER_PATH=${PROJECT_SOURCE_DIR}/tests/scripts/castxml_output_reader.py diff --git a/tests/unit/test_chemistry_struct_synced.cpp b/tests/unit/test_chemistry_struct_synced.cpp index 6a3bd9642..ee02a02bb 100644 --- a/tests/unit/test_chemistry_struct_synced.cpp +++ b/tests/unit/test_chemistry_struct_synced.cpp @@ -1,4 +1,4 @@ -#include "grtest_cmd.hpp" +#include "grtestutils/cmd.hpp" #include diff --git a/tests/unit/test_ghost_zone.cpp b/tests/unit/test_ghost_zone.cpp index b009fbe7b..607da2325 100644 --- a/tests/unit/test_ghost_zone.cpp +++ b/tests/unit/test_ghost_zone.cpp @@ -24,7 +24,7 @@ #include #include -#include "grtest_utils.hpp" +#include "grtestutils/utils.hpp" #include diff --git a/tests/unit/test_linalg.cpp b/tests/unit/test_linalg.cpp index 943b83d75..d3fb7d080 100644 --- a/tests/unit/test_linalg.cpp +++ b/tests/unit/test_linalg.cpp @@ -2,7 +2,7 @@ #include #include "fortran_func_wrappers.hpp" -#include "utest_helpers.hpp" +#include "grtestutils/googletest/check_allclose.hpp" /// Records the paramters for a linear algebra test-case diff --git a/tests/unit/test_status_reporting.cpp b/tests/unit/test_status_reporting.cpp index 1922fef2a..91ce3791c 100644 --- a/tests/unit/test_status_reporting.cpp +++ b/tests/unit/test_status_reporting.cpp @@ -12,7 +12,7 @@ #include "grackle.h" // GR_FAIL #include "status_reporting.h" -#include "grtest_os.hpp" +#include "grtestutils/os.hpp" testing::AssertionResult ContainsFormattedMessage_(int n) { From b5b7e65e1461923b944031514e2efa3b299f4536 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Thu, 18 Dec 2025 12:47:21 -0500 Subject: [PATCH 101/175] slightly alter we define targets that support testing --- tests/grtestutils/CMakeLists.txt | 83 +++++++++++++++++++++----------- tests/unit/CMakeLists.txt | 11 ++--- 2 files changed, 61 insertions(+), 33 deletions(-) diff --git a/tests/grtestutils/CMakeLists.txt b/tests/grtestutils/CMakeLists.txt index cd21e6065..42675d148 100644 --- a/tests/grtestutils/CMakeLists.txt +++ b/tests/grtestutils/CMakeLists.txt @@ -1,20 +1,16 @@ -# Purpose: Defines 2 "libraries" to aid with the testing of Grackle -# ================================================================= +# Purpose: define "libraries" to aid with the testing of Grackle +# ============================================================== -# 1. testdeps: bundles dependencies used by all tests -# =================================================== -# - this is an interface library (i.e. nothing is compiled) that ONLY exists -# to aggregate dependencies, include directories and compile definitions -# - in other words, a basic unit test (that doesn't require logic from -# grtestutils can list this as its sole dependency) +# first, define an interface "library" (i.e. nothing is compiled) for +# book-keeping purposes. dependents get "linked" against this library in order +# to be able to access grackle's internal functionality -add_library(testdeps INTERFACE) -target_link_libraries(testdeps INTERFACE Grackle::Grackle GTest::gtest_main) +add_library(_grackle_internals INTERFACE) +target_link_libraries(_grackle_internals INTERFACE Grackle::Grackle) -# compiler defs are short-term hacks to help tests invoke internal functions -# from Grackle (both of these will become unnecessary in the near future) -target_compile_definitions(testdeps - # currently needed to invoke the fortran function wrappers from within clib +# short-term macro definitions (both will become unnecessary in the near future) +target_compile_definitions(_grackle_internals + # currently required for functions declared by fortran_func_wrappers.hpp INTERFACE "$<$:LINUX>" # suppresses warnings about C internal headers using our deprecated public # headers (the files should include grackle.h instead). We're currently @@ -23,17 +19,24 @@ target_compile_definitions(testdeps INTERFACE GRIMPL_PUBLIC_INCLUDE=1 ) -# needed to let tests call internal functions from src/clib -target_include_directories(testdeps INTERFACE ${PROJECT_SOURCE_DIR}/src/clib) -target_compile_features(testdeps INTERFACE cxx_std_17) - +# this makes it possible to write an include-directive of a header from +# src/clib, by writing something like +# #include "{name}.hpp" +# where {name} is replaced by the name of the header +# -> frankly, I don't love this because it's not immediately clear that we are +# including a private header. The alternative is to require the paths +# in the include directives to include the name of the directory holding +# the implementation files (e.g. "clib/{header}.hpp") +target_include_directories(_grackle_internals + INTERFACE ${PROJECT_SOURCE_DIR}/src/clib +) -# 2. grtestutils: testing utility library -# ======================================= +# grtestutils: testing utility library +# ==================================== # - this is an internal library that defines reusable testing utilities # - Frankly, I don't love the name. Originally I called it grtest, but I'm a # a little concerned that may look a little too much like gtest (i.e. the -# shorthand that googletest uses. +# shorthand that googletest uses). # Code Organization # ----------------- @@ -68,22 +71,32 @@ target_compile_features(testdeps INTERFACE cxx_std_17) # Grackle with the OpenMP backend. While we can and will address this, # there will additional challenges as we introduce GPU acceleration # - this library is intended as a location where that kind of hypothetical -# functionality can be introduced, and organization strategy ensures that +# functionality can be introduced. The organization strategy ensures that # it will be straightforward to provide this hypothetical functionality to -# the python bindings without it depending upon googletest (i.e. we may -# treat the googletest subdirectory as a distinct interface library) +# the python bindings (and any C++ testing code) without making the python +# bindings link against googletest. add_library(grtestutils + # files outside of the googletest subdirectory + # -> these shouldn't include headers from the googletest subdirectory cmd.hpp cmd.cpp utils.hpp utils.cpp os.hpp os.cpp - # REMINDER: the googletest subdirectory should only contain headers + # files in the googletest subdirectory (reminder: should just be headers!) googletest/check_allclose.hpp ) -# we are being a little lazy with our usage of testdeps right here -target_link_libraries(grtestutils PUBLIC testdeps) +target_link_libraries(grtestutils + PRIVATE _grackle_internals + PUBLIC Grackle::Grackle + # to express the transitive dependency on googletest (it's transitive since + # its only referenced by header files), we should theoretically write + # INTERFACE GTest::GTest + # we choose not to do this since all test code pulls in this dependency by + # explicitly listing `testdeps` as a dependency (defined below) +) + target_compile_features(grtestutils PUBLIC cxx_std_17) # configure the grtestutils target so that when a file outside of this @@ -106,3 +119,19 @@ target_compile_definitions(grtestutils # enabling/disabling os-specific features) PRIVATE "$<$:PLATFORM_GENERIC_UNIX>" ) + + +# 2. testdeps: bundles dependencies used by tests +# =============================================== +# - this is an interface library (i.e. nothing is compiled) that ONLY exists +# to aggregate dependencies, include directories and compile definitions +# - all tests should depend on this target + +add_library(testdeps INTERFACE) +target_link_libraries(testdeps + INTERFACE Grackle::Grackle grtestutils _grackle_internals GTest::gtest_main +) +# indicates that all consumers are written in C++17 or newer +target_compile_features(testdeps INTERFACE cxx_std_17) + + diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index 6bac6b918..fd5a75ac1 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -1,12 +1,11 @@ -# NOTE: the grtestutils and testdeps library targets are both defined within -# ../grtestutils/CMakeLists.txt +# NOTE: the testdeps target is defined within ../grtestutils/CMakeLists.txt add_executable(runInterpolationTests test_unit_interpolators_g.cpp) target_link_libraries(runInterpolationTests testdeps) gtest_discover_tests(runInterpolationTests) add_executable(runLinAlgTests test_linalg.cpp) -target_link_libraries(runLinAlgTests grtestutils) +target_link_libraries(runLinAlgTests testdeps) gtest_discover_tests(runLinAlgTests) add_executable(runGrainSpeciesIntoTests test_grain_species_info.cpp) @@ -14,7 +13,7 @@ target_link_libraries(runGrainSpeciesIntoTests testdeps) gtest_discover_tests(runGrainSpeciesIntoTests) add_executable(runStatusReporting test_status_reporting.cpp) -target_link_libraries(runStatusReporting grtestutils) +target_link_libraries(runStatusReporting testdeps) gtest_discover_tests(runStatusReporting) # one might argue that the following is more of an integration or end-to-end @@ -26,7 +25,7 @@ gtest_discover_tests(runVisitorTests) # one might argue that the following is more of an integration or end-to-end # test than a unit-test add_executable(runGhostZoneTests test_ghost_zone.cpp) -target_link_libraries(runGhostZoneTests grtestutils testdeps) +target_link_libraries(runGhostZoneTests testdeps) gtest_discover_tests(runGhostZoneTests) # this target tests that the members of the chemistry_data struct can be @@ -36,7 +35,7 @@ gtest_discover_tests(runGhostZoneTests) # problems for "death-tests", so these test-cases should remain separate from # the rest of the gtest framework add_executable(runSyncedChemistryData test_chemistry_struct_synced.cpp) -target_link_libraries(runSyncedChemistryData grtestutils testdeps) +target_link_libraries(runSyncedChemistryData testdeps) target_compile_definitions(runSyncedChemistryData PRIVATE READER_PATH=${PROJECT_SOURCE_DIR}/tests/scripts/castxml_output_reader.py From 8cae77700db4cda8599c9563237252ddf1fd588f Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Thu, 18 Dec 2025 14:37:13 -0500 Subject: [PATCH 102/175] address a todo item (to reduce code duplication) --- tests/grtestutils/cmd.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/tests/grtestutils/cmd.cpp b/tests/grtestutils/cmd.cpp index 700cafa01..36128da0b 100644 --- a/tests/grtestutils/cmd.cpp +++ b/tests/grtestutils/cmd.cpp @@ -1,18 +1,13 @@ #include "cmd.hpp" +// internal Grackle routine: +#include "status_reporting.h" // GR_INTERNAL_ERROR, GR_INTERNAL_REQUIRE + #include // FILE, fgets, fprintf, stderr, (popen/pclose on POSIX) -#include // std::exit #include // std::stringstream #include -// TODO: replace with Grackle's existing err machinery -[[noreturn]] static void err_(std::string msg="") { - const char* ptr = (msg.empty()) ? "" : msg.c_str(); - fprintf(stderr, "ERROR: %s\n", ptr); - std::exit(1); -} - #ifdef PLATFORM_GENERIC_UNIX #define TEMP_BUF_SIZE 128 @@ -29,14 +24,14 @@ grtest::ProcessStatusAndStdout grtest::capture_status_and_output( // fp represents a buffered pipe to the standard output of the command. FILE* fp = popen(command.data(), "r"); - if (fp == nullptr) { err_("there was a problem launching the command"); } + GR_INTERNAL_REQUIRE(fp != nullptr, "there's a problem launching the command"); // if our reads from the pipe outpace the rate at which the command writes to // the pipe, fgets won't return until more data becomes available. If the // processess ends, fgets encounters EOF (causing fgets to return) while (fgets(temp_buf, TEMP_BUF_SIZE, fp) != nullptr) { buf << temp_buf; } int status = pclose(fp); - if (status == -1) { err_("there was a problem closing the command"); } + GR_INTERNAL_REQUIRE(status != -1, "there was a problem closing the command"); return {status, buf.str()}; } @@ -45,7 +40,7 @@ grtest::ProcessStatusAndStdout grtest::capture_status_and_output( grtest::ProcessStatusAndStdout grtest::capture_status_and_output( const std::string& command ) { - err_("not implemented on this platform"); + GR_INTERNAL_ERROR("not implemented on this platform"); } #endif /* PLATFORM_GENERIC_UNIX */ From 5cf43bca95b2e26b28d640f692b65098cd91ec41 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Fri, 19 Dec 2025 11:11:07 -0500 Subject: [PATCH 103/175] Add gmock to the list of libraries linked via testdeps For context, the gmock library is a component of googletest (it's already being installed). All this commit does is make it possible for us to use it in subsequent PRs --- tests/grtestutils/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/grtestutils/CMakeLists.txt b/tests/grtestutils/CMakeLists.txt index 42675d148..e58b7322b 100644 --- a/tests/grtestutils/CMakeLists.txt +++ b/tests/grtestutils/CMakeLists.txt @@ -129,7 +129,8 @@ target_compile_definitions(grtestutils add_library(testdeps INTERFACE) target_link_libraries(testdeps - INTERFACE Grackle::Grackle grtestutils _grackle_internals GTest::gtest_main + INTERFACE Grackle::Grackle grtestutils _grackle_internals + GTest::gtest_main GTest::gmock ) # indicates that all consumers are written in C++17 or newer target_compile_features(testdeps INTERFACE cxx_std_17) From deb6c84a93c7537a3c4fb9a39beb19dc96a996b6 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Tue, 16 Dec 2025 16:33:32 -0500 Subject: [PATCH 104/175] mv GrackleCtxPack out of test_ghost_zone and refactor --- src/clib/status_reporting.h | 16 +++ tests/grtestutils/CMakeLists.txt | 4 +- tests/grtestutils/googletest/fixtures.hpp | 110 +++++++++++++++ tests/grtestutils/preset.cpp | 107 +++++++++++++++ tests/grtestutils/preset.hpp | 66 +++++++++ tests/unit/test_ghost_zone.cpp | 157 +++++++--------------- 6 files changed, 351 insertions(+), 109 deletions(-) create mode 100644 tests/grtestutils/googletest/fixtures.hpp create mode 100644 tests/grtestutils/preset.cpp create mode 100644 tests/grtestutils/preset.hpp diff --git a/src/clib/status_reporting.h b/src/clib/status_reporting.h index f52f24651..fe1a1cd5b 100644 --- a/src/clib/status_reporting.h +++ b/src/clib/status_reporting.h @@ -320,6 +320,22 @@ ERRFMT_ATTR_(2) void grimpl_print_err_msg_( #define GrPrintErrMsg(...) \ grimpl_print_err_msg_(__GRIMPL_SRCLOC__, __VA_ARGS__); +/// @def GR_INTERNAL_UNREACHABLE_ERROR() +/// @brief function-like macro that aborts with a (lethal) error message +/// indicating that +/// +/// This macro should be treated as a function with the signature: +/// +/// [[noreturn]] void GR_INTERNAL_UNREACHABLE_ERROR(); +/// +/// @note +/// Unlike gcc/clang's __builtin_unreachable or C++23's std::unreachable, this +/// aborts the program with an error if its executed (the other cases produce +/// undefined behavior). (An argument could be made for conditionally compiling +/// this macro into the alternatives to test speed) +#define GR_INTERNAL_UNREACHABLE_ERROR() \ +{ grimpl_abort_with_internal_err_(__GRIMPL_SRCLOC__, \ +"location shouldn't be reachable"); } // undefine the attributes so we avoid leaking them // ------------------------------------------------ diff --git a/tests/grtestutils/CMakeLists.txt b/tests/grtestutils/CMakeLists.txt index e58b7322b..f05d4ff1f 100644 --- a/tests/grtestutils/CMakeLists.txt +++ b/tests/grtestutils/CMakeLists.txt @@ -80,11 +80,13 @@ add_library(grtestutils # files outside of the googletest subdirectory # -> these shouldn't include headers from the googletest subdirectory cmd.hpp cmd.cpp - utils.hpp utils.cpp os.hpp os.cpp + preset.hpp preset.cpp + utils.hpp utils.cpp # files in the googletest subdirectory (reminder: should just be headers!) googletest/check_allclose.hpp + googletest/fixtures.hpp ) target_link_libraries(grtestutils diff --git a/tests/grtestutils/googletest/fixtures.hpp b/tests/grtestutils/googletest/fixtures.hpp new file mode 100644 index 000000000..b1bc74969 --- /dev/null +++ b/tests/grtestutils/googletest/fixtures.hpp @@ -0,0 +1,110 @@ +//===----------------------------------------------------------------------===// +// +// See the LICENSE file for license and copyright information +// SPDX-License-Identifier: NCSA AND BSD-3-Clause +// +//===----------------------------------------------------------------------===// +/// +/// @file +/// Define machinery for creating GoogleTest Fixutures to help test Grackle's +/// C API. +/// +//===----------------------------------------------------------------------===// + +#ifndef GRTEST_FIXTURE +#define GRTEST_FIXTURE + +#include +// because we include gtest.h here, we should NOT include this file in any +// grtest source files (in other words, this should be a header-only file) + +#include + +#include "grackle.h" +#include "../preset.hpp" + +namespace grtest { + +/// Tracks the group of Grackle objects needed for executing API functions +/// +/// The primary motivation for this object's existence is making sure that +/// the allocations get cleaned up when a test fails +/// +/// @note +/// Ideally, we would only make it possible to create a fully initialized +/// instance (in that case, we would delete the default constructor), but that +/// involves a bunch more work +/// +/// We choose to implement this in terms of std::unique_ptr (rather than raw +/// pointers) since it implements proper move semantics for us +class GrackleCtxPack { + /// units used for initializing chemistry_data + code_units initial_units_; + /// the fully initialized chemistry_data instance + std::unique_ptr my_chemistry_; + /// the fully initialized chemistry_data_storage_instance + std::unique_ptr my_rates_; + +public: + /// Construct an uninitialized instance + GrackleCtxPack() : my_chemistry_(nullptr), my_rates_(nullptr) {} + + GrackleCtxPack(GrackleCtxPack&&) = default; + GrackleCtxPack& operator=(GrackleCtxPack&&) = default; + + // forbid copy and assignment operations... + // -> we could re-enable them if we wanted to be able add to clone the + // types (or if we wanted to internally use std::shared_ptr + GrackleCtxPack(const GrackleCtxPack&) = delete; + GrackleCtxPack& operator=(const GrackleCtxPack&) = delete; + + ~GrackleCtxPack() { + if (!this->is_initialized()) { + return; + } + local_free_chemistry_data(this->my_chemistry_.get(), this->my_rates_.get()); + // unique_ptr destructor will handle calls to delete + } + + bool is_initialized() const { return this->my_chemistry_ != nullptr; } + + // getter functions + const code_units& initial_units() const { return this->initial_units_; } + chemistry_data* my_chemistry() { return this->my_chemistry_.get(); } + chemistry_data_storage* my_rates() { return this->my_rates_.get(); } + + /// create an initialized instance from a preset + static GrackleCtxPack create(const FullConfPreset& preset, + InitStatus* status) { + std::unique_ptr my_chemistry(new chemistry_data); + InitStatus tmp = + setup_chemistry_data_from_preset(my_chemistry.get(), preset.chemistry); + if (tmp != InitStatus::success) { + if (status != nullptr) { + *status = tmp; + } + return GrackleCtxPack(); // return an unitialized instance + } + + code_units initial_unit = setup_initial_unit(preset.unit); + std::unique_ptr my_rates( + new chemistry_data_storage); + if (local_initialize_chemistry_data(my_chemistry.get(), my_rates.get(), + &initial_unit) != GR_SUCCESS) { + if (status != nullptr) { + *status = InitStatus::generic_fail; + } + return GrackleCtxPack(); // return an unitialized instance + } + + GrackleCtxPack out; + out.initial_units_ = initial_unit; + out.my_chemistry_ = std::move(my_chemistry); + out.my_rates_ = std::move(my_rates); + return out; + } +}; + +} // namespace grtest + +#endif // GRTEST_FIXTURE diff --git a/tests/grtestutils/preset.cpp b/tests/grtestutils/preset.cpp new file mode 100644 index 000000000..22621cc18 --- /dev/null +++ b/tests/grtestutils/preset.cpp @@ -0,0 +1,107 @@ +//===----------------------------------------------------------------------===// +// +// See the LICENSE file for license and copyright information +// SPDX-License-Identifier: NCSA AND BSD-3-Clause +// +//===----------------------------------------------------------------------===// +/// +/// @file +/// implement logic pertaining to pre-defined configuration presets +/// +//===----------------------------------------------------------------------===// + +#include "./preset.hpp" +#include "./utils.hpp" + +#include "grackle.h" +#include "status_reporting.h" // GR_INTERNAL_UNREACHABLE_ERROR + +static std::string to_string(const grtest::ChemPreset& preset) { + switch (preset) { + case grtest::ChemPreset::primchem0: + return "pc=0"; + case grtest::ChemPreset::primchem1: + return "pc=1"; + case grtest::ChemPreset::primchem2: + return "pc=2"; + case grtest::ChemPreset::primchem3: + return "pc=3"; + } + + GR_INTERNAL_UNREACHABLE_ERROR(); +} + +grtest::InitStatus grtest::setup_chemistry_data_from_preset( + chemistry_data* my_chem, ChemPreset preset) { + if (local_initialize_chemistry_parameters(my_chem) != GR_SUCCESS) { + return InitStatus::generic_fail; + } + + if (!grtest::set_standard_datafile(*my_chem, "CloudyData_UVB=HM2012.h5")) { + return InitStatus::datafile_notfound; + } + + my_chem->use_grackle = 1; // chemistry on + my_chem->use_isrf_field = 1; + my_chem->with_radiative_cooling = 1; // cooling on + my_chem->metal_cooling = 1; // metal cooling on + my_chem->UVbackground = 1; // UV background on + + switch (preset) { + case ChemPreset::primchem0: { + my_chem->primordial_chemistry = 0; + my_chem->dust_chemistry = 0; + return InitStatus::success; + } + case ChemPreset::primchem1: { + my_chem->primordial_chemistry = 1; + my_chem->dust_chemistry = 1; + return InitStatus::success; + } + case ChemPreset::primchem2: { + my_chem->primordial_chemistry = 2; + my_chem->dust_chemistry = 1; + return InitStatus::success; + } + case ChemPreset::primchem3: { + my_chem->primordial_chemistry = 3; + my_chem->dust_chemistry = 1; + return InitStatus::success; + } + } + GR_INTERNAL_UNREACHABLE_ERROR(); +} + +static std::string to_string(const grtest::InitialUnitPreset& preset) { + switch (preset) { + case grtest::InitialUnitPreset::simple_z0: + return "simpleUnit-z=0"; + } + GR_INTERNAL_UNREACHABLE_ERROR(); +} + +code_units grtest::setup_initial_unit(grtest::InitialUnitPreset preset) { + // since we return in the switch statement, the compiler should always warn + // us if we're missing an enumeration + switch (preset) { + case InitialUnitPreset::simple_z0: { + double initial_redshift = 0.; + code_units my_units; + my_units.comoving_coordinates = 0; // 1 if cosmological sim, 0 if not + my_units.density_units = 1.67e-24; + my_units.length_units = 1.0; + my_units.time_units = 1.0e12; + my_units.a_units = 1.0; // units for the expansion factor + // Set expansion factor to 1 for non-cosmological simulation. + my_units.a_value = 1. / (1. + initial_redshift) / my_units.a_units; + set_velocity_units(&my_units); + return my_units; + } + } + GR_INTERNAL_UNREACHABLE_ERROR(); +} + +void grtest::PrintTo(const grtest::FullConfPreset& preset, std::ostream* os) { + *os << "Preset{" << to_string(preset.chemistry) << ',' + << to_string(preset.unit) << '}'; +} diff --git a/tests/grtestutils/preset.hpp b/tests/grtestutils/preset.hpp new file mode 100644 index 000000000..5f62c4e7b --- /dev/null +++ b/tests/grtestutils/preset.hpp @@ -0,0 +1,66 @@ +//===----------------------------------------------------------------------===// +// +// See the LICENSE file for license and copyright information +// SPDX-License-Identifier: NCSA AND BSD-3-Clause +// +//===----------------------------------------------------------------------===// +/// +/// @file +/// declare some standard pre-defined configuration presets +/// +//===----------------------------------------------------------------------===// +#ifndef GRTESTUTILS_PRESET_HPP +#define GRTESTUTILS_PRESET_HPP + +#include "grackle.h" +#include +#include + +namespace grtest { + +/// this only exists so that we can determine the reason that a test fails +enum class InitStatus { + success, + generic_fail, + datafile_notfound, +}; + +/// represents different presets for initializing chemistry_data +/// +/// @note +/// In the future, we probably want to add more +enum class ChemPreset { + primchem0, + primchem1, + primchem2, + primchem3, +}; + +/// override the settings of my_chem based on the specified preset +InitStatus setup_chemistry_data_from_preset(chemistry_data* my_chem, + ChemPreset preset); + +/// Preset for constructing the code_unit instance used for initializing the +/// Grackle Solver +/// +/// @note +/// In the future, we probably want to add more +enum class InitialUnitPreset { + simple_z0, // <- no cosmology, z=0 +}; + +/// return a code_unit instance initialized based on the specified preset +code_units setup_initial_unit(InitialUnitPreset preset); + +/// Represents the preset for creating a GrackleCtxPack +struct FullConfPreset { + ChemPreset chemistry; + InitialUnitPreset unit; +}; + +// teach googletest how to print FullConfPreset +void PrintTo(const FullConfPreset& preset, std::ostream* os); + +} // namespace grtest + +#endif // GRTESTUTILS_PRESET_HPP diff --git a/tests/unit/test_ghost_zone.cpp b/tests/unit/test_ghost_zone.cpp index 607da2325..2ee3807e5 100644 --- a/tests/unit/test_ghost_zone.cpp +++ b/tests/unit/test_ghost_zone.cpp @@ -25,6 +25,7 @@ #include #include "grtestutils/utils.hpp" +#include "grtestutils/googletest/fixtures.hpp" #include @@ -33,7 +34,8 @@ #define mh 1.67262171e-24 #define kboltz 1.3806504e-16 -typedef int (*property_func)(code_units*, grackle_field_data*, gr_float*); +typedef int (*property_func)(chemistry_data*, chemistry_data_storage*, + code_units*, grackle_field_data*, gr_float*); typedef std::map> val_vec_map_t; @@ -79,7 +81,8 @@ class FieldInitHelper{ // allocates the grackle_field_data struct void construct_field_data(grackle_field_data& my_fields, grid_props& my_grid_props, - code_units& my_units, + const chemistry_data* my_chemistry, + const code_units& my_units, val_vec_map_t& val_map, std::minstd_rand& generator){ @@ -162,11 +165,11 @@ void construct_field_data(grackle_field_data& my_fields, for (int ix = gx; ix < (mx - gx); ix++){ int i = ix + mx * (iy + my*iz); my_fields.density[i] = 1.0; - my_fields.HI_density[i] = grackle_data->HydrogenFractionByMass * + my_fields.HI_density[i] = my_chemistry->HydrogenFractionByMass * my_fields.density[i]; my_fields.HII_density[i] = tiny_number * my_fields.density[i]; my_fields.HM_density[i] = tiny_number * my_fields.density[i]; - my_fields.HeI_density[i] = (1.0 - grackle_data->HydrogenFractionByMass) + my_fields.HeI_density[i] = (1.0 - my_chemistry->HydrogenFractionByMass) * my_fields.density[i]; my_fields.HeII_density[i] = tiny_number * my_fields.density[i]; my_fields.HeIII_density[i] = tiny_number * my_fields.density[i]; @@ -177,7 +180,7 @@ void construct_field_data(grackle_field_data& my_fields, my_fields.HDI_density[i] = tiny_number * my_fields.density[i]; my_fields.e_density[i] = tiny_number * my_fields.density[i]; // solar metallicity - my_fields.metal_density[i] = grackle_data->SolarMetalFractionByMass * + my_fields.metal_density[i] = my_chemistry->SolarMetalFractionByMass * my_fields.density[i]; my_fields.x_velocity[i] = 0.0; @@ -196,7 +199,7 @@ void construct_field_data(grackle_field_data& my_fields, my_fields.RT_H2_dissociation_rate[i] = 0.0; my_fields.RT_heating_rate[i] = 0.0; - my_fields.isrf_habing[i] = grackle_data->interstellar_radiation_field; + my_fields.isrf_habing[i] = my_chemistry->interstellar_radiation_field; } } } @@ -246,77 +249,8 @@ bool equal_ghost_values(val_vec_map_t& ref, val_vec_map_t& actual, return true; } -namespace { // stuff within anonymous namespace is local to the current file - -/// the following is just a dummy struct that primarily exists to assist with -/// cleanup (and avoid memory leaks) -struct GrackleCtxPack { - bool successful_default = false; - bool successful_data_file = false; - bool successful_init = false; - code_units my_units; - chemistry_data* my_chemistry = nullptr; -}; - -void cleanup_grackle_conditions(GrackleCtxPack& pack) { - if (pack.successful_init) { free_chemistry_data(); } - if (pack.my_chemistry != nullptr) { delete pack.my_chemistry; } -} - -GrackleCtxPack setup_simple_grackle_conditions(int primordial_chemistry) { - /********************************************************************* - / Initial setup of units and chemistry objects. - *********************************************************************/ - - GrackleCtxPack pack; - - // Set initial redshift (for internal units). - double initial_redshift = 0.; - - // First, set up the units system. - // These are conversions from code units to cgs. - pack.my_units.comoving_coordinates = 0; // 1 if cosmological sim, 0 if not - pack.my_units.density_units = 1.67e-24; - pack.my_units.length_units = 1.0; - pack.my_units.time_units = 1.0e12; - pack.my_units.a_units = 1.0; // units for the expansion factor - // Set expansion factor to 1 for non-cosmological simulation. - pack.my_units.a_value = 1. / (1. + initial_redshift) / pack.my_units.a_units; - set_velocity_units(&pack.my_units); - - // Second, create a chemistry object for parameters. - pack.my_chemistry = new chemistry_data; - if (set_default_chemistry_parameters(pack.my_chemistry) != GR_SUCCESS) { - return pack; - } - pack.successful_default=true; - - // Set parameter values for chemistry. - // Access the parameter storage with the struct you've created - // or with the grackle_data pointer declared in grackle.h (see further below). - pack.my_chemistry->use_grackle = 1; // chemistry on - pack.my_chemistry->use_isrf_field = 1; - pack.my_chemistry->with_radiative_cooling = 1; // cooling on - pack.my_chemistry->primordial_chemistry = primordial_chemistry; - pack.my_chemistry->dust_chemistry = (primordial_chemistry == 0) ? 0 : 1; - pack.my_chemistry->metal_cooling = 1; // metal cooling on - pack.my_chemistry->UVbackground = 1; // UV background on - - pack.successful_data_file = grtest::set_standard_datafile( - *pack.my_chemistry, "CloudyData_UVB=HM2012.h5" - ); - if (!pack.successful_data_file) { return pack; } - - // Finally, initialize the chemistry object. - if (initialize_chemistry_data(&pack.my_units) != GR_SUCCESS) { return pack; } - pack.successful_init = true; - return pack; -} - -} // anonymous namespace - // this defines a parameterized test-fixture (it is parameterized on -// primordial_chemistry) +// InitStatus::data_file_not_found) // -> it has a GetParam() method to access the parameters // -> to assist with avoiding memory leaks, I decided to also make this setup // and teardown GrackleCtxPack. @@ -324,30 +258,25 @@ GrackleCtxPack setup_simple_grackle_conditions(int primordial_chemistry) { // really doesn't care how grackle is configured (other than that // primordial_chemistry varies and that it will actually perform // calculations) -class APIConventionTest : public testing::TestWithParam { +class APIConventionTest : public testing::TestWithParam { protected: void SetUp() override { // Disable output grackle_verbose = 0; // called immediately after the constructor (but before the test-case) - int primordial_chemistry = GetParam(); - - pack_ = setup_simple_grackle_conditions(primordial_chemistry); - if (!pack_.successful_default) { - FAIL() << "Error in set_default_chemistry_parameters."; - } else if (!pack_.successful_data_file) { - GTEST_SKIP() << "something went wrong with finding the data file"; - } else if (!pack_.successful_init) { - FAIL() << "Error in initialize_chemistry_data."; + grtest::InitStatus status; + pack_ = grtest::GrackleCtxPack::create(GetParam(), &status); + if (!pack_.is_initialized()) { + if (status == grtest::InitStatus::datafile_notfound) { + GTEST_SKIP() << "something went wrong with finding the data file"; + } else { + FAIL() << "Error in initialize_chemistry_data."; + } } } - void TearDown() override { - cleanup_grackle_conditions(this->pack_); - } - - GrackleCtxPack pack_; + grtest::GrackleCtxPack pack_; }; TEST_P(APIConventionTest, GridZoneStartEnd) { @@ -355,7 +284,8 @@ TEST_P(APIConventionTest, GridZoneStartEnd) { grid_props my_grid_props = {{5,6,7}, {1,0,2}}; // alias the pack_ attribute tracked by the fixture - GrackleCtxPack& pack = pack_; + grtest::GrackleCtxPack& pack = pack_; + code_units my_units = pack_.initial_units(); // initialize pseudo random number generator std::uint32_t seed = 1379069008; @@ -377,7 +307,7 @@ TEST_P(APIConventionTest, GridZoneStartEnd) { // For example: my_fields.density = my_field_map["density"].data() val_vec_map_t my_field_map; construct_field_data( - my_fields, my_grid_props, pack.my_units, my_field_map, generator + my_fields, my_grid_props, pack.my_chemistry(), my_units, my_field_map, generator ); // orig_field_map_copy is a deepcopy of my_field_map. We will use this as a @@ -393,9 +323,11 @@ TEST_P(APIConventionTest, GridZoneStartEnd) { // Evolving the chemistry. // some timestep - double dt = 3.15e7 * 1e6 / pack.my_units.time_units; + double dt = 3.15e7 * 1e6 / my_units.time_units; - if (solve_chemistry(&pack.my_units, &my_fields, dt) != GR_SUCCESS) { + if (local_solve_chemistry(pack.my_chemistry(), pack.my_rates(), + &my_units, &my_fields, + dt)!= GR_SUCCESS) { FAIL() << "Error running solve_chemistry"; } @@ -404,17 +336,17 @@ TEST_P(APIConventionTest, GridZoneStartEnd) { FAIL() << "Some ghost values were modified in solve_chemistry."; } - // Now check what hapens when computing various properties - const char* func_names[5] = {"calculate_cooling_time", - "calculate_temperature", - "calculate_pressure", - "calculate_gamma", - "calculate_dust_temperature"}; - property_func func_ptrs[5] = {&calculate_cooling_time, - &calculate_temperature, - &calculate_pressure, - &calculate_gamma, - &calculate_dust_temperature}; + // Now check what happens when computing various properties + const char* func_names[5] = {"local_calculate_cooling_time", + "local_calculate_temperature", + "local_calculate_pressure", + "local_calculate_gamma", + "local_calculate_dust_temperature"}; + property_func func_ptrs[5] = {&local_calculate_cooling_time, + &local_calculate_temperature, + &local_calculate_pressure, + &local_calculate_gamma, + &local_calculate_dust_temperature}; for (int i = 0; i < 5; i++){ std::uint32_t seed2 = 1860889605; std::minstd_rand generator2(seed2); @@ -426,7 +358,7 @@ TEST_P(APIConventionTest, GridZoneStartEnd) { // perform the calculation property_func func_ptr = func_ptrs[i]; - if ( (*func_ptr)(&pack.my_units, &my_fields, out_vals.data()) + if ( (*func_ptr)(pack.my_chemistry(), pack.my_rates(), &my_units, &my_fields, out_vals.data()) != GR_SUCCESS ) { FAIL() << "Error reported by " << func_names; } @@ -439,6 +371,15 @@ TEST_P(APIConventionTest, GridZoneStartEnd) { } +using grtest::FullConfPreset; +using grtest::ChemPreset; +using grtest::InitialUnitPreset; + INSTANTIATE_TEST_SUITE_P( - VaryingPrimordialChem, APIConventionTest, ::testing::Range(0, 4) + VaryingPrimordialChem, APIConventionTest, + ::testing::Values( + FullConfPreset{ChemPreset::primchem0, InitialUnitPreset::simple_z0}, + FullConfPreset{ChemPreset::primchem1, InitialUnitPreset::simple_z0}, + FullConfPreset{ChemPreset::primchem2, InitialUnitPreset::simple_z0}, + FullConfPreset{ChemPreset::primchem3, InitialUnitPreset::simple_z0}) ); From c4495e7a9cd8bdd0423601b23432e06beb3f4688 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Tue, 16 Dec 2025 16:55:57 -0500 Subject: [PATCH 105/175] transfer grtest_api_fixture out of test_ghost_zone --- tests/grtestutils/googletest/fixtures.hpp | 96 ++++++----------------- tests/grtestutils/preset.hpp | 80 +++++++++++++++++++ tests/unit/test_ghost_zone.cpp | 35 +-------- 3 files changed, 107 insertions(+), 104 deletions(-) diff --git a/tests/grtestutils/googletest/fixtures.hpp b/tests/grtestutils/googletest/fixtures.hpp index b1bc74969..e139ed072 100644 --- a/tests/grtestutils/googletest/fixtures.hpp +++ b/tests/grtestutils/googletest/fixtures.hpp @@ -25,84 +25,34 @@ namespace grtest { -/// Tracks the group of Grackle objects needed for executing API functions +/// defines a parameterized test-fixture that can used to run a parametrized +/// set of tests that are initialized with different chemistry data presets. /// -/// The primary motivation for this object's existence is making sure that -/// the allocations get cleaned up when a test fails +/// This sets up a GrackleCtxPack (where the contents are configured with +/// appropriate presets) and deallocates that memory at the end of the test. /// -/// @note -/// Ideally, we would only make it possible to create a fully initialized -/// instance (in that case, we would delete the default constructor), but that -/// involves a bunch more work -/// -/// We choose to implement this in terms of std::unique_ptr (rather than raw -/// pointers) since it implements proper move semantics for us -class GrackleCtxPack { - /// units used for initializing chemistry_data - code_units initial_units_; - /// the fully initialized chemistry_data instance - std::unique_ptr my_chemistry_; - /// the fully initialized chemistry_data_storage_instance - std::unique_ptr my_rates_; - -public: - /// Construct an uninitialized instance - GrackleCtxPack() : my_chemistry_(nullptr), my_rates_(nullptr) {} - - GrackleCtxPack(GrackleCtxPack&&) = default; - GrackleCtxPack& operator=(GrackleCtxPack&&) = default; - - // forbid copy and assignment operations... - // -> we could re-enable them if we wanted to be able add to clone the - // types (or if we wanted to internally use std::shared_ptr - GrackleCtxPack(const GrackleCtxPack&) = delete; - GrackleCtxPack& operator=(const GrackleCtxPack&) = delete; - - ~GrackleCtxPack() { - if (!this->is_initialized()) { - return; - } - local_free_chemistry_data(this->my_chemistry_.get(), this->my_rates_.get()); - // unique_ptr destructor will handle calls to delete - } - - bool is_initialized() const { return this->my_chemistry_ != nullptr; } - - // getter functions - const code_units& initial_units() const { return this->initial_units_; } - chemistry_data* my_chemistry() { return this->my_chemistry_.get(); } - chemistry_data_storage* my_rates() { return this->my_rates_.get(); } - - /// create an initialized instance from a preset - static GrackleCtxPack create(const FullConfPreset& preset, - InitStatus* status) { - std::unique_ptr my_chemistry(new chemistry_data); - InitStatus tmp = - setup_chemistry_data_from_preset(my_chemistry.get(), preset.chemistry); - if (tmp != InitStatus::success) { - if (status != nullptr) { - *status = tmp; +/// How To Use +/// ========== +/// To make use of this, you might create a subclass of this type that is named +/// for the test suite. I don't love this strategy, but it seems to be the +/// standard way to do things. We can revisit this in the future. +class ParametrizedConfigPresetFixture + : public testing::TestWithParam { +protected: + void SetUp() override { + // called immediately after the constructor (but before the test-case) + grtest::InitStatus status; + pack_ = GrackleCtxPack::create(GetParam(), &status); + if (!pack_.is_initialized()) { + if (status == InitStatus::datafile_notfound) { + GTEST_SKIP() << "something went wrong with finding the data file"; + } else { + FAIL() << "Error in initialize_chemistry_data."; } - return GrackleCtxPack(); // return an unitialized instance } - - code_units initial_unit = setup_initial_unit(preset.unit); - std::unique_ptr my_rates( - new chemistry_data_storage); - if (local_initialize_chemistry_data(my_chemistry.get(), my_rates.get(), - &initial_unit) != GR_SUCCESS) { - if (status != nullptr) { - *status = InitStatus::generic_fail; - } - return GrackleCtxPack(); // return an unitialized instance - } - - GrackleCtxPack out; - out.initial_units_ = initial_unit; - out.my_chemistry_ = std::move(my_chemistry); - out.my_rates_ = std::move(my_rates); - return out; } + + GrackleCtxPack pack_; }; } // namespace grtest diff --git a/tests/grtestutils/preset.hpp b/tests/grtestutils/preset.hpp index 5f62c4e7b..c8a22a526 100644 --- a/tests/grtestutils/preset.hpp +++ b/tests/grtestutils/preset.hpp @@ -61,6 +61,86 @@ struct FullConfPreset { // teach googletest how to print FullConfPreset void PrintTo(const FullConfPreset& preset, std::ostream* os); +/// Tracks the group of Grackle objects needed for executing API functions +/// +/// The primary motivation for this object's existence is making sure that +/// the allocations get cleaned up when a test fails +/// +/// @note +/// Ideally, we would only make it possible to create a fully initialized +/// instance (in that case, we would delete the default constructor), but that +/// involves a bunch more work +/// +/// We choose to implement this in terms of std::unique_ptr (rather than raw +/// pointers) since it implements proper move semantics for us +class GrackleCtxPack { + /// units used for initializing chemistry_data + code_units initial_units_; + /// the fully initialized chemistry_data instance + std::unique_ptr my_chemistry_; + /// the fully initialized chemistry_data_storage_instance + std::unique_ptr my_rates_; + +public: + /// Construct an uninitialized instance + GrackleCtxPack() : my_chemistry_(nullptr), my_rates_(nullptr) {} + + GrackleCtxPack(GrackleCtxPack&&) = default; + GrackleCtxPack& operator=(GrackleCtxPack&&) = default; + + // forbid copy and assignment operations... + // -> we could re-enable them if we wanted to be able add to clone the + // types (or if we wanted to internally use std::shared_ptr + GrackleCtxPack(const GrackleCtxPack&) = delete; + GrackleCtxPack& operator=(const GrackleCtxPack&) = delete; + + ~GrackleCtxPack() { + if (!this->is_initialized()) { + return; + } + local_free_chemistry_data(this->my_chemistry_.get(), this->my_rates_.get()); + // unique_ptr destructor will handle calls to delete + } + + bool is_initialized() const { return this->my_chemistry_ != nullptr; } + + // getter functions + const code_units& initial_units() const { return this->initial_units_; } + chemistry_data* my_chemistry() { return this->my_chemistry_.get(); } + chemistry_data_storage* my_rates() { return this->my_rates_.get(); } + + /// create an initialized instance from a preset + static GrackleCtxPack create(const FullConfPreset& preset, + InitStatus* status) { + std::unique_ptr my_chemistry(new chemistry_data); + InitStatus tmp = + setup_chemistry_data_from_preset(my_chemistry.get(), preset.chemistry); + if (tmp != InitStatus::success) { + if (status != nullptr) { + *status = tmp; + } + return GrackleCtxPack(); // return an unitialized instance + } + + code_units initial_unit = setup_initial_unit(preset.unit); + std::unique_ptr my_rates( + new chemistry_data_storage); + if (local_initialize_chemistry_data(my_chemistry.get(), my_rates.get(), + &initial_unit) != GR_SUCCESS) { + if (status != nullptr) { + *status = InitStatus::generic_fail; + } + return GrackleCtxPack(); // return an unitialized instance + } + + GrackleCtxPack out; + out.initial_units_ = initial_unit; + out.my_chemistry_ = std::move(my_chemistry); + out.my_rates_ = std::move(my_rates); + return out; + } +}; + } // namespace grtest #endif // GRTESTUTILS_PRESET_HPP diff --git a/tests/unit/test_ghost_zone.cpp b/tests/unit/test_ghost_zone.cpp index 2ee3807e5..c565183a6 100644 --- a/tests/unit/test_ghost_zone.cpp +++ b/tests/unit/test_ghost_zone.cpp @@ -249,37 +249,10 @@ bool equal_ghost_values(val_vec_map_t& ref, val_vec_map_t& actual, return true; } -// this defines a parameterized test-fixture (it is parameterized on -// InitStatus::data_file_not_found) -// -> it has a GetParam() method to access the parameters -// -> to assist with avoiding memory leaks, I decided to also make this setup -// and teardown GrackleCtxPack. -// -> Frankly, I don't love this, but I think it is okay since the test -// really doesn't care how grackle is configured (other than that -// primordial_chemistry varies and that it will actually perform -// calculations) -class APIConventionTest : public testing::TestWithParam { - protected: - void SetUp() override { - // Disable output - grackle_verbose = 0; - - // called immediately after the constructor (but before the test-case) - grtest::InitStatus status; - pack_ = grtest::GrackleCtxPack::create(GetParam(), &status); - if (!pack_.is_initialized()) { - if (status == grtest::InitStatus::datafile_notfound) { - GTEST_SKIP() << "something went wrong with finding the data file"; - } else { - FAIL() << "Error in initialize_chemistry_data."; - } - } - } - - grtest::GrackleCtxPack pack_; -}; +class APIGhostZoneTest: public grtest::ParametrizedConfigPresetFixture +{}; -TEST_P(APIConventionTest, GridZoneStartEnd) { +TEST_P(APIGhostZoneTest, GridZoneStartEnd) { grid_props my_grid_props = {{5,6,7}, {1,0,2}}; @@ -376,7 +349,7 @@ using grtest::ChemPreset; using grtest::InitialUnitPreset; INSTANTIATE_TEST_SUITE_P( - VaryingPrimordialChem, APIConventionTest, + VaryingPrimordialChem, APIGhostZoneTest, ::testing::Values( FullConfPreset{ChemPreset::primchem0, InitialUnitPreset::simple_z0}, FullConfPreset{ChemPreset::primchem1, InitialUnitPreset::simple_z0}, From 268b9b4650e03549aeb7f13f707d16d8c9afeb24 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Tue, 16 Dec 2025 19:20:53 -0500 Subject: [PATCH 106/175] introduce some basic tests of ratequery --- tests/grtestutils/googletest/fixtures.hpp | 51 +++++++++++++++++++---- tests/grtestutils/preset.cpp | 10 +++++ tests/grtestutils/preset.hpp | 1 + tests/unit/CMakeLists.txt | 11 ++--- tests/unit/test_api_ratequery.cpp | 49 ++++++++++++++++++++++ tests/unit/test_ghost_zone.cpp | 8 ++-- 6 files changed, 113 insertions(+), 17 deletions(-) create mode 100644 tests/unit/test_api_ratequery.cpp diff --git a/tests/grtestutils/googletest/fixtures.hpp b/tests/grtestutils/googletest/fixtures.hpp index e139ed072..e3998dbbe 100644 --- a/tests/grtestutils/googletest/fixtures.hpp +++ b/tests/grtestutils/googletest/fixtures.hpp @@ -25,7 +25,42 @@ namespace grtest { -/// defines a parameterized test-fixture that can used to run a parametrized +/// test-fixture that can used to run one or more tests with a chemistry data +/// configuration initialized from a given chemistry presets. +/// +/// This sets up a GrackleCtxPack (where the contents are configured with +/// appropriate presets) and deallocates that memory at the end of the test. +/// +/// How To Use +/// ========== +/// To make use of this fixture in a test-suite called `MyFeatureTest`, you +/// need to either: +/// 1. make a type alias (via `using` or `typedef`), named `MyFeatureTest`, of +/// the relevant instantiation of this class template, OR +/// 2. make a subclass, named `MyFeatureTest`, of the relevant instantiation of +/// this class template +template +class ConfigPresetFixture : public testing::Test { +protected: + void SetUp() override { + // called immediately after the constructor (but before the test-case) + + grtest::InitStatus status; + pack = GrackleCtxPack::create(FullConfPreset{chem_preset, unit_preset}, + &status); + if (!pack.is_initialized()) { + if (status == InitStatus::datafile_notfound) { + GTEST_SKIP() << "something went wrong with finding the data file"; + } else { + FAIL() << "Error in initialize_chemistry_data."; + } + } + } + + GrackleCtxPack pack; +}; + +/// defines a parameterized test-fixture that can be used to run a parametrized /// set of tests that are initialized with different chemistry data presets. /// /// This sets up a GrackleCtxPack (where the contents are configured with @@ -33,17 +68,19 @@ namespace grtest { /// /// How To Use /// ========== -/// To make use of this, you might create a subclass of this type that is named -/// for the test suite. I don't love this strategy, but it seems to be the -/// standard way to do things. We can revisit this in the future. +/// To make use of this fixture in a test-suite called `MyFeatureTest`, you +/// need to either: +/// 1. make a type alias (via `using` or `typedef`), named `MyFeatureTest`, of +/// this class, OR +/// 2. make a subclass, named `MyFeatureTest`, of this class class ParametrizedConfigPresetFixture : public testing::TestWithParam { protected: void SetUp() override { // called immediately after the constructor (but before the test-case) grtest::InitStatus status; - pack_ = GrackleCtxPack::create(GetParam(), &status); - if (!pack_.is_initialized()) { + pack = GrackleCtxPack::create(GetParam(), &status); + if (!pack.is_initialized()) { if (status == InitStatus::datafile_notfound) { GTEST_SKIP() << "something went wrong with finding the data file"; } else { @@ -52,7 +89,7 @@ class ParametrizedConfigPresetFixture } } - GrackleCtxPack pack_; + GrackleCtxPack pack; }; } // namespace grtest diff --git a/tests/grtestutils/preset.cpp b/tests/grtestutils/preset.cpp index 22621cc18..53f3a64e3 100644 --- a/tests/grtestutils/preset.cpp +++ b/tests/grtestutils/preset.cpp @@ -26,6 +26,8 @@ static std::string to_string(const grtest::ChemPreset& preset) { return "pc=2"; case grtest::ChemPreset::primchem3: return "pc=3"; + case grtest::ChemPreset::primchem4_dustspecies3: + return "pc=3-dust_species=4"; } GR_INTERNAL_UNREACHABLE_ERROR(); @@ -68,6 +70,14 @@ grtest::InitStatus grtest::setup_chemistry_data_from_preset( my_chem->dust_chemistry = 1; return InitStatus::success; } + case ChemPreset::primchem4_dustspecies3: { + my_chem->primordial_chemistry = 4; + my_chem->dust_chemistry = 1; + my_chem->metal_chemistry = 1; + my_chem->dust_species = 1; + my_chem->use_dust_density_field = 1; + return InitStatus::success; + } } GR_INTERNAL_UNREACHABLE_ERROR(); } diff --git a/tests/grtestutils/preset.hpp b/tests/grtestutils/preset.hpp index c8a22a526..b30f69632 100644 --- a/tests/grtestutils/preset.hpp +++ b/tests/grtestutils/preset.hpp @@ -34,6 +34,7 @@ enum class ChemPreset { primchem1, primchem2, primchem3, + primchem4_dustspecies3, }; /// override the settings of my_chem based on the specified preset diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index fd5a75ac1..915a28c93 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -22,11 +22,12 @@ add_executable(runVisitorTests test_visitor.cpp) target_link_libraries(runVisitorTests testdeps) gtest_discover_tests(runVisitorTests) -# one might argue that the following is more of an integration or end-to-end -# test than a unit-test -add_executable(runGhostZoneTests test_ghost_zone.cpp) -target_link_libraries(runGhostZoneTests testdeps) -gtest_discover_tests(runGhostZoneTests) +# tests of the API functions +# -> one might argue that these are better classified as integration or +# end-to-end tests than as unit-test +add_executable(runApiTests test_ghost_zone.cpp test_api_ratequery.cpp) +target_link_libraries(runApiTests testdeps) +gtest_discover_tests(runApiTests) # this target tests that the members of the chemistry_data struct can be # accessed through the "dynamic api." The test cases in this target are diff --git a/tests/unit/test_api_ratequery.cpp b/tests/unit/test_api_ratequery.cpp new file mode 100644 index 000000000..260d69ba1 --- /dev/null +++ b/tests/unit/test_api_ratequery.cpp @@ -0,0 +1,49 @@ +//===----------------------------------------------------------------------===// +// +// See the LICENSE file for license and copyright information +// SPDX-License-Identifier: NCSA AND BSD-3-Clause +// +//===----------------------------------------------------------------------===// +/// +/// @file +/// Define some basic tests of the experimental ratequery API +/// +//===----------------------------------------------------------------------===// + +#include +#include +#include "grtestutils/googletest/fixtures.hpp" + +#include "grackle.h" + +/// returns the rateid used to denote invalid rate names +grunstable_rateid_type get_invalid_rateid(const grtest::GrackleCtxPack& pack) { + // although we don't use pack, yet a forthcoming refactor requires it + return grunstable_ratequery_id(nullptr); +} + +using SimpleRateQueryTest = + grtest::ConfigPresetFixture; + +TEST_F(SimpleRateQueryTest, InvalidIthRate) { + const char* name = grunstable_ith_rate( + std::numeric_limits::max(), nullptr); + EXPECT_EQ(name, nullptr); +} + +TEST_F(SimpleRateQueryTest, EmptyNameQuery) { + grunstable_rateid_type rateid = grunstable_ratequery_id(""); + EXPECT_EQ(rateid, get_invalid_rateid(pack)); +} + +TEST_F(SimpleRateQueryTest, InvalidNameQuery) { + grunstable_rateid_type rateid = grunstable_ratequery_id("NotAValidName"); + EXPECT_EQ(rateid, get_invalid_rateid(pack)); +} + +TEST_F(SimpleRateQueryTest, PtrInvalidRateId) { + double* ptr = + grunstable_ratequery_get_ptr(pack.my_rates(), get_invalid_rateid(pack)); + EXPECT_EQ(ptr, nullptr); +} diff --git a/tests/unit/test_ghost_zone.cpp b/tests/unit/test_ghost_zone.cpp index c565183a6..5bdf4ac8a 100644 --- a/tests/unit/test_ghost_zone.cpp +++ b/tests/unit/test_ghost_zone.cpp @@ -249,16 +249,14 @@ bool equal_ghost_values(val_vec_map_t& ref, val_vec_map_t& actual, return true; } -class APIGhostZoneTest: public grtest::ParametrizedConfigPresetFixture -{}; +using APIGhostZoneTest = grtest::ParametrizedConfigPresetFixture; TEST_P(APIGhostZoneTest, GridZoneStartEnd) { grid_props my_grid_props = {{5,6,7}, {1,0,2}}; - // alias the pack_ attribute tracked by the fixture - grtest::GrackleCtxPack& pack = pack_; - code_units my_units = pack_.initial_units(); + // the pack attribute holds grtest::GrackleCtxPack + code_units my_units = pack.initial_units(); // initialize pseudo random number generator std::uint32_t seed = 1379069008; From cd7deacef442058e1305c30516bfd65a056aa223 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Tue, 16 Dec 2025 21:10:15 -0500 Subject: [PATCH 107/175] add more ratequery tests --- tests/unit/test_api_ratequery.cpp | 112 ++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/tests/unit/test_api_ratequery.cpp b/tests/unit/test_api_ratequery.cpp index 260d69ba1..9033334d6 100644 --- a/tests/unit/test_api_ratequery.cpp +++ b/tests/unit/test_api_ratequery.cpp @@ -10,7 +10,10 @@ /// //===----------------------------------------------------------------------===// +#include #include +#include +#include #include #include "grtestutils/googletest/fixtures.hpp" @@ -47,3 +50,112 @@ TEST_F(SimpleRateQueryTest, PtrInvalidRateId) { grunstable_ratequery_get_ptr(pack.my_rates(), get_invalid_rateid(pack)); EXPECT_EQ(ptr, nullptr); } + +// will be implemented (in a much more robust manner) in the near future +unsigned long long grunstable_ratequery_nrates( + const chemistry_data_storage* my_rates) { + // current implementation is stupid! (in future, will use my_rates) + unsigned long long i = 0; + while (nullptr != grunstable_ith_rate(i, nullptr)) { + i++; + } + return i; +} + +// most of the remaining tests (and future planned tests) involve iterating +// through all rates made available via the ratequery interface. To make the +// tests themselves as easy to read as possible, we implate a C++-style +// iterator to wrap part of the interface + +struct RateNameIdPair { + std::string name; + grunstable_rateid_type rateid; +}; + +class RQIterator { + chemistry_data_storage* my_rates_; + unsigned long long counter_; + unsigned long long n_rates_; + RateNameIdPair pair_; + + RQIterator& update_pair_and_ret_(unsigned long long val) { + if (val < n_rates_) { + pair_.name = std::string(grunstable_ith_rate(val, &pair_.rateid)); + } + return *this; + } + +public: + using iterator_category = std::input_iterator_tag; + using value_type = RateNameIdPair; + using difference_type = std::ptrdiff_t; + using pointer = const RateNameIdPair*; + using reference = const RateNameIdPair; + + RQIterator(unsigned long long counter, unsigned long long n_rates, + chemistry_data_storage* my_rates) + : my_rates_(my_rates), counter_(counter), n_rates_(n_rates) { + update_pair_and_ret_(counter); + } + + bool operator==(RQIterator other) const { + return (counter_ == other.counter_) && (my_rates_ == other.my_rates_); + } + + bool operator!=(RQIterator other) const { return !(*this == other); } + reference operator*() const { return pair_; } + RQIterator& operator++() { return update_pair_and_ret_(++counter_); } + + RQIterator operator++(int) { + RQIterator ret = *this; + ++(*this); + return ret; + } +}; + +// used for creating the iterator and within range-based for-loops +class RateQueryRange { + grtest::GrackleCtxPack& pack_; + long long n_rates_; + +public: + explicit RateQueryRange(grtest::GrackleCtxPack& pack) + : pack_(pack), n_rates_(grunstable_ratequery_nrates(pack.my_rates())) {} + + RQIterator begin() { return RQIterator(0, n_rates_, pack_.my_rates()); } + RQIterator end() { return RQIterator(n_rates_, n_rates_, pack_.my_rates()); } +}; + +using ParametrizedRateQueryTest = grtest::ParametrizedConfigPresetFixture; + +TEST_P(ParametrizedRateQueryTest, AllUnique) { + std::set name_set; + std::set id_set; + for (const RateNameIdPair pair : RateQueryRange(pack)) { + ASSERT_TRUE(name_set.insert(pair.name).second) + << "the name, \"" << pair.name << "\" appears more than once"; + ASSERT_TRUE(id_set.insert(pair.rateid).second) + << "the id, " << pair.rateid << " appears more than once"; + } +} + +TEST_P(ParametrizedRateQueryTest, ConsistentIDs) { + for (const RateNameIdPair pair : RateQueryRange(pack)) { + grunstable_rateid_type rateid = grunstable_ratequery_id(pair.name.c_str()); + EXPECT_EQ(rateid, pair.rateid); + } +} + +using grtest::ChemPreset; +using grtest::FullConfPreset; +using grtest::InitialUnitPreset; + +INSTANTIATE_TEST_SUITE_P( + /* 1st arg is intentionally empty */, ParametrizedRateQueryTest, + ::testing::Values( + FullConfPreset{ChemPreset::primchem0, InitialUnitPreset::simple_z0}, + FullConfPreset{ChemPreset::primchem1, InitialUnitPreset::simple_z0}, + FullConfPreset{ChemPreset::primchem2, InitialUnitPreset::simple_z0}, + FullConfPreset{ChemPreset::primchem3, InitialUnitPreset::simple_z0}, + FullConfPreset{ChemPreset::primchem4_dustspecies3, + InitialUnitPreset::simple_z0})); From 24257017a30d3c805894e966c81b3bc50824d5f2 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Tue, 16 Dec 2025 21:11:49 -0500 Subject: [PATCH 108/175] tweak the name of the test_ghost_zone tests --- tests/unit/test_ghost_zone.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/test_ghost_zone.cpp b/tests/unit/test_ghost_zone.cpp index 5bdf4ac8a..16628721f 100644 --- a/tests/unit/test_ghost_zone.cpp +++ b/tests/unit/test_ghost_zone.cpp @@ -347,7 +347,7 @@ using grtest::ChemPreset; using grtest::InitialUnitPreset; INSTANTIATE_TEST_SUITE_P( - VaryingPrimordialChem, APIGhostZoneTest, + /* 1st arg is intentionally empty */, APIGhostZoneTest, ::testing::Values( FullConfPreset{ChemPreset::primchem0, InitialUnitPreset::simple_z0}, FullConfPreset{ChemPreset::primchem1, InitialUnitPreset::simple_z0}, From 37fad17d0a47c5822aa05af0bd578657900521c3 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Thu, 18 Dec 2025 17:01:18 -0500 Subject: [PATCH 109/175] factor out machinery for creating adaptor --- tests/grtestutils/CMakeLists.txt | 1 + tests/grtestutils/iterator_adaptor.hpp | 140 +++++++++++++++++++++++++ tests/unit/test_api_ratequery.cpp | 81 ++------------ 3 files changed, 147 insertions(+), 75 deletions(-) create mode 100644 tests/grtestutils/iterator_adaptor.hpp diff --git a/tests/grtestutils/CMakeLists.txt b/tests/grtestutils/CMakeLists.txt index f05d4ff1f..27bf11d17 100644 --- a/tests/grtestutils/CMakeLists.txt +++ b/tests/grtestutils/CMakeLists.txt @@ -80,6 +80,7 @@ add_library(grtestutils # files outside of the googletest subdirectory # -> these shouldn't include headers from the googletest subdirectory cmd.hpp cmd.cpp + iterator_adaptor.hpp os.hpp os.cpp preset.hpp preset.cpp utils.hpp utils.cpp diff --git a/tests/grtestutils/iterator_adaptor.hpp b/tests/grtestutils/iterator_adaptor.hpp new file mode 100644 index 000000000..ad84a3559 --- /dev/null +++ b/tests/grtestutils/iterator_adaptor.hpp @@ -0,0 +1,140 @@ +//===----------------------------------------------------------------------===// +// +// See the LICENSE file for license and copyright information +// SPDX-License-Identifier: NCSA AND BSD-3-Clause +// +//===----------------------------------------------------------------------===// +/// +/// @file +/// Declare and implement the IteratorAdaptor +/// +//===----------------------------------------------------------------------===// +#ifndef GRTESTUTILS_ITERATOR_ADAPTOR_HPP +#define GRTESTUTILS_ITERATOR_ADAPTOR_HPP + +#include +#include + +#include "grackle.h" +#include "preset.hpp" + +namespace grtest { + +/// the standard value-type that an IteratorAdaptor instantiation refers to +struct NameIdPair { + std::string name; + long long id; +}; + +/// implements a C++ style InputIterator by adapting a simple Plugin type +/// that wraps a set of Grackle functions +/// +/// This is useful for making use of C++ standard library algorithms and +/// (arguably more importantly) making use of range-based for-loops +template +class IteratorAdaptor { + unsigned long long counter_; + unsigned long long n_rates_; + Plugin plugin_; + NameIdPair current_pair_; + + /// Updates current_pair_ and returns `*this` + IteratorAdaptor& update_pair_and_ret_(unsigned long long current_count) { + if (current_count < this->n_rates_) { + this->current_pair_ = this->plugin_(current_count); + } + return *this; + } + +public: + using iterator_category = std::input_iterator_tag; + using value_type = NameIdPair; + using difference_type = std::ptrdiff_t; + using pointer = const NameIdPair*; + using reference = const NameIdPair; + + /// construct a new instance + IteratorAdaptor(unsigned long long counter, unsigned long long n_rates, + Plugin plugin) + : counter_(counter), n_rates_(n_rates), plugin_(plugin) { + update_pair_and_ret_(counter); + } + + /// implements the equality operation + bool operator==(const IteratorAdaptor& other) const { + return (counter_ == other.counter_) && (plugin_ == other.plugin_); + } + + /// implements the inequality operation + bool operator!=(const IteratorAdaptor& other) const { + return !(*this == other); + } + + /// implements the dereference operation + reference operator*() const { return current_pair_; } + + /// implements the prefix increment operation + /// + /// This effectively implements `++x`, which increments the value of `x` + /// before determining the returned value. In other words, `++x` returns the + /// value of `x` from **after** after the increment + IteratorAdaptor& operator++() { return update_pair_and_ret_(++counter_); } + + /// implements the prefix increment operation + /// + /// This effectively implements `x++`, which increments the value of `x` + /// after determining the returned value. In other words, `x++` returns the + /// value of `x` from **before** the increment + IteratorAdaptor operator++(int) { + IteratorAdaptor ret = *this; + ++(*this); + return ret; + } +}; + +// Now lets use this machinery to implement logic iterating over the names +// accessible through the ratequery api + +struct RateQueryPlugin { + chemistry_data_storage* my_rates; + + NameIdPair operator()(unsigned long long i) const { + grunstable_rateid_type tmp; + const char* name = grunstable_ith_rate(i, &tmp); + return NameIdPair{name, tmp}; + } + + bool operator==(const RateQueryPlugin& other) const { + return my_rates == other.my_rates; + } +}; + +// will be implemented (in a much more robust manner) in the near future +inline unsigned long long grunstable_ratequery_nrates( + const chemistry_data_storage* my_rates) { + // current implementation is stupid! (in future, will use my_rates) + unsigned long long i = 0; + while (nullptr != grunstable_ith_rate(i, nullptr)) { + i++; + } + return i; +} + +/// used for creating the iterator and within range-based for-loops +class RateQueryRange { + RateQueryPlugin plugin_; + using iterator = IteratorAdaptor; + long long n_rates_; + +public: + explicit RateQueryRange(grtest::GrackleCtxPack& pack) + : plugin_(RateQueryPlugin{pack.my_rates()}), + n_rates_(grunstable_ratequery_nrates(pack.my_rates())) {} + + iterator begin() { return iterator(0, n_rates_, plugin_); } + iterator end() { return iterator(n_rates_, n_rates_, plugin_); } +}; + +} // namespace grtest + +#endif // GRTESTUTILS_ITERATOR_ADAPTOR_HPP diff --git a/tests/unit/test_api_ratequery.cpp b/tests/unit/test_api_ratequery.cpp index 9033334d6..02d0882bd 100644 --- a/tests/unit/test_api_ratequery.cpp +++ b/tests/unit/test_api_ratequery.cpp @@ -15,6 +15,7 @@ #include #include #include +#include "grtestutils/iterator_adaptor.hpp" #include "grtestutils/googletest/fixtures.hpp" #include "grackle.h" @@ -51,98 +52,28 @@ TEST_F(SimpleRateQueryTest, PtrInvalidRateId) { EXPECT_EQ(ptr, nullptr); } -// will be implemented (in a much more robust manner) in the near future -unsigned long long grunstable_ratequery_nrates( - const chemistry_data_storage* my_rates) { - // current implementation is stupid! (in future, will use my_rates) - unsigned long long i = 0; - while (nullptr != grunstable_ith_rate(i, nullptr)) { - i++; - } - return i; -} - // most of the remaining tests (and future planned tests) involve iterating // through all rates made available via the ratequery interface. To make the // tests themselves as easy to read as possible, we implate a C++-style // iterator to wrap part of the interface -struct RateNameIdPair { - std::string name; - grunstable_rateid_type rateid; -}; - -class RQIterator { - chemistry_data_storage* my_rates_; - unsigned long long counter_; - unsigned long long n_rates_; - RateNameIdPair pair_; - - RQIterator& update_pair_and_ret_(unsigned long long val) { - if (val < n_rates_) { - pair_.name = std::string(grunstable_ith_rate(val, &pair_.rateid)); - } - return *this; - } - -public: - using iterator_category = std::input_iterator_tag; - using value_type = RateNameIdPair; - using difference_type = std::ptrdiff_t; - using pointer = const RateNameIdPair*; - using reference = const RateNameIdPair; - - RQIterator(unsigned long long counter, unsigned long long n_rates, - chemistry_data_storage* my_rates) - : my_rates_(my_rates), counter_(counter), n_rates_(n_rates) { - update_pair_and_ret_(counter); - } - - bool operator==(RQIterator other) const { - return (counter_ == other.counter_) && (my_rates_ == other.my_rates_); - } - - bool operator!=(RQIterator other) const { return !(*this == other); } - reference operator*() const { return pair_; } - RQIterator& operator++() { return update_pair_and_ret_(++counter_); } - - RQIterator operator++(int) { - RQIterator ret = *this; - ++(*this); - return ret; - } -}; - -// used for creating the iterator and within range-based for-loops -class RateQueryRange { - grtest::GrackleCtxPack& pack_; - long long n_rates_; - -public: - explicit RateQueryRange(grtest::GrackleCtxPack& pack) - : pack_(pack), n_rates_(grunstable_ratequery_nrates(pack.my_rates())) {} - - RQIterator begin() { return RQIterator(0, n_rates_, pack_.my_rates()); } - RQIterator end() { return RQIterator(n_rates_, n_rates_, pack_.my_rates()); } -}; - using ParametrizedRateQueryTest = grtest::ParametrizedConfigPresetFixture; TEST_P(ParametrizedRateQueryTest, AllUnique) { std::set name_set; std::set id_set; - for (const RateNameIdPair pair : RateQueryRange(pack)) { + for (const grtest::NameIdPair pair : grtest::RateQueryRange(pack)) { ASSERT_TRUE(name_set.insert(pair.name).second) << "the name, \"" << pair.name << "\" appears more than once"; - ASSERT_TRUE(id_set.insert(pair.rateid).second) - << "the id, " << pair.rateid << " appears more than once"; + ASSERT_TRUE(id_set.insert(pair.id).second) + << "the id, " << pair.id << " appears more than once"; } } TEST_P(ParametrizedRateQueryTest, ConsistentIDs) { - for (const RateNameIdPair pair : RateQueryRange(pack)) { + for (const grtest::NameIdPair pair : grtest::RateQueryRange(pack)) { grunstable_rateid_type rateid = grunstable_ratequery_id(pair.name.c_str()); - EXPECT_EQ(rateid, pair.rateid); + EXPECT_EQ(rateid, pair.id); } } From 39e1c0c7d8183b53c366f033e69b7a4fe95e8ec7 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Fri, 19 Dec 2025 08:14:21 -0500 Subject: [PATCH 110/175] fix a broken header include --- tests/grtestutils/googletest/fixtures.hpp | 3 --- tests/grtestutils/preset.hpp | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/grtestutils/googletest/fixtures.hpp b/tests/grtestutils/googletest/fixtures.hpp index e3998dbbe..25c53bb22 100644 --- a/tests/grtestutils/googletest/fixtures.hpp +++ b/tests/grtestutils/googletest/fixtures.hpp @@ -18,9 +18,6 @@ // because we include gtest.h here, we should NOT include this file in any // grtest source files (in other words, this should be a header-only file) -#include - -#include "grackle.h" #include "../preset.hpp" namespace grtest { diff --git a/tests/grtestutils/preset.hpp b/tests/grtestutils/preset.hpp index b30f69632..6f942167d 100644 --- a/tests/grtestutils/preset.hpp +++ b/tests/grtestutils/preset.hpp @@ -13,6 +13,7 @@ #define GRTESTUTILS_PRESET_HPP #include "grackle.h" +#include #include #include From 804efcfe0f22d315c94368ea2be4a2e2131aa42e Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Thu, 11 Dec 2025 20:46:54 -0500 Subject: [PATCH 111/175] some light refactoring of the rate utlities --- src/clib/rate_utils.cpp | 50 ++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/src/clib/rate_utils.cpp b/src/clib/rate_utils.cpp index f24cf66fd..4cb8d3315 100644 --- a/src/clib/rate_utils.cpp +++ b/src/clib/rate_utils.cpp @@ -10,9 +10,8 @@ /// //===----------------------------------------------------------------------===// -#include // bool, true, and false are defined -#include // strcmp -#include // LLONG_MAX +#include // strcmp +#include // LLONG_MAX #include "grackle.h" #include "internal_types.hpp" // CollisionalRxnRateCollection #include "LUT.hpp" // CollisionalRxnLUT @@ -39,15 +38,17 @@ // offsetof in this fashion // +namespace grackle::impl::ratequery { + // we have reserved the right to change this value at any time enum { UNDEFINED_RATE_ID_ = 0 }; // introduce some basic machinery to help us implement dynamic lookup of rates -typedef struct { +struct rateprop_ { double* data; const char* name; -} rateprop_; +}; static inline rateprop_ mk_rateprop_(double* rate, const char* name) { rateprop_ out; @@ -68,9 +69,9 @@ static inline rateprop_ mk_rateprop_standard_kcol_( } #define MKPROP_(PTR, NAME) \ - mk_rateprop_(((PTR) == NULL) ? NULL : (PTR)->NAME, #NAME) + mk_rateprop_(((PTR) == nullptr) ? nullptr : (PTR)->NAME, #NAME) #define MKPROP_SCALAR_(PTR, NAME) \ - mk_rateprop_(((PTR) == NULL) ? NULL : &((PTR)->NAME), #NAME) + mk_rateprop_(((PTR) == nullptr) ? nullptr : &((PTR)->NAME), #NAME) #define MKPROP_STANDARD_KCOL_(PTR, NAME, INDEX) \ mk_rateprop_standard_kcol_(PTR, #NAME, INDEX) @@ -97,7 +98,7 @@ static rateprop_ get_CollisionalRxn_rateprop_(chemistry_data_storage* my_rates, #include "collisional_rxn_rate_members.def" #undef ENTRY default: { - rateprop_ out = {NULL, NULL}; + rateprop_ out = {nullptr, nullptr}; return out; } } @@ -145,7 +146,7 @@ static rateprop_ get_MiscRxn_rateprop_(chemistry_data_storage* my_rates, case MiscRxn_k31: return MKPROP_SCALAR_(my_rates, k31); default: { - rateprop_ out = {NULL, NULL}; + rateprop_ out = {nullptr, nullptr}; return out; } } @@ -199,40 +200,49 @@ static struct ratequery_rslt_ query_rateprop_(chemistry_data_storage* my_rates, } total_len += cur_set.len; } - struct ratequery_rslt_ out = {UNDEFINED_RATE_ID_, {NULL, NULL}}; + struct ratequery_rslt_ out = {UNDEFINED_RATE_ID_, {nullptr, nullptr}}; return out; } +} // namespace grackle::impl::ratequery + // here we implement the public API // -------------------------------- extern "C" grunstable_rateid_type grunstable_ratequery_id(const char* name) { - if (name == NULL) { - return UNDEFINED_RATE_ID_; + namespace rate_q = grackle::impl::ratequery; + + if (name == nullptr) { + return rate_q::UNDEFINED_RATE_ID_; } - for (int set_idx = 0; set_idx < rate_registry_.len; set_idx++) { - const struct rateprop_set_ cur_set = rate_registry_.sets[set_idx]; + for (int set_idx = 0; set_idx < rate_q::rate_registry_.len; set_idx++) { + const rate_q::rateprop_set_ cur_set = rate_q::rate_registry_.sets[set_idx]; for (int i = 0; i < cur_set.len; i++) { - rateprop_ prop = cur_set.fn(NULL, i); - if (strcmp(name, prop.name) == 0) { + rate_q::rateprop_ prop = cur_set.fn(nullptr, i); + if (std::strcmp(name, prop.name) == 0) { return cur_set.id_offset + i; } } } - return UNDEFINED_RATE_ID_; + return rate_q::UNDEFINED_RATE_ID_; } extern "C" double* grunstable_ratequery_get_ptr( chemistry_data_storage* my_rates, grunstable_rateid_type rate_id) { - return query_rateprop_(my_rates, rate_id, true).prop.data; + namespace rate_q = grackle::impl::ratequery; + + return rate_q::query_rateprop_(my_rates, rate_id, true).prop.data; } extern "C" const char* grunstable_ith_rate( unsigned long long i, grunstable_rateid_type* out_rate_id) { + namespace rate_q = grackle::impl::ratequery; + const long long sanitized_i = (i < LLONG_MAX) ? (long long)i : -1; - struct ratequery_rslt_ tmp = query_rateprop_(NULL, sanitized_i, false); - if (out_rate_id != NULL) { + rate_q::ratequery_rslt_ tmp = + rate_q::query_rateprop_(nullptr, sanitized_i, false); + if (out_rate_id != nullptr) { *out_rate_id = tmp.rate_id; } return tmp.prop.name; From ff9eca6b864d15fdd1b449bff0d75db29336e85a Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Thu, 11 Dec 2025 20:58:36 -0500 Subject: [PATCH 112/175] rename rateprop -> ratequery::Descr (as in a rate description) --- src/clib/rate_utils.cpp | 105 ++++++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 53 deletions(-) diff --git a/src/clib/rate_utils.cpp b/src/clib/rate_utils.cpp index 4cb8d3315..67ceee203 100644 --- a/src/clib/rate_utils.cpp +++ b/src/clib/rate_utils.cpp @@ -45,35 +45,36 @@ enum { UNDEFINED_RATE_ID_ = 0 }; // introduce some basic machinery to help us implement dynamic lookup of rates -struct rateprop_ { +/// A description of a rate +struct Descr { double* data; const char* name; }; -static inline rateprop_ mk_rateprop_(double* rate, const char* name) { - rateprop_ out; +static inline Descr mk_Descr(double* rate, const char* name) { + Descr out; out.data = rate; out.name = name; return out; } -static inline rateprop_ mk_rateprop_standard_kcol_( - chemistry_data_storage* my_rates, const char* name, int index) { +static inline Descr mk_Descr_standard_kcol_(chemistry_data_storage* my_rates, + const char* name, int index) { if ((my_rates == nullptr) || (my_rates->opaque_storage == nullptr) || (my_rates->opaque_storage->kcol_rate_tables == nullptr)) { - return mk_rateprop_(nullptr, name); + return mk_Descr(nullptr, name); } else { - return mk_rateprop_(my_rates->opaque_storage->kcol_rate_tables->data[index], - name); + return mk_Descr(my_rates->opaque_storage->kcol_rate_tables->data[index], + name); } } -#define MKPROP_(PTR, NAME) \ - mk_rateprop_(((PTR) == nullptr) ? nullptr : (PTR)->NAME, #NAME) -#define MKPROP_SCALAR_(PTR, NAME) \ - mk_rateprop_(((PTR) == nullptr) ? nullptr : &((PTR)->NAME), #NAME) -#define MKPROP_STANDARD_KCOL_(PTR, NAME, INDEX) \ - mk_rateprop_standard_kcol_(PTR, #NAME, INDEX) +#define MKDESCR_(PTR, NAME) \ + mk_Descr(((PTR) == nullptr) ? nullptr : (PTR)->NAME, #NAME) +#define MKDESCR_SCALAR_(PTR, NAME) \ + mk_Descr(((PTR) == nullptr) ? nullptr : &((PTR)->NAME), #NAME) +#define MKDESCR_STANDARD_KCOL_(PTR, NAME, INDEX) \ + mk_Descr_standard_kcol_(PTR, #NAME, INDEX) // Create machinery to lookup Standard-Form Collisional Reaction Rates // ------------------------------------------------------------------- @@ -88,17 +89,16 @@ static inline rateprop_ mk_rateprop_standard_kcol_( // of the previous value (if a value isn't explicitly specified) // - CollisionalRxnLUT::NUM_ENTRIES specifies the number of other enumeration // constants (excluding CollisionalRxnLUT::NUM_ENTRIES) in the enum -static rateprop_ get_CollisionalRxn_rateprop_(chemistry_data_storage* my_rates, - int i) { +static Descr get_CollisionalRxn_Descr(chemistry_data_storage* my_rates, int i) { switch (i) { #define ENTRY(NAME) \ case CollisionalRxnLUT::NAME: { \ - return MKPROP_STANDARD_KCOL_(my_rates, NAME, CollisionalRxnLUT::NAME); \ + return MKDESCR_STANDARD_KCOL_(my_rates, NAME, CollisionalRxnLUT::NAME); \ } #include "collisional_rxn_rate_members.def" #undef ENTRY default: { - rateprop_ out = {nullptr, nullptr}; + Descr out = {nullptr, nullptr}; return out; } } @@ -121,32 +121,31 @@ enum MiscRxnRateKind_ { MiscRxn_NRATES // <- will hold the number of reactions }; -static rateprop_ get_MiscRxn_rateprop_(chemistry_data_storage* my_rates, - int i) { +static Descr get_MiscRxn_Descr(chemistry_data_storage* my_rates, int i) { switch (i) { // density dependent version of k13 (which is a CollisionalRxn) case MiscRxn_k13dd: - return MKPROP_(my_rates, k13dd); + return MKDESCR_(my_rates, k13dd); // Radiative rates for 6-species (for external field): case MiscRxn_k24: - return MKPROP_SCALAR_(my_rates, k24); + return MKDESCR_SCALAR_(my_rates, k24); case MiscRxn_k25: - return MKPROP_SCALAR_(my_rates, k25); + return MKDESCR_SCALAR_(my_rates, k25); case MiscRxn_k26: - return MKPROP_SCALAR_(my_rates, k26); + return MKDESCR_SCALAR_(my_rates, k26); // Radiative rates for 9-species case MiscRxn_k27: - return MKPROP_SCALAR_(my_rates, k27); + return MKDESCR_SCALAR_(my_rates, k27); case MiscRxn_k28: - return MKPROP_SCALAR_(my_rates, k28); + return MKDESCR_SCALAR_(my_rates, k28); case MiscRxn_k29: - return MKPROP_SCALAR_(my_rates, k29); + return MKDESCR_SCALAR_(my_rates, k29); case MiscRxn_k30: - return MKPROP_SCALAR_(my_rates, k30); + return MKDESCR_SCALAR_(my_rates, k30); case MiscRxn_k31: - return MKPROP_SCALAR_(my_rates, k31); + return MKDESCR_SCALAR_(my_rates, k31); default: { - rateprop_ out = {nullptr, nullptr}; + Descr out = {nullptr, nullptr}; return out; } } @@ -155,47 +154,47 @@ static rateprop_ get_MiscRxn_rateprop_(chemistry_data_storage* my_rates, // define some additional generic machinery // ---------------------------------------- -#define RATE_SET_COUNT 2 -typedef rateprop_ fetch_rateprop_fn(chemistry_data_storage*, int); -struct rateprop_set_ { +#define DESCR_SET_COUNT 2 +typedef Descr fetch_Descr_fn(chemistry_data_storage*, int); +struct Descr_set_ { int id_offset; int len; - fetch_rateprop_fn* fn; + fetch_Descr_fn* fn; }; struct rate_registry_type_ { int len; - struct rateprop_set_ sets[RATE_SET_COUNT]; + Descr_set_ sets[DESCR_SET_COUNT]; }; static const struct rate_registry_type_ rate_registry_ = { - /* len: */ RATE_SET_COUNT, + /* len: */ DESCR_SET_COUNT, /* sets: */ { - {1000, CollisionalRxnLUT::NUM_ENTRIES, &get_CollisionalRxn_rateprop_}, - {2000, MiscRxn_NRATES, &get_MiscRxn_rateprop_}}}; + {1000, CollisionalRxnLUT::NUM_ENTRIES, &get_CollisionalRxn_Descr}, + {2000, MiscRxn_NRATES, &get_MiscRxn_Descr}}}; struct ratequery_rslt_ { grunstable_rateid_type rate_id; - rateprop_ prop; + Descr descr; }; -/// internal function to search for the rate_property i +/// internal function to search for the rate description i /// /// We interpret i as rate_id, when use_rate_id is true. Otherwise, we just -/// look for the ith rateprop (we introduce an artificial distinction between -/// the 2 cases because we want to reserve the right to be able to change the -/// relationship if it becomes convenient in the future) -static struct ratequery_rslt_ query_rateprop_(chemistry_data_storage* my_rates, - long long i, bool use_rate_id) { +/// look for the ith rate description (we introduce an artificial distinction +/// between the 2 cases because we want to reserve the right to be able to +/// change the relationship if it becomes convenient in the future) +static struct ratequery_rslt_ query_Descr(chemistry_data_storage* my_rates, + long long i, bool use_rate_id) { int total_len = 0; // <- we increment this as we go through the rates for (int set_idx = 0; set_idx < rate_registry_.len; set_idx++) { - const struct rateprop_set_ cur_set = rate_registry_.sets[set_idx]; + const struct Descr_set_ cur_set = rate_registry_.sets[set_idx]; const long long tmp = (use_rate_id) ? i - cur_set.id_offset : i - total_len; if ((tmp >= 0) && (tmp < cur_set.len)) { struct ratequery_rslt_ out; out.rate_id = tmp + cur_set.id_offset; - out.prop = cur_set.fn(my_rates, tmp); + out.descr = cur_set.fn(my_rates, tmp); return out; } total_len += cur_set.len; @@ -217,10 +216,10 @@ extern "C" grunstable_rateid_type grunstable_ratequery_id(const char* name) { } for (int set_idx = 0; set_idx < rate_q::rate_registry_.len; set_idx++) { - const rate_q::rateprop_set_ cur_set = rate_q::rate_registry_.sets[set_idx]; + const rate_q::Descr_set_ cur_set = rate_q::rate_registry_.sets[set_idx]; for (int i = 0; i < cur_set.len; i++) { - rate_q::rateprop_ prop = cur_set.fn(nullptr, i); - if (std::strcmp(name, prop.name) == 0) { + rate_q::Descr descr = cur_set.fn(nullptr, i); + if (std::strcmp(name, descr.name) == 0) { return cur_set.id_offset + i; } } @@ -232,7 +231,7 @@ extern "C" double* grunstable_ratequery_get_ptr( chemistry_data_storage* my_rates, grunstable_rateid_type rate_id) { namespace rate_q = grackle::impl::ratequery; - return rate_q::query_rateprop_(my_rates, rate_id, true).prop.data; + return rate_q::query_Descr(my_rates, rate_id, true).descr.data; } extern "C" const char* grunstable_ith_rate( @@ -241,9 +240,9 @@ extern "C" const char* grunstable_ith_rate( const long long sanitized_i = (i < LLONG_MAX) ? (long long)i : -1; rate_q::ratequery_rslt_ tmp = - rate_q::query_rateprop_(nullptr, sanitized_i, false); + rate_q::query_Descr(nullptr, sanitized_i, false); if (out_rate_id != nullptr) { *out_rate_id = tmp.rate_id; } - return tmp.prop.name; + return tmp.descr.name; } From 9a32a9e121f9c44bae3e270f42597c0d7767edcd Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Thu, 11 Dec 2025 21:47:41 -0500 Subject: [PATCH 113/175] slightly more refactoring --- src/clib/rate_utils.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/clib/rate_utils.cpp b/src/clib/rate_utils.cpp index 67ceee203..1d075b3a0 100644 --- a/src/clib/rate_utils.cpp +++ b/src/clib/rate_utils.cpp @@ -156,17 +156,17 @@ static Descr get_MiscRxn_Descr(chemistry_data_storage* my_rates, int i) { #define DESCR_SET_COUNT 2 typedef Descr fetch_Descr_fn(chemistry_data_storage*, int); -struct Descr_set_ { +struct DescrSet { int id_offset; int len; fetch_Descr_fn* fn; }; -struct rate_registry_type_ { +struct DescrRegistry { int len; - Descr_set_ sets[DESCR_SET_COUNT]; + DescrSet sets[DESCR_SET_COUNT]; }; -static const struct rate_registry_type_ rate_registry_ = { +static const struct DescrRegistry descr_registry_ = { /* len: */ DESCR_SET_COUNT, /* sets: */ { {1000, CollisionalRxnLUT::NUM_ENTRIES, &get_CollisionalRxn_Descr}, @@ -187,8 +187,8 @@ static struct ratequery_rslt_ query_Descr(chemistry_data_storage* my_rates, long long i, bool use_rate_id) { int total_len = 0; // <- we increment this as we go through the rates - for (int set_idx = 0; set_idx < rate_registry_.len; set_idx++) { - const struct Descr_set_ cur_set = rate_registry_.sets[set_idx]; + for (int set_idx = 0; set_idx < descr_registry_.len; set_idx++) { + const struct DescrSet cur_set = descr_registry_.sets[set_idx]; const long long tmp = (use_rate_id) ? i - cur_set.id_offset : i - total_len; if ((tmp >= 0) && (tmp < cur_set.len)) { @@ -215,8 +215,8 @@ extern "C" grunstable_rateid_type grunstable_ratequery_id(const char* name) { return rate_q::UNDEFINED_RATE_ID_; } - for (int set_idx = 0; set_idx < rate_q::rate_registry_.len; set_idx++) { - const rate_q::Descr_set_ cur_set = rate_q::rate_registry_.sets[set_idx]; + for (int set_idx = 0; set_idx < rate_q::descr_registry_.len; set_idx++) { + const rate_q::DescrSet cur_set = rate_q::descr_registry_.sets[set_idx]; for (int i = 0; i < cur_set.len; i++) { rate_q::Descr descr = cur_set.fn(nullptr, i); if (std::strcmp(name, descr.name) == 0) { From d13591ea98784a627e8f44c326268cfb57652c90 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Thu, 11 Dec 2025 22:13:40 -0500 Subject: [PATCH 114/175] tweak signatures of grunstable_(ratequery_id|ith_rate) --- src/clib/rate_utils.cpp | 6 ++-- src/include/grackle.h | 9 ++++-- src/python/gracklepy/grackle_defs.pxd | 5 +++- src/python/gracklepy/grackle_wrapper.pyx | 37 ++++++++++++++---------- tests/grtestutils/iterator_adaptor.hpp | 4 +-- tests/grtestutils/preset.hpp | 8 +++++ tests/unit/test_api_ratequery.cpp | 12 ++++---- 7 files changed, 53 insertions(+), 28 deletions(-) diff --git a/src/clib/rate_utils.cpp b/src/clib/rate_utils.cpp index 1d075b3a0..ce28a5be7 100644 --- a/src/clib/rate_utils.cpp +++ b/src/clib/rate_utils.cpp @@ -208,7 +208,8 @@ static struct ratequery_rslt_ query_Descr(chemistry_data_storage* my_rates, // here we implement the public API // -------------------------------- -extern "C" grunstable_rateid_type grunstable_ratequery_id(const char* name) { +extern "C" grunstable_rateid_type grunstable_ratequery_id( + const chemistry_data_storage* my_rates, const char* name) { namespace rate_q = grackle::impl::ratequery; if (name == nullptr) { @@ -235,7 +236,8 @@ extern "C" double* grunstable_ratequery_get_ptr( } extern "C" const char* grunstable_ith_rate( - unsigned long long i, grunstable_rateid_type* out_rate_id) { + const chemistry_data_storage* my_rates, unsigned long long i, + grunstable_rateid_type* out_rate_id) { namespace rate_q = grackle::impl::ratequery; const long long sanitized_i = (i < LLONG_MAX) ? (long long)i : -1; diff --git a/src/include/grackle.h b/src/include/grackle.h index 0473ebd0e..84b63c51d 100644 --- a/src/include/grackle.h +++ b/src/include/grackle.h @@ -231,7 +231,8 @@ typedef long long grunstable_rateid_type; /// > [!note] /// > While this is unstable, not all rates may be known yet (but, the number /// > rates are all accessible). -grunstable_rateid_type grunstable_ratequery_id(const char* name); +grunstable_rateid_type grunstable_ratequery_id( + const chemistry_data_storage* my_rates, const char* name); /// Access the pointer associated with the rateid from myrates /// @@ -270,14 +271,16 @@ double* grunstable_ratequery_get_ptr( /// > [!warning] /// > The order of parameters may change between different versions of Grackle /// -/// @param[in] i the index of the access rate +/// @param[in] my_rates The object being queried +/// @param[in] i the index of the accessed rate /// @param[out] out_rate_id A pointer to store the rate of the queried rate_id. /// The behavior is **NOT** currently well defined when there are `i` or /// fewer registered rates. /// @result Pointer to the string-literal specifying the rate's name. This is /// `NULL`, if there are `i` or fewer registered rates. const char* grunstable_ith_rate( - unsigned long long i, grunstable_rateid_type* out_rate_id + const chemistry_data_storage* my_rates, unsigned long long i, + grunstable_rateid_type* out_rate_id ); /** @}*/ // end of group diff --git a/src/python/gracklepy/grackle_defs.pxd b/src/python/gracklepy/grackle_defs.pxd index 7ac1eecd2..462b83503 100644 --- a/src/python/gracklepy/grackle_defs.pxd +++ b/src/python/gracklepy/grackle_defs.pxd @@ -298,12 +298,15 @@ cdef extern from "grackle.h": # the unstable API ctypedef long long grunstable_rateid_type - grunstable_rateid_type grunstable_ratequery_id(const char* name) + grunstable_rateid_type grunstable_ratequery_id( + const c_chemistry_data_storage* my_rates, + const char* name) double* grunstable_ratequery_get_ptr( c_chemistry_data_storage* my_rates, grunstable_rateid_type rate_id) const char* grunstable_ith_rate( + const c_chemistry_data_storage* my_rates, unsigned long long i, grunstable_rateid_type* out_rate_id) diff --git a/src/python/gracklepy/grackle_wrapper.pyx b/src/python/gracklepy/grackle_wrapper.pyx index d8d827f88..320fa1ea1 100644 --- a/src/python/gracklepy/grackle_wrapper.pyx +++ b/src/python/gracklepy/grackle_wrapper.pyx @@ -897,18 +897,6 @@ def _get_rate_shape(wrapped_chemistry_data_obj, rate_name): "the shape of the rate {rate_name!r} has not been specified yet" ) -@functools.lru_cache # (could use functools.cache starting in python3.9) -def _name_rateid_map(): - cdef dict out = {} - cdef const char* rate_name - cdef grunstable_rateid_type rate_id - cdef unsigned long long i = 0 - while True: - rate_name = grunstable_ith_rate(i, &rate_id) - if rate_name is NULL: - return out - out[rate_name.decode('UTF-8')] = int(rate_id) - i+=1 cdef class _rate_mapping_access: # This class is used internally by the chemistry_data extension class to @@ -925,10 +913,12 @@ cdef class _rate_mapping_access: cdef c_chemistry_data_storage *_ptr cdef object _rate_shape_callback + cdef dict _cached_name_rateid_map def __cinit__(self): self._ptr = NULL self._rate_shape_callback = None + self._cached_name_rateid_map = None def __init__(self): # Prevent accidental instantiation from normal Python code @@ -945,11 +935,28 @@ cdef class _rate_mapping_access: out._rate_shape_callback = callback return out + @property + def _name_rateid_map(self): + if self._cached_name_rateid_map is not None: + return self._cached_name_rateid_map + + cdef dict out = {} + cdef const char* rate_name + cdef grunstable_rateid_type rate_id + cdef unsigned long long i = 0 + while True: + rate_name = grunstable_ith_rate(self._ptr, i, &rate_id) + if rate_name is NULL: + self._cached_name_rateid_map = out + return out + out[rate_name.decode('UTF-8')] = int(rate_id) + i+=1 + def _access_rate(self, key, val): # determine whether the rate needs to be updated update_rate = (val is not _NOSETVAL) - rate_id = _name_rateid_map()[key] # will raise a KeyError if not known + rate_id = self._name_rateid_map[key] # will raise a KeyError if not known if self._ptr is NULL: raise RuntimeError( @@ -991,9 +998,9 @@ cdef class _rate_mapping_access: def __setitem__(self, key, value): self._access_rate(key, value) - def __iter__(self): return iter(_name_rateid_map()) + def __iter__(self): return iter(self._name_rateid_map) - def __len__(self): return len(_name_rateid_map()) + def __len__(self): return len(self._name_rateid_map) diff --git a/tests/grtestutils/iterator_adaptor.hpp b/tests/grtestutils/iterator_adaptor.hpp index ad84a3559..af5f9f259 100644 --- a/tests/grtestutils/iterator_adaptor.hpp +++ b/tests/grtestutils/iterator_adaptor.hpp @@ -100,7 +100,7 @@ struct RateQueryPlugin { NameIdPair operator()(unsigned long long i) const { grunstable_rateid_type tmp; - const char* name = grunstable_ith_rate(i, &tmp); + const char* name = grunstable_ith_rate(my_rates, i, &tmp); return NameIdPair{name, tmp}; } @@ -114,7 +114,7 @@ inline unsigned long long grunstable_ratequery_nrates( const chemistry_data_storage* my_rates) { // current implementation is stupid! (in future, will use my_rates) unsigned long long i = 0; - while (nullptr != grunstable_ith_rate(i, nullptr)) { + while (nullptr != grunstable_ith_rate(my_rates, i, nullptr)) { i++; } return i; diff --git a/tests/grtestutils/preset.hpp b/tests/grtestutils/preset.hpp index 6f942167d..738a79dad 100644 --- a/tests/grtestutils/preset.hpp +++ b/tests/grtestutils/preset.hpp @@ -108,8 +108,16 @@ class GrackleCtxPack { // getter functions const code_units& initial_units() const { return this->initial_units_; } + chemistry_data* my_chemistry() { return this->my_chemistry_.get(); } + const chemistry_data* my_chemistry() const { + return this->my_chemistry_.get(); + } + chemistry_data_storage* my_rates() { return this->my_rates_.get(); } + const chemistry_data_storage* my_rates() const { + return this->my_rates_.get(); + } /// create an initialized instance from a preset static GrackleCtxPack create(const FullConfPreset& preset, diff --git a/tests/unit/test_api_ratequery.cpp b/tests/unit/test_api_ratequery.cpp index 02d0882bd..cf9c5f52e 100644 --- a/tests/unit/test_api_ratequery.cpp +++ b/tests/unit/test_api_ratequery.cpp @@ -23,7 +23,7 @@ /// returns the rateid used to denote invalid rate names grunstable_rateid_type get_invalid_rateid(const grtest::GrackleCtxPack& pack) { // although we don't use pack, yet a forthcoming refactor requires it - return grunstable_ratequery_id(nullptr); + return grunstable_ratequery_id(pack.my_rates(), nullptr); } using SimpleRateQueryTest = @@ -32,17 +32,18 @@ using SimpleRateQueryTest = TEST_F(SimpleRateQueryTest, InvalidIthRate) { const char* name = grunstable_ith_rate( - std::numeric_limits::max(), nullptr); + pack.my_rates(), std::numeric_limits::max(), nullptr); EXPECT_EQ(name, nullptr); } TEST_F(SimpleRateQueryTest, EmptyNameQuery) { - grunstable_rateid_type rateid = grunstable_ratequery_id(""); + grunstable_rateid_type rateid = grunstable_ratequery_id(pack.my_rates(), ""); EXPECT_EQ(rateid, get_invalid_rateid(pack)); } TEST_F(SimpleRateQueryTest, InvalidNameQuery) { - grunstable_rateid_type rateid = grunstable_ratequery_id("NotAValidName"); + grunstable_rateid_type rateid = + grunstable_ratequery_id(pack.my_rates(), "NotAValidName"); EXPECT_EQ(rateid, get_invalid_rateid(pack)); } @@ -72,7 +73,8 @@ TEST_P(ParametrizedRateQueryTest, AllUnique) { TEST_P(ParametrizedRateQueryTest, ConsistentIDs) { for (const grtest::NameIdPair pair : grtest::RateQueryRange(pack)) { - grunstable_rateid_type rateid = grunstable_ratequery_id(pair.name.c_str()); + grunstable_rateid_type rateid = + grunstable_ratequery_id(pack.my_rates(), pair.name.c_str()); EXPECT_EQ(rateid, pair.id); } } From 1fff13c7552459502544a12eb4c0c5a817bb47fb Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Fri, 12 Dec 2025 08:24:24 -0500 Subject: [PATCH 115/175] rename rate_utils to ratequery --- src/clib/CMakeLists.txt | 2 +- src/clib/Make.config.objects | 2 +- src/clib/{rate_utils.cpp => ratequery.cpp} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename src/clib/{rate_utils.cpp => ratequery.cpp} (100%) diff --git a/src/clib/CMakeLists.txt b/src/clib/CMakeLists.txt index 693d6ea37..9d417790b 100644 --- a/src/clib/CMakeLists.txt +++ b/src/clib/CMakeLists.txt @@ -120,7 +120,7 @@ add_library(Grackle_Grackle lookup_cool_rates1d.hpp make_consistent.cpp make_consistent.hpp opaque_storage.hpp - rate_utils.cpp + ratequery.cpp solve_chemistry.cpp scale_fields.cpp scale_fields.hpp solve_rate_cool_g-cpp.cpp solve_rate_cool_g-cpp.h diff --git a/src/clib/Make.config.objects b/src/clib/Make.config.objects index 7a4bb87af..d3a721cbd 100644 --- a/src/clib/Make.config.objects +++ b/src/clib/Make.config.objects @@ -49,7 +49,7 @@ OBJS_CONFIG_LIB = \ calc_tdust_3d.lo \ calc_grain_size_increment_1d.lo \ rate_functions.lo \ - rate_utils.lo \ + ratequery.lo \ gaussj_g.lo \ utils.lo \ utils-cpp.lo \ diff --git a/src/clib/rate_utils.cpp b/src/clib/ratequery.cpp similarity index 100% rename from src/clib/rate_utils.cpp rename to src/clib/ratequery.cpp From 3659a3abad0d577c43c5d380bde785e75f101a84 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Fri, 12 Dec 2025 09:54:24 -0500 Subject: [PATCH 116/175] rename Descr->Entry --- src/clib/ratequery.cpp | 107 +++++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 51 deletions(-) diff --git a/src/clib/ratequery.cpp b/src/clib/ratequery.cpp index ce28a5be7..e0eb0fec3 100644 --- a/src/clib/ratequery.cpp +++ b/src/clib/ratequery.cpp @@ -6,7 +6,7 @@ //===----------------------------------------------------------------------===// /// /// @file -/// Defines functions that perform basic utilities related to rate data. +/// Defines functionality for querying rate data. /// //===----------------------------------------------------------------------===// @@ -45,36 +45,36 @@ enum { UNDEFINED_RATE_ID_ = 0 }; // introduce some basic machinery to help us implement dynamic lookup of rates -/// A description of a rate -struct Descr { +/// Description of a queryable entity +struct Entry { double* data; const char* name; }; -static inline Descr mk_Descr(double* rate, const char* name) { - Descr out; +static inline Entry mk_Entry(double* rate, const char* name) { + Entry out; out.data = rate; out.name = name; return out; } -static inline Descr mk_Descr_standard_kcol_(chemistry_data_storage* my_rates, +static inline Entry mk_Entry_standard_kcol_(chemistry_data_storage* my_rates, const char* name, int index) { if ((my_rates == nullptr) || (my_rates->opaque_storage == nullptr) || (my_rates->opaque_storage->kcol_rate_tables == nullptr)) { - return mk_Descr(nullptr, name); + return mk_Entry(nullptr, name); } else { - return mk_Descr(my_rates->opaque_storage->kcol_rate_tables->data[index], + return mk_Entry(my_rates->opaque_storage->kcol_rate_tables->data[index], name); } } -#define MKDESCR_(PTR, NAME) \ - mk_Descr(((PTR) == nullptr) ? nullptr : (PTR)->NAME, #NAME) -#define MKDESCR_SCALAR_(PTR, NAME) \ - mk_Descr(((PTR) == nullptr) ? nullptr : &((PTR)->NAME), #NAME) -#define MKDESCR_STANDARD_KCOL_(PTR, NAME, INDEX) \ - mk_Descr_standard_kcol_(PTR, #NAME, INDEX) +#define MKENTRY_(PTR, NAME) \ + mk_Entry(((PTR) == nullptr) ? nullptr : (PTR)->NAME, #NAME) +#define MKENTRY_SCALAR_(PTR, NAME) \ + mk_Entry(((PTR) == nullptr) ? nullptr : &((PTR)->NAME), #NAME) +#define MKENTRY_STANDARD_KCOL_(PTR, NAME, INDEX) \ + mk_Entry_standard_kcol_(PTR, #NAME, INDEX) // Create machinery to lookup Standard-Form Collisional Reaction Rates // ------------------------------------------------------------------- @@ -89,16 +89,16 @@ static inline Descr mk_Descr_standard_kcol_(chemistry_data_storage* my_rates, // of the previous value (if a value isn't explicitly specified) // - CollisionalRxnLUT::NUM_ENTRIES specifies the number of other enumeration // constants (excluding CollisionalRxnLUT::NUM_ENTRIES) in the enum -static Descr get_CollisionalRxn_Descr(chemistry_data_storage* my_rates, int i) { +static Entry get_CollisionalRxn_Entry(chemistry_data_storage* my_rates, int i) { switch (i) { #define ENTRY(NAME) \ case CollisionalRxnLUT::NAME: { \ - return MKDESCR_STANDARD_KCOL_(my_rates, NAME, CollisionalRxnLUT::NAME); \ + return MKENTRY_STANDARD_KCOL_(my_rates, NAME, CollisionalRxnLUT::NAME); \ } #include "collisional_rxn_rate_members.def" #undef ENTRY default: { - Descr out = {nullptr, nullptr}; + Entry out = {nullptr, nullptr}; return out; } } @@ -121,31 +121,31 @@ enum MiscRxnRateKind_ { MiscRxn_NRATES // <- will hold the number of reactions }; -static Descr get_MiscRxn_Descr(chemistry_data_storage* my_rates, int i) { +static Entry get_MiscRxn_Entry(chemistry_data_storage* my_rates, int i) { switch (i) { // density dependent version of k13 (which is a CollisionalRxn) case MiscRxn_k13dd: - return MKDESCR_(my_rates, k13dd); + return MKENTRY_(my_rates, k13dd); // Radiative rates for 6-species (for external field): case MiscRxn_k24: - return MKDESCR_SCALAR_(my_rates, k24); + return MKENTRY_SCALAR_(my_rates, k24); case MiscRxn_k25: - return MKDESCR_SCALAR_(my_rates, k25); + return MKENTRY_SCALAR_(my_rates, k25); case MiscRxn_k26: - return MKDESCR_SCALAR_(my_rates, k26); + return MKENTRY_SCALAR_(my_rates, k26); // Radiative rates for 9-species case MiscRxn_k27: - return MKDESCR_SCALAR_(my_rates, k27); + return MKENTRY_SCALAR_(my_rates, k27); case MiscRxn_k28: - return MKDESCR_SCALAR_(my_rates, k28); + return MKENTRY_SCALAR_(my_rates, k28); case MiscRxn_k29: - return MKDESCR_SCALAR_(my_rates, k29); + return MKENTRY_SCALAR_(my_rates, k29); case MiscRxn_k30: - return MKDESCR_SCALAR_(my_rates, k30); + return MKENTRY_SCALAR_(my_rates, k30); case MiscRxn_k31: - return MKDESCR_SCALAR_(my_rates, k31); + return MKENTRY_SCALAR_(my_rates, k31); default: { - Descr out = {nullptr, nullptr}; + Entry out = {nullptr, nullptr}; return out; } } @@ -154,27 +154,32 @@ static Descr get_MiscRxn_Descr(chemistry_data_storage* my_rates, int i) { // define some additional generic machinery // ---------------------------------------- -#define DESCR_SET_COUNT 2 -typedef Descr fetch_Descr_fn(chemistry_data_storage*, int); -struct DescrSet { +/// describes a recipe for creating 1 or more different entries +/// from a chemistry_data_storage pointer +typedef Entry fetch_Entry_recipe_fn(chemistry_data_storage*, int); + +/// Entryibes a set of rate descriptions that +struct RecipeEntrySet { int id_offset; int len; - fetch_Descr_fn* fn; + fetch_Entry_recipe_fn* fn; }; -struct DescrRegistry { + +#define DESCR_SET_COUNT 2 +struct EntryRegistry { int len; - DescrSet sets[DESCR_SET_COUNT]; + RecipeEntrySet sets[DESCR_SET_COUNT]; }; -static const struct DescrRegistry descr_registry_ = { +static const struct EntryRegistry entry_registry_ = { /* len: */ DESCR_SET_COUNT, /* sets: */ { - {1000, CollisionalRxnLUT::NUM_ENTRIES, &get_CollisionalRxn_Descr}, - {2000, MiscRxn_NRATES, &get_MiscRxn_Descr}}}; + {1000, CollisionalRxnLUT::NUM_ENTRIES, &get_CollisionalRxn_Entry}, + {2000, MiscRxn_NRATES, &get_MiscRxn_Entry}}}; struct ratequery_rslt_ { grunstable_rateid_type rate_id; - Descr descr; + Entry entry; }; /// internal function to search for the rate description i @@ -183,18 +188,18 @@ struct ratequery_rslt_ { /// look for the ith rate description (we introduce an artificial distinction /// between the 2 cases because we want to reserve the right to be able to /// change the relationship if it becomes convenient in the future) -static struct ratequery_rslt_ query_Descr(chemistry_data_storage* my_rates, +static struct ratequery_rslt_ query_Entry(chemistry_data_storage* my_rates, long long i, bool use_rate_id) { int total_len = 0; // <- we increment this as we go through the rates - for (int set_idx = 0; set_idx < descr_registry_.len; set_idx++) { - const struct DescrSet cur_set = descr_registry_.sets[set_idx]; + for (int set_idx = 0; set_idx < entry_registry_.len; set_idx++) { + const struct RecipeEntrySet cur_set = entry_registry_.sets[set_idx]; const long long tmp = (use_rate_id) ? i - cur_set.id_offset : i - total_len; if ((tmp >= 0) && (tmp < cur_set.len)) { struct ratequery_rslt_ out; out.rate_id = tmp + cur_set.id_offset; - out.descr = cur_set.fn(my_rates, tmp); + out.entry = cur_set.fn(my_rates, tmp); return out; } total_len += cur_set.len; @@ -216,12 +221,12 @@ extern "C" grunstable_rateid_type grunstable_ratequery_id( return rate_q::UNDEFINED_RATE_ID_; } - for (int set_idx = 0; set_idx < rate_q::descr_registry_.len; set_idx++) { - const rate_q::DescrSet cur_set = rate_q::descr_registry_.sets[set_idx]; - for (int i = 0; i < cur_set.len; i++) { - rate_q::Descr descr = cur_set.fn(nullptr, i); - if (std::strcmp(name, descr.name) == 0) { - return cur_set.id_offset + i; + for (int set_idx = 0; set_idx < rate_q::entry_registry_.len; set_idx++) { + const rate_q::RecipeEntrySet set = rate_q::entry_registry_.sets[set_idx]; + for (int i = 0; i < set.len; i++) { + rate_q::Entry entry = set.fn(nullptr, i); + if (std::strcmp(name, entry.name) == 0) { + return set.id_offset + i; } } } @@ -232,7 +237,7 @@ extern "C" double* grunstable_ratequery_get_ptr( chemistry_data_storage* my_rates, grunstable_rateid_type rate_id) { namespace rate_q = grackle::impl::ratequery; - return rate_q::query_Descr(my_rates, rate_id, true).descr.data; + return rate_q::query_Entry(my_rates, rate_id, true).entry.data; } extern "C" const char* grunstable_ith_rate( @@ -242,9 +247,9 @@ extern "C" const char* grunstable_ith_rate( const long long sanitized_i = (i < LLONG_MAX) ? (long long)i : -1; rate_q::ratequery_rslt_ tmp = - rate_q::query_Descr(nullptr, sanitized_i, false); + rate_q::query_Entry(nullptr, sanitized_i, false); if (out_rate_id != nullptr) { *out_rate_id = tmp.rate_id; } - return tmp.descr.name; + return tmp.entry.name; } From 11ddf78b8df50a4b7b60dc49199176a44e461445 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Fri, 12 Dec 2025 11:17:28 -0500 Subject: [PATCH 117/175] introduce ratequery.hpp --- src/clib/CMakeLists.txt | 2 +- src/clib/ratequery.cpp | 49 ++++--------------- src/clib/ratequery.hpp | 103 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+), 40 deletions(-) create mode 100644 src/clib/ratequery.hpp diff --git a/src/clib/CMakeLists.txt b/src/clib/CMakeLists.txt index 9d417790b..8bd5db35d 100644 --- a/src/clib/CMakeLists.txt +++ b/src/clib/CMakeLists.txt @@ -120,7 +120,7 @@ add_library(Grackle_Grackle lookup_cool_rates1d.hpp make_consistent.cpp make_consistent.hpp opaque_storage.hpp - ratequery.cpp + ratequery.cpp ratequery.hpp solve_chemistry.cpp scale_fields.cpp scale_fields.hpp solve_rate_cool_g-cpp.cpp solve_rate_cool_g-cpp.h diff --git a/src/clib/ratequery.cpp b/src/clib/ratequery.cpp index e0eb0fec3..70bdc0dfb 100644 --- a/src/clib/ratequery.cpp +++ b/src/clib/ratequery.cpp @@ -16,6 +16,7 @@ #include "internal_types.hpp" // CollisionalRxnRateCollection #include "LUT.hpp" // CollisionalRxnLUT #include "opaque_storage.hpp" // gr_opaque_storage +#include "ratequery.hpp" // In comparison to the dynamic API for accessing elements of chemistry_data, // we have explicitly opted NOT to make use of offsetof to access arbitrary @@ -45,36 +46,23 @@ enum { UNDEFINED_RATE_ID_ = 0 }; // introduce some basic machinery to help us implement dynamic lookup of rates -/// Description of a queryable entity -struct Entry { - double* data; - const char* name; -}; - -static inline Entry mk_Entry(double* rate, const char* name) { - Entry out; - out.data = rate; - out.name = name; - return out; -} - -static inline Entry mk_Entry_standard_kcol_(chemistry_data_storage* my_rates, - const char* name, int index) { +static Entry new_Entry_standard_kcol_(chemistry_data_storage* my_rates, + const char* name, int index) { if ((my_rates == nullptr) || (my_rates->opaque_storage == nullptr) || (my_rates->opaque_storage->kcol_rate_tables == nullptr)) { - return mk_Entry(nullptr, name); + return new_Entry(nullptr, name); } else { - return mk_Entry(my_rates->opaque_storage->kcol_rate_tables->data[index], - name); + return new_Entry(my_rates->opaque_storage->kcol_rate_tables->data[index], + name); } } #define MKENTRY_(PTR, NAME) \ - mk_Entry(((PTR) == nullptr) ? nullptr : (PTR)->NAME, #NAME) + new_Entry(((PTR) == nullptr) ? nullptr : (PTR)->NAME, #NAME) #define MKENTRY_SCALAR_(PTR, NAME) \ - mk_Entry(((PTR) == nullptr) ? nullptr : &((PTR)->NAME), #NAME) + new_Entry(((PTR) == nullptr) ? nullptr : &((PTR)->NAME), #NAME) #define MKENTRY_STANDARD_KCOL_(PTR, NAME, INDEX) \ - mk_Entry_standard_kcol_(PTR, #NAME, INDEX) + new_Entry_standard_kcol_(PTR, #NAME, INDEX) // Create machinery to lookup Standard-Form Collisional Reaction Rates // ------------------------------------------------------------------- @@ -154,25 +142,8 @@ static Entry get_MiscRxn_Entry(chemistry_data_storage* my_rates, int i) { // define some additional generic machinery // ---------------------------------------- -/// describes a recipe for creating 1 or more different entries -/// from a chemistry_data_storage pointer -typedef Entry fetch_Entry_recipe_fn(chemistry_data_storage*, int); - -/// Entryibes a set of rate descriptions that -struct RecipeEntrySet { - int id_offset; - int len; - fetch_Entry_recipe_fn* fn; -}; - -#define DESCR_SET_COUNT 2 -struct EntryRegistry { - int len; - RecipeEntrySet sets[DESCR_SET_COUNT]; -}; - static const struct EntryRegistry entry_registry_ = { - /* len: */ DESCR_SET_COUNT, + /* len: */ ENTRY_SET_COUNT, /* sets: */ { {1000, CollisionalRxnLUT::NUM_ENTRIES, &get_CollisionalRxn_Entry}, {2000, MiscRxn_NRATES, &get_MiscRxn_Entry}}}; diff --git a/src/clib/ratequery.hpp b/src/clib/ratequery.hpp new file mode 100644 index 000000000..0ab72145b --- /dev/null +++ b/src/clib/ratequery.hpp @@ -0,0 +1,103 @@ +//===----------------------------------------------------------------------===// +// +// See the LICENSE file for license and copyright information +// SPDX-License-Identifier: NCSA AND BSD-3-Clause +// +//===----------------------------------------------------------------------===// +/// +/// @file +/// Declares functionality for querying rate data +/// +//===----------------------------------------------------------------------===// +#ifndef RATEQUERY_HPP +#define RATEQUERY_HPP + +#include "grackle.h" + +namespace grackle::impl::ratequery { + +/// @defgroup Dynamic Rate Query Machinery +/// +/// This group of entities provides the machinery for implementing the API for +/// dynamically accessing rate data. +/// +/// The design of this machinery is based on a simple model: +/// - the query machinery queries a Registry +/// - you can think of a Registry as a container. Each item is an Entry that +/// describes a unique queryable rate. +/// +/// The actualy implementation is a little more sophisticated. In practice is +/// divided into subsets of `Entry` instances. Moreover, subsets are free to +/// treat `Entry` instances as ephemeral objects (i.e. a subset can lazily +/// construct a new `Entry` instance and is allowed to forget about the +/// instance). +/// +/// Design Considerations +/// ===================== +/// Ideally, this machinery should balance 3 design considerations: (1) memory +/// usage, (2) impact on grackle solver initialization, (3) Query Performance. +/// +/// The relative of importance of these considerations should be informed by +/// the fact that dynamic rate API logic is not central to querying logic is +/// not of central important to Grackle as a library: +/// - currently, none of the rates ever need to queried for regular Grackle +/// usage (i.e. they are only queried for debugging/experimentation) +/// - moreover, if we do need to query some information in certain +/// configurations (e.g. assumed grain species yields for different injection +/// pathways), the data probably isn't in the most useful format for +/// everyone. Even if queries were ultra-fast, a performance-oriented user +/// would only query that information once, repack the data so that it's +/// structured in a more useful way, and cache the repacked data. +/// +/// In principle, if we had an idea for an delivered significantly better +/// performance, at the cost of increased memory usage and/or longer +/// initialization, we could consider making construction of the registry (or +/// non-essential registry-entries) a runtime parameter. +/// +/// ASIDE: The current design is very much prioritizes doing something easy +/// over runtime performance. +/** @{ */ + +/// A queryable entity +struct Entry { + double* data; + const char* name; +}; + +/// Constructs an entry +inline Entry new_Entry(double* rate, const char* name) { + Entry out; + out.data = rate; + out.name = name; + return out; +} + +/// a recipe for querying 1 or more entries from a chemistry_data_storage +/// pointer given an index. A recipe generally lazily creates an Entry as +/// the underlying data is fetched. +/// +/// If `N` denotes the number of entries that can be queried by a given recipe, +/// then this function should produce unique entries for each unique index that +/// satisfies `0 <= index <= (N-1)` +typedef Entry fetch_Entry_recipe_fn(chemistry_data_storage*, int); + +/// Describes the set of entries that can be accessed through a given recipe +struct RecipeEntrySet { + int id_offset; + int len; + fetch_Entry_recipe_fn* fn; +}; + +#define ENTRY_SET_COUNT 2 + +/// Describes a registry of queryable entries +struct EntryRegistry { + int len; + RecipeEntrySet sets[ENTRY_SET_COUNT]; +}; + +/** @}*/ // end of group + +} // namespace grackle::impl::ratequery + +#endif // RATEQUERY_HPP From fb030ffd697b49c1de993e82b6b12a24d03f2945 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Fri, 12 Dec 2025 12:05:52 -0500 Subject: [PATCH 118/175] Store the `Entry` Registry within chemistry_data_storage --- src/clib/initialize_chemistry_data.cpp | 16 ++++++ src/clib/opaque_storage.hpp | 4 ++ src/clib/ratequery.cpp | 72 +++++++++++++++++++------- src/clib/ratequery.hpp | 12 +++-- 4 files changed, 81 insertions(+), 23 deletions(-) diff --git a/src/clib/initialize_chemistry_data.cpp b/src/clib/initialize_chemistry_data.cpp index b8b39fabf..8d74713ab 100644 --- a/src/clib/initialize_chemistry_data.cpp +++ b/src/clib/initialize_chemistry_data.cpp @@ -28,6 +28,7 @@ #include "internal_types.hpp" // drop_CollisionalRxnRateCollection #include "opaque_storage.hpp" // gr_opaque_storage #include "phys_constants.h" +#include "ratequery.hpp" #ifdef _OPENMP #include @@ -403,6 +404,7 @@ extern "C" int local_initialize_chemistry_data(chemistry_data *my_chemistry, init_empty_interp_grid_props_( &my_rates->opaque_storage->h2dust_grain_interp_props); my_rates->opaque_storage->grain_species_info = nullptr; + my_rates->opaque_storage->registry = nullptr; double co_length_units, co_density_units; if (my_units->comoving_coordinates == TRUE) { @@ -456,6 +458,11 @@ extern "C" int local_initialize_chemistry_data(chemistry_data *my_chemistry, /* store a copy of the initial units */ my_rates->initial_units = *my_units; + // initialize the registry + my_rates->opaque_storage->registry = new grackle::impl::ratequery::Registry( + grackle::impl::ratequery::new_Registry() + ); + if (grackle_verbose) { time_t timer; char tstr[80]; @@ -659,6 +666,15 @@ extern "C" int local_free_chemistry_data(chemistry_data *my_chemistry, delete my_rates->opaque_storage->grain_species_info; } + if (my_rates->opaque_storage->registry != nullptr) { + // delete contents of registry + grackle::impl::ratequery::drop_Registry( + my_rates->opaque_storage->registry + ); + // delete registry, itself + delete my_rates->opaque_storage->registry; + } + delete my_rates->opaque_storage; my_rates->opaque_storage = nullptr; diff --git a/src/clib/opaque_storage.hpp b/src/clib/opaque_storage.hpp index a118d42c4..e79776094 100644 --- a/src/clib/opaque_storage.hpp +++ b/src/clib/opaque_storage.hpp @@ -16,6 +16,7 @@ #include "grackle.h" #include "dust/grain_species_info.hpp" #include "internal_types.hpp" +#include "ratequery.hpp" /// a struct that used to wrap some private storage details /// @@ -95,6 +96,9 @@ struct gr_opaque_storage { /// > calculations). An alternative would be to briefly initialize an /// > instance during setup and then repack the data. grackle::impl::GrainSpeciesInfo* grain_species_info; + + /// used to implement the experimental ratequery machinery + grackle::impl::ratequery::Registry* registry; }; #endif /* OPAQUE_STORAGE_HPP */ diff --git a/src/clib/ratequery.cpp b/src/clib/ratequery.cpp index 70bdc0dfb..a60ac3519 100644 --- a/src/clib/ratequery.cpp +++ b/src/clib/ratequery.cpp @@ -139,44 +139,76 @@ static Entry get_MiscRxn_Entry(chemistry_data_storage* my_rates, int i) { } } -// define some additional generic machinery -// ---------------------------------------- +} // namespace grackle::impl::ratequery + +grackle::impl::ratequery::Registry grackle::impl::ratequery::new_Registry() { + const RecipeEntrySet standard_sets[] = { + {1000, CollisionalRxnLUT::NUM_ENTRIES, &get_CollisionalRxn_Entry}, + {2000, MiscRxn_NRATES, &get_MiscRxn_Entry}}; + int len = static_cast(sizeof(standard_sets) / sizeof(RecipeEntrySet)); + RecipeEntrySet* sets = new RecipeEntrySet[len]; + for (int i = 0; i < len; i++) { + sets[i] = standard_sets[i]; + } + + return Registry{len, sets}; +} -static const struct EntryRegistry entry_registry_ = { - /* len: */ ENTRY_SET_COUNT, - /* sets: */ { - {1000, CollisionalRxnLUT::NUM_ENTRIES, &get_CollisionalRxn_Entry}, - {2000, MiscRxn_NRATES, &get_MiscRxn_Entry}}}; +void grackle::impl::ratequery::drop_Registry( + grackle::impl::ratequery::Registry* ptr) { + if (ptr->sets != nullptr) { + delete[] ptr->sets; + ptr->sets = nullptr; + } +} + +namespace grackle::impl::ratequery { struct ratequery_rslt_ { grunstable_rateid_type rate_id; Entry entry; }; +static ratequery_rslt_ invalid_rslt_() { + return {UNDEFINED_RATE_ID_, {nullptr, nullptr}}; +} + +static const Registry* get_registry(const chemistry_data_storage* my_rates) { + if ((my_rates == nullptr) || (my_rates->opaque_storage == nullptr)) { + return nullptr; + } + return my_rates->opaque_storage->registry; +} + /// internal function to search for the rate description i /// /// We interpret i as rate_id, when use_rate_id is true. Otherwise, we just /// look for the ith rate description (we introduce an artificial distinction /// between the 2 cases because we want to reserve the right to be able to /// change the relationship if it becomes convenient in the future) -static struct ratequery_rslt_ query_Entry(chemistry_data_storage* my_rates, - long long i, bool use_rate_id) { +static ratequery_rslt_ query_Entry(chemistry_data_storage* my_rates, + long long i, bool use_rate_id) { + const Registry* registry = get_registry(my_rates); + + if (registry == nullptr) { + return invalid_rslt_(); + } + int total_len = 0; // <- we increment this as we go through the rates - for (int set_idx = 0; set_idx < entry_registry_.len; set_idx++) { - const struct RecipeEntrySet cur_set = entry_registry_.sets[set_idx]; + for (int set_idx = 0; set_idx < registry->len; set_idx++) { + const struct RecipeEntrySet cur_set = registry->sets[set_idx]; const long long tmp = (use_rate_id) ? i - cur_set.id_offset : i - total_len; if ((tmp >= 0) && (tmp < cur_set.len)) { - struct ratequery_rslt_ out; + ratequery_rslt_ out; out.rate_id = tmp + cur_set.id_offset; out.entry = cur_set.fn(my_rates, tmp); return out; } total_len += cur_set.len; } - struct ratequery_rslt_ out = {UNDEFINED_RATE_ID_, {nullptr, nullptr}}; - return out; + return invalid_rslt_(); } } // namespace grackle::impl::ratequery @@ -188,12 +220,13 @@ extern "C" grunstable_rateid_type grunstable_ratequery_id( const chemistry_data_storage* my_rates, const char* name) { namespace rate_q = grackle::impl::ratequery; - if (name == nullptr) { + const rate_q::Registry* registry = rate_q::get_registry(my_rates); + if ((name == nullptr) || (registry == nullptr)) { return rate_q::UNDEFINED_RATE_ID_; } - for (int set_idx = 0; set_idx < rate_q::entry_registry_.len; set_idx++) { - const rate_q::RecipeEntrySet set = rate_q::entry_registry_.sets[set_idx]; + for (int set_idx = 0; set_idx < registry->len; set_idx++) { + const rate_q::RecipeEntrySet set = registry->sets[set_idx]; for (int i = 0; i < set.len; i++) { rate_q::Entry entry = set.fn(nullptr, i); if (std::strcmp(name, entry.name) == 0) { @@ -217,8 +250,9 @@ extern "C" const char* grunstable_ith_rate( namespace rate_q = grackle::impl::ratequery; const long long sanitized_i = (i < LLONG_MAX) ? (long long)i : -1; - rate_q::ratequery_rslt_ tmp = - rate_q::query_Entry(nullptr, sanitized_i, false); + // short-term hack! (it's bad practice to "cast away the const") + rate_q::ratequery_rslt_ tmp = rate_q::query_Entry( + const_cast(my_rates), sanitized_i, false); if (out_rate_id != nullptr) { *out_rate_id = tmp.rate_id; } diff --git a/src/clib/ratequery.hpp b/src/clib/ratequery.hpp index 0ab72145b..69cb8e20d 100644 --- a/src/clib/ratequery.hpp +++ b/src/clib/ratequery.hpp @@ -88,14 +88,18 @@ struct RecipeEntrySet { fetch_Entry_recipe_fn* fn; }; -#define ENTRY_SET_COUNT 2 - /// Describes a registry of queryable entries -struct EntryRegistry { +struct Registry { int len; - RecipeEntrySet sets[ENTRY_SET_COUNT]; + RecipeEntrySet* sets; }; +/// construct a new registry +Registry new_Registry(); + +/// deallocate the contents of a registry +void drop_Registry(Registry* ptr); + /** @}*/ // end of group } // namespace grackle::impl::ratequery From e42e0dd75b97461c1eabd227880580e26d46e240 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Fri, 12 Dec 2025 15:16:34 -0500 Subject: [PATCH 119/175] lay the foundation for querying properties --- src/clib/initialize_chemistry_data.cpp | 2 +- src/clib/ratequery.cpp | 88 ++++++++++++++++++++++---- src/clib/ratequery.hpp | 29 +++++++-- src/clib/status_reporting.h | 19 ++++++ src/include/grackle.h | 33 ++++++++++ 5 files changed, 151 insertions(+), 20 deletions(-) diff --git a/src/clib/initialize_chemistry_data.cpp b/src/clib/initialize_chemistry_data.cpp index 8d74713ab..95900c440 100644 --- a/src/clib/initialize_chemistry_data.cpp +++ b/src/clib/initialize_chemistry_data.cpp @@ -460,7 +460,7 @@ extern "C" int local_initialize_chemistry_data(chemistry_data *my_chemistry, // initialize the registry my_rates->opaque_storage->registry = new grackle::impl::ratequery::Registry( - grackle::impl::ratequery::new_Registry() + grackle::impl::ratequery::new_Registry(*my_chemistry) ); if (grackle_verbose) { diff --git a/src/clib/ratequery.cpp b/src/clib/ratequery.cpp index a60ac3519..be4c582d7 100644 --- a/src/clib/ratequery.cpp +++ b/src/clib/ratequery.cpp @@ -17,6 +17,7 @@ #include "LUT.hpp" // CollisionalRxnLUT #include "opaque_storage.hpp" // gr_opaque_storage #include "ratequery.hpp" +#include "status_reporting.h" // In comparison to the dynamic API for accessing elements of chemistry_data, // we have explicitly opted NOT to make use of offsetof to access arbitrary @@ -57,8 +58,8 @@ static Entry new_Entry_standard_kcol_(chemistry_data_storage* my_rates, } } -#define MKENTRY_(PTR, NAME) \ - new_Entry(((PTR) == nullptr) ? nullptr : (PTR)->NAME, #NAME) +#define MKENTRY_(PTR, NAME, FAMILY) \ + new_Entry(((PTR) == nullptr) ? nullptr : (PTR)->NAME, #NAME, FAMILY) #define MKENTRY_SCALAR_(PTR, NAME) \ new_Entry(((PTR) == nullptr) ? nullptr : &((PTR)->NAME), #NAME) #define MKENTRY_STANDARD_KCOL_(PTR, NAME, INDEX) \ @@ -86,17 +87,24 @@ static Entry get_CollisionalRxn_Entry(chemistry_data_storage* my_rates, int i) { #include "collisional_rxn_rate_members.def" #undef ENTRY default: { - Entry out = {nullptr, nullptr}; - return out; + return mk_invalid_Entry(); } } } +static Entry get_k13dd_Entry(chemistry_data_storage* my_rates, int i) { + if (i == 0) { + double* ptr = (my_rates == nullptr) ? nullptr : my_rates->k13dd; + return new_Entry(ptr, "k13dd"); + } else { + return mk_invalid_Entry(); + } +} + // Create machinery to lookup Other Miscellaneous Rates // ---------------------------------------------------- enum MiscRxnRateKind_ { - MiscRxn_k13dd, MiscRxn_k24, MiscRxn_k25, MiscRxn_k26, @@ -111,9 +119,6 @@ enum MiscRxnRateKind_ { static Entry get_MiscRxn_Entry(chemistry_data_storage* my_rates, int i) { switch (i) { - // density dependent version of k13 (which is a CollisionalRxn) - case MiscRxn_k13dd: - return MKENTRY_(my_rates, k13dd); // Radiative rates for 6-species (for external field): case MiscRxn_k24: return MKENTRY_SCALAR_(my_rates, k24); @@ -133,18 +138,33 @@ static Entry get_MiscRxn_Entry(chemistry_data_storage* my_rates, int i) { case MiscRxn_k31: return MKENTRY_SCALAR_(my_rates, k31); default: { - Entry out = {nullptr, nullptr}; - return out; + return mk_invalid_Entry(); } } } } // namespace grackle::impl::ratequery -grackle::impl::ratequery::Registry grackle::impl::ratequery::new_Registry() { +grackle::impl::ratequery::Registry grackle::impl::ratequery::new_Registry( + const chemistry_data& my_chemistry) { + EntryProps props_LogTLinInterp = mk_invalid_EntryProps(); + props_LogTLinInterp.ndim = 1; + props_LogTLinInterp.shape[0] = my_chemistry.NumberOfTemperatureBins; + + // maybe k13dd should be considered multi-dimensional? + EntryProps props_k13dd = mk_invalid_EntryProps(); + props_k13dd.ndim = 1; + props_k13dd.shape[0] = my_chemistry.NumberOfTemperatureBins * 14; + + EntryProps props_scalar = mk_invalid_EntryProps(); + props_scalar.ndim = 0; + const RecipeEntrySet standard_sets[] = { - {1000, CollisionalRxnLUT::NUM_ENTRIES, &get_CollisionalRxn_Entry}, - {2000, MiscRxn_NRATES, &get_MiscRxn_Entry}}; + {1000, CollisionalRxnLUT::NUM_ENTRIES, &get_CollisionalRxn_Entry, + props_LogTLinInterp}, + {1999, 1, &get_k13dd_Entry, props_k13dd}, + {2000, MiscRxn_NRATES, &get_MiscRxn_Entry, props_scalar}}; + int len = static_cast(sizeof(standard_sets) / sizeof(RecipeEntrySet)); RecipeEntrySet* sets = new RecipeEntrySet[len]; for (int i = 0; i < len; i++) { @@ -204,6 +224,7 @@ static ratequery_rslt_ query_Entry(chemistry_data_storage* my_rates, ratequery_rslt_ out; out.rate_id = tmp + cur_set.id_offset; out.entry = cur_set.fn(my_rates, tmp); + out.entry.props = cur_set.common_props; return out; } total_len += cur_set.len; @@ -244,6 +265,47 @@ extern "C" double* grunstable_ratequery_get_ptr( return rate_q::query_Entry(my_rates, rate_id, true).entry.data; } +extern "C" int grunstable_ratequery_prop( + const chemistry_data_storage* my_rates, grunstable_rateid_type rate_id, + enum grunstable_ratequery_prop_kind prop_kind, long long* ptr) { + namespace rate_q = grackle::impl::ratequery; + + // short-term hack! (it's bad practice to "cast away the const") + rate_q::Entry entry = + rate_q::query_Entry(const_cast(my_rates), + rate_id, true) + .entry; + + const rate_q::EntryProps& props = entry.props; + if ((entry.name == nullptr) || !rate_q::EntryProps_is_valid(props)) { + return GR_FAIL; + } + + switch (prop_kind) { + case GRUNSTABLE_QPROP_NDIM: { + *ptr = static_cast(props.ndim); + return GR_SUCCESS; + } + case GRUNSTABLE_QPROP_SHAPE: { + for (int i = 0; i < props.ndim; i++) { + ptr[i] = static_cast(props.shape[i]); + } + return GR_SUCCESS; + } + case GRUNSTABLE_QPROP_TYPE: + return GR_FAIL; + case GRUNSTABLE_QPROP_MAXITEMSIZE: { + *ptr = static_cast(sizeof(double)); + return GR_SUCCESS; + } + case GRUNSTABLE_QPROP_WRITABLE: { + *ptr = 1LL; + } + default: + GR_INTERNAL_UNREACHABLE_ERROR(); + } +} + extern "C" const char* grunstable_ith_rate( const chemistry_data_storage* my_rates, unsigned long long i, grunstable_rateid_type* out_rate_id) { diff --git a/src/clib/ratequery.hpp b/src/clib/ratequery.hpp index 69cb8e20d..55b01c27f 100644 --- a/src/clib/ratequery.hpp +++ b/src/clib/ratequery.hpp @@ -58,18 +58,34 @@ namespace grackle::impl::ratequery { /// over runtime performance. /** @{ */ +/// Describes properties about the data in an entry +struct EntryProps { + int ndim; + int shape[GRACKLE_CLOUDY_TABLE_MAX_DIMENSION]; +}; + +inline EntryProps mk_invalid_EntryProps() { + EntryProps out; + out.ndim = -1; + return out; +} + +inline bool EntryProps_is_valid(EntryProps obj) { return obj.ndim >= 0; } + /// A queryable entity struct Entry { double* data; const char* name; + EntryProps props; }; -/// Constructs an entry +inline Entry mk_invalid_Entry() { + return Entry{nullptr, nullptr, mk_invalid_EntryProps()}; +} + +/// Constructs an Entry inline Entry new_Entry(double* rate, const char* name) { - Entry out; - out.data = rate; - out.name = name; - return out; + return Entry{rate, name, mk_invalid_EntryProps()}; } /// a recipe for querying 1 or more entries from a chemistry_data_storage @@ -86,6 +102,7 @@ struct RecipeEntrySet { int id_offset; int len; fetch_Entry_recipe_fn* fn; + EntryProps common_props; }; /// Describes a registry of queryable entries @@ -95,7 +112,7 @@ struct Registry { }; /// construct a new registry -Registry new_Registry(); +Registry new_Registry(const chemistry_data&); /// deallocate the contents of a registry void drop_Registry(Registry* ptr); diff --git a/src/clib/status_reporting.h b/src/clib/status_reporting.h index fe1a1cd5b..60373d4b0 100644 --- a/src/clib/status_reporting.h +++ b/src/clib/status_reporting.h @@ -230,6 +230,7 @@ ERRFMT_ATTR_(2) NORETURN_ATTR_ void grimpl_abort_with_internal_err_( #define GRIMPL_ERROR(...) \ { grimpl_abort_with_internal_err_(__GRIMPL_SRCLOC__, __VA_ARGS__); } + /// @def GR_INTERNAL_REQUIRE /// @brief implements functionality analogous to the assert() macro /// @@ -255,6 +256,24 @@ ERRFMT_ATTR_(2) NORETURN_ATTR_ void grimpl_abort_with_internal_err_( { if (!(cond)) \ { grimpl_abort_with_internal_err_(__GRIMPL_SRCLOC__, __VA_ARGS__); } } + +/// @def GR_INTERNAL_UNREACHABLE_ERROR() +/// @brief function-like macro that aborts with a (lethal) error message +/// indicating that +/// +/// This macro should be treated as a function with the signature: +/// +/// [[noreturn]] void GR_INTERNAL_UNREACHABLE_ERROR(); +/// +/// @note +/// Unlike gcc/clang's __builtin_unreachable or C++23's std::unreachable, this +/// aborts the program with an error if its executed (the other cases produce +/// undefined behavior). (An argument could be made for conditionally compiling +/// this macro into the alternatives to test speed) +#define GR_INTERNAL_UNREACHABLE_ERROR() \ + { grimpl_abort_with_internal_err_(__GRIMPL_SRCLOC__, \ + "location shouldn't be reachable"); } + // helper function ERRFMT_ATTR_(2) NODISCARD_ATTR_ int grimpl_print_and_return_err_( const struct grimpl_source_location_ locinfo, const char* msg, ... diff --git a/src/include/grackle.h b/src/include/grackle.h index 84b63c51d..ab6e03e01 100644 --- a/src/include/grackle.h +++ b/src/include/grackle.h @@ -266,6 +266,39 @@ double* grunstable_ratequery_get_ptr( chemistry_data_storage* my_rates, grunstable_rateid_type rate_id ); +/// Describe Rate-Query Property Types +/// +/// > [!note] +/// > It may make more sense to use macros if we want to support these from +/// > Fortran +/// +/// > [!important] +/// > Users should obviously avoid hardcoding values in their codebase. +enum grunstable_ratequery_prop_kind { + GRUNSTABLE_QPROP_NDIM = 1, + GRUNSTABLE_QPROP_SHAPE = 2, + GRUNSTABLE_QPROP_TYPE = 3, + GRUNSTABLE_QPROP_MAXITEMSIZE = 4, + // I don't like the next one + GRUNSTABLE_QPROP_WRITABLE = 5, +}; + +/// Query a property of the specified rate +/// +/// @param[in] my_rates The object being queried +/// @param[in] rate_id The id of the rate for which the property is queried +/// @param[in] prop_kind The proprty to query +/// @param[out] ptr The pointer where the property is recorded +/// +/// @returns GR_SUCCESS if successful. Otherwise, a different value is returned. +/// +/// The behavior is undefined when @p my_rates is a `nullptr`, @p ptr is a +/// nullptr or @p ptr doesn't have enough space to store the queried property +int grunstable_ratequery_prop(const chemistry_data_storage* my_rates, + grunstable_rateid_type rate_id, + enum grunstable_ratequery_prop_kind prop_kind, + long long* ptr); + /// Query the name (and optionally the rate_id) of the ith registered rate /// /// > [!warning] From 97d3ce621ccf234e1f1b49e274cf17bde8cb4674 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Fri, 12 Dec 2025 16:26:17 -0500 Subject: [PATCH 120/175] gracklepy: start directly querying shapes --- src/python/gracklepy/grackle_defs.pxd | 14 +++++++++++ src/python/gracklepy/grackle_wrapper.pyx | 31 +++++++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/src/python/gracklepy/grackle_defs.pxd b/src/python/gracklepy/grackle_defs.pxd index 462b83503..a8e6b761c 100644 --- a/src/python/gracklepy/grackle_defs.pxd +++ b/src/python/gracklepy/grackle_defs.pxd @@ -212,6 +212,7 @@ cdef extern from "grackle.h": # defined in "grackle.h" # ---------------------- + cdef int GR_SUCCESS cdef int GRACKLE_FAIL_VALUE "GR_FAIL" cdef int GR_SPECIFY_INITIAL_A_VALUE @@ -306,6 +307,19 @@ cdef extern from "grackle.h": c_chemistry_data_storage* my_rates, grunstable_rateid_type rate_id) + cdef enum grunstable_ratequery_prop_kind: + GRUNSTABLE_QPROP_NDIM + GRUNSTABLE_QPROP_SHAPE + GRUNSTABLE_QPROP_TYPE + GRUNSTABLE_QPROP_MAXITEMSIZE + GRUNSTABLE_QPROP_WRITABLE + + int grunstable_ratequery_prop( + const c_chemistry_data_storage* my_rates, + grunstable_rateid_type rate_id, + grunstable_ratequery_prop_kind prop_kind, + long long* ptr) + const char* grunstable_ith_rate( const c_chemistry_data_storage* my_rates, unsigned long long i, diff --git a/src/python/gracklepy/grackle_wrapper.pyx b/src/python/gracklepy/grackle_wrapper.pyx index 320fa1ea1..d1b872a62 100644 --- a/src/python/gracklepy/grackle_wrapper.pyx +++ b/src/python/gracklepy/grackle_wrapper.pyx @@ -952,11 +952,35 @@ cdef class _rate_mapping_access: out[rate_name.decode('UTF-8')] = int(rate_id) i+=1 + def _try_get_shape(self, rate_id): + cdef long long buf[7] + cdef int ret = grunstable_ratequery_prop( + self._ptr, rate_id, GRUNSTABLE_QPROP_NDIM, &buf[0] + ) + if ret != GR_SUCCESS: + return None + ndim = int(buf[0]) + if ndim == 0: + return () + elif ndim >7: + tmp = int(ndim) + raise RuntimeError( + f"rate_id {rate_id} has a questionable number of dims: {tmp}" + ) + + ret = grunstable_ratequery_prop( + self._ptr, rate_id, GRUNSTABLE_QPROP_SHAPE, &buf[0] + ) + if ret != GR_SUCCESS: + raise RuntimeError( + "the query for shape failed after query for ndim succeeded") + return tuple(int(buf[i]) for i in range(ndim)) + def _access_rate(self, key, val): # determine whether the rate needs to be updated update_rate = (val is not _NOSETVAL) - rate_id = self._name_rateid_map[key] # will raise a KeyError if not known + rate_id = self._name_rateid_map[key] # will raise KeyError if not known if self._ptr is NULL: raise RuntimeError( @@ -967,10 +991,15 @@ cdef class _rate_mapping_access: # retrieve the pointer cdef double* rate_ptr = grunstable_ratequery_get_ptr(self._ptr, rate_id) + # experimental shape retrieval + exp_shape = self._try_get_shape(rate_id) + # lookup the shape of the rates callback = self._rate_shape_callback shape = callback(rate_name=key) + assert shape == exp_shape + # predeclare a memoryview to use with 1d arrays cdef double[:] memview From ab816b4aea72eb21141342f7d6bb3d1120c79f7c Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Fri, 12 Dec 2025 16:35:37 -0500 Subject: [PATCH 121/175] gracklepy: use new shape query logic --- src/python/gracklepy/grackle_wrapper.pyx | 49 ++---------------------- 1 file changed, 3 insertions(+), 46 deletions(-) diff --git a/src/python/gracklepy/grackle_wrapper.pyx b/src/python/gracklepy/grackle_wrapper.pyx index d1b872a62..46ccf3e67 100644 --- a/src/python/gracklepy/grackle_wrapper.pyx +++ b/src/python/gracklepy/grackle_wrapper.pyx @@ -12,7 +12,6 @@ ######################################################################## import copy -import functools from gracklepy.utilities.physical_constants import \ boltzmann_constant_cgs, \ mass_hydrogen_cgs @@ -38,12 +37,7 @@ cdef class chemistry_data: def __cinit__(self): self.data = _wrapped_c_chemistry_data() - self._rate_map = _rate_mapping_access.from_ptr_and_callback( - ptr=&self.rates, - callback=functools.partial( - _get_rate_shape, wrapped_chemistry_data_obj = self.data - ) - ) + self._rate_map = _rate_mapping_access.from_ptr(&self.rates) self.data_copy_from_init = None cdef void _try_uninitialize(self): @@ -871,32 +865,6 @@ cdef class _wrapped_c_chemistry_data: out[k] = self[k] return out -def _get_rate_shape(wrapped_chemistry_data_obj, rate_name): - # for now we need to manually keep this updated. - # -> in the future, we could add probably encode some/all of this - # information within Grackle's ratequery API - - def _is_standard_colrecombination_rate(rate_name): - if rate_name[:2] == 'kz' and rate_name[2:].isdecimal(): - return 11 <= int(rate_name[2:]) <= 54 - elif rate_name[:1] == 'k' and rate_name[1:].isdecimal(): - digit = int(rate_name[1:]) - return ( (1 <= digit <= 23) or - (50 <= digit <= 58) or - (125 <= digit <= 153) ) - return False - - if rate_name in ("k24", "k25", "k26", "k27", "k28", "k29", "k30", "k31"): - return () # the rate is a scalar - elif _is_standard_colrecombination_rate(rate_name): - return (wrapped_chemistry_data_obj['NumberOfTemperatureBins'],) - elif rate_name == 'k13dd': - return (wrapped_chemistry_data_obj['NumberOfTemperatureBins'] * 14,) - else: - raise RuntimeError( - "the shape of the rate {rate_name!r} has not been specified yet" - ) - cdef class _rate_mapping_access: # This class is used internally by the chemistry_data extension class to @@ -912,12 +880,10 @@ cdef class _rate_mapping_access: # we might make some different choices) cdef c_chemistry_data_storage *_ptr - cdef object _rate_shape_callback cdef dict _cached_name_rateid_map def __cinit__(self): self._ptr = NULL - self._rate_shape_callback = None self._cached_name_rateid_map = None def __init__(self): @@ -925,14 +891,11 @@ cdef class _rate_mapping_access: raise TypeError("This class cannot be instantiated directly.") @staticmethod - cdef _rate_mapping_access from_ptr_and_callback( - c_chemistry_data_storage *ptr, object callback - ): + cdef _rate_mapping_access from_ptr(c_chemistry_data_storage *ptr): cdef _rate_mapping_access out = _rate_mapping_access.__new__( _rate_mapping_access ) out._ptr = ptr - out._rate_shape_callback = callback return out @property @@ -991,14 +954,8 @@ cdef class _rate_mapping_access: # retrieve the pointer cdef double* rate_ptr = grunstable_ratequery_get_ptr(self._ptr, rate_id) - # experimental shape retrieval - exp_shape = self._try_get_shape(rate_id) - # lookup the shape of the rates - callback = self._rate_shape_callback - shape = callback(rate_name=key) - - assert shape == exp_shape + shape = self._try_get_shape(rate_id) # predeclare a memoryview to use with 1d arrays cdef double[:] memview From 080a097df43d743d83da12228c62b5eec0268d3c Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sat, 13 Dec 2025 09:26:23 -0500 Subject: [PATCH 122/175] Tweak grackle wrapper This change ensures that the chemistry_data extension type will provide a consistent set of attributes, even if we make unused rate information inaccessible through the ratequery interface --- src/python/gracklepy/grackle_wrapper.pyx | 65 ++++++++++++++++++++---- 1 file changed, 56 insertions(+), 9 deletions(-) diff --git a/src/python/gracklepy/grackle_wrapper.pyx b/src/python/gracklepy/grackle_wrapper.pyx index 46ccf3e67..772ccfb36 100644 --- a/src/python/gracklepy/grackle_wrapper.pyx +++ b/src/python/gracklepy/grackle_wrapper.pyx @@ -20,6 +20,41 @@ from libc.limits cimport INT_MAX from .grackle_defs cimport * import numpy as np +# define a set of rate-related properties that the chemistry_data extension +# type must support as attributes: +# - historically, these rates have been accessible regardless of whether a +# chemistry solver class has been defined to use them. +# - in the near future, the _rate_mapping_access machinery may lose the ability +# to access rate buffers that are not being actively used +# - we will use this set to ensure that these types remain accessible +_legacy_rate_attrs = frozenset( + [ + "k1", "k2", "k3", "k4", "k5", "k6", "k7", "k8", "k9", "k10", "k11", + "k12", "k13", "k14", "k15", "k16", "k17", "k18", "k19", "k20", "k21", + "k22", "k23", "k50", "k51", "k52", "k53", "k54", "k55", "k56", "k57", + "k58", "k13dd", + # radiative rates: + "k24", "k25", "k26", "k27", "k28", "k29", "k30", "k31", + + # A question for another time (before releasing Grackle 3.5): + # - do we want to provide an alternative approach for people to query + # rates? (like a method or function?) + # - If so, then maybe we don't the following to be attributes of + # chemistry_data + # - for now, they are accessible as attributes of chemistry_data + + # 15 species rates (with DM, HDII, HeHII) + "k125", "k129", "k130", "k131", "k132", "k133", "k134", "k135", "k136", + "k137", "k148", "k149", "k150", "k151", "k152", "k153", + # metal species rates: + "kz15", "kz16", "kz17", "kz18", "kz19", "kz20", "kz21", "kz22", "kz23", + "kz24", "kz25", "kz26", "kz27", "kz28", "kz29", "kz30", "kz31", "kz32", + "kz33", "kz34", "kz35", "kz36", "kz37", "kz38", "kz39", "kz40", "kz41", + "kz42", "kz43", "kz44", "kz45", "kz46", "kz47", "kz48", "kz49", "kz50", + "kz51", "kz52", "kz53", "kz54", + ] +) + cdef class chemistry_data: cdef _wrapped_c_chemistry_data data cdef c_chemistry_data_storage rates @@ -93,10 +128,8 @@ cdef class chemistry_data: except KeyError: pass - try: - return self._rate_map[name] # case where name specifies a rate - except KeyError: - pass + if name in _legacy_rate_attrs: + return self._rate_map.get(name) # this method is expected to raise AttributeError when it fails raise AttributeError( @@ -143,11 +176,15 @@ cdef class chemistry_data: except KeyError: pass - try: - self._rate_map[name] = value - return # early exit - except KeyError: - pass + if name in _legacy_rate_attrs: + try: + self._rate_map[name] = value + return # early exit + except KeyError: + raise AttributeError( + f"attribute '{name}' of '{type(self).__name__}' can't be " + "mutated under the current configuration" + ) from None raise AttributeError( f"'{type(self).__name__}' object has no attribute '{name}'" @@ -980,6 +1017,16 @@ cdef class _rate_mapping_access: "no support is in place for higher dimensional arrays" ) + def get(self, key, default=None, /): + """ + Retrieve the value associated with key, if key is known. Otherwise, + return the default. + """ + try: + return self._access_rate(key, _NOSETVAL) + except: + return default + def __getitem__(self, key): return self._access_rate(key, _NOSETVAL) def __setitem__(self, key, value): self._access_rate(key, value) From 3a95ef02cfca9bba1f22f156345495d758bf7ba0 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sat, 13 Dec 2025 09:30:19 -0500 Subject: [PATCH 123/175] remove unimplemented rate properties --- src/clib/ratequery.cpp | 5 ----- src/include/grackle.h | 5 +---- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/clib/ratequery.cpp b/src/clib/ratequery.cpp index be4c582d7..deb8328b7 100644 --- a/src/clib/ratequery.cpp +++ b/src/clib/ratequery.cpp @@ -292,15 +292,10 @@ extern "C" int grunstable_ratequery_prop( } return GR_SUCCESS; } - case GRUNSTABLE_QPROP_TYPE: - return GR_FAIL; case GRUNSTABLE_QPROP_MAXITEMSIZE: { *ptr = static_cast(sizeof(double)); return GR_SUCCESS; } - case GRUNSTABLE_QPROP_WRITABLE: { - *ptr = 1LL; - } default: GR_INTERNAL_UNREACHABLE_ERROR(); } diff --git a/src/include/grackle.h b/src/include/grackle.h index ab6e03e01..19da9c6d9 100644 --- a/src/include/grackle.h +++ b/src/include/grackle.h @@ -277,10 +277,7 @@ double* grunstable_ratequery_get_ptr( enum grunstable_ratequery_prop_kind { GRUNSTABLE_QPROP_NDIM = 1, GRUNSTABLE_QPROP_SHAPE = 2, - GRUNSTABLE_QPROP_TYPE = 3, - GRUNSTABLE_QPROP_MAXITEMSIZE = 4, - // I don't like the next one - GRUNSTABLE_QPROP_WRITABLE = 5, + GRUNSTABLE_QPROP_MAXITEMSIZE = 3, }; /// Query a property of the specified rate From 5df10fcf487dc8ef5c9d8ab1a5574c85754e27f6 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Fri, 19 Dec 2025 08:57:59 -0500 Subject: [PATCH 124/175] address a gcc compiler warning --- src/clib/ratequery.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clib/ratequery.cpp b/src/clib/ratequery.cpp index deb8328b7..2d0bcfc80 100644 --- a/src/clib/ratequery.cpp +++ b/src/clib/ratequery.cpp @@ -190,7 +190,7 @@ struct ratequery_rslt_ { }; static ratequery_rslt_ invalid_rslt_() { - return {UNDEFINED_RATE_ID_, {nullptr, nullptr}}; + return {UNDEFINED_RATE_ID_, mk_invalid_Entry()}; } static const Registry* get_registry(const chemistry_data_storage* my_rates) { From fe1aba6a1893257a5f5030bc60253719e234f7bc Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Fri, 19 Dec 2025 11:37:55 -0500 Subject: [PATCH 125/175] introduce grunstable_ratequery_nrates --- src/clib/ratequery.cpp | 12 ++++++++++++ src/include/grackle.h | 4 ++++ tests/grtestutils/iterator_adaptor.hpp | 11 ----------- tests/unit/test_api_ratequery.cpp | 10 +++++++++- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/clib/ratequery.cpp b/src/clib/ratequery.cpp index 2d0bcfc80..5c54f74cb 100644 --- a/src/clib/ratequery.cpp +++ b/src/clib/ratequery.cpp @@ -315,3 +315,15 @@ extern "C" const char* grunstable_ith_rate( } return tmp.entry.name; } + +extern "C" unsigned long long grunstable_ratequery_nrates( + const chemistry_data_storage* my_rates) { + namespace rate_q = grackle::impl::ratequery; + const rate_q::Registry* registry = my_rates->opaque_storage->registry; + + unsigned long long out = 0; + for (int i = 0; i < registry->len; i++) { + out += static_cast(registry->sets[i].len); + } + return out; +} diff --git a/src/include/grackle.h b/src/include/grackle.h index 19da9c6d9..a599a15d5 100644 --- a/src/include/grackle.h +++ b/src/include/grackle.h @@ -313,6 +313,10 @@ const char* grunstable_ith_rate( grunstable_rateid_type* out_rate_id ); +/// Query the number of rates accessible through the ratequery API +unsigned long long grunstable_ratequery_nrates( + const chemistry_data_storage* my_rates); + /** @}*/ // end of group #ifdef __cplusplus diff --git a/tests/grtestutils/iterator_adaptor.hpp b/tests/grtestutils/iterator_adaptor.hpp index af5f9f259..cb9781047 100644 --- a/tests/grtestutils/iterator_adaptor.hpp +++ b/tests/grtestutils/iterator_adaptor.hpp @@ -109,17 +109,6 @@ struct RateQueryPlugin { } }; -// will be implemented (in a much more robust manner) in the near future -inline unsigned long long grunstable_ratequery_nrates( - const chemistry_data_storage* my_rates) { - // current implementation is stupid! (in future, will use my_rates) - unsigned long long i = 0; - while (nullptr != grunstable_ith_rate(my_rates, i, nullptr)) { - i++; - } - return i; -} - /// used for creating the iterator and within range-based for-loops class RateQueryRange { RateQueryPlugin plugin_; diff --git a/tests/unit/test_api_ratequery.cpp b/tests/unit/test_api_ratequery.cpp index cf9c5f52e..375f8257c 100644 --- a/tests/unit/test_api_ratequery.cpp +++ b/tests/unit/test_api_ratequery.cpp @@ -22,7 +22,6 @@ /// returns the rateid used to denote invalid rate names grunstable_rateid_type get_invalid_rateid(const grtest::GrackleCtxPack& pack) { - // although we don't use pack, yet a forthcoming refactor requires it return grunstable_ratequery_id(pack.my_rates(), nullptr); } @@ -36,6 +35,15 @@ TEST_F(SimpleRateQueryTest, InvalidIthRate) { EXPECT_EQ(name, nullptr); } +TEST_F(SimpleRateQueryTest, IthRateChecks) { + chemistry_data_storage* my_rates = pack.my_rates(); + unsigned long long n_rates = grunstable_ratequery_nrates(my_rates); + ASSERT_GT(n_rates, 0); // <- sanity check! + EXPECT_NE(nullptr, grunstable_ith_rate(my_rates, n_rates - 1, nullptr)); + EXPECT_EQ(nullptr, grunstable_ith_rate(my_rates, n_rates, nullptr)); + EXPECT_EQ(nullptr, grunstable_ith_rate(my_rates, n_rates + 1, nullptr)); +} + TEST_F(SimpleRateQueryTest, EmptyNameQuery) { grunstable_rateid_type rateid = grunstable_ratequery_id(pack.my_rates(), ""); EXPECT_EQ(rateid, get_invalid_rateid(pack)); From 93c4c74842dfacc7a90d2e03f1654d81616efdc6 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Fri, 19 Dec 2025 17:39:51 -0500 Subject: [PATCH 126/175] add some tests that query rates --- tests/grtestutils/CMakeLists.txt | 1 + tests/grtestutils/googletest/assertions.hpp | 70 ++++++ tests/grtestutils/iterator_adaptor.hpp | 9 + tests/unit/test_api_ratequery.cpp | 258 ++++++++++++++++++++ 4 files changed, 338 insertions(+) create mode 100644 tests/grtestutils/googletest/assertions.hpp diff --git a/tests/grtestutils/CMakeLists.txt b/tests/grtestutils/CMakeLists.txt index 27bf11d17..42bb65246 100644 --- a/tests/grtestutils/CMakeLists.txt +++ b/tests/grtestutils/CMakeLists.txt @@ -86,6 +86,7 @@ add_library(grtestutils utils.hpp utils.cpp # files in the googletest subdirectory (reminder: should just be headers!) + googletest/assertions.hpp googletest/check_allclose.hpp googletest/fixtures.hpp ) diff --git a/tests/grtestutils/googletest/assertions.hpp b/tests/grtestutils/googletest/assertions.hpp new file mode 100644 index 000000000..14177d7d8 --- /dev/null +++ b/tests/grtestutils/googletest/assertions.hpp @@ -0,0 +1,70 @@ +//===----------------------------------------------------------------------===// +// +// See the LICENSE file for license and copyright information +// SPDX-License-Identifier: NCSA AND BSD-3-Clause +// +//===----------------------------------------------------------------------===// +/// +/// @file +/// Declares some general-purpose assertions for testing grackle +/// +//===----------------------------------------------------------------------===// +#ifndef GRTEST_GOOGLETEST_ASSERTIONS_HPP +#define GRTEST_GOOGLETEST_ASSERTIONS_HPP + +#include + +#include +#include "grackle.h" + +namespace grtest { + +inline testing::AssertionResult IsGRSUCCESS(const char* expr1, int val1) { + if (val1 == GR_SUCCESS) { + return testing::AssertionSuccess(); + } + + std::string descr; + switch (val1) { + case GR_SUCCESS: { + descr = "GR_SUCCESS"; + break; + } + case GR_FAIL: { + descr = "GR_FAIL"; + break; + } + default: { + descr = "not a standard code"; + } + } + testing::AssertionResult out = testing::AssertionFailure(); + out << "Evaluated: " << expr1 << '\n' + << " Expected: GR_SUCCESS (aka " << GR_SUCCESS << ")\n" + << " Actual: " << val1 << " (" << descr << ')'; + return out; +} + +inline testing::AssertionResult IsGRError(const char* expr1, int val1) { + if (val1 != GR_SUCCESS) { + return testing::AssertionSuccess(); + } + + testing::AssertionResult out = testing::AssertionFailure(); + out << "Evaluated: " << expr1 << '\n' + << " Expected: a value other than GR_SUCCESS\n" + << " Actual: " << val1 << " (GR_SUCCESS)"; + return out; +} + +} // namespace grtest + +#define EXPECT_GR_SUCCESS(expr) EXPECT_PRED_FORMAT1(::grtest::IsGRSUCCESS, expr) + +#define ASSERT_GR_SUCCESS(expr) ASSERT_PRED_FORMAT1(::grtest::IsGRSUCCESS, expr) + +#define EXPECT_GR_ERR(expr) EXPECT_PRED_FORMAT1(::grtest::IsGRError, expr) + +#define ASSERT_GR_ERR(expr) ASSERT_PRED_FORMAT1(::grtest::IsGRError, expr) + +#endif // GRTEST_GOOGLETEST_ASSERTIONS_HPP diff --git a/tests/grtestutils/iterator_adaptor.hpp b/tests/grtestutils/iterator_adaptor.hpp index cb9781047..71bd745a2 100644 --- a/tests/grtestutils/iterator_adaptor.hpp +++ b/tests/grtestutils/iterator_adaptor.hpp @@ -13,6 +13,7 @@ #define GRTESTUTILS_ITERATOR_ADAPTOR_HPP #include +#include #include #include "grackle.h" @@ -26,6 +27,14 @@ struct NameIdPair { long long id; }; +/// teach std::ostream how to format NameIdPair +/// +/// The motivation is to make it easier write detailed error messages +inline std::ostream& operator<<(std::ostream& os, const NameIdPair& pair) { + os << "{name=\"" << pair.name << "\", id=" << pair.id << "}"; + return os; +} + /// implements a C++ style InputIterator by adapting a simple Plugin type /// that wraps a set of Grackle functions /// diff --git a/tests/unit/test_api_ratequery.cpp b/tests/unit/test_api_ratequery.cpp index 375f8257c..9a0b58f02 100644 --- a/tests/unit/test_api_ratequery.cpp +++ b/tests/unit/test_api_ratequery.cpp @@ -10,15 +10,22 @@ /// //===----------------------------------------------------------------------===// +#include // std::min, std::max #include #include +#include +#include #include #include +#include #include +#include #include "grtestutils/iterator_adaptor.hpp" +#include "grtestutils/googletest/assertions.hpp" #include "grtestutils/googletest/fixtures.hpp" #include "grackle.h" +#include "status_reporting.h" /// returns the rateid used to denote invalid rate names grunstable_rateid_type get_invalid_rateid(const grtest::GrackleCtxPack& pack) { @@ -66,6 +73,71 @@ TEST_F(SimpleRateQueryTest, PtrInvalidRateId) { // tests themselves as easy to read as possible, we implate a C++-style // iterator to wrap part of the interface +std::string stringify_prop_kind(enum grunstable_ratequery_prop_kind kind) { + switch (kind) { + case GRUNSTABLE_QPROP_NDIM: + return "GRUNSTABLE_QPROP_NDIM"; + case GRUNSTABLE_QPROP_SHAPE: + return "GRUNSTABLE_QPROP_SHAPE"; + case GRUNSTABLE_QPROP_MAXITEMSIZE: + return "GRUNSTABLE_QPROP_MAXITEMSIZE"; + } + GR_INTERNAL_UNREACHABLE_ERROR(); +} + +/// return a vector of some invalid rateids +std::vector invalid_rateids( + grtest::GrackleCtxPack& pack) { + grunstable_rateid_type max_id = + std::numeric_limits::lowest(); + grunstable_rateid_type min_id = + std::numeric_limits::max(); + + // iterate over (parameter-name, rate-id) pairs + for (const grtest::NameIdPair pair : grtest::RateQueryRange(pack)) { + max_id = std::max(max_id, static_cast(pair.id)); + min_id = std::min(min_id, static_cast(pair.id)); + } + + std::vector bad_ids; + if (min_id > std::numeric_limits::lowest()) { + bad_ids.push_back(min_id - 1); + } + if (max_id < std::numeric_limits::max()) { + bad_ids.push_back(max_id + 1); + } + return bad_ids; +} + +TEST_F(SimpleRateQueryTest, PropertyInvalidRateID) { + std::vector invalid_ids = invalid_rateids(pack); + if (invalid_ids.empty()) { + GTEST_SKIP() << "unable to come up with known invalid rate ids to use for " + << "the test"; + } + + std::vector prop_kinds{ + GRUNSTABLE_QPROP_NDIM, GRUNSTABLE_QPROP_SHAPE, + GRUNSTABLE_QPROP_MAXITEMSIZE}; + std::vector buf; + + for (grunstable_rateid_type invalid_id : invalid_ids) { + for (enum grunstable_ratequery_prop_kind kind : prop_kinds) { + constexpr std::size_t BUF_LEN = 20; // <- arbitrarily large value + constexpr long long DEFAULT_VAL = -25634634LL; // <- arbitrary value + buf.assign(BUF_LEN, DEFAULT_VAL); + ASSERT_GR_ERR(grunstable_ratequery_prop(pack.my_rates(), invalid_id, kind, + buf.data())) + << "executed with invalid_id=" << invalid_id + << ", kind=" << stringify_prop_kind(kind); + EXPECT_THAT(buf, testing::Each(testing::Eq(DEFAULT_VAL))) + << "grunstable_ratequery_prop mutated the ptr even though it " + << "reported a failure. It was called with an invalid id of " + << invalid_id << " and a kind of " << stringify_prop_kind(kind); + } + } +} + using ParametrizedRateQueryTest = grtest::ParametrizedConfigPresetFixture; TEST_P(ParametrizedRateQueryTest, AllUnique) { @@ -87,6 +159,102 @@ TEST_P(ParametrizedRateQueryTest, ConsistentIDs) { } } +TEST_P(ParametrizedRateQueryTest, Property) { + std::vector buf; + for (const grtest::NameIdPair pair : grtest::RateQueryRange(pack)) { + constexpr long long DEFAULT_VAL = -25634634LL; // <- arbitrary value + + // check ndim + long long ndim = DEFAULT_VAL; + EXPECT_GR_SUCCESS(grunstable_ratequery_prop(pack.my_rates(), pair.id, + GRUNSTABLE_QPROP_NDIM, &ndim)) + << "for " << pair; + ASSERT_GE(ndim, 0LL) << "for " << pair; + + // check shape + buf.assign((ndim == 0LL) ? 1 : ndim, DEFAULT_VAL); + EXPECT_GR_SUCCESS(grunstable_ratequery_prop( + pack.my_rates(), pair.id, GRUNSTABLE_QPROP_SHAPE, buf.data())) + << "for " << pair; + if (ndim == 0LL) { + EXPECT_EQ(buf[0], DEFAULT_VAL) + << "the buffer passed to grunstable_ratequery_prop was unexpectedly " + << "modified while querying the shape for the rate " << pair + << ". It shouldn't be modified since ndim=0."; + } else { + EXPECT_THAT(buf, testing::Each(testing::Gt(0))) + << "buf holds the shape queried for " << pair; + } + + long long maxitemsize = DEFAULT_VAL; + EXPECT_GR_SUCCESS(grunstable_ratequery_prop( + pack.my_rates(), pair.id, GRUNSTABLE_QPROP_MAXITEMSIZE, &maxitemsize)) + << "for " << pair; + EXPECT_EQ(maxitemsize, sizeof(double)) << "for " << pair; + } +} + +/// summarizes details about rate properties +struct RateProperties { + std::vector shape; + std::size_t maxitemsize; + + bool operator==(const RateProperties& other) const { + return maxitemsize == other.maxitemsize && shape == other.shape; + } + + /// teach googletest how to print this type + friend void PrintTo(const RateProperties& props, std::ostream* os) { + *os << "{shape={"; + for (std::size_t i = 0; i < props.shape.size(); i++) { + if (i != 0) { + *os << ", "; + } + *os << props.shape[i]; + } + *os << "}, maxitemsize=" << props.maxitemsize << "}"; + } +}; + +/// construct a RateProperties instance for the specified rate +/// +/// returns an empty optional if any there are any issues +std::optional try_query_RateProperties( + chemistry_data_storage* my_rates, grunstable_rateid_type rateid) { + long long ndim = -1LL; + std::vector shape; + if (grunstable_ratequery_prop(my_rates, rateid, GRUNSTABLE_QPROP_NDIM, + &ndim) != GR_SUCCESS) { + return std::nullopt; + } else if (ndim != 0LL) { + if (ndim < 0LL) { // <- sanity check! + return std::nullopt; + } + shape.assign(ndim, 0LL); + if (grunstable_ratequery_prop(my_rates, rateid, GRUNSTABLE_QPROP_SHAPE, + shape.data()) != GR_SUCCESS) { + return std::nullopt; + } + } + + // sanity check! confirm that no shape elements are non-positive + if (std::count_if(shape.begin(), shape.end(), + [](long long x) { return x <= 0; }) > 0) { + return std::nullopt; // sanity check failed! + } + + long long maxitemsize = -1LL; + if (grunstable_ratequery_prop(my_rates, rateid, GRUNSTABLE_QPROP_MAXITEMSIZE, + &maxitemsize) != GR_SUCCESS) { + return std::nullopt; + } + if (maxitemsize <= 0LL) { + return std::nullopt; + } + + return {RateProperties{shape, static_cast(maxitemsize)}}; +} + using grtest::ChemPreset; using grtest::FullConfPreset; using grtest::InitialUnitPreset; @@ -100,3 +268,93 @@ INSTANTIATE_TEST_SUITE_P( FullConfPreset{ChemPreset::primchem3, InitialUnitPreset::simple_z0}, FullConfPreset{ChemPreset::primchem4_dustspecies3, InitialUnitPreset::simple_z0})); + +// now, we are going to check on some well-established rates +// -> this may not be the most maintainable test (we may want to re-evaluate it +// in the future) + +enum RateKind { scalar_f64, simple_1d_rate, k13dd }; + +static RateProperties RateProperties_from_RateKind( + const chemistry_data* my_chemistry, RateKind kind) { + switch (kind) { + case RateKind::scalar_f64: { + std::vector shape = {}; // <-- intentionally empty + return RateProperties{shape, sizeof(double)}; + } + case RateKind::simple_1d_rate: { + std::vector shape = {my_chemistry->NumberOfTemperatureBins}; + return RateProperties{shape, sizeof(double)}; + } + case RateKind::k13dd: { + std::vector shape = {my_chemistry->NumberOfTemperatureBins * + 14}; + return RateProperties{shape, sizeof(double)}; + } + } + GR_INTERNAL_UNREACHABLE_ERROR() +} + +/// returns a map between known rate names and the rate kind +std::map known_rates() { + std::map out; + // radiative rates: + for (int i = 24; i < 32; i++) { + out.insert({"k" + std::to_string(i), RateKind::scalar_f64}); + } + + // standard collisional rates + for (int i = 1; i < 24; i++) { + out.insert({"k" + std::to_string(i), RateKind::simple_1d_rate}); + } + for (int i = 50; i < 58; i++) { + out.insert({"k" + std::to_string(i), RateKind::simple_1d_rate}); + } + for (int i = 125; i < 154; i++) { + out.insert({"k" + std::to_string(i), RateKind::simple_1d_rate}); + } + + // metal chemistry rates + for (int i = 11; i < 55; i++) { + out.insert({"kz" + std::to_string(i), RateKind::simple_1d_rate}); + } + + out.insert({"k13dd", RateKind::k13dd}); + + return out; +} + +using KnownRateQueryTest = + grtest::ConfigPresetFixture; + +TEST_F(KnownRateQueryTest, CheckProperties) { + const std::map known_rate_map = known_rates(); + + // iterate over every known {parameter-name, key-id} pair + for (const grtest::NameIdPair pair : grtest::RateQueryRange(pack)) { + // check if the current rateid is in known_rate_map + std::map::const_iterator search = + known_rate_map.find(pair.name); + if (search == known_rate_map.end()) { + continue; // the rateid is **NOT** in known_rate_map + } + // construct the expected properties + RateProperties expected_props = + RateProperties_from_RateKind(pack.my_chemistry(), search->second); + + // load the actual props + std::optional maybe_actual_props = + try_query_RateProperties(pack.my_rates(), pair.id); + if (!maybe_actual_props.has_value()) { + GTEST_FAIL() + << "something went wrong while trying to lookup the properties for " + << "the " << pair << " rate."; + } + RateProperties actual_props = maybe_actual_props.value(); + + EXPECT_EQ(expected_props, actual_props) + << "this mismatch in the queried properties is for the " << pair + << " rate."; + } +} From 08841f77b758cf9e52254066db9d63aec2d2cc46 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Fri, 19 Dec 2025 19:12:12 -0500 Subject: [PATCH 127/175] introduced a setter and getter function --- src/clib/ratequery.cpp | 67 +++++++++++++++++++++++++++++++ src/include/grackle.h | 56 +++++++++++++++++++++++--- tests/unit/test_api_ratequery.cpp | 62 ++++++++++++++++++++++++++++ 3 files changed, 180 insertions(+), 5 deletions(-) diff --git a/src/clib/ratequery.cpp b/src/clib/ratequery.cpp index 5c54f74cb..294b731ed 100644 --- a/src/clib/ratequery.cpp +++ b/src/clib/ratequery.cpp @@ -147,6 +147,9 @@ static Entry get_MiscRxn_Entry(chemistry_data_storage* my_rates, int i) { grackle::impl::ratequery::Registry grackle::impl::ratequery::new_Registry( const chemistry_data& my_chemistry) { + if (my_chemistry.primordial_chemistry == 0) { + return Registry{0, nullptr}; + } EntryProps props_LogTLinInterp = mk_invalid_EntryProps(); props_LogTLinInterp.ndim = 1; props_LogTLinInterp.shape[0] = my_chemistry.NumberOfTemperatureBins; @@ -232,6 +235,37 @@ static ratequery_rslt_ query_Entry(chemistry_data_storage* my_rates, return invalid_rslt_(); } +/* +/// this only exists for debugging purposes +static void show_Entry(const Entry* entry) { + std::printf( + "{.data=%p, .name=\"%s\", .props={.ndim=%d, .shape={", + reinterpret_cast(entry->data), entry->name, entry->props.ndim); + // we should strongly consider factoring out logic for printing arrays + for (int i = 0; i < entry->props.ndim; i++) { + if (i > 0) { + std::printf(", "); + } + std::printf("%d", entry->props.shape[i]); + } + std::printf("}}\n"); +} +*/ + +/// compute the number of items in an Entry described by @p props +static long long get_n_items(EntryProps props) { + GR_INTERNAL_REQUIRE(props.ndim >= 0, "sanity check!"); + + if (props.ndim == 0) { + return 1LL; // a scalar always consists of 1 item + } + long long n_items = 1LL; + for (int i = 0; i < props.ndim; i++) { + n_items *= static_cast(props.shape[i]); + } + return n_items; +} + } // namespace grackle::impl::ratequery // here we implement the public API @@ -258,6 +292,39 @@ extern "C" grunstable_rateid_type grunstable_ratequery_id( return rate_q::UNDEFINED_RATE_ID_; } +extern "C" int grunstable_ratequery_get_f64(chemistry_data_storage* my_rates, + grunstable_rateid_type rate_id, + double* buf) { + namespace rate_q = grackle::impl::ratequery; + rate_q::Entry entry = rate_q::query_Entry(my_rates, rate_id, true).entry; + + if (entry.data == nullptr) { // in this case, the query failed + return GR_FAIL; + } + + long long n_items = rate_q::get_n_items(entry.props); + for (long long i = 0; i < n_items; i++) { + buf[i] = entry.data[i]; + } + return GR_SUCCESS; +} + +extern "C" int grunstable_ratequery_set_f64(chemistry_data_storage* my_rates, + grunstable_rateid_type rate_id, + const double* buf) { + namespace rate_q = grackle::impl::ratequery; + rate_q::Entry entry = rate_q::query_Entry(my_rates, rate_id, true).entry; + if (entry.data == nullptr) { // in this case, the query failed + return GR_FAIL; + } + + long long n_items = rate_q::get_n_items(entry.props); + for (long long i = 0; i < n_items; i++) { + entry.data[i] = buf[i]; + } + return GR_SUCCESS; +} + extern "C" double* grunstable_ratequery_get_ptr( chemistry_data_storage* my_rates, grunstable_rateid_type rate_id) { namespace rate_q = grackle::impl::ratequery; diff --git a/src/include/grackle.h b/src/include/grackle.h index a599a15d5..5f513a184 100644 --- a/src/include/grackle.h +++ b/src/include/grackle.h @@ -198,11 +198,7 @@ int gr_initialize_field_data(grackle_field_data *my_fields); /// > - we should probably update all of the function signatures so that a /// > pointer to chemistry_data_storage* is passed as an argument to each /// > of the functions. -/// > 2. Should we prevent direct access to the underlying data pointers? -/// > Instead we would provide getter and setters. We discuss this further -/// > down below (in the relevant function's API). This is important for -/// > different backends. -/// > 3. We should generally consider whether the API is consistent enough with +/// > 2. We should generally consider whether the API is consistent enough with /// > APIs for accessing other data structures. /// > - currently the dynamic parameter API is grackle's only other /// > data-access API, but we could imagine creating an API for the fields @@ -234,6 +230,56 @@ typedef long long grunstable_rateid_type; grunstable_rateid_type grunstable_ratequery_id( const chemistry_data_storage* my_rates, const char* name); +/// Copy data associated with the @p rate_id in @p my_rates into buf +/// +/// The behavior is currently undefined if: +/// - the @p my_rates argument is a NULL pointer +/// - the @p my_rates argument isn't configured to use the specified rate +/// - the @p buf argument is NULL +/// - the @p buf isn't large enough to store the copied rates +/// +/// @param[in] my_rates The object from which data is retrieved +/// @param[in] rate_id The id of the rate for which the data is retrieved +/// @param[out] buf The buffer that the function writes to +/// +/// @return Returns GR_SUCCESS if successful. If an invalid @p rate_id is +/// specified, this returns a different value +/// +/// > [!note] +/// > Before stablizing, we should consider whether we want to add an argument +/// > that specifies the supplied size of `buf` (and provide well-defined +/// > behavior when `buf` is too small +int grunstable_ratequery_get_f64( + chemistry_data_storage* my_rates, grunstable_rateid_type rate_id, + double* buf +); + + +/// Overwrite the data associated with @p rate_id in @p my_rates with the +/// values provided by @p buf +/// +/// The behavior is currently undefined if: +/// - the @p my_rates argument is a NULL pointer +/// - the @p my_rates argument isn't configured to use the specified rate +/// - the @p buf argument is NULL +/// - the @p buf isn't large enough to store the copied rates +/// +/// @param[out] my_rates The object from which data is retrieved +/// @param[in] rate_id The id of the rate for which the data is retrieved +/// @param[in] buf The buffer that the function writes to +/// +/// @return Returns GR_SUCCESS if successful. If an invalid @p rate_id is +/// specified, this returns a different value +/// +/// > [!note] +/// > Before stablizing, we should consider whether we want to add an argument +/// > that specifies the supplied size of `buf` (and provide well-defined +/// > behavior when `buf` is too small +int grunstable_ratequery_set_f64( + chemistry_data_storage* my_rates, grunstable_rateid_type rate_id, + const double* buf +); + /// Access the pointer associated with the rateid from myrates /// /// The behavior is **NOT** currently defined if the `my_rates` struct isn't diff --git a/tests/unit/test_api_ratequery.cpp b/tests/unit/test_api_ratequery.cpp index 9a0b58f02..e7b6c5672 100644 --- a/tests/unit/test_api_ratequery.cpp +++ b/tests/unit/test_api_ratequery.cpp @@ -203,6 +203,14 @@ struct RateProperties { return maxitemsize == other.maxitemsize && shape == other.shape; } + long long n_items() const { + long long n_items = 1LL; + for (std::size_t i = 0; i < shape.size(); i++) { + n_items *= shape[i]; + } + return n_items; // this is correct even for scalars + } + /// teach googletest how to print this type friend void PrintTo(const RateProperties& props, std::ostream* os) { *os << "{shape={"; @@ -255,6 +263,57 @@ std::optional try_query_RateProperties( return {RateProperties{shape, static_cast(maxitemsize)}}; } +// returns a value that differs from the input +static double remap_value(double in) { + if (in == 0.0 || !std::isfinite(in)) { + return 1.0; + } + return -in; +} + +TEST_P(ParametrizedRateQueryTest, SetAndGet) { + std::vector initial_buf; + std::vector post_update_buf; + + // iterate over every known (rate-name, rate-id) pair + for (const grtest::NameIdPair pair : grtest::RateQueryRange(pack)) { + // get the properties associated with the current rate + std::optional maybe_props = + try_query_RateProperties(pack.my_rates(), pair.id); + if (!maybe_props.has_value()) { + GTEST_FAIL() + << "something went wrong while trying to lookup the properties for " + << "the " << pair << " rate."; + } + RateProperties props = maybe_props.value(); + long long n_items = props.n_items(); + + // load in data associated with the current rate + initial_buf.assign(n_items, NAN); + ASSERT_GR_SUCCESS(grunstable_ratequery_get_f64(pack.my_rates(), pair.id, + initial_buf.data())) + << "for " << pair; + + // overwrite each entry with a different value + for (long long i = 0; i < n_items; i++) { + initial_buf[i] = remap_value(initial_buf[i]); + } + + // write the new values back to my_rates + EXPECT_GR_SUCCESS(grunstable_ratequery_set_f64(pack.my_rates(), pair.id, + initial_buf.data())) + << "for " << pair; + + // finally, lets check that the values actually got updated + post_update_buf.assign(n_items, NAN); + EXPECT_GR_SUCCESS(grunstable_ratequery_get_f64(pack.my_rates(), pair.id, + post_update_buf.data())) + << "for " << pair; + + EXPECT_EQ(initial_buf, post_update_buf) << "for " << pair; + } +} + using grtest::ChemPreset; using grtest::FullConfPreset; using grtest::InitialUnitPreset; @@ -357,4 +416,7 @@ TEST_F(KnownRateQueryTest, CheckProperties) { << "this mismatch in the queried properties is for the " << pair << " rate."; } + + // it might be useful to repeat the tests using another chemistry_data + // instance with a different NumberOfTemperatureBins value } From c75aacfdbc7f0820a37298e99948ba7c0629d558 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sat, 20 Dec 2025 10:54:58 -0500 Subject: [PATCH 128/175] gracklepy: implement wrappers that use getter/setter --- src/python/gracklepy/grackle_defs.pxd | 10 ++ src/python/gracklepy/grackle_wrapper.pyx | 116 ++++++++++++++++++++++- 2 files changed, 125 insertions(+), 1 deletion(-) diff --git a/src/python/gracklepy/grackle_defs.pxd b/src/python/gracklepy/grackle_defs.pxd index a8e6b761c..81de18dd8 100644 --- a/src/python/gracklepy/grackle_defs.pxd +++ b/src/python/gracklepy/grackle_defs.pxd @@ -303,6 +303,16 @@ cdef extern from "grackle.h": const c_chemistry_data_storage* my_rates, const char* name) + int grunstable_ratequery_get_f64( + c_chemistry_data_storage* my_rates, + grunstable_rateid_type rate_id, + double* buf) + + int grunstable_ratequery_set_f64( + c_chemistry_data_storage* my_rates, + grunstable_rateid_type rate_id, + const double* buf) + double* grunstable_ratequery_get_ptr( c_chemistry_data_storage* my_rates, grunstable_rateid_type rate_id) diff --git a/src/python/gracklepy/grackle_wrapper.pyx b/src/python/gracklepy/grackle_wrapper.pyx index 772ccfb36..0e2e12ea6 100644 --- a/src/python/gracklepy/grackle_wrapper.pyx +++ b/src/python/gracklepy/grackle_wrapper.pyx @@ -903,6 +903,18 @@ cdef class _wrapped_c_chemistry_data: return out +def _portable_reshape(arr: np.ndarray, shape: tuple[int, ...]) -> np.ndarray: + """ + Reshape a numpy array (raises an error if a copy can't be avoided) + """ + if np.__version__.startswith("1.") or np.__version__.startswith("2.0."): + out = arr.view() + out.shape = shape + return out + else: + return arr.reshape(shape, order="C", copy=False) + + cdef class _rate_mapping_access: # This class is used internally by the chemistry_data extension class to # wrap its chemistry_data_storage ptr and provide access to the stored @@ -929,6 +941,9 @@ cdef class _rate_mapping_access: @staticmethod cdef _rate_mapping_access from_ptr(c_chemistry_data_storage *ptr): + """ + Construct a _rate_mapping_access instance from the provided pointer + """ cdef _rate_mapping_access out = _rate_mapping_access.__new__( _rate_mapping_access ) @@ -937,9 +952,17 @@ cdef class _rate_mapping_access: @property def _name_rateid_map(self): + """returns a mapping between rate names and rate id""" + if self._cached_name_rateid_map is not None: return self._cached_name_rateid_map + if self._ptr is NULL: + raise RuntimeError( + "this instance hasn't been configured with a pointer for it " + "access retrieve data from" + ) + cdef dict out = {} cdef const char* rate_name cdef grunstable_rateid_type rate_id @@ -952,7 +975,10 @@ cdef class _rate_mapping_access: out[rate_name.decode('UTF-8')] = int(rate_id) i+=1 - def _try_get_shape(self, rate_id): + def _try_get_shape(self, rate_id: int) -> tuple[int, ...]: + """ + try to query the shape associated with rate_id + """ cdef long long buf[7] cdef int ret = grunstable_ratequery_prop( self._ptr, rate_id, GRUNSTABLE_QPROP_NDIM, &buf[0] @@ -976,6 +1002,94 @@ cdef class _rate_mapping_access: "the query for shape failed after query for ndim succeeded") return tuple(int(buf[i]) for i in range(ndim)) + def _get_rate(self, key: str): + """ + Returns a numpy array that holds a copy of grackle's internal data + associated with `key` + + Parameters + ---------- + key: str + The name of the quantity to access + + Returns + ------- + np.ndarray or float + The retrieved value + """ + + # lookup the rate_id and shape of the rates + rate_id = self._name_rateid_map[key] + shape = self._try_get_shape(rate_id) + + # allocate the memory that grackle will write data to + nelements = 1 if shape == () else np.prod(shape) + out = np.empty(shape=(nelements,), dtype=np.float64) + + # create a memoryview of out (so we can access the underlying pointer) + cdef double[:] memview = out + + if grunstable_ratequery_get_f64(self._ptr, rate_id, &memview[0]) != GR_SUCCESS: + raise RuntimeError( + "Something went wrong while retrieving the data associated with the " + f"\"{key}\" key" + ) + if shape == (): + return float(out[0]) + + if shape != out.shape: + out = _portable_reshape(out, shape=shape) + # we set the WRITABLE flag to False so that people don't mistakenly believe + # that by modifying the array in place that they are updating Grackle's + # internal buffers + out.setflags(write=False) + return out + + def _set_rate(self, key, val): + """ + Copies value(s) into the Grackle solver's internal buffer associated + with `key` + + Parameters + ---------- + key: str + The name of the quantity to modify + val: array_like + The values to be written + """ + # lookup the rate_id and shape of the rates + rate_id = self._name_rateid_map[key] + shape = self._try_get_shape(rate_id) + + # validate that val meets expectations and then coerce to `buf` a 1D numpy + # array that we can feed to the C function + if np.shape(val) != shape: + if shape == (): + raise ValueError(f"The \"{key}\" key expects a scalar") + raise ValueError(f"The \"{key}\" expects a value with shape, {shape}") + elif shape == (): + coerced = float(val) + buf = np.array([coerced]) + else: + coerced = np.asanyarray(val, dtype=np.float64, order="C") + if hasattr(coerced, "unit") or hasattr(coerced, "units"): + # val is probably an astropy.Quantity or unyt.unyt_array instance + raise ValueError( + f"'{type(self).__name__}' can't handle numpy.ndarray subclasses " + "that attach unit information" + ) + buf = _portable_reshape(coerced, shape = (coerced.size,)) + + # create a memoryview of out (so we can access the underlying pointer) + cdef const double[:] memview = buf + + if grunstable_ratequery_set_f64(self._ptr, rate_id, &memview[0]) != GR_SUCCESS: + raise RuntimeError( + "Something went wrong while writing data associated with the " + f"\"{key}\" key" + ) + + def _access_rate(self, key, val): # determine whether the rate needs to be updated update_rate = (val is not _NOSETVAL) From 088187305f508066c2dbda3572e2ab42c85cb676 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sat, 20 Dec 2025 10:58:25 -0500 Subject: [PATCH 129/175] gracklepy: purge uses of grunstable_ratequery_get_ptr --- src/python/gracklepy/grackle_defs.pxd | 4 -- src/python/gracklepy/grackle_wrapper.pyx | 48 ++---------------------- 2 files changed, 3 insertions(+), 49 deletions(-) diff --git a/src/python/gracklepy/grackle_defs.pxd b/src/python/gracklepy/grackle_defs.pxd index 81de18dd8..9a8017345 100644 --- a/src/python/gracklepy/grackle_defs.pxd +++ b/src/python/gracklepy/grackle_defs.pxd @@ -313,10 +313,6 @@ cdef extern from "grackle.h": grunstable_rateid_type rate_id, const double* buf) - double* grunstable_ratequery_get_ptr( - c_chemistry_data_storage* my_rates, - grunstable_rateid_type rate_id) - cdef enum grunstable_ratequery_prop_kind: GRUNSTABLE_QPROP_NDIM GRUNSTABLE_QPROP_SHAPE diff --git a/src/python/gracklepy/grackle_wrapper.pyx b/src/python/gracklepy/grackle_wrapper.pyx index 0e2e12ea6..342817cae 100644 --- a/src/python/gracklepy/grackle_wrapper.pyx +++ b/src/python/gracklepy/grackle_wrapper.pyx @@ -1089,61 +1089,19 @@ cdef class _rate_mapping_access: f"\"{key}\" key" ) - - def _access_rate(self, key, val): - # determine whether the rate needs to be updated - update_rate = (val is not _NOSETVAL) - - rate_id = self._name_rateid_map[key] # will raise KeyError if not known - - if self._ptr is NULL: - raise RuntimeError( - "this instance hasn't been configured with a pointer for it " - "access retrieve data from" - ) - - # retrieve the pointer - cdef double* rate_ptr = grunstable_ratequery_get_ptr(self._ptr, rate_id) - - # lookup the shape of the rates - shape = self._try_get_shape(rate_id) - - # predeclare a memoryview to use with 1d arrays - cdef double[:] memview - - if shape == (): # handle the scalar case! - if update_rate: - rate_ptr[0] = val # cast performs type check - return float(rate_ptr[0]) - elif len(shape) == 1: - if update_rate: - raise RuntimeError( - f"You cannot assign a value to the {key!r} rate.\n\n" - "If you are looking to modify the rate's values, you " - f"should retrieve the {key!r} rate's value (a numpy " - "array), and modify the values in place" - ) - size = shape[0] - memview = (rate_ptr) - return np.asarray(memview) - else: - raise RuntimeError( - "no support is in place for higher dimensional arrays" - ) - def get(self, key, default=None, /): """ Retrieve the value associated with key, if key is known. Otherwise, return the default. """ try: - return self._access_rate(key, _NOSETVAL) + return self._get_rate(key) except: return default - def __getitem__(self, key): return self._access_rate(key, _NOSETVAL) + def __getitem__(self, key): return self._get_rate(key) - def __setitem__(self, key, value): self._access_rate(key, value) + def __setitem__(self, key, value): self._set_rate(key, value) def __iter__(self): return iter(self._name_rateid_map) From 144db1fa4240eceb47e469e56f3d4439c6f1e451 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sat, 20 Dec 2025 11:34:05 -0500 Subject: [PATCH 130/175] remove remaining references to grunstable_ratequery_get_ptr --- src/clib/ratequery.cpp | 7 ------- src/include/grackle.h | 32 ------------------------------- tests/unit/test_api_ratequery.cpp | 6 ------ 3 files changed, 45 deletions(-) diff --git a/src/clib/ratequery.cpp b/src/clib/ratequery.cpp index 294b731ed..746fba471 100644 --- a/src/clib/ratequery.cpp +++ b/src/clib/ratequery.cpp @@ -325,13 +325,6 @@ extern "C" int grunstable_ratequery_set_f64(chemistry_data_storage* my_rates, return GR_SUCCESS; } -extern "C" double* grunstable_ratequery_get_ptr( - chemistry_data_storage* my_rates, grunstable_rateid_type rate_id) { - namespace rate_q = grackle::impl::ratequery; - - return rate_q::query_Entry(my_rates, rate_id, true).entry.data; -} - extern "C" int grunstable_ratequery_prop( const chemistry_data_storage* my_rates, grunstable_rateid_type rate_id, enum grunstable_ratequery_prop_kind prop_kind, long long* ptr) { diff --git a/src/include/grackle.h b/src/include/grackle.h index 5f513a184..34993b8ad 100644 --- a/src/include/grackle.h +++ b/src/include/grackle.h @@ -280,38 +280,6 @@ int grunstable_ratequery_set_f64( const double* buf ); -/// Access the pointer associated with the rateid from myrates -/// -/// The behavior is **NOT** currently defined if the `my_rates` struct isn't -/// configured to use the specified rate. -/// -/// @return The pointer to the accessed data (whether the rate data corresponds -/// to an array or scalar). If an invalid `rate_id` is specified, this -/// returns NULL. -/// -/// > [!note] -/// > Before stablizing, we should consider whether we actually want this -/// > function. It may be better to replace it with a getter (that copies the -/// > rate data to the supplied buffer) and a setter (that copies the provided -/// > data out of the provided buffer). This may be appealing for a number of -/// > reasons: -/// > 1. When we add GPU support, the rate data may live permanently on the GPU -/// > (or some data may live on the GPU while other data lives on the CPU). -/// > With dedicated setters/getters, we could always require that the -/// > provided buffer data is on the CPU. -/// > 2. We have the option to conditionally disable the setter. For example, -/// > if we choose to support custom rates, I assume we will want to specify -/// > all custom choices as part of initialization (for simplicity) and then -/// > we may want to deprecate/remove the setter. (One could also imagine, -/// > disabling the setter when using GPUs). -/// > 3. It eliminates a certain class of memory-lifetime bugs (People could -/// > try use the pointer returned by the incarnation of this function after -/// > destroying Grackle. This problem can't happen with the proposed -/// > getter/setter) -double* grunstable_ratequery_get_ptr( - chemistry_data_storage* my_rates, grunstable_rateid_type rate_id -); - /// Describe Rate-Query Property Types /// /// > [!note] diff --git a/tests/unit/test_api_ratequery.cpp b/tests/unit/test_api_ratequery.cpp index e7b6c5672..69c03b336 100644 --- a/tests/unit/test_api_ratequery.cpp +++ b/tests/unit/test_api_ratequery.cpp @@ -62,12 +62,6 @@ TEST_F(SimpleRateQueryTest, InvalidNameQuery) { EXPECT_EQ(rateid, get_invalid_rateid(pack)); } -TEST_F(SimpleRateQueryTest, PtrInvalidRateId) { - double* ptr = - grunstable_ratequery_get_ptr(pack.my_rates(), get_invalid_rateid(pack)); - EXPECT_EQ(ptr, nullptr); -} - // most of the remaining tests (and future planned tests) involve iterating // through all rates made available via the ratequery interface. To make the // tests themselves as easy to read as possible, we implate a C++-style From 5d6fb08a83aa7e4b1ed9ffe564939770d774de2f Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sat, 13 Dec 2025 10:25:42 -0500 Subject: [PATCH 131/175] Rename `RecipeEntrySet` -> `EntrySet` and track `id_offset` separately --- src/clib/ratequery.cpp | 81 +++++++++++++++++++++--------------------- src/clib/ratequery.hpp | 25 +++++++++---- 2 files changed, 59 insertions(+), 47 deletions(-) diff --git a/src/clib/ratequery.cpp b/src/clib/ratequery.cpp index 746fba471..14825adc5 100644 --- a/src/clib/ratequery.cpp +++ b/src/clib/ratequery.cpp @@ -148,8 +148,9 @@ static Entry get_MiscRxn_Entry(chemistry_data_storage* my_rates, int i) { grackle::impl::ratequery::Registry grackle::impl::ratequery::new_Registry( const chemistry_data& my_chemistry) { if (my_chemistry.primordial_chemistry == 0) { - return Registry{0, nullptr}; + return Registry{0, 0, nullptr, nullptr}; } + // step 1: define several common EntryProps EntryProps props_LogTLinInterp = mk_invalid_EntryProps(); props_LogTLinInterp.ndim = 1; props_LogTLinInterp.shape[0] = my_chemistry.NumberOfTemperatureBins; @@ -162,24 +163,33 @@ grackle::impl::ratequery::Registry grackle::impl::ratequery::new_Registry( EntryProps props_scalar = mk_invalid_EntryProps(); props_scalar.ndim = 0; - const RecipeEntrySet standard_sets[] = { - {1000, CollisionalRxnLUT::NUM_ENTRIES, &get_CollisionalRxn_Entry, + // step 2: define standard entry recipies + const EntrySet standard_recipies[] = { + {CollisionalRxnLUT::NUM_ENTRIES, &get_CollisionalRxn_Entry, props_LogTLinInterp}, - {1999, 1, &get_k13dd_Entry, props_k13dd}, - {2000, MiscRxn_NRATES, &get_MiscRxn_Entry, props_scalar}}; - - int len = static_cast(sizeof(standard_sets) / sizeof(RecipeEntrySet)); - RecipeEntrySet* sets = new RecipeEntrySet[len]; - for (int i = 0; i < len; i++) { - sets[i] = standard_sets[i]; + {1, &get_k13dd_Entry, props_k13dd}, + {MiscRxn_NRATES, &get_MiscRxn_Entry, props_scalar}}; + + int n_sets = static_cast(sizeof(standard_recipies) / sizeof(EntrySet)); + + // step 3: actually set up Registry + EntrySet* sets = new EntrySet[n_sets]; + int* id_offsets = new int[n_sets]; + int tot_entry_count = 0; + for (int i = 0; i < n_sets; i++) { + id_offsets[i] = tot_entry_count; + sets[i] = standard_recipies[i]; + tot_entry_count += standard_recipies[i].len; } - return Registry{len, sets}; + return Registry{tot_entry_count, n_sets, id_offsets, sets}; } void grackle::impl::ratequery::drop_Registry( grackle::impl::ratequery::Registry* ptr) { if (ptr->sets != nullptr) { + delete[] ptr->id_offsets; + ptr->id_offsets = nullptr; delete[] ptr->sets; ptr->sets = nullptr; } @@ -204,33 +214,26 @@ static const Registry* get_registry(const chemistry_data_storage* my_rates) { } /// internal function to search for the rate description i -/// -/// We interpret i as rate_id, when use_rate_id is true. Otherwise, we just -/// look for the ith rate description (we introduce an artificial distinction -/// between the 2 cases because we want to reserve the right to be able to -/// change the relationship if it becomes convenient in the future) static ratequery_rslt_ query_Entry(chemistry_data_storage* my_rates, - long long i, bool use_rate_id) { + long long i) { const Registry* registry = get_registry(my_rates); - if (registry == nullptr) { + if (registry == nullptr || i >= registry->n_entries) { return invalid_rslt_(); } - int total_len = 0; // <- we increment this as we go through the rates - - for (int set_idx = 0; set_idx < registry->len; set_idx++) { - const struct RecipeEntrySet cur_set = registry->sets[set_idx]; + for (int set_idx = 0; set_idx < registry->n_sets; set_idx++) { + const struct EntrySet cur_set = registry->sets[set_idx]; + int cur_id_offset = registry->id_offsets[set_idx]; - const long long tmp = (use_rate_id) ? i - cur_set.id_offset : i - total_len; + const long long tmp = i - static_cast(cur_id_offset); if ((tmp >= 0) && (tmp < cur_set.len)) { ratequery_rslt_ out; - out.rate_id = tmp + cur_set.id_offset; - out.entry = cur_set.fn(my_rates, tmp); + out.rate_id = i; + out.entry = cur_set.recipe_fn(my_rates, tmp); out.entry.props = cur_set.common_props; return out; } - total_len += cur_set.len; } return invalid_rslt_(); } @@ -280,12 +283,13 @@ extern "C" grunstable_rateid_type grunstable_ratequery_id( return rate_q::UNDEFINED_RATE_ID_; } - for (int set_idx = 0; set_idx < registry->len; set_idx++) { - const rate_q::RecipeEntrySet set = registry->sets[set_idx]; - for (int i = 0; i < set.len; i++) { - rate_q::Entry entry = set.fn(nullptr, i); + for (int set_idx = 0; set_idx < registry->n_sets; set_idx++) { + const rate_q::EntrySet set = registry->sets[set_idx]; + int set_len = set.len; + for (int i = 0; i < set_len; i++) { + rate_q::Entry entry = set.recipe_fn(nullptr, i); if (std::strcmp(name, entry.name) == 0) { - return set.id_offset + i; + return registry->id_offsets[set_idx] + i; } } } @@ -296,7 +300,7 @@ extern "C" int grunstable_ratequery_get_f64(chemistry_data_storage* my_rates, grunstable_rateid_type rate_id, double* buf) { namespace rate_q = grackle::impl::ratequery; - rate_q::Entry entry = rate_q::query_Entry(my_rates, rate_id, true).entry; + rate_q::Entry entry = rate_q::query_Entry(my_rates, rate_id).entry; if (entry.data == nullptr) { // in this case, the query failed return GR_FAIL; @@ -313,7 +317,7 @@ extern "C" int grunstable_ratequery_set_f64(chemistry_data_storage* my_rates, grunstable_rateid_type rate_id, const double* buf) { namespace rate_q = grackle::impl::ratequery; - rate_q::Entry entry = rate_q::query_Entry(my_rates, rate_id, true).entry; + rate_q::Entry entry = rate_q::query_Entry(my_rates, rate_id).entry; if (entry.data == nullptr) { // in this case, the query failed return GR_FAIL; } @@ -333,7 +337,7 @@ extern "C" int grunstable_ratequery_prop( // short-term hack! (it's bad practice to "cast away the const") rate_q::Entry entry = rate_q::query_Entry(const_cast(my_rates), - rate_id, true) + rate_id) .entry; const rate_q::EntryProps& props = entry.props; @@ -369,7 +373,7 @@ extern "C" const char* grunstable_ith_rate( const long long sanitized_i = (i < LLONG_MAX) ? (long long)i : -1; // short-term hack! (it's bad practice to "cast away the const") rate_q::ratequery_rslt_ tmp = rate_q::query_Entry( - const_cast(my_rates), sanitized_i, false); + const_cast(my_rates), sanitized_i); if (out_rate_id != nullptr) { *out_rate_id = tmp.rate_id; } @@ -380,10 +384,5 @@ extern "C" unsigned long long grunstable_ratequery_nrates( const chemistry_data_storage* my_rates) { namespace rate_q = grackle::impl::ratequery; const rate_q::Registry* registry = my_rates->opaque_storage->registry; - - unsigned long long out = 0; - for (int i = 0; i < registry->len; i++) { - out += static_cast(registry->sets[i].len); - } - return out; + return registry->n_entries; } diff --git a/src/clib/ratequery.hpp b/src/clib/ratequery.hpp index 55b01c27f..2477f9919 100644 --- a/src/clib/ratequery.hpp +++ b/src/clib/ratequery.hpp @@ -97,18 +97,31 @@ inline Entry new_Entry(double* rate, const char* name) { /// satisfies `0 <= index <= (N-1)` typedef Entry fetch_Entry_recipe_fn(chemistry_data_storage*, int); -/// Describes the set of entries that can be accessed through a given recipe -struct RecipeEntrySet { - int id_offset; +/// Describes the set of entries that can be access through a given recipe +struct EntrySet { + /// number of entries in the current set int len; - fetch_Entry_recipe_fn* fn; + + /// a function pointer that can be used to access entries through a recipe + fetch_Entry_recipe_fn* recipe_fn; + + /// properties used by all entries accessed through a recipe + /// + /// In more detail, an entry returned by `recipe_fn` has its `props` member + /// overwritten by this value EntryProps common_props; }; /// Describes a registry of queryable entries struct Registry { - int len; - RecipeEntrySet* sets; + /// number of entries + int n_entries; + /// number of contained EntrySets + int n_sets; + /// stores the minimum rate_id for each EntrySet + int* id_offsets; + /// stores sets of entries + EntrySet* sets; }; /// construct a new registry From 5b7ed15ca8bd1d17029045a90f6c1b4febe142cb Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sat, 20 Dec 2025 14:24:44 -0500 Subject: [PATCH 132/175] initial implementation of RegBuilder --- src/clib/ratequery.cpp | 83 ++++++++++++++++++++++++++++++++ src/clib/ratequery.hpp | 105 +++++++++++++++++++++++++++++++++++------ 2 files changed, 174 insertions(+), 14 deletions(-) diff --git a/src/clib/ratequery.cpp b/src/clib/ratequery.cpp index 14825adc5..3908f9225 100644 --- a/src/clib/ratequery.cpp +++ b/src/clib/ratequery.cpp @@ -85,6 +85,7 @@ static Entry get_CollisionalRxn_Entry(chemistry_data_storage* my_rates, int i) { return MKENTRY_STANDARD_KCOL_(my_rates, NAME, CollisionalRxnLUT::NAME); \ } #include "collisional_rxn_rate_members.def" + #undef ENTRY default: { return mk_invalid_Entry(); @@ -143,8 +144,90 @@ static Entry get_MiscRxn_Entry(chemistry_data_storage* my_rates, int i) { } } +/// resets the instance to the initial (empty) state. +/// +/// the skip_dealloc argument will only be true when the data is transferred +/// to a Registry +static void RegBuilder_reset_to_empty(RegBuilder* ptr, bool skip_dealloc) { + if ((ptr->capacity > 0) && !skip_dealloc) { + delete[] ptr->sets; + } + (*ptr) = new_RegBuilder(); +} + +static int RegBuilder_recipe_(RegBuilder* ptr, fetch_Entry_recipe_fn* recipe_fn, + int n_entries, EntryProps common_props) { + if (recipe_fn == nullptr) { + return GrPrintAndReturnErr("recipe_fn is a nullptr"); + } else if (n_entries <= 0) { + return GrPrintAndReturnErr("n_entries is not positive"); + } else if (!EntryProps_is_valid(common_props)) { + return GrPrintAndReturnErr("common_props isn't valid"); + } + + if (ptr->capacity == 0) { + ptr->capacity = 5; + ptr->sets = new EntrySet[ptr->capacity]; + } else if (ptr->len == ptr->capacity) { + // consider making this resizable in the future... + return GrPrintAndReturnErr("out of capacity"); + } + + ptr->sets[ptr->len++] = EntrySet{n_entries, recipe_fn, common_props}; + return GR_SUCCESS; +} + } // namespace grackle::impl::ratequery +void grackle::impl::ratequery::drop_RegBuilder(RegBuilder* ptr) { + RegBuilder_reset_to_empty(ptr, false); +} + +namespace grackle::impl::ratequery {} // namespace grackle::impl::ratequery + +int grackle::impl::ratequery::RegBuilder_recipe_scalar( + RegBuilder* ptr, int n_entries, fetch_Entry_recipe_fn* recipe_fn) { + EntryProps common_props = mk_invalid_EntryProps(); + common_props.ndim = 0; + return RegBuilder_recipe_(ptr, recipe_fn, n_entries, common_props); +} + +int grackle::impl::ratequery::RegBuilder_recipe_1d( + RegBuilder* ptr, int n_entries, fetch_Entry_recipe_fn* recipe_fn, + int common_len) { + EntryProps common_props = mk_invalid_EntryProps(); + common_props.ndim = 1; + common_props.shape[0] = common_len; + return RegBuilder_recipe_(ptr, recipe_fn, n_entries, common_props); +} + +/// build a new Registry. +/// +/// In the process, the current Registry is consumed; it's effectively reset to +/// the state immediately after it was initialized. (This lets us avoid +/// reallocating lots of memory) +grackle::impl::ratequery::Registry +grackle::impl::ratequery::RegBuilder_consume_and_build(RegBuilder* ptr) { + int n_sets = ptr->len; + if (n_sets == 0) { + drop_RegBuilder(ptr); + return Registry{0, n_sets, nullptr, nullptr}; + } else { + // set up id_offsets and determine the total number of entries + int* id_offsets = new int[n_sets]; + int tot_entry_count = 0; + for (int i = 0; i < n_sets; i++) { + id_offsets[i] = tot_entry_count; + tot_entry_count += ptr->sets[i].len; + } + Registry out{tot_entry_count, n_sets, id_offsets, ptr->sets}; + // reset to ptr to initial state (but don't deallocate since the ptr was + // transferred to out + RegBuilder_reset_to_empty(ptr, true); + return out; + } +} + grackle::impl::ratequery::Registry grackle::impl::ratequery::new_Registry( const chemistry_data& my_chemistry) { if (my_chemistry.primordial_chemistry == 0) { diff --git a/src/clib/ratequery.hpp b/src/clib/ratequery.hpp index 2477f9919..2c264839b 100644 --- a/src/clib/ratequery.hpp +++ b/src/clib/ratequery.hpp @@ -97,20 +97,8 @@ inline Entry new_Entry(double* rate, const char* name) { /// satisfies `0 <= index <= (N-1)` typedef Entry fetch_Entry_recipe_fn(chemistry_data_storage*, int); -/// Describes the set of entries that can be access through a given recipe -struct EntrySet { - /// number of entries in the current set - int len; - - /// a function pointer that can be used to access entries through a recipe - fetch_Entry_recipe_fn* recipe_fn; - - /// properties used by all entries accessed through a recipe - /// - /// In more detail, an entry returned by `recipe_fn` has its `props` member - /// overwritten by this value - EntryProps common_props; -}; +// temporary forward declaration +struct EntrySet; /// Describes a registry of queryable entries struct Registry { @@ -130,6 +118,95 @@ Registry new_Registry(const chemistry_data&); /// deallocate the contents of a registry void drop_Registry(Registry* ptr); +/// An interface for gradually configuring a Registry +/// +/// @par Context within the codebase +/// This is intended to be an ephemeral object that only lives during within +/// the function that initializes a Grackle solver from user-specified +/// parameters +/// - the instance is created at the start of this function +/// - a pointer to the instance is passed to various initialization functions. +/// These functions can use the instance to register entries that will be +/// accessible in the resulting Registry +/// - if all configuration has gone well, this instance will be used to +/// initialize the Registry +/// - the instance is **always** destroyed when it is time to exit the solver +/// initialization function +/// +/// @par Motivation +/// There are 2 main sources of motivation +/// 1. It lets us locate a "recipe-routine" for accessing data next to the +/// routines that initialize the same data. This makes sense from a +/// code-organization perspective. Moreover, if we conditionally initialize +/// data, it will be easier to ensure that recipies won't try to provide +/// access to the uninitialized data +/// 2. this will make it easier for us to handle data that Grackle only +/// initializes for the sake of supporting user queries (at the moment, +/// this is hypothetical) +/// +/// @important +/// Other parts of grackle should refrain from directly accessing the internals +/// of this function (i.e. they should only use the associated methods) +struct RegBuilder { + int capacity; + int len; + EntrySet* sets; +}; + +/// initialize a new instance +inline RegBuilder new_RegBuilder() { return {0, 0, nullptr}; } + +/// deallocates all storage within a RegBuilder instance +void drop_RegBuilder(RegBuilder* ptr); + +/// register a recipe for accessing scalar values +/// +/// @param[inout] ptr The RegBuilder that will be updated +/// @param[in] n_entries The number of entries accessible through the recipe +/// @param[in] recipe_fn The recipe being registered +/// @param[in] common_props The properties shared by each Entry in the recipe +/// +/// @returns GR_SUCCESS if successful, otherwise returns a different value +int RegBuilder_recipe_scalar(RegBuilder* ptr, int n_entries, + fetch_Entry_recipe_fn* recipe_fn); + +/// register a recipe for accessing 1D arrays +/// +/// @param[inout] ptr The RegBuilder that will be updated +/// @param[in] n_entries The number of entries accessible through the recipe +/// @param[in] recipe_fn The recipe being registered +/// @param[in] common_len The length shared by each 1D array accessible +/// through this recipe. +/// +/// @returns GR_SUCCESS if successful, otherwise returns a different value +int RegBuilder_recipe_1d(RegBuilder* ptr, int n_entries, + fetch_Entry_recipe_fn* recipe_fn, int common_len); + +/// build a new Registry. +/// +/// In the process, the current Registry is consumed; it's effectively reset to +/// the state immediately after it was initialized. (This lets us avoid +/// reallocating lots of memory) +/// +/// @note +/// For safety, the caller should still plan to call drop_RegBuilder +Registry RegBuilder_consume_and_build(RegBuilder* ptr); + +/// Describes the set of entries that can be access through a given recipe +struct EntrySet { + /// number of entries in the current set + int len; + + /// a function pointer that can be used to access entries through a recipe + fetch_Entry_recipe_fn* recipe_fn; + + /// properties used by all entries accessed through a recipe + /// + /// In more detail, an entry returned by `recipe_fn` has its `props` member + /// overwritten by this value + EntryProps common_props; +}; + /** @}*/ // end of group } // namespace grackle::impl::ratequery From 7baec78f8c15f0d6b82c349d135605765dd10d8d Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sat, 20 Dec 2025 15:24:47 -0500 Subject: [PATCH 133/175] use RegistryBuilder within RegistryConstructor --- src/clib/ratequery.cpp | 48 ++++++++++++------------------------------ 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/src/clib/ratequery.cpp b/src/clib/ratequery.cpp index 3908f9225..0444e0f37 100644 --- a/src/clib/ratequery.cpp +++ b/src/clib/ratequery.cpp @@ -230,42 +230,22 @@ grackle::impl::ratequery::RegBuilder_consume_and_build(RegBuilder* ptr) { grackle::impl::ratequery::Registry grackle::impl::ratequery::new_Registry( const chemistry_data& my_chemistry) { - if (my_chemistry.primordial_chemistry == 0) { - return Registry{0, 0, nullptr, nullptr}; - } - // step 1: define several common EntryProps - EntryProps props_LogTLinInterp = mk_invalid_EntryProps(); - props_LogTLinInterp.ndim = 1; - props_LogTLinInterp.shape[0] = my_chemistry.NumberOfTemperatureBins; - - // maybe k13dd should be considered multi-dimensional? - EntryProps props_k13dd = mk_invalid_EntryProps(); - props_k13dd.ndim = 1; - props_k13dd.shape[0] = my_chemistry.NumberOfTemperatureBins * 14; - - EntryProps props_scalar = mk_invalid_EntryProps(); - props_scalar.ndim = 0; - - // step 2: define standard entry recipies - const EntrySet standard_recipies[] = { - {CollisionalRxnLUT::NUM_ENTRIES, &get_CollisionalRxn_Entry, - props_LogTLinInterp}, - {1, &get_k13dd_Entry, props_k13dd}, - {MiscRxn_NRATES, &get_MiscRxn_Entry, props_scalar}}; - - int n_sets = static_cast(sizeof(standard_recipies) / sizeof(EntrySet)); - - // step 3: actually set up Registry - EntrySet* sets = new EntrySet[n_sets]; - int* id_offsets = new int[n_sets]; - int tot_entry_count = 0; - for (int i = 0; i < n_sets; i++) { - id_offsets[i] = tot_entry_count; - sets[i] = standard_recipies[i]; - tot_entry_count += standard_recipies[i].len; + RegBuilder reg_builder = new_RegBuilder(); + if (my_chemistry.primordial_chemistry != 0) { + RegBuilder_recipe_1d(®_builder, CollisionalRxnLUT::NUM_ENTRIES, + &get_CollisionalRxn_Entry, + my_chemistry.NumberOfTemperatureBins); + + // maybe k13dd should be considered multi-dimensional? + RegBuilder_recipe_1d(®_builder, 1, &get_k13dd_Entry, + my_chemistry.NumberOfTemperatureBins * 14); + + RegBuilder_recipe_scalar(®_builder, MiscRxn_NRATES, &get_MiscRxn_Entry); } - return Registry{tot_entry_count, n_sets, id_offsets, sets}; + Registry out = RegBuilder_consume_and_build(®_builder); + drop_RegBuilder(®_builder); + return out; } void grackle::impl::ratequery::drop_Registry( From c5a7231cbe1e0509f5eec801970ed8d6e262b95e Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sat, 20 Dec 2025 16:30:56 -0500 Subject: [PATCH 134/175] Remove new_Registry --- src/clib/initialize_chemistry_data.cpp | 29 +++++++++++++++--- src/clib/ratequery.cpp | 41 ++++++++++++-------------- src/clib/ratequery.hpp | 13 ++++++-- 3 files changed, 54 insertions(+), 29 deletions(-) diff --git a/src/clib/initialize_chemistry_data.cpp b/src/clib/initialize_chemistry_data.cpp index 95900c440..ec3eb2674 100644 --- a/src/clib/initialize_chemistry_data.cpp +++ b/src/clib/initialize_chemistry_data.cpp @@ -230,9 +230,15 @@ static void initialize_empty_chemistry_data_storage_struct(chemistry_data_storag my_rates->opaque_storage = NULL; } -extern "C" int local_initialize_chemistry_data(chemistry_data *my_chemistry, - chemistry_data_storage *my_rates, - code_units *my_units) +/// core logic of local_initialize_chemistry_data_ +/// +/// @note +/// This has been separated from local_initialize_chemistry_data to ensure that +/// any memory allocations tracked by reg_builder can be appropriately freed +/// (this is somewhat unavoidable in C++ without destructors) +static int local_initialize_chemistry_data_( + chemistry_data *my_chemistry, chemistry_data_storage *my_rates, + code_units *my_units, grackle::impl::ratequery::RegBuilder* reg_builder) { /* Better safe than sorry: Initialize everything to NULL/0 */ @@ -459,8 +465,9 @@ extern "C" int local_initialize_chemistry_data(chemistry_data *my_chemistry, my_rates->initial_units = *my_units; // initialize the registry + grackle::impl::ratequery::RegBuilder_misc_recipies(reg_builder, my_chemistry); my_rates->opaque_storage->registry = new grackle::impl::ratequery::Registry( - grackle::impl::ratequery::new_Registry(*my_chemistry) + grackle::impl::ratequery::RegBuilder_consume_and_build(reg_builder) ); if (grackle_verbose) { @@ -510,6 +517,20 @@ extern "C" int local_initialize_chemistry_data(chemistry_data *my_chemistry, return GR_SUCCESS; } + +extern "C" int local_initialize_chemistry_data(chemistry_data *my_chemistry, + chemistry_data_storage *my_rates, + code_units *my_units) +{ + namespace rate_q = grackle::impl::ratequery; + rate_q::RegBuilder reg_builder = rate_q::new_RegBuilder(); + + int out = local_initialize_chemistry_data_(my_chemistry, my_rates, my_units, + ®_builder); + rate_q::drop_RegBuilder(®_builder); + return out; +} + extern "C" int initialize_chemistry_data(code_units *my_units) { if (local_initialize_chemistry_data(grackle_data, &grackle_rates, diff --git a/src/clib/ratequery.cpp b/src/clib/ratequery.cpp index 0444e0f37..e8df8fbd7 100644 --- a/src/clib/ratequery.cpp +++ b/src/clib/ratequery.cpp @@ -41,7 +41,6 @@ // namespace grackle::impl::ratequery { - // we have reserved the right to change this value at any time enum { UNDEFINED_RATE_ID_ = 0 }; @@ -127,7 +126,7 @@ static Entry get_MiscRxn_Entry(chemistry_data_storage* my_rates, int i) { return MKENTRY_SCALAR_(my_rates, k25); case MiscRxn_k26: return MKENTRY_SCALAR_(my_rates, k26); - // Radiative rates for 9-species + // Radiative rates for 9-species case MiscRxn_k27: return MKENTRY_SCALAR_(my_rates, k27); case MiscRxn_k28: @@ -143,6 +142,24 @@ static Entry get_MiscRxn_Entry(chemistry_data_storage* my_rates, int i) { } } } +} // namespace grackle::impl::ratequery + +void grackle::impl::ratequery::RegBuilder_misc_recipies( + RegBuilder* ptr, const chemistry_data* my_chemistry) { + if (my_chemistry->primordial_chemistry != 0) { + RegBuilder_recipe_1d(ptr, CollisionalRxnLUT::NUM_ENTRIES, + &get_CollisionalRxn_Entry, + my_chemistry->NumberOfTemperatureBins); + + // maybe k13dd should be considered multi-dimensional? + RegBuilder_recipe_1d(ptr, 1, &get_k13dd_Entry, + my_chemistry->NumberOfTemperatureBins * 14); + + RegBuilder_recipe_scalar(ptr, MiscRxn_NRATES, &get_MiscRxn_Entry); + } +} + +namespace grackle::impl::ratequery { /// resets the instance to the initial (empty) state. /// @@ -228,26 +245,6 @@ grackle::impl::ratequery::RegBuilder_consume_and_build(RegBuilder* ptr) { } } -grackle::impl::ratequery::Registry grackle::impl::ratequery::new_Registry( - const chemistry_data& my_chemistry) { - RegBuilder reg_builder = new_RegBuilder(); - if (my_chemistry.primordial_chemistry != 0) { - RegBuilder_recipe_1d(®_builder, CollisionalRxnLUT::NUM_ENTRIES, - &get_CollisionalRxn_Entry, - my_chemistry.NumberOfTemperatureBins); - - // maybe k13dd should be considered multi-dimensional? - RegBuilder_recipe_1d(®_builder, 1, &get_k13dd_Entry, - my_chemistry.NumberOfTemperatureBins * 14); - - RegBuilder_recipe_scalar(®_builder, MiscRxn_NRATES, &get_MiscRxn_Entry); - } - - Registry out = RegBuilder_consume_and_build(®_builder); - drop_RegBuilder(®_builder); - return out; -} - void grackle::impl::ratequery::drop_Registry( grackle::impl::ratequery::Registry* ptr) { if (ptr->sets != nullptr) { diff --git a/src/clib/ratequery.hpp b/src/clib/ratequery.hpp index 2c264839b..ce3150646 100644 --- a/src/clib/ratequery.hpp +++ b/src/clib/ratequery.hpp @@ -101,6 +101,8 @@ typedef Entry fetch_Entry_recipe_fn(chemistry_data_storage*, int); struct EntrySet; /// Describes a registry of queryable entries +/// +/// @note This is constructed from a RegBuilder struct Registry { /// number of entries int n_entries; @@ -112,9 +114,6 @@ struct Registry { EntrySet* sets; }; -/// construct a new registry -Registry new_Registry(const chemistry_data&); - /// deallocate the contents of a registry void drop_Registry(Registry* ptr); @@ -182,6 +181,14 @@ int RegBuilder_recipe_scalar(RegBuilder* ptr, int n_entries, int RegBuilder_recipe_1d(RegBuilder* ptr, int n_entries, fetch_Entry_recipe_fn* recipe_fn, int common_len); +/// registers miscellaneous recipes +/// +/// @note +/// This is a hack until we can figure out a better spot to put definitions of +/// some miscellaneous rates +void RegBuilder_misc_recipies(RegBuilder* ptr, + const chemistry_data* my_chemistry); + /// build a new Registry. /// /// In the process, the current Registry is consumed; it's effectively reset to From de89e2b56692e92e02eec733784955e1ed89d5d3 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sat, 20 Dec 2025 20:16:21 -0500 Subject: [PATCH 135/175] relocate and simplify get_CollisionalRxn_Entry --- src/clib/initialize_chemistry_data.cpp | 3 +- src/clib/initialize_rates.cpp | 59 +++++++++++++++++++++++++- src/clib/initialize_rates.hpp | 4 +- src/clib/ratequery.cpp | 49 ++------------------- src/clib/ratequery.hpp | 1 - 5 files changed, 66 insertions(+), 50 deletions(-) diff --git a/src/clib/initialize_chemistry_data.cpp b/src/clib/initialize_chemistry_data.cpp index ec3eb2674..f19669228 100644 --- a/src/clib/initialize_chemistry_data.cpp +++ b/src/clib/initialize_chemistry_data.cpp @@ -426,7 +426,8 @@ static int local_initialize_chemistry_data_( // Compute rate tables. if (grackle::impl::initialize_rates(my_chemistry, my_rates, my_units, - co_length_units, co_density_units) + co_length_units, co_density_units, + reg_builder) != GR_SUCCESS) { fprintf(stderr, "Error in initialize_rates.\n"); return GR_FAIL; diff --git a/src/clib/initialize_rates.cpp b/src/clib/initialize_rates.cpp index 18909b011..d33b13ee6 100644 --- a/src/clib/initialize_rates.cpp +++ b/src/clib/initialize_rates.cpp @@ -385,12 +385,60 @@ int init_kcol_rate_tables( return GR_SUCCESS; } + +/// a function that encodes the algorithm for looking up the `i`th pointer +/// collisional reaction rate from an instance of `chemistry_data_storage`. +/// +/// This is intended to be registered with RegBuilder in order to provide +/// access to the various collisional reaction rates. +/// +/// @param my_rates The object from which the rate Entry is loaded +/// @param i the index of the queried rate +grackle::impl::ratequery::Entry get_CollisionalRxn_Entry + (chemistry_data_storage* my_rates, int i) { + // sanity check! (this shouldn't actually happen) + if ((my_rates == nullptr) || (my_rates->opaque_storage == nullptr) || + (my_rates->opaque_storage->kcol_rate_tables == nullptr)) { + return grackle::impl::ratequery::mk_invalid_Entry(); + } + + // import new_Entry into the current scope (so we don't need the full name) + using ::grackle::impl::ratequery::new_Entry; + + double** data = my_rates->opaque_storage->kcol_rate_tables->data; + + // this implementation leverages the following properties of the + // CollisionalRxnLUT enum: + // - each entry of collisional_rxn_rate_members.def has a corresponding + // enumeration-constant + // - the very first enumeration constant has a value of 0 (since a value + // wasn't explicitly specified) + // - the value of each other enumeration constants is 1 larger than the value + // of the previous value (if a value isn't explicitly specified) + // - CollisionalRxnLUT::NUM_ENTRIES specifies the number of other enumeration + // constants (excluding CollisionalRxnLUT::NUM_ENTRIES) in the enum + switch (i) { +#define TO_STR(s) #s +#define ENTRY(NAME) \ + case CollisionalRxnLUT::NAME: { return new_Entry(data[i], TO_STR(NAME)); } +#include "collisional_rxn_rate_members.def" + +#undef ENTRY +#undef TO_STR + default: { + return grackle::impl::ratequery::mk_invalid_Entry(); + } + } +} + + } // anonymous namespace //Definition of the initialise_rates function. int grackle::impl::initialize_rates( chemistry_data *my_chemistry, chemistry_data_storage *my_rates, - code_units *my_units, double co_length_unit, double co_density_unit) + code_units *my_units, double co_length_unit, double co_density_unit, + ratequery::RegBuilder* reg_builder) { // TODO: we REALLY need to do an error check that // my_chemistry->NumberOfTemperatureBins >= 2 @@ -493,6 +541,15 @@ int grackle::impl::initialize_rates( return GR_FAIL; } + // register the recipe for looking up the "standard" collisional rates + if (grackle::impl::ratequery::RegBuilder_recipe_1d( + reg_builder, CollisionalRxnLUT::NUM_ENTRIES, + &get_CollisionalRxn_Entry, my_chemistry->NumberOfTemperatureBins + ) != GR_SUCCESS) { + return GrPrintAndReturnErr("error registering standard collisional " + "reaction rates"); + } + //--------Calculate coefficients for density-dependent collisional H2 dissociation rate-------- // // idt = 0 calculates coefficients for direct collisional dissociation idt = 1 diff --git a/src/clib/initialize_rates.hpp b/src/clib/initialize_rates.hpp index 0a004895c..99e2e9b21 100644 --- a/src/clib/initialize_rates.hpp +++ b/src/clib/initialize_rates.hpp @@ -14,12 +14,14 @@ #define INITIALIZE_RATES_HPP #include "grackle.h" +#include "ratequery.hpp" namespace grackle::impl { int initialize_rates(chemistry_data* my_chemistry, chemistry_data_storage* my_rates, code_units* my_units, - double co_length_unit, double co_density_unit); + double co_length_unit, double co_density_unit, + ratequery::RegBuilder* reg_builder); } // namespace grackle::impl diff --git a/src/clib/ratequery.cpp b/src/clib/ratequery.cpp index e8df8fbd7..433867c92 100644 --- a/src/clib/ratequery.cpp +++ b/src/clib/ratequery.cpp @@ -46,51 +46,10 @@ enum { UNDEFINED_RATE_ID_ = 0 }; // introduce some basic machinery to help us implement dynamic lookup of rates -static Entry new_Entry_standard_kcol_(chemistry_data_storage* my_rates, - const char* name, int index) { - if ((my_rates == nullptr) || (my_rates->opaque_storage == nullptr) || - (my_rates->opaque_storage->kcol_rate_tables == nullptr)) { - return new_Entry(nullptr, name); - } else { - return new_Entry(my_rates->opaque_storage->kcol_rate_tables->data[index], - name); - } -} - #define MKENTRY_(PTR, NAME, FAMILY) \ new_Entry(((PTR) == nullptr) ? nullptr : (PTR)->NAME, #NAME, FAMILY) #define MKENTRY_SCALAR_(PTR, NAME) \ new_Entry(((PTR) == nullptr) ? nullptr : &((PTR)->NAME), #NAME) -#define MKENTRY_STANDARD_KCOL_(PTR, NAME, INDEX) \ - new_Entry_standard_kcol_(PTR, #NAME, INDEX) - -// Create machinery to lookup Standard-Form Collisional Reaction Rates -// ------------------------------------------------------------------- -// see the next section for other macros - -// this fn leverages the following properties of the CollisionalRxnLUT enum: -// - each entry of collisional_rxn_rate_members.def has a corresponding -// enumeration-constant -// - the very first enumeration constant has a value of 0 (since a value wasn't -// explicitly specified) -// - the value of each other enumeration constants is 1 larger than the value -// of the previous value (if a value isn't explicitly specified) -// - CollisionalRxnLUT::NUM_ENTRIES specifies the number of other enumeration -// constants (excluding CollisionalRxnLUT::NUM_ENTRIES) in the enum -static Entry get_CollisionalRxn_Entry(chemistry_data_storage* my_rates, int i) { - switch (i) { -#define ENTRY(NAME) \ - case CollisionalRxnLUT::NAME: { \ - return MKENTRY_STANDARD_KCOL_(my_rates, NAME, CollisionalRxnLUT::NAME); \ - } -#include "collisional_rxn_rate_members.def" - -#undef ENTRY - default: { - return mk_invalid_Entry(); - } - } -} static Entry get_k13dd_Entry(chemistry_data_storage* my_rates, int i) { if (i == 0) { @@ -147,10 +106,6 @@ static Entry get_MiscRxn_Entry(chemistry_data_storage* my_rates, int i) { void grackle::impl::ratequery::RegBuilder_misc_recipies( RegBuilder* ptr, const chemistry_data* my_chemistry) { if (my_chemistry->primordial_chemistry != 0) { - RegBuilder_recipe_1d(ptr, CollisionalRxnLUT::NUM_ENTRIES, - &get_CollisionalRxn_Entry, - my_chemistry->NumberOfTemperatureBins); - // maybe k13dd should be considered multi-dimensional? RegBuilder_recipe_1d(ptr, 1, &get_k13dd_Entry, my_chemistry->NumberOfTemperatureBins * 14); @@ -347,7 +302,9 @@ extern "C" grunstable_rateid_type grunstable_ratequery_id( const rate_q::EntrySet set = registry->sets[set_idx]; int set_len = set.len; for (int i = 0; i < set_len; i++) { - rate_q::Entry entry = set.recipe_fn(nullptr, i); + // short-term hack! (it's bad practice to "cast away the const") + rate_q::Entry entry = + set.recipe_fn(const_cast(my_rates), i); if (std::strcmp(name, entry.name) == 0) { return registry->id_offsets[set_idx] + i; } diff --git a/src/clib/ratequery.hpp b/src/clib/ratequery.hpp index ce3150646..0397405c9 100644 --- a/src/clib/ratequery.hpp +++ b/src/clib/ratequery.hpp @@ -163,7 +163,6 @@ void drop_RegBuilder(RegBuilder* ptr); /// @param[inout] ptr The RegBuilder that will be updated /// @param[in] n_entries The number of entries accessible through the recipe /// @param[in] recipe_fn The recipe being registered -/// @param[in] common_props The properties shared by each Entry in the recipe /// /// @returns GR_SUCCESS if successful, otherwise returns a different value int RegBuilder_recipe_scalar(RegBuilder* ptr, int n_entries, From ef5b1be6f7c30cf1c8c925362d540d1f8a33478a Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sat, 20 Dec 2025 20:36:21 -0500 Subject: [PATCH 136/175] assorted cleanup --- src/clib/initialize_chemistry_data.cpp | 7 +++- src/clib/initialize_rates.cpp | 27 +++++++++++++++ src/clib/ratequery.cpp | 46 +++++++++----------------- src/clib/ratequery.hpp | 4 +-- 4 files changed, 51 insertions(+), 33 deletions(-) diff --git a/src/clib/initialize_chemistry_data.cpp b/src/clib/initialize_chemistry_data.cpp index f19669228..0a196abe2 100644 --- a/src/clib/initialize_chemistry_data.cpp +++ b/src/clib/initialize_chemistry_data.cpp @@ -29,6 +29,7 @@ #include "opaque_storage.hpp" // gr_opaque_storage #include "phys_constants.h" #include "ratequery.hpp" +#include "status_reporting.h" #ifdef _OPENMP #include @@ -466,7 +467,11 @@ static int local_initialize_chemistry_data_( my_rates->initial_units = *my_units; // initialize the registry - grackle::impl::ratequery::RegBuilder_misc_recipies(reg_builder, my_chemistry); + if (grackle::impl::ratequery::RegBuilder_misc_recipies(reg_builder, + my_chemistry) + != GR_SUCCESS){ + return GrPrintAndReturnErr("error in RegBuilder_misc_recipies"); + } my_rates->opaque_storage->registry = new grackle::impl::ratequery::Registry( grackle::impl::ratequery::RegBuilder_consume_and_build(reg_builder) ); diff --git a/src/clib/initialize_rates.cpp b/src/clib/initialize_rates.cpp index d33b13ee6..a5198b5d4 100644 --- a/src/clib/initialize_rates.cpp +++ b/src/clib/initialize_rates.cpp @@ -432,6 +432,25 @@ grackle::impl::ratequery::Entry get_CollisionalRxn_Entry } +/// a function that encodes the algorithm for looking up the k13dd +/// collisional reaction rate from an instance of `chemistry_data_storage`. +/// +/// This is intended to be registered with RegBuilder in order to provide +/// access to the various collisional reaction rates. +/// +/// @param my_rates The object from which the rate Entry is loaded +/// @param i the index of the queried rate +grackle::impl::ratequery::Entry get_k13dd_Entry( + chemistry_data_storage* my_rates, int i) { + if (i == 0) { + double* ptr = (my_rates == nullptr) ? nullptr : my_rates->k13dd; + return grackle::impl::ratequery::new_Entry(ptr, "k13dd"); + } else { + return grackle::impl::ratequery::mk_invalid_Entry(); + } +} + + } // anonymous namespace //Definition of the initialise_rates function. @@ -565,6 +584,14 @@ int grackle::impl::initialize_rates( // coeff7(idt=0, TbinFinal), coeff1(idt=1, Tbin1), ..., coeff7(idt=1, TbinFinal)} add_k13dd_reaction_rate(&my_rates->k13dd, kUnit, my_chemistry); + // maybe k13dd should be considered multi-dimensional? + if (grackle::impl::ratequery::RegBuilder_recipe_1d( + reg_builder, 1, &get_k13dd_Entry, + my_chemistry->NumberOfTemperatureBins * 14) != GR_SUCCESS) { + return GrPrintAndReturnErr("error registering k13dd rate"); + } + + //H2 formation on dust grains requires loop over the dust temperature. add_h2dust_reaction_rate(&my_rates->h2dust, kUnit, my_chemistry); diff --git a/src/clib/ratequery.cpp b/src/clib/ratequery.cpp index 433867c92..73a02a3d9 100644 --- a/src/clib/ratequery.cpp +++ b/src/clib/ratequery.cpp @@ -44,24 +44,10 @@ namespace grackle::impl::ratequery { // we have reserved the right to change this value at any time enum { UNDEFINED_RATE_ID_ = 0 }; -// introduce some basic machinery to help us implement dynamic lookup of rates - -#define MKENTRY_(PTR, NAME, FAMILY) \ - new_Entry(((PTR) == nullptr) ? nullptr : (PTR)->NAME, #NAME, FAMILY) -#define MKENTRY_SCALAR_(PTR, NAME) \ - new_Entry(((PTR) == nullptr) ? nullptr : &((PTR)->NAME), #NAME) - -static Entry get_k13dd_Entry(chemistry_data_storage* my_rates, int i) { - if (i == 0) { - double* ptr = (my_rates == nullptr) ? nullptr : my_rates->k13dd; - return new_Entry(ptr, "k13dd"); - } else { - return mk_invalid_Entry(); - } -} - // Create machinery to lookup Other Miscellaneous Rates // ---------------------------------------------------- +// -> ideally this should get relocated to a more sensible location (but not +// sure where that is... enum MiscRxnRateKind_ { MiscRxn_k24, @@ -77,25 +63,28 @@ enum MiscRxnRateKind_ { }; static Entry get_MiscRxn_Entry(chemistry_data_storage* my_rates, int i) { + if (my_rates == nullptr) { // <- shouldn't come up + return mk_invalid_Entry(); + } switch (i) { // Radiative rates for 6-species (for external field): case MiscRxn_k24: - return MKENTRY_SCALAR_(my_rates, k24); + return new_Entry(&my_rates->k24, "k24"); case MiscRxn_k25: - return MKENTRY_SCALAR_(my_rates, k25); + return new_Entry(&my_rates->k25, "k25"); case MiscRxn_k26: - return MKENTRY_SCALAR_(my_rates, k26); + return new_Entry(&my_rates->k26, "k26"); // Radiative rates for 9-species case MiscRxn_k27: - return MKENTRY_SCALAR_(my_rates, k27); + return new_Entry(&my_rates->k27, "k27"); case MiscRxn_k28: - return MKENTRY_SCALAR_(my_rates, k28); + return new_Entry(&my_rates->k28, "k28"); case MiscRxn_k29: - return MKENTRY_SCALAR_(my_rates, k29); + return new_Entry(&my_rates->k29, "k29"); case MiscRxn_k30: - return MKENTRY_SCALAR_(my_rates, k30); + return new_Entry(&my_rates->k30, "k30"); case MiscRxn_k31: - return MKENTRY_SCALAR_(my_rates, k31); + return new_Entry(&my_rates->k31, "k31"); default: { return mk_invalid_Entry(); } @@ -103,15 +92,12 @@ static Entry get_MiscRxn_Entry(chemistry_data_storage* my_rates, int i) { } } // namespace grackle::impl::ratequery -void grackle::impl::ratequery::RegBuilder_misc_recipies( +int grackle::impl::ratequery::RegBuilder_misc_recipies( RegBuilder* ptr, const chemistry_data* my_chemistry) { if (my_chemistry->primordial_chemistry != 0) { - // maybe k13dd should be considered multi-dimensional? - RegBuilder_recipe_1d(ptr, 1, &get_k13dd_Entry, - my_chemistry->NumberOfTemperatureBins * 14); - - RegBuilder_recipe_scalar(ptr, MiscRxn_NRATES, &get_MiscRxn_Entry); + return RegBuilder_recipe_scalar(ptr, MiscRxn_NRATES, &get_MiscRxn_Entry); } + return GR_SUCCESS; } namespace grackle::impl::ratequery { diff --git a/src/clib/ratequery.hpp b/src/clib/ratequery.hpp index 0397405c9..a5f3d7f55 100644 --- a/src/clib/ratequery.hpp +++ b/src/clib/ratequery.hpp @@ -185,8 +185,8 @@ int RegBuilder_recipe_1d(RegBuilder* ptr, int n_entries, /// @note /// This is a hack until we can figure out a better spot to put definitions of /// some miscellaneous rates -void RegBuilder_misc_recipies(RegBuilder* ptr, - const chemistry_data* my_chemistry); +int RegBuilder_misc_recipies(RegBuilder* ptr, + const chemistry_data* my_chemistry); /// build a new Registry. /// From a2665b21c0bc8f357ffb4fadaf84827acb841dea Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sun, 28 Dec 2025 13:39:32 -0500 Subject: [PATCH 137/175] address a typo in a docstring --- src/clib/ratequery.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clib/ratequery.hpp b/src/clib/ratequery.hpp index a5f3d7f55..972102203 100644 --- a/src/clib/ratequery.hpp +++ b/src/clib/ratequery.hpp @@ -54,7 +54,7 @@ namespace grackle::impl::ratequery { /// initialization, we could consider making construction of the registry (or /// non-essential registry-entries) a runtime parameter. /// -/// ASIDE: The current design is very much prioritizes doing something easy +/// ASIDE: The current design very much prioritizes doing something easy /// over runtime performance. /** @{ */ From 25da6bae20f0d55b8d0f043396b5f8ecf6302820 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sat, 13 Dec 2025 15:38:55 -0500 Subject: [PATCH 138/175] introduce PtrUnion --- src/clib/ratequery.cpp | 34 +++++++++-- src/clib/ratequery.hpp | 133 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 159 insertions(+), 8 deletions(-) diff --git a/src/clib/ratequery.cpp b/src/clib/ratequery.cpp index 73a02a3d9..70d9d266d 100644 --- a/src/clib/ratequery.cpp +++ b/src/clib/ratequery.cpp @@ -215,6 +215,11 @@ static const Registry* get_registry(const chemistry_data_storage* my_rates) { } /// internal function to search for the rate description i +/// +/// @note +/// While it would be nice to enforce that rate data in a +/// `const chemistry_data_storage` can't be mutated, that is something that +/// should be done at the public API level. static ratequery_rslt_ query_Entry(chemistry_data_storage* my_rates, long long i) { const Registry* registry = get_registry(my_rates); @@ -305,13 +310,25 @@ extern "C" int grunstable_ratequery_get_f64(chemistry_data_storage* my_rates, namespace rate_q = grackle::impl::ratequery; rate_q::Entry entry = rate_q::query_Entry(my_rates, rate_id).entry; - if (entry.data == nullptr) { // in this case, the query failed + if (entry.data.is_null()) { // in this case, the query failed return GR_FAIL; } + const double* src; + switch (entry.data.tag()) { + case rate_q::PtrKind::const_f64: + src = entry.data.const_f64(); + break; + case rate_q::PtrKind::mutable_f64: + src = const_cast(entry.data.mutable_f64()); + break; + default: + return GR_FAIL; + } + long long n_items = rate_q::get_n_items(entry.props); for (long long i = 0; i < n_items; i++) { - buf[i] = entry.data[i]; + buf[i] = src[i]; } return GR_SUCCESS; } @@ -321,15 +338,20 @@ extern "C" int grunstable_ratequery_set_f64(chemistry_data_storage* my_rates, const double* buf) { namespace rate_q = grackle::impl::ratequery; rate_q::Entry entry = rate_q::query_Entry(my_rates, rate_id).entry; - if (entry.data == nullptr) { // in this case, the query failed + if (entry.data.is_null()) { // in this case, the query failed return GR_FAIL; } long long n_items = rate_q::get_n_items(entry.props); - for (long long i = 0; i < n_items; i++) { - entry.data[i] = buf[i]; + if (entry.data.tag() == rate_q::PtrKind::mutable_f64) { + double* dst = entry.data.mutable_f64(); + for (long long i = 0; i < n_items; i++) { + dst[i] = buf[i]; + } + return GR_SUCCESS; + } else { // the retrieved pointer is either immutable or the wrong type + return GR_FAIL; } - return GR_SUCCESS; } extern "C" int grunstable_ratequery_prop( diff --git a/src/clib/ratequery.hpp b/src/clib/ratequery.hpp index 972102203..19a191389 100644 --- a/src/clib/ratequery.hpp +++ b/src/clib/ratequery.hpp @@ -13,6 +13,8 @@ #define RATEQUERY_HPP #include "grackle.h" +#include "utils-cpp.hpp" // GRIMPL_FORCE_INLINE +#include "status_reporting.h" namespace grackle::impl::ratequery { @@ -58,6 +60,133 @@ namespace grackle::impl::ratequery { /// over runtime performance. /** @{ */ +enum struct PtrKind { + const_f64, + mutable_f64, + const_str, + // there's no circumstance where we ever want mutable_str +}; + +/// Represents a pointer union +/// +/// We use a class here because it's extremely easy to introduce undefined +/// behavior when interacting with a union. +/// - it's even easier to get undefined behavior in C++ than in C. In C, you +/// are allowed to access an inactive union member (but that's undefined in +/// C++) +/// +/// The compromise between safety and writing Grackle in a C-like subset of C++ +/// is to basically write a class with getters and setters that is equivalent +/// to the following C struct +/// ```C +/// struct PtrUnion{ +/// union { +/// const double* const_f64; +/// double* mutable_f64; +/// // ... +/// const char * const * const_str; +/// } pointer; +/// +/// enum PtrKind tag; +/// }; +/// ``` +/// The only difference is that this class enforces runtime-checks that will +/// crash the program if a mistake is made (rather than trigger undefined +/// behavior). In practice, if the union is used properly, most runtime checks +/// should get optimized out. +class PtrUnion { + // if we ever wanted to include something other than a pointer or fundamental + // type, then we almost certainly use std::variant rather than a union + union Storage { + const double* const_f64; + double* mutable_f64; + const char* const* const_str; + // there's no scenario where we *EVER* want a reason mutable_str + }; + + // define the data-members (we specify values for the default constructor) + + /// the actual union + Storage pointer = {nullptr}; // <- intializes the first member + /// the tag (that tracks the kind of pointer) + PtrKind tag_ = PtrKind::const_f64; + +public: + // explicitly declare the use of default constructor/assignment/destructor + PtrUnion() = default; + PtrUnion(const PtrUnion&) = default; + PtrUnion(PtrUnion&&) = default; + PtrUnion& operator=(const PtrUnion&) = default; + PtrUnion& operator=(PtrUnion&&) = default; + ~PtrUnion() = default; + + // introduce 2 convenienece methods related to nullptr + + /// constructor to use when is the `nullptr` literal is used + PtrUnion(std::nullptr_t) : PtrUnion() {} + + /// Convenience method to check whether the instance holds a nullptr + /// + /// @note + /// An argument could be made for converting this to a standalone function + /// so that things are more C-like + bool is_null() const { + // maybe we turn on errors for non-exhaustive switch statements with + // a pragma? + switch (this->tag_) { + case PtrKind::const_f64: + return pointer.const_f64 == nullptr; + case PtrKind::mutable_f64: + return pointer.mutable_f64 == nullptr; + case PtrKind::const_str: + return pointer.const_str == nullptr; + } + GR_INTERNAL_UNREACHABLE_ERROR(); + } + + /// access the tag attribute + PtrKind tag() const { return this->tag_; } + + // methods associated with const_f64 + explicit PtrUnion(const double* ptr) { this->set_const_f64(ptr); } + + GRIMPL_FORCE_INLINE const double* const_f64() const { + GR_INTERNAL_REQUIRE(this->tag_ == PtrKind::const_f64, "has wrong tag"); + return this->pointer.const_f64; + } + + GRIMPL_FORCE_INLINE void set_const_f64(const double* ptr) { + this->tag_ = PtrKind::const_f64; + this->pointer.const_f64 = ptr; + } + + // methods associated with mutable_f64 + explicit PtrUnion(double* ptr) { this->set_mutable_f64(ptr); } + + GRIMPL_FORCE_INLINE double* mutable_f64() const { + GR_INTERNAL_REQUIRE(this->tag_ == PtrKind::mutable_f64, "has wrong tag"); + return this->pointer.mutable_f64; + } + + GRIMPL_FORCE_INLINE void set_mutable_f64(double* ptr) { + this->tag_ = PtrKind::mutable_f64; + this->pointer.mutable_f64 = ptr; + } + + // methods associated with const_str + explicit PtrUnion(const char* const* ptr) { this->set_const_str(ptr); } + + GRIMPL_FORCE_INLINE const char* const* const_str() const { + GR_INTERNAL_REQUIRE(this->tag_ == PtrKind::const_str, "has wrong tag"); + return this->pointer.const_str; + } + + GRIMPL_FORCE_INLINE void set_const_str(const char* const* ptr) { + this->tag_ = PtrKind::const_str; + this->pointer.const_str = ptr; + } +}; + /// Describes properties about the data in an entry struct EntryProps { int ndim; @@ -74,7 +203,7 @@ inline bool EntryProps_is_valid(EntryProps obj) { return obj.ndim >= 0; } /// A queryable entity struct Entry { - double* data; + PtrUnion data; const char* name; EntryProps props; }; @@ -85,7 +214,7 @@ inline Entry mk_invalid_Entry() { /// Constructs an Entry inline Entry new_Entry(double* rate, const char* name) { - return Entry{rate, name, mk_invalid_EntryProps()}; + return Entry{PtrUnion(rate), name, mk_invalid_EntryProps()}; } /// a recipe for querying 1 or more entries from a chemistry_data_storage From 3f8ef14c172a7b725ad8cf721b227d7236bf554d Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Tue, 16 Dec 2025 11:30:41 -0500 Subject: [PATCH 139/175] recombine RecipeInfo and EntrySet and flesh out the role of EntrySet --- src/clib/ratequery.cpp | 118 ++++++++++++++++++++++++++++++++++------- src/clib/ratequery.hpp | 40 +++++++++++++- 2 files changed, 138 insertions(+), 20 deletions(-) diff --git a/src/clib/ratequery.cpp b/src/clib/ratequery.cpp index 70d9d266d..ec3b7f25e 100644 --- a/src/clib/ratequery.cpp +++ b/src/clib/ratequery.cpp @@ -102,6 +102,67 @@ int grackle::impl::ratequery::RegBuilder_misc_recipies( namespace grackle::impl::ratequery { +/// calls delete or delete[] on the specified pointer (depending on the value +/// of is_scalar). +/// +/// @note +/// This was originally function-like macro. We can go back to that if people +/// dislike this usage of a template function. +/// function-like macro +template +static void careful_delete_(T* ptr, bool is_scalar) { + (is_scalar) ? delete ptr : delete[] ptr; +} + +/// This deallocates data within a list of owned Entries (i.e. all pointers +/// within an Entry are deleted) +/// +/// Importantly, this does **NOT** call delete[] on entry_list +static void drop_owned_Entry_list_contents(Entry* entry_list, int n_entries) { + for (int entry_idx = 0; entry_idx < n_entries; entry_idx++) { + Entry* cur_entry = &entry_list[entry_idx]; + + // invariant: each Entry within an embedded-list should be valid and + // fully initialized + GR_INTERNAL_REQUIRE(cur_entry->name != nullptr, "sanity check!"); + GR_INTERNAL_REQUIRE(!cur_entry->data.is_null(), "sanity check!"); + + delete[] cur_entry->name; + + bool is_scalar = cur_entry->props.ndim == 0; + switch (cur_entry->data.tag()) { + case PtrKind::const_f64: { + careful_delete_(cur_entry->data.const_f64(), is_scalar); + break; + } + case PtrKind::mutable_f64: { + careful_delete_(cur_entry->data.mutable_f64(), is_scalar); + break; + } + case PtrKind::const_str: { + const char* const* ptr = cur_entry->data.const_str(); + + // get the number of strings referenced by cur_entry->data + int n_strings = 1; + for (int i = 0; i < cur_entry->props.ndim; i++) { + n_strings *= cur_entry->props.shape[i]; + } + + // delete each string within ptr + for (int i = 0; i < n_strings; i++) { + delete[] ptr[i]; + } + + // now actually delete ptr + careful_delete_(ptr, is_scalar); + break; + } + default: + GR_INTERNAL_UNREACHABLE_ERROR(); + } + } +} + /// resets the instance to the initial (empty) state. /// /// the skip_dealloc argument will only be true when the data is transferred @@ -131,7 +192,7 @@ static int RegBuilder_recipe_(RegBuilder* ptr, fetch_Entry_recipe_fn* recipe_fn, return GrPrintAndReturnErr("out of capacity"); } - ptr->sets[ptr->len++] = EntrySet{n_entries, recipe_fn, common_props}; + ptr->sets[ptr->len++] = EntrySet{n_entries, nullptr, recipe_fn, common_props}; return GR_SUCCESS; } @@ -141,8 +202,6 @@ void grackle::impl::ratequery::drop_RegBuilder(RegBuilder* ptr) { RegBuilder_reset_to_empty(ptr, false); } -namespace grackle::impl::ratequery {} // namespace grackle::impl::ratequery - int grackle::impl::ratequery::RegBuilder_recipe_scalar( RegBuilder* ptr, int n_entries, fetch_Entry_recipe_fn* recipe_fn) { EntryProps common_props = mk_invalid_EntryProps(); @@ -186,11 +245,41 @@ grackle::impl::ratequery::RegBuilder_consume_and_build(RegBuilder* ptr) { } } +grackle::impl::ratequery::Entry grackle::impl::ratequery::EntrySet_access( + const EntrySet* entry_set, chemistry_data_storage* my_rates, int i) { + if (i > entry_set->len) { + return mk_invalid_Entry(); + } else if (entry_set->embedded_list == nullptr) { // in recipe-mode + Entry out = (entry_set->recipe_fn)(my_rates, i); + out.props = entry_set->common_recipe_props; + return out; + } else { // in embedded-list mode + return entry_set->embedded_list[i]; + } +} + +void grackle::impl::ratequery::drop_EntrySet(EntrySet* ptr) { + if (ptr->embedded_list == nullptr) { + // nothing to deallocate in recipe-mode + } else { + // in embedded-list-mode, we need to deallocate each Entry in the list + // and the deallocate the actual list-pointer + drop_owned_Entry_list_contents(ptr->embedded_list, ptr->len); + + // deallocate the memory associated with embedded_list + delete[] ptr->embedded_list; + ptr->embedded_list = nullptr; + } +} + void grackle::impl::ratequery::drop_Registry( grackle::impl::ratequery::Registry* ptr) { if (ptr->sets != nullptr) { delete[] ptr->id_offsets; ptr->id_offsets = nullptr; + for (int i = 0; i < ptr->n_sets; i++) { + drop_EntrySet(&ptr->sets[i]); + } delete[] ptr->sets; ptr->sets = nullptr; } @@ -229,16 +318,10 @@ static ratequery_rslt_ query_Entry(chemistry_data_storage* my_rates, } for (int set_idx = 0; set_idx < registry->n_sets; set_idx++) { - const struct EntrySet cur_set = registry->sets[set_idx]; - int cur_id_offset = registry->id_offsets[set_idx]; - - const long long tmp = i - static_cast(cur_id_offset); - if ((tmp >= 0) && (tmp < cur_set.len)) { - ratequery_rslt_ out; - out.rate_id = i; - out.entry = cur_set.recipe_fn(my_rates, tmp); - out.entry.props = cur_set.common_props; - return out; + EntrySet* cur_set = ®istry->sets[set_idx]; + int tmp = i - registry->id_offsets[set_idx]; + if ((tmp >= 0) && (tmp < cur_set->len)) { + return ratequery_rslt_{i, EntrySet_access(cur_set, my_rates, tmp)}; } } return invalid_rslt_(); @@ -290,12 +373,11 @@ extern "C" grunstable_rateid_type grunstable_ratequery_id( } for (int set_idx = 0; set_idx < registry->n_sets; set_idx++) { - const rate_q::EntrySet set = registry->sets[set_idx]; - int set_len = set.len; + rate_q::EntrySet* set = ®istry->sets[set_idx]; + int set_len = set->len; for (int i = 0; i < set_len; i++) { - // short-term hack! (it's bad practice to "cast away the const") - rate_q::Entry entry = - set.recipe_fn(const_cast(my_rates), i); + rate_q::Entry entry = rate_q::EntrySet_access( + set, const_cast(my_rates), i); if (std::strcmp(name, entry.name) == 0) { return registry->id_offsets[set_idx] + i; } diff --git a/src/clib/ratequery.hpp b/src/clib/ratequery.hpp index 19a191389..96bfffa62 100644 --- a/src/clib/ratequery.hpp +++ b/src/clib/ratequery.hpp @@ -327,11 +327,30 @@ int RegBuilder_misc_recipies(RegBuilder* ptr, /// For safety, the caller should still plan to call drop_RegBuilder Registry RegBuilder_consume_and_build(RegBuilder* ptr); -/// Describes the set of entries that can be access through a given recipe +/// Describes a set of entries +/// +/// This can operate in 2 modes: +/// 1. Embedded-List-mode: +/// - the EntrySet directly holds a list of Entry instances that **ONLY** +/// exist for querying purposes and should **NEVER** be mutated by +/// external code. +/// - imporantly, the EntrySet is responsible for managing the memory the +/// pointers to string each string and pointer referenced by a pointer in +/// this list. +/// 2. Recipe-mode: +/// - In this case, the EntrySet provides access to Entry instances that +/// directly reference data managed by `chemistry_data_storage` struct EntrySet { /// number of entries in the current set int len; + /// an embedded list of entries, where the allocation are directly owned and + /// managed by this instance. + /// + /// @important + /// this **must** be a nullptr if operating in Recipe-mode + Entry* embedded_list; + /// a function pointer that can be used to access entries through a recipe fetch_Entry_recipe_fn* recipe_fn; @@ -339,9 +358,26 @@ struct EntrySet { /// /// In more detail, an entry returned by `recipe_fn` has its `props` member /// overwritten by this value - EntryProps common_props; + /// + /// @note + /// only used in Recipe-mode + EntryProps common_recipe_props; }; +/// look up an Entry in an EntrySet +/// +/// @param[in] entry_set The container object being queried +/// @param[in] my_rates Used for looking up Entry in recipe-mode +/// @param[in] i The index to query +/// +/// @returns An instance that references memory owned by either my_rates or by +/// the entry_set, itself. +Entry EntrySet_access(const EntrySet* entry_set, + chemistry_data_storage* my_rates, int i); + +/// deallocate the contents of an EntrySet +void drop_EntrySet(EntrySet* ptr); + /** @}*/ // end of group } // namespace grackle::impl::ratequery From 7da7b81d90a52408a75a1de2b390860d2d476220 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sun, 21 Dec 2025 09:30:25 -0500 Subject: [PATCH 140/175] fix an issue with the canonical invalid rateid --- src/clib/ratequery.cpp | 9 ++++++--- tests/unit/test_api_ratequery.cpp | 10 ++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/clib/ratequery.cpp b/src/clib/ratequery.cpp index ec3b7f25e..1035b5a5f 100644 --- a/src/clib/ratequery.cpp +++ b/src/clib/ratequery.cpp @@ -11,7 +11,7 @@ //===----------------------------------------------------------------------===// #include // strcmp -#include // LLONG_MAX +#include #include "grackle.h" #include "internal_types.hpp" // CollisionalRxnRateCollection #include "LUT.hpp" // CollisionalRxnLUT @@ -42,7 +42,9 @@ namespace grackle::impl::ratequery { // we have reserved the right to change this value at any time -enum { UNDEFINED_RATE_ID_ = 0 }; +enum { + UNDEFINED_RATE_ID_ = std::numeric_limits::max() +}; // Create machinery to lookup Other Miscellaneous Rates // ---------------------------------------------------- @@ -477,7 +479,8 @@ extern "C" const char* grunstable_ith_rate( grunstable_rateid_type* out_rate_id) { namespace rate_q = grackle::impl::ratequery; - const long long sanitized_i = (i < LLONG_MAX) ? (long long)i : -1; + const long long sanitized_i = + (i < std::numeric_limits::max()) ? (long long)i : -1; // short-term hack! (it's bad practice to "cast away the const") rate_q::ratequery_rslt_ tmp = rate_q::query_Entry( const_cast(my_rates), sanitized_i); diff --git a/tests/unit/test_api_ratequery.cpp b/tests/unit/test_api_ratequery.cpp index 69c03b336..23d24796b 100644 --- a/tests/unit/test_api_ratequery.cpp +++ b/tests/unit/test_api_ratequery.cpp @@ -134,6 +134,16 @@ TEST_F(SimpleRateQueryTest, PropertyInvalidRateID) { using ParametrizedRateQueryTest = grtest::ParametrizedConfigPresetFixture; +TEST_P(ParametrizedRateQueryTest, InvalidIdCollision) { + grunstable_rateid_type invalid_id = + grunstable_ratequery_id(pack.my_rates(), nullptr); + for (const grtest::NameIdPair pair : grtest::RateQueryRange(pack)) { + EXPECT_NE(invalid_id, pair.id) + << "there is a collision between the canonical invalid id " + << "and the id associated with the \"" << pair.name << "\" rate"; + } +} + TEST_P(ParametrizedRateQueryTest, AllUnique) { std::set name_set; std::set id_set; From f9df7b8df72dbbb2225da383314421367d75f605 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sun, 21 Dec 2025 10:13:23 -0500 Subject: [PATCH 141/175] flesh out additional support for querying strings --- src/clib/ratequery.cpp | 66 ++++++++++++++++++- src/clib/ratequery.hpp | 16 +++++ src/include/grackle.h | 26 +++++++- tests/unit/test_api_ratequery.cpp | 103 ++++++++++++++++++++++++++---- 4 files changed, 193 insertions(+), 18 deletions(-) diff --git a/src/clib/ratequery.cpp b/src/clib/ratequery.cpp index 1035b5a5f..2c3e021d4 100644 --- a/src/clib/ratequery.cpp +++ b/src/clib/ratequery.cpp @@ -10,7 +10,7 @@ /// //===----------------------------------------------------------------------===// -#include // strcmp +#include // std::strcmp, std::strlen, std::strcpy #include #include "grackle.h" #include "internal_types.hpp" // CollisionalRxnRateCollection @@ -19,6 +19,8 @@ #include "ratequery.hpp" #include "status_reporting.h" +#include + // In comparison to the dynamic API for accessing elements of chemistry_data, // we have explicitly opted NOT to make use of offsetof to access arbitrary // values within a struct. @@ -438,6 +440,27 @@ extern "C" int grunstable_ratequery_set_f64(chemistry_data_storage* my_rates, } } +extern "C" int grunstable_ratequery_get_str(chemistry_data_storage* my_rates, + grunstable_rateid_type rate_id, + char* const* buf) { + namespace rate_q = grackle::impl::ratequery; + rate_q::Entry entry = rate_q::query_Entry(my_rates, rate_id).entry; + + if (entry.data.is_null()) { // in this case, the query failed + return GR_FAIL; + } + + if (entry.data.tag() != rate_q::PtrKind::const_str) { + return GR_FAIL; + } + const char* const* src = entry.data.const_str(); + long long n_items = rate_q::get_n_items(entry.props); + for (long long i = 0; i < n_items; i++) { + std::strcpy(buf[i], src[i]); + } + return GR_SUCCESS; +} + extern "C" int grunstable_ratequery_prop( const chemistry_data_storage* my_rates, grunstable_rateid_type rate_id, enum grunstable_ratequery_prop_kind prop_kind, long long* ptr) { @@ -466,12 +489,49 @@ extern "C" int grunstable_ratequery_prop( return GR_SUCCESS; } case GRUNSTABLE_QPROP_MAXITEMSIZE: { - *ptr = static_cast(sizeof(double)); + switch (entry.data.tag()) { + case rate_q::PtrKind::const_f64: + case rate_q::PtrKind::mutable_f64: { + *ptr = static_cast(sizeof(double)); + return GR_SUCCESS; + } + case rate_q::PtrKind::const_str: { + long long n_items = rate_q::get_n_items(entry.props); + const char* const* str_list = entry.data.const_str(); + + std::size_t max_size = 1; + for (long long i = 0; i < n_items; i++) { + // max_size holds the max number of bytes per element + max_size = std::max(max_size, std::strlen(str_list[i]) + 1); + } + *ptr = static_cast(max_size); + return GR_SUCCESS; + } + } + // if we reach here then we didn't handle a possible PtrKind + GR_INTERNAL_UNREACHABLE_ERROR(); + } + case GRUNSTABLE_QPROP_WRITABLE: { + *ptr = static_cast(entry.data.is_const_ptr()); return GR_SUCCESS; } - default: + case GRUNSTABLE_QPROP_DTYPE: { + switch (entry.data.tag()) { + case rate_q::PtrKind::const_f64: + case rate_q::PtrKind::mutable_f64: { + *ptr = static_cast(GRUNSTABLE_TYPE_F64); + return GR_SUCCESS; + } + case rate_q::PtrKind::const_str: { + *ptr = static_cast(GRUNSTABLE_TYPE_STR); + return GR_SUCCESS; + } + } + // if we reach here then we didn't handle a possible PtrKind GR_INTERNAL_UNREACHABLE_ERROR(); + } } + return GrPrintAndReturnErr("received an unknown prop_kind"); } extern "C" const char* grunstable_ith_rate( diff --git a/src/clib/ratequery.hpp b/src/clib/ratequery.hpp index 96bfffa62..193700f67 100644 --- a/src/clib/ratequery.hpp +++ b/src/clib/ratequery.hpp @@ -144,6 +144,22 @@ class PtrUnion { GR_INTERNAL_UNREACHABLE_ERROR(); } + /// Convenience method to check whether the tag holds a const pointer + /// + /// @note + /// An argument could be made for converting this to a standalone function + /// so that things are more C-like + bool is_const_ptr() const { + switch (this->tag_) { + case PtrKind::const_f64: + case PtrKind::const_str: + return true; + case PtrKind::mutable_f64: + return false; + } + GR_INTERNAL_UNREACHABLE_ERROR(); + } + /// access the tag attribute PtrKind tag() const { return this->tag_; } diff --git a/src/include/grackle.h b/src/include/grackle.h index 34993b8ad..f87bed08b 100644 --- a/src/include/grackle.h +++ b/src/include/grackle.h @@ -272,7 +272,7 @@ int grunstable_ratequery_get_f64( /// specified, this returns a different value /// /// > [!note] -/// > Before stablizing, we should consider whether we want to add an argument +/// > Before stabilizing, we should consider whether we want to add an argument /// > that specifies the supplied size of `buf` (and provide well-defined /// > behavior when `buf` is too small int grunstable_ratequery_set_f64( @@ -280,6 +280,28 @@ int grunstable_ratequery_set_f64( const double* buf ); +int grunstable_ratequery_get_str( + chemistry_data_storage* my_rates, grunstable_rateid_type rate_id, + char* const * buf +); + + +/// Describe types known to grackle +/// +/// > [!note] +/// > Before stabilizing, we should consider: +/// > 1. whether this is general enough to be useful throughout grackle. +/// > - For example, we could imagine adding a function in the future to the +/// > chemistry_data dynamic-access API that generically tries to query +/// > datatype. +/// > - In that case, we would want to reuse these macros +/// > 2. if these should actually be defined as macros (that may make it easier +/// > to support them from Fortran +enum grunstable_types { + GRUNSTABLE_TYPE_F64 = 1, + GRUNSTABLE_TYPE_STR = 2, +}; + /// Describe Rate-Query Property Types /// /// > [!note] @@ -292,6 +314,8 @@ enum grunstable_ratequery_prop_kind { GRUNSTABLE_QPROP_NDIM = 1, GRUNSTABLE_QPROP_SHAPE = 2, GRUNSTABLE_QPROP_MAXITEMSIZE = 3, + GRUNSTABLE_QPROP_WRITABLE = 4, + GRUNSTABLE_QPROP_DTYPE = 5, }; /// Query a property of the specified rate diff --git a/tests/unit/test_api_ratequery.cpp b/tests/unit/test_api_ratequery.cpp index 23d24796b..b8828aeb1 100644 --- a/tests/unit/test_api_ratequery.cpp +++ b/tests/unit/test_api_ratequery.cpp @@ -75,10 +75,34 @@ std::string stringify_prop_kind(enum grunstable_ratequery_prop_kind kind) { return "GRUNSTABLE_QPROP_SHAPE"; case GRUNSTABLE_QPROP_MAXITEMSIZE: return "GRUNSTABLE_QPROP_MAXITEMSIZE"; + case GRUNSTABLE_QPROP_WRITABLE: + return "GRUNSTABLE_QPROP_WRITABLE"; + case GRUNSTABLE_QPROP_DTYPE: + return "GRUNSTABLE_QPROP_DTYPE"; } GR_INTERNAL_UNREACHABLE_ERROR(); } +std::string stringify_type(enum grunstable_types kind) { + switch (kind) { + case GRUNSTABLE_TYPE_F64: + return "GRUNSTABLE_TYPE_F64"; + case GRUNSTABLE_TYPE_STR: + return "GRUNSTABLE_TYPE_STR"; + } + GR_INTERNAL_UNREACHABLE_ERROR(); +} + +std::optional safe_type_enum_cast(long long val) { + if (static_cast(GRUNSTABLE_TYPE_F64) == val) { + return std::make_optional(GRUNSTABLE_TYPE_F64); + } else if (static_cast(GRUNSTABLE_TYPE_STR) == val) { + return std::make_optional(GRUNSTABLE_TYPE_STR); + } else { + return std::nullopt; + } +} + /// return a vector of some invalid rateids std::vector invalid_rateids( grtest::GrackleCtxPack& pack) { @@ -190,11 +214,29 @@ TEST_P(ParametrizedRateQueryTest, Property) { << "buf holds the shape queried for " << pair; } + long long tmp = DEFAULT_VAL; + EXPECT_GR_SUCCESS(grunstable_ratequery_prop(pack.my_rates(), pair.id, + GRUNSTABLE_QPROP_DTYPE, &tmp)) + << "for " << pair; + std::optional dtype_maybe = safe_type_enum_cast(tmp); + EXPECT_TRUE(dtype_maybe.has_value()) << "for " << pair; + enum grunstable_types dtype = dtype_maybe.value(); + long long maxitemsize = DEFAULT_VAL; EXPECT_GR_SUCCESS(grunstable_ratequery_prop( pack.my_rates(), pair.id, GRUNSTABLE_QPROP_MAXITEMSIZE, &maxitemsize)) << "for " << pair; - EXPECT_EQ(maxitemsize, sizeof(double)) << "for " << pair; + if (dtype == GRUNSTABLE_TYPE_F64) { + EXPECT_EQ(maxitemsize, sizeof(double)) << "for " << pair; + } else { + EXPECT_GT(maxitemsize, 0) << "for " << pair; + } + + long long writable = DEFAULT_VAL; + EXPECT_GR_SUCCESS(grunstable_ratequery_prop( + pack.my_rates(), pair.id, GRUNSTABLE_QPROP_WRITABLE, &writable)) + << "for " << pair; + EXPECT_THAT(writable, ::testing::AnyOf(0LL, 1LL)) << "for " << pair; } } @@ -202,9 +244,12 @@ TEST_P(ParametrizedRateQueryTest, Property) { struct RateProperties { std::vector shape; std::size_t maxitemsize; + enum grunstable_types dtype; + bool writable; bool operator==(const RateProperties& other) const { - return maxitemsize == other.maxitemsize && shape == other.shape; + return maxitemsize == other.maxitemsize && shape == other.shape && + dtype == other.dtype && writable == other.writable; } long long n_items() const { @@ -224,32 +269,41 @@ struct RateProperties { } *os << props.shape[i]; } - *os << "}, maxitemsize=" << props.maxitemsize << "}"; + *os << "}, maxitemsize=" << props.maxitemsize + << ", dtype=" << stringify_type(props.dtype) + << ", writable=" << props.writable << '}'; } }; /// construct a RateProperties instance for the specified rate /// /// returns an empty optional if any there are any issues +/// +/// @note +/// After we query each property, we encode an extra sanity-check. We **only** +/// encode this in case there are other underlying issues (so that we don't end +/// up with an extremely crazy set of errors). The Property tests should +/// generally provide more details about these tests. To be clear, user-code +/// should never need to include these sanity check! std::optional try_query_RateProperties( chemistry_data_storage* my_rates, grunstable_rateid_type rateid) { long long ndim = -1LL; - std::vector shape; if (grunstable_ratequery_prop(my_rates, rateid, GRUNSTABLE_QPROP_NDIM, &ndim) != GR_SUCCESS) { return std::nullopt; - } else if (ndim != 0LL) { - if (ndim < 0LL) { // <- sanity check! - return std::nullopt; - } + } + if (ndim < 0LL) { + return std::nullopt; // sanity-check failed! + } + + std::vector shape; + if (ndim > 0LL) { shape.assign(ndim, 0LL); if (grunstable_ratequery_prop(my_rates, rateid, GRUNSTABLE_QPROP_SHAPE, shape.data()) != GR_SUCCESS) { return std::nullopt; } } - - // sanity check! confirm that no shape elements are non-positive if (std::count_if(shape.begin(), shape.end(), [](long long x) { return x <= 0; }) > 0) { return std::nullopt; // sanity check failed! @@ -261,10 +315,30 @@ std::optional try_query_RateProperties( return std::nullopt; } if (maxitemsize <= 0LL) { + return std::nullopt; // sanity check failed! + } + + long long dtype_tmp; + if (grunstable_ratequery_prop(my_rates, rateid, GRUNSTABLE_QPROP_DTYPE, + &dtype_tmp) != GR_SUCCESS) { + return std::nullopt; + } + std::optional dtype = safe_type_enum_cast(dtype_tmp); + if (maxitemsize <= 0LL) { + return std::nullopt; // sanity check failed! + } + + long long writable; + if (grunstable_ratequery_prop(my_rates, rateid, GRUNSTABLE_QPROP_WRITABLE, + &writable) != GR_SUCCESS) { + return std::nullopt; + } + if ((writable != 0LL) && (writable != 1LL)) { return std::nullopt; } - return {RateProperties{shape, static_cast(maxitemsize)}}; + return {RateProperties{shape, static_cast(maxitemsize), + dtype.value(), static_cast(writable)}}; } // returns a value that differs from the input @@ -340,19 +414,20 @@ enum RateKind { scalar_f64, simple_1d_rate, k13dd }; static RateProperties RateProperties_from_RateKind( const chemistry_data* my_chemistry, RateKind kind) { + const enum grunstable_types f64dtype = GRUNSTABLE_TYPE_F64; switch (kind) { case RateKind::scalar_f64: { std::vector shape = {}; // <-- intentionally empty - return RateProperties{shape, sizeof(double)}; + return RateProperties{shape, sizeof(double), f64dtype, true}; } case RateKind::simple_1d_rate: { std::vector shape = {my_chemistry->NumberOfTemperatureBins}; - return RateProperties{shape, sizeof(double)}; + return RateProperties{shape, sizeof(double), f64dtype, true}; } case RateKind::k13dd: { std::vector shape = {my_chemistry->NumberOfTemperatureBins * 14}; - return RateProperties{shape, sizeof(double)}; + return RateProperties{shape, sizeof(double), f64dtype, true}; } } GR_INTERNAL_UNREACHABLE_ERROR() From 587a13425d53276e1dcf4313c243a91ce19e622b Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Mon, 22 Dec 2025 15:02:07 -0500 Subject: [PATCH 142/175] first stab at update gracklepy --- src/python/gracklepy/grackle_defs.pxd | 12 +- src/python/gracklepy/grackle_wrapper.pyx | 213 +++++++++++++++++++---- 2 files changed, 194 insertions(+), 31 deletions(-) diff --git a/src/python/gracklepy/grackle_defs.pxd b/src/python/gracklepy/grackle_defs.pxd index 9a8017345..7f10e54c3 100644 --- a/src/python/gracklepy/grackle_defs.pxd +++ b/src/python/gracklepy/grackle_defs.pxd @@ -313,12 +313,22 @@ cdef extern from "grackle.h": grunstable_rateid_type rate_id, const double* buf) + int grunstable_ratequery_get_str( + c_chemistry_data_storage* my_rates, + grunstable_rateid_type rate_id, + char* const * buf + ); + + cdef enum grunstable_types: + GRUNSTABLE_TYPE_F64 + GRUNSTABLE_TYPE_STR + cdef enum grunstable_ratequery_prop_kind: GRUNSTABLE_QPROP_NDIM GRUNSTABLE_QPROP_SHAPE - GRUNSTABLE_QPROP_TYPE GRUNSTABLE_QPROP_MAXITEMSIZE GRUNSTABLE_QPROP_WRITABLE + GRUNSTABLE_QPROP_DTYPE int grunstable_ratequery_prop( const c_chemistry_data_storage* my_rates, diff --git a/src/python/gracklepy/grackle_wrapper.pyx b/src/python/gracklepy/grackle_wrapper.pyx index 342817cae..c52aa18ca 100644 --- a/src/python/gracklepy/grackle_wrapper.pyx +++ b/src/python/gracklepy/grackle_wrapper.pyx @@ -12,11 +12,13 @@ ######################################################################## import copy +import sys from gracklepy.utilities.physical_constants import \ boltzmann_constant_cgs, \ mass_hydrogen_cgs from libc.limits cimport INT_MAX +from libc.stdlib cimport malloc, free from .grackle_defs cimport * import numpy as np @@ -915,6 +917,150 @@ def _portable_reshape(arr: np.ndarray, shape: tuple[int, ...]) -> np.ndarray: return arr.reshape(shape, order="C", copy=False) +class RatequeryFailException(Exception): + pass + +cdef long long rateq_raw_nonshape_prop( + c_chemistry_data_storage *ptr, + grunstable_rateid_type rate_id, + grunstable_ratequery_prop_kind prop_kind, +) except*: + """ + queries a non-shape property & raises RatequeryFailException on failure + + This **ONLY** exists to simplify the implementation of rateq_get_prop + """ + cdef long long buf + cdef int ret = grunstable_ratequery_prop(ptr, rate_id, prop_kind, &buf) + if ret != GR_SUCCESS: + raise RatequeryFailException() + return buf + +cdef object rateq_get_prop( + c_chemistry_data_storage *ptr, + grunstable_rateid_type rate_id, + grunstable_ratequery_prop_kind prop_kind, +) except*: + """ + query the property and coerce the result to the appropriate python type + + Notes + ----- + If performance becomes a concern, we should stop using + RatequeryFailException. + """ + cdef long long buf[7] + cdef int ret_code + if prop_kind == GRUNSTABLE_QPROP_SHAPE: + ndim = rateq_get_prop(ptr, rate_id, prop_kind=GRUNSTABLE_QPROP_NDIM) + if ndim > 7: + raise RuntimeError( + f"rate_id {rate_id} has a questionable number of dims: {ndim}" + ) + elif ndim == 0: + return () + else: + ret_code = grunstable_ratequery_prop( + ptr, rate_id, GRUNSTABLE_QPROP_SHAPE, &buf[0] + ) + if ret_code != GR_SUCCESS: + raise RuntimeError( + f"shape query fail after ndim query success, for {rate_id=}" + ) + return tuple(int(buf[i]) for i in range(ndim)) + elif (prop_kind == GRUNSTABLE_QPROP_NDIM or + prop_kind == GRUNSTABLE_QPROP_MAXITEMSIZE): + buf[0] = rateq_raw_nonshape_prop(ptr, rate_id, prop_kind) + #if sizeof(Py_ssize_t) > sizeof(long long): + # if + return int(buf[0]) + elif prop_kind == GRUNSTABLE_QPROP_WRITABLE: + buf[0] = rateq_raw_nonshape_prop(ptr, rate_id, prop_kind) + return bool(buf[0]) + elif prop_kind == GRUNSTABLE_QPROP_DTYPE: + buf[0] = rateq_raw_nonshape_prop(ptr, rate_id, prop_kind) + if buf[0] == GRUNSTABLE_TYPE_F64: + return float + elif buf[0] == GRUNSTABLE_TYPE_STR: + return str + else: + # did we forget to update this function after adding a dtype? + raise RuntimeError(f"{rate_id=} has an unknown dtype") + else: + # did we forget to update this function after adding a new prop_kind? + raise ValueError(f"recieved an unknown prop_kind: {prop_kind}") + +cdef object rateq_load_string( + c_chemistry_data_storage *ptr, grunstable_rateid_type rate_id, tuple shape +): + """ + query the property and coerce the result to the appropriate python type + + Notes + ----- + strings are very much a special case (compared to say floating point + values or integer values) + """ + # reminder: when Cython casts python's built-in (arbitrary precision) int type to a + # C type will check for overflows during the cast + # https://cython.readthedocs.io/en/3.0.x/src/quickstart/cythonize.html + + cdef Py_ssize_t n_strings + if shape == (): + n_strings = 1 + elif len(shape) == 1 and shape[0] > 0: + n_strings = (shape[0]) + else: + # a multi-dimensional string array or an array of 0 strings makes **NO** sense + raise ValueError(f"invalid shape: {shape}") + + # query max number of bytes per string (includes space for trailing '\0') + cdef Py_ssize_t bytes_per_string + try: + bytes_per_string= ( + rateq_get_prop(ptr, rate_id, GRUNSTABLE_QPROP_MAXITEMSIZE) + ) + except OverflowError: + raise RuntimeError( + "bytes per string is suspiciously big (rate_id={})".format(int(rate_id)) + ) from None + + # let's confirm that the allocation size doesn't exceed the max value of Py_ssize_t + # -> technically, the max allocation size shouldn't exceed SIZE_MAX from C's + # header (i.e. the max value of size_t) + # -> for simplicity, we require that it doesn't exceed the max value of Py_ssize_t + # (by definition, the max value represented by Py_ssize_t uses 1 less bit of + # storage than SIZE_MAX) + cdef Py_ssize_t max_alloc_size = sys.maxsize # sys.maxsize is max val of Py_ssize_t + if (max_alloc_size / bytes_per_string) > n_strings: + raise RuntimeError( + "rate_id={} requires too much memory to load".format(int(rate_id)) + ) + + # allocate memory + cdef char* str_storage = malloc(bytes_per_string * n_strings) + cdef char** str_array = malloc(sizeof(char*)*n_strings) + cdef Py_ssize_t i + cdef list py_string_list = [] + try: + for i in range(n_strings): + str_array[i] = &str_storage[i*bytes_per_string] + + if (grunstable_ratequery_get_str(ptr, rate_id, str_array) + != GR_SUCCESS): + raise RatequeryFailException() + + for i in range(n_strings): + py_string_list.append((str_storage[i]).decode("ASCII")) + finally: + free(str_array) + free(str_storage) + + if shape == (): + return py_string_list[0] + return py_string_list + + cdef class _rate_mapping_access: # This class is used internally by the chemistry_data extension class to # wrap its chemistry_data_storage ptr and provide access to the stored @@ -975,32 +1121,19 @@ cdef class _rate_mapping_access: out[rate_name.decode('UTF-8')] = int(rate_id) i+=1 - def _try_get_shape(self, rate_id: int) -> tuple[int, ...]: + def _try_get_shape_type_pair( + self, rate_id: int + ) -> tuple[tuple[int, ...], type[float] | type[str]]: """ try to query the shape associated with rate_id """ - cdef long long buf[7] - cdef int ret = grunstable_ratequery_prop( - self._ptr, rate_id, GRUNSTABLE_QPROP_NDIM, &buf[0] - ) - if ret != GR_SUCCESS: + cdef grunstable_rateid_type casted_id = (rate_id) + try: + shape = rateq_get_prop(self._ptr, casted_id, GRUNSTABLE_QPROP_SHAPE) + dtype = rateq_get_prop(self._ptr, casted_id, GRUNSTABLE_QPROP_DTYPE) + return (shape, dtype) + except RatequeryFailException: return None - ndim = int(buf[0]) - if ndim == 0: - return () - elif ndim >7: - tmp = int(ndim) - raise RuntimeError( - f"rate_id {rate_id} has a questionable number of dims: {tmp}" - ) - - ret = grunstable_ratequery_prop( - self._ptr, rate_id, GRUNSTABLE_QPROP_SHAPE, &buf[0] - ) - if ret != GR_SUCCESS: - raise RuntimeError( - "the query for shape failed after query for ndim succeeded") - return tuple(int(buf[i]) for i in range(ndim)) def _get_rate(self, key: str): """ @@ -1014,19 +1147,25 @@ cdef class _rate_mapping_access: Returns ------- - np.ndarray or float + np.ndarray or float or list of strings or string The retrieved value """ # lookup the rate_id and shape of the rates rate_id = self._name_rateid_map[key] - shape = self._try_get_shape(rate_id) + shape, dtype = self._try_get_shape_type_pair(rate_id) + + if dtype == str: + # strings are a special case where we don't really want to rely upon numpy + return rateq_load_string(self._ptr, rate_id, shape) + elif dtype != float: + raise RuntimeError(f"no support (yet?) for rates of {dtype} values") # allocate the memory that grackle will write data to nelements = 1 if shape == () else np.prod(shape) out = np.empty(shape=(nelements,), dtype=np.float64) - # create a memoryview of out (so we can access the underlying pointer) + # declare a few memoryview types cdef double[:] memview = out if grunstable_ratequery_get_f64(self._ptr, rate_id, &memview[0]) != GR_SUCCESS: @@ -1059,7 +1198,15 @@ cdef class _rate_mapping_access: """ # lookup the rate_id and shape of the rates rate_id = self._name_rateid_map[key] - shape = self._try_get_shape(rate_id) + shape, dtype = self._try_get_shape_type_pair(rate_id) + + if dtype == str: + raise ValueError( + f"Grackle doesn't support assignment to keys (like \"{key}\") that are" + "associated with string values" + ) + elif dtype != float: + raise RuntimeError(f"no support (yet?) for rates of {dtype} values") # validate that val meets expectations and then coerce to `buf` a 1D numpy # array that we can feed to the C function @@ -1084,10 +1231,16 @@ cdef class _rate_mapping_access: cdef const double[:] memview = buf if grunstable_ratequery_set_f64(self._ptr, rate_id, &memview[0]) != GR_SUCCESS: - raise RuntimeError( - "Something went wrong while writing data associated with the " - f"\"{key}\" key" - ) + writable = rateq_get_prop(self._ptr, rate_id, GRUNSTABLE_QPROP_WRITABLE) + if writable: + raise RuntimeError( + "Something went wrong while writing data associated with the " + f"\"{key}\" key" + ) + else: + raise ValueError( + f"the values associated with the \"{key}\" key can't be overwritten" + ) def get(self, key, default=None, /): """ From de1c5efd01e6d3221eec8168b8c6a121afc91705 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Tue, 23 Dec 2025 10:19:36 -0500 Subject: [PATCH 143/175] improve the gracklepy bindings --- src/python/gracklepy/grackle_wrapper.pyx | 111 ++++++++++++----------- 1 file changed, 57 insertions(+), 54 deletions(-) diff --git a/src/python/gracklepy/grackle_wrapper.pyx b/src/python/gracklepy/grackle_wrapper.pyx index c52aa18ca..c199ddbb4 100644 --- a/src/python/gracklepy/grackle_wrapper.pyx +++ b/src/python/gracklepy/grackle_wrapper.pyx @@ -990,11 +990,14 @@ cdef object rateq_get_prop( # did we forget to update this function after adding a new prop_kind? raise ValueError(f"recieved an unknown prop_kind: {prop_kind}") -cdef object rateq_load_string( - c_chemistry_data_storage *ptr, grunstable_rateid_type rate_id, tuple shape +cdef list rateq_load_string( + c_chemistry_data_storage *ptr, + grunstable_rateid_type rate_id, + Py_ssize_t n_items, + object key ): """ - query the property and coerce the result to the appropriate python type + Load the single string or list of strings associated with rate_id Notes ----- @@ -1005,15 +1008,6 @@ cdef object rateq_load_string( # C type will check for overflows during the cast # https://cython.readthedocs.io/en/3.0.x/src/quickstart/cythonize.html - cdef Py_ssize_t n_strings - if shape == (): - n_strings = 1 - elif len(shape) == 1 and shape[0] > 0: - n_strings = (shape[0]) - else: - # a multi-dimensional string array or an array of 0 strings makes **NO** sense - raise ValueError(f"invalid shape: {shape}") - # query max number of bytes per string (includes space for trailing '\0') cdef Py_ssize_t bytes_per_string try: @@ -1021,9 +1015,7 @@ cdef object rateq_load_string( rateq_get_prop(ptr, rate_id, GRUNSTABLE_QPROP_MAXITEMSIZE) ) except OverflowError: - raise RuntimeError( - "bytes per string is suspiciously big (rate_id={})".format(int(rate_id)) - ) from None + raise RuntimeError(f"bytes per string is suspiciously big ({key=})") from None # let's confirm that the allocation size doesn't exceed the max value of Py_ssize_t # -> technically, the max allocation size shouldn't exceed SIZE_MAX from C's @@ -1032,33 +1024,55 @@ cdef object rateq_load_string( # (by definition, the max value represented by Py_ssize_t uses 1 less bit of # storage than SIZE_MAX) cdef Py_ssize_t max_alloc_size = sys.maxsize # sys.maxsize is max val of Py_ssize_t - if (max_alloc_size / bytes_per_string) > n_strings: - raise RuntimeError( - "rate_id={} requires too much memory to load".format(int(rate_id)) - ) + if (max_alloc_size / bytes_per_string) > n_items: + raise RuntimeError(f"{key=} requires too much memory to load") # allocate memory - cdef char* str_storage = malloc(bytes_per_string * n_strings) - cdef char** str_array = malloc(sizeof(char*)*n_strings) + cdef char* str_storage = malloc(bytes_per_string * n_items) + cdef char** str_array = malloc(sizeof(char*) * n_items) cdef Py_ssize_t i - cdef list py_string_list = [] + cdef list out = [] try: - for i in range(n_strings): + for i in range(n_items): str_array[i] = &str_storage[i*bytes_per_string] if (grunstable_ratequery_get_str(ptr, rate_id, str_array) != GR_SUCCESS): - raise RatequeryFailException() + raise RuntimeError(f"Error retrieving data for the \"{key}\" key") - for i in range(n_strings): - py_string_list.append((str_storage[i]).decode("ASCII")) + for i in range(n_items): + out.append((str_storage[i]).decode("ASCII")) finally: free(str_array) free(str_storage) - if shape == (): - return py_string_list[0] - return py_string_list + return out + + +cdef object rateq_load_f64( + c_chemistry_data_storage *ptr, + grunstable_rateid_type rate_id, + Py_ssize_t n_items, + object key +): + """ + Returns a 1D numpy array of loaded 64-bit floats + + Notes + ----- + If we add more types (other than strings), it would be easier to use cython's + fused-type functionality to generalize this function + """ + out = np.empty(shape=(n_items,), dtype=np.float64) + cdef double[:] memview = out + if grunstable_ratequery_get_f64(ptr, rate_id, &memview[0]) != GR_SUCCESS: + raise RuntimeError(f"Error retrieving data for the \"{key}\" key") + + # we set the WRITABLE flag to False so that people don't mistakenly believe + # that by modifying the array in place that they are updating Grackle's + # internal buffers + out.setflags(write=False) + return out cdef class _rate_mapping_access: @@ -1155,33 +1169,23 @@ cdef class _rate_mapping_access: rate_id = self._name_rateid_map[key] shape, dtype = self._try_get_shape_type_pair(rate_id) + ndim = len(shape) + nelements = 1 if shape == () else np.prod(shape) + if dtype == str: - # strings are a special case where we don't really want to rely upon numpy - return rateq_load_string(self._ptr, rate_id, shape) - elif dtype != float: + if ndim > 1: + raise RuntimeError("multi-dimensional arrays of strings aren't alowed") + out = rateq_load_string(self._ptr, rate_id, nelements, key) + elif dtype == float: + out = rateq_load_f64(self._ptr, rate_id, nelements, key) + else: raise RuntimeError(f"no support (yet?) for rates of {dtype} values") - # allocate the memory that grackle will write data to - nelements = 1 if shape == () else np.prod(shape) - out = np.empty(shape=(nelements,), dtype=np.float64) - # declare a few memoryview types - cdef double[:] memview = out - - if grunstable_ratequery_get_f64(self._ptr, rate_id, &memview[0]) != GR_SUCCESS: - raise RuntimeError( - "Something went wrong while retrieving the data associated with the " - f"\"{key}\" key" - ) if shape == (): - return float(out[0]) - - if shape != out.shape: - out = _portable_reshape(out, shape=shape) - # we set the WRITABLE flag to False so that people don't mistakenly believe - # that by modifying the array in place that they are updating Grackle's - # internal buffers - out.setflags(write=False) + return dtype(out[0]) + elif ndim != 1: + return _portable_reshape(out, shape=shape) return out def _set_rate(self, key, val): @@ -1234,8 +1238,7 @@ cdef class _rate_mapping_access: writable = rateq_get_prop(self._ptr, rate_id, GRUNSTABLE_QPROP_WRITABLE) if writable: raise RuntimeError( - "Something went wrong while writing data associated with the " - f"\"{key}\" key" + f"Error writing to data associated with the \"{key}\" key" ) else: raise ValueError( @@ -1249,7 +1252,7 @@ cdef class _rate_mapping_access: """ try: return self._get_rate(key) - except: + except KeyError: return default def __getitem__(self, key): return self._get_rate(key) From 5c36e45f447aabe6c6bc03b7f4158ee76190a3f5 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Tue, 23 Dec 2025 10:58:07 -0500 Subject: [PATCH 144/175] elaborate on a few more items that need addressing before stabilizing the ratequery API --- src/include/grackle.h | 61 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/src/include/grackle.h b/src/include/grackle.h index f87bed08b..1a43077e4 100644 --- a/src/include/grackle.h +++ b/src/include/grackle.h @@ -188,7 +188,7 @@ int gr_initialize_field_data(grackle_field_data *my_fields); /// > anyways to support any variant of this API for dynamic rates) /// /// > [!note] -/// > There are a number of considerations before stablization. Some are +/// > There are a number of considerations before stabilization. Some are /// > discussed in docstrings. Below we summarize more generic considerations: /// > 1. Do we want to be able to use this API to eventually support a dynamic /// > set of rates? If so, then: @@ -203,13 +203,49 @@ int gr_initialize_field_data(grackle_field_data *my_fields); /// > - currently the dynamic parameter API is grackle's only other /// > data-access API, but we could imagine creating an API for the fields /// > (in order to achieve ABI stability) +/// > 3. I think it may be beneficial to follow the example of yt and make keys +/// > 2 element strings (rather than just a single string). +/// > - this is attractive because it would let us group things together +/// > - for example, we could group k1, k2, k3, ... under a group of +/// > collisional reaction rates. It might be useful to list yields for +/// > different injection pathways (e.g. used in the multi-dust grain +/// > species model) under a separate group. +/// > 4. We should consider improving "ergonomics" of this API +/// > - accessing arrays of strings are currently very clunky. +/// > - Maybe we should avoid requiring a deep-copy? And just require the +/// > user to allocate a buffer to hold pointers to internal strings? I +/// > don't love this. +/// > - There's a piece of me that wonders if we could entirely eliminate +/// > arrays of strings (while still supporting single strings) by +/// > adopting keys composed of 2 strings and refactoring +/// > grackle_field_data to only provide access to strings through keys +/// > (as in PR 271) +/// > - property-querying also feels a little clunky... See the note +/// > attached to that docstring for more details +/// > 5. We need to come up with a consistent strategy when rates are not +/// > defined. +/// > - In a lot of cases, I think it's ok to simply "not" define the rate. +/// > For example, when primordial_chemistry=0, I don't think we should +/// > define rates like k1, k2, k3, ... If we ever want to support a +/// > dynamic API, I think this approach makes a lot of sense in a lot of +/// > cases. +/// > - There's a separate, related question of whether we should support the +/// > idea of an empty entry (i.e. a 1D array with 0 entries). This may +/// > come up in the context of arrays of strings +/// > - for example, if we normally list the names of all dust grain +/// > species, we may want an empty string when there are no dust grain +/// > grain species +/// > - but does it make sense to support an empty scalar? +/// > - as we discuss earlier in this list, it's plausible certain changes +/// > could make string-datasets unnecessary. In that case, this point +/// > may become moot. /** @{ */ /// @typedef grunstable_rateid_type /// @brief Type of rate-ids returned to the user /// /// > [!note] -/// > Before stablizing, we should consider: +/// > Before stabilizing, we should consider: /// > - if we should use `int64_t` rather than `long long` /// > - if we want to make this a more generic name like `gr_idtype` (i.e. if /// > we plan to use rates in other parts of the code) @@ -322,13 +358,32 @@ enum grunstable_ratequery_prop_kind { /// /// @param[in] my_rates The object being queried /// @param[in] rate_id The id of the rate for which the property is queried -/// @param[in] prop_kind The proprty to query +/// @param[in] prop_kind The property to query /// @param[out] ptr The pointer where the property is recorded /// /// @returns GR_SUCCESS if successful. Otherwise, a different value is returned. /// /// The behavior is undefined when @p my_rates is a `nullptr`, @p ptr is a /// nullptr or @p ptr doesn't have enough space to store the queried property +/// +/// @note +/// It turns out that using this interface is a little clunky... +/// - before stabilization, it may be better to change this function so that +/// - it accepts an additional argument specifying the total size of the +/// provided buffer (and report an error if the buffer isn't long enough) +/// - it would also be great (but not essential) to change the return-value +/// to specify: +/// - the number of entries that were filled written to ptr by this +/// function +/// - aside: we need to return 0 for GRUNSTABLE_QPROP_SHAPE when +/// querying a scalar quantity +/// - a negative value would denote an error +/// - optionally, when ptr is a nullptr, we could have the function return +/// the number of required ptr needs (similar to the interface for +/// snprintf), but this isn't necessary +/// - Doing this would allow users to write extra code to handle queries of +/// GRUNSTABLE_QPROP_SHAPE in a special way (i.e. currently you **NEED** to +/// query GRUNSTABLE_QPROP_NDIM, first to make sure you allocate enough space) int grunstable_ratequery_prop(const chemistry_data_storage* my_rates, grunstable_rateid_type rate_id, enum grunstable_ratequery_prop_kind prop_kind, From f69092cd33cf7f62035d510516d91b5cd39ca4df Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Tue, 23 Dec 2025 11:10:26 -0500 Subject: [PATCH 145/175] fix some issues in test_api_ratequery --- tests/unit/test_api_ratequery.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/unit/test_api_ratequery.cpp b/tests/unit/test_api_ratequery.cpp index b8828aeb1..07c104cf6 100644 --- a/tests/unit/test_api_ratequery.cpp +++ b/tests/unit/test_api_ratequery.cpp @@ -219,7 +219,11 @@ TEST_P(ParametrizedRateQueryTest, Property) { GRUNSTABLE_QPROP_DTYPE, &tmp)) << "for " << pair; std::optional dtype_maybe = safe_type_enum_cast(tmp); - EXPECT_TRUE(dtype_maybe.has_value()) << "for " << pair; + if (!dtype_maybe.has_value()) { + GTEST_FAIL() + << "Error coercing " << tmp << ", the dtype for " << pair + << ", to an enum value"; + } enum grunstable_types dtype = dtype_maybe.value(); long long maxitemsize = DEFAULT_VAL; @@ -324,7 +328,7 @@ std::optional try_query_RateProperties( return std::nullopt; } std::optional dtype = safe_type_enum_cast(dtype_tmp); - if (maxitemsize <= 0LL) { + if (!dtype.has_value()) { return std::nullopt; // sanity check failed! } From 0de69ae9c95f52662381164e0fe5d7e64c6b59e0 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Tue, 23 Dec 2025 11:13:23 -0500 Subject: [PATCH 146/175] fix a bug in writable check --- src/clib/ratequery.cpp | 2 +- tests/unit/test_api_ratequery.cpp | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/clib/ratequery.cpp b/src/clib/ratequery.cpp index 2c3e021d4..90967c2f4 100644 --- a/src/clib/ratequery.cpp +++ b/src/clib/ratequery.cpp @@ -512,7 +512,7 @@ extern "C" int grunstable_ratequery_prop( GR_INTERNAL_UNREACHABLE_ERROR(); } case GRUNSTABLE_QPROP_WRITABLE: { - *ptr = static_cast(entry.data.is_const_ptr()); + *ptr = static_cast(!entry.data.is_const_ptr()); return GR_SUCCESS; } case GRUNSTABLE_QPROP_DTYPE: { diff --git a/tests/unit/test_api_ratequery.cpp b/tests/unit/test_api_ratequery.cpp index 07c104cf6..2d7b2c79c 100644 --- a/tests/unit/test_api_ratequery.cpp +++ b/tests/unit/test_api_ratequery.cpp @@ -220,9 +220,8 @@ TEST_P(ParametrizedRateQueryTest, Property) { << "for " << pair; std::optional dtype_maybe = safe_type_enum_cast(tmp); if (!dtype_maybe.has_value()) { - GTEST_FAIL() - << "Error coercing " << tmp << ", the dtype for " << pair - << ", to an enum value"; + GTEST_FAIL() << "Error coercing " << tmp << ", the dtype for " << pair + << ", to an enum value"; } enum grunstable_types dtype = dtype_maybe.value(); From 862a86d873133d3141e80e0d9224be100f1d5c21 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Tue, 23 Dec 2025 14:17:25 -0500 Subject: [PATCH 147/175] Shifted the entire definition of EntrySet into ratequery.cpp --- src/clib/ratequery.cpp | 100 ++++++++++++++++++++++++++++++----------- src/clib/ratequery.hpp | 51 --------------------- 2 files changed, 73 insertions(+), 78 deletions(-) diff --git a/src/clib/ratequery.cpp b/src/clib/ratequery.cpp index 90967c2f4..2ece0ee6c 100644 --- a/src/clib/ratequery.cpp +++ b/src/clib/ratequery.cpp @@ -167,6 +167,79 @@ static void drop_owned_Entry_list_contents(Entry* entry_list, int n_entries) { } } +/// Describes a set of entries +/// +/// This can operate in 2 modes: +/// 1. Embedded-List-mode: +/// - the EntrySet directly holds a list of Entry instances that **ONLY** +/// exist for querying purposes and should **NEVER** be mutated by +/// external code. +/// - importantly, the EntrySet is responsible for managing the memory the +/// pointers to string each string and pointer referenced by a pointer in +/// this list. +/// 2. Recipe-mode: +/// - In this case, the EntrySet provides access to Entry instances that +/// directly reference data managed by `chemistry_data_storage` +struct EntrySet { + /// number of entries in the current set + int len; + + /// an embedded list of entries, where the allocation are directly owned and + /// managed by this instance. + /// + /// @important + /// this **must** be a nullptr if operating in Recipe-mode + Entry* embedded_list; + + /// a function pointer that can be used to access entries through a recipe + fetch_Entry_recipe_fn* recipe_fn; + + /// properties used by all entries accessed through a recipe + /// + /// In more detail, an entry returned by `recipe_fn` has its `props` member + /// overwritten by this value + /// + /// @note + /// only used in Recipe-mode + EntryProps common_recipe_props; +}; + +/// look up an Entry in an EntrySet +/// +/// @param[in] entry_set The container object being queried +/// @param[in] my_rates Used for looking up Entry in recipe-mode +/// @param[in] i The index to query +/// +/// @returns An instance that references memory owned by either my_rates or by +/// the entry_set, itself. +Entry EntrySet_access(const EntrySet* entry_set, + chemistry_data_storage* my_rates, int i) { + if (i > entry_set->len) { + return mk_invalid_Entry(); + } else if (entry_set->embedded_list == nullptr) { // in recipe-mode + Entry out = (entry_set->recipe_fn)(my_rates, i); + out.props = entry_set->common_recipe_props; + return out; + } else { // in embedded-list mode + return entry_set->embedded_list[i]; + } +} + +/// deallocate the contents of an EntrySet +void drop_EntrySet(EntrySet* ptr) { + if (ptr->embedded_list == nullptr) { + // nothing to deallocate in recipe-mode + } else { + // in embedded-list-mode, we need to deallocate each Entry in the list + // and the deallocate the actual list-pointer + drop_owned_Entry_list_contents(ptr->embedded_list, ptr->len); + + // deallocate the memory associated with embedded_list + delete[] ptr->embedded_list; + ptr->embedded_list = nullptr; + } +} + /// resets the instance to the initial (empty) state. /// /// the skip_dealloc argument will only be true when the data is transferred @@ -249,33 +322,6 @@ grackle::impl::ratequery::RegBuilder_consume_and_build(RegBuilder* ptr) { } } -grackle::impl::ratequery::Entry grackle::impl::ratequery::EntrySet_access( - const EntrySet* entry_set, chemistry_data_storage* my_rates, int i) { - if (i > entry_set->len) { - return mk_invalid_Entry(); - } else if (entry_set->embedded_list == nullptr) { // in recipe-mode - Entry out = (entry_set->recipe_fn)(my_rates, i); - out.props = entry_set->common_recipe_props; - return out; - } else { // in embedded-list mode - return entry_set->embedded_list[i]; - } -} - -void grackle::impl::ratequery::drop_EntrySet(EntrySet* ptr) { - if (ptr->embedded_list == nullptr) { - // nothing to deallocate in recipe-mode - } else { - // in embedded-list-mode, we need to deallocate each Entry in the list - // and the deallocate the actual list-pointer - drop_owned_Entry_list_contents(ptr->embedded_list, ptr->len); - - // deallocate the memory associated with embedded_list - delete[] ptr->embedded_list; - ptr->embedded_list = nullptr; - } -} - void grackle::impl::ratequery::drop_Registry( grackle::impl::ratequery::Registry* ptr) { if (ptr->sets != nullptr) { diff --git a/src/clib/ratequery.hpp b/src/clib/ratequery.hpp index 193700f67..29372f66a 100644 --- a/src/clib/ratequery.hpp +++ b/src/clib/ratequery.hpp @@ -343,57 +343,6 @@ int RegBuilder_misc_recipies(RegBuilder* ptr, /// For safety, the caller should still plan to call drop_RegBuilder Registry RegBuilder_consume_and_build(RegBuilder* ptr); -/// Describes a set of entries -/// -/// This can operate in 2 modes: -/// 1. Embedded-List-mode: -/// - the EntrySet directly holds a list of Entry instances that **ONLY** -/// exist for querying purposes and should **NEVER** be mutated by -/// external code. -/// - imporantly, the EntrySet is responsible for managing the memory the -/// pointers to string each string and pointer referenced by a pointer in -/// this list. -/// 2. Recipe-mode: -/// - In this case, the EntrySet provides access to Entry instances that -/// directly reference data managed by `chemistry_data_storage` -struct EntrySet { - /// number of entries in the current set - int len; - - /// an embedded list of entries, where the allocation are directly owned and - /// managed by this instance. - /// - /// @important - /// this **must** be a nullptr if operating in Recipe-mode - Entry* embedded_list; - - /// a function pointer that can be used to access entries through a recipe - fetch_Entry_recipe_fn* recipe_fn; - - /// properties used by all entries accessed through a recipe - /// - /// In more detail, an entry returned by `recipe_fn` has its `props` member - /// overwritten by this value - /// - /// @note - /// only used in Recipe-mode - EntryProps common_recipe_props; -}; - -/// look up an Entry in an EntrySet -/// -/// @param[in] entry_set The container object being queried -/// @param[in] my_rates Used for looking up Entry in recipe-mode -/// @param[in] i The index to query -/// -/// @returns An instance that references memory owned by either my_rates or by -/// the entry_set, itself. -Entry EntrySet_access(const EntrySet* entry_set, - chemistry_data_storage* my_rates, int i); - -/// deallocate the contents of an EntrySet -void drop_EntrySet(EntrySet* ptr); - /** @}*/ // end of group } // namespace grackle::impl::ratequery From ac69a552f8f420d388c2053e713203551fb9cfd1 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Tue, 23 Dec 2025 17:45:24 -0500 Subject: [PATCH 148/175] introduce SimpleVec --- src/clib/CMakeLists.txt | 1 + src/clib/support/SimpleVec.hpp | 130 +++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 src/clib/support/SimpleVec.hpp diff --git a/src/clib/CMakeLists.txt b/src/clib/CMakeLists.txt index 8bd5db35d..174bfb431 100644 --- a/src/clib/CMakeLists.txt +++ b/src/clib/CMakeLists.txt @@ -124,6 +124,7 @@ add_library(Grackle_Grackle solve_chemistry.cpp scale_fields.cpp scale_fields.hpp solve_rate_cool_g-cpp.cpp solve_rate_cool_g-cpp.h + support/SimpleVec.hpp step_rate_gauss_seidel.hpp step_rate_newton_raphson.hpp time_deriv_0d.hpp diff --git a/src/clib/support/SimpleVec.hpp b/src/clib/support/SimpleVec.hpp new file mode 100644 index 000000000..7dd0741a6 --- /dev/null +++ b/src/clib/support/SimpleVec.hpp @@ -0,0 +1,130 @@ +//===----------------------------------------------------------------------===// +// +// See the LICENSE file for license and copyright information +// SPDX-License-Identifier: NCSA AND BSD-3-Clause +// +//===----------------------------------------------------------------------===// +/// +/// @file +/// Implements the SimpleVec type +/// +//===----------------------------------------------------------------------===// +#ifndef SUPPORT_SIMPLEVEC_HPP +#define SUPPORT_SIMPLEVEC_HPP + +#include +#include + +#include "status_reporting.h" + +namespace grackle::impl { + +/// This is a **VERY** simplified version of std::vector that is intended to be +/// very C-like. +/// +/// It is C-like in the sense that: +/// - it essentially acts like a struct with a bunch of associated functions +/// (the associated functions act like methods). +/// - **IMPORTANTLY:** the caller is responsible for explicitly calling the +/// destructor-function. +/// +/// @par Motivation +/// This type is motivated by the fact that to dynamically build up objects, +/// you commonly need to construct arrays where the instances are not +/// well-known ahead of time. This comes up with enough frequency that it is +/// useful to define an abstraction for this data-structure +/// +/// @todo +/// We should **STRONGLY** consider replacing this type with std::vector. In my +/// opinion, the primary "cost" is that std::vector is more "contagious." +/// Unlike the status quo where we can extract the underlying pointer (and take +/// ownership of it), that can't be done with a std::vector; you need to either +/// allocate a new pointer or continue carrying around the underlying vector) +template +struct SimpleVec { + static_assert( // sanity-check! + std::is_default_constructible_v && std::is_copy_assignable_v, + "template type is too sophisticated. You should be using std::vector"); + + // declare the struct-members + // - default-member initialization is used to ensure that this struct is in + // a valid state without calling an explicit constructor function + int capacity = 0; + int len = 0; + T* data = nullptr; + + // in practice, the following logic prevents other structs from directly + // embedding an instance of this type as a data member (a pointer to this + // struct must be stored) + // - There is always a risk of mistakes with a C-like API when it comes to + // dangling pointers. But, the SimpleVec_extract_ptr_and_make_empty + // function definitely amplifies the risk. + // - By forcing the use of pointers to this type, we are mitigating this risk + // to an extent at the cost of an extra pointer indirection. + // - (if we're willing to fully embrace C++, we could do a **LOT** better) + SimpleVec(const SimpleVec&) = delete; + SimpleVec(SimpleVec&&) = delete; + SimpleVec& operator=(const SimpleVec&) = delete; + SimpleVec& operator=(SimpleVec&&) = delete; +}; + +/// Deletes internal data within a vec (acts like a destructor) +/// +/// As per usual, this does not try to directly deallocate the pointer itself +template +void drop_SimpleVec(SimpleVec* vec) { + if (vec->data != nullptr) { + delete[] vec->data; + } + vec->data = nullptr; + vec->capacity = 0; + vec->len = 0; +} + +/// returns the internal data pointer (the caller takes ownership of it) and +/// modifies the provided vec so that it's equivalent to an empty vector +/// +/// After this function executes, passing the argument to drop_SimpleVec or to +/// SimpleVec_push_back will **NOT** affect the extracted pointer. +template +T* SimpleVec_extract_ptr_and_make_empty(SimpleVec* vec) { + T* ptr = vec->data; + vec->data = nullptr; + vec->capacity = 0; + vec->len = 0; + return ptr; +} + +/// Deletes internal data within a vec +template +void SimpleVec_push_back(SimpleVec* vec, T value) { + if (vec->capacity == 0) { + vec->capacity = 5; + vec->data = new T[vec->capacity]; + } else if (vec->capacity == vec->len) { + int max_cap = std::numeric_limits::max(); + GR_INTERNAL_REQUIRE(vec->capacity < max_cap, "should never happen!"); + int new_cap = + ((max_cap / 2) <= vec->capacity) ? max_cap : vec->capacity * 2; + T* new_data = new T[new_cap]; + for (int i = 0; i < vec->len; i++) { + new_data[i] = vec->data[i]; + } + delete[] vec->data; + vec->data = new_data; + vec->capacity = new_cap; + } + + vec->data[vec->len] = value; + ++(vec->len); +} + +/// Deletes internal data within a vec +template +int SimpleVec_len(SimpleVec* vec) { + return vec->len; +} + +} // namespace grackle::impl + +#endif // SUPPORT_SIMPLEVEC_HPP From 651db0e3526af25bf946a70c49413d42efeb13e0 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Fri, 26 Dec 2025 12:54:32 -0500 Subject: [PATCH 149/175] refactor RegBuilder to use SimpleVec --- src/clib/ratequery.cpp | 37 +++++++++------------------------- src/clib/ratequery.hpp | 10 +++++---- src/clib/support/SimpleVec.hpp | 26 ++++++++++++++++-------- 3 files changed, 34 insertions(+), 39 deletions(-) diff --git a/src/clib/ratequery.cpp b/src/clib/ratequery.cpp index 2ece0ee6c..cd86e4c6b 100644 --- a/src/clib/ratequery.cpp +++ b/src/clib/ratequery.cpp @@ -240,17 +240,6 @@ void drop_EntrySet(EntrySet* ptr) { } } -/// resets the instance to the initial (empty) state. -/// -/// the skip_dealloc argument will only be true when the data is transferred -/// to a Registry -static void RegBuilder_reset_to_empty(RegBuilder* ptr, bool skip_dealloc) { - if ((ptr->capacity > 0) && !skip_dealloc) { - delete[] ptr->sets; - } - (*ptr) = new_RegBuilder(); -} - static int RegBuilder_recipe_(RegBuilder* ptr, fetch_Entry_recipe_fn* recipe_fn, int n_entries, EntryProps common_props) { if (recipe_fn == nullptr) { @@ -261,22 +250,18 @@ static int RegBuilder_recipe_(RegBuilder* ptr, fetch_Entry_recipe_fn* recipe_fn, return GrPrintAndReturnErr("common_props isn't valid"); } - if (ptr->capacity == 0) { - ptr->capacity = 5; - ptr->sets = new EntrySet[ptr->capacity]; - } else if (ptr->len == ptr->capacity) { - // consider making this resizable in the future... - return GrPrintAndReturnErr("out of capacity"); - } + SimpleVec_push_back(ptr->sets, + EntrySet{n_entries, nullptr, recipe_fn, common_props}); - ptr->sets[ptr->len++] = EntrySet{n_entries, nullptr, recipe_fn, common_props}; return GR_SUCCESS; } } // namespace grackle::impl::ratequery void grackle::impl::ratequery::drop_RegBuilder(RegBuilder* ptr) { - RegBuilder_reset_to_empty(ptr, false); + drop_SimpleVec(ptr->sets); + delete ptr->sets; + ptr->sets = nullptr; } int grackle::impl::ratequery::RegBuilder_recipe_scalar( @@ -302,22 +287,20 @@ int grackle::impl::ratequery::RegBuilder_recipe_1d( /// reallocating lots of memory) grackle::impl::ratequery::Registry grackle::impl::ratequery::RegBuilder_consume_and_build(RegBuilder* ptr) { - int n_sets = ptr->len; + int n_sets = SimpleVec_len(ptr->sets); if (n_sets == 0) { - drop_RegBuilder(ptr); + drop_SimpleVec(ptr->sets); return Registry{0, n_sets, nullptr, nullptr}; } else { + EntrySet* sets = SimpleVec_extract_ptr_and_make_empty(ptr->sets); // set up id_offsets and determine the total number of entries int* id_offsets = new int[n_sets]; int tot_entry_count = 0; for (int i = 0; i < n_sets; i++) { id_offsets[i] = tot_entry_count; - tot_entry_count += ptr->sets[i].len; + tot_entry_count += sets[i].len; } - Registry out{tot_entry_count, n_sets, id_offsets, ptr->sets}; - // reset to ptr to initial state (but don't deallocate since the ptr was - // transferred to out - RegBuilder_reset_to_empty(ptr, true); + Registry out{tot_entry_count, n_sets, id_offsets, sets}; return out; } } diff --git a/src/clib/ratequery.hpp b/src/clib/ratequery.hpp index 29372f66a..9f22187f3 100644 --- a/src/clib/ratequery.hpp +++ b/src/clib/ratequery.hpp @@ -15,6 +15,7 @@ #include "grackle.h" #include "utils-cpp.hpp" // GRIMPL_FORCE_INLINE #include "status_reporting.h" +#include "support/SimpleVec.hpp" namespace grackle::impl::ratequery { @@ -292,13 +293,14 @@ void drop_Registry(Registry* ptr); /// Other parts of grackle should refrain from directly accessing the internals /// of this function (i.e. they should only use the associated methods) struct RegBuilder { - int capacity; - int len; - EntrySet* sets; + SimpleVec* sets; }; /// initialize a new instance -inline RegBuilder new_RegBuilder() { return {0, 0, nullptr}; } +inline RegBuilder new_RegBuilder() { + // by default SimpleVec is automatically initialized + return {new SimpleVec}; +} /// deallocates all storage within a RegBuilder instance void drop_RegBuilder(RegBuilder* ptr); diff --git a/src/clib/support/SimpleVec.hpp b/src/clib/support/SimpleVec.hpp index 7dd0741a6..74ede3b33 100644 --- a/src/clib/support/SimpleVec.hpp +++ b/src/clib/support/SimpleVec.hpp @@ -13,7 +13,7 @@ #define SUPPORT_SIMPLEVEC_HPP #include -#include +// #include #include "status_reporting.h" @@ -38,14 +38,23 @@ namespace grackle::impl { /// We should **STRONGLY** consider replacing this type with std::vector. In my /// opinion, the primary "cost" is that std::vector is more "contagious." /// Unlike the status quo where we can extract the underlying pointer (and take -/// ownership of it), that can't be done with a std::vector; you need to either -/// allocate a new pointer or continue carrying around the underlying vector) +/// ownership of it), storage can't be taken from a std::vector; you need to +/// either allocate a new pointer or continue carrying around the underlying +/// vector) +/// +/// @par Justification for making this a class template +/// The alternatives to making this a template are *MUCH* less desirable: +/// 1. We could use a macro to define a version of this type and all associated +/// functions for each contained type. This is messy, and we would need to +/// come up with unique names for each version of the primary struct. In +/// practice, the template is doing this under the hood +/// 2. We could convert data from `T*` to `void**`. While this is doable, it +/// will require extra memory. Every time we push back a value, we would +/// need to copy that value into newly allocated memory and cast a pointer +/// to that memory to `void*`. For cleanup, you would need to cast each +/// `void*` back to the original type before calling `delete` template struct SimpleVec { - static_assert( // sanity-check! - std::is_default_constructible_v && std::is_copy_assignable_v, - "template type is too sophisticated. You should be using std::vector"); - // declare the struct-members // - default-member initialization is used to ensure that this struct is in // a valid state without calling an explicit constructor function @@ -62,6 +71,7 @@ struct SimpleVec { // - By forcing the use of pointers to this type, we are mitigating this risk // to an extent at the cost of an extra pointer indirection. // - (if we're willing to fully embrace C++, we could do a **LOT** better) + SimpleVec() = default; SimpleVec(const SimpleVec&) = delete; SimpleVec(SimpleVec&&) = delete; SimpleVec& operator=(const SimpleVec&) = delete; @@ -121,7 +131,7 @@ void SimpleVec_push_back(SimpleVec* vec, T value) { /// Deletes internal data within a vec template -int SimpleVec_len(SimpleVec* vec) { +int SimpleVec_len(const SimpleVec* vec) { return vec->len; } From 9a99f755db7effe8b4d4cd2a8ee5f14115c8f4e4 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Fri, 26 Dec 2025 13:32:37 -0500 Subject: [PATCH 150/175] prepare RegBuilder to handle owned Entries --- src/clib/ratequery.cpp | 37 ++++++++++++++++++++++++++++++------- src/clib/ratequery.hpp | 12 ++++++++++-- 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/src/clib/ratequery.cpp b/src/clib/ratequery.cpp index cd86e4c6b..305541a16 100644 --- a/src/clib/ratequery.cpp +++ b/src/clib/ratequery.cpp @@ -250,7 +250,7 @@ static int RegBuilder_recipe_(RegBuilder* ptr, fetch_Entry_recipe_fn* recipe_fn, return GrPrintAndReturnErr("common_props isn't valid"); } - SimpleVec_push_back(ptr->sets, + SimpleVec_push_back(ptr->recipe_sets, EntrySet{n_entries, nullptr, recipe_fn, common_props}); return GR_SUCCESS; @@ -259,9 +259,21 @@ static int RegBuilder_recipe_(RegBuilder* ptr, fetch_Entry_recipe_fn* recipe_fn, } // namespace grackle::impl::ratequery void grackle::impl::ratequery::drop_RegBuilder(RegBuilder* ptr) { - drop_SimpleVec(ptr->sets); - delete ptr->sets; - ptr->sets = nullptr; + if (ptr->recipe_sets != nullptr) { + drop_SimpleVec(ptr->recipe_sets); + delete ptr->recipe_sets; + ptr->recipe_sets = nullptr; + } + if (ptr->owned_entries != nullptr) { + int n_entries = SimpleVec_len(ptr->owned_entries); + if (n_entries > 0) { + Entry* entry_l = SimpleVec_extract_ptr_and_make_empty(ptr->owned_entries); + drop_owned_Entry_list_contents(entry_l, n_entries); + } + drop_SimpleVec(ptr->owned_entries); + delete ptr->owned_entries; + ptr->owned_entries = nullptr; + } } int grackle::impl::ratequery::RegBuilder_recipe_scalar( @@ -287,12 +299,23 @@ int grackle::impl::ratequery::RegBuilder_recipe_1d( /// reallocating lots of memory) grackle::impl::ratequery::Registry grackle::impl::ratequery::RegBuilder_consume_and_build(RegBuilder* ptr) { - int n_sets = SimpleVec_len(ptr->sets); + // try to construct an EntrySet that contains all owned entries + if (SimpleVec_len(ptr->owned_entries) > 0) { + EntrySet tmp{/* len = */ SimpleVec_len(ptr->owned_entries), + /* embedded_list = */ + SimpleVec_extract_ptr_and_make_empty(ptr->owned_entries), + /* recipe_fn = */ nullptr, + /* common_recipe_props = */ mk_invalid_EntryProps()}; + SimpleVec_push_back(ptr->recipe_sets, tmp); + } + + // now actually set up the registry + int n_sets = SimpleVec_len(ptr->recipe_sets); if (n_sets == 0) { - drop_SimpleVec(ptr->sets); + drop_SimpleVec(ptr->recipe_sets); return Registry{0, n_sets, nullptr, nullptr}; } else { - EntrySet* sets = SimpleVec_extract_ptr_and_make_empty(ptr->sets); + EntrySet* sets = SimpleVec_extract_ptr_and_make_empty(ptr->recipe_sets); // set up id_offsets and determine the total number of entries int* id_offsets = new int[n_sets]; int tot_entry_count = 0; diff --git a/src/clib/ratequery.hpp b/src/clib/ratequery.hpp index 9f22187f3..69a30ac0f 100644 --- a/src/clib/ratequery.hpp +++ b/src/clib/ratequery.hpp @@ -293,13 +293,21 @@ void drop_Registry(Registry* ptr); /// Other parts of grackle should refrain from directly accessing the internals /// of this function (i.e. they should only use the associated methods) struct RegBuilder { - SimpleVec* sets; + /// a growable array that records recipies for accessing sets of entries + SimpleVec* recipe_sets; + /// a growable array of owned Entry instances + /// + /// The basic premise is that these Entry instances **ONLY** exist for the + /// purpose of supporting queries. Cleaning up each instance involves extra + /// effort. When a Registry instance is constructed, this pointer will be + /// transferred to an EntrySet. + SimpleVec* owned_entries; }; /// initialize a new instance inline RegBuilder new_RegBuilder() { // by default SimpleVec is automatically initialized - return {new SimpleVec}; + return {new SimpleVec, new SimpleVec}; } /// deallocates all storage within a RegBuilder instance From a2e31db45f982271c649fd50f37059d63b4e43e7 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sun, 28 Dec 2025 13:15:40 -0500 Subject: [PATCH 151/175] implement logic for RegBuilder to create owned Entry instances --- src/clib/ratequery.cpp | 61 ++++++++++++++++++++++++++++++++++++++++-- src/clib/ratequery.hpp | 41 ++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 2 deletions(-) diff --git a/src/clib/ratequery.cpp b/src/clib/ratequery.cpp index 305541a16..5c8a70d96 100644 --- a/src/clib/ratequery.cpp +++ b/src/clib/ratequery.cpp @@ -240,6 +240,32 @@ void drop_EntrySet(EntrySet* ptr) { } } +/// Helper function that takes ownership of owned_data +static int RegBuilder_take_data_(RegBuilder* ptr, const char* raw_name, + PtrUnion owned_data, EntryProps props) { + if (raw_name == nullptr) { + return GrPrintAndReturnErr("raw_name is a nullptr"); + } else if (owned_data.is_null()) { + return GrPrintAndReturnErr("owned_data holds a nullptr"); + } else if (!owned_data.is_const_ptr()) { + return GrPrintAndReturnErr("owned_data isn't const"); + } else if (!EntryProps_is_valid(props)) { + return GrPrintAndReturnErr("common_props isn't valid"); + } + + std::size_t n_byte = std::strlen(raw_name) + 1; + char* name = new char[n_byte]; + // NOLINTNEXTLINE(bugprone-not-null-terminated-result) + std::memcpy(name, raw_name, n_byte); + + Entry tmp = mk_invalid_Entry(); + tmp.data = owned_data; + tmp.name = name; + tmp.props = props; + SimpleVec_push_back(ptr->owned_entries, tmp); + return GR_SUCCESS; +} + static int RegBuilder_recipe_(RegBuilder* ptr, fetch_Entry_recipe_fn* recipe_fn, int n_entries, EntryProps common_props) { if (recipe_fn == nullptr) { @@ -292,6 +318,38 @@ int grackle::impl::ratequery::RegBuilder_recipe_1d( return RegBuilder_recipe_(ptr, recipe_fn, n_entries, common_props); } +int grackle::impl::ratequery::RegBuilder_copied_str_arr1d( + RegBuilder* ptr, const char* name, const char* const* str_arr1d, int len) { + if (len <= 0) { + return GrPrintAndReturnErr("len must be positive"); + } + char** my_copy = new char*[len]; + for (int i = 0; i < len; i++) { + int nbytes = std::strlen(str_arr1d[i]) + 1; + my_copy[i] = new char[nbytes]; + std::memcpy(my_copy[i], str_arr1d[i], nbytes); + } + PtrUnion data(const_cast(my_copy)); + EntryProps props = mk_invalid_EntryProps(); + props.ndim = 1; + props.shape[0] = len; + return RegBuilder_take_data_(ptr, name, data, props); +} + +int grackle::impl::ratequery::RegBuilder_copied_f64_arr1d( + RegBuilder* ptr, const char* name, const double* f64_arr1d, int len) { + if (len <= 0) { + return GrPrintAndReturnErr("len must be positive"); + } + double* my_copy = new double[len]; + std::memcpy(my_copy, f64_arr1d, sizeof(double) * len); + PtrUnion data(const_cast(my_copy)); + EntryProps props = mk_invalid_EntryProps(); + props.ndim = 1; + props.shape[0] = len; + return RegBuilder_take_data_(ptr, name, data, props); +} + /// build a new Registry. /// /// In the process, the current Registry is consumed; it's effectively reset to @@ -328,8 +386,7 @@ grackle::impl::ratequery::RegBuilder_consume_and_build(RegBuilder* ptr) { } } -void grackle::impl::ratequery::drop_Registry( - grackle::impl::ratequery::Registry* ptr) { +void grackle::impl::ratequery::drop_Registry(Registry* ptr) { if (ptr->sets != nullptr) { delete[] ptr->id_offsets; ptr->id_offsets = nullptr; diff --git a/src/clib/ratequery.hpp b/src/clib/ratequery.hpp index 69a30ac0f..89474e7fe 100644 --- a/src/clib/ratequery.hpp +++ b/src/clib/ratequery.hpp @@ -343,6 +343,47 @@ int RegBuilder_recipe_1d(RegBuilder* ptr, int n_entries, int RegBuilder_misc_recipies(RegBuilder* ptr, const chemistry_data* my_chemistry); +/// copies a 1d array of strings to make a queryable entry +/// +/// The resulting Registry will have a queryable entry corresponding to the +/// specified 1D array of strings. Importantly, the RegBuilder and Registry +/// hold a deepcopy of the specified strings. +/// +/// @param[inout] ptr The RegBuilder that will be updated +/// @param[in] name The queryable name that corresponds to the provided data +/// @param[in] str_arr1d The 1d array of strings +/// @param[in] len The length of str_arr1d +/// +/// @returns GR_SUCCESS if successful, otherwise returns a different value +/// +/// @note +/// This is intended to be used for making information available that Grackle +/// otherwise does not need access to. +int RegBuilder_copied_str_arr1d(RegBuilder* ptr, const char* name, + const char* const* str_arr1d, int len); + +/// copies a 1d array of doubles to make a queryable entry +/// +/// The resulting Registry will have a queryable entry corresponding to the +/// specified 1D array of doubles. Importantly, the RegBuilder and Registry +/// hold a deepcopy of the values. +/// +/// @param[inout] ptr The RegBuilder that will be updated +/// @param[in] name The queryable name that corresponds to the provided data +/// @param[in] f64_arr1d The 1d array of doubles +/// @param[in] len The length of str_list +/// +/// @returns GR_SUCCESS if successful, otherwise returns a different value +/// +/// @note +/// This is intended to be used for making information available that Grackle +/// otherwise does not need access to. For example, it might be used to provide +/// information about assumed abundances that Grackle doesn't directly use (i.e. +/// the abundances could be "baked into" some tables), but external simulation +/// codes may want to know about to achieve better consistency. +int RegBuilder_copied_f64_arr1d(RegBuilder* ptr, const char* name, + const double* f64_arr1d, int len); + /// build a new Registry. /// /// In the process, the current Registry is consumed; it's effectively reset to From 5b45e620c066b4c3aff9c2d6ec30c566a9b562ca Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sun, 28 Dec 2025 13:25:07 -0500 Subject: [PATCH 152/175] tweak a test --- tests/unit/test_api_ratequery.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/unit/test_api_ratequery.cpp b/tests/unit/test_api_ratequery.cpp index 2d7b2c79c..3fb69dde6 100644 --- a/tests/unit/test_api_ratequery.cpp +++ b/tests/unit/test_api_ratequery.cpp @@ -369,6 +369,10 @@ TEST_P(ParametrizedRateQueryTest, SetAndGet) { RateProperties props = maybe_props.value(); long long n_items = props.n_items(); + if (!props.writable) { + continue; + } + // load in data associated with the current rate initial_buf.assign(n_items, NAN); ASSERT_GR_SUCCESS(grunstable_ratequery_get_f64(pack.my_rates(), pair.id, From 4a62639632e2ed057cda7cbdc6a578cdbac6828c Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sun, 28 Dec 2025 14:35:57 -0500 Subject: [PATCH 153/175] initial attempt to make the names of the injectionpathway data queryable --- src/clib/initialize_rates.cpp | 4 ++-- src/clib/inject_model/load_data.cpp | 13 ++++++++++++- src/clib/inject_model/load_data.hpp | 4 +++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/clib/initialize_rates.cpp b/src/clib/initialize_rates.cpp index 6f8bcd6ce..b23947594 100644 --- a/src/clib/initialize_rates.cpp +++ b/src/clib/initialize_rates.cpp @@ -738,8 +738,8 @@ int grackle::impl::initialize_rates( } // Load injection pathway data - if (grackle::impl::load_inject_path_data(my_chemistry, my_rates) - != GR_SUCCESS) { + if (grackle::impl::load_inject_path_data( + my_chemistry, my_rates, reg_builder) != GR_SUCCESS) { return GrPrintAndReturnErr("Error in load_inject_path_data."); } diff --git a/src/clib/inject_model/load_data.cpp b/src/clib/inject_model/load_data.cpp index b39768da7..45c5e1ea8 100644 --- a/src/clib/inject_model/load_data.cpp +++ b/src/clib/inject_model/load_data.cpp @@ -17,6 +17,7 @@ #include "raw_data.hpp" #include "../LUT.hpp" #include "../opaque_storage.hpp" +#include "../ratequery.hpp" #include "../status_reporting.h" // GrPrintAndReturnErr #include "../utils/FrozenKeyIdxBiMap.hpp" @@ -250,7 +251,8 @@ void zero_out_dust_inject_props( } // anonymous namespace int grackle::impl::load_inject_path_data(const chemistry_data* my_chemistry, - chemistry_data_storage* my_rates) { + chemistry_data_storage* my_rates, + ratequery::RegBuilder* reg_builder) { // Currently, this function "loads" injection pathway data from data that is // directly embedded as part of the Grackle library in a manner controlled // by raw_data.hpp and raw_data.cpp @@ -301,6 +303,15 @@ int grackle::impl::load_inject_path_data(const chemistry_data* my_chemistry, "there was a problem building the map of model names"); } + // we are going to make the list of model names available to Grackle users + // through the ratequery interface + if (ratequery::RegBuilder_copied_str_arr1d(reg_builder, "inject_model_names", + inj_path_name_l, + n_pathways) != GR_SUCCESS) { + return GrPrintAndReturnErr( + "There was an issue making names of inject pathways queryable"); + } + // initialize the object that will hold the loaded data int n_log10Tdust_vals = grackle::impl::inj_model_input::N_Tdust_Opacity_Table; int n_opac_poly_coef = grackle::impl::inj_model_input::N_Opacity_Coef; diff --git a/src/clib/inject_model/load_data.hpp b/src/clib/inject_model/load_data.hpp index 4ab8a0eed..802f0503a 100644 --- a/src/clib/inject_model/load_data.hpp +++ b/src/clib/inject_model/load_data.hpp @@ -14,6 +14,7 @@ #define INJECT_MODEL_LOAD_DATA_HPP #include "grackle.h" +#include "../ratequery.hpp" namespace grackle::impl { @@ -22,7 +23,8 @@ namespace grackle::impl { /// /// @returns GR_SUCCESS if successful int load_inject_path_data(const chemistry_data* my_chemistry, - chemistry_data_storage* my_rates); + chemistry_data_storage* my_rates, + ratequery::RegBuilder* reg_builder); } // namespace grackle::impl From 122e57447d649ad2931b408e28e4de8fbf8e6b82 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Mon, 29 Dec 2025 10:31:37 -0500 Subject: [PATCH 154/175] make more rate-info queryable --- src/clib/inject_model/load_data.cpp | 170 ++++++++++++++++++++++++++-- 1 file changed, 161 insertions(+), 9 deletions(-) diff --git a/src/clib/inject_model/load_data.cpp b/src/clib/inject_model/load_data.cpp index 45c5e1ea8..0013c9625 100644 --- a/src/clib/inject_model/load_data.cpp +++ b/src/clib/inject_model/load_data.cpp @@ -23,6 +23,160 @@ namespace { // stuff inside an anonymous namespace is local to this file +/// a function that encodes the algorithm for looking up the pointer to the +/// gas yield fractions (as in fractions of the total injected non-primordial +/// material) from each injection pathway for the `i`th metal nuclide +/// +/// This is intended to be registered with RegBuilder in order to provide +/// access to these quantities +/// +/// @param my_rates The object from which the rate Entry is loaded +/// @param i the index of the queried rate +grackle::impl::ratequery::Entry nuclide_gas_yield_recipe( + chemistry_data_storage* my_rates, int i) { + namespace rateq = grackle::impl::ratequery; + if ((my_rates == nullptr) || (my_rates->opaque_storage == nullptr) || + (my_rates->opaque_storage->inject_pathway_props == nullptr)) { + return rateq::mk_invalid_Entry(); + } + const grackle::impl::yields::MetalTables& tab = + my_rates->opaque_storage->inject_pathway_props->gas_metal_nuclide_yields; + + switch (i) { + case 0: + return rateq::new_Entry(tab.C, "inject_path_gas_yield_frac.C"); + case 1: + return rateq::new_Entry(tab.O, "inject_path_gas_yield_frac.O"); + case 2: + return rateq::new_Entry(tab.Mg, "inject_path_gas_yield_frac.Mg"); + case 3: + return rateq::new_Entry(tab.Al, "inject_path_gas_yield_frac.Al"); + case 4: + return rateq::new_Entry(tab.Si, "inject_path_gas_yield_frac.Si"); + case 5: + return rateq::new_Entry(tab.S, "inject_path_gas_yield_frac.S"); + case 6: + return rateq::new_Entry(tab.Fe, "inject_path_gas_yield_frac.Fe"); + default: + return rateq::mk_invalid_Entry(); + } +} + +/// a function that encodes the algorithm for looking up the pointer to the +/// yield fractions (as in fractions of the total injected non-primordial +/// material) from each injection pathway for the `i`th dust grain species +/// +/// This is intended to be registered with RegBuilder in order to provide +/// access to these quantities +/// +/// @param my_rates The object from which the rate Entry is loaded +/// @param i the index of the queried rate +/// +/// @note +/// This function makes 2 things clear: +/// 1. We *may* want to configure recipes to accept an arbitrary callback +/// argument so that we don't have to hardcode the names of every dust +/// grain species +/// 2. It would be advantageous to adopt key-names that are composed of 2 +/// strings (that way we could reuse string-literals holding the grain +/// species names) +grackle::impl::ratequery::Entry grain_yield_recipe( + chemistry_data_storage* my_rates, int i) { + namespace rateq = grackle::impl::ratequery; + if ((my_rates == nullptr) || (my_rates->opaque_storage == nullptr) || + (my_rates->opaque_storage->inject_pathway_props == nullptr)) { + return rateq::mk_invalid_Entry(); + } + const grackle::impl::GrainSpeciesCollection& tab = + my_rates->opaque_storage->inject_pathway_props->grain_yields; + double* const* data = tab.data; + + switch (i) { + case 0: + return rateq::new_Entry(data[OnlyGrainSpLUT::MgSiO3_dust], + "inject_path_grain_yield_frac.MgSiO3_dust"); + case 1: + return rateq::new_Entry(data[OnlyGrainSpLUT::AC_dust], + "inject_path_grain_yield_frac.AC_dust"); + case 2: + return rateq::new_Entry(data[OnlyGrainSpLUT::SiM_dust], + "inject_path_grain_yield_frac.SiM_dust"); + case 3: + return rateq::new_Entry(data[OnlyGrainSpLUT::FeM_dust], + "inject_path_grain_yield_frac.FeM_dust"); + case 4: + return rateq::new_Entry(data[OnlyGrainSpLUT::Mg2SiO4_dust], + "inject_path_grain_yield_frac.Mg2SiO4_dust"); + case 5: + return rateq::new_Entry(data[OnlyGrainSpLUT::Fe3O4_dust], + "inject_path_grain_yield_frac.Fe3O4_dust"); + case 6: + return rateq::new_Entry(data[OnlyGrainSpLUT::SiO2_dust], + "inject_path_grain_yield_frac.SiO2_dust"); + case 7: + return rateq::new_Entry(data[OnlyGrainSpLUT::MgO_dust], + "inject_path_grain_yield_frac.MgO_dust"); + case 8: + return rateq::new_Entry(data[OnlyGrainSpLUT::FeS_dust], + "inject_path_grain_yield_frac.FeS_dust"); + case 9: + return rateq::new_Entry(data[OnlyGrainSpLUT::Al2O3_dust], + "inject_path_grain_yield_frac.Al2O3_dust"); + case 10: + return rateq::new_Entry(data[OnlyGrainSpLUT::ref_org_dust], + "inject_path_grain_yield_frac.ref_org_dust"); + case 11: + return rateq::new_Entry(data[OnlyGrainSpLUT::vol_org_dust], + "inject_path_grain_yield_frac.vol_org_dust"); + case 12: + return rateq::new_Entry(data[OnlyGrainSpLUT::H2O_ice_dust], + "inject_path_grain_yield_frac.H2O_ice_dust"); + default: + return rateq::mk_invalid_Entry(); + } +} + +int configure_RegBuilder(const chemistry_data_storage* my_rates, + grackle::impl::ratequery::RegBuilder* reg_builder, + const char* const* inj_path_name_l, int n_pathways) { + namespace rateq = grackle::impl::ratequery; + + // make list of pathway names available to users through the ratequery API + if (rateq::RegBuilder_copied_str_arr1d(reg_builder, "inject_model_names", + inj_path_name_l, + n_pathways) != GR_SUCCESS) { + return GrPrintAndReturnErr( + "There was an issue making names of inject pathways queryable"); + } + + // the length of each gas nuclide yield array is equal to the number of + // injection pathways + if (rateq::RegBuilder_recipe_1d(reg_builder, 7, &nuclide_gas_yield_recipe, + n_pathways) != GR_SUCCESS) { + return GrPrintAndReturnErr( + "There was an issue making nuclide gas yield fractions (for each " + "injection pathway) queryable"); + } + + if ((my_rates->opaque_storage != nullptr) && + (my_rates->opaque_storage->grain_species_info != nullptr)) { + int n_grain_species = + my_rates->opaque_storage->grain_species_info->n_species; + + // the length of each grain species yield array is equal to the number of + // injection pathways + if (rateq::RegBuilder_recipe_1d(reg_builder, n_grain_species, + &grain_yield_recipe, + n_pathways) != GR_SUCCESS) { + return GrPrintAndReturnErr( + "There was an issue making nuclide gas yield fractions (for each " + "injection pathway) queryable"); + } + } + + return GR_SUCCESS; +} + /// names of all injection pathways known to grackle listed in the order /// consistent with the logic for implementing InjectPathFieldPack /// @@ -303,15 +457,6 @@ int grackle::impl::load_inject_path_data(const chemistry_data* my_chemistry, "there was a problem building the map of model names"); } - // we are going to make the list of model names available to Grackle users - // through the ratequery interface - if (ratequery::RegBuilder_copied_str_arr1d(reg_builder, "inject_model_names", - inj_path_name_l, - n_pathways) != GR_SUCCESS) { - return GrPrintAndReturnErr( - "There was an issue making names of inject pathways queryable"); - } - // initialize the object that will hold the loaded data int n_log10Tdust_vals = grackle::impl::inj_model_input::N_Tdust_Opacity_Table; int n_opac_poly_coef = grackle::impl::inj_model_input::N_Opacity_Coef; @@ -376,5 +521,12 @@ int grackle::impl::load_inject_path_data(const chemistry_data* my_chemistry, n_pathways); } + // Before we finish, let's register some of these it can be queried by + // Grackle-users + if (configure_RegBuilder(my_rates, reg_builder, inj_path_name_l, + n_pathways) != GR_SUCCESS) { + return GrPrintAndReturnErr("error making injection pathway info queryable"); + } + return GR_SUCCESS; } From 32f2ddb3e646ced601f5de24426c1c6efc992b90 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Tue, 30 Dec 2025 09:28:19 -0500 Subject: [PATCH 155/175] add some basic tests of the new quantities accessible through ratequery --- tests/unit/test_api_ratequery.cpp | 135 +++++++++++++++++++++++++----- 1 file changed, 114 insertions(+), 21 deletions(-) diff --git a/tests/unit/test_api_ratequery.cpp b/tests/unit/test_api_ratequery.cpp index 3fb69dde6..9c0ff2c6a 100644 --- a/tests/unit/test_api_ratequery.cpp +++ b/tests/unit/test_api_ratequery.cpp @@ -25,6 +25,7 @@ #include "grtestutils/googletest/fixtures.hpp" #include "grackle.h" +#include "inject_model/raw_data.hpp" // grackle::impl::inj_model_input::N_Injection_Pathways #include "status_reporting.h" /// returns the rateid used to denote invalid rate names @@ -243,6 +244,21 @@ TEST_P(ParametrizedRateQueryTest, Property) { } } +/// A helper function that is used to help implement PrintTo for +/// ExpectedRateProperties and RateProperties +template +void print_standard_props_(const T& props, std::ostream* os) { + *os << "shape={"; + for (std::size_t i = 0; i < props.shape.size(); i++) { + if (i != 0) { + *os << ", "; + } + *os << props.shape[i]; + } + *os << "}, dtype=" << stringify_type(props.dtype) + << ", writable=" << props.writable; +} + /// summarizes details about rate properties struct RateProperties { std::vector shape; @@ -250,11 +266,6 @@ struct RateProperties { enum grunstable_types dtype; bool writable; - bool operator==(const RateProperties& other) const { - return maxitemsize == other.maxitemsize && shape == other.shape && - dtype == other.dtype && writable == other.writable; - } - long long n_items() const { long long n_items = 1LL; for (std::size_t i = 0; i < shape.size(); i++) { @@ -265,19 +276,57 @@ struct RateProperties { /// teach googletest how to print this type friend void PrintTo(const RateProperties& props, std::ostream* os) { - *os << "{shape={"; - for (std::size_t i = 0; i < props.shape.size(); i++) { - if (i != 0) { - *os << ", "; - } - *os << props.shape[i]; - } - *os << "}, maxitemsize=" << props.maxitemsize - << ", dtype=" << stringify_type(props.dtype) - << ", writable=" << props.writable << '}'; + *os << "RateProperties{"; + print_standard_props_(props, os); + *os << ", maxitemsize=" << props.maxitemsize << '}'; } }; +/// analogous to RateProperties, but it doesn't have the maxitemsize member +/// +/// The premise is that you construct this to express expectations since you +/// can't know the maxitemsize for an arbitrary array of strings +/// +/// @todo +/// This is an ugly kludge. We may want to replace this with some kind of +/// custom "matcher"... +struct ExpectedRateProperties { + std::vector shape; + enum grunstable_types dtype; + bool writable; + + /// teach googletest how to print this type + friend void PrintTo(const ExpectedRateProperties& props, std::ostream* os) { + *os << "ExpectedRateProperties{"; + print_standard_props_(props, os); + *os << '}'; + } +}; + +bool operator==(const RateProperties& a, const RateProperties& b) { + return a.maxitemsize == b.maxitemsize && a.shape == b.shape && + a.dtype == b.dtype && a.writable == b.writable; +} + +static bool has_appropriate_maxitemsize_(const RateProperties& props) { + switch (props.dtype) { + case GRUNSTABLE_TYPE_F64: + return props.maxitemsize == sizeof(double); + case GRUNSTABLE_TYPE_STR: + return true; + } + GR_INTERNAL_UNREACHABLE_ERROR(); +} + +bool operator==(const RateProperties& a, const ExpectedRateProperties& b) { + return has_appropriate_maxitemsize_(a) && a.shape == b.shape && + a.dtype == b.dtype && a.writable == b.writable; +} + +bool operator==(const ExpectedRateProperties& a, const RateProperties& b) { + return b == a; +} + /// construct a RateProperties instance for the specified rate /// /// returns an empty optional if any there are any issues @@ -417,24 +466,51 @@ INSTANTIATE_TEST_SUITE_P( // -> this may not be the most maintainable test (we may want to re-evaluate it // in the future) -enum RateKind { scalar_f64, simple_1d_rate, k13dd }; +enum RateKind { + scalar_f64, + simple_1d_rate, + k13dd, + inject_path_yield, + inject_path_names +}; + +static long long get_n_inj_pathways(const chemistry_data* my_chemistry) { + if (my_chemistry->metal_chemistry <= 0) { + GR_INTERNAL_ERROR("there are no injection pathways"); + } else if (my_chemistry->multi_metals == 0) { + return 1LL; + } else { + return static_cast( + grackle::impl::inj_model_input::N_Injection_Pathways); + } +}; -static RateProperties RateProperties_from_RateKind( +static ExpectedRateProperties RateProperties_from_RateKind( const chemistry_data* my_chemistry, RateKind kind) { const enum grunstable_types f64dtype = GRUNSTABLE_TYPE_F64; + const enum grunstable_types strdtype = GRUNSTABLE_TYPE_STR; + switch (kind) { case RateKind::scalar_f64: { std::vector shape = {}; // <-- intentionally empty - return RateProperties{shape, sizeof(double), f64dtype, true}; + return ExpectedRateProperties{shape, f64dtype, true}; } case RateKind::simple_1d_rate: { std::vector shape = {my_chemistry->NumberOfTemperatureBins}; - return RateProperties{shape, sizeof(double), f64dtype, true}; + return ExpectedRateProperties{shape, f64dtype, true}; } case RateKind::k13dd: { std::vector shape = {my_chemistry->NumberOfTemperatureBins * 14}; - return RateProperties{shape, sizeof(double), f64dtype, true}; + return ExpectedRateProperties{shape, f64dtype, true}; + } + case RateKind::inject_path_yield: { + std::vector shape = {get_n_inj_pathways(my_chemistry)}; + return ExpectedRateProperties{shape, f64dtype, true}; + } + case RateKind::inject_path_names: { + std::vector shape = {get_n_inj_pathways(my_chemistry)}; + return ExpectedRateProperties{shape, strdtype, false}; } } GR_INTERNAL_UNREACHABLE_ERROR() @@ -466,6 +542,23 @@ std::map known_rates() { out.insert({"k13dd", RateKind::k13dd}); + std::vector metal_nuclides = {"C", "O", "Mg", "Al", + "Si", "S", "Fe"}; + for (const std::string& metal_nuclide : metal_nuclides) { + out.insert({"inject_path_gas_yield_frac." + metal_nuclide, + RateKind::inject_path_yield}); + } + std::vector known_grain_species = { + "MgSiO3_dust", "AC_dust", "SiM_dust", "FeM_dust", "Mg2SiO4_dust", + "Fe3O4_dust", "SiO2_dust", "MgO_dust", "FeS_dust", "Al2O3_dust", + "ref_org_dust", "vol_org_dust", "H2O_ice_dust"}; + for (const std::string& grain_species : known_grain_species) { + out.insert({"inject_path_grain_yield_frac." + grain_species, + RateKind::inject_path_yield}); + } + + out.insert({"inject_model_names", RateKind::inject_path_names}); + return out; } @@ -485,7 +578,7 @@ TEST_F(KnownRateQueryTest, CheckProperties) { continue; // the rateid is **NOT** in known_rate_map } // construct the expected properties - RateProperties expected_props = + ExpectedRateProperties expected_props = RateProperties_from_RateKind(pack.my_chemistry(), search->second); // load the actual props From 78b8e63719b9331dc7304eea0042b7e581154553 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Tue, 30 Dec 2025 09:55:35 -0500 Subject: [PATCH 156/175] Move reusable machinery for testing ratequery API into its own file --- tests/grtestutils/CMakeLists.txt | 1 + tests/grtestutils/ratequery.hpp | 224 ++++++++++++++++++++++++++++++ tests/unit/test_api_ratequery.cpp | 218 +++-------------------------- 3 files changed, 241 insertions(+), 202 deletions(-) create mode 100644 tests/grtestutils/ratequery.hpp diff --git a/tests/grtestutils/CMakeLists.txt b/tests/grtestutils/CMakeLists.txt index 42bb65246..8bbd5a6bf 100644 --- a/tests/grtestutils/CMakeLists.txt +++ b/tests/grtestutils/CMakeLists.txt @@ -83,6 +83,7 @@ add_library(grtestutils iterator_adaptor.hpp os.hpp os.cpp preset.hpp preset.cpp + ratequery.hpp utils.hpp utils.cpp # files in the googletest subdirectory (reminder: should just be headers!) diff --git a/tests/grtestutils/ratequery.hpp b/tests/grtestutils/ratequery.hpp new file mode 100644 index 000000000..b09886c98 --- /dev/null +++ b/tests/grtestutils/ratequery.hpp @@ -0,0 +1,224 @@ +//===----------------------------------------------------------------------===// +// +// See the LICENSE file for license and copyright information +// SPDX-License-Identifier: NCSA AND BSD-3-Clause +// +//===----------------------------------------------------------------------===// +/// +/// @file +/// Define assorted machinery to help with testing the ratequery machinery +/// +//===----------------------------------------------------------------------===// +#ifndef GRTESTUTILS_RATEQUERY_UTILS_HPP +#define GRTESTUTILS_RATEQUERY_UTILS_HPP + +#include "grackle.h" +#include "status_reporting.h" + +#include +#include +#include +#include + +namespace grtest { + +/// returns the rateid used to denote invalid rate names +inline grunstable_rateid_type get_invalid_rateid( + const grtest::GrackleCtxPack& pack) { + return grunstable_ratequery_id(pack.my_rates(), nullptr); +} + +inline std::string stringify_prop_kind( + enum grunstable_ratequery_prop_kind kind) { + switch (kind) { + case GRUNSTABLE_QPROP_NDIM: + return "GRUNSTABLE_QPROP_NDIM"; + case GRUNSTABLE_QPROP_SHAPE: + return "GRUNSTABLE_QPROP_SHAPE"; + case GRUNSTABLE_QPROP_MAXITEMSIZE: + return "GRUNSTABLE_QPROP_MAXITEMSIZE"; + case GRUNSTABLE_QPROP_WRITABLE: + return "GRUNSTABLE_QPROP_WRITABLE"; + case GRUNSTABLE_QPROP_DTYPE: + return "GRUNSTABLE_QPROP_DTYPE"; + } + GR_INTERNAL_UNREACHABLE_ERROR(); +} + +inline std::string stringify_type(enum grunstable_types kind) { + switch (kind) { + case GRUNSTABLE_TYPE_F64: + return "GRUNSTABLE_TYPE_F64"; + case GRUNSTABLE_TYPE_STR: + return "GRUNSTABLE_TYPE_STR"; + } + GR_INTERNAL_UNREACHABLE_ERROR(); +} + +inline std::optional safe_type_enum_cast(long long val) { + if (static_cast(GRUNSTABLE_TYPE_F64) == val) { + return std::make_optional(GRUNSTABLE_TYPE_F64); + } else if (static_cast(GRUNSTABLE_TYPE_STR) == val) { + return std::make_optional(GRUNSTABLE_TYPE_STR); + } else { + return std::nullopt; + } +} + +/// A helper function that is used to help implement PrintTo for +/// ExpectedRateProperties and RateProperties +template +void print_standard_props_(const T& props, std::ostream* os) { + *os << "shape={"; + for (std::size_t i = 0; i < props.shape.size(); i++) { + if (i != 0) { + *os << ", "; + } + *os << props.shape[i]; + } + *os << "}, dtype=" << stringify_type(props.dtype) + << ", writable=" << props.writable; +} + +/// summarizes details about rate properties +struct RateProperties { + std::vector shape; + std::size_t maxitemsize; + enum grunstable_types dtype; + bool writable; + + long long n_items() const { + long long n_items = 1LL; + for (std::size_t i = 0; i < shape.size(); i++) { + n_items *= shape[i]; + } + return n_items; // this is correct even for scalars + } + + /// teach googletest how to print this type + friend void PrintTo(const RateProperties& props, std::ostream* os) { + *os << "RateProperties{"; + print_standard_props_(props, os); + *os << ", maxitemsize=" << props.maxitemsize << '}'; + } +}; + +/// analogous to RateProperties, but it doesn't have the maxitemsize member +/// +/// The premise is that you construct this to express expectations since you +/// can't know the maxitemsize for an arbitrary array of strings +/// +/// @todo +/// This is an ugly kludge. We may want to replace this with some kind of +/// custom "matcher"... +struct ExpectedRateProperties { + std::vector shape; + enum grunstable_types dtype; + bool writable; + + /// teach googletest how to print this type + friend void PrintTo(const ExpectedRateProperties& props, std::ostream* os) { + *os << "ExpectedRateProperties{"; + print_standard_props_(props, os); + *os << '}'; + } +}; + +inline bool operator==(const RateProperties& a, const RateProperties& b) { + return a.maxitemsize == b.maxitemsize && a.shape == b.shape && + a.dtype == b.dtype && a.writable == b.writable; +} + +static bool has_appropriate_maxitemsize_(const RateProperties& props) { + switch (props.dtype) { + case GRUNSTABLE_TYPE_F64: + return props.maxitemsize == sizeof(double); + case GRUNSTABLE_TYPE_STR: + return true; + } + GR_INTERNAL_UNREACHABLE_ERROR(); +} + +inline bool operator==(const RateProperties& a, + const ExpectedRateProperties& b) { + return has_appropriate_maxitemsize_(a) && a.shape == b.shape && + a.dtype == b.dtype && a.writable == b.writable; +} + +inline bool operator==(const ExpectedRateProperties& a, + const RateProperties& b) { + return b == a; +} + +/// construct a RateProperties instance for the specified rate +/// +/// returns an empty optional if any there are any issues. To be clear, this +/// function shouldn't actually be used to test whether the property-querying +/// machinery works (it just tries to gracefully handle cases issues to avoid +/// distracting error-messages) +/// +/// @note +/// After we query each property, we encode an extra sanity-check. We **only** +/// encode this in case there are other underlying issues (so that we don't end +/// up with an extremely crazy set of errors). The Property tests should +/// generally provide more details about these tests. To be clear, user-code +/// should never need to include these sanity check! +inline std::optional try_query_RateProperties( + chemistry_data_storage* my_rates, grunstable_rateid_type rateid) { + long long ndim = -1LL; + if (grunstable_ratequery_prop(my_rates, rateid, GRUNSTABLE_QPROP_NDIM, + &ndim) != GR_SUCCESS) { + return std::nullopt; + } + if (ndim < 0LL) { + return std::nullopt; // sanity-check failed! + } + + std::vector shape; + if (ndim > 0LL) { + shape.assign(ndim, 0LL); + if (grunstable_ratequery_prop(my_rates, rateid, GRUNSTABLE_QPROP_SHAPE, + shape.data()) != GR_SUCCESS) { + return std::nullopt; + } + } + if (std::count_if(shape.begin(), shape.end(), + [](long long x) { return x <= 0; }) > 0) { + return std::nullopt; // sanity check failed! + } + + long long maxitemsize = -1LL; + if (grunstable_ratequery_prop(my_rates, rateid, GRUNSTABLE_QPROP_MAXITEMSIZE, + &maxitemsize) != GR_SUCCESS) { + return std::nullopt; + } + if (maxitemsize <= 0LL) { + return std::nullopt; // sanity check failed! + } + + long long dtype_tmp; + if (grunstable_ratequery_prop(my_rates, rateid, GRUNSTABLE_QPROP_DTYPE, + &dtype_tmp) != GR_SUCCESS) { + return std::nullopt; + } + std::optional dtype = safe_type_enum_cast(dtype_tmp); + if (!dtype.has_value()) { + return std::nullopt; // sanity check failed! + } + + long long writable; + if (grunstable_ratequery_prop(my_rates, rateid, GRUNSTABLE_QPROP_WRITABLE, + &writable) != GR_SUCCESS) { + return std::nullopt; + } + if ((writable != 0LL) && (writable != 1LL)) { + return std::nullopt; + } + + return {RateProperties{shape, static_cast(maxitemsize), + dtype.value(), static_cast(writable)}}; +} + +} // namespace grtest + +#endif // GRTESTUTILS_RATEQUERY_UTILS_HPP diff --git a/tests/unit/test_api_ratequery.cpp b/tests/unit/test_api_ratequery.cpp index 9c0ff2c6a..8ae567571 100644 --- a/tests/unit/test_api_ratequery.cpp +++ b/tests/unit/test_api_ratequery.cpp @@ -21,6 +21,7 @@ #include #include #include "grtestutils/iterator_adaptor.hpp" +#include "grtestutils/ratequery.hpp" #include "grtestutils/googletest/assertions.hpp" #include "grtestutils/googletest/fixtures.hpp" @@ -28,11 +29,6 @@ #include "inject_model/raw_data.hpp" // grackle::impl::inj_model_input::N_Injection_Pathways #include "status_reporting.h" -/// returns the rateid used to denote invalid rate names -grunstable_rateid_type get_invalid_rateid(const grtest::GrackleCtxPack& pack) { - return grunstable_ratequery_id(pack.my_rates(), nullptr); -} - using SimpleRateQueryTest = grtest::ConfigPresetFixture; @@ -54,7 +50,7 @@ TEST_F(SimpleRateQueryTest, IthRateChecks) { TEST_F(SimpleRateQueryTest, EmptyNameQuery) { grunstable_rateid_type rateid = grunstable_ratequery_id(pack.my_rates(), ""); - EXPECT_EQ(rateid, get_invalid_rateid(pack)); + EXPECT_EQ(rateid, grtest::get_invalid_rateid(pack)); } TEST_F(SimpleRateQueryTest, InvalidNameQuery) { @@ -68,42 +64,6 @@ TEST_F(SimpleRateQueryTest, InvalidNameQuery) { // tests themselves as easy to read as possible, we implate a C++-style // iterator to wrap part of the interface -std::string stringify_prop_kind(enum grunstable_ratequery_prop_kind kind) { - switch (kind) { - case GRUNSTABLE_QPROP_NDIM: - return "GRUNSTABLE_QPROP_NDIM"; - case GRUNSTABLE_QPROP_SHAPE: - return "GRUNSTABLE_QPROP_SHAPE"; - case GRUNSTABLE_QPROP_MAXITEMSIZE: - return "GRUNSTABLE_QPROP_MAXITEMSIZE"; - case GRUNSTABLE_QPROP_WRITABLE: - return "GRUNSTABLE_QPROP_WRITABLE"; - case GRUNSTABLE_QPROP_DTYPE: - return "GRUNSTABLE_QPROP_DTYPE"; - } - GR_INTERNAL_UNREACHABLE_ERROR(); -} - -std::string stringify_type(enum grunstable_types kind) { - switch (kind) { - case GRUNSTABLE_TYPE_F64: - return "GRUNSTABLE_TYPE_F64"; - case GRUNSTABLE_TYPE_STR: - return "GRUNSTABLE_TYPE_STR"; - } - GR_INTERNAL_UNREACHABLE_ERROR(); -} - -std::optional safe_type_enum_cast(long long val) { - if (static_cast(GRUNSTABLE_TYPE_F64) == val) { - return std::make_optional(GRUNSTABLE_TYPE_F64); - } else if (static_cast(GRUNSTABLE_TYPE_STR) == val) { - return std::make_optional(GRUNSTABLE_TYPE_STR); - } else { - return std::nullopt; - } -} - /// return a vector of some invalid rateids std::vector invalid_rateids( grtest::GrackleCtxPack& pack) { @@ -148,11 +108,12 @@ TEST_F(SimpleRateQueryTest, PropertyInvalidRateID) { ASSERT_GR_ERR(grunstable_ratequery_prop(pack.my_rates(), invalid_id, kind, buf.data())) << "executed with invalid_id=" << invalid_id - << ", kind=" << stringify_prop_kind(kind); + << ", kind=" << grtest::stringify_prop_kind(kind); EXPECT_THAT(buf, testing::Each(testing::Eq(DEFAULT_VAL))) << "grunstable_ratequery_prop mutated the ptr even though it " << "reported a failure. It was called with an invalid id of " - << invalid_id << " and a kind of " << stringify_prop_kind(kind); + << invalid_id << " and a kind of " + << grtest::stringify_prop_kind(kind); } } } @@ -219,7 +180,8 @@ TEST_P(ParametrizedRateQueryTest, Property) { EXPECT_GR_SUCCESS(grunstable_ratequery_prop(pack.my_rates(), pair.id, GRUNSTABLE_QPROP_DTYPE, &tmp)) << "for " << pair; - std::optional dtype_maybe = safe_type_enum_cast(tmp); + std::optional dtype_maybe = + grtest::safe_type_enum_cast(tmp); if (!dtype_maybe.has_value()) { GTEST_FAIL() << "Error coercing " << tmp << ", the dtype for " << pair << ", to an enum value"; @@ -244,155 +206,6 @@ TEST_P(ParametrizedRateQueryTest, Property) { } } -/// A helper function that is used to help implement PrintTo for -/// ExpectedRateProperties and RateProperties -template -void print_standard_props_(const T& props, std::ostream* os) { - *os << "shape={"; - for (std::size_t i = 0; i < props.shape.size(); i++) { - if (i != 0) { - *os << ", "; - } - *os << props.shape[i]; - } - *os << "}, dtype=" << stringify_type(props.dtype) - << ", writable=" << props.writable; -} - -/// summarizes details about rate properties -struct RateProperties { - std::vector shape; - std::size_t maxitemsize; - enum grunstable_types dtype; - bool writable; - - long long n_items() const { - long long n_items = 1LL; - for (std::size_t i = 0; i < shape.size(); i++) { - n_items *= shape[i]; - } - return n_items; // this is correct even for scalars - } - - /// teach googletest how to print this type - friend void PrintTo(const RateProperties& props, std::ostream* os) { - *os << "RateProperties{"; - print_standard_props_(props, os); - *os << ", maxitemsize=" << props.maxitemsize << '}'; - } -}; - -/// analogous to RateProperties, but it doesn't have the maxitemsize member -/// -/// The premise is that you construct this to express expectations since you -/// can't know the maxitemsize for an arbitrary array of strings -/// -/// @todo -/// This is an ugly kludge. We may want to replace this with some kind of -/// custom "matcher"... -struct ExpectedRateProperties { - std::vector shape; - enum grunstable_types dtype; - bool writable; - - /// teach googletest how to print this type - friend void PrintTo(const ExpectedRateProperties& props, std::ostream* os) { - *os << "ExpectedRateProperties{"; - print_standard_props_(props, os); - *os << '}'; - } -}; - -bool operator==(const RateProperties& a, const RateProperties& b) { - return a.maxitemsize == b.maxitemsize && a.shape == b.shape && - a.dtype == b.dtype && a.writable == b.writable; -} - -static bool has_appropriate_maxitemsize_(const RateProperties& props) { - switch (props.dtype) { - case GRUNSTABLE_TYPE_F64: - return props.maxitemsize == sizeof(double); - case GRUNSTABLE_TYPE_STR: - return true; - } - GR_INTERNAL_UNREACHABLE_ERROR(); -} - -bool operator==(const RateProperties& a, const ExpectedRateProperties& b) { - return has_appropriate_maxitemsize_(a) && a.shape == b.shape && - a.dtype == b.dtype && a.writable == b.writable; -} - -bool operator==(const ExpectedRateProperties& a, const RateProperties& b) { - return b == a; -} - -/// construct a RateProperties instance for the specified rate -/// -/// returns an empty optional if any there are any issues -/// -/// @note -/// After we query each property, we encode an extra sanity-check. We **only** -/// encode this in case there are other underlying issues (so that we don't end -/// up with an extremely crazy set of errors). The Property tests should -/// generally provide more details about these tests. To be clear, user-code -/// should never need to include these sanity check! -std::optional try_query_RateProperties( - chemistry_data_storage* my_rates, grunstable_rateid_type rateid) { - long long ndim = -1LL; - if (grunstable_ratequery_prop(my_rates, rateid, GRUNSTABLE_QPROP_NDIM, - &ndim) != GR_SUCCESS) { - return std::nullopt; - } - if (ndim < 0LL) { - return std::nullopt; // sanity-check failed! - } - - std::vector shape; - if (ndim > 0LL) { - shape.assign(ndim, 0LL); - if (grunstable_ratequery_prop(my_rates, rateid, GRUNSTABLE_QPROP_SHAPE, - shape.data()) != GR_SUCCESS) { - return std::nullopt; - } - } - if (std::count_if(shape.begin(), shape.end(), - [](long long x) { return x <= 0; }) > 0) { - return std::nullopt; // sanity check failed! - } - - long long maxitemsize = -1LL; - if (grunstable_ratequery_prop(my_rates, rateid, GRUNSTABLE_QPROP_MAXITEMSIZE, - &maxitemsize) != GR_SUCCESS) { - return std::nullopt; - } - if (maxitemsize <= 0LL) { - return std::nullopt; // sanity check failed! - } - - long long dtype_tmp; - if (grunstable_ratequery_prop(my_rates, rateid, GRUNSTABLE_QPROP_DTYPE, - &dtype_tmp) != GR_SUCCESS) { - return std::nullopt; - } - std::optional dtype = safe_type_enum_cast(dtype_tmp); - if (!dtype.has_value()) { - return std::nullopt; // sanity check failed! - } - - long long writable; - if (grunstable_ratequery_prop(my_rates, rateid, GRUNSTABLE_QPROP_WRITABLE, - &writable) != GR_SUCCESS) { - return std::nullopt; - } - if ((writable != 0LL) && (writable != 1LL)) { - return std::nullopt; - } - - return {RateProperties{shape, static_cast(maxitemsize), - dtype.value(), static_cast(writable)}}; -} - // returns a value that differs from the input static double remap_value(double in) { if (in == 0.0 || !std::isfinite(in)) { @@ -408,14 +221,14 @@ TEST_P(ParametrizedRateQueryTest, SetAndGet) { // iterate over every known (rate-name, rate-id) pair for (const grtest::NameIdPair pair : grtest::RateQueryRange(pack)) { // get the properties associated with the current rate - std::optional maybe_props = - try_query_RateProperties(pack.my_rates(), pair.id); + std::optional maybe_props = + grtest::try_query_RateProperties(pack.my_rates(), pair.id); if (!maybe_props.has_value()) { GTEST_FAIL() << "something went wrong while trying to lookup the properties for " << "the " << pair << " rate."; } - RateProperties props = maybe_props.value(); + grtest::RateProperties props = maybe_props.value(); long long n_items = props.n_items(); if (!props.writable) { @@ -485,8 +298,9 @@ static long long get_n_inj_pathways(const chemistry_data* my_chemistry) { } }; -static ExpectedRateProperties RateProperties_from_RateKind( +static grtest::ExpectedRateProperties RateProperties_from_RateKind( const chemistry_data* my_chemistry, RateKind kind) { + using grtest::ExpectedRateProperties; const enum grunstable_types f64dtype = GRUNSTABLE_TYPE_F64; const enum grunstable_types strdtype = GRUNSTABLE_TYPE_STR; @@ -578,18 +392,18 @@ TEST_F(KnownRateQueryTest, CheckProperties) { continue; // the rateid is **NOT** in known_rate_map } // construct the expected properties - ExpectedRateProperties expected_props = + grtest::ExpectedRateProperties expected_props = RateProperties_from_RateKind(pack.my_chemistry(), search->second); // load the actual props - std::optional maybe_actual_props = - try_query_RateProperties(pack.my_rates(), pair.id); + std::optional maybe_actual_props = + grtest::try_query_RateProperties(pack.my_rates(), pair.id); if (!maybe_actual_props.has_value()) { GTEST_FAIL() << "something went wrong while trying to lookup the properties for " << "the " << pair << " rate."; } - RateProperties actual_props = maybe_actual_props.value(); + grtest::RateProperties actual_props = maybe_actual_props.value(); EXPECT_EQ(expected_props, actual_props) << "this mismatch in the queried properties is for the " << pair From c36c4e714eea4806e69406a9cf7bf57e6672ee0b Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Tue, 30 Dec 2025 11:11:33 -0500 Subject: [PATCH 157/175] add a basic test for querying arrays of strings --- tests/unit/test_api_ratequery.cpp | 85 +++++++++++++++++++++++++++++-- 1 file changed, 82 insertions(+), 3 deletions(-) diff --git a/tests/unit/test_api_ratequery.cpp b/tests/unit/test_api_ratequery.cpp index 8ae567571..c164f62c3 100644 --- a/tests/unit/test_api_ratequery.cpp +++ b/tests/unit/test_api_ratequery.cpp @@ -11,6 +11,7 @@ //===----------------------------------------------------------------------===// #include // std::min, std::max +#include #include #include #include @@ -206,6 +207,81 @@ TEST_P(ParametrizedRateQueryTest, Property) { } } +// This test case performs basic sanity checks when it comes to querying arrays +// of strings (this doesn't really care whether the queried values are correct) +// +// note: this test isn't currently part of the parameterized suite since some +// presets don't have any queryable arrays of strings (at least at the +// time of writing) +TEST_F(SimpleRateQueryTest, GetStr) { + std::vector char_buffer; + std::vector str_buffer; + + bool any_str = false; + + // iterate over every known (rate-name, rate-id) pair + for (const grtest::NameIdPair pair : grtest::RateQueryRange(pack)) { + // get the properties associated with the current rate + std::optional maybe_props = + grtest::try_query_RateProperties(pack.my_rates(), pair.id); + if (!maybe_props.has_value()) { + GTEST_FAIL() + << "something went wrong while trying to lookup the properties for " + << "the " << pair << " rate."; + } + grtest::RateProperties props = maybe_props.value(); + if (props.dtype != GRUNSTABLE_TYPE_STR) { + continue; + } + any_str = true; // <- record that we have seen a string + + // the following check probably won't ever change + ASSERT_LT(props.shape.size(), 2) + << pair << " appears to correspond to a multi-dimensional array of " + << "strings"; + + // we may need to remove the following check + EXPECT_NE(props.shape.size(), 0) + << pair << " appears to correspond to a single scalar string"; + + ASSERT_GT(props.n_items(), 0LL) << "for " << pair; + std::size_t n_strings = static_cast(props.n_items()); + + // set up the buffers for loading the data + // -> (we allocate more memory than necessary) + std::size_t bytes_per_str = props.maxitemsize; + constexpr char DUMMY_CHAR = '}'; + char_buffer.assign(bytes_per_str * n_strings, DUMMY_CHAR); + str_buffer.clear(); + for (std::size_t i = 0; i < n_strings; i++) { + str_buffer.push_back(char_buffer.data() + i * bytes_per_str); + } + + ASSERT_GR_SUCCESS(grunstable_ratequery_get_str(pack.my_rates(), pair.id, + str_buffer.data())) + << "for " << pair; + + std::size_t max_strlen = 0; + for (std::size_t i = 0; i < n_strings; i++) { + ASSERT_NE(str_buffer[i][0], DUMMY_CHAR) + << "nothing wasn't written for index " << i << " of the string " + << "array associated with " << pair; + std::size_t cur_strlen = std::strlen(str_buffer[i]); + EXPECT_GT(cur_strlen, 0) + << "The element at index " << i << " of the string array, associated " + << "with " << pair << ", is an empty string."; + max_strlen = std::max(max_strlen, cur_strlen); + } + EXPECT_EQ(max_strlen + 1, bytes_per_str) + << "The queried maxitemsize for " << pair << "doesn't match the " + << "maximum number of bytes per string. Strictly speaking, this " + << "doesn't violate any API guarantees, but it would be nice to " + << "avoid wasting memory."; + } + + ASSERT_TRUE(any_str) << "no string keys were encountered for the preset"; +} + // returns a value that differs from the input static double remap_value(double in) { if (in == 0.0 || !std::isfinite(in)) { @@ -214,7 +290,9 @@ static double remap_value(double in) { return -in; } -TEST_P(ParametrizedRateQueryTest, SetAndGet) { +// This test case performs basic sanity checks when it comes to querying arrays +// of double-precision values +TEST_P(ParametrizedRateQueryTest, SetAndGetF64) { std::vector initial_buf; std::vector post_update_buf; @@ -229,12 +307,13 @@ TEST_P(ParametrizedRateQueryTest, SetAndGet) { << "the " << pair << " rate."; } grtest::RateProperties props = maybe_props.value(); - long long n_items = props.n_items(); - if (!props.writable) { + if (!props.writable || props.dtype != GRUNSTABLE_TYPE_F64) { continue; } + long long n_items = props.n_items(); + // load in data associated with the current rate initial_buf.assign(n_items, NAN); ASSERT_GR_SUCCESS(grunstable_ratequery_get_f64(pack.my_rates(), pair.id, From 019cb0af2b753899d743bd3ecc4b1ee35ec3e3cd Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 31 Dec 2025 15:06:37 -0500 Subject: [PATCH 158/175] add some tests of queryable injection-pathway data --- tests/grtestutils/CMakeLists.txt | 1 + tests/grtestutils/googletest/assertions.hpp | 4 + tests/grtestutils/googletest/matchers.hpp | 84 +++++++++++ tests/grtestutils/preset.cpp | 16 +- tests/grtestutils/preset.hpp | 1 + tests/grtestutils/ratequery.hpp | 122 ++++++++++++++- tests/grtestutils/utils.hpp | 27 ++++ tests/unit/.clang-tidy | 15 ++ tests/unit/CMakeLists.txt | 3 +- tests/unit/test_inject_pathway.cpp | 159 ++++++++++++++++++++ 10 files changed, 427 insertions(+), 5 deletions(-) create mode 100644 tests/grtestutils/googletest/matchers.hpp create mode 100644 tests/unit/.clang-tidy create mode 100644 tests/unit/test_inject_pathway.cpp diff --git a/tests/grtestutils/CMakeLists.txt b/tests/grtestutils/CMakeLists.txt index 8bbd5a6bf..4397bd23e 100644 --- a/tests/grtestutils/CMakeLists.txt +++ b/tests/grtestutils/CMakeLists.txt @@ -90,6 +90,7 @@ add_library(grtestutils googletest/assertions.hpp googletest/check_allclose.hpp googletest/fixtures.hpp + googletest/matchers.hpp ) target_link_libraries(grtestutils diff --git a/tests/grtestutils/googletest/assertions.hpp b/tests/grtestutils/googletest/assertions.hpp index 14177d7d8..0b29d7adf 100644 --- a/tests/grtestutils/googletest/assertions.hpp +++ b/tests/grtestutils/googletest/assertions.hpp @@ -12,6 +12,7 @@ #ifndef GRTEST_GOOGLETEST_ASSERTIONS_HPP #define GRTEST_GOOGLETEST_ASSERTIONS_HPP +#include #include #include @@ -67,4 +68,7 @@ inline testing::AssertionResult IsGRError(const char* expr1, int val1) { #define ASSERT_GR_ERR(expr) ASSERT_PRED_FORMAT1(::grtest::IsGRError, expr) +/// applies to a std::optional +#define ASSERT_NOT_EMPTY(expr) ASSERT_NE(expr, std::nullopt) + #endif // GRTEST_GOOGLETEST_ASSERTIONS_HPP diff --git a/tests/grtestutils/googletest/matchers.hpp b/tests/grtestutils/googletest/matchers.hpp new file mode 100644 index 000000000..16f7f0fe5 --- /dev/null +++ b/tests/grtestutils/googletest/matchers.hpp @@ -0,0 +1,84 @@ +//===----------------------------------------------------------------------===// +// +// See the LICENSE file for license and copyright information +// SPDX-License-Identifier: NCSA AND BSD-3-Clause +// +//===----------------------------------------------------------------------===// +/// +/// @file Define custom matchers +/// +//===----------------------------------------------------------------------===// +#ifndef GRTESTUTILS_GOOGLETEST_MATCHERS_HPP +#define GRTESTUTILS_GOOGLETEST_MATCHERS_HPP + +#include +#include + +namespace grtest { + +/// Implements the polymorphic IsUnique matcher +/// +/// This can be used as a Matcher as long as T is a container (like +/// std::vector or std::string) that defines: +/// - the T::begin() and T::end() member functions +/// - the T::const_iterator member type +/// - the T::value_type member type +/// +/// @note +/// The implementation is modelled on the way that gmock implements matchers +/// for C++ standard library containers +/// +/// @todo +/// Currently, there is an additional implicit requirement that the elements +/// are copy-constructible. If we want a more general implementation, we should +/// consider using std::reference_wrapper +class HoldsUniqueMatcher { +public: + template + bool MatchAndExplain(const MatcheeContainerType& c, + ::testing::MatchResultListener* listener) const { + typename MatcheeContainerType::const_iterator it = c.begin(); + typename MatcheeContainerType::const_iterator last = c.end(); + + using val_type = typename MatcheeContainerType::value_type; + std::set set; + + for (; it != last; ++it) { + auto insertion_result = set.emplace(*it); + if (!insertion_result.second) { + *listener << "who contains at least 2 occurrences of the element, " + << *it; + return false; + } + } + return true; + } + + // Describes what this matcher matches. + void DescribeTo(std::ostream* os) const { *os << "contains unique elements"; } + + void DescribeNegationTo(std::ostream* os) const { + *os << "contains more than one occurrence of an element"; + } +}; + +/// Matches an STL-style container that holds unique values +/// +/// @par Example +/// In the following example, each call to `EXPECT_THAT` should pass +/// @code{.cpp} +/// std::vector v; +/// EXPECT_THAT(v, grtest::HoldsUnique()); +/// v.push_back(1); +/// v.push_back(3); +/// EXPECT_THAT(v, grtest::HoldsUnique()); +/// v.push_back(1); +/// EXPECT_THAT(v, ::testing::Not(grtest::HoldsUnique())); +/// @endcode +inline testing::PolymorphicMatcher HoldsUnique() { + return testing::MakePolymorphicMatcher(HoldsUniqueMatcher()); +} + +} // namespace grtest + +#endif // GRTESTUTILS_GOOGLETEST_MATCHERS_HPP diff --git a/tests/grtestutils/preset.cpp b/tests/grtestutils/preset.cpp index 53f3a64e3..67dc1da77 100644 --- a/tests/grtestutils/preset.cpp +++ b/tests/grtestutils/preset.cpp @@ -27,7 +27,9 @@ static std::string to_string(const grtest::ChemPreset& preset) { case grtest::ChemPreset::primchem3: return "pc=3"; case grtest::ChemPreset::primchem4_dustspecies3: - return "pc=3-dust_species=4"; + return "pc=4-dust_species=3"; + case grtest::ChemPreset::primchem4_dustspecies3_allinjectpaths: + return "pc=4-dust_species=3-multi_metals=1"; } GR_INTERNAL_UNREACHABLE_ERROR(); @@ -74,8 +76,18 @@ grtest::InitStatus grtest::setup_chemistry_data_from_preset( my_chem->primordial_chemistry = 4; my_chem->dust_chemistry = 1; my_chem->metal_chemistry = 1; - my_chem->dust_species = 1; + my_chem->dust_species = 3; my_chem->use_dust_density_field = 1; + my_chem->multi_metals = 0; + return InitStatus::success; + } + case ChemPreset::primchem4_dustspecies3_allinjectpaths: { + my_chem->primordial_chemistry = 4; + my_chem->dust_chemistry = 1; + my_chem->metal_chemistry = 1; + my_chem->dust_species = 3; + my_chem->use_dust_density_field = 1; + my_chem->multi_metals = 1; return InitStatus::success; } } diff --git a/tests/grtestutils/preset.hpp b/tests/grtestutils/preset.hpp index 738a79dad..0bc1d2e71 100644 --- a/tests/grtestutils/preset.hpp +++ b/tests/grtestutils/preset.hpp @@ -36,6 +36,7 @@ enum class ChemPreset { primchem2, primchem3, primchem4_dustspecies3, + primchem4_dustspecies3_allinjectpaths, }; /// override the settings of my_chem based on the specified preset diff --git a/tests/grtestutils/ratequery.hpp b/tests/grtestutils/ratequery.hpp index b09886c98..aa714c9a4 100644 --- a/tests/grtestutils/ratequery.hpp +++ b/tests/grtestutils/ratequery.hpp @@ -16,6 +16,7 @@ #include "status_reporting.h" #include +#include #include #include #include @@ -23,9 +24,14 @@ namespace grtest { /// returns the rateid used to denote invalid rate names +inline grunstable_rateid_type get_invalid_rateid( + const chemistry_data_storage* my_rates) { + return grunstable_ratequery_id(my_rates, nullptr); +} + inline grunstable_rateid_type get_invalid_rateid( const grtest::GrackleCtxPack& pack) { - return grunstable_ratequery_id(pack.my_rates(), nullptr); + return get_invalid_rateid(pack.my_rates()); } inline std::string stringify_prop_kind( @@ -152,7 +158,7 @@ inline bool operator==(const ExpectedRateProperties& a, /// construct a RateProperties instance for the specified rate /// -/// returns an empty optional if any there are any issues. To be clear, this +/// returns an empty optional if any there are any issues. to be clear, this /// function shouldn't actually be used to test whether the property-querying /// machinery works (it just tries to gracefully handle cases issues to avoid /// distracting error-messages) @@ -219,6 +225,118 @@ inline std::optional try_query_RateProperties( dtype.value(), static_cast(writable)}}; } +/// A convenience function to try to query a 1d array of strings +/// +/// returns an empty optional if any there are any issues. to be clear, this +/// function shouldn't actually be used to test the ratequiery API machinery, +/// itself. It's intended to be used to query that queried strings hold +/// expected values or as a building-block in more sophisticated calculations. +inline std::optional> try_query_str_arr1d( + chemistry_data_storage* my_rates, std::string name) { + grunstable_rateid_type id = grunstable_ratequery_id(my_rates, name.c_str()); + if (id == get_invalid_rateid(my_rates)) { + return std::nullopt; + } + + std::optional props_maybe = + try_query_RateProperties(my_rates, id); + if (!props_maybe.has_value()) { + return std::nullopt; + } + RateProperties props = props_maybe.value(); + + if ((props.shape.size() != 1) || props.dtype != GRUNSTABLE_TYPE_STR) { + return std::nullopt; + } + + // allocate output storage + std::size_t bytes_per_string = props.maxitemsize; + std::size_t max_chars_per_string = bytes_per_string - 1; + std::size_t n_strings = static_cast(props.n_items()); + // NOTE: C++ standards older than C++17 can't directly write to strings + // without triggering undefined behavior + std::vector out_arr; + out_arr.reserve(n_strings); + for (std::size_t i = 0; i < n_strings; i++) { + out_arr.emplace_back(max_chars_per_string, '\0'); + } + + // now, we are actually going to make the query + // WARNING: do NOT touch `out_arr` until after we are done with this. + // Otherwise, undefined behavior may arise since std::string may (must?) be + // implemented using the "small-string optimization" (SSO). + // -> for context, most standard library C++ containers (e.g. std::vector) + // are implemented as a class/struct with 3 data-members: + // 1. a pointer to heap-memory that is the storage for contained items + // 2. the container's current size + // 3. the container's current capacity + // -> SSO is the idea that sufficiently small strings may directly embed the + // stored elements as part of the struct/class as long as the total size + // of the struct/class doesn't exceed the size of the container's required + // members (outlined above) + // -> this is helpful since it avoids needless heap-allocations + // -> issues arise for us when `bytes_per_string` is small enough to take + // advantage of the SSO. In this scenario, the characters of the strings + // are being tracked as part of the storage allocating by `out_arr`. If we + // do something (e.g. append an element) that causes `out_arr` to + // reallocate its storage pointer, then the pointers in tmp_buf would be + // invalidated + { + // set up the buffer to actually pass to Grackle + std::vector tmp_buf; + tmp_buf.reserve(n_strings); + for (std::size_t i = 0; i < n_strings; i++) { + tmp_buf.push_back(out_arr[i].data()); + } + + if (grunstable_ratequery_get_str(my_rates, id, tmp_buf.data()) != + GR_SUCCESS) { + return std::nullopt; + } + } + + // since we allocated more memory than was necessary, let's resize each + // element in out_arr so it has the appropriate size + for (std::string& element : out_arr) { + element.resize(std::strlen(element.c_str())); + } + + return {out_arr}; +} + +/// A convenience function to try to query a 1d array of `double`s +/// +/// returns an empty optional if any there are any issues. to be clear, this +/// function shouldn't actually be used to test the ratequiery API machinery, +/// itself. It's intended to be used to query that queried strings hold +/// expected values or as a building-block in more sophisticated calculations. +inline std::optional> try_query_f64_arr1d( + chemistry_data_storage* my_rates, std::string name) { + grunstable_rateid_type id = grunstable_ratequery_id(my_rates, name.c_str()); + if (id == get_invalid_rateid(my_rates)) { + return std::nullopt; + } + + std::optional props_maybe = + try_query_RateProperties(my_rates, id); + if (!props_maybe.has_value()) { + return std::nullopt; + } + RateProperties props = props_maybe.value(); + + if ((props.shape.size() != 1) || props.dtype != GRUNSTABLE_TYPE_F64) { + return std::nullopt; + } + std::vector out_arr; + out_arr.assign(props.n_items(), -1.0); + if (grunstable_ratequery_get_f64(my_rates, id, out_arr.data()) != + GR_SUCCESS) { + return std::nullopt; + } + + return {out_arr}; +} + } // namespace grtest #endif // GRTESTUTILS_RATEQUERY_UTILS_HPP diff --git a/tests/grtestutils/utils.hpp b/tests/grtestutils/utils.hpp index 72e4e77fa..0ce3bd92c 100644 --- a/tests/grtestutils/utils.hpp +++ b/tests/grtestutils/utils.hpp @@ -5,9 +5,36 @@ #include #include +#include +#include namespace grtest { +/// Returns whether the `s` begins with the provided prefix +/// +/// @note +/// When we start using C++ 20, this can be replaced with the `starts_with` +/// member functions of `std::string` and `std::string_view` +inline bool starts_with(std::string_view s, std::string_view prefix) { +#if defined(__cpp_lib_starts_ends_with) && __cpp_lib_starts_ends_with >= 201711L + return s.starts_with(prefix); +#else + return s.substr(0, prefix.size()) == prefix; +#endif +} + +inline bool starts_with(std::string_view s, const char* prefix) { + return starts_with(s, std::string_view(prefix)); +} + +inline bool starts_with(const std::string& s, std::string_view prefix) { + return starts_with(std::string_view(s), prefix); +} + +inline bool starts_with(const std::string& s, const char* prefix) { + return starts_with(std::string_view(s), prefix); +} + /// this function records the desired standard datafile within the /// chemistry_data struct. It deals with the minutia of making sure that /// grackle can find the standardized data-file diff --git a/tests/unit/.clang-tidy b/tests/unit/.clang-tidy new file mode 100644 index 000000000..77e8e7968 --- /dev/null +++ b/tests/unit/.clang-tidy @@ -0,0 +1,15 @@ +# this file lets alter the checks that clang-tidy uses +# - by default, we inherit all checks (and options) from parent directories + + +# we modify the behavior of the bugprone-unchecked-optional-access check to +# allow usage of the `.value()` method without an explicit check for whether +# an optional contains a value +# - the primary motivation is that it's fairly verbose to check if an optional +# is empty (in a way that Googletest reports an error) without trigger this +# warning. Our policy is to continue checking before we access an optional, +# but if we ever forget, the worst that happens is that the test-case aborts +# with an error because an expection was raised. +# - maybe we can come up with a workaround involving a macro in the future? +CheckOptions: + bugprone-unchecked-optional-access.IgnoreValueCalls: true diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index e4e95bef1..4e4e3f5f9 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -29,7 +29,8 @@ gtest_discover_tests(runVisitorTests) # tests of the API functions # -> one might argue that these are better classified as integration or # end-to-end tests than as unit-test -add_executable(runApiTests test_ghost_zone.cpp test_api_ratequery.cpp) +add_executable(runApiTests + test_ghost_zone.cpp test_api_ratequery.cpp test_inject_pathway.cpp) target_link_libraries(runApiTests testdeps) gtest_discover_tests(runApiTests) diff --git a/tests/unit/test_inject_pathway.cpp b/tests/unit/test_inject_pathway.cpp new file mode 100644 index 000000000..9264e292e --- /dev/null +++ b/tests/unit/test_inject_pathway.cpp @@ -0,0 +1,159 @@ +//===----------------------------------------------------------------------===// +// +// See the LICENSE file for license and copyright information +// SPDX-License-Identifier: NCSA AND BSD-3-Clause +// +//===----------------------------------------------------------------------===// +/// +/// @file +/// Miscellaneous tests pertaining to the use of injection pathways +/// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include "grackle.h" +#include +#include "grtestutils/iterator_adaptor.hpp" +#include "grtestutils/preset.hpp" +#include "grtestutils/googletest/assertions.hpp" +#include "grtestutils/googletest/fixtures.hpp" +#include "grtestutils/googletest/matchers.hpp" +#include "grtestutils/ratequery.hpp" +#include "grtestutils/utils.hpp" // starts_with + +using namespace std::string_literals; // enables s-suffix for std::string + +using grtest::ChemPreset; +using grtest::FullConfPreset; +using grtest::InitialUnitPreset; + +const std::array CANONICAL_INJ_PATH_NAMES = { + "local_ISM", "ccsn13", "ccsn20", "ccsn25", "ccsn30", "fsn13", + "fsn15", "fsn50", "fsn80", "pisn170", "pisn200", "y19", +}; + +const std::string INJ_PATH_NAMES_KEY = "inject_model_names"s; +const std::string INJ_PATH_NUCLIDE_GAS_YIELD_PREFIX = + "inject_path_gas_yield_frac."s; +const std::string INJ_PATH_GRAIN_YIELD_PREFIX = + "inject_path_grain_yield_frac."s; + +using InjPathSuite = grtest::ParametrizedConfigPresetFixture; + +TEST_P(InjPathSuite, PathName) { + std::optional> str_list_maybe = + grtest::try_query_str_arr1d(pack.my_rates(), INJ_PATH_NAMES_KEY); + ASSERT_NOT_EMPTY(str_list_maybe) + << "error querying \"" << INJ_PATH_NAMES_KEY << '"'; + std::vector str_list = + std::exchange(str_list_maybe, std::nullopt).value(); + + EXPECT_THAT(str_list, grtest::HoldsUnique()); + EXPECT_THAT(str_list, ::testing::Not(::testing::IsEmpty())); + EXPECT_THAT(str_list, ::testing::IsSubsetOf(CANONICAL_INJ_PATH_NAMES)); +} + +TEST_P(InjPathSuite, Yields) { + std::optional> str_list_maybe = + grtest::try_query_str_arr1d(pack.my_rates(), INJ_PATH_NAMES_KEY); + ASSERT_NOT_EMPTY(str_list_maybe) + << "error querying \"" << INJ_PATH_NAMES_KEY << '"'; + std::vector str_list = + std::exchange(str_list_maybe, std::nullopt).value(); + + // ideally, we would verify that there is a yield for each kind of relevant + // nuclide or grain species, but there's no convenient way to do that (yet!) + // -> for now, lets just settle for checking the most common ones + std::array keys = {INJ_PATH_NUCLIDE_GAS_YIELD_PREFIX + "C", + INJ_PATH_GRAIN_YIELD_PREFIX + "AC_dust"}; + for (const std::string& key : keys) { + std::optional> dbl_arr_maybe = + grtest::try_query_f64_arr1d(pack.my_rates(), key); + ASSERT_NOT_EMPTY(dbl_arr_maybe) << "error querying \"" << key << '"'; + std::vector dbl_arr = + std::exchange(dbl_arr_maybe, std::nullopt).value(); + EXPECT_THAT(dbl_arr, ::testing::SizeIs(str_list.size())) + << "array associated with \"" << key << "\" should have the same " + << "length as the array associated with \"" << INJ_PATH_NAMES_KEY + << '"'; + } +} + +// Let's check the sum of all the yields +// - the total yield at an index i should satidfy 0<= total[i] <= 1 +// - this a very robust invariant that should be true for all injection pathway +// information shipped with Grackle +TEST_P(InjPathSuite, YieldSum) { + std::optional> str_list_maybe = + grtest::try_query_str_arr1d(pack.my_rates(), INJ_PATH_NAMES_KEY); + if (!str_list_maybe.has_value()) { + GTEST_FAIL() << "error querying \"" << INJ_PATH_NAMES_KEY << '"'; + } + std::vector str_list = + std::exchange(str_list_maybe, std::nullopt).value(); + + // define an inline function that returns a string describing the string + // associated with index i + auto describe_index = [&](std::size_t i) -> std::string { + return "in the current configuration, the index is associated with the \""s + + str_list[i] + "\" injection pathway"s; + }; + std::size_t n_pathways = str_list.size(); + + // sum up the total yields (for grain species & metal nuclides in gas phase) + // Reminders: we track yields for each injection pathway + std::vector totals(str_list.size(), 0.0); + + int n_gas_nuclide_yields = 0; + int n_grain_yields = 0; + for (const grtest::NameIdPair pair : grtest::RateQueryRange(pack)) { + const char* descr = nullptr; + if (grtest::starts_with(pair.name, INJ_PATH_NUCLIDE_GAS_YIELD_PREFIX)) { + descr = "gas-phase metal nuclide yield fractions"; + n_gas_nuclide_yields++; + } else if (grtest::starts_with(pair.name, INJ_PATH_GRAIN_YIELD_PREFIX)) { + descr = "grain-species yield fractions"; + n_grain_yields++; + } else { + continue; + } + std::optional> dbl_arr_maybe = + grtest::try_query_f64_arr1d(pack.my_rates(), pair.name); + ASSERT_NOT_EMPTY(dbl_arr_maybe) << "error querying \"" << pair.name << '"'; + const std::vector dbl_arr = + std::exchange(dbl_arr_maybe, std::nullopt).value(); + for (std::size_t i = 0; i < n_pathways; i++) { + EXPECT_THAT(dbl_arr[i], + ::testing::AllOf(::testing::Ge(0.0), ::testing::Le(1.0))) + << "the array of " << descr << ", corresponding to the \"" + << pair.name << "\" key, has an invalid value at index " << i << " (" + << describe_index(i) << ')'; + totals[i] += dbl_arr[i]; + } + } + + for (std::size_t i = 0; i < n_pathways; i++) { + EXPECT_THAT(totals[i], ::testing::AnyOf(::testing::Lt(1.0), + ::testing::DoubleNear(1.0, 4e-7))) + << "the sum of each yield fractions (i.e. fraction of all injected " + << "non-primordial material) for all relevant grain-species and all " + << "the gas-phase components of all relevant metal nuclides has an " + << "invalid value at index " << i << " (" << describe_index(i) << ')'; + } + + EXPECT_GT(n_gas_nuclide_yields, 0) + << "no keys were encountered for gas-phase metal nuclide yield fractions"; + EXPECT_GT(n_grain_yields, 0) + << "no keys were encountered for n_gas_nuclide_yields"; +} + +INSTANTIATE_TEST_SUITE_P( + /* 1st arg is intentionally empty */, InjPathSuite, + ::testing::Values(FullConfPreset{ChemPreset::primchem4_dustspecies3, + InitialUnitPreset::simple_z0}, + FullConfPreset{ + ChemPreset::primchem4_dustspecies3_allinjectpaths, + InitialUnitPreset::simple_z0})); From 49e263a6c536ea68b70dffbf6fab2f3022475eef Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 31 Dec 2025 15:57:32 -0500 Subject: [PATCH 159/175] use weakref to make _rate_mapping_access marginally safer --- src/python/gracklepy/grackle_wrapper.pyx | 31 +++++++++++++++++++----- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/python/gracklepy/grackle_wrapper.pyx b/src/python/gracklepy/grackle_wrapper.pyx index c199ddbb4..2a3d3808d 100644 --- a/src/python/gracklepy/grackle_wrapper.pyx +++ b/src/python/gracklepy/grackle_wrapper.pyx @@ -12,6 +12,7 @@ ######################################################################## import copy +import weakref import sys from gracklepy.utilities.physical_constants import \ boltzmann_constant_cgs, \ @@ -72,9 +73,12 @@ cdef class chemistry_data: # backwards compatibility) cdef object data_copy_from_init + # ensure that weak references can be made to instances of this type + cdef object __weakref__ + def __cinit__(self): self.data = _wrapped_c_chemistry_data() - self._rate_map = _rate_mapping_access.from_ptr(&self.rates) + self._rate_map = _rate_mapping_access.from_ptr(&self.rates, weakref.ref(self)) self.data_copy_from_init = None cdef void _try_uninitialize(self): @@ -1091,6 +1095,15 @@ cdef class _rate_mapping_access: cdef c_chemistry_data_storage *_ptr cdef dict _cached_name_rateid_map + # holds an object returned by weakref.ref that was called on the object + # that owns the wrapped _ptr. + # -> this is tracked purely as a safety mechanism to ensure that we won't + # try to access a dangling pointer (to guard against programming mistakes + # within the python module) + # -> if we are extremely concerned about performance, we can probably remove + # this attribute + cdef object _parent_weakref + def __cinit__(self): self._ptr = NULL self._cached_name_rateid_map = None @@ -1100,7 +1113,8 @@ cdef class _rate_mapping_access: raise TypeError("This class cannot be instantiated directly.") @staticmethod - cdef _rate_mapping_access from_ptr(c_chemistry_data_storage *ptr): + cdef _rate_mapping_access from_ptr(c_chemistry_data_storage *ptr, + object parent_weakref): """ Construct a _rate_mapping_access instance from the provided pointer """ @@ -1108,16 +1122,22 @@ cdef class _rate_mapping_access: _rate_mapping_access ) out._ptr = ptr + out._parent_weakref = parent_weakref return out @property def _name_rateid_map(self): """returns a mapping between rate names and rate id""" - if self._cached_name_rateid_map is not None: + parent_weakref = self._parent_weakref + if parent_weakref() is None: + raise RuntimeError( + "this appears to be a dangling instance. Access to rates " + "can't be provided when the parent has been garbage collected" + ) + elif self._cached_name_rateid_map is not None: return self._cached_name_rateid_map - - if self._ptr is NULL: + elif self._ptr is NULL: raise RuntimeError( "this instance hasn't been configured with a pointer for it " "access retrieve data from" @@ -1264,7 +1284,6 @@ cdef class _rate_mapping_access: def __len__(self): return len(self._name_rateid_map) - def _query_units(chemistry_data chem_data, object name, object current_a_value): """ From 721c0d001fc0d1efba14ce9f5b2a86a2ec690462 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 31 Dec 2025 16:01:30 -0500 Subject: [PATCH 160/175] minor bugfix --- src/python/gracklepy/grackle_wrapper.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/python/gracklepy/grackle_wrapper.pyx b/src/python/gracklepy/grackle_wrapper.pyx index 2a3d3808d..4447927ca 100644 --- a/src/python/gracklepy/grackle_wrapper.pyx +++ b/src/python/gracklepy/grackle_wrapper.pyx @@ -1028,7 +1028,7 @@ cdef list rateq_load_string( # (by definition, the max value represented by Py_ssize_t uses 1 less bit of # storage than SIZE_MAX) cdef Py_ssize_t max_alloc_size = sys.maxsize # sys.maxsize is max val of Py_ssize_t - if (max_alloc_size / bytes_per_string) > n_items: + if (max_alloc_size / bytes_per_string) < n_items: raise RuntimeError(f"{key=} requires too much memory to load") # allocate memory @@ -1045,7 +1045,7 @@ cdef list rateq_load_string( raise RuntimeError(f"Error retrieving data for the \"{key}\" key") for i in range(n_items): - out.append((str_storage[i]).decode("ASCII")) + out.append((str_array[i]).decode("ASCII")) finally: free(str_array) free(str_storage) From 61564aa34bb15d4b7e2b9cbafd36fc8a5b68fc06 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 31 Dec 2025 17:11:34 -0500 Subject: [PATCH 161/175] Refactor fluid_container to query list of possible inject_pathways This is an important step in order to generalize for modelling arbitrary injection pathway names. --- src/python/gracklepy/fluid_container.py | 50 ++++++++++++------- src/python/gracklepy/grackle_wrapper.pyx | 5 +- src/python/gracklepy/utilities/convenience.py | 39 ++++++++++----- 3 files changed, 62 insertions(+), 32 deletions(-) diff --git a/src/python/gracklepy/fluid_container.py b/src/python/gracklepy/fluid_container.py index 51f02ba87..afdd12fe6 100644 --- a/src/python/gracklepy/fluid_container.py +++ b/src/python/gracklepy/fluid_container.py @@ -229,19 +229,27 @@ for field in _dust_temperatures[max(_dust_temperatures.keys())]} ) -_metal_yield_densities = \ - ["local_ISM_metal_density", - "ccsn13_metal_density", - "ccsn20_metal_density", - "ccsn25_metal_density", - "ccsn30_metal_density", - "fsn13_metal_density", - "fsn15_metal_density", - "fsn50_metal_density", - "fsn80_metal_density", - "pisn170_metal_density", - "pisn200_metal_density", - "y19_metal_density"] +def _ordered_inject_pathway_yield_densities(my_chemistry): + """ + Returns the names of metal yield density field names for each injection + pathway in the appropriate order + """ + # rate_map is safe as long as the instance doesn't outlive my_chemistry + rate_map = my_chemistry._unsafe_get_rate_map() + inject_path_names = rate_map.get("inject_model_names", []) + + # perform a few sanity checks: + # - these checks should really be handled while initializing chemistry_data, + # (by the core Grackle library) but we are preserving the checks for now + if my_chemistry.metal_chemistry > 0: + if (my_chemistry.multi_metals != 0) and (my_chemistry.multi_metals != 1): + raise ValueError("multi_metals must be either 0 or 1.") + elif len(inject_path_names) == 0: + raise AssertionError( + "Something is very wrong. There should be at least one injection " + "pathway yield field why metal_chemistry > 0" + ) + return [f"{name}_metal_density" for name in inject_path_names] _base_radiation_transfer_fields = \ ["RT_heating_rate", @@ -259,12 +267,9 @@ def _required_density_fields(my_chemistry): if my_chemistry.dust_chemistry == 1: my_fields.append("dust_density") if my_chemistry.metal_chemistry > 0: - my_fields.extend(_dust_metal_densities[my_chemistry.dust_species] + - _dust_densities[my_chemistry.dust_species]) - if my_chemistry.multi_metals == 0: - my_fields.append(_metal_yield_densities[my_chemistry.metal_abundances]) - else: - my_fields.extend(_metal_yield_densities) + my_fields.extend(_dust_metal_densities[my_chemistry.dust_species]) + my_fields.extend(_dust_densities[my_chemistry.dust_species]) + my_fields.extend(_ordered_inject_pathway_yield_densities(my_chemistry)) return my_fields def _required_radiation_transfer_fields(my_chemistry): @@ -338,6 +343,8 @@ def _photo_units(my_chemistry): class FluidContainer(dict): def __init__(self, chemistry_data, n_vals, dtype="float64", itype="int64"): + if not chemistry_data._is_initialized(): + raise ValueError("chemistry_data must be initialized") super(FluidContainer, self).__init__() self.dtype = dtype self.chemistry_data = chemistry_data @@ -371,6 +378,11 @@ def cooling_units(self): def density_fields(self): return _required_density_fields(self.chemistry_data) + @property + def inject_pathway_density_yield_fields(self): + # the order of returned fields is significant + return _ordered_inject_pathway_yield_densities(self.chemistry_data) + @property def input_fields(self): return _required_extra_fields(self.chemistry_data) + \ diff --git a/src/python/gracklepy/grackle_wrapper.pyx b/src/python/gracklepy/grackle_wrapper.pyx index 4447927ca..8cb1203cb 100644 --- a/src/python/gracklepy/grackle_wrapper.pyx +++ b/src/python/gracklepy/grackle_wrapper.pyx @@ -81,8 +81,11 @@ cdef class chemistry_data: self._rate_map = _rate_mapping_access.from_ptr(&self.rates, weakref.ref(self)) self.data_copy_from_init = None + def _is_initialized(self): + return self.data_copy_from_init is not None + cdef void _try_uninitialize(self): - if self.data_copy_from_init is None: + if not self._is_initialized(): return # nothing to uninitialize c_local_free_chemistry_data( diff --git a/src/python/gracklepy/utilities/convenience.py b/src/python/gracklepy/utilities/convenience.py index 177e2b4f9..195c786a6 100644 --- a/src/python/gracklepy/utilities/convenience.py +++ b/src/python/gracklepy/utilities/convenience.py @@ -16,7 +16,6 @@ from gracklepy.fluid_container import \ _element_masses, \ - _metal_yield_densities, \ FluidContainer from gracklepy.utilities.atomic import solar_abundance @@ -43,6 +42,32 @@ def check_convergence(fc1, fc2, fields=None, tol=0.01): return False return True +def _setup_inj_pathway_fields(state_vals: dict[str, float], + inj_pathway_yield_field_names: list[str]): + """ + Helper function that updates state_vals to hold entries corresponding + to the field(s) that specify the metals yielded by each injection pathway + """ + n_pathways = len(inj_pathway_yield_field_names) + if n_pathways == 0: + return # nothing to be done + elif n_pathways == 1: + # put all the metal into the single yield we are following + primary_pathway_yield_field = inj_pathway_yield_field_names[0] + else: + # we are following all possible metal yields, but for now + # just put everything in the local ISM field. + primary_pathway_yield_field = "local_ISM_metal_density" + if primary_pathway_yield_field not in inj_pathway_yield_field_names: + # at the time of writing, this shouldn't happen. But it will become + # possible in the near future. + raise RuntimeError( + "We don't yet support the case where we have multiple injection " + f"pathways but not the '{primary_pathway_yield_field}' field" + ) + state_vals[primary_pathway_yield_field] = state_vals["metal_density"] + + def setup_fluid_container(my_chemistry, density=mass_hydrogen_cgs, temperature=None, @@ -142,17 +167,7 @@ def setup_fluid_container(my_chemistry, "dust_density": dust_to_gas_ratio * fc_density } - if my_chemistry.metal_chemistry > 0: - if my_chemistry.multi_metals == 0: - # put all the metal into the single yield we are following - my_metal = _metal_yield_densities[my_chemistry.metal_abundances] - elif my_chemistry.multi_metals == 1: - # we are following all possible metal yields, but for now - # just put everything in the local ISM field. - my_metal = _metal_yield_densities[0] - else: - raise ValueError("multi_metals must be either 0 or 1.") - state_vals[my_metal] = state_vals["metal_density"] + _setup_inj_pathway_fields(state_vals, fc.inject_pathway_density_yield_fields) if state == "neutral": state_vals["HI_density"] = H_total * fc_density From 707e45d46113e874b0935b51a92482d4ff8fe3dc Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Thu, 1 Jan 2026 14:17:50 -0500 Subject: [PATCH 162/175] introduce experimental machinery to query injection pathway info from python --- src/python/gracklepy/grackle_wrapper.pyx | 97 +++++++++++++++++++++++- src/python/tests/test_inject_pathway.py | 90 ++++++++++++++++++++++ 2 files changed, 185 insertions(+), 2 deletions(-) create mode 100644 src/python/tests/test_inject_pathway.py diff --git a/src/python/gracklepy/grackle_wrapper.pyx b/src/python/gracklepy/grackle_wrapper.pyx index 8cb1203cb..1e8f41e37 100644 --- a/src/python/gracklepy/grackle_wrapper.pyx +++ b/src/python/gracklepy/grackle_wrapper.pyx @@ -14,6 +14,7 @@ import copy import weakref import sys +from types import MappingProxyType from gracklepy.utilities.physical_constants import \ boltzmann_constant_cgs, \ mass_hydrogen_cgs @@ -199,6 +200,79 @@ cdef class chemistry_data: f"'{type(self).__name__}' object has no attribute '{name}'" ) + def _experimental_nuclide_gas_inj_path_yields( + self + ) -> MappingProxyType[str, np.ndarray]: + """ + Just like ``_experimental_grain_inj_path_yields`` except that it + returns yield-fractions for the gas-phase components of each + relevant metal nuclide (rather than yield fractions for grain + species). + + Note + ---- + See the docstring for ``_experimental_grain_inj_path_yields`` for a + discussion of how we might want to modify the interface for accessing + this information before stabilizing the API. + """ + return _get_inj_path_yield_map(self._rate_map, "inject_path_gas_yield_frac.") + + def _experimental_grain_inj_path_yields( + self + ) -> MappingProxyType[str, np.ndarray]: + """ + A helper method that returns a dictionary of grain-species yields + expected by each modelled injection pathway (if there are any). This + is **ONLY** meaningful when using the multi-grain species dust model. + + This method returns an immutable mapping that maps the name of each + relevant grain-species to a 1D array of yield fractions of that + species. In a given array, element ``i`` corresponds to the initial + yield assumed for the injection pathway specified by + ``FluidContainer.inject_pathway_density_yield_fields[i]``. + + Note + ---- + While we must make this information available in order to properly + make use of the multi-grain species dust models (as consistently as + possible), we are still experimenting with how best to do this. + + Before we stabilize the API for accessing this information: + + - we may want to consider replacing both this method and the + ``_experimental_nuclide_gas_inj_path_yields`` method, with a single + method that instead returns a dataclass that holds the information + currently returned by the existing methods. This has a couple of + appealing properites: + 1. all injection pathway information is only used in a very small + subset of Grackle configurations. It makes logical sense to + return all of this information together at once (plus, we could + return `None` if the information isn't defined) + 2. if we ever wanted to expose additional injection pathway + information to end-users (like the initial size moments assumed + by each pathway for each grain-species), it would be a logical + place to group the information + + - alternatively, we may want to get rid of special methods for curating + this information and instead provide an interface to the + query-machinery that mirrors the C-interface and require python users + to use that same interface: + - In the long term, I think that this would be a lot better + (especially if we make this the preferred way to access all rate + info like k1, k2, ...). + - But, in the shorter term, this requires us to make a bunch of final + decisions about the interface. + - If we do this, I think we may want to first shift from using + single-string keys to a key consisting of a string-pair. This + could plausibly make a more ergonomic interface + + - we also need to decide on whether we want to make this information + mutable. Currently, we don't support any mutations. I don't actually + think this is an issue since we're moving towards using HDF5 files + for configuring this information + """ + return _get_inj_path_yield_map(self._rate_map, "inject_path_grain_yield_frac.") + property h2dust: def __get__(self): cdef double[:] memview = ( self.rates.h2dust) @@ -512,7 +586,6 @@ cdef class chemistry_data: return self.density_units * self.energy_units - cdef gr_float* get_field(object fc, object name) except? NULL: """ Helper function to retrieve a field's pointer from a ``FluidContainer`` @@ -911,7 +984,6 @@ cdef class _wrapped_c_chemistry_data: out[k] = self[k] return out - def _portable_reshape(arr: np.ndarray, shape: tuple[int, ...]) -> np.ndarray: """ Reshape a numpy array (raises an error if a copy can't be avoided) @@ -1287,6 +1359,27 @@ cdef class _rate_mapping_access: def __len__(self): return len(self._name_rateid_map) +def _get_inj_path_yield_map( + rate_map: _rate_mapping_access, key_prefix: str +) -> MappingProxyType[str, np.ndarray]: + """ + A helper function to return read-only mappings of arrays that share a + common prefix + """ + if not key_prefix: + raise ValueError("key_prefix must be a non-empty string") + # we will strip off the common prefix + suffix_start = len(key_prefix) + + tmp = {key[suffix_start:] : rate_map[key] for key in rate_map + if key.startswith(key_prefix)} + + # we return a MappingProxyType rather than a regular dict to reflect the fact + # users can't directly the mutate the queried entries (the entries also don't + # have the numpy array's writable flag set to False) + return MappingProxyType(tmp) + + def _query_units(chemistry_data chem_data, object name, object current_a_value): """ diff --git a/src/python/tests/test_inject_pathway.py b/src/python/tests/test_inject_pathway.py new file mode 100644 index 000000000..c4b620358 --- /dev/null +++ b/src/python/tests/test_inject_pathway.py @@ -0,0 +1,90 @@ +######################################################################## +# +# Basic tests that the python layer has appropriate access to relevant +# injection pathway information. Checks of the correctness of the +# injection pathway information are handled in the C++ test-suite. +# +# Copyright (c) 2013, Enzo/Grackle Development Team. +# +# Distributed under the terms of the Enzo Public Licence. +# +# The full license is in the file LICENSE, distributed with this +# software. +######################################################################## + +import os.path + +from gracklepy import chemistry_data, FluidContainer +from gracklepy.utilities.data_path import grackle_data_dir +from gracklepy.utilities.physical_constants import ( + mass_hydrogen_cgs, + sec_per_Myr, + cm_per_mpc, +) + + +def test_info_is_accessible(): + # the main objective here is to make sure that the relevant information + # can be accessed by the python layer + # -> the primary concern here is that we might change a convention about + # *HOW* the information is accessed and forget to propogate the change + # into the python layer + + # first, lets set up a chemistry_data instance with settings that should + # *always* involve multiple grain-species fields + # - the details here will slightly change with time + # - we may want to look into configuring presets like the C++ tests + + my_chemistry = chemistry_data() + my_chemistry.use_grackle = 1 + my_chemistry.with_radiative_cooling = 1 + my_chemistry.primordial_chemistry = 4 + my_chemistry.metal_cooling = 1 + my_chemistry.UVbackground = 1 + my_chemistry.grackle_data_file = os.path.join( + grackle_data_dir, "CloudyData_UVB=HM2012.h5" + ) + + my_chemistry.dust_chemistry = 1 + my_chemistry.metal_chemistry = 1 + my_chemistry.dust_species = 1 + my_chemistry.use_dust_density_field = 1 + my_chemistry.multi_metals = 1 + + # Set units + redshift = 0.0 + my_chemistry.comoving_coordinates = 0 + my_chemistry.a_units = 1.0 + my_chemistry.a_value = 1.0 / (1.0 + redshift) / my_chemistry.a_units + my_chemistry.density_units = mass_hydrogen_cgs + my_chemistry.length_units = cm_per_mpc + my_chemistry.time_units = sec_per_Myr + my_chemistry.set_velocity_units() + + # initialize my_chemistry + assert my_chemistry.initialize() == 1 + + # let's confirm that we properly require injection pathway fields + fc = FluidContainer(my_chemistry, n_vals=1) + inject_pathway_yield_density_names = fc.inject_pathway_density_yield_fields + n_pathways = len(inject_pathway_yield_density_names) + assert n_pathways > 0, ( + "internal logic appears to have broken for accessing the modelled injection " + "pathway names from the python layer" + ) + + # let's confirm that we properly access gas nuclide yields + nuclide_gas_yields = my_chemistry._experimental_nuclide_gas_inj_path_yields() + assert len(nuclide_gas_yields) > 0, ( + "internal logic appears to have broken for accessing (from the gracklepy " + "layer) the assumed gas-phase yields of each relevant metal nuclide" + ) + assert "C" in nuclide_gas_yields # extra sanity check! + + # let's confirm that we properly list grain nuclide yields + grain_yields = my_chemistry._experimental_grain_inj_path_yields() + assert len(grain_yields) > 0, ( + "internal logic appears to have broken for accessing (from the gracklepy " + "layer) the assumed yields of each relevant grain-species" + ) + assert "AC_dust" in grain_yields # extra sanity check! From 35e5aa10ec66e2ce1cca15549a477ddd277d3b21 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Thu, 1 Jan 2026 15:49:15 -0500 Subject: [PATCH 163/175] address clang-tidy warnings --- tests/unit/test_chemistry_struct_synced.cpp | 1 + tests/unit/test_grain_species_info.cpp | 2 ++ tests/unit/test_visitor.cpp | 8 ++++++++ 3 files changed, 11 insertions(+) diff --git a/tests/unit/test_chemistry_struct_synced.cpp b/tests/unit/test_chemistry_struct_synced.cpp index ee02a02bb..40d9cbb83 100644 --- a/tests/unit/test_chemistry_struct_synced.cpp +++ b/tests/unit/test_chemistry_struct_synced.cpp @@ -106,6 +106,7 @@ MemberTypeNameMapResult query_struct_members(std::string struct_name) {} }; } else if (std::fgetc(f) == EOF) { + std::fclose(f); std::string msg( "The build-system wrote an empty xml-file, which usually means that " "castxml wasn't installed. If you install castxml, you need to instruct " diff --git a/tests/unit/test_grain_species_info.cpp b/tests/unit/test_grain_species_info.cpp index b941d55a0..900ae0458 100644 --- a/tests/unit/test_grain_species_info.cpp +++ b/tests/unit/test_grain_species_info.cpp @@ -92,9 +92,11 @@ using unique_GrainSpeciesInfo_ptr = /// This is useful for preventing memory leaks when tests fail unique_GrainSpeciesInfo_ptr make_unique_GrainSpeciesInfo( int dust_species_param) { + // NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks) grackle::impl::GrainSpeciesInfo* ptr = new grackle::impl::GrainSpeciesInfo; (*ptr) = grackle::impl::new_GrainSpeciesInfo(dust_species_param); return unique_GrainSpeciesInfo_ptr(ptr, GrainSpeciesInfoDeleter()); + // NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks) } } // anonymous namespace diff --git a/tests/unit/test_visitor.cpp b/tests/unit/test_visitor.cpp index 73e8af2ae..fe5e7ef94 100644 --- a/tests/unit/test_visitor.cpp +++ b/tests/unit/test_visitor.cpp @@ -37,6 +37,9 @@ void visit_member(MyDummyStruct* obj, UnaryFn fn){ GRIMPL_IMPL_VISIT_MEMBER(visit_member_pair, MyDummyStruct, obj, fn)} TEST(VisitorTest, Simple) { + // as currently written, there isn't an easy way to avoid memory leaks if the + // test fails + // NOLINTBEGIN(clang-analyzer-unix.Malloc) grackle::impl::visitor::VisitorCtx ctx{2u}; MyDummyStruct tmp{nullptr, nullptr}; @@ -61,6 +64,7 @@ TEST(VisitorTest, Simple) { visit_member(&tmp, grackle::impl::visitor::FreeMembers{}); visit_member(&tmp2, grackle::impl::visitor::FreeMembers{}); + // NOLINTEND(clang-analyzer-unix.Malloc) } struct MyNestedStruct { @@ -89,6 +93,9 @@ void visit_member(MyNestedStruct* obj, UnaryFn fn){ GRIMPL_IMPL_VISIT_MEMBER(visit_member_pair, MyNestedStruct, obj, fn)} TEST(VisitorTest, Nested) { + // as currently written, there isn't an easy way to avoid memory leaks if the + // test fails + // NOLINTBEGIN(clang-analyzer-unix.Malloc) grackle::impl::visitor::VisitorCtx ctx{2u}; MyNestedStruct tmp{nullptr, {nullptr, nullptr}}; @@ -122,4 +129,5 @@ TEST(VisitorTest, Nested) { visit_member(&tmp, grackle::impl::visitor::FreeMembers{}); visit_member(&tmp2, grackle::impl::visitor::FreeMembers{}); + // NOLINTEND(clang-analyzer-unix.Malloc) } From 6b69e773da57183db0e6add11f9805941a3a0bb1 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Thu, 1 Jan 2026 17:57:57 -0500 Subject: [PATCH 164/175] a minor hint to try to fix clang-tidy behavior --- tests/unit/test_grain_species_info.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/unit/test_grain_species_info.cpp b/tests/unit/test_grain_species_info.cpp index 900ae0458..bd9eb8b22 100644 --- a/tests/unit/test_grain_species_info.cpp +++ b/tests/unit/test_grain_species_info.cpp @@ -253,6 +253,9 @@ TEST(GrainSpeciesInfoTestMisc, DustSpeciesExtremeValues) { // indeed holds the maximum number of ingredients that a grain species can // have. TEST(GrainSpeciesInfoTestMisc, MaxIngredientsPerGrainSpecies) { + // I really don't understand this linter issue + // NOLINTBEGIN(clang-analyzer-core.CallAndMessage) + // construct a GrainSpeciesInfo instance that holds values for every dust // grain species unique_GrainSpeciesInfo_ptr gsp_info = @@ -271,4 +274,5 @@ TEST(GrainSpeciesInfoTestMisc, MaxIngredientsPerGrainSpecies) { grackle::impl::max_ingredients_per_grain_species) << "it appears that grackle::impl::max_ingredients_per_grain_species " << "should have a value of " << max_ingredient_count; + // NOLINTEND(clang-analyzer-core.CallAndMessage) } From a5b3225209371d44520ea91e37d442b6c87d9673 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Thu, 1 Jan 2026 15:23:26 -0500 Subject: [PATCH 165/175] Start undefining internal macros in headers --- src/clib/CMakeLists.txt | 17 +++++++++++++---- src/include/grackle_chemistry_data.h | 9 ++++++++- src/include/grackle_float.h.in | 2 +- src/include/grackle_types.h | 2 +- tests/grtestutils/CMakeLists.txt | 7 ++----- 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/clib/CMakeLists.txt b/src/clib/CMakeLists.txt index 52a94c920..7a828ec55 100644 --- a/src/clib/CMakeLists.txt +++ b/src/clib/CMakeLists.txt @@ -302,7 +302,16 @@ if ("${CMAKE_SYSTEM_NAME}" MATCHES "^(Linux)|(Darwin)$") target_compile_definitions(Grackle_Grackle PRIVATE "LINUX") endif() -# define macro to suppress warnings about C files using our deprecated public -# headers (the files should include grackle.h instead). We're currently holding -# off on this to minimize conflicts with the newchem-cpp branch -target_compile_definitions(Grackle_Grackle PRIVATE GRIMPL_PUBLIC_INCLUDE=1) +# define macro to slightly customize behavior in header files since we're compiling +# the grackle library +# - suppresses warnings about C files using our deprecated public headers (the files +# should include grackle.h instead). We're gradually making this transition. It will +# probably be complete once we're finished transcribing all Fortran +# - indicate to the headers that they shouldn't undef certain macros +# +# In reality, a "cleaner" approach than this may be to have +# - all files in the core library include a wrapper-header-file that wraps the public +# headers and have that wrapper-file define this macro instead +# - this is appealing since there's one less custom argument that needs to be passed +# to the compiler +target_compile_definitions(Grackle_Grackle PRIVATE GRIMPL_COMPILING_CORE_LIB=1) diff --git a/src/include/grackle_chemistry_data.h b/src/include/grackle_chemistry_data.h index 0881952b3..3bc2a8e47 100644 --- a/src/include/grackle_chemistry_data.h +++ b/src/include/grackle_chemistry_data.h @@ -12,7 +12,7 @@ ************************************************************************/ // this should go before the header-guard -#ifndef GRIMPL_PUBLIC_INCLUDE +#if !defined(GRIMPL_PUBLIC_INCLUDE) && !defined(GRIMPL_COMPILING_CORE_LIB) #include "grackle_misc.h" GRIMPL_COMPTIME_WARNING( "You are using a deprecated header file; include the public \"grackle.h\" " @@ -662,4 +662,11 @@ typedef struct } /* extern "C" */ #endif /* __cplusplus */ + +#if !defined(GRIMPL_COMPILING_CORE_LIB) +// avoid leaking these macros used for defining implementation details out of +// the core library +#undef GRACKLE_CLOUDY_TABLE_MAX_DIMENSION +#endif + #endif /* __CHEMISTRY_DATA_H__ */ diff --git a/src/include/grackle_float.h.in b/src/include/grackle_float.h.in index 76111b104..9e4fa8813 100644 --- a/src/include/grackle_float.h.in +++ b/src/include/grackle_float.h.in @@ -8,7 +8,7 @@ // relevant `.def` file. // this logic should occur before the header guards - #ifndef GRIMPL_PUBLIC_INCLUDE + #if !defined(GRIMPL_PUBLIC_INCLUDE) && !defined(GRIMPL_COMPILING_CORE_LIB) #include "grackle_misc.h" GRIMPL_COMPTIME_WARNING( "You are using a deprecated header file; include the public " diff --git a/src/include/grackle_types.h b/src/include/grackle_types.h index b764fd1fa..749e6e316 100644 --- a/src/include/grackle_types.h +++ b/src/include/grackle_types.h @@ -12,7 +12,7 @@ ************************************************************************/ // this should go before the header-guard -#ifndef GRIMPL_PUBLIC_INCLUDE +#if !defined(GRIMPL_PUBLIC_INCLUDE) && !defined(GRIMPL_COMPILING_CORE_LIB) #include "grackle_misc.h" GRIMPL_COMPTIME_WARNING( "You are using a deprecated header file; include the public \"grackle.h\" " diff --git a/tests/grtestutils/CMakeLists.txt b/tests/grtestutils/CMakeLists.txt index 4397bd23e..dd32eed0b 100644 --- a/tests/grtestutils/CMakeLists.txt +++ b/tests/grtestutils/CMakeLists.txt @@ -12,11 +12,8 @@ target_link_libraries(_grackle_internals INTERFACE Grackle::Grackle) target_compile_definitions(_grackle_internals # currently required for functions declared by fortran_func_wrappers.hpp INTERFACE "$<$:LINUX>" - # suppresses warnings about C internal headers using our deprecated public - # headers (the files should include grackle.h instead). We're currently - # holding off on properly fixing this to minimize conflicts with pending PRs - # on the newchem-cpp branch - INTERFACE GRIMPL_PUBLIC_INCLUDE=1 + # TODO: see what we can do to stop defining the following + INTERFACE GRIMPL_COMPILING_CORE_LIB=1 ) # this makes it possible to write an include-directive of a header from From 1c2c84c7db6244a9d531f685e115e38025188da8 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Thu, 1 Jan 2026 16:17:49 -0500 Subject: [PATCH 166/175] introduce grackle_field_data::inject_pathway_metal_density --- src/clib/Make.config.assemble | 2 +- src/clib/set_default_chemistry_parameters.c | 5 +++++ src/clib/utils-field.hpp | 7 +++++++ src/include/grackle_fortran_interface.def | 1 + src/include/grackle_types.h | 11 +++++++++++ src/python/gracklepy/grackle_defs.pxd | 1 + 6 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/clib/Make.config.assemble b/src/clib/Make.config.assemble index b2b57e5cb..5704fcdd4 100644 --- a/src/clib/Make.config.assemble +++ b/src/clib/Make.config.assemble @@ -199,7 +199,7 @@ # this to minimize conflicts with the newchem-cpp branch DEFINES = $(MACH_DEFINES) \ $(ASSEMBLE_IO_DEFINES) \ - -DGRIMPL_PUBLIC_INCLUDE=1 + -DGRIMPL_COMPILING_CORE_LIB=1 PUBLIC_HEADER_SRCDIR = $(GRACKLE_DIR)/../include AUTOGEN_DIR = $(GRACKLE_DIR)/autogen diff --git a/src/clib/set_default_chemistry_parameters.c b/src/clib/set_default_chemistry_parameters.c index 2db984476..ee98d260a 100644 --- a/src/clib/set_default_chemistry_parameters.c +++ b/src/clib/set_default_chemistry_parameters.c @@ -68,5 +68,10 @@ int gr_initialize_field_data(grackle_field_data *my_fields) #include "field_data_misc_fdatamembers.def" #undef ENTRY + // Part 3: modify inject pathway density field slots + for (int i = 0; i < GRIMPL_MAX_INJ_PATHWAYS; i++) { + my_fields->inject_pathway_metal_density[i] = NULL; + } + return SUCCESS; } diff --git a/src/clib/utils-field.hpp b/src/clib/utils-field.hpp index 41ddcb7c3..1cb2eb564 100644 --- a/src/clib/utils-field.hpp +++ b/src/clib/utils-field.hpp @@ -52,6 +52,13 @@ inline void copy_offset_fieldmember_ptrs_(grackle_field_data* dest, #include "field_data_misc_fdatamembers.def" #undef ENTRY + // Part 3: modify inject pathway density field slots + for (int i = 0; i < GRIMPL_MAX_INJ_PATHWAYS; i++) { + gr_float* p = src->inject_pathway_metal_density[i]; + dest->inject_pathway_metal_density[i] = + (p == nullptr) ? nullptr : p + offset; + } + #undef GRIMPL_OFFSET_PTR_CPY } diff --git a/src/include/grackle_fortran_interface.def b/src/include/grackle_fortran_interface.def index 96db23394..47755873e 100644 --- a/src/include/grackle_fortran_interface.def +++ b/src/include/grackle_fortran_interface.def @@ -112,6 +112,7 @@ c This is the fortran definition of grackle_field_data TYPE(C_PTR) :: pisn170_metal_density TYPE(C_PTR) :: pisn200_metal_density TYPE(C_PTR) :: y19_metal_density + TYPE(C_PTR) :: inject_pathway_metal_density(12) TYPE(C_PTR) :: volumetric_heating_rate TYPE(C_PTR) :: specific_heating_rate TYPE(C_PTR) :: temperature_floor diff --git a/src/include/grackle_types.h b/src/include/grackle_types.h index 749e6e316..f61df9eaa 100644 --- a/src/include/grackle_types.h +++ b/src/include/grackle_types.h @@ -53,6 +53,8 @@ extern "C" { #error "Both GRACKLE_FLOAT_4 and GRACKLE_FLOAT_8 are defined. Only one can be defined." #endif +#define GRIMPL_MAX_INJ_PATHWAYS 12 + typedef struct { @@ -162,6 +164,9 @@ typedef struct gr_float *pisn200_metal_density; gr_float *y19_metal_density; + // in the next few commits, this will replace all *_metal_density fields + gr_float* inject_pathway_metal_density[GRIMPL_MAX_INJ_PATHWAYS]; + // use_volumetric_heating_rate = 1 gr_float *volumetric_heating_rate; // use_specific_heating_rate = 1 @@ -223,6 +228,12 @@ typedef struct } grackle_version; +#if !defined(GRIMPL_COMPILING_CORE_LIB) +// avoid leaking these macros used for defining implementation details out of +// the core library +#undef GRIMPL_MAX_INJ_PATHWAYS +#endif + #ifdef __cplusplus } /* extern "C" */ #endif /* __cplusplus */ diff --git a/src/python/gracklepy/grackle_defs.pxd b/src/python/gracklepy/grackle_defs.pxd index 7f10e54c3..ac10a6c18 100644 --- a/src/python/gracklepy/grackle_defs.pxd +++ b/src/python/gracklepy/grackle_defs.pxd @@ -173,6 +173,7 @@ cdef extern from "grackle.h": gr_float *pisn170_metal_density; gr_float *pisn200_metal_density; gr_float *y19_metal_density; + gr_float *inject_pathway_metal_density[12]; gr_float *volumetric_heating_rate; gr_float *specific_heating_rate; gr_float *temperature_floor; From 2d7fc718dc9a829c01dd27199bcf401760a2655a Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Thu, 1 Jan 2026 16:31:31 -0500 Subject: [PATCH 167/175] hack: start using grackle_field_data::inject_pathway_metal_density This a crude hack --- .../inject_model/inject_path_field_pack.hpp | 52 +++++++++++-------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/src/clib/inject_model/inject_path_field_pack.hpp b/src/clib/inject_model/inject_path_field_pack.hpp index 4992045db..fd45a8221 100644 --- a/src/clib/inject_model/inject_path_field_pack.hpp +++ b/src/clib/inject_model/inject_path_field_pack.hpp @@ -26,39 +26,47 @@ struct InjectPathFieldPack { int n_fields; /// holds pointers to the various injection model density fields - const gr_float* fields[inj_model_input::N_Injection_Pathways]; + const gr_float* const* fields; }; /// Setup an InjectPathFieldPack instance inline InjectPathFieldPack setup_InjectPathFieldPack( const chemistry_data* my_chem, const grackle_field_data* my_fields) { if ((my_chem->metal_chemistry > 0) && (my_chem->multi_metals == 1)) { - return InjectPathFieldPack{inj_model_input::N_Injection_Pathways, - { - my_fields->local_ISM_metal_density, - my_fields->ccsn13_metal_density, - my_fields->ccsn20_metal_density, - my_fields->ccsn25_metal_density, - my_fields->ccsn30_metal_density, - my_fields->fsn13_metal_density, - my_fields->fsn15_metal_density, - my_fields->fsn50_metal_density, - my_fields->fsn80_metal_density, - my_fields->pisn170_metal_density, - my_fields->pisn200_metal_density, - my_fields->y19_metal_density, - }}; - } + grackle_field_data* my_fields_ = const_cast(my_fields); + my_fields_->inject_pathway_metal_density[0] = + my_fields_->local_ISM_metal_density; + my_fields_->inject_pathway_metal_density[1] = + my_fields_->ccsn13_metal_density; + my_fields_->inject_pathway_metal_density[2] = + my_fields_->ccsn20_metal_density; + my_fields_->inject_pathway_metal_density[3] = + my_fields_->ccsn25_metal_density; + my_fields_->inject_pathway_metal_density[4] = + my_fields_->ccsn30_metal_density; + my_fields_->inject_pathway_metal_density[5] = + my_fields_->fsn13_metal_density; + my_fields_->inject_pathway_metal_density[6] = + my_fields_->fsn15_metal_density; + my_fields_->inject_pathway_metal_density[7] = + my_fields_->fsn50_metal_density; + my_fields_->inject_pathway_metal_density[8] = + my_fields_->fsn80_metal_density; + my_fields_->inject_pathway_metal_density[9] = + my_fields_->pisn170_metal_density; + my_fields_->inject_pathway_metal_density[10] = + my_fields_->pisn200_metal_density; + my_fields_->inject_pathway_metal_density[11] = + my_fields_->y19_metal_density; - InjectPathFieldPack out; - out.n_fields = 0; - for (int i = 0; i < inj_model_input::N_Injection_Pathways; i++) { - out.fields[i] = nullptr; + return InjectPathFieldPack{inj_model_input::N_Injection_Pathways, + my_fields->inject_pathway_metal_density}; } + InjectPathFieldPack out{0, nullptr}; if ((my_chem->metal_chemistry > 0) && (my_chem->multi_metals == 0)) { out.n_fields = 1; - out.fields[0] = my_fields->metal_density; + out.fields = &my_fields->metal_density; } return out; From 7881c69883494316ff5d9df8ce8f1f4b0339fa14 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Thu, 1 Jan 2026 16:43:40 -0500 Subject: [PATCH 168/175] hack: stop using InjectPathFieldPack This leaves some temporary machinery --- src/clib/CMakeLists.txt | 2 +- .../calc_grain_size_increment_1d.hpp | 11 ++- .../inject_model/inject_path_field_pack.hpp | 77 ------------------- src/clib/inject_model/misc.hpp | 73 ++++++++++++++++++ src/clib/make_consistent.cpp | 9 +-- 5 files changed, 83 insertions(+), 89 deletions(-) delete mode 100644 src/clib/inject_model/inject_path_field_pack.hpp create mode 100644 src/clib/inject_model/misc.hpp diff --git a/src/clib/CMakeLists.txt b/src/clib/CMakeLists.txt index 7a828ec55..0529b173f 100644 --- a/src/clib/CMakeLists.txt +++ b/src/clib/CMakeLists.txt @@ -117,8 +117,8 @@ add_library(Grackle_Grackle initialize_chemistry_data.cpp initialize_rates.cpp initialize_rates.hpp inject_model/grain_metal_inject_pathways.hpp - inject_model/inject_path_field_pack.hpp inject_model/load_data.cpp inject_model/load_data.hpp + inject_model/misc.hpp inject_model/raw_data.cpp inject_model/raw_data.hpp internal_types.cpp internal_types.hpp interp_table_utils.hpp diff --git a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp index a0a1976e5..92222c0a5 100644 --- a/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp +++ b/src/clib/dust/multi_grain_species/calc_grain_size_increment_1d.hpp @@ -26,7 +26,7 @@ #include "fortran_func_decls.h" #include "index_helper.h" #include "inject_model/grain_metal_inject_pathways.hpp" -#include "inject_model/inject_path_field_pack.hpp" +#include "inject_model/misc.hpp" #include "LUT.hpp" #include "utils-cpp.hpp" #include "utils-field.hpp" @@ -129,8 +129,8 @@ inline void calc_grain_size_increment_1d( my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - InjectPathFieldPack inject_path_metal_densities = - setup_InjectPathFieldPack(my_chemistry, my_fields); + const gr_float* const* inject_pathway_metal_densities = + get_inject_pathway_metal_density(my_chemistry, my_fields); // make arrays for (int count = 0; count < n_pathways; count++) { @@ -138,9 +138,8 @@ inline void calc_grain_size_increment_1d( // the same pointer as `metal` grackle::impl::View inj_path_metal_dens( - inject_path_metal_densities.fields[count], - my_fields->grid_dimension[0], my_fields->grid_dimension[1], - my_fields->grid_dimension[2]); + inject_pathway_metal_densities[count], my_fields->grid_dimension[0], + my_fields->grid_dimension[1], my_fields->grid_dimension[2]); // calculate the max ratio between inj_path_metal_dens and metal gr_float max_ratio = std::numeric_limits::lowest(); diff --git a/src/clib/inject_model/inject_path_field_pack.hpp b/src/clib/inject_model/inject_path_field_pack.hpp deleted file mode 100644 index fd45a8221..000000000 --- a/src/clib/inject_model/inject_path_field_pack.hpp +++ /dev/null @@ -1,77 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// See the LICENSE file for license and copyright information -// SPDX-License-Identifier: NCSA AND BSD-3-Clause -// -//===----------------------------------------------------------------------===// -/// -/// @file -/// Declares the InjectPathFieldPack type -/// -//===----------------------------------------------------------------------===// -#ifndef INJECT_MODEL_INJECT_PATH_FIELD_PACK_HPP -#define INJECT_MODEL_INJECT_PATH_FIELD_PACK_HPP - -#include "raw_data.hpp" // grackle::impl::inj_model_input::N_Injection_Pathways - -namespace grackle::impl { - -/// A temporary type that is used to collect the injection pathway metal -/// density fields in the order that is assumed throughout Grackle -/// -/// I have some ideas that will let us dispose of this type in the near future. -struct InjectPathFieldPack { - /// Specifies the number of injection pathways that should have data in - /// the fields member. - int n_fields; - - /// holds pointers to the various injection model density fields - const gr_float* const* fields; -}; - -/// Setup an InjectPathFieldPack instance -inline InjectPathFieldPack setup_InjectPathFieldPack( - const chemistry_data* my_chem, const grackle_field_data* my_fields) { - if ((my_chem->metal_chemistry > 0) && (my_chem->multi_metals == 1)) { - grackle_field_data* my_fields_ = const_cast(my_fields); - my_fields_->inject_pathway_metal_density[0] = - my_fields_->local_ISM_metal_density; - my_fields_->inject_pathway_metal_density[1] = - my_fields_->ccsn13_metal_density; - my_fields_->inject_pathway_metal_density[2] = - my_fields_->ccsn20_metal_density; - my_fields_->inject_pathway_metal_density[3] = - my_fields_->ccsn25_metal_density; - my_fields_->inject_pathway_metal_density[4] = - my_fields_->ccsn30_metal_density; - my_fields_->inject_pathway_metal_density[5] = - my_fields_->fsn13_metal_density; - my_fields_->inject_pathway_metal_density[6] = - my_fields_->fsn15_metal_density; - my_fields_->inject_pathway_metal_density[7] = - my_fields_->fsn50_metal_density; - my_fields_->inject_pathway_metal_density[8] = - my_fields_->fsn80_metal_density; - my_fields_->inject_pathway_metal_density[9] = - my_fields_->pisn170_metal_density; - my_fields_->inject_pathway_metal_density[10] = - my_fields_->pisn200_metal_density; - my_fields_->inject_pathway_metal_density[11] = - my_fields_->y19_metal_density; - - return InjectPathFieldPack{inj_model_input::N_Injection_Pathways, - my_fields->inject_pathway_metal_density}; - } - - InjectPathFieldPack out{0, nullptr}; - if ((my_chem->metal_chemistry > 0) && (my_chem->multi_metals == 0)) { - out.n_fields = 1; - out.fields = &my_fields->metal_density; - } - - return out; -} - -} // namespace grackle::impl - -#endif /* INJECT_MODEL_INJECT_PATH_FIELD_PACK_HPP */ diff --git a/src/clib/inject_model/misc.hpp b/src/clib/inject_model/misc.hpp new file mode 100644 index 000000000..0f24fcf30 --- /dev/null +++ b/src/clib/inject_model/misc.hpp @@ -0,0 +1,73 @@ +//===----------------------------------------------------------------------===// +// +// See the LICENSE file for license and copyright information +// SPDX-License-Identifier: NCSA AND BSD-3-Clause +// +//===----------------------------------------------------------------------===// +/// +/// @file +/// Defines miscellaneous machinery. In the long term, we can hopefully remove +/// this machinery +/// +//===----------------------------------------------------------------------===// +#ifndef INJECT_MODEL_MISC_HPP +#define INJECT_MODEL_MISC_HPP + +#include "raw_data.hpp" // grackle::impl::inj_model_input::N_Injection_Pathways + +namespace grackle::impl { + +/// Retrieves a pointer that corresponds to the array of user-specified fields +/// holding the cumulative metal density injected by each relevant injection +/// pathway +/// +/// @note +/// At the time of writing, when `metal_chemistry > 0 && multi_metals == 0`, +/// Grackle assumes that 100% of the density within `my_fields->metal_density` +/// is injected by the single pathway. In this scenario, we return a pointer +/// `my_fields->metal_density`. +/// - theoretically, this could introduce slightly unexpected behavior if a +/// routine tried to modify `my_fields->metal_density` and expected the +/// injection pathway metal density to remain unchanged. In practice, this +/// never comes up +/// - in the longer term we plan to remove this specialized behavior from +/// Grackle altogether (i.e. users will need to specify separate injection +/// pathway metal densities in all cases). It will lead to less surprising +/// behavior and will become important once we start reading injection +/// pathway details from user-specified HDF5 files +inline const gr_float* const* get_inject_pathway_metal_density( + const chemistry_data* my_chem, grackle_field_data* my_fields) { + if ((my_chem->metal_chemistry > 0) && (my_chem->multi_metals == 1)) { + my_fields->inject_pathway_metal_density[0] = + my_fields->local_ISM_metal_density; + my_fields->inject_pathway_metal_density[1] = + my_fields->ccsn13_metal_density; + my_fields->inject_pathway_metal_density[2] = + my_fields->ccsn20_metal_density; + my_fields->inject_pathway_metal_density[3] = + my_fields->ccsn25_metal_density; + my_fields->inject_pathway_metal_density[4] = + my_fields->ccsn30_metal_density; + my_fields->inject_pathway_metal_density[5] = my_fields->fsn13_metal_density; + my_fields->inject_pathway_metal_density[6] = my_fields->fsn15_metal_density; + my_fields->inject_pathway_metal_density[7] = my_fields->fsn50_metal_density; + my_fields->inject_pathway_metal_density[8] = my_fields->fsn80_metal_density; + my_fields->inject_pathway_metal_density[9] = + my_fields->pisn170_metal_density; + my_fields->inject_pathway_metal_density[10] = + my_fields->pisn200_metal_density; + my_fields->inject_pathway_metal_density[11] = my_fields->y19_metal_density; + } + + if (my_chem->metal_chemistry <= 0) { + return nullptr; + } else if (my_chem->multi_metals == 0) { + return &my_fields->metal_density; + } else { + return my_fields->inject_pathway_metal_density; + } +} + +} // namespace grackle::impl + +#endif // INJECT_MODEL_MISC_HPP diff --git a/src/clib/make_consistent.cpp b/src/clib/make_consistent.cpp index 10fa44741..77b253893 100644 --- a/src/clib/make_consistent.cpp +++ b/src/clib/make_consistent.cpp @@ -19,7 +19,7 @@ #include "grackle.h" #include "fortran_func_decls.h" #include "inject_model/grain_metal_inject_pathways.hpp" -#include "inject_model/inject_path_field_pack.hpp" +#include "inject_model/misc.hpp" #include "opaque_storage.hpp" #include "utils-cpp.hpp" @@ -217,20 +217,19 @@ void make_consistent( SN_metal_arr[inj_model_input::N_Injection_Pathways]; int n_pathways = 0; - // construct view of each specified injection pathway metal density field if (my_chemistry->metal_chemistry > 0) { // note: when (my_chemistry->multi_metals == 0) a view within // SN_metal_arr will wrap my_fields->metal_density. In other words, // that view will be an alias of the `metal` view. This is ok because // my_fields->metal_density is **NOT** mutated by this function. - InjectPathFieldPack p = setup_InjectPathFieldPack(my_chemistry, my_fields); - n_pathways = inject_pathway_props->n_pathways; + const gr_float* const* inject_pathway_metal_densities = + get_inject_pathway_metal_density(my_chemistry, my_fields); for (int iSN = 0; iSN < n_pathways; iSN++) { SN_metal_arr[iSN] = grackle::impl::View( - p.fields[iSN], my_fields->grid_dimension[0], + inject_pathway_metal_densities[iSN], my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); } } From dde169a6bd06e32e81d6775ae9fa685eb4b29035 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sat, 3 Jan 2026 09:40:45 -0500 Subject: [PATCH 169/175] hack: don't use `_metal_density` from gracklepy --- src/clib/inject_model/misc.hpp | 3 ++- src/python/gracklepy/grackle_wrapper.pyx | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/clib/inject_model/misc.hpp b/src/clib/inject_model/misc.hpp index 0f24fcf30..b3e157542 100644 --- a/src/clib/inject_model/misc.hpp +++ b/src/clib/inject_model/misc.hpp @@ -37,7 +37,8 @@ namespace grackle::impl { /// pathway details from user-specified HDF5 files inline const gr_float* const* get_inject_pathway_metal_density( const chemistry_data* my_chem, grackle_field_data* my_fields) { - if ((my_chem->metal_chemistry > 0) && (my_chem->multi_metals == 1)) { + if ((my_chem->metal_chemistry > 0) && (my_chem->multi_metals == 1) + && (my_fields->inject_pathway_metal_density[0] == nullptr)) { my_fields->inject_pathway_metal_density[0] = my_fields->local_ISM_metal_density; my_fields->inject_pathway_metal_density[1] = diff --git a/src/python/gracklepy/grackle_wrapper.pyx b/src/python/gracklepy/grackle_wrapper.pyx index 1e8f41e37..44a3dbbdb 100644 --- a/src/python/gracklepy/grackle_wrapper.pyx +++ b/src/python/gracklepy/grackle_wrapper.pyx @@ -718,18 +718,18 @@ cdef c_field_data setup_field_data(object fc, int[::1] buf, my_fields.vol_org_dust_density = get_field(fc, "vol_org_dust_density") my_fields.H2O_ice_dust_density = get_field(fc, "H2O_ice_dust_density") - my_fields.local_ISM_metal_density = get_field(fc, "local_ISM_metal_density") - my_fields.ccsn13_metal_density = get_field(fc, "ccsn13_metal_density") - my_fields.ccsn20_metal_density = get_field(fc, "ccsn20_metal_density") - my_fields.ccsn25_metal_density = get_field(fc, "ccsn25_metal_density") - my_fields.ccsn30_metal_density = get_field(fc, "ccsn30_metal_density") - my_fields.fsn13_metal_density = get_field(fc, "fsn13_metal_density") - my_fields.fsn15_metal_density = get_field(fc, "fsn15_metal_density") - my_fields.fsn50_metal_density = get_field(fc, "fsn50_metal_density") - my_fields.fsn80_metal_density = get_field(fc, "fsn80_metal_density") - my_fields.pisn170_metal_density = get_field(fc, "pisn170_metal_density") - my_fields.pisn200_metal_density = get_field(fc, "pisn200_metal_density") - my_fields.y19_metal_density = get_field(fc, "y19_metal_density") + # todo: replace this with a faster alternative + cdef list inject_pathway_density_fields = fc.inject_pathway_density_yield_fields + cdef Py_ssize_t n_pathways = len(inject_pathway_density_fields) + cdef Py_ssize_t i + cdef gr_float* ptr + #raise RuntimeError(inject_pathway_density_fields) + for i in range(n_pathways): + my_fields.inject_pathway_metal_density[i] = get_field( + fc, inject_pathway_density_fields[i] + ) + if my_fields.inject_pathway_metal_density[i] is NULL: + raise RuntimeError("{!r} holds NULL".format(inject_pathway_density_fields[i])) my_fields.volumetric_heating_rate = get_field(fc, "volumetric_heating_rate") my_fields.specific_heating_rate = get_field(fc, "specific_heating_rate") From ffc0f0bfbf125b3c7d7e942b1b23b8d0974b943f Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sat, 3 Jan 2026 11:23:13 -0500 Subject: [PATCH 170/175] scale_fields.[ch]pp stops listing pathway densities --- src/clib/inject_model/misc.hpp | 14 +++++- src/clib/scale_fields.cpp | 92 ++++++++++++++-------------------- src/clib/scale_fields.hpp | 70 +++++++------------------- 3 files changed, 67 insertions(+), 109 deletions(-) diff --git a/src/clib/inject_model/misc.hpp b/src/clib/inject_model/misc.hpp index b3e157542..c008ee1fc 100644 --- a/src/clib/inject_model/misc.hpp +++ b/src/clib/inject_model/misc.hpp @@ -17,6 +17,16 @@ namespace grackle::impl { +/// this is a hacky short-term helper function +/// +/// @todo +/// Get rid of this function. This will be necessary in the future in order to +/// start reading injection pathway details from user-specified HDF5 files. +inline int get_n_inject_pathway_density_ptrs(const chemistry_data* my_chem) { + bool nonzero = (my_chem->metal_chemistry > 0) && (my_chem->multi_metals > 0); + return (nonzero) ? grackle::impl::inj_model_input::N_Injection_Pathways : 0; +} + /// Retrieves a pointer that corresponds to the array of user-specified fields /// holding the cumulative metal density injected by each relevant injection /// pathway @@ -37,8 +47,8 @@ namespace grackle::impl { /// pathway details from user-specified HDF5 files inline const gr_float* const* get_inject_pathway_metal_density( const chemistry_data* my_chem, grackle_field_data* my_fields) { - if ((my_chem->metal_chemistry > 0) && (my_chem->multi_metals == 1) - && (my_fields->inject_pathway_metal_density[0] == nullptr)) { + if ((my_chem->metal_chemistry > 0) && (my_chem->multi_metals == 1) && + (my_fields->inject_pathway_metal_density[0] == nullptr)) { my_fields->inject_pathway_metal_density[0] = my_fields->local_ISM_metal_density; my_fields->inject_pathway_metal_density[1] = diff --git a/src/clib/scale_fields.cpp b/src/clib/scale_fields.cpp index 5eccdc54b..9d425d676 100644 --- a/src/clib/scale_fields.cpp +++ b/src/clib/scale_fields.cpp @@ -15,12 +15,49 @@ #include "grackle.h" #include "fortran_func_decls.h" +#include "index_helper.h" +#include "inject_model/misc.hpp" #include "utils-cpp.hpp" #include "scale_fields_g-cpp.h" namespace grackle::impl { +void scale_inject_path_metal_densities_(const chemistry_data* my_chemistry, + grackle_field_data* my_fields, + gr_float factor) { + // each view within inj_path_view_arr wraps a field specifying the total + // metal density that was injected by an injection pathway (we allocate + // space for the max possible number of injection pathways) + // + // -> note: get_n_inject_pathway_density_ptrs returns 0 in the event that + // my_fields->inject_pathway_metal_density holds no entries + View inj_path_view_arr[inj_model_input::N_Injection_Pathways]; + int n_inject_pathways = get_n_inject_pathway_density_ptrs(my_chemistry); + for (int path_idx = 0; path_idx < n_inject_pathways; path_idx++) { + inj_path_view_arr[path_idx] = View( + my_fields->inject_pathway_metal_density[path_idx], + my_fields->grid_dimension[0], my_fields->grid_dimension[1], + my_fields->grid_dimension[2]); + } + + // parallelize the k and j loops with OpenMP + // flat j and k loops for better parallelism + const grackle_index_helper idx_helper = build_index_helper_(my_fields); + OMP_PRAGMA("omp parallel for schedule(runtime)") + for (int t = 0; t < idx_helper.outer_ind_size; t++) { + const IndexRange idx_range = make_idx_range_(t, &idx_helper); + const int k = idx_range.k; // use 0-based index + const int j = idx_range.j; // use 0-based index + for (int path_idx = 0; path_idx < n_inject_pathways; path_idx++) { + for (int i = idx_range.i_start; i < idx_range.i_stop; i++) { + inj_path_view_arr[path_idx](i, j, k) = + inj_path_view_arr[path_idx](i, j, k) * factor; + } + } + } +} + void scale_fields_g(int imetal, gr_float factor, chemistry_data* my_chemistry, grackle_field_data* my_fields) { grackle::impl::View d( @@ -185,42 +222,6 @@ void scale_fields_g(int imetal, gr_float factor, chemistry_data* my_chemistry, grackle::impl::View H2Oice( my_fields->H2O_ice_dust_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_loc( - my_fields->local_ISM_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_C13( - my_fields->ccsn13_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_C20( - my_fields->ccsn20_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_C25( - my_fields->ccsn25_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_C30( - my_fields->ccsn30_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_F13( - my_fields->fsn13_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_F15( - my_fields->fsn15_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_F50( - my_fields->fsn50_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_F80( - my_fields->fsn80_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_P170( - my_fields->pisn170_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_P200( - my_fields->pisn200_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_Y19( - my_fields->y19_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); int dj, dk; dk = my_fields->grid_end[2] - my_fields->grid_start[2] + 1; @@ -301,23 +302,6 @@ void scale_fields_g(int imetal, gr_float factor, chemistry_data* my_chemistry, } } - if (my_chemistry->multi_metals > 0) { - for (i = my_fields->grid_start[0]; i <= my_fields->grid_end[0]; i++) { - metal_loc(i, j, k) = metal_loc(i, j, k) * factor; - metal_C13(i, j, k) = metal_C13(i, j, k) * factor; - metal_C20(i, j, k) = metal_C20(i, j, k) * factor; - metal_C25(i, j, k) = metal_C25(i, j, k) * factor; - metal_C30(i, j, k) = metal_C30(i, j, k) * factor; - metal_F13(i, j, k) = metal_F13(i, j, k) * factor; - metal_F15(i, j, k) = metal_F15(i, j, k) * factor; - metal_F50(i, j, k) = metal_F50(i, j, k) * factor; - metal_F80(i, j, k) = metal_F80(i, j, k) * factor; - metal_P170(i, j, k) = metal_P170(i, j, k) * factor; - metal_P200(i, j, k) = metal_P200(i, j, k) * factor; - metal_Y19(i, j, k) = metal_Y19(i, j, k) * factor; - } - } - if ((my_chemistry->grain_growth == 1) || (my_chemistry->dust_sublimation == 1)) { if (my_chemistry->dust_species > 0) { @@ -377,7 +361,7 @@ void scale_fields_g(int imetal, gr_float factor, chemistry_data* my_chemistry, } } // OMP_PRAGMA("omp parallel") - return; + scale_inject_path_metal_densities_(my_chemistry, my_fields, factor); } } // namespace grackle::impl \ No newline at end of file diff --git a/src/clib/scale_fields.hpp b/src/clib/scale_fields.hpp index aec70be43..43cc20b76 100644 --- a/src/clib/scale_fields.hpp +++ b/src/clib/scale_fields.hpp @@ -1,7 +1,14 @@ -// See LICENSE file for license and copyright information - -/// @file scale_fields.hpp +//===----------------------------------------------------------------------===// +// +// See the LICENSE file for license and copyright information +// SPDX-License-Identifier: NCSA AND BSD-3-Clause +// +//===----------------------------------------------------------------------===// +/// +/// @file /// @brief Defines field-scaling functions (to account for cosmology) +/// +//===----------------------------------------------------------------------===// // This file was initially generated automatically during conversion of the // scale_fields_table_g function from FORTRAN to C++ @@ -50,6 +57,11 @@ inline void scale_fields_table(grackle_field_data* my_fields, double factor) { } } +/// A helper function for scaling the injection pathway metal density fields +void scale_inject_path_metal_densities_(const chemistry_data* my_chemistry, + grackle_field_data* my_fields, + gr_float factor); + /// Scales fields related to computing dust temperature inline void scale_fields_dust(chemistry_data* my_chemistry, grackle_field_data* my_fields, int imetal, @@ -60,42 +72,6 @@ inline void scale_fields_dust(chemistry_data* my_chemistry, grackle::impl::View dust( my_fields->dust_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_loc( - my_fields->local_ISM_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_C13( - my_fields->ccsn13_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_C20( - my_fields->ccsn20_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_C25( - my_fields->ccsn25_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_C30( - my_fields->ccsn30_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_F13( - my_fields->fsn13_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_F15( - my_fields->fsn15_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_F50( - my_fields->fsn50_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_F80( - my_fields->fsn80_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_P170( - my_fields->pisn170_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_P200( - my_fields->pisn200_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); - grackle::impl::View metal_Y19( - my_fields->y19_metal_density, my_fields->grid_dimension[0], - my_fields->grid_dimension[1], my_fields->grid_dimension[2]); grackle::impl::View SiM( my_fields->SiM_dust_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); @@ -148,20 +124,6 @@ inline void scale_fields_dust(chemistry_data* my_chemistry, if (imetal == 1) { for (int i = idx_range.i_start; i < idx_range.i_stop; i++) { metal(i, j, k) = metal(i, j, k) * factor; - if (my_chemistry->multi_metals > 0) { - metal_loc(i, j, k) = metal_loc(i, j, k) * factor; - metal_C13(i, j, k) = metal_C13(i, j, k) * factor; - metal_C20(i, j, k) = metal_C20(i, j, k) * factor; - metal_C25(i, j, k) = metal_C25(i, j, k) * factor; - metal_C30(i, j, k) = metal_C30(i, j, k) * factor; - metal_F13(i, j, k) = metal_F13(i, j, k) * factor; - metal_F15(i, j, k) = metal_F15(i, j, k) * factor; - metal_F50(i, j, k) = metal_F50(i, j, k) * factor; - metal_F80(i, j, k) = metal_F80(i, j, k) * factor; - metal_P170(i, j, k) = metal_P170(i, j, k) * factor; - metal_P200(i, j, k) = metal_P200(i, j, k) * factor; - metal_Y19(i, j, k) = metal_Y19(i, j, k) * factor; - } } } if (my_chemistry->use_dust_density_field == 1) { @@ -194,6 +156,8 @@ inline void scale_fields_dust(chemistry_data* my_chemistry, } } } + + scale_inject_path_metal_densities_(my_chemistry, my_fields, factor); } void scale_fields_g(int imetal, gr_float factor, chemistry_data* my_chemistry, From bbf061cb6b7448dc1d77c55f96445e461033e5de Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sat, 3 Jan 2026 12:25:06 -0500 Subject: [PATCH 171/175] remove `_metal_density` members from `grackle_field_data` --- src/clib/field_data_misc_fdatamembers.def | 18 ------------------ src/clib/inject_model/misc.hpp | 23 ----------------------- src/include/grackle_fortran_interface.def | 12 ------------ src/include/grackle_types.h | 23 ++++++----------------- src/python/gracklepy/grackle_defs.pxd | 12 ------------ 5 files changed, 6 insertions(+), 82 deletions(-) diff --git a/src/clib/field_data_misc_fdatamembers.def b/src/clib/field_data_misc_fdatamembers.def index 775ffeec2..3832322b2 100644 --- a/src/clib/field_data_misc_fdatamembers.def +++ b/src/clib/field_data_misc_fdatamembers.def @@ -31,24 +31,6 @@ ENTRY(metal_density) // use_dust_density_field = 1 ENTRY(dust_density) -// the following are included in this list because we don't evolve these species - - // metal_chemistry = 1 - // multi_metals = 0, metal_abundances = 0-11 selects one of below - // multi_metals = 1, all of below -ENTRY(local_ISM_metal_density) -ENTRY(ccsn13_metal_density) -ENTRY(ccsn20_metal_density) -ENTRY(ccsn25_metal_density) -ENTRY(ccsn30_metal_density) -ENTRY(fsn13_metal_density) -ENTRY(fsn15_metal_density) -ENTRY(fsn50_metal_density) -ENTRY(fsn80_metal_density) -ENTRY(pisn170_metal_density) -ENTRY(pisn200_metal_density) -ENTRY(y19_metal_density) - // use_volumetric_heating_rate = 1 ENTRY(volumetric_heating_rate) // use_specific_heating_rate = 1 diff --git a/src/clib/inject_model/misc.hpp b/src/clib/inject_model/misc.hpp index c008ee1fc..f4df548f1 100644 --- a/src/clib/inject_model/misc.hpp +++ b/src/clib/inject_model/misc.hpp @@ -47,29 +47,6 @@ inline int get_n_inject_pathway_density_ptrs(const chemistry_data* my_chem) { /// pathway details from user-specified HDF5 files inline const gr_float* const* get_inject_pathway_metal_density( const chemistry_data* my_chem, grackle_field_data* my_fields) { - if ((my_chem->metal_chemistry > 0) && (my_chem->multi_metals == 1) && - (my_fields->inject_pathway_metal_density[0] == nullptr)) { - my_fields->inject_pathway_metal_density[0] = - my_fields->local_ISM_metal_density; - my_fields->inject_pathway_metal_density[1] = - my_fields->ccsn13_metal_density; - my_fields->inject_pathway_metal_density[2] = - my_fields->ccsn20_metal_density; - my_fields->inject_pathway_metal_density[3] = - my_fields->ccsn25_metal_density; - my_fields->inject_pathway_metal_density[4] = - my_fields->ccsn30_metal_density; - my_fields->inject_pathway_metal_density[5] = my_fields->fsn13_metal_density; - my_fields->inject_pathway_metal_density[6] = my_fields->fsn15_metal_density; - my_fields->inject_pathway_metal_density[7] = my_fields->fsn50_metal_density; - my_fields->inject_pathway_metal_density[8] = my_fields->fsn80_metal_density; - my_fields->inject_pathway_metal_density[9] = - my_fields->pisn170_metal_density; - my_fields->inject_pathway_metal_density[10] = - my_fields->pisn200_metal_density; - my_fields->inject_pathway_metal_density[11] = my_fields->y19_metal_density; - } - if (my_chem->metal_chemistry <= 0) { return nullptr; } else if (my_chem->multi_metals == 0) { diff --git a/src/include/grackle_fortran_interface.def b/src/include/grackle_fortran_interface.def index 47755873e..a5e281976 100644 --- a/src/include/grackle_fortran_interface.def +++ b/src/include/grackle_fortran_interface.def @@ -100,18 +100,6 @@ c This is the fortran definition of grackle_field_data TYPE(C_PTR) :: ref_org_dust_density TYPE(C_PTR) :: vol_org_dust_density TYPE(C_PTR) :: H2O_ice_dust_density - TYPE(C_PTR) :: local_ISM_metal_density - TYPE(C_PTR) :: ccsn13_metal_density - TYPE(C_PTR) :: ccsn20_metal_density - TYPE(C_PTR) :: ccsn25_metal_density - TYPE(C_PTR) :: ccsn30_metal_density - TYPE(C_PTR) :: fsn13_metal_density - TYPE(C_PTR) :: fsn15_metal_density - TYPE(C_PTR) :: fsn50_metal_density - TYPE(C_PTR) :: fsn80_metal_density - TYPE(C_PTR) :: pisn170_metal_density - TYPE(C_PTR) :: pisn200_metal_density - TYPE(C_PTR) :: y19_metal_density TYPE(C_PTR) :: inject_pathway_metal_density(12) TYPE(C_PTR) :: volumetric_heating_rate TYPE(C_PTR) :: specific_heating_rate diff --git a/src/include/grackle_types.h b/src/include/grackle_types.h index f61df9eaa..8f17388a3 100644 --- a/src/include/grackle_types.h +++ b/src/include/grackle_types.h @@ -148,23 +148,12 @@ typedef struct gr_float *vol_org_dust_density; // volatile organics gr_float *H2O_ice_dust_density; // water ice - // metal_chemistry = 1 - // multi_metals = 0, metal_abundances = 0-11 selects one of below - // multi_metals = 1, all of below - gr_float *local_ISM_metal_density; - gr_float *ccsn13_metal_density; - gr_float *ccsn20_metal_density; - gr_float *ccsn25_metal_density; - gr_float *ccsn30_metal_density; - gr_float *fsn13_metal_density; - gr_float *fsn15_metal_density; - gr_float *fsn50_metal_density; - gr_float *fsn80_metal_density; - gr_float *pisn170_metal_density; - gr_float *pisn200_metal_density; - gr_float *y19_metal_density; - - // in the next few commits, this will replace all *_metal_density fields + // metal_chemistry = 1 && multi_metals = 1 + // -> the number and names of models are queried with the experimental + // ratequery interface + // -> when metal_chemistry = 1 && multi_metals = 0, Grackle currently expects + // this to be empty and uses metal_density, instead (This may change in + // the near future as we start using hdf5 configuration files) gr_float* inject_pathway_metal_density[GRIMPL_MAX_INJ_PATHWAYS]; // use_volumetric_heating_rate = 1 diff --git a/src/python/gracklepy/grackle_defs.pxd b/src/python/gracklepy/grackle_defs.pxd index ac10a6c18..479e7aa07 100644 --- a/src/python/gracklepy/grackle_defs.pxd +++ b/src/python/gracklepy/grackle_defs.pxd @@ -161,18 +161,6 @@ cdef extern from "grackle.h": gr_float *ref_org_dust_density; gr_float *vol_org_dust_density; gr_float *H2O_ice_dust_density; - gr_float *local_ISM_metal_density; - gr_float *ccsn13_metal_density; - gr_float *ccsn20_metal_density; - gr_float *ccsn25_metal_density; - gr_float *ccsn30_metal_density; - gr_float *fsn13_metal_density; - gr_float *fsn15_metal_density; - gr_float *fsn50_metal_density; - gr_float *fsn80_metal_density; - gr_float *pisn170_metal_density; - gr_float *pisn200_metal_density; - gr_float *y19_metal_density; gr_float *inject_pathway_metal_density[12]; gr_float *volumetric_heating_rate; gr_float *specific_heating_rate; From 7deb501036168c75a032b8c34357c663a5c1274f Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sat, 3 Jan 2026 14:33:00 -0500 Subject: [PATCH 172/175] gracklepy: pass inj_path_densities to grackle more efficiently --- src/python/gracklepy/fluid_container.py | 32 +++++++++++++++++++++--- src/python/gracklepy/grackle_wrapper.pyx | 16 +++++------- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/src/python/gracklepy/fluid_container.py b/src/python/gracklepy/fluid_container.py index afdd12fe6..82e07cc9a 100644 --- a/src/python/gracklepy/fluid_container.py +++ b/src/python/gracklepy/fluid_container.py @@ -339,6 +339,14 @@ def _photo_units(my_chemistry): "z_velocity": ("velocity_units", "cm/s"), } +def _shape_arg_has_integer_type(arg) -> bool: + # checks if arg has a type that `np.zeros` would both accept for the shape + # argument and be interpretted as a scalar integer + # -> note: np.zeros raises TypeError for values of `True` or `3.` + if isinstance(arg, int): + return True + tmp = np.asarray(arg) + return tmp.ndim == 0 and np.issubdtype(tmp.dtype, np.integer) class FluidContainer(dict): def __init__(self, chemistry_data, n_vals, dtype="float64", @@ -348,10 +356,26 @@ def __init__(self, chemistry_data, n_vals, dtype="float64", super(FluidContainer, self).__init__() self.dtype = dtype self.chemistry_data = chemistry_data - self.n_vals = n_vals - - for field in self.input_fields + \ - _required_calculated_fields(self.chemistry_data): + if not _shape_arg_has_integer_type(n_vals): + raise TypeError(f"expected n_vals to be an integer, got {n_vals!r}") + elif n_vals <= 0: + raise ValueError("a non-positive n_vals is not allowed") + else: + self.n_vals = int(n_vals) + + # first, allocate any injection pathway density fields so we can efficiently + # iterate over the fields' pointers in the order expected by the Grackle solver + # -> this works properly even when there are 0 injection pathways + inj_pathway_density_fields = self.inject_pathway_density_yield_fields + _shape = (len(inj_pathway_density_fields), self.n_vals) + self._inj_path_density_arrays = np.zeros(shape=_shape, dtype=self.dtype) + for i, field in enumerate(inj_pathway_density_fields): + self[field] = self._inj_path_density_arrays[i, :] + + # allocate all other fields + for field in self.input_fields + _required_calculated_fields(chemistry_data): + if field in self: + continue self._setup_fluid(field) def __getitem__(self, key): diff --git a/src/python/gracklepy/grackle_wrapper.pyx b/src/python/gracklepy/grackle_wrapper.pyx index 44a3dbbdb..a1f6a7a78 100644 --- a/src/python/gracklepy/grackle_wrapper.pyx +++ b/src/python/gracklepy/grackle_wrapper.pyx @@ -718,18 +718,14 @@ cdef c_field_data setup_field_data(object fc, int[::1] buf, my_fields.vol_org_dust_density = get_field(fc, "vol_org_dust_density") my_fields.H2O_ice_dust_density = get_field(fc, "H2O_ice_dust_density") - # todo: replace this with a faster alternative - cdef list inject_pathway_density_fields = fc.inject_pathway_density_yield_fields - cdef Py_ssize_t n_pathways = len(inject_pathway_density_fields) + # copy over pointers to all (if any) injection pathway metal density fields + # -> the data already has the order expected by the Grackle solver + cdef gr_float[:, ::1] inj_path_fields = fc._inj_path_density_arrays + assert inj_path_fields.shape[1] == fc.n_vals # sanity check + cdef Py_ssize_t n_pathways = inj_path_fields.shape[0] cdef Py_ssize_t i - cdef gr_float* ptr - #raise RuntimeError(inject_pathway_density_fields) for i in range(n_pathways): - my_fields.inject_pathway_metal_density[i] = get_field( - fc, inject_pathway_density_fields[i] - ) - if my_fields.inject_pathway_metal_density[i] is NULL: - raise RuntimeError("{!r} holds NULL".format(inject_pathway_density_fields[i])) + my_fields.inject_pathway_metal_density[i] = &inj_path_fields[i, 0] my_fields.volumetric_heating_rate = get_field(fc, "volumetric_heating_rate") my_fields.specific_heating_rate = get_field(fc, "specific_heating_rate") From 02f35e86d369824bd28c3e661ac5c2627bd6ebae Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sat, 3 Jan 2026 15:42:23 -0500 Subject: [PATCH 173/175] Make GRIMPL_MAX_INJ_PATHWAYS visible to Fortran Headers --- src/include/grackle.h | 11 +++++++++++ src/include/grackle_chemistry_data.h | 7 ------- src/include/grackle_float.h.in | 12 ++++++++++++ src/include/grackle_fortran_interface.def | 4 +++- src/include/grackle_types.h | 8 +------- 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/include/grackle.h b/src/include/grackle.h index 1a43077e4..f8d8dd548 100644 --- a/src/include/grackle.h +++ b/src/include/grackle.h @@ -416,6 +416,17 @@ unsigned long long grunstable_ratequery_nrates( } /* extern "C" */ #endif /* __cplusplus */ +#if !defined(GRIMPL_COMPILING_CORE_LIB) +// avoid leaking these macros used for defining implementation details out of +// the core library +// -> while this not essential, it's considered a good practice to do this +// (people can't use the macros if they aren't defined) +// -> note: these definitions will leak if external codes include deprecated +// (but that's probably ok) + +#undef GRACKLE_CLOUDY_TABLE_MAX_DIMENSION +#undef GRIMPL_MAX_INJ_PATHWAYS +#endif // this is important for letting us diagnose improper use of private headrs #if GRIMPL_PUBLIC_INCLUDE == 0 diff --git a/src/include/grackle_chemistry_data.h b/src/include/grackle_chemistry_data.h index 3bc2a8e47..499de6095 100644 --- a/src/include/grackle_chemistry_data.h +++ b/src/include/grackle_chemistry_data.h @@ -662,11 +662,4 @@ typedef struct } /* extern "C" */ #endif /* __cplusplus */ - -#if !defined(GRIMPL_COMPILING_CORE_LIB) -// avoid leaking these macros used for defining implementation details out of -// the core library -#undef GRACKLE_CLOUDY_TABLE_MAX_DIMENSION -#endif - #endif /* __CHEMISTRY_DATA_H__ */ diff --git a/src/include/grackle_float.h.in b/src/include/grackle_float.h.in index 9e4fa8813..6d89431a1 100644 --- a/src/include/grackle_float.h.in +++ b/src/include/grackle_float.h.in @@ -21,5 +21,17 @@ #ifndef __GRACKLE_FLOAT_H__ #define __GRACKLE_FLOAT_H__ + #define @GRACKLE_FLOAT_MACRO@ + +#ifdef __cplusplus +// GRIMPL_MAX_INJ_PATHWAYS is used to specify the maximum number of injection +// pathways that Grackle can currently model at a given time +// -> we choose to define this macro within this header so that it's exposed +// to both C and Fortran headers +// -> the existence of this macro is an implementation detail, it can/will +// be removed at any time (without warning) +#endif +#define GRIMPL_MAX_INJ_PATHWAYS 12 + #endif diff --git a/src/include/grackle_fortran_interface.def b/src/include/grackle_fortran_interface.def index a5e281976..7b541d1c3 100644 --- a/src/include/grackle_fortran_interface.def +++ b/src/include/grackle_fortran_interface.def @@ -22,6 +22,7 @@ c using the 2003 Fortran C interoperability features. Note that some c care must be taken defining matching types. c This is the fortran definition of grackle_units +#include "grackle_float.h" TYPE, BIND(C) :: grackle_units INTEGER(C_INT) :: comoving_coordinates @@ -100,7 +101,8 @@ c This is the fortran definition of grackle_field_data TYPE(C_PTR) :: ref_org_dust_density TYPE(C_PTR) :: vol_org_dust_density TYPE(C_PTR) :: H2O_ice_dust_density - TYPE(C_PTR) :: inject_pathway_metal_density(12) + TYPE(C_PTR) :: + & inject_pathway_metal_density(GRIMPL_MAX_INJ_PATHWAYS) TYPE(C_PTR) :: volumetric_heating_rate TYPE(C_PTR) :: specific_heating_rate TYPE(C_PTR) :: temperature_floor diff --git a/src/include/grackle_types.h b/src/include/grackle_types.h index 8f17388a3..e65e9f81c 100644 --- a/src/include/grackle_types.h +++ b/src/include/grackle_types.h @@ -53,8 +53,6 @@ extern "C" { #error "Both GRACKLE_FLOAT_4 and GRACKLE_FLOAT_8 are defined. Only one can be defined." #endif -#define GRIMPL_MAX_INJ_PATHWAYS 12 - typedef struct { @@ -217,11 +215,7 @@ typedef struct } grackle_version; -#if !defined(GRIMPL_COMPILING_CORE_LIB) -// avoid leaking these macros used for defining implementation details out of -// the core library -#undef GRIMPL_MAX_INJ_PATHWAYS -#endif + #ifdef __cplusplus } /* extern "C" */ From 7e2d8474035fcdab9146eda654a58c414dca3df0 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sat, 3 Jan 2026 16:06:40 -0500 Subject: [PATCH 174/175] gracklepy: add some comments pertaining to GRIMPL_MAX_INJ_PATHWAYS --- src/include/grackle_float.h.in | 2 ++ src/python/gracklepy/grackle_defs.pxd | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/src/include/grackle_float.h.in b/src/include/grackle_float.h.in index 6d89431a1..705ef977c 100644 --- a/src/include/grackle_float.h.in +++ b/src/include/grackle_float.h.in @@ -31,6 +31,8 @@ // to both C and Fortran headers // -> the existence of this macro is an implementation detail, it can/will // be removed at any time (without warning) +// -> if you update the value of this macro, make sure you update hardcoded +// value(s) used in grackle_defs.pxd #endif #define GRIMPL_MAX_INJ_PATHWAYS 12 diff --git a/src/python/gracklepy/grackle_defs.pxd b/src/python/gracklepy/grackle_defs.pxd index 479e7aa07..9b9215366 100644 --- a/src/python/gracklepy/grackle_defs.pxd +++ b/src/python/gracklepy/grackle_defs.pxd @@ -161,7 +161,15 @@ cdef extern from "grackle.h": gr_float *ref_org_dust_density; gr_float *vol_org_dust_density; gr_float *H2O_ice_dust_density; + + # the array-length should be kept synchronized with the value of the + # GRIMPL_MAX_INJ_PATHWAYS macro + # -> cython prevents us from directly using GRIMPL_MAX_INJ_PATHWAYS + # -> unfortunately cython doesn't complain if the values differ + # -> I suspect the specified length may not actually matter, but that + # is NOT confirmed by the documentation gr_float *inject_pathway_metal_density[12]; + gr_float *volumetric_heating_rate; gr_float *specific_heating_rate; gr_float *temperature_floor; From 2bb15e124026a5f280562f23b7bedfab73f907ce Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Sat, 3 Jan 2026 22:38:58 -0500 Subject: [PATCH 175/175] Some final refactoring This is uglier, but the number of inject field paths are now entirely determined by the values read in from the table. To add/remove/rename pathways, you "just" need to modify `inject_model/raw_data.[ch]pp` and `inject_model/load_data.[ch]pp`. This is a massive step that will make it possible to move this data into HDF5 tables --- src/clib/calc_tdust_3d.cpp | 9 +++++++-- src/clib/cool_multi_time_g.cpp | 11 ++++++++--- src/clib/inject_model/misc.hpp | 26 +++++++++++++++++++------ src/clib/inject_model/raw_data.hpp | 2 +- src/clib/scale_fields.cpp | 17 ++++++---------- src/clib/scale_fields.hpp | 31 ++++++++++++++++++++++++------ src/clib/solve_rate_cool_g-cpp.cpp | 11 ++++++++--- 7 files changed, 75 insertions(+), 32 deletions(-) diff --git a/src/clib/calc_tdust_3d.cpp b/src/clib/calc_tdust_3d.cpp index 2035b424d..f2521bd23 100644 --- a/src/clib/calc_tdust_3d.cpp +++ b/src/clib/calc_tdust_3d.cpp @@ -23,6 +23,7 @@ #include "grackle.h" #include "index_helper.h" #include "inject_model/grain_metal_inject_pathways.hpp" +#include "inject_model/misc.hpp" #include "internal_types.hpp" #include "scale_fields.hpp" #include "utils-cpp.hpp" @@ -61,7 +62,9 @@ void calc_tdust_3d_g( // Convert densities to 'proper' from comoving if (internalu.extfields_in_comoving == 1) { gr_float factor = (gr_float)(1.0)/(gr_float)std::pow(internalu.a_value,3); - grackle::impl::scale_fields_dust(my_chemistry, my_fields, imetal, factor); + grackle::impl::scale_fields_dust( + my_chemistry, my_fields, imetal, factor, + grackle::impl::get_n_inject_pathway_density_ptrs(my_rates)); } OMP_PRAGMA("omp parallel") @@ -305,7 +308,9 @@ void calc_tdust_3d_g( // Convert densities back to comoving from 'proper' if (internalu.extfields_in_comoving == 1) { gr_float factor = (gr_float)std::pow(internalu.a_value,3); - grackle::impl::scale_fields_dust(my_chemistry, my_fields, imetal, factor); + grackle::impl::scale_fields_dust( + my_chemistry, my_fields, imetal, factor, + grackle::impl::get_n_inject_pathway_density_ptrs(my_rates)); } return; diff --git a/src/clib/cool_multi_time_g.cpp b/src/clib/cool_multi_time_g.cpp index 1299e1267..5a8ec0793 100644 --- a/src/clib/cool_multi_time_g.cpp +++ b/src/clib/cool_multi_time_g.cpp @@ -21,11 +21,12 @@ #include "grackle.h" #include "fortran_func_wrappers.hpp" #include "index_helper.h" +#include "inject_model/misc.hpp" #include "internal_units.h" #include "internal_types.hpp" #include "utils-cpp.hpp" -#include "scale_fields_g-cpp.h" +#include "scale_fields.hpp" #ifdef __cplusplus extern "C" { @@ -42,7 +43,9 @@ void cool_multi_time_g( // Convert densities from comoving to 'proper' if (internalu.extfields_in_comoving == 1) { gr_float factor = (gr_float)(std::pow(internalu.a_value,(-3)) ); - grackle::impl::scale_fields_g(imetal, factor, my_chemistry, my_fields); + grackle::impl::scale_fields_g( + imetal, factor, my_chemistry, my_fields, + grackle::impl::get_n_inject_pathway_density_ptrs(my_rates)); } @@ -132,7 +135,9 @@ void cool_multi_time_g( // Convert densities back to comoving from 'proper' if (internalu.extfields_in_comoving == 1) { gr_float factor = (gr_float)(std::pow(internalu.a_value,3) ); - grackle::impl::scale_fields_g(imetal, factor, my_chemistry, my_fields); + grackle::impl::scale_fields_g( + imetal, factor, my_chemistry, my_fields, + grackle::impl::get_n_inject_pathway_density_ptrs(my_rates)); } return; diff --git a/src/clib/inject_model/misc.hpp b/src/clib/inject_model/misc.hpp index f4df548f1..37a96cf8c 100644 --- a/src/clib/inject_model/misc.hpp +++ b/src/clib/inject_model/misc.hpp @@ -13,18 +13,32 @@ #ifndef INJECT_MODEL_MISC_HPP #define INJECT_MODEL_MISC_HPP +#include "opaque_storage.hpp" #include "raw_data.hpp" // grackle::impl::inj_model_input::N_Injection_Pathways +#include "status_reporting.h" namespace grackle::impl { /// this is a hacky short-term helper function /// -/// @todo -/// Get rid of this function. This will be necessary in the future in order to -/// start reading injection pathway details from user-specified HDF5 files. -inline int get_n_inject_pathway_density_ptrs(const chemistry_data* my_chem) { - bool nonzero = (my_chem->metal_chemistry > 0) && (my_chem->multi_metals > 0); - return (nonzero) ? grackle::impl::inj_model_input::N_Injection_Pathways : 0; +/// @note +/// Because (at the time of writing), when `metal_chemistry > 0` and +/// `multi_metals == 0`, Grackle simply uses the `metal_density` field rather +/// than a pointer from `my_fields->inject_pathway_metal_density`, this function +/// returns 0 in that case. +inline int get_n_inject_pathway_density_ptrs( + const chemistry_data_storage* my_rates) { + const gr_opaque_storage* tmp = my_rates->opaque_storage; + GR_INTERNAL_REQUIRE(tmp != nullptr, "sanity-check failed!"); + + if (tmp->inject_pathway_props == nullptr) { + return 0; + } + int n_pathways = tmp->inject_pathway_props->n_pathways; + // at the time of writing, the only way `n_pathways` can have a value of 1 is + // when `metal_chemistry > 0 && multi_metals == 0` + // -> as we note in the docstring, we return 0 in this case + return (n_pathways == 1) ? 0 : n_pathways; } /// Retrieves a pointer that corresponds to the array of user-specified fields diff --git a/src/clib/inject_model/raw_data.hpp b/src/clib/inject_model/raw_data.hpp index 6486b5602..95a013d5b 100644 --- a/src/clib/inject_model/raw_data.hpp +++ b/src/clib/inject_model/raw_data.hpp @@ -37,7 +37,7 @@ static constexpr int N_Opacity_Coef = 4; static constexpr int N_Tdust_Opacity_Table = 35; /// the number of hard-coded injection pathways -static constexpr int N_Injection_Pathways = 12; +static constexpr int N_Injection_Pathways = GRIMPL_MAX_INJ_PATHWAYS; struct MetalNuclideYieldProps; struct GrainSpeciesYieldProps; diff --git a/src/clib/scale_fields.cpp b/src/clib/scale_fields.cpp index 9d425d676..2cb7e89ee 100644 --- a/src/clib/scale_fields.cpp +++ b/src/clib/scale_fields.cpp @@ -14,18 +14,14 @@ #include #include "grackle.h" -#include "fortran_func_decls.h" #include "index_helper.h" #include "inject_model/misc.hpp" #include "utils-cpp.hpp" -#include "scale_fields_g-cpp.h" - namespace grackle::impl { -void scale_inject_path_metal_densities_(const chemistry_data* my_chemistry, - grackle_field_data* my_fields, - gr_float factor) { +void scale_inject_path_metal_densities_(grackle_field_data* my_fields, + gr_float factor, int n_inj_path_ptrs) { // each view within inj_path_view_arr wraps a field specifying the total // metal density that was injected by an injection pathway (we allocate // space for the max possible number of injection pathways) @@ -33,8 +29,7 @@ void scale_inject_path_metal_densities_(const chemistry_data* my_chemistry, // -> note: get_n_inject_pathway_density_ptrs returns 0 in the event that // my_fields->inject_pathway_metal_density holds no entries View inj_path_view_arr[inj_model_input::N_Injection_Pathways]; - int n_inject_pathways = get_n_inject_pathway_density_ptrs(my_chemistry); - for (int path_idx = 0; path_idx < n_inject_pathways; path_idx++) { + for (int path_idx = 0; path_idx < n_inj_path_ptrs; path_idx++) { inj_path_view_arr[path_idx] = View( my_fields->inject_pathway_metal_density[path_idx], my_fields->grid_dimension[0], my_fields->grid_dimension[1], @@ -49,7 +44,7 @@ void scale_inject_path_metal_densities_(const chemistry_data* my_chemistry, const IndexRange idx_range = make_idx_range_(t, &idx_helper); const int k = idx_range.k; // use 0-based index const int j = idx_range.j; // use 0-based index - for (int path_idx = 0; path_idx < n_inject_pathways; path_idx++) { + for (int path_idx = 0; path_idx < n_inj_path_ptrs; path_idx++) { for (int i = idx_range.i_start; i < idx_range.i_stop; i++) { inj_path_view_arr[path_idx](i, j, k) = inj_path_view_arr[path_idx](i, j, k) * factor; @@ -59,7 +54,7 @@ void scale_inject_path_metal_densities_(const chemistry_data* my_chemistry, } void scale_fields_g(int imetal, gr_float factor, chemistry_data* my_chemistry, - grackle_field_data* my_fields) { + grackle_field_data* my_fields, int n_inj_path_ptrs) { grackle::impl::View d( my_fields->density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); @@ -361,7 +356,7 @@ void scale_fields_g(int imetal, gr_float factor, chemistry_data* my_chemistry, } } // OMP_PRAGMA("omp parallel") - scale_inject_path_metal_densities_(my_chemistry, my_fields, factor); + scale_inject_path_metal_densities_(my_fields, factor, n_inj_path_ptrs); } } // namespace grackle::impl \ No newline at end of file diff --git a/src/clib/scale_fields.hpp b/src/clib/scale_fields.hpp index 43cc20b76..4583bbee4 100644 --- a/src/clib/scale_fields.hpp +++ b/src/clib/scale_fields.hpp @@ -58,14 +58,25 @@ inline void scale_fields_table(grackle_field_data* my_fields, double factor) { } /// A helper function for scaling the injection pathway metal density fields -void scale_inject_path_metal_densities_(const chemistry_data* my_chemistry, - grackle_field_data* my_fields, - gr_float factor); +/// +/// @param[inout] my_fields holds the fields that will be updated in-place +/// @param[in] factor The factor that is multiplied by the fields +/// @param[in] n_inj_path_ptrs The number of pointers tracked by +/// `my_fields->inject_pathway_metal_density` +void scale_inject_path_metal_densities_(grackle_field_data* my_fields, + gr_float factor, int n_inj_path_ptrs); /// Scales fields related to computing dust temperature +/// +/// @param[in] my_chemistry holds a number of configuration parameters +/// @param[inout] my_fields holds the fields that will be updated in-place +/// @param[in] imetal Specifies whether the metal_density was specified +/// @param[in] factor The factor that is multiplied by the fields +/// @param[in] n_inj_path_ptrs The number of pointers tracked by +/// `my_fields->inject_pathway_metal_density` inline void scale_fields_dust(chemistry_data* my_chemistry, grackle_field_data* my_fields, int imetal, - gr_float factor) { + gr_float factor, int n_inj_path_ptrs) { grackle::impl::View metal( my_fields->metal_density, my_fields->grid_dimension[0], my_fields->grid_dimension[1], my_fields->grid_dimension[2]); @@ -157,11 +168,19 @@ inline void scale_fields_dust(chemistry_data* my_chemistry, } } - scale_inject_path_metal_densities_(my_chemistry, my_fields, factor); + scale_inject_path_metal_densities_(my_fields, factor, n_inj_path_ptrs); } +/// Scales fields related to computing dust temperature +/// +/// @param[in] imetal Specifies whether the metal_density was specified +/// @param[in] factor The factor that is multiplied by the fields +/// @param[in] my_chemistry holds a number of configuration parameters +/// @param[inout] my_fields holds the fields that will be updated in-place +/// @param[in] n_inj_path_ptrs The number of pointers tracked by +/// `my_fields->inject_pathway_metal_density` void scale_fields_g(int imetal, gr_float factor, chemistry_data* my_chemistry, - grackle_field_data* my_fields); + grackle_field_data* my_fields, int n_inj_path_ptrs); } // namespace grackle::impl diff --git a/src/clib/solve_rate_cool_g-cpp.cpp b/src/clib/solve_rate_cool_g-cpp.cpp index 453b3090c..2222f64b0 100644 --- a/src/clib/solve_rate_cool_g-cpp.cpp +++ b/src/clib/solve_rate_cool_g-cpp.cpp @@ -22,6 +22,7 @@ #include "fortran_func_wrappers.hpp" #include "index_helper.h" #include "inject_model/grain_metal_inject_pathways.hpp" +#include "inject_model/misc.hpp" #include "internal_types.hpp" #include "internal_units.h" #include "lookup_cool_rates1d.hpp" @@ -33,7 +34,7 @@ #include "visitor/memory.hpp" #include "ceiling_species.hpp" -#include "scale_fields_g-cpp.h" +#include "scale_fields.hpp" #include "solve_rate_cool_g-cpp.h" /// overrides the subcycle timestep (for each index in the index-range that is @@ -682,7 +683,9 @@ int solve_rate_cool_g( if (internalu.extfields_in_comoving == 1) { gr_float factor = (gr_float)(std::pow(internalu.a_value,(-3)) ); - grackle::impl::scale_fields_g(imetal, factor, my_chemistry, my_fields); + grackle::impl::scale_fields_g( + imetal, factor, my_chemistry, my_fields, + grackle::impl::get_n_inject_pathway_density_ptrs(my_rates)); } grackle::impl::ceiling_species(imetal, my_chemistry, my_fields); @@ -1007,7 +1010,9 @@ int solve_rate_cool_g( if (internalu.extfields_in_comoving == 1) { gr_float factor = (gr_float)(std::pow(internalu.a_value,3) ); - grackle::impl::scale_fields_g(imetal, factor, my_chemistry, my_fields); + grackle::impl::scale_fields_g( + imetal, factor, my_chemistry, my_fields, + grackle::impl::get_n_inject_pathway_density_ptrs(my_rates)); } if (my_chemistry->primordial_chemistry > 0) {