https://mooseframework.inl.gov
Loading...
Searching...
No Matches
UnitTripControl.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
10#include "UnitTripControl.h"
12
13registerMooseObject("ThermalHydraulicsApp", UnitTripControl);
14
17{
21 "Trips a boolean based on the evaluation of a parsed condition expression");
22 params.addRequiredCustomTypeParam<std::string>(
23 "condition",
24 "FunctionExpression",
25 "The condition that this trip unit uses to determine its state.");
26 params.addParam<bool>("latch",
27 false,
28 "Determines if the output of this control stays true after the trip went "
29 "from false to true.");
30 return params;
31}
32
34 : THMControl(parameters),
35 MooseParsedFunctionBase(parameters),
36 _condition(verifyFunction(getParam<std::string>("condition"))),
37 _state(declareComponentControlData<bool>("state")),
38 _latch(getParam<bool>("latch")),
39 _tripped(false)
40{
41}
42
43void
45{
46 if (!_condition_ptr)
47 {
48 THREAD_ID tid = 0;
49 if (isParamValid("_tid"))
50 tid = getParam<THREAD_ID>("_tid");
51
52 _condition_ptr = std::make_unique<THMParsedFunctionWrapper>(
54 }
55}
56
57void
62
63void
65{
67
68 // establish dependency so that the control data graph is properly evaluated
69 for (auto & ctrl_name : _condition_ptr->getRealControlData())
70 getControlDataByName<Real>(ctrl_name->name());
71 for (auto & ctrl_name : _condition_ptr->getBoolControlData())
72 getControlDataByName<bool>(ctrl_name->name());
73}
74
75void
77{
78 if (_latch && _tripped)
79 {
80 _state = true;
81 return;
82 }
83
84 Real result = _condition_ptr->evaluate(_t, Point(0., 0., 0.));
85 if (result == 0.)
86 _state = false;
87 else if (result == 1.)
88 {
89 _state = true;
90 _tripped = true;
91 }
92 else
94 ": The user-provided condition expression did not return a boolean value (0 or 1).");
95}
unsigned int THREAD_ID
registerMooseObject("ThermalHydraulicsApp", UnitTripControl)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addRequiredCustomTypeParam(const std::string &name, const std::string &custom_type, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
const std::string & name() const
void mooseError(Args &&... args) const
bool isParamValid(const std::string &name) const
const std::vector< std::string > _vals
FEProblemBase & _pfb_feproblem
static InputParameters validParams()
const std::vector< std::string > _vars
static InputParameters validParams()
Definition THMControl.C:13
THMProblem * _sim
Definition THMControl.h:90
Real & _t
This control block uses a user-defined condition to determine if a trip happened.
virtual void init() override
std::unique_ptr< THMParsedFunctionWrapper > _condition_ptr
Pointer to the Parsed function wrapper object.
UnitTripControl(const InputParameters &parameters)
bool & _state
The state of this control object.
virtual void execute() override
bool _tripped
true if the trip happened, otherwise false
virtual void initialSetup() override
void buildConditionFunction()
Build the function that is used to evaluate the condition of this trip control.
const bool & _latch
Determines if the state of the trip should stay true for the rest of the simulation after the trip ha...
std::string _condition
The user-defined condition.
static InputParameters validParams()