@@ -149,39 +149,24 @@ void FlatSourceDomain::update_single_neutron_source(SourceRegionHandle& srh)
149149 }
150150 total_source = (scatter_source + fission_source * inverse_k_eff);
151151
152- if (settings::kinetic_simulation && !simulation::is_initial_condition) {
153- // Add delayed source for kinetic simulation if delayed neutrons are
154- // turned on
155- if (settings::create_delayed_neutrons) {
156- double delayed_source = 0.0 ;
157- for (int dg = 0 ; dg < ndgroups_; dg++) {
158- double chi_d =
159- chi_d_[material * negroups_ * ndgroups_ + dg * negroups_ + g_out];
160- double lambda = lambda_[material * ndgroups_ + dg];
161- double precursors = srh.precursors_old (dg);
162- delayed_source += chi_d * precursors * lambda;
163- }
164- total_source += delayed_source;
165- }
166- // Add derivative of scalar flux to source (only works for isotropic
167- // method)
168- if (RandomRay::time_method_ == RandomRayTimeMethod::ISOTROPIC) {
169- double inverse_vbar = inverse_vbar_[material * negroups_ + g_out];
170- double scalar_flux_rhs_bd = srh.scalar_flux_rhs_bd (g_out);
171- double A0 =
172- (bd_coefficients_first_order_.at (RandomRay::bd_order_))[0 ] /
173- settings::dt;
174- double scalar_flux = srh.scalar_flux_old (g_out);
175- double scalar_flux_time_derivative =
176- A0 * scalar_flux + scalar_flux_rhs_bd;
177- total_source -= scalar_flux_time_derivative * inverse_vbar;
152+ // Add delayed source for kinetic simulation if delayed neutrons are
153+ // turned on
154+ if (settings::kinetic_simulation && !simulation::is_initial_condition &&
155+ settings::create_delayed_neutrons) {
156+ double delayed_source = 0.0 ;
157+ for (int dg = 0 ; dg < ndgroups_; dg++) {
158+ double chi_d =
159+ chi_d_[material * negroups_ * ndgroups_ + dg * negroups_ + g_out];
160+ double lambda = lambda_[material * ndgroups_ + dg];
161+ double precursors = srh.precursors_old (dg);
162+ delayed_source += chi_d * precursors * lambda;
178163 }
164+ total_source += delayed_source;
179165 }
180166 srh.source (g_out) = total_source / sigma_t ;
181167 }
182168 }
183169
184- // TODO: Add control flow for k-eigenvalue forward-weighted adjoint
185170 // Add external source if in fixed source mode
186171 if (settings::run_mode == RunMode::FIXED_SOURCE) {
187172 for (int g = 0 ; g < negroups_; g++) {
@@ -200,9 +185,11 @@ void FlatSourceDomain::update_all_neutron_sources()
200185 for (int64_t sr = 0 ; sr < n_source_regions (); sr++) {
201186 SourceRegionHandle srh = source_regions_.get_source_region_handle (sr);
202187 update_single_neutron_source (srh);
203- if (settings::kinetic_simulation && !simulation::is_initial_condition &&
204- RandomRay::time_method_ == RandomRayTimeMethod::PROPAGATION) {
205- compute_single_T1 (srh);
188+ if (settings::kinetic_simulation && !simulation::is_initial_condition) {
189+ if (RandomRay::time_method_ == RandomRayTimeMethod::ISOTROPIC)
190+ compute_single_phi_prime (srh);
191+ else if (RandomRay::time_method_ == RandomRayTimeMethod::PROPAGATION)
192+ compute_single_T1 (srh);
206193 }
207194 }
208195
@@ -243,7 +230,6 @@ void FlatSourceDomain::set_flux_to_flux_plus_source(
243230 int64_t sr, double volume, int g)
244231{
245232 int material = source_regions_.material (sr);
246- // TODO: Implement support for time-dependent void transport
247233 if (material == MATERIAL_VOID) {
248234 source_regions_.scalar_flux_new (sr, g) /= volume;
249235 if (settings::run_mode == RunMode::FIXED_SOURCE) {
@@ -252,20 +238,21 @@ void FlatSourceDomain::set_flux_to_flux_plus_source(
252238 source_regions_.volume_sq (sr);
253239 }
254240 } else {
255- double sigma_t = sigma_t_[source_regions_. material (sr) * negroups_ + g];
241+ double sigma_t = sigma_t_[material * negroups_ + g];
256242 source_regions_.scalar_flux_new (sr, g) /= (sigma_t * volume);
257243 source_regions_.scalar_flux_new (sr, g) += source_regions_.source (sr, g);
258- if (settings::kinetic_simulation && !simulation::is_initial_condition &&
259- RandomRay::time_method_ == RandomRayTimeMethod::PROPAGATION) {
260- double inverse_vbar =
261- inverse_vbar_[source_regions_.material (sr) * negroups_ + g];
262- double scalar_flux_rhs_bd = source_regions_.scalar_flux_rhs_bd (sr, g);
263- double A0 = (bd_coefficients_first_order_.at (RandomRay::bd_order_))[0 ] /
264- settings::dt;
265- source_regions_.scalar_flux_new (sr, g) -=
266- scalar_flux_rhs_bd * inverse_vbar / sigma_t ;
267- source_regions_.scalar_flux_new (sr, g) /= 1 + A0 * inverse_vbar / sigma_t ;
268- }
244+ }
245+ if (settings::kinetic_simulation && !simulation::is_initial_condition) {
246+ double inverse_vbar =
247+ inverse_vbar_[source_regions_.material (sr) * negroups_ + g];
248+ double scalar_flux_rhs_bd = source_regions_.scalar_flux_rhs_bd (sr, g);
249+ double A0 =
250+ (bd_coefficients_first_order_.at (RandomRay::bd_order_))[0 ] / settings::dt;
251+ // TODO: Add support for expicit void regions
252+ double sigma_t = sigma_t_[material * negroups_ + g];
253+ source_regions_.scalar_flux_new (sr, g) -=
254+ scalar_flux_rhs_bd * inverse_vbar / sigma_t ;
255+ source_regions_.scalar_flux_new (sr, g) /= 1 + A0 * inverse_vbar / sigma_t ;
269256 }
270257}
271258
@@ -1736,6 +1723,11 @@ SourceRegionHandle FlatSourceDomain::get_subdivided_source_region_handle(
17361723 }
17371724 }
17381725
1726+ if (settings::kinetic_simulation && material == MATERIAL_VOID) {
1727+ fatal_error (" Explicit void treatment for kinetic simulations "
1728+ " is not currently supported." );
1729+ }
1730+
17391731 handle.material () = material;
17401732
17411733 // Store the mesh index (if any) assigned to this source region
@@ -1774,9 +1766,11 @@ SourceRegionHandle FlatSourceDomain::get_subdivided_source_region_handle(
17741766
17751767 // Compute the combined source term
17761768 update_single_neutron_source (handle);
1777- if (settings::kinetic_simulation && !simulation::is_initial_condition &&
1778- RandomRay::time_method_ == RandomRayTimeMethod::PROPAGATION) {
1779- compute_single_T1 (handle);
1769+ if (settings::kinetic_simulation && !simulation::is_initial_condition) {
1770+ if (RandomRay::time_method_ == RandomRayTimeMethod::ISOTROPIC)
1771+ compute_single_phi_prime (handle);
1772+ else if (RandomRay::time_method_ == RandomRayTimeMethod::PROPAGATION)
1773+ compute_single_T1 (handle);
17801774 }
17811775
17821776 // Unlock the parallel map. Note: we may be tempted to release
@@ -1936,6 +1930,22 @@ int64_t FlatSourceDomain::lookup_mesh_bin(int64_t sr, Position r) const
19361930// kinetic simulations) sources in each source region based on the flux
19371931// estimate from the previous iteration.
19381932
1933+ void FlatSourceDomain::compute_single_phi_prime (SourceRegionHandle& srh)
1934+ {
1935+ double A0 =
1936+ (bd_coefficients_first_order_.at (RandomRay::bd_order_))[0 ] / settings::dt;
1937+ int material = srh.material ();
1938+ for (int g = 0 ; g < negroups_; g++) {
1939+ double inverse_vbar = inverse_vbar_[material * negroups_ + g];
1940+ // TODO: add support for explicit void
1941+ double sigma_t = sigma_t_[material * negroups_ + g];
1942+
1943+ double scalar_flux_time_derivative =
1944+ A0 * srh.scalar_flux_old (g) + srh.scalar_flux_rhs_bd (g);
1945+ srh.phi_prime (g) = scalar_flux_time_derivative * inverse_vbar / sigma_t ;
1946+ }
1947+ }
1948+
19391949// T1 calculation
19401950void FlatSourceDomain::compute_single_T1 (SourceRegionHandle& srh)
19411951{
@@ -1946,9 +1956,8 @@ void FlatSourceDomain::compute_single_T1(SourceRegionHandle& srh)
19461956 int material = srh.material ();
19471957 for (int g = 0 ; g < negroups_; g++) {
19481958 double inverse_vbar = inverse_vbar_[material * negroups_ + g];
1949- double sigma_t = 1.0 ;
1950- if (material != MATERIAL_VOID)
1951- sigma_t = sigma_t_[material * negroups_ + g];
1959+ // TODO: add support for explicit void
1960+ double sigma_t = sigma_t_[material * negroups_ + g];
19521961
19531962 // Multiply out sigma_t to correctly compute the derivative term
19541963 float source_time_derivative =
@@ -2131,10 +2140,10 @@ void FlatSourceDomain::store_time_step_quantities(bool increment_not_initialize)
21312140 source_regions_.scalar_flux_final (sr, g), increment_not_initialize,
21322141 RandomRay::bd_order_ + j);
21332142 if (RandomRay::time_method_ == RandomRayTimeMethod::PROPAGATION) {
2134- // TODO: add support for void regions
21352143 // Multiply out sigma_t to store the base source
2136- double sigma_t = sigma_t =
2137- sigma_t_[source_regions_.material (sr) * negroups_ + g];
2144+ int material = source_regions_.material (sr);
2145+ // TODO: add support for explicit void regions
2146+ double sigma_t = sigma_t_[source_regions_.material (sr) * negroups_ + g];
21382147 float source = source_regions_.source_final (sr, g) * sigma_t ;
21392148 add_value_to_bd_vector (source_regions_.source_bd (sr, g), source,
21402149 increment_not_initialize, RandomRay::bd_order_);
0 commit comments