Chi-Tech
lbs_06b_compute_fission_rates.cc
Go to the documentation of this file.
2
4
5#include "chi_runtime.h"
6using namespace lbs;
7
8//###################################################################
9/**Compute the total fission production in the problem.
10\author Zachary Hardy.*/
11double LBSSolver::ComputeFissionProduction(const std::vector<double>& phi)
12{
13 const int first_grp = groups_.front().id_;
14 const int last_grp = groups_.back().id_;
15
16 //============================================= Loop over local cells
17 double local_production = 0.0;
18 for (auto& cell : grid_ptr_->local_cells)
19 {
20 const auto& transport_view = cell_transport_views_[cell.local_id_];
21 const auto& cell_matrices = unit_cell_matrices_[cell.local_id_];
22
23 //====================================== Obtain xs
24 const auto& xs = transport_view.XS();
25 const auto& F = xs.ProductionMatrix();
26 const auto& nu_delayed_sigma_f = xs.NuDelayedSigmaF();
27
28 if (not xs.IsFissionable()) continue;
29
30 //====================================== Loop over nodes
31 const int num_nodes = transport_view.NumNodes();
32 for (int i = 0; i < num_nodes; ++i)
33 {
34 const size_t uk_map = transport_view.MapDOF(i, 0, 0);
35 const double IntV_ShapeI = cell_matrices.Vi_vectors[i];
36
37 //=============================== Loop over groups
38 for (size_t g = first_grp; g <= last_grp; ++g)
39 {
40 const auto& prod = F[g];
41 for (size_t gp = 0; gp <= last_grp; ++gp)
42 local_production += prod[gp] *
43 phi[uk_map + gp] *
44 IntV_ShapeI;
45
47 for (unsigned int j = 0; j < xs.NumPrecursors(); ++j)
48 local_production += nu_delayed_sigma_f[g] *
49 phi[uk_map + g] *
50 IntV_ShapeI;
51 }
52 }//for node
53 }//for cell
54
55 //============================================= Allreduce global production
56 double global_production = 0.0;
57 MPI_Allreduce(&local_production, //sendbuf
58 &global_production, //recvbuf
59 1, MPI_DOUBLE, //count+datatype
60 MPI_SUM, //operation
61 Chi::mpi.comm); //communicator
62
63 return global_production;
64}
65
66//###################################################################
67/**Computes the total fission rate in the problem.
68\author Zachary Hardy.*/
69double LBSSolver::ComputeFissionRate(const std::vector<double>& phi)
70{
71 const int first_grp = groups_.front().id_;
72 const int last_grp = groups_.back().id_;
73
74 //============================================= Loop over local cells
75 double local_fission_rate = 0.0;
76 for (auto& cell : grid_ptr_->local_cells)
77 {
78 const auto& transport_view = cell_transport_views_[cell.local_id_];
79 const auto& cell_matrices = unit_cell_matrices_[cell.local_id_];
80
81 //====================================== Obtain xs
82 const auto& xs = transport_view.XS();
83 const auto& sigma_f = xs.SigmaFission();
84
85 // skip non-fissionable material
86 if (not xs.IsFissionable()) continue;
87
88 //====================================== Loop over nodes
89 const int num_nodes = transport_view.NumNodes();
90 for (int i = 0; i < num_nodes; ++i)
91 {
92 const size_t uk_map = transport_view.MapDOF(i, 0, 0);
93 const double IntV_ShapeI = cell_matrices.Vi_vectors[i];
94
95 //=============================== Loop over groups
96 for (size_t g = first_grp; g <= last_grp; ++g)
97 local_fission_rate += sigma_f[g] * phi[uk_map + g] * IntV_ShapeI;
98 }//for node
99 }//for cell
100
101 //============================================= Allreduce global production
102 double global_fission_rate = 0.0;
103 MPI_Allreduce(&local_fission_rate, //sendbuf
104 &global_fission_rate, //recvbuf
105 1, MPI_DOUBLE, //count+datatype
106 MPI_SUM, //operation
107 Chi::mpi.comm); //communicator
108
109 return global_fission_rate;
110}
static chi::MPI_Info & mpi
Definition: chi_runtime.h:78
chi_mesh::MeshContinuumPtr grid_ptr_
Definition: lbs_solver.h:75
std::vector< lbs::CellLBSView > cell_transport_views_
Definition: lbs_solver.h:83
std::vector< UnitCellMatrices > unit_cell_matrices_
Definition: lbs_solver.h:81
std::vector< LBSGroup > groups_
Definition: lbs_solver.h:67
lbs::Options options_
Definition: lbs_solver.h:61
double ComputeFissionRate(const std::vector< double > &phi)
bool use_precursors
Definition: lbs_structs.h:138