https://mooseframework.inl.gov
Loading...
Searching...
No Matches
HeatSourceFromTotalPower.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 "HeatStructurePlate.h"
13#include "TotalPowerBase.h"
14
16
19{
21 params.addRequiredParam<std::string>("power", "Component that provides total power");
22 params.addParam<Real>(
23 "power_fraction", 1., "Fraction of the total power that goes into the heat structure [-]");
24 params.addParam<FunctionName>("power_shape_function", "Axial power shape [-]");
25 params.declareControllable("power_fraction");
26 params.addClassDescription("Heat generation from total power");
27 return params;
28}
29
31 : HeatSourceBase(parameters),
32 _power_fraction(getParam<Real>("power_fraction")),
33 _has_psf(isParamValid("power_shape_function")),
34 _power_shape_func(_has_psf ? getParam<FunctionName>("power_shape_function") : "")
35{
36 checkSizeGreaterThan<std::string>("regions", 0);
37}
38
39void
41{
43
44 if (hasComponent<TotalPowerBase>("power"))
45 {
46 const TotalPowerBase & rp = getComponent<TotalPowerBase>("power");
48 }
49}
50
51void
53{
55
56 checkComponentOfTypeExists<TotalPowerBase>("power");
57}
58
59void
61{
63 const HeatStructureInterface & hs = getComponent<HeatStructureInterface>("hs");
64 const HeatStructureBase * hs_base = dynamic_cast<const HeatStructureBase *>(&hs);
65
66 Real n_units, length;
67 if (hs_base)
68 {
69 n_units = hs_base->getNumberOfUnits();
70 length = hs_base->getLength();
71 }
72 else // HeatStructureFromFile3D
73 {
74 n_units = 1.0;
75 length = 1.0;
76 }
77
78 const HeatStructureCylindricalBase * hs_cyl =
79 dynamic_cast<const HeatStructureCylindricalBase *>(&hs);
80 const bool is_cylindrical = hs_cyl != nullptr;
81
82 const HeatStructurePlate * hs_plate = dynamic_cast<const HeatStructurePlate *>(&hs);
83 const bool is_plate = hs_plate != nullptr;
84
85 if (!_has_psf)
86 {
87 _power_shape_func = genName(name(), "power_shape_fn");
88 std::string class_name = "ConstantFunction";
89 InputParameters pars = _factory.getValidParams(class_name);
90 pars.set<Real>("value") = 1. / length;
91 getTHMProblem().addFunction(class_name, _power_shape_func, pars);
92 }
93
94 const std::string power_shape_integral_name = _has_psf
95 ? genName(name(), _power_shape_func, "integral")
96 : genName(_power_shape_func, "integral");
97
98 {
99 const std::string class_name =
100 is_cylindrical ? "FunctionElementIntegralRZ" : "FunctionElementIntegral";
101 InputParameters pars = _factory.getValidParams(class_name);
102 pars.set<std::vector<SubdomainName>>("block") = _subdomain_names;
103 pars.set<FunctionName>("function") = _power_shape_func;
104 if (is_cylindrical)
105 {
106 pars.set<Point>("axis_point") = hs_cyl->getPosition();
107 pars.set<RealVectorValue>("axis_dir") = hs_cyl->getDirection();
108 }
109 pars.set<ExecFlagEnum>("execute_on") = {EXEC_INITIAL};
110 pars.set<std::vector<OutputName>>("outputs") = {"none"};
111 getTHMProblem().addPostprocessor(class_name, power_shape_integral_name, pars);
112 }
113
114 {
115 const std::string class_name =
116 is_cylindrical ? "ADHeatStructureHeatSourceRZ" : "ADHeatStructureHeatSource";
117 InputParameters pars = _factory.getValidParams(class_name);
118 pars.set<NonlinearVariableName>("variable") = HeatConductionModel::TEMPERATURE;
119 pars.set<std::vector<SubdomainName>>("block") = _subdomain_names;
120 pars.set<Real>("num_units") = n_units;
121 pars.set<Real>("power_fraction") = _power_fraction;
122 pars.set<FunctionName>("power_shape_function") = _power_shape_func;
123 pars.set<std::vector<VariableName>>("total_power") =
124 std::vector<VariableName>(1, _power_var_name);
125 if (is_cylindrical)
126 {
127 pars.set<Point>("axis_point") = hs_cyl->getPosition();
128 pars.set<RealVectorValue>("axis_dir") = hs_cyl->getDirection();
129 }
130 else if (is_plate)
131 {
132 // For plate heat structure, the element integral of the power shape only
133 // integrates over x and y, not z, so the depth still needs to be applied.
134 pars.set<Real>("scale") = 1.0 / hs_plate->getDepth();
135 }
136 pars.set<PostprocessorName>("power_shape_integral_pp") = power_shape_integral_name;
137 std::string mon = genName(name(), "heat_src");
138 getTHMProblem().addKernel(class_name, mon, pars);
139 connectObject(pars, mon, "power_fraction");
140 }
141}
registerMooseObject("ThermalHydraulicsApp", HeatSourceFromTotalPower)
const ExecFlagType EXEC_INITIAL
const std::string name
Definition Setup.h:21
virtual void init()
Initializes the component.
Definition Component.h:405
THMProblem & getTHMProblem() const
Gets the THM problem.
Definition Component.C:135
Factory & _factory
The Factory associated with the MooseApp.
Definition Component.h:497
void connectObject(const InputParameters &obj_params, const std::string &obj_name, const std::string &param) const
Connects a controllable parameter of the component to a controllable parameter of a constituent objec...
Definition Component.C:98
virtual RealVectorValue getDirection() const
virtual void addFunction(const std::string &type, const std::string &name, InputParameters &parameters)
virtual void addPostprocessor(const std::string &pp_name, const std::string &name, InputParameters &parameters)
virtual void addKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
InputParameters getValidParams(const std::string &name) const
static const std::string TEMPERATURE
Base class for heat source components.
std::vector< SubdomainName > _subdomain_names
Names of the heat structure subdomains corresponding to the given regions.
static InputParameters validParams()
virtual void check() const override
Check the component integrity.
Heat generation from total power.
virtual void init() override
Initializes the component.
HeatSourceFromTotalPower(const InputParameters &parameters)
FunctionName _power_shape_func
The name of the power shape function.
static InputParameters validParams()
virtual void addMooseObjects() override
const bool _has_psf
true if power shape function is being used
const Real & _power_fraction
The fraction of the power that goes into the heat structure.
virtual void check() const override
Check the component integrity.
VariableName _power_var_name
The name of the variable that represents total power.
Base class for 2D generated heat structures.
Real getNumberOfUnits() const
Gets the number of units that heat structure represents.
Base class for cylindrical heat structure components.
Interface class for heat structure components.
Component to model plate heat structure.
const Real & getDepth() const
Gets the depth of the plate.
void declareControllable(const std::string &name, std::set< ExecFlagType > execute_flags={})
void addRequiredParam(const std::string &name, const std::string &doc_string)
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)
T & set(const std::string &name, bool quiet_mode=false)
std::string genName(const std::string &prefix, unsigned int id, const std::string &suffix="") const
Build a name from a prefix, number and possible suffix.
Base class for components that provide total power.
virtual const VariableName & getPowerVariableName() const