https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
38void
40{
41 // setting seed for random number generator
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
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 {
60 // Remove last element if we are repeating the timestep
61 mooseAssert(_t_step_old <= _t_step,
62 "The old time step needs to be behind or the same as the current time step.");
63 if (_t_step_old == _t_step)
64 {
65 _time_values.pop_back();
66 _input_signal_values.pop_back();
67 _integrand.pop_back();
68 }
69
71 _time_values.push_back(_t);
73
74 // Check if the size is greater than 500
75 if (_time_values.size() > 500 && _input_signal_values.size() > _vector_size)
76 {
77 // Remove the first 10 elements
78 _time_values.erase(_time_values.begin(), _time_values.begin() + 10);
80 }
81 Real _input_signal_delayed = getDelayedInputSignal();
82
83 // computing integral term
84 Real term_for_integration = _input_signal + signalToNoise_value * noise_value;
85 _integrand.push_back(term_for_integration);
87
88 // output
89 Real proportional_value = _input_signal_delayed + signalToNoise_value * noise_value;
90 _sensor_value = drift_value +
91 efficiency_value * (_proportional_weight * proportional_value +
93 uncertainty_value;
94
95 // Update old time step
97 }
98}
99
105
106vector<Real>
108{
109 _R_function_values.clear();
110 // computing vector of exponential term
111 for (const auto i : index_range(_time_values))
112 _R_function_values.push_back(exp(-(_t - _time_values[i]) / _delay_value) / _delay_value);
113 return _R_function_values;
114}
Real PostprocessorValue
registerMooseObject("MiscApp", ThermocoupleSensorPostprocessor)
virtual bool isTransient() const override
virtual Real value(Real t, const Point &p) const
A generalized sensor Postprocessor.
const Function & _drift_function
The drift function to be evaluated and returned.
int & _t_step_old
The last time step this object was executed on.
std::vector< Real > & _R_function_values
vector to store R function values
const Real _proportional_weight
A weighing factor for the proportional term.
const Function & _signalToNoise_function
Signal to noise function.
Real _sensor_value
for getValue() output
std::vector< Real > & _input_signal_values
Input Signal vector for calculating delay.
const Real _integral_weight
A weighing factor for the integral term.
const PostprocessorValue & _input_signal
A postprocessor used as the sensor input signal.
const Function & _uncertainty_std_dev_function
Uncertainty std dev function.
const Function & _efficiency_function
Efficiency function.
std::vector< Real > & _time_values
Time vector for calculating delay.
const unsigned int _seed
To get fixed seed random numbers.
const Real _vector_size
Size of vector to be stored.
Real _delay_value
Variable to store delay value.
Real getIntegral(std::vector< Real > integrand)
Function to calculate integral term.
const Function & _delay_function
Delay function.
const Function & _noise_std_dev_function
Noise standard deviation function.
Real getDelayedInputSignal()
Function to calculate delayed input signal.
std::vector< Real > & _integrand
Vector to store integrand data for numerical integration.
static InputParameters validParams()
Real _integration_value
the output of the integrand
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
bool isParamSetByUser(const std::string &name) const
void mooseError(Args &&... args) const
void seed(std::size_t i, unsigned int seed)
Real randNormal(std::size_t i, Real mean, Real sigma)
A Thermocouple Sensor Postprocessor that allows the user to characterize a thermocouple's response by...
ThermocoupleSensorPostprocessor(const InputParameters &parameters)
virtual vector< Real > getRVector() override
Function to calculate R vector.
virtual PostprocessorValue getValue() const override
FEProblemBase & _fe_problem