diff --git a/.gitignore b/.gitignore index cbadc197..aa376fb5 100644 --- a/.gitignore +++ b/.gitignore @@ -77,10 +77,11 @@ subprojects/liblogging/ subprojects/eigen-*/ subprojects/fourdst/ subprojects/libplugin/ -subprojects/minizip-ng-4.0.10/ +subprojects/minizip-ng-*/ subprojects/cvode-*/ subprojects/kinsol-*/ subprojects/CLI11-*/ +subprojects/openssl-*/ *.fbundle *.wraplock @@ -95,6 +96,7 @@ libconfig.wrap libconstants.wrap liblogging.wrap minizip-ng.wrap +openssl.wrap .vscode/ diff --git a/build-config/meson.build b/build-config/meson.build index 864988aa..08312c6c 100644 --- a/build-config/meson.build +++ b/build-config/meson.build @@ -5,7 +5,6 @@ subdir('libplugin') subdir('sundials') -subdir('boost') subdir('cppad') subdir('xxHash') subdir('eigen') diff --git a/meson.build b/meson.build index 8d13d0c7..1bbc4d8b 100644 --- a/meson.build +++ b/meson.build @@ -39,12 +39,34 @@ if meson.get_compiler('cpp').get_id() == 'gcc' # We disable these because of boost notes about abi changes from C++10 -> C++17 make the build too noisey message('disabling psabi warnings for gcc') add_project_arguments('-Wno-psabi', language: 'cpp') + + if (meson.get_compiler('cpp').version().version_compare('<14.0')) + error('g++ version must be at least 14.0, found ' + meson.get_compiler('cpp').version()) + endif +endif + +build_fortran = get_option('build-fortran') +if (build_fortran) + add_languages('fortran', native: true) + message('Building fortran module (gridfire_mod.mod)') + fc = meson.get_compiler('fortran') + if not get_option('unsafe-fortran') + if fc.get_id() != 'gcc' + error('The only supported fortran compiler for GridFire is gfortran (version >= 14.0), found ' + fc + '. GridFire has not been tested with any other compilers. You can disable this check with the -Dunsafe-fortran=true flag to try other compilers') + endif + endif +endif + + + +if (meson.get_compiler('fortran').version().version_compare('<14.0')) + error('gfortran version must be at least 14.0, found ' + meson.get_compiler('fortran').version()) endif # For Eigen add_project_arguments('-Wno-deprecated-declarations', language: 'cpp') -llevel = get_option('log_level') +llevel = get_option('log-level') logbase='QUILL_COMPILE_ACTIVE_LOG_LEVEL_' diff --git a/meson_options.txt b/meson_options.txt index c42ba6fa..868af617 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,4 +1,6 @@ -option('log_level', type: 'combo', choices: ['traceL3', 'traceL2', 'traceL1', 'debug', 'info', 'warning', 'error', 'critial'], value: 'info', description: 'Set the log level for the GridFire library') +option('log-level', type: 'combo', choices: ['traceL3', 'traceL2', 'traceL1', 'debug', 'info', 'warning', 'error', 'critial'], value: 'info', description: 'Set the log level for the GridFire library') option('pkg-config', type: 'boolean', value: true, description: 'generate pkg-config file for GridFire (gridfire.pc)') option('build-python', type: 'boolean', value: true, description: 'build the python bindings so you can use GridFire from python') option('build-tests', type: 'boolean', value: true, description: 'build the test suite') +option('build-fortran', type: 'boolean', value: true, description: 'build fortran module support') +option('unsafe-fortran', type: 'boolean', value: false, description: 'Allow untested fortran compilers (compilers other than gfortran)') diff --git a/src/include/gridfire/engine/engine_graph.h b/src/include/gridfire/engine/engine_graph.h index c710dbc4..96b2d083 100644 --- a/src/include/gridfire/engine/engine_graph.h +++ b/src/include/gridfire/engine/engine_graph.h @@ -20,7 +20,6 @@ #include #include -#include #include "cppad/cppad.hpp" #include "cppad/utility/sparse_rc.hpp" @@ -863,7 +862,6 @@ namespace gridfire::engine { std::unordered_map m_speciesToIndexMap; ///< Map from species to their index in the stoichiometry matrix. std::unordered_map m_indexToSpeciesMap; ///< Map from index to species in the stoichiometry matrix. - boost::numeric::ublas::compressed_matrix m_stoichiometryMatrix; ///< Stoichiometry matrix (species x reactions). mutable CppAD::ADFun m_rhsADFun; ///< CppAD function for the right-hand side of the ODE. mutable CppAD::ADFun m_epsADFun; ///< CppAD function for the energy generation rate. @@ -1281,4 +1279,4 @@ namespace gridfire::engine { return molar_concentration_product * k_reaction * densityTerm; } -}; \ No newline at end of file +}; diff --git a/src/lib/engine/engine_graph.cpp b/src/lib/engine/engine_graph.cpp index b13fb6df..cbc1e97c 100644 --- a/src/lib/engine/engine_graph.cpp +++ b/src/lib/engine/engine_graph.cpp @@ -24,9 +24,6 @@ #include #include -#include -#include - #include "cppad/cppad.hpp" #include "cppad/utility/sparse_rc.hpp" #include "cppad/utility/sparse_rcv.hpp" @@ -819,9 +816,9 @@ namespace gridfire::engine { LOG_TRACE_L1(m_logger, "Generating stoichiometry matrix..."); // Task 1: Set dimensions and initialize the matrix - size_t numSpecies = m_networkSpecies.size(); - size_t numReactions = m_reactions.size(); - m_stoichiometryMatrix.resize(numSpecies, numReactions, false); + // size_t numSpecies = m_networkSpecies.size(); + // size_t numReactions = m_reactions.size(); + // m_stoichiometryMatrix.resize(numSpecies, numReactions, false); LOG_TRACE_L1(m_logger, "Stoichiometry matrix initialized with dimensions: {} rows (species) x {} columns (reactions).", numSpecies, numReactions); @@ -838,9 +835,9 @@ namespace gridfire::engine { // Find the row index for this species auto it = m_speciesToIndexMap.find(species); if (it != m_speciesToIndexMap.end()) { - const size_t speciesRowIndex = it->second; + // const size_t speciesRowIndex = it->second; // Set the matrix element. Boost.uBLAS handles sparse insertion. - m_stoichiometryMatrix(speciesRowIndex, reactionColumnIndex) = coefficient; + // m_stoichiometryMatrix(speciesRowIndex, reactionColumnIndex) = coefficient; } else { // This scenario should ideally not happen if m_networkSpeciesMap and m_speciesToIndexMap are correctly synced LOG_ERROR(m_logger, "CRITICAL ERROR: Species '{}' from reaction '{}' stoichiometry not found in species to index map.", @@ -852,8 +849,6 @@ namespace gridfire::engine { reactionColumnIndex++; // Move to the next column for the next reaction } - LOG_TRACE_L1(m_logger, "Stoichiometry matrix population complete. Number of non-zero elements: {}.", - m_stoichiometryMatrix.nnz()); // Assuming nnz() exists for compressed_matrix } void GraphEngine::setScreeningModel(const screening::ScreeningType model) { diff --git a/src/lib/engine/types/jacobian.cpp b/src/lib/engine/types/jacobian.cpp index 7535e476..99f0a3b5 100644 --- a/src/lib/engine/types/jacobian.cpp +++ b/src/lib/engine/types/jacobian.cpp @@ -15,7 +15,7 @@ namespace gridfire::engine { const Eigen::SparseMatrix& jacobianMatrix, const std::function &indexToSpeciesFunc ): m_jacobianMatrix(jacobianMatrix) { - for (size_t i = 0; i < jacobianMatrix.rows(); ++i) { + for (long int i = 0; i < jacobianMatrix.rows(); ++i) { fourdst::atomic::Species species = indexToSpeciesFunc(i); m_speciesToIndexMap[species] = i; } @@ -57,7 +57,7 @@ namespace gridfire::engine { } double NetworkJacobian::operator()(const size_t i, const size_t j) const { - if (i >= m_jacobianMatrix.rows() || j >= m_jacobianMatrix.cols()) { + if (i >= static_cast(m_jacobianMatrix.rows()) || j >= static_cast(m_jacobianMatrix.cols())) { throw std::out_of_range(std::format("Index ({}, {}) out of bounds in NetworkJacobian operator() for jacobian of shape ({}, {}).", i, j, m_jacobianMatrix.rows(), m_jacobianMatrix.cols())); } return m_jacobianMatrix.coeff(i, j); @@ -73,7 +73,7 @@ namespace gridfire::engine { } void NetworkJacobian::set(const size_t i, const size_t j, const double value) { - if (i >= m_jacobianMatrix.rows() || j >= m_jacobianMatrix.cols()) { + if (i >= static_cast(m_jacobianMatrix.rows()) || j >= static_cast(m_jacobianMatrix.cols())) { throw std::out_of_range(std::format("Index ({}, {}) out of bounds in NetworkJacobian set() for jacobian of shape ({}, {}).", i, j, m_jacobianMatrix.rows(), m_jacobianMatrix.cols())); } m_jacobianMatrix.coeffRef(i, j) = value; diff --git a/src/meson.build b/src/meson.build index bf6b7014..4532d6da 100644 --- a/src/meson.build +++ b/src/meson.build @@ -31,7 +31,6 @@ gridfire_sources = files( gridfire_build_dependencies = [ - boost_dep, const_dep, config_dep, composition_dep, @@ -67,4 +66,4 @@ if get_option('build-python') subdir('python') else message('Skipping Python bindings...') -endif \ No newline at end of file +endif diff --git a/subprojects/fourdst.wrap b/subprojects/fourdst.wrap index b97019bc..f8a87d6d 100644 --- a/subprojects/fourdst.wrap +++ b/subprojects/fourdst.wrap @@ -1,4 +1,4 @@ [wrap-git] url = https://github.com/4D-STAR/fourdst -revision = v0.9.7 +revision = v0.9.8 depth = 1 diff --git a/subprojects/libplugin.wrap b/subprojects/libplugin.wrap index dd4476b5..b8a3eda5 100644 --- a/subprojects/libplugin.wrap +++ b/subprojects/libplugin.wrap @@ -1,4 +1,4 @@ [wrap-git] url = https://github.com/4D-STAR/libplugin -revision = v0.3.4 +revision = v0.3.5 depth = 1 diff --git a/tests/graphnet_sandbox/main.cpp b/tests/graphnet_sandbox/main.cpp index 4455606f..217cfe38 100644 --- a/tests/graphnet_sandbox/main.cpp +++ b/tests/graphnet_sandbox/main.cpp @@ -15,16 +15,12 @@ #include -#include - #include "gridfire/reaction/reaclib.h" static std::terminate_handler g_previousHandler = nullptr; -boost::json::object g_reaction_contribution_history; static std::vector>>> g_callbackHistory; static bool s_wrote_abundance_history = false; -static bool s_wrote_reaction_history = false; void quill_terminate_handler(); gridfire::NetIn init(const double temp, const double rho, const double tMax) { @@ -164,37 +160,6 @@ void record_abundance_history_callback(const gridfire::solver::CVODESolverStrate g_callbackHistory.emplace_back(ctx.t, abundances); } -size_t g_iters = 0; -void record_contribution_callback(const gridfire::solver::CVODESolverStrategy::TimestepContext& ctx) { - s_wrote_reaction_history = true; - boost::json::object timestep; - boost::json::object reaction_contribution; - boost::json::object species_abundance; - std::set activeSpecies(ctx.engine.getNetworkSpecies().begin(), ctx.engine.getNetworkSpecies().end()); - for (const auto& [species, contributions] : ctx.reactionContributionMap) { - boost::json::object species_obj; - for (const auto& [reaction_id, contribution] : contributions) { - species_obj[reaction_id] = contribution; - } - reaction_contribution[std::string(species.name())] = species_obj; - - double y; - if (activeSpecies.contains(species)) { - const size_t sid = ctx.engine.getSpeciesIndex(species); - y = N_VGetArrayPointer(ctx.state)[sid]; - } else { - y = 0.0; - } - - species_abundance[std::string(species.name())] = y; - } - timestep["t"] = ctx.t; - timestep["dt"] = ctx.dt; - timestep["reaction_contribution"] = reaction_contribution; - timestep["species_abundance"] = species_abundance; - g_reaction_contribution_history[std::to_string(g_iters)] = timestep; - g_iters++; -} void save_callback_data(const std::string_view filename) { std::set unique_species; @@ -243,12 +208,6 @@ void log_callback_data(const double temp) { save_callback_data("abundance_history_" + std::to_string(temp) + ".csv"); } - if (s_wrote_reaction_history) { - std::cout << "Saving reaction history to reaction_contribution_history.json" << std::endl; - std::ofstream jsonFile("reaction_contribution_history_" + std::to_string(temp) + ".json", std::ios::out); - jsonFile << boost::json::serialize(g_reaction_contribution_history); - jsonFile.close(); - } } void quill_terminate_handler() @@ -263,7 +222,6 @@ void quill_terminate_handler() void callback_main(const gridfire::solver::CVODESolverStrategy::TimestepContext& ctx) { record_abundance_history_callback(ctx); - record_contribution_callback(ctx); } int main(int argc, char** argv) { @@ -294,4 +252,4 @@ int main(int argc, char** argv) { log_results(netOut, netIn); log_callback_data(temp); -} \ No newline at end of file +}