LCOV - code coverage report
Current view: top level - src/userobjects - NeutronicsSpectrumSamplerFission.C (source / functions) Hit Total Coverage
Test: idaholab/magpie: 5710af Lines: 0 41 0.0 %
Date: 2025-07-21 23:34:39 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /**********************************************************************/
       2             : /*                     DO NOT MODIFY THIS HEADER                      */
       3             : /* MAGPIE - Mesoscale Atomistic Glue Program for Integrated Execution */
       4             : /*                                                                    */
       5             : /*            Copyright 2017 Battelle Energy Alliance, LLC            */
       6             : /*                        ALL RIGHTS RESERVED                         */
       7             : /**********************************************************************/
       8             : 
       9             : #include "NeutronicsSpectrumSamplerFission.h"
      10             : #include "MooseMesh.h"
      11             : 
      12             : #include <algorithm>
      13             : 
      14             : registerMooseObject("MagpieApp", NeutronicsSpectrumSamplerFission);
      15             : 
      16             : InputParameters
      17           0 : NeutronicsSpectrumSamplerFission::validParams()
      18             : {
      19           0 :   InputParameters params = NeutronicsSpectrumSamplerBase::validParams();
      20           0 :   params.suppressParameter<unsigned int>("L");
      21           0 :   params.set<unsigned int>("L") = 0;
      22           0 :   params.addRequiredCoupledVar("scalar_fluxes", "Scalar fluxes, dimension G.");
      23             :   // FIXME: This is not the permanent solution for providing fission cross sections. It must be
      24             :   // implemented as material property.
      25           0 :   params.addRequiredParam<std::vector<Real>>(
      26             :       "fission_cross_sections", "Fission cross sections. Size = npoints x nisotopes x G.");
      27           0 :   params.addClassDescription("Computes fractional fission rates (Ni * simga_fi * phi) for a "
      28             :                              "selection of points.\nUsed for computing PDFs from fission reactions "
      29             :                              "to sample PKAs.");
      30           0 :   return params;
      31           0 : }
      32             : 
      33           0 : NeutronicsSpectrumSamplerFission::NeutronicsSpectrumSamplerFission(
      34           0 :     const InputParameters & parameters)
      35           0 :   : NeutronicsSpectrumSamplerBase(parameters)
      36             : {
      37           0 :   _nmu = 1;
      38           0 :   _nphi = 1; // can't initialize base class members in initializer
      39             : 
      40           0 :   std::vector<Real> fxs = getParam<std::vector<Real>>("fission_cross_sections");
      41           0 :   if (fxs.size() != _npoints * _I * _G)
      42           0 :     mooseError("fission cross sections must be of length npoints x nisotopes x G");
      43             : 
      44             :   // get scalar fluxes
      45           0 :   _scalar_flux.resize(_G);
      46           0 :   for (unsigned int g = 0; g < _G; ++g)
      47           0 :     _scalar_flux[g] = &coupledValue("scalar_fluxes", g);
      48             : 
      49             :   // allocate and assign fission cross sections
      50             :   unsigned int p = 0;
      51           0 :   _fission_cross_section.resize(_npoints);
      52           0 :   for (unsigned j = 0; j < _npoints; ++j)
      53             :   {
      54           0 :     _fission_cross_section[j].resize(_I);
      55           0 :     for (unsigned int i = 0; i < _I; ++i)
      56             :     {
      57           0 :       _fission_cross_section[j][i].resize(_G);
      58           0 :       for (unsigned int g = 0; g < _G; ++g)
      59           0 :         _fission_cross_section[j][i][g] = fxs[p++];
      60             :     }
      61             :   }
      62           0 : }
      63             : 
      64             : Real
      65           0 : NeutronicsSpectrumSamplerFission::totalRecoilRate(unsigned int point_id,
      66             :                                                   const std::string & target_isotope) const
      67             : {
      68             :   Real rate = 0.0;
      69           0 :   auto it = std::find(_target_isotope_names.begin(), _target_isotope_names.end(), target_isotope);
      70           0 :   if (it == _target_isotope_names.end())
      71           0 :     mooseError("Isotope ", target_isotope, "does not exist");
      72           0 :   unsigned int target_isotope_id = std::distance(_target_isotope_names.begin(), it);
      73           0 :   for (unsigned int g = 0; g < _G; ++g)
      74           0 :     rate += _sample_point_data[point_id]({target_isotope_id, g, 0, 0});
      75           0 :   return rate;
      76             : }
      77             : 
      78             : Real
      79           0 : NeutronicsSpectrumSamplerFission::computeRadiationDamagePDF(unsigned int i,
      80             :                                                             unsigned int g,
      81             :                                                             unsigned int /*p*/,
      82             :                                                             unsigned int /*q*/)
      83             : {
      84           0 :   return (*_scalar_flux[g])[_qp] * (*_number_densities[i])[_qp] *
      85           0 :          _fission_cross_section[_current_point][i][g];
      86             : }
      87             : 
      88             : MultiIndex<Real>
      89           0 : NeutronicsSpectrumSamplerFission::getPDF(unsigned int point_id) const
      90             : {
      91             :   mooseAssert(_sample_point_data[point_id].size()[2] == 1,
      92             :               "RadiationDamageBase: Dimension of mu index is not 1.");
      93             :   mooseAssert(_sample_point_data[point_id].size()[3] == 1,
      94             :               "RadiationDamageBase: Dimension of phi index is not 1.");
      95             :   // the final index of the pdf has dimension 1 so we slice it to return a MI of dimension 2
      96           0 :   return _sample_point_data[point_id].slice(3, 0).slice(2, 0);
      97             : }

Generated by: LCOV version 1.14