Skip to content

Commit 57b79b7

Browse files
committed
adding more functionality
1 parent a8046cb commit 57b79b7

8 files changed

Lines changed: 72 additions & 96 deletions

File tree

include/Depletion.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#ifndef ASTARA_DEPLETION_H
2+
#define ASTARA_DEPLETION_H
3+
4+
namespace astara{
5+
class DepletionSolver{
6+
public:
7+
DepletionSolver();
8+
~DepletionSolver();
9+
protected:
10+
// isotope list
11+
};
12+
}
13+
#endif //ASTARA_DEPLETION_H
File renamed without changes.

include/Math.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#ifndef ASTARA_MATH_H
2+
#define ASTARA_MATH_H
3+
4+
// main math functions and solvers for the framework
5+
namespace astara{
6+
7+
template <typename T>
8+
T predictor_corrector_integrator(T (*differential_func)(), T time_step);
9+
10+
template <typename T>
11+
T predictor_integrator(T (*differential_func)(), T time_step);
12+
}
13+
14+
#endif //ASTARA_MATH_H
15+
16+

include/Reactor.h

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ class Function;
1111
class Reactor {
1212

1313
public:
14-
Reactor(unsigned int n_groups, std::vector<double> delayed_neutron_constants);
14+
Reactor(unsigned int n_groups,
15+
std::vector<double> neutron_group_const,
16+
std::vector<double> delayed_neutron_constants,
17+
double neutron_generation_time);
1518
~Reactor();
1619

1720
/* initial condition setters*/
@@ -67,14 +70,26 @@ class Reactor {
6770
std::unique_ptr<Function> _moderator_temperature_co_efficient;
6871
std::unique_ptr<Function> _boron_temperature_co_efficient;
6972

73+
//neutron generation time
74+
const double _neutron_generation_time;
75+
76+
//variables
77+
/* There is an initial reactivity which can be calculated from the startup
78+
* condition. Like how much boron in it, fuel moderator temperature, initial xenon presence
79+
* fuel inventory presence etc */
80+
double _reactivity = 0;
81+
7082
// temperatures
7183
double _fuel_temperature;
7284
double _moderator_temperature;
7385

7486
// delayed neutron fractions
7587
const unsigned int _number_of_neutron_groups;
76-
const std::vector<double> _delayed_neutron_constants;
77-
const double _sum_delayed_neutron_constants;
88+
const std::vector<double> _neutron_group_const;
89+
const std::vector<double> _decay_constants;
90+
const double _total_decay_constant;
91+
const double _total_group_const;
92+
7893
};
7994
} // namespace astara
8095

src/Parser.cpp renamed to src/Function.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "Parser.h"
1+
#include "Function.h"
22

33
astara::Function::Function(const std::string &expr,
44
const std::vector<std::string> &variable_names)

src/Reactor.cpp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
11
#include <iostream>
22
#include <numeric>
33

4-
#include "Parser.h"
4+
#include "Function.h"
55
#include "Reactor.h"
66

77
astara::Reactor::Reactor(unsigned int n_groups,
8-
std::vector<double> delayed_neutron_constants)
8+
std::vector<double> neutron_group_const,
9+
std::vector<double> delayed_neutron_constants,
10+
double neutron_generation_time)
911
: _number_of_neutron_groups(n_groups),
10-
_delayed_neutron_constants(delayed_neutron_constants),
11-
_sum_delayed_neutron_constants(
12-
std::accumulate(_delayed_neutron_constants.begin(),
13-
_delayed_neutron_constants.end(), 0.0)) {
14-
15-
if (_number_of_neutron_groups != _delayed_neutron_constants.size())
12+
_neutron_group_const(neutron_group_const),
13+
_decay_constants(delayed_neutron_constants),
14+
_total_decay_constant(std::accumulate(_decay_constants.begin(),
15+
_decay_constants.end(), 0.0)),
16+
_total_group_const(std::accumulate(_neutron_group_const.begin(),
17+
_neutron_group_const.end(), 0)),
18+
_neutron_generation_time(neutron_generation_time) {
19+
20+
if (_number_of_neutron_groups != _decay_constants.size() and
21+
_number_of_neutron_groups != _neutron_group_const.size())
1622
throw std::runtime_error("Number of neutron group must be equal to the "
17-
"number of delayed consts");
23+
"number of delayed and group consts");
1824
}
1925

26+
astara::Reactor::Reactor::~Reactor() = default;
27+
2028
void astara::Reactor::setHeatTransferCoefficient(
2129
Function *heat_transfer_co_eff_function) {
2230
if (heat_transfer_co_eff_function != nullptr)
@@ -49,4 +57,4 @@ void astara::Reactor::setModeratorTemperatureCoEfficientFunction(
4957
throw std::runtime_error("moderator_temp_feed_back_func is null_ptr");
5058
}
5159

52-
astara::Reactor::Reactor::~Reactor() = default;
60+
void astara::Reactor::dRhoDt() {}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "cmath"
22
#include <gtest/gtest.h>
33

4-
#include "Parser.h"
4+
#include "Function.h"
55

66
TEST(AstaraParser, ConstantExpression) {
77
astara::Function f("2 + 3 * 4", {});

unit_tests/reactor_tests.cpp

Lines changed: 5 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -2,98 +2,22 @@
22
#include <stdexcept>
33
#include <vector>
44

5-
#include "Parser.h"
5+
#include "Function.h"
66
#include "Reactor.h"
77

88
using namespace astara;
99

10-
1110
TEST(ReactorConstructorTest, ThrowsWhenGroupCountDoesNotMatchConstants) {
12-
EXPECT_THROW(Reactor reactor(3, {0.1, 0.2}), std::runtime_error);
13-
}
14-
15-
TEST(ReactorConstructorTest, DoesNotThrowWhenGroupCountMatchesConstants) {
16-
EXPECT_NO_THROW(Reactor reactor(2, {0.1, 0.2}));
17-
}
18-
19-
// ------------------------
20-
// Heat transfer coefficient setter
21-
// ------------------------
22-
TEST(ReactorFunctionSetterTest, HeatTransferCoefficientThrowsOnNullptr) {
23-
Reactor reactor(1, {0.1});
24-
EXPECT_THROW(reactor.setHeatTransferCoefficient(nullptr), std::runtime_error);
25-
}
26-
27-
TEST(ReactorFunctionSetterTest, HeatTransferCoefficientAcceptsValidFunction) {
28-
Reactor reactor(1, {0.1});
29-
EXPECT_NO_THROW(
30-
reactor.setHeatTransferCoefficient(new Function("2.0 * x", {"x"})));
31-
}
32-
33-
// ------------------------
34-
// Fuel specific heat setter
35-
// ------------------------
36-
TEST(ReactorFunctionSetterTest, FuelSpecificHeatThrowsOnNullptr) {
37-
Reactor reactor(1, {0.1});
38-
EXPECT_THROW(reactor.setFuelSpecificHeatFunction(nullptr),
39-
std::runtime_error);
40-
}
41-
42-
TEST(ReactorFunctionSetterTest, FuelSpecificHeatAcceptsValidFunction) {
43-
Reactor reactor(1, {0.1});
44-
EXPECT_NO_THROW(
45-
reactor.setFuelSpecificHeatFunction(new Function("1000 + T", {"T"})));
46-
}
47-
48-
// ------------------------
49-
// Fuel temperature coefficient setter
50-
// ------------------------
51-
TEST(ReactorFunctionSetterTest, FuelTemperatureCoefficientThrowsOnNullptr) {
52-
Reactor reactor(1, {0.1});
53-
EXPECT_THROW(reactor.setFuelTemperatureCoEfficientFunction(nullptr),
54-
std::runtime_error);
55-
}
56-
57-
TEST(ReactorFunctionSetterTest,
58-
FuelTemperatureCoefficientAcceptsValidFunction) {
59-
Reactor reactor(1, {0.1});
60-
EXPECT_NO_THROW(reactor.setFuelTemperatureCoEfficientFunction(
61-
new Function("-0.01 * T", {"T"})));
62-
}
63-
64-
// ------------------------
65-
// Moderator temperature coefficient setter
66-
// ------------------------
67-
TEST(ReactorFunctionSetterTest,
68-
ModeratorTemperatureCoefficientThrowsOnNullptr) {
69-
Reactor reactor(1, {0.1});
70-
EXPECT_THROW(reactor.setModeratorTemperatureCoEfficientFunction(nullptr),
11+
EXPECT_THROW(Reactor reactor(3, {0.1, 0.2}, {0.1, 0.2}, 1e-9),
7112
std::runtime_error);
7213
}
7314

74-
TEST(ReactorFunctionSetterTest,
75-
ModeratorTemperatureCoefficientAcceptsValidFunction) {
76-
Reactor reactor(1, {0.1});
77-
EXPECT_NO_THROW(reactor.setModeratorTemperatureCoEfficientFunction(
78-
new Function("-0.002 * T", {"T"})));
79-
}
80-
81-
// ------------------------
82-
// Replacement semantics
83-
// ------------------------
84-
TEST(ReactorFunctionSetterTest, ReplacingHeatTransferCoefficientDoesNotThrow) {
85-
Reactor reactor(1, {0.1});
86-
EXPECT_NO_THROW({
87-
reactor.setHeatTransferCoefficient(new Function("x", {"x"}));
88-
reactor.setHeatTransferCoefficient(new Function("2 * x", {"x"}));
89-
});
15+
TEST(ReactorConstructorTest, DoesNotThrowWhenGroupCountMatchesConstants) {
16+
EXPECT_NO_THROW(Reactor reactor(2, {0.1, 0.2}, {0.1, 0.2}, 1e-9));
9017
}
9118

92-
// ------------------------
93-
// Multiple setters together
94-
// ------------------------
9519
TEST(ReactorFunctionSetterTest, SettingAllFunctionsDoesNotThrow) {
96-
Reactor reactor(1, {0.1});
20+
Reactor reactor(2, {0.1, 0.2}, {0.1, 0.2}, 1e-9);
9721
EXPECT_NO_THROW({
9822
reactor.setHeatTransferCoefficient(new Function("x", {"x"}));
9923
reactor.setFuelSpecificHeatFunction(new Function("1000 + T", {"T"}));

0 commit comments

Comments
 (0)