From a75a94d46724a0463509e76544f345176ab6e1cf Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Mon, 21 Apr 2025 08:56:45 -0400 Subject: [PATCH 1/4] docs(src): updated file headers --- src/network/private/approx8.cpp | 20 ++++++++++++++++++++ src/network/private/network.cpp | 20 ++++++++++++++++++++ src/network/public/approx8.h | 20 ++++++++++++++++++++ src/network/public/network.h | 20 ++++++++++++++++++++ 4 files changed, 80 insertions(+) diff --git a/src/network/private/approx8.cpp b/src/network/private/approx8.cpp index c9e597a7..a0aad988 100644 --- a/src/network/private/approx8.cpp +++ b/src/network/private/approx8.cpp @@ -1,3 +1,23 @@ +/* *********************************************************************** +// +// Copyright (C) 2025 -- The 4D-STAR Collaboration +// File Author: Emily Boudreaux +// Last Modified: March 21, 2025 +// +// 4DSSE is free software; you can use it and/or modify +// it under the terms and restrictions the GNU General Library Public +// License version 3 (GPLv3) as published by the Free Software Foundation. +// +// 4DSSE is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public License +// along with this software; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// *********************************************************************** */ #include #include #include diff --git a/src/network/private/network.cpp b/src/network/private/network.cpp index 5ffaac70..8a95af4c 100644 --- a/src/network/private/network.cpp +++ b/src/network/private/network.cpp @@ -1,3 +1,23 @@ +/* *********************************************************************** +// +// Copyright (C) 2025 -- The 4D-STAR Collaboration +// File Authors: Aaron Dotter, Emily Boudreaux +// Last Modified: March 21, 2025 +// +// 4DSSE is free software; you can use it and/or modify +// it under the terms and restrictions the GNU General Library Public +// License version 3 (GPLv3) as published by the Free Software Foundation. +// +// 4DSSE is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public License +// along with this software; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// *********************************************************************** */ #include "network.h" #include "probe.h" #include "quill/LogMacros.h" diff --git a/src/network/public/approx8.h b/src/network/public/approx8.h index 75d88e89..cb9e01aa 100644 --- a/src/network/public/approx8.h +++ b/src/network/public/approx8.h @@ -1,3 +1,23 @@ +/* *********************************************************************** +// +// Copyright (C) 2025 -- The 4D-STAR Collaboration +// File Author: Emily Boudreaux +// Last Modified: March 21, 2025 +// +// 4DSSE is free software; you can use it and/or modify +// it under the terms and restrictions the GNU General Library Public +// License version 3 (GPLv3) as published by the Free Software Foundation. +// +// 4DSSE is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public License +// along with this software; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// *********************************************************************** */ #ifndef APPROX8_H #define APPROX8_H diff --git a/src/network/public/network.h b/src/network/public/network.h index 9cb6a3c8..82f24d6d 100644 --- a/src/network/public/network.h +++ b/src/network/public/network.h @@ -1,3 +1,23 @@ +/* *********************************************************************** +// +// Copyright (C) 2025 -- The 4D-STAR Collaboration +// File Authors: Emily Boudreaux, Aaron Dotter +// Last Modified: March 21, 2025 +// +// 4DSSE is free software; you can use it and/or modify +// it under the terms and restrictions the GNU General Library Public +// License version 3 (GPLv3) as published by the Free Software Foundation. +// +// 4DSSE is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public License +// along with this software; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// *********************************************************************** */ #ifndef NETWORK_H #define NETWORK_H From c5296dd2e6368cb6187bbab2e233a7e125b3003a Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Tue, 6 May 2025 15:27:40 -0400 Subject: [PATCH 2/4] refactor(network): header guard -> pragma once --- src/network/public/approx8.h | 5 +---- src/network/public/network.h | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/network/public/approx8.h b/src/network/public/approx8.h index cb9e01aa..6977df79 100644 --- a/src/network/public/approx8.h +++ b/src/network/public/approx8.h @@ -18,8 +18,7 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // *********************************************************************** */ -#ifndef APPROX8_H -#define APPROX8_H +#pragma once #include @@ -330,5 +329,3 @@ namespace nnApprox8{ }; } // namespace nnApprox8 - -#endif \ No newline at end of file diff --git a/src/network/public/network.h b/src/network/public/network.h index 82f24d6d..36f50589 100644 --- a/src/network/public/network.h +++ b/src/network/public/network.h @@ -18,8 +18,7 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // *********************************************************************** */ -#ifndef NETWORK_H -#define NETWORK_H +#pragma once #include @@ -109,5 +108,3 @@ namespace nuclearNetwork { }; } // namespace nuclearNetwork - -#endif // NETWORK_H \ No newline at end of file From 81323d60a0750af01487b6fb836623a6e4136e16 Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Wed, 11 Jun 2025 14:49:11 -0400 Subject: [PATCH 3/4] refactor(serif): refactored entire codebase into serif and sub namespaces --- src/network/private/approx8.cpp | 12 ++++++------ src/network/private/network.cpp | 8 ++++---- src/network/public/approx8.h | 8 ++++---- src/network/public/network.h | 6 +++--- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/network/private/approx8.cpp b/src/network/private/approx8.cpp index a0aad988..c485765e 100644 --- a/src/network/private/approx8.cpp +++ b/src/network/private/approx8.cpp @@ -72,7 +72,7 @@ The coefficients to the fit are from reaclib.jinaweb.org . */ -namespace nnApprox8{ +namespace serif::network::approx8{ // using namespace std; using namespace boost::numeric::odeint; @@ -245,7 +245,7 @@ namespace nnApprox8{ // a Jacobian matrix for implicit solvers void Jacobian::operator() ( const vector_type &y, matrix_type &J, double /* t */, vector_type &dfdt ) { - Constants& constants = Constants::getInstance(); + serif::constant::Constants& constants = serif::constant::Constants::getInstance(); const double avo = constants.get("N_a").value; const double clight = constants.get("c").value; // EOS @@ -350,7 +350,7 @@ namespace nnApprox8{ } void ODE::operator() ( const vector_type &y, vector_type &dydt, double /* t */) { - Constants& constants = Constants::getInstance(); + serif::constant::Constants& constants = serif::constant::Constants::getInstance(); const double avo = constants.get("N_a").value; const double clight = constants.get("c").value; @@ -444,7 +444,7 @@ namespace nnApprox8{ dydt[Net::iener] = -enuc*avo*clight*clight; } - nuclearNetwork::NetOut Approx8Network::evaluate(const nuclearNetwork::NetIn &netIn) { + NetOut Approx8Network::evaluate(const NetIn &netIn) { m_y = convert_netIn(netIn); m_tmax = netIn.tmax; m_dt0 = netIn.dt0; @@ -488,7 +488,7 @@ namespace nnApprox8{ m_y[i] /= ysum; } - nuclearNetwork::NetOut netOut; + NetOut netOut; std::vector outComposition; outComposition.reserve(Net::nvar); @@ -506,7 +506,7 @@ namespace nnApprox8{ m_stiff = stiff; } - vector_type Approx8Network::convert_netIn(const nuclearNetwork::NetIn &netIn) { + vector_type Approx8Network::convert_netIn(const NetIn &netIn) { if (netIn.composition.size() != Net::niso) { LOG_ERROR(m_logger, "Error: composition size mismatch in convert_netIn"); throw std::runtime_error("Error: composition size mismatch in convert_netIn"); diff --git a/src/network/private/network.cpp b/src/network/private/network.cpp index 8a95af4c..d3b3b25e 100644 --- a/src/network/private/network.cpp +++ b/src/network/private/network.cpp @@ -22,13 +22,13 @@ #include "probe.h" #include "quill/LogMacros.h" -namespace nuclearNetwork { +namespace serif::network { Network::Network() : - m_config(Config::getInstance()), - m_logManager(Probe::LogManager::getInstance()), + m_config(serif::config::Config::getInstance()), + m_logManager(serif::probe::LogManager::getInstance()), m_logger(m_logManager.getLogger("log")) { } - nuclearNetwork::NetOut nuclearNetwork::Network::evaluate(const NetIn &netIn) { + NetOut Network::evaluate(const NetIn &netIn) { // You can throw an exception here or log a warning if it should never be used. LOG_ERROR(m_logger, "nuclearNetwork::Network::evaluate() is not implemented"); throw std::runtime_error("nuclearNetwork::Network::evaluate() is not implemented"); diff --git a/src/network/public/approx8.h b/src/network/public/approx8.h index 6977df79..711d2a1e 100644 --- a/src/network/public/approx8.h +++ b/src/network/public/approx8.h @@ -53,7 +53,7 @@ typedef boost::numeric::ublas::matrix< double > matrix_type; */ typedef std::array vec7; -namespace nnApprox8{ +namespace serif::network::approx8{ using namespace boost::numeric::odeint; @@ -294,14 +294,14 @@ namespace nnApprox8{ * @class Approx8Network * @brief Class for the Approx8 nuclear reaction network. */ - class Approx8Network : public nuclearNetwork::Network { + class Approx8Network : public Network { public: /** * @brief Evaluates the nuclear network. * @param netIn Input parameters for the network. * @return Output results from the network. */ - virtual nuclearNetwork::NetOut evaluate(const nuclearNetwork::NetIn &netIn); + virtual NetOut evaluate(const NetIn &netIn); /** * @brief Sets whether the solver should use a stiff method. @@ -325,7 +325,7 @@ namespace nnApprox8{ * @param netIn Input parameters for the network. * @return Internal state vector. */ - vector_type convert_netIn(const nuclearNetwork::NetIn &netIn); + vector_type convert_netIn(const NetIn &netIn); }; } // namespace nnApprox8 diff --git a/src/network/public/network.h b/src/network/public/network.h index 36f50589..0ae46779 100644 --- a/src/network/public/network.h +++ b/src/network/public/network.h @@ -26,7 +26,7 @@ #include "config.h" #include "quill/Logger.h" -namespace nuclearNetwork { +namespace serif::network { /** * @struct NetIn @@ -102,8 +102,8 @@ namespace nuclearNetwork { virtual NetOut evaluate(const NetIn &netIn); protected: - Config& m_config; ///< Configuration instance - Probe::LogManager& m_logManager; ///< Log manager instance + serif::config::Config& m_config; ///< Configuration instance + serif::probe::LogManager& m_logManager; ///< Log manager instance quill::Logger* m_logger; ///< Logger instance }; From 602a9a0409e023cfb6391a7713e2918b52e54ef8 Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Wed, 11 Jun 2025 14:49:26 -0400 Subject: [PATCH 4/4] refactor(serif): updated tests to reflect new serif namespaces --- tests/network/approx8Test.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/network/approx8Test.cpp b/tests/network/approx8Test.cpp index acebae89..7bddef3e 100644 --- a/tests/network/approx8Test.cpp +++ b/tests/network/approx8Test.cpp @@ -14,13 +14,13 @@ class approx8Test : public ::testing::Test {}; * @brief Test the constructor of the Config class. */ TEST_F(approx8Test, constructor) { - Config& config = Config::getInstance(); + serif::config::Config& config = serif::config::Config::getInstance(); config.loadConfig(TEST_CONFIG); - EXPECT_NO_THROW(nnApprox8::Approx8Network()); + EXPECT_NO_THROW(serif::network::approx8::Approx8Network()); } TEST_F(approx8Test, setStiff) { - nnApprox8::Approx8Network network; + serif::network::approx8::Approx8Network network; EXPECT_NO_THROW(network.setStiff(true)); EXPECT_TRUE(network.isStiff()); EXPECT_NO_THROW(network.setStiff(false)); @@ -28,8 +28,8 @@ TEST_F(approx8Test, setStiff) { } TEST_F(approx8Test, evaluate) { - nnApprox8::Approx8Network network; - nuclearNetwork::NetIn netIn; + serif::network::approx8::Approx8Network network; + serif::network::NetIn netIn; std::vector comp = {0.708, 2.94e-5, 0.276, 0.003, 0.0011, 9.62e-3, 1.62e-3, 5.16e-4}; @@ -41,10 +41,10 @@ TEST_F(approx8Test, evaluate) { netIn.tmax = 3.15e17; netIn.dt0 = 1e12; - nuclearNetwork::NetOut netOut; + serif::network::NetOut netOut; EXPECT_NO_THROW(netOut = network.evaluate(netIn)); - EXPECT_DOUBLE_EQ(netOut.composition[nnApprox8::Net::ih1], 0.50166260916650918); - EXPECT_DOUBLE_EQ(netOut.composition[nnApprox8::Net::ihe4],0.48172270591286032); + EXPECT_DOUBLE_EQ(netOut.composition[serif::network::approx8::Net::ih1], 0.50166260916650918); + EXPECT_DOUBLE_EQ(netOut.composition[serif::network::approx8::Net::ihe4],0.48172270591286032); EXPECT_DOUBLE_EQ(netOut.energy, 1.6433049870528356e+18); }