LCOV - code coverage report
Current view: top level - src/fluidproperties - FlinakFluidProperties.C (source / functions) Hit Total Coverage
Test: idaholab/moose fluid_properties: #31706 (f8ed4a) with base bb0a08 Lines: 126 171 73.7 %
Date: 2025-11-03 17:24:35 Functions: 31 40 77.5 %
Legend: Lines: hit not hit

          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 "FlinakFluidProperties.h"
      11             : 
      12             : registerMooseObject("FluidPropertiesApp", FlinakFluidProperties);
      13             : 
      14             : InputParameters
      15          22 : FlinakFluidProperties::validParams()
      16             : {
      17          22 :   InputParameters params = SinglePhaseFluidProperties::validParams();
      18          66 :   params.addRangeCheckedParam<Real>(
      19             :       "drho_dp",
      20          44 :       1.7324E-7,
      21             :       "drho_dp > 0.0",
      22             :       "derivative of density with respect to pressure (at constant temperature)");
      23          22 :   params.addClassDescription("Fluid properties for flinak");
      24          22 :   return params;
      25           0 : }
      26             : 
      27          11 : FlinakFluidProperties::FlinakFluidProperties(const InputParameters & parameters)
      28             :   : SinglePhaseFluidProperties(parameters),
      29          11 :     _drho_dp(getParam<Real>("drho_dp")),
      30          11 :     _drho_dT(-0.73),
      31          11 :     _p_atm(101325.0),
      32          11 :     _cp(2010.0),
      33          11 :     _c0(2729.0),
      34          11 :     _dp_dT_at_constant_v(-_drho_dT / _drho_dp)
      35             : {
      36          11 : }
      37             : 
      38             : std::string
      39           1 : FlinakFluidProperties::fluidName() const
      40             : {
      41           1 :   return "flinak";
      42             : }
      43             : 
      44             : Real
      45           1 : FlinakFluidProperties::molarMass() const
      46             : {
      47           1 :   return 41.291077435E-3;
      48             : }
      49             : 
      50             : Real
      51           9 : FlinakFluidProperties::p_from_v_e(Real v, Real e) const
      52             : {
      53           9 :   Real temperature = T_from_v_e(v, e);
      54           9 :   return (1.0 / v - _drho_dT * temperature - _c0) / _drho_dp + _p_atm;
      55             : }
      56             : 
      57             : void
      58           1 : FlinakFluidProperties::p_from_v_e(Real v, Real e, Real & p, Real & dp_dv, Real & dp_de) const
      59             : {
      60           1 :   p = p_from_v_e(v, e);
      61             : 
      62             :   // chain rule, (dp_de)_v = (dp_dT)_v * (dT_de)_v
      63             :   Real T, dT_dv, dT_de;
      64           1 :   T_from_v_e(v, e, T, dT_dv, dT_de);
      65           1 :   dp_de = _dp_dT_at_constant_v * dT_de;
      66             : 
      67             :   // cyclic relation, (dP_dv)_e = - (dp_de)_v * (de_dv)_p
      68           1 :   Real cp = cp_from_v_e(v, e);
      69           1 :   Real dT_dv_at_constant_p = -1.0 / (_drho_dT * v * v);
      70           1 :   Real de_dv_at_constant_p = cp * dT_dv_at_constant_p - p;
      71           1 :   dp_dv = -dp_de * de_dv_at_constant_p;
      72           1 : }
      73             : 
      74             : void
      75           0 : FlinakFluidProperties::p_from_v_e(
      76             :     const ADReal & v, const ADReal & e, ADReal & p, ADReal & dp_dv, ADReal & dp_de) const
      77             : {
      78           0 :   p = SinglePhaseFluidProperties::p_from_v_e(v, e);
      79             : 
      80             :   // chain rule, (dp_de)_v = (dp_dT)_v * (dT_de)_v
      81             :   ADReal T, dT_dv, dT_de;
      82           0 :   T_from_v_e(v, e, T, dT_dv, dT_de);
      83           0 :   dp_de = _dp_dT_at_constant_v * dT_de;
      84             : 
      85             :   // cyclic relation, (dP_dv)_e = - (dp_de)_v * (de_dv)_p
      86           0 :   auto cp = SinglePhaseFluidProperties::cp_from_v_e(v, e);
      87           0 :   auto dT_dv_at_constant_p = -1.0 / (_drho_dT * v * v);
      88           0 :   auto de_dv_at_constant_p = cp * dT_dv_at_constant_p - p;
      89           0 :   dp_dv = -dp_de * de_dv_at_constant_p;
      90           0 : }
      91             : 
      92             : Real
      93          19 : FlinakFluidProperties::T_from_v_e(Real v, Real e) const
      94             : {
      95             :   // We need to write these in a somewhat strange manner to ensure that pressure
      96             :   // and temperature do not depend implicitly on each other, causing a circular
      97             :   // logic problem. Substituting the definition for pressure based on the
      98             :   // rho * (h - e) = P, where h = Cp * T into the density correlation for flibe,
      99             :   // we can rearrange and get temperature in terms of only v and e
     100             : 
     101             :   // p = (Cp * T - e) / v
     102             :   // T = (1 / v - drho_dp * [p                - p_atm] + _c0) / drho_dT
     103             :   //   = (1 / v - drho_dp * [(Cp * T - e) / v - p_atm] + _c0) / drho_dT
     104             :   //   = (1 + drho_dp * e + p_atm * v * drho_dp - _c0 * v) / (drho_dT * v + drho_dp * Cp)
     105             : 
     106          19 :   Real cp = cp_from_v_e(v, e);
     107          19 :   Real numerator = 1.0 + _drho_dp * (e + _p_atm * v) - _c0 * v;
     108          19 :   Real denominator = _drho_dT * v + _drho_dp * cp;
     109          19 :   return numerator / denominator;
     110             : }
     111             : 
     112             : void
     113           2 : FlinakFluidProperties::T_from_v_e(Real v, Real e, Real & T, Real & dT_dv, Real & dT_de) const
     114             : {
     115           2 :   T = T_from_v_e(v, e);
     116             : 
     117             :   // reciprocity relation based on the definition of cv
     118           2 :   Real cv = cv_from_v_e(v, e);
     119           2 :   dT_de = 1.0 / cv;
     120             : 
     121             :   // cyclic relation, (dT_dv)_e = -(dT_de)_v * (de_dv)_T
     122           2 :   Real p = p_from_v_e(v, e);
     123           2 :   Real dp_dv_at_constant_T = -1.0 / (_drho_dp * v * v);
     124           2 :   Real de_dv_at_constant_T = -(p + v * dp_dv_at_constant_T);
     125           2 :   dT_dv = -dT_de * de_dv_at_constant_T;
     126           2 : }
     127             : 
     128             : void
     129           0 : FlinakFluidProperties::T_from_v_e(
     130             :     const ADReal & v, const ADReal & e, ADReal & T, ADReal & dT_dv, ADReal & dT_de) const
     131             : {
     132           0 :   T = SinglePhaseFluidProperties::T_from_v_e(v, e);
     133             : 
     134             :   // reciprocity relation based on the definition of cv
     135           0 :   auto cv = SinglePhaseFluidProperties::cv_from_v_e(v, e);
     136           0 :   dT_de = 1.0 / cv;
     137             : 
     138             :   // cyclic relation, (dT_dv)_e = -(dT_de)_v * (de_dv)_T
     139           0 :   auto p = SinglePhaseFluidProperties::p_from_v_e(v, e);
     140           0 :   auto dp_dv_at_constant_T = -1.0 / (_drho_dp * v * v);
     141           0 :   auto de_dv_at_constant_T = -(p + v * dp_dv_at_constant_T);
     142           0 :   dT_dv = -dT_de * de_dv_at_constant_T;
     143           0 : }
     144             : 
     145             : Real
     146           1 : FlinakFluidProperties::T_from_p_h(Real /* p */, Real h) const
     147             : {
     148           1 :   return h / _cp;
     149             : }
     150             : 
     151             : ADReal
     152           0 : FlinakFluidProperties::T_from_p_h(const ADReal & /* p */, const ADReal & h) const
     153             : {
     154           0 :   return h / _cp;
     155             : }
     156             : 
     157             : Real
     158           2 : FlinakFluidProperties::T_from_p_rho(Real p, Real rho) const
     159             : {
     160           2 :   Real temperature = (rho - (p - _p_atm) * _drho_dp - _c0) / _drho_dT;
     161           2 :   return temperature;
     162             : }
     163             : 
     164          60 : Real FlinakFluidProperties::cp_from_v_e(Real /*v*/, Real /*e*/) const { return _cp; }
     165             : 
     166             : void
     167           1 : FlinakFluidProperties::cp_from_v_e(Real v, Real e, Real & cp, Real & dcp_dv, Real & dcp_de) const
     168             : {
     169           1 :   cp = cp_from_v_e(v, e);
     170           1 :   dcp_dv = 0.0;
     171           1 :   dcp_de = 0.0;
     172           1 : }
     173             : 
     174             : Real
     175           9 : FlinakFluidProperties::cv_from_v_e(Real v, Real e) const
     176             : {
     177             :   // definition of Cv by replacing e by h + p * v
     178           9 :   Real cp = cp_from_v_e(v, e);
     179           9 :   return cp - _dp_dT_at_constant_v * v;
     180             : }
     181             : 
     182             : void
     183           1 : FlinakFluidProperties::cv_from_v_e(Real v, Real e, Real & cv, Real & dcv_dv, Real & dcv_de) const
     184             : {
     185           1 :   cv = cv_from_v_e(v, e);
     186           1 :   dcv_dv = -_dp_dT_at_constant_v;
     187           1 :   dcv_de = 0.0;
     188           1 : }
     189             : 
     190             : void
     191           0 : FlinakFluidProperties::cv_from_v_e(
     192             :     const ADReal & v, const ADReal & e, ADReal & cv, ADReal & dcv_dv, ADReal & dcv_de) const
     193             : {
     194           0 :   cv = SinglePhaseFluidProperties::cv_from_v_e(v, e);
     195           0 :   dcv_dv = -_dp_dT_at_constant_v;
     196           0 :   dcv_de = 0.0;
     197           0 : }
     198             : 
     199             : Real
     200           1 : FlinakFluidProperties::mu_from_v_e(Real v, Real e) const
     201             : {
     202           1 :   Real temperature = T_from_v_e(v, e);
     203           1 :   return 4.0e-5 * std::exp(4170.0 / temperature);
     204             : }
     205             : 
     206             : Real
     207           1 : FlinakFluidProperties::k_from_v_e(Real v, Real e) const
     208             : {
     209           1 :   Real temperature = T_from_v_e(v, e);
     210           1 :   return 5.0e-4 * temperature + 0.43;
     211             : }
     212             : 
     213             : Real
     214          14 : FlinakFluidProperties::rho_from_p_T(Real pressure, Real temperature) const
     215             : {
     216          14 :   return _drho_dT * temperature + _drho_dp * (pressure - _p_atm) + _c0;
     217             : }
     218             : 
     219             : void
     220           1 : FlinakFluidProperties::rho_from_p_T(
     221             :     Real pressure, Real temperature, Real & rho, Real & drho_dp, Real & drho_dT) const
     222             : {
     223           1 :   rho = rho_from_p_T(pressure, temperature);
     224           1 :   drho_dp = _drho_dp;
     225           1 :   drho_dT = _drho_dT;
     226           1 : }
     227             : 
     228             : void
     229           0 : FlinakFluidProperties::rho_from_p_T(const ADReal & pressure,
     230             :                                     const ADReal & temperature,
     231             :                                     ADReal & rho,
     232             :                                     ADReal & drho_dp,
     233             :                                     ADReal & drho_dT) const
     234             : {
     235           0 :   rho = SinglePhaseFluidProperties::rho_from_p_T(pressure, temperature);
     236           0 :   drho_dp = _drho_dp;
     237           0 :   drho_dT = _drho_dT;
     238           0 : }
     239             : 
     240             : ADReal
     241           0 : FlinakFluidProperties::v_from_p_T(const ADReal & pressure, const ADReal & temperature) const
     242             : {
     243           0 :   return 1.0 / (_drho_dT * temperature + _drho_dp * (pressure - _p_atm) + _c0);
     244             : }
     245             : 
     246             : Real
     247          15 : FlinakFluidProperties::v_from_p_T(Real pressure, Real temperature) const
     248             : {
     249          15 :   return 1.0 / (_drho_dT * temperature + _drho_dp * (pressure - _p_atm) + _c0);
     250             : }
     251             : 
     252             : void
     253           1 : FlinakFluidProperties::v_from_p_T(
     254             :     Real pressure, Real temperature, Real & v, Real & dv_dp, Real & dv_dT) const
     255             : {
     256           1 :   v = v_from_p_T(pressure, temperature);
     257           1 :   dv_dp = -v * v * _drho_dp;
     258           1 :   dv_dT = -v * v * _drho_dT;
     259           1 : }
     260             : 
     261             : Real
     262           8 : FlinakFluidProperties::h_from_p_T(Real /*pressure*/, Real temperature) const
     263             : {
     264             :   // definition of h for constant Cp
     265           8 :   Real cp = cp_from_v_e(0.0 /* dummy */, 0.0 /* dummy */);
     266           8 :   return cp * temperature;
     267             : }
     268             : 
     269             : void
     270           1 : FlinakFluidProperties::h_from_p_T(
     271             :     Real pressure, Real temperature, Real & h, Real & dh_dp, Real & dh_dT) const
     272             : {
     273           1 :   h = h_from_p_T(pressure, temperature);
     274           1 :   Real cp = cp_from_v_e(0.0 /* dummy */, 0.0 /* dummy */);
     275             : 
     276           1 :   dh_dp = 0.0;
     277           1 :   dh_dT = cp;
     278           1 : }
     279             : 
     280             : Real
     281          14 : FlinakFluidProperties::e_from_p_T(Real pressure, Real temperature) const
     282             : {
     283             :   // definition of h = e + p * v
     284          14 :   Real v = v_from_p_T(pressure, temperature);
     285          14 :   Real cp = cp_from_v_e(v, 0.0 /* dummy */);
     286          14 :   return cp * temperature - pressure * v;
     287             : }
     288             : 
     289             : void
     290           1 : FlinakFluidProperties::e_from_p_T(
     291             :     Real pressure, Real temperature, Real & e, Real & de_dp, Real & de_dT) const
     292             : {
     293           1 :   e = e_from_p_T(pressure, temperature);
     294             : 
     295             :   Real v, dv_dp, dv_dT;
     296           1 :   v_from_p_T(pressure, temperature, v, dv_dp, dv_dT);
     297             : 
     298             :   // definition of e = h - p * v
     299           1 :   de_dp = -pressure * dv_dp - v;
     300             : 
     301             :   // definition of e = h - p * v
     302           1 :   Real cp = cp_from_v_e(v, e);
     303           1 :   de_dT = cp - pressure * dv_dT;
     304           1 : }
     305             : 
     306             : Real
     307           1 : FlinakFluidProperties::e_from_p_rho(Real p, Real rho) const
     308             : {
     309           1 :   return e_from_p_T(p, T_from_p_rho(p, rho));
     310             : }
     311             : 
     312             : Real
     313           0 : FlinakFluidProperties::beta_from_p_T(Real pressure, Real temperature) const
     314             : {
     315             :   Real rho, drho_dp, drho_dT;
     316           0 :   rho_from_p_T(pressure, temperature, rho, drho_dp, drho_dT);
     317           0 :   return -drho_dT / rho;
     318             : }
     319             : 
     320           7 : Real FlinakFluidProperties::cp_from_p_T(Real /*pressure*/, Real /*temperature*/) const
     321             : {
     322           7 :   return _cp;
     323             : }
     324             : 
     325             : void
     326           1 : FlinakFluidProperties::cp_from_p_T(
     327             :     Real pressure, Real temperature, Real & cp, Real & dcp_dp, Real & dcp_dT) const
     328             : {
     329           1 :   cp = cp_from_p_T(pressure, temperature);
     330           1 :   dcp_dp = 0.0;
     331           1 :   dcp_dT = 0.0;
     332           1 : }
     333             : 
     334             : Real
     335           0 : FlinakFluidProperties::cv_from_p_T(Real pressure, Real temperature) const
     336             : {
     337           0 :   Real v = v_from_p_T(pressure, temperature);
     338           0 :   Real e = e_from_p_T(pressure, temperature);
     339           0 :   return cv_from_v_e(v, e);
     340             : }
     341             : 
     342             : void
     343           0 : FlinakFluidProperties::cv_from_p_T(
     344             :     Real pressure, Real temperature, Real & cv, Real & dcv_dp, Real & dcv_dT) const
     345             : {
     346           0 :   cv = cv_from_p_T(pressure, temperature);
     347           0 :   dcv_dp = 0.0;
     348           0 :   dcv_dT = 0.0;
     349           0 : }
     350             : 
     351             : Real
     352           7 : FlinakFluidProperties::mu_from_p_T(Real /*pressure*/, Real temperature) const
     353             : {
     354           7 :   return 4.0e-5 * std::exp(4170.0 / temperature);
     355             : }
     356             : 
     357             : void
     358           1 : FlinakFluidProperties::mu_from_p_T(
     359             :     Real pressure, Real temperature, Real & mu, Real & dmu_dp, Real & dmu_dT) const
     360             : {
     361           1 :   mu = this->mu_from_p_T(pressure, temperature);
     362           1 :   dmu_dp = 0.0;
     363           1 :   dmu_dT = -4.0e-5 * std::exp(4170.0 / temperature) * 4170.0 / (temperature * temperature);
     364           1 : }
     365             : 
     366             : Real
     367           7 : FlinakFluidProperties::k_from_p_T(Real /*pressure*/, Real temperature) const
     368             : {
     369           7 :   return 5.0e-4 * temperature + 0.43;
     370             : }
     371             : 
     372             : void
     373           1 : FlinakFluidProperties::k_from_p_T(
     374             :     Real pressure, Real temperature, Real & k, Real & dk_dp, Real & dk_dT) const
     375             : {
     376           1 :   k = this->k_from_p_T(pressure, temperature);
     377           1 :   dk_dp = 0.0;
     378           1 :   dk_dT = 5.0e-4;
     379           1 : }

Generated by: LCOV version 1.14