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 "TwoPhaseFluidProperties.h" 11 : #include "SinglePhaseFluidProperties.h" 12 : 13 : InputParameters 14 653 : TwoPhaseFluidProperties::validParams() 15 : { 16 653 : InputParameters params = FluidProperties::validParams(); 17 653 : params.set<std::string>("fp_type") = "two-phase-fp"; 18 : 19 1306 : params.addParam<UserObjectName>("fp_liquid", 20 : "Liquid single-phase fluid properties user object name"); 21 1306 : params.addParam<UserObjectName>("fp_vapor", 22 : "Vapor single-phase fluid properties user object name"); 23 : 24 653 : return params; 25 0 : } 26 : 27 361 : TwoPhaseFluidProperties::TwoPhaseFluidProperties(const InputParameters & parameters) 28 : : FluidProperties(parameters), 29 : 30 722 : _liquid_name(isParamValid("fp_liquid") ? getParam<UserObjectName>("fp_liquid") 31 571 : : UserObjectName(name() + ":liquid")), 32 1083 : _vapor_name(isParamValid("fp_vapor") ? getParam<UserObjectName>("fp_vapor") 33 932 : : UserObjectName(name() + ":vapor")) 34 : { 35 : // If the single-phase fluid properties user object names are not provided, it 36 : // is implied that these objects will be created by a derived class. In this 37 : // case, we need to check that these user objects do not already exist. 38 722 : if (!isParamValid("fp_liquid")) 39 105 : if (_tid == 0 && _fe_problem.hasUserObject(_liquid_name)) 40 0 : paramError("fp_liquid", 41 0 : "The two-phase fluid properties object '" + name() + "' is ", 42 : "trying to create a single-phase fluid properties object with ", 43 : "name '", 44 : _liquid_name, 45 : "', but a single-phase fluid properties ", 46 : "object with this name already exists."); 47 722 : if (!isParamValid("fp_vapor")) 48 105 : if (_tid == 0 && _fe_problem.hasUserObject(_vapor_name)) 49 0 : paramError("fp_vapor", 50 0 : "The two-phase fluid properties object '" + name() + "' is ", 51 : "trying to create a single-phase fluid properties object with ", 52 : "name '", 53 : _vapor_name, 54 : "', but a single-phase fluid properties ", 55 : "object with this name already exists."); 56 361 : } 57 : 58 : #pragma GCC diagnostic push 59 : #pragma GCC diagnostic ignored "-Woverloaded-virtual" 60 : 61 : Real 62 0 : TwoPhaseFluidProperties::T_triple() const 63 : { 64 0 : mooseError(__PRETTY_FUNCTION__, " is not implemented."); 65 : } 66 : 67 : ADReal 68 7 : TwoPhaseFluidProperties::T_sat(const ADReal & p) const 69 : { 70 7 : const Real p_real = p.value(); 71 7 : const Real T_sat_real = T_sat(p_real); 72 7 : const Real dT_sat_dp_real = dT_sat_dp(p_real); 73 : 74 7 : ADReal T_sat = T_sat_real; 75 7 : T_sat.derivatives() = p.derivatives() * dT_sat_dp_real; 76 7 : return T_sat; 77 : } 78 : 79 : ADReal 80 7 : TwoPhaseFluidProperties::p_sat(const ADReal & T) const 81 : { 82 7 : const Real T_real = T.value(); 83 7 : const Real p_sat_real = p_sat(T_real); 84 7 : const Real dp_sat_dT_real = 1.0 / dT_sat_dp(p_sat_real); 85 : 86 7 : ADReal p_sat = p_sat_real; 87 7 : p_sat.derivatives() = T.derivatives() * dp_sat_dT_real; 88 7 : return p_sat; 89 : } 90 : 91 : Real 92 73 : TwoPhaseFluidProperties::h_lat(Real p, Real T) const 93 : { 94 73 : return _fp_vapor->h_from_p_T(p, T) - _fp_liquid->h_from_p_T(p, T); 95 : } 96 : 97 : ADReal 98 1 : TwoPhaseFluidProperties::h_lat(const ADReal & p, const ADReal & T) const 99 : { 100 1 : return _fp_vapor->h_from_p_T(p, T) - _fp_liquid->h_from_p_T(p, T); 101 : } 102 : 103 : Real 104 0 : TwoPhaseFluidProperties::L_fusion() const 105 : { 106 0 : mooseError(__PRETTY_FUNCTION__, " is not implemented."); 107 : } 108 : 109 0 : Real TwoPhaseFluidProperties::sigma_from_T(Real /*T*/) const 110 : { 111 0 : mooseError(__PRETTY_FUNCTION__, " is not implemented."); 112 : } 113 : 114 : ADReal 115 7 : TwoPhaseFluidProperties::sigma_from_T(const ADReal & T) const 116 : { 117 7 : const Real T_real = T.value(); 118 7 : const Real sigma_real = sigma_from_T(T_real); 119 7 : const Real dsigma_dT = dsigma_dT_from_T(T_real); 120 : 121 7 : ADReal sigma = sigma_real; 122 7 : sigma.derivatives() = T.derivatives() * dsigma_dT; 123 7 : return sigma; 124 : } 125 : 126 0 : Real TwoPhaseFluidProperties::dsigma_dT_from_T(Real /*T*/) const 127 : { 128 0 : mooseError(__PRETTY_FUNCTION__, " is not implemented."); 129 : } 130 : 131 : #pragma GCC diagnostic pop