|
2 | 2 |
|
3 | 3 | #include "openmc/error.h" |
4 | 4 | #include "openmc/geometry.h" |
| 5 | +#include "openmc/material.h" |
| 6 | +#include "openmc/mgxs_interface.h" |
5 | 7 | #include "openmc/settings.h" |
6 | 8 |
|
7 | 9 | namespace openmc { |
@@ -136,8 +138,8 @@ void Ray::trace() |
136 | 138 | cross_lattice(*this, boundary(), settings::verbosity >= 10); |
137 | 139 | } |
138 | 140 |
|
139 | | - // Record how far the ray has traveled |
140 | | - traversal_distance_ += boundary().distance(); |
| 141 | + update_distance(); |
| 142 | + |
141 | 143 | inside_cell = neighbor_list_find_cell(*this, settings::verbosity >= 10); |
142 | 144 |
|
143 | 145 | // Call the specialized logic for this type of ray. Note that we do not |
@@ -165,4 +167,45 @@ void Ray::trace() |
165 | 167 | } |
166 | 168 | } |
167 | 169 |
|
| 170 | +void Ray::update_distance() |
| 171 | +{ |
| 172 | + // Record how far the ray has traveled |
| 173 | + traversal_distance_ += boundary().distance(); |
| 174 | +} |
| 175 | + |
| 176 | +void ParticleRay::update_distance() |
| 177 | +{ |
| 178 | + Ray::update_distance(); |
| 179 | + |
| 180 | + time_distance_ += speed() * boundary().distance(); |
| 181 | + |
| 182 | + // Calculate microscopic and macroscopic cross sections |
| 183 | + if (material() != MATERIAL_VOID) { |
| 184 | + if (settings::run_CE) { |
| 185 | + if (material() != material_last() || sqrtkT() != sqrtkT_last() || |
| 186 | + density_mult() != density_mult_last()) { |
| 187 | + // If the material is the same as the last material and the |
| 188 | + // temperature hasn't changed, we don't need to lookup cross |
| 189 | + // sections again. |
| 190 | + model::materials[material()]->calculate_xs(*this); |
| 191 | + } |
| 192 | + } else { |
| 193 | + // Get the MG data; unlike the CE case above, we have to re-calculate |
| 194 | + // cross sections for every collision since the cross sections may |
| 195 | + // be angle-dependent |
| 196 | + data::mg.macro_xs_[material()].calculate_xs(*this); |
| 197 | + |
| 198 | + // Update the particle's group while we know we are multi-group |
| 199 | + g_last() = g(); |
| 200 | + } |
| 201 | + } else { |
| 202 | + macro_xs().total = 0.0; |
| 203 | + macro_xs().absorption = 0.0; |
| 204 | + macro_xs().fission = 0.0; |
| 205 | + macro_xs().nu_fission = 0.0; |
| 206 | + } |
| 207 | + |
| 208 | + mfp_distance_ += macro_xs().total * boundary().distance(); |
| 209 | +} |
| 210 | + |
168 | 211 | } // namespace openmc |
0 commit comments