Chi-Tech
multigroup_xs_pushlua.cc
Go to the documentation of this file.
1#include "multigroup_xs.h"
2
3#include "chi_log.h"
4
5//###################################################################
6/**Pushes all of the relevant items of the transport xs to a lua table.*/
8{
9 //================================================== General data
10 lua_newtable(L);
11 lua_pushstring(L, "is_empty");
12 lua_pushboolean(L, false);
13 lua_settable(L, -3);
14
15 lua_pushstring(L, "num_groups");
16 lua_pushinteger(L, static_cast<lua_Integer>(NumGroups()));
17 lua_settable(L, -3);
18
19 lua_pushstring(L, "scattering_order");
20 lua_pushinteger(L, static_cast<lua_Integer>(ScatteringOrder()));
21 lua_settable(L, -3);
22
23 lua_pushstring(L, "num_precursors");
24 lua_pushinteger(L, static_cast<lua_Integer>(NumPrecursors()));
25 lua_settable(L, -3);
26
27 lua_pushstring(L, "is_fissionable");
28 lua_pushboolean(L, IsFissionable());
29 lua_settable(L, -3);
30
31 //================================================== 1D cross sections
32 auto Push1DXS =
33 [L](const std::vector<double>& xs,
34 const std::string& name)
35 {
36 lua_pushstring(L, name.c_str());
37 lua_newtable(L);
38 {
39 unsigned int g = 0;
40 for (const auto& val : xs)
41 {
42 lua_pushinteger(L, ++g);
43 lua_pushnumber(L ,val);
44 lua_settable(L, -3);
45 }
46 }
47 lua_settable(L, -3);
48 };
49
50 Push1DXS(SigmaTotal(), "sigma_t");
51 Push1DXS(SigmaAbsorption(), "sigma_a");
52 Push1DXS(SigmaFission(), "sigma_f");
53 Push1DXS(NuSigmaF(), "nu_sigma_f");
54 Push1DXS(NuPromptSigmaF(), "nu_prompt_sigma_f");
55 Push1DXS(NuDelayedSigmaF(), "nu_delayed_sigma_f");
56 Push1DXS(InverseVelocity(), "inv_velocity");
57
58 //================================================== Emission spectra
59 std::vector<std::vector<double>> chi_delayed;
60 for (unsigned int g = 0; g < NumGroups(); ++g)
61 {
62 std::vector<double> vals;
63 for (const auto& precursor : Precursors())
64 vals.push_back(precursor.emission_spectrum[g]);
65 chi_delayed.push_back(vals);
66 }
67
68 lua_pushstring(L, "chi_delayed");
69 lua_newtable(L);
70 {
71 unsigned int g = 0;
72 for (const auto& emission_g: chi_delayed)
73 {
74 lua_pushinteger(L, ++g);
75 lua_newtable(L);
76 {
77 unsigned int j = 0;
78 for (const auto& val: emission_g)
79 {
80 lua_pushinteger(L, ++j);
81 lua_pushnumber(L, val);
82 lua_settable(L, -3);
83 }
84 }
85 lua_settable(L, -3);
86 }
87 }
88 lua_settable(L, -3);
89
90 //================================================== Precursor data
91 lua_pushstring(L,"precursor_decay_constants");
92 lua_newtable(L);
93 {
94 unsigned int j = 0;
95 for (const auto& precursor : Precursors())
96 {
97 lua_pushinteger(L, ++j);
98 lua_pushnumber(L, precursor.decay_constant);
99 lua_settable(L, -3);
100 }
101 }
102 lua_settable(L, -3);
103
104 lua_pushstring(L, "precursor_fractional_yields");
105 lua_newtable(L);
106 {
107 unsigned int j = 0;
108 for (const auto& precursor : Precursors())
109 {
110 lua_pushinteger(L, ++j);
111 lua_pushnumber(L, precursor.fractional_yield);
112 lua_settable(L, -3);
113 }
114 }
115 lua_settable(L, -3);
116
117 //================================================== Transfer matrices
118 lua_pushstring(L, "transfer_matrix");
119 lua_newtable(L);
120 {
121 unsigned int ell = 0;
122 for (const auto& matrix : TransferMatrices())
123 {
124 lua_pushinteger(L, ++ell);
125 lua_newtable(L);
126 {
127 for (unsigned int g = 0; g < matrix.NumRows(); ++g)
128 {
129 const auto& col_indices = matrix.rowI_indices_[g];
130 const auto& col_values = matrix.rowI_values_[g];
131 size_t num_vals = col_values.size();
132
133 lua_pushinteger(L, g + 1);
134 lua_newtable(L);
135 {
136 for (unsigned int gg = 0; gg < num_vals; ++gg)
137 {
138 lua_pushinteger(L, static_cast<long long>(col_indices[gg]) + 1);
139 lua_pushnumber(L, col_values[gg]);
140 lua_settable(L, -3);
141 }
142 lua_settable(L, -3);
143 }
144 }
145 }
146 lua_settable(L, -3);
147 }
148 }
149 lua_settable(L, -3);
150
151 //================================================== Production matrix
152 lua_pushstring(L, "production_matrix");
153 lua_newtable(L);
154 {
155 unsigned int g = 0;
156 for (const auto& prod : ProductionMatrix())
157 {
158 lua_pushinteger(L, ++g);
159 lua_newtable(L);
160 {
161 unsigned int gp = 0;
162 for (const auto& val : prod)
163 {
164 lua_pushinteger(L, ++gp);
165 lua_pushnumber(L, val);
166 lua_settable(L, -3);
167 }
168 lua_settable(L, -3);
169 }
170 }//for g
171 }
172 lua_settable(L, -3);
173
174 //================================================== Push diffusion quantities
175 Push1DXS(DiffusionCoefficient(), "diffusion_coeff");
176 Push1DXS(SigmaRemoval(), "sigma_removal");
177 Push1DXS(SigmaSGtoG(), "sigma_s_gtog");
178}
virtual const unsigned int NumGroups() const =0
virtual const std::vector< Precursor > & Precursors() const =0
virtual const unsigned int NumPrecursors() const =0
virtual const std::vector< double > & InverseVelocity() const =0
void PushLuaTable(lua_State *L) const override
virtual const std::vector< double > & NuDelayedSigmaF() const =0
virtual const std::vector< std::vector< double > > ProductionMatrix() const =0
virtual const std::vector< double > & SigmaTotal() const =0
virtual const std::vector< double > & SigmaAbsorption() const =0
virtual const std::vector< double > & SigmaFission() const =0
virtual const unsigned int ScatteringOrder() const =0
virtual const std::vector< double > & SigmaRemoval() const =0
virtual const std::vector< double > & NuSigmaF() const =0
virtual const bool IsFissionable() const =0
virtual const std::vector< double > & NuPromptSigmaF() const =0
virtual const std::vector< chi_math::SparseMatrix > & TransferMatrices() const =0
virtual const std::vector< double > & SigmaSGtoG() const =0
virtual const std::vector< double > & DiffusionCoefficient() const =0