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 "PKAGeneratorRecoil.h" 10 : #include "DiscreteFissionPKAPDF.h" 11 : #include "MultiIndex.h" 12 : 13 : registerMooseObject("MagpieApp", PKAGeneratorRecoil); 14 : 15 : InputParameters 16 0 : PKAGeneratorRecoil::validParams() 17 : { 18 0 : InputParameters params = PKAGeneratorNeutronicsBase::validParams(); 19 0 : params.addClassDescription( 20 : "PKA recoil generator user object.\n Takes pdf and samples PKAs due to recoil reaction."); 21 0 : return params; 22 0 : } 23 : 24 0 : PKAGeneratorRecoil::PKAGeneratorRecoil(const InputParameters & parameters) 25 0 : : PKAGeneratorNeutronicsBase(parameters) 26 : { 27 0 : } 28 : 29 : void 30 0 : PKAGeneratorRecoil::setPDF(const std::vector<unsigned int> & ZAID, 31 : const std::vector<Real> & energies, 32 : const MultiIndex<Real> & probabilities) 33 : { 34 0 : _pdf = DiscretePKAPDF(ZAID, energies, probabilities); 35 : #if DEBUG 36 : _console << "\nPKAGeneratorRecoil object received the following pdf from DiscretePKAPDF object:\n" 37 : << _pdf; 38 : #endif 39 0 : } 40 : 41 : void 42 0 : PKAGeneratorRecoil::appendPKAs(std::vector<MyTRIM_NS::IonBase> & ion_list, 43 : const MyTRIMRasterizer::PKAParameters & pka_parameters, 44 : const MyTRIMRasterizer::AveragedData & averaged_data) const 45 : { 46 0 : const auto dt = pka_parameters._dt; 47 0 : const auto vol = pka_parameters._volume; 48 0 : const auto recoil_rate_scaling = pka_parameters._recoil_rate_scaling; 49 : 50 : mooseAssert(dt >= 0, "Passed a negative time window into PKAGeneratorRecoil::appendPKAs"); 51 : mooseAssert(vol >= 0, "Passed a negative volume into PKAGeneratorRecoil::appendPKAs"); 52 : 53 0 : if (averaged_data._elements.size() != _partial_neutronics_reaction_rates.size()) 54 0 : mooseError("Size of averaged_data and partial_reaction_rates must be equal"); 55 : 56 0 : for (unsigned int nuclide = 0; nuclide < _partial_neutronics_reaction_rates.size(); ++nuclide) 57 : { 58 : unsigned int num_recoils = 59 0 : std::floor(recoil_rate_scaling * dt * vol * (*_partial_neutronics_reaction_rates[nuclide]) / 60 0 : (*_averaged_number_densities[nuclide]) * averaged_data._elements[nuclide] + 61 0 : getRandomReal()); 62 : 63 0 : for (unsigned i = 0; i < num_recoils; ++i) 64 : { 65 : std::vector<MyTRIM_NS::IonBase> ion; 66 0 : _pdf.drawSample(ion); 67 0 : ion[0].setEf(); 68 : // we need to track this recoil for getting interstitial count right 69 0 : ion[0]._tag = nuclide; 70 0 : setPosition(ion[0]); 71 0 : ion_list.push_back(ion[0]); 72 0 : } 73 : } 74 0 : }