https://mooseframework.inl.gov
ThermocoupleSensorPostprocessor.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 
12 #include "Function.h"
13 #include "MooseRandom.h"
14 #include "LinearInterpolation.h"
15 #include "SplineInterpolation.h"
16 
18 
21 {
23  params.addClassDescription("This is a ThermocoupleSensorPostprocessor for various classes of "
24  "thermocouples, described by the 'thermocouple_type' parameter");
25  params.addParam<Real>("proportional_weight", 0, "The weight assigned to the proportional term");
26  params.addParam<Real>("integral_weight", 1, "The weight assigned to the integral term");
27  return params;
28 }
29 
31  : GeneralSensorPostprocessor(parameters)
32 {
33  if (isParamSetByUser("R_function"))
34  mooseError("In thermocouple postprocessor R function is fixed. If you want to change it, use "
35  "GeneralSensorPostprocessor.");
36 }
37 
38 void
40 {
41  // setting seed for random number generator
42  _rng.seed(_seed);
43  Real drift_value = _drift_function.value(_t);
44  Real efficiency_value = _efficiency_function.value(_t);
45  Real signalToNoise_value = _signalToNoise_function.value(_t);
46  Real noise_std_dev = _noise_std_dev_function.value(_t);
47  Real noise_value = _rng.randNormal(0, noise_std_dev);
48  Real uncertainty_std_dev = _uncertainty_std_dev_function.value(_t);
49  Real uncertainty_value = _rng.randNormal(0, uncertainty_std_dev);
50 
51  // if the problem is steady-state
52  if (!_fe_problem.isTransient())
53  _sensor_value = drift_value +
54  efficiency_value * (_input_signal + signalToNoise_value * noise_value) +
55  uncertainty_value;
56 
57  // if the problem is transient
58  else
59  {
61  _time_values.push_back(_t);
63 
64  // Check if the size is greater than 500
65  if (_time_values.size() > 500 && _input_signal_values.size() > _vector_size)
66  {
67  // Remove the first 10 elements
68  _time_values.erase(_time_values.begin(), _time_values.begin() + 10);
70  }
71  Real _input_signal_delayed = getDelayedInputSignal();
72 
73  // computing integral term
74  Real term_for_integration = _input_signal + signalToNoise_value * noise_value;
75  _integrand.push_back(term_for_integration);
77 
78  // output
79  Real proportional_value = _input_signal_delayed + signalToNoise_value * noise_value;
80  _sensor_value = drift_value +
81  efficiency_value * (_proportional_weight * proportional_value +
83  uncertainty_value;
84  }
85 }
86 
89 {
90  return _sensor_value;
91 }
92 
93 vector<Real>
95 {
96  _R_function_values.clear();
97  // computing vector of exponential term
98  for (const auto i : index_range(_time_values))
100  return _R_function_values;
101 }
const Function & _signalToNoise_function
Signal to noise function.
std::vector< Real > & _input_signal_values
Input Signal vector for calculating delay.
auto exp(const T &)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const Function & _uncertainty_std_dev_function
Uncertainty std dev function.
void seed(std::size_t i, unsigned int seed)
const Function & _efficiency_function
Efficiency function.
ThermocoupleSensorPostprocessor(const InputParameters &parameters)
A Thermocouple Sensor Postprocessor that allows the user to characterize a thermocouple&#39;s response by...
registerMooseObject("MiscApp", ThermocoupleSensorPostprocessor)
Real randNormal(std::size_t i, Real mean, Real sigma)
const Function & _drift_function
The drift function to be evaluated and returned.
std::vector< Real > & _R_function_values
vector to store R function values
const Function & _noise_std_dev_function
Noise standard deviation function.
Real PostprocessorValue
Real getIntegral(std::vector< Real > integrand)
Function to calculate integral term.
std::vector< Real > & _integrand
Vector to store integrand data for numerical integration.
Real _sensor_value
for getValue() output
const Real _proportional_weight
A weighing factor for the proportional term.
bool isParamSetByUser(const std::string &nm) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Real _delay_value
Variable to store delay value.
FEProblemBase & _fe_problem
virtual PostprocessorValue getValue() const override
const PostprocessorValue & _input_signal
A postprocessor used as the sensor input signal.
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
std::vector< Real > & _time_values
Time vector for calculating delay.
virtual bool isTransient() const override
virtual vector< Real > getRVector() override
Function to calculate R vector.
virtual Real value(Real t, const Point &p) const
Real _integration_value
the output of the integrand
A generalized sensor Postprocessor.
const Real _integral_weight
A weighing factor for the integral term.
auto index_range(const T &sizable)
const Real _vector_size
Size of vector to be stored.
const unsigned int _seed
To get fixed seed random numbers.
const Function & _delay_function
Delay function.
static InputParameters validParams()
Real getDelayedInputSignal()
Function to calculate delayed input signal.