Chi-Tech
lbts_step_precursors.cc
Go to the documentation of this file.
2
3//###################################################################
4/**Performs a timestep of the precursors.*/
6{
7 const auto& BackwardEuler = chi_math::SteppingMethod::IMPLICIT_EULER;
8 const auto& CrankNicolson = chi_math::SteppingMethod::CRANK_NICOLSON;
9
10 double theta;
11 if (method == BackwardEuler) theta = 1.0;
12 else if (method == CrankNicolson) theta = 0.5;
13 else theta = 0.7;
14
15 const double eff_dt = theta * dt_;
16
17 //============================================= Clear destination vector
18 precursor_new_local_.assign(precursor_new_local_.size(), 0.0);
19
20 //================================================== Loop over local cells
21 // Uses phi_new and precursor_prev_local to compute
22 // precursor_new_local(theta-flavor)
23 for (auto& cell : grid_ptr_->local_cells)
24 {
25 const auto& fe_values = unit_cell_matrices_[cell.local_id_];
26 const auto& transport_view = cell_transport_views_[cell.local_id_];
27 const double cell_volume = transport_view.Volume();
28
29 //==================== Obtain xs
30 const auto& xs = matid_to_xs_map_.at(cell.material_id_);
31 const auto& precursors = xs->Precursors();
32 const auto& nu_delayed_sigma_f = xs->NuDelayedSigmaF();
33
34 //======================================== Compute delayed fission rate
35 double delayed_fission = 0.0;
36 for (int i = 0; i < transport_view.NumNodes(); ++i)
37 {
38 const size_t uk_map = transport_view.MapDOF(i, 0, 0);
39 const double node_V_fraction = fe_values.Vi_vectors[i]/cell_volume;
40
41 for (int g = 0; g < groups_.size(); ++g)
42 delayed_fission += nu_delayed_sigma_f[g] *
43 phi_new_local_[uk_map + g] *
44 node_V_fraction;
45 }
46
47 //========================================= Loop over precursors
48 const auto& max_precursors = max_precursors_per_material_;
49 for (unsigned int j = 0; j < xs->NumPrecursors(); ++j)
50 {
51 const size_t dof_map = cell.local_id_ * max_precursors + j;
52 const auto& precursor = precursors[j];
53 const double coeff = 1.0 / (1.0 + eff_dt * precursor.decay_constant);
54
55 //contribute last time step precursors
56 precursor_new_local_[dof_map] = coeff * precursor_prev_local_[dof_map];
57
58 //contribute delayed fission production
59 precursor_new_local_[dof_map] +=
60 coeff * eff_dt * precursor.fractional_yield * delayed_fission;
61 }
62 }//for cell
63
64 //======================================== Compute t^{n+1} value
65 {
66 auto& Cj = precursor_new_local_;
67 const auto& Cj_prev = precursor_prev_local_;
68
69 const double inv_theta = 1.0/theta;
70 for (size_t i = 0; i < Cj.size(); ++i)
71 Cj[i] = inv_theta * (Cj[i] + (theta - 1.0) * Cj_prev[i]);
72 }
73}
std::vector< double > precursor_prev_local_
chi_math::SteppingMethod method