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 "PKAFixedPointGenerator.h" 10 : #include "MooseMesh.h" 11 : 12 : registerMooseObject("MagpieApp", PKAFixedPointGenerator); 13 : 14 : InputParameters 15 87 : PKAFixedPointGenerator::validParams() 16 : { 17 87 : InputParameters params = PKAGeneratorBase::validParams(); 18 87 : params.addClassDescription("This PKAGenerator starts particle from a fixed point in a random " 19 : "direction (isotropically)."); 20 174 : params.addParam<unsigned int>( 21 174 : "num_pkas", 1000, "The number of PKAs to be started from this position"); 22 174 : params.addRequiredParam<Point>("point", "The point from which the PKAs are started"); 23 174 : params.addRequiredParam<Real>("Z", "PKA nuclear charge"); 24 174 : params.addRequiredParam<Real>("m", "PKA mass in amu"); 25 174 : params.addRequiredParam<Real>("E", "PKA energy in eV"); 26 87 : return params; 27 0 : } 28 : 29 48 : PKAFixedPointGenerator::PKAFixedPointGenerator(const InputParameters & parameters) 30 : : PKAGeneratorBase(parameters), 31 48 : _num_pka(getParam<unsigned int>("num_pkas")), 32 96 : _point(getParam<Point>("point")), 33 96 : _Z(getParam<Real>("Z")), 34 96 : _m(getParam<Real>("m")), 35 96 : _E(getParam<Real>("E")), 36 96 : _pl(_mesh.getPointLocator()) 37 : { 38 48 : _pl->enable_out_of_mesh_mode(); 39 48 : updateCachedElementID(); 40 48 : } 41 : 42 : void 43 11421 : PKAFixedPointGenerator::appendPKAs(std::vector<MyTRIM_NS::IonBase> & ion_list, 44 : const MyTRIMRasterizer::PKAParameters & pka_parameters, 45 : const MyTRIMRasterizer::AveragedData &) const 46 : { 47 11421 : if (_current_elem->id() != _elem_id) 48 : return; 49 : 50 27 : unsigned int num_pka = _num_pka; 51 27 : if (pka_parameters._recoil_rate_scaling != 1) 52 0 : num_pka = std::floor(pka_parameters._recoil_rate_scaling * _num_pka + getRandomReal()); 53 : 54 12960 : for (unsigned i = 0; i < num_pka; ++i) 55 : { 56 : // each fission event generates a pair of recoils 57 12933 : MyTRIM_NS::IonBase pka; 58 : 59 : // sample fission fragment masses 60 12933 : pka._Z = _Z; 61 12933 : pka._m = _m; 62 12933 : pka._E = _E; 63 : 64 : // the tag is the element this PKA get registered as upon stopping 65 : // -1 means the PKA will be ignored 66 12933 : pka._tag = ionTag(pka_parameters, pka._Z, pka._m); 67 : ; 68 : 69 : // set stopping criteria 70 12933 : pka.setEf(); 71 : 72 : // set initial location of the PKAs 73 12933 : pka._pos = _point; 74 : 75 : // set random direction for ion 1 and opposite direction for ion 2 76 12933 : setDirection(pka); 77 : 78 : // add PKA to list 79 12933 : ion_list.push_back(pka); 80 : } 81 : } 82 : 83 : void 84 9030 : PKAFixedPointGenerator::setDirection(MyTRIM_NS::IonBase & ion) const 85 : { 86 : // by default the angular distribution of PKAs is just uniform 87 9030 : setRandomDirection(ion); 88 9030 : } 89 : 90 : void 91 48 : PKAFixedPointGenerator::updateCachedElementID() 92 : { 93 : // get element containing the point 94 : mooseAssert(_pl != nullptr, "initialize() must be called on the MooseMyTRIMSample object."); 95 48 : const Elem * elem = (*_pl)(_point); 96 48 : if (elem == nullptr) 97 0 : mooseError("Point ", _point, " is not within the domain."); 98 48 : _elem_id = elem->id(); 99 48 : }