https://mooseframework.inl.gov
QuadInterWrapperPowerIC.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
11 #include "Function.h"
12 #include "QuadInterWrapperMesh.h"
13 
14 using namespace std;
15 using namespace Eigen;
16 
18 
21 {
23  params.addClassDescription("Computes axial power rate, W/m that goes into the inter-wrapper "
24  "cells in a square lattice subchannel arrangement");
25  params.addParam<Real>(
26  "power", 0.0, "The power of all the sub-assemblies that the inter-wrapper wraps around[W]");
27  params.addParam<std::string>("filename",
28  "file_was_not_found",
29  "name of power profile .txt file (should be a single column). It's "
30  "a Radial Power Profile. [UnitLess]");
31  params.addParam<FunctionName>(
32  "axial_heat_rate",
33  "1.0",
34  "user provided normalized function of axial heat rate [Unitless]. "
35  "The integral over pin heated length should equal the heated length."
36  "Zero is considered the inlet of the heated length.");
37  return params;
38 }
39 
41  : QuadInterWrapperBaseIC(params),
42  _power(getParam<Real>("power")),
43  _numberoflines(0),
44  _filename(getParam<std::string>("filename")),
45  _axial_heat_rate(getFunction("axial_heat_rate"))
46 {
47  auto nx = _mesh.getNx();
48  auto ny = _mesh.getNy();
49  auto heated_length = _mesh.getHeatedLength();
50 
51  _power_dis.resize((ny - 1) * (nx - 1), 1);
52  _power_dis.setZero();
53  _assembly_power_correction.resize((ny - 1) * (nx - 1), 1);
55  Real vin;
56  ifstream inFile;
57 
58  _console << "Power file: " << _filename << std::endl;
59 
60  if (_filename.compare("file_was_not_found"))
61  {
62  inFile.open(_filename);
63  if (!inFile)
64  mooseError(name(), "unable to open file : ", _filename);
65 
66  while (inFile >> vin)
67  _numberoflines += 1;
68 
69  if (inFile.fail() && !inFile.eof())
70  mooseError(name(), " non numerical input at line : ", _numberoflines);
71 
72  if (_numberoflines != (ny - 1) * (nx - 1))
73  mooseError(name(), " Radial profile file doesn't have correct size : ", (ny - 1) * (nx - 1));
74  inFile.close();
75  }
76  else
77  {
78  _numberoflines = (ny - 1) * (nx - 1);
79  }
80 
81  if (_filename.compare("file_was_not_found"))
82  {
83  inFile.open(_filename);
84  int i(0);
85  while (inFile >> vin)
86  {
87  _power_dis(i, 0) = vin;
88  i++;
89  }
90  inFile.close();
91  }
92 
93  _console << " Power distribution matrix :\n" << _power_dis << " \n";
94  auto sum = _power_dis.sum();
95  // full (100%) power of one pin [W]
96  auto fpin_power = _power / sum;
97  // actual pin power [W]
98  _ref_power = _power_dis * fpin_power;
99  // Convert the actual pin power to a linear heat rate [W/m]
100  _ref_qprime = _ref_power / heated_length;
101 }
102 
103 void
105 {
106 
107  auto nx = _mesh.getNx();
108  auto ny = _mesh.getNy();
109  auto nz = _mesh.getNumOfAxialCells();
110  auto z_grid = _mesh.getZGrid();
111  auto heated_length = _mesh.getHeatedLength();
112  auto unheated_length_entry = _mesh.getHeatedLengthEntry();
113 
114  _estimate_power.resize((ny - 1) * (nx - 1), 1);
115  _estimate_power.setZero();
116  for (unsigned int iz = 1; iz < nz + 1; iz++)
117  {
118  // Compute the height of this element.
119  auto dz = z_grid[iz] - z_grid[iz - 1];
120  // Compute axial location of nodes.
121  auto z2 = z_grid[iz];
122  auto z1 = z_grid[iz - 1];
123  Point p1(0, 0, z1 - unheated_length_entry);
124  Point p2(0, 0, z2 - unheated_length_entry);
125  // cycle through pins to estimate the total power of each pin
126  if (z2 > unheated_length_entry && z2 <= unheated_length_entry + heated_length)
127  {
128  for (unsigned int i_pin = 0; i_pin < (ny - 1) * (nx - 1); i_pin++)
129  {
130  // use of trapezoidal rule to add to total power of pin
131  _estimate_power(i_pin) +=
132  _ref_qprime(i_pin) * (_axial_heat_rate.value(_t, p1) + _axial_heat_rate.value(_t, p2)) *
133  dz / 2.0;
134  }
135  }
136  }
137 
138  // if a Pin has zero power (_ref_qprime(j, i) = 0) then I need to avoid dividing by zero. I
139  // divide by a wrong non-zero number which is not correct but this error doesn't mess things cause
140  // _ref_qprime(j, i) = 0.0
141  for (unsigned int i_pin = 0; i_pin < (ny - 1) * (nx - 1); i_pin++)
142  {
143  if (_estimate_power(i_pin) == 0.0)
144  _estimate_power(i_pin) = 1.0;
145  }
147 }
148 
149 Real
151 {
152  auto heated_length = _mesh.getHeatedLength();
153  auto unheated_length_entry = _mesh.getHeatedLengthEntry();
154  Point p1(0, 0, unheated_length_entry);
155  Point P = p - p1;
156  auto pin_mesh_exist = _mesh.pinMeshExist();
157 
158  if (pin_mesh_exist)
159  {
160  // project axial heat rate on pins
161  auto i_pin = _mesh.getPinIndexFromPoint(p);
162  {
163  if (p(2) >= unheated_length_entry && p(2) <= unheated_length_entry + heated_length)
164  return _ref_qprime(i_pin) * _assembly_power_correction(i_pin) *
166  else
167  return 0.0;
168  }
169  }
170  else
171  {
172  // project axial heat rate on subchannels
173  auto i_ch = _mesh.getSubchannelIndexFromPoint(p);
174  // if we are adjacent to the heated part of the fuel Pin
175  if (p(2) >= unheated_length_entry && p(2) <= unheated_length_entry + heated_length)
176  {
177  auto heat_rate = 0.0;
178  for (auto i_pin : _mesh.getChannelPins(i_ch))
179  {
180  heat_rate += 0.25 * _ref_qprime(i_pin) * _assembly_power_correction(i_pin) *
182  }
183  return heat_rate;
184  }
185  else
186  return 0.0;
187  }
188 }
Eigen::MatrixXd _estimate_power
Matrix which will hold the total estimated power of each fuel assembly [W].
unsigned int _numberoflines
The number of lines associated with the radial power profile .txt file.
Eigen::MatrixXd _power_dis
matrix that holds the values of the relative pin power
virtual const unsigned int & getNumOfAxialCells() const
Return the number of axial cells.
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
virtual const Real & getHeatedLength() const
Return heated length.
virtual const Real & getHeatedLengthEntry() const
Return unheated length at entry.
QuadInterWrapperPowerIC(const InputParameters &params)
unsigned int getPinIndexFromPoint(const Point &p) const override
Return a pin index for a given physical point p
registerMooseObject("SubChannelApp", QuadInterWrapperPowerIC)
Eigen::MatrixXd _ref_qprime
Average linear heat rate over the inter wrapper assembly [W/m].
virtual bool pinMeshExist() const override
Return if Pin Mesh exists or not.
virtual const std::string & name() const
unsigned int getSubchannelIndexFromPoint(const Point &p) const override
Return a inter-wrapper index for a given physical point p
Eigen::MatrixXd _assembly_power_correction
The correction that will be applied to the estimated calculation [unitless].
Eigen::MatrixXd _ref_power
Actual assembly power directly heating the inter-wrapper [W].
virtual const std::vector< unsigned int > & getChannelPins(unsigned int i_chan) const override
Return a vector of pin indices for a given channel index.
static InputParameters validParams()
virtual void initialSetup() override
const QuadInterWrapperMesh & _mesh
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual const unsigned int & getNx() const
number of inter-wrapper channels in the -x direction
virtual const std::vector< Real > & getZGrid() const
Get axial location of layers.
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
Sets the axial heat rate for each pin according to a radial power distribution and a user defined axi...
const ConsoleStream _console
static InputParameters validParams()
virtual Real value(Real t, const Point &p) const
std::string _filename
The name of the radial power profile file.
virtual const unsigned int & getNy() const
number of inter-wrapper channels in the -y direction
An abstract class for ICs for quadrilateral subchannels.
Real _power
The total power of the assembly.
Real value(const Point &p) override