Line data Source code
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 "ADBoundaryFlux3EqnGhostMassFlowRateTemperature.h" 11 : #include "THMIndicesVACE.h" 12 : #include "SinglePhaseFluidProperties.h" 13 : #include "Numerics.h" 14 : #include "Function.h" 15 : 16 : registerMooseObject("ThermalHydraulicsApp", ADBoundaryFlux3EqnGhostMassFlowRateTemperature); 17 : 18 : InputParameters 19 838 : ADBoundaryFlux3EqnGhostMassFlowRateTemperature::validParams() 20 : { 21 838 : InputParameters params = ADBoundaryFlux3EqnGhostBase::validParams(); 22 : 23 838 : params.addClassDescription( 24 : "Computes a boundary flux from a specified mass flow rate and temperature for the 1-D, " 25 : "1-phase, variable-area Euler equations using a ghost cell"); 26 : 27 1676 : params.addRequiredParam<Real>("mass_flow_rate", "Specified mass flow rate"); 28 1676 : params.addRequiredParam<Real>("T", "Specified temperature"); 29 1676 : params.addRequiredParam<std::vector<FunctionName>>( 30 : "passives", "Specified passive transport functions [amount/m^3]"); 31 1676 : params.addParam<bool>("reversible", true, "True for reversible, false for pure inlet"); 32 : 33 1676 : params.addRequiredParam<UserObjectName>("fluid_properties", 34 : "Name of single-phase fluid properties user object"); 35 : 36 1676 : params.declareControllable("mass_flow_rate T"); 37 838 : return params; 38 0 : } 39 : 40 445 : ADBoundaryFlux3EqnGhostMassFlowRateTemperature::ADBoundaryFlux3EqnGhostMassFlowRateTemperature( 41 445 : const InputParameters & parameters) 42 : : ADBoundaryFlux3EqnGhostBase(parameters), 43 : 44 445 : _rhouA(getParam<Real>("mass_flow_rate")), 45 890 : _T(getParam<Real>("T")), 46 890 : _reversible(getParam<bool>("reversible")), 47 890 : _fp(getUserObject<SinglePhaseFluidProperties>("fluid_properties")) 48 : { 49 : // get specified passive transport functions 50 890 : const auto & passives = getParam<std::vector<FunctionName>>("passives"); 51 445 : _n_passives = passives.size(); 52 445 : _passives_fn.resize(_n_passives); 53 465 : for (const auto i : make_range(_n_passives)) 54 20 : _passives_fn[i] = &getFunctionByName(passives[i]); 55 445 : } 56 : 57 : std::vector<ADReal> 58 20717 : ADBoundaryFlux3EqnGhostMassFlowRateTemperature::getGhostCellSolution(const std::vector<ADReal> & U, 59 : const Point & point) const 60 : { 61 20717 : const ADReal rhoA = U[THMVACE1D::RHOA]; 62 20717 : const ADReal rhouA = U[THMVACE1D::RHOUA]; 63 20717 : const ADReal rhoEA = U[THMVACE1D::RHOEA]; 64 20717 : const ADReal A = U[THMVACE1D::AREA]; 65 : 66 20717 : std::vector<ADReal> U_ghost(THMVACE1D::N_FLUX_INPUTS + _n_passives); 67 20717 : if (!_reversible || THM::isInlet(_rhouA, _normal)) 68 : { 69 : // Pressure is the only quantity coming from the interior 70 : const ADReal rho = rhoA / A; 71 : const ADReal vel = rhouA / rhoA; 72 : const ADReal E = rhoEA / rhoA; 73 20261 : const ADReal e = E - 0.5 * vel * vel; 74 40522 : const ADReal p = _fp.p_from_v_e(1.0 / rho, e); 75 : 76 20261 : const ADReal rho_b = _fp.rho_from_p_T(p, _T); 77 20261 : const ADReal vel_b = _rhouA / (rho_b * A); 78 20261 : const ADReal e_b = _fp.e_from_p_rho(p, rho_b); 79 40522 : const ADReal E_b = e_b + 0.5 * vel_b * vel_b; 80 : 81 20261 : U_ghost[THMVACE1D::RHOA] = rho_b * A; 82 20261 : U_ghost[THMVACE1D::RHOUA] = _rhouA; 83 20261 : U_ghost[THMVACE1D::RHOEA] = rho_b * E_b * A; 84 20261 : U_ghost[THMVACE1D::AREA] = A; 85 20455 : for (const auto i : make_range(_n_passives)) 86 388 : U_ghost[THMVACE1D::N_FLUX_INPUTS + i] = _passives_fn[i]->value(_t, point) * A; 87 : } 88 : else 89 : { 90 456 : U_ghost[THMVACE1D::RHOA] = rhoA; 91 456 : U_ghost[THMVACE1D::RHOUA] = _rhouA; 92 456 : U_ghost[THMVACE1D::RHOEA] = rhoEA; 93 456 : U_ghost[THMVACE1D::AREA] = A; 94 456 : for (const auto i : make_range(_n_passives)) 95 0 : U_ghost[THMVACE1D::N_FLUX_INPUTS + i] = U[THMVACE1D::N_FLUX_INPUTS + i]; 96 : } 97 : 98 20717 : return U_ghost; 99 0 : }