SERiF 0.0.1a
3+1D Stellar Structure and Evolution
Loading...
Searching...
No Matches
approx8Test.cpp
Go to the documentation of this file.
1#include <gtest/gtest.h>
2#include <string>
3
4#include "approx8.h"
5#include "config.h"
6#include "network.h"
7#include "composition.h"
8#include "reaclib.h"
9#include "netgraph.h"
10
11#include <vector>
12
13#include "reactions.h"
14
15std::string TEST_CONFIG = std::string(getenv("MESON_SOURCE_ROOT")) + "/tests/testsConfig.yaml";
16class approx8Test : public ::testing::Test {};
17
21TEST_F(approx8Test, constructor) {
22 serif::config::Config& config = serif::config::Config::getInstance();
23 config.loadConfig(TEST_CONFIG);
25}
26
27TEST_F(approx8Test, setStiff) {
29 EXPECT_NO_THROW(network.setStiff(true));
30 EXPECT_TRUE(network.isStiff());
31 EXPECT_NO_THROW(network.setStiff(false));
32 EXPECT_FALSE(network.isStiff());
33}
34
35TEST_F(approx8Test, evaluate) {
38
39 std::vector<double> comp = {0.708, 2.94e-5, 0.276, 0.003, 0.0011, 9.62e-3, 1.62e-3, 5.16e-4};
40 std::vector<std::string> symbols = {"H-1", "He-3", "He-4", "C-12", "N-14", "O-16", "Ne-20", "Mg-24"};
41
43 composition.registerSymbol(symbols, true);
44 composition.setMassFraction(symbols, comp);
45 bool isFinalized = composition.finalize(true);
46 EXPECT_TRUE(isFinalized);
47
48 netIn.composition = composition;
49 netIn.temperature = 1e7;
50 netIn.density = 1e2;
51 netIn.energy = 0.0;
52
53 netIn.tMax = 3.15e17;
54 netIn.dt0 = 1e12;
55
57 EXPECT_NO_THROW(netOut = network.evaluate(netIn));
58
59 double energyFraction = netOut.energy / 1.6433051127589775E+18;
60 double H1MassFraction = netOut.composition.getMassFraction("H-1")/ 0.50166262445895604;
61 double He4MassFraction = netOut.composition.getMassFraction("He-4") / 0.48172273720971226;
62
63 double relError = 1e-6;
64 EXPECT_NEAR(H1MassFraction, 1.0, relError);
65 EXPECT_NEAR(He4MassFraction, 1.0, relError);
66 EXPECT_NEAR(energyFraction, 1.0, relError);
67}
68
70 using namespace serif::network;
71 const std::vector<double> comp = {0.708, 2.94e-5, 0.276, 0.003, 0.0011, 9.62e-3, 1.62e-3, 5.16e-4};
72 const std::vector<std::string> symbols = {"H-1", "He-3", "He-4", "C-12", "N-14", "O-16", "Ne-20", "Mg-24"};
73
75 composition.registerSymbol(symbols, true);
76 composition.setMassFraction(symbols, comp);
77 composition.finalize(true);
78
79 NetIn netIn;
80 netIn.composition = composition;
81 netIn.temperature = 1e7;
82 netIn.density = 1e2;
83 netIn.energy = 0.0;
84
85 netIn.tMax = 3.15e17;
86 netIn.dt0 = 1e12;
87
89 NetOut netOut;
90 netOut = network.evaluate(netIn);
91 std::cout << netOut << std::endl;
92}
Header file for the Approx8 nuclear reaction network.
TEST_F(approx8Test, constructor)
Test the constructor of the Config class.
Manages the composition of elements.
Graph-based nuclear reaction network using REACLIB reactions.
Definition netgraph.h:77
Class for the Approx8 nuclear reaction network.
Definition approx8.h:294
NetOut evaluate(const NetIn &netIn) override
Evaluates the nuclear network.
Definition approx8.cpp:449
void setStiff(bool stiff) override
Sets whether the solver should use a stiff method.
Definition approx8.cpp:509
bool isStiff() const override
Checks if the solver is using a stiff method.
Definition approx8.h:315
std::string TEST_CONFIG
Definition eosTest.cpp:22
Defines the GraphNetwork class for representing and evolving nuclear reaction networks as a heavily c...
Input structure for the network evaluation.
Definition network.h:65
Output structure for the network evaluation.
Definition network.h:89