LCOV - code coverage report
Current view: top level - include/fluidproperties - TemperaturePressureFunctionFluidProperties.h (source / functions) Hit Total Coverage
Test: idaholab/moose fluid_properties: #31405 (292dce) with base fef103 Lines: 0 3 0.0 %
Date: 2025-09-04 07:53:14 Functions: 0 2 0.0 %
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             : #pragma once
      11             : 
      12             : #include "SinglePhaseFluidProperties.h"
      13             : #include "Function.h"
      14             : 
      15             : /**
      16             :  * Fluid properties provided as multiple-variable functions of temperature and pressure.
      17             :  * Temperature is passed as the first spatial coordinate, x, to the function, while pressure
      18             :  * is passed as the second spatial coordinate, y.
      19             :  */
      20             : class TemperaturePressureFunctionFluidProperties : public SinglePhaseFluidProperties
      21             : {
      22             : public:
      23             :   TemperaturePressureFunctionFluidProperties(const InputParameters & parameters);
      24             : 
      25             :   static InputParameters validParams();
      26             : 
      27             :   /**
      28             :    * Fluid name
      29             :    *
      30             :    * @return "TemperaturePressureFunctionFluidProperties"
      31             :    */
      32             :   virtual std::string fluidName() const override;
      33             : 
      34             :   /**
      35             :    * Temperature from specific volume and specific internal energy
      36             :    *
      37             :    * @param[in] v   specific volume (m$^3$/kg)
      38             :    * @param[in] e   specific internal energy (J/kg)
      39             :    * @return temperature (K)
      40             :    */
      41             :   virtual Real T_from_v_e(Real v, Real e) const override;
      42             : 
      43             :   /**
      44             :    * Temperature from pressure and density
      45             :    *
      46             :    * @param[in] p          pressure (Pa)
      47             :    * @param[in] rho        density (kg/m$^3$)
      48             :    * @return temperature (T)
      49             :    */
      50             :   virtual Real T_from_p_rho(Real p, Real rho) const;
      51             : 
      52             :   /**
      53             :    * Temperature from pressure and specific enthalpy
      54             :    *
      55             :    * @param[in] p          pressure (Pa)
      56             :    * @param[in] h          specific enthalpy (J/kg)
      57             :    * @return temperature (T)
      58             :    */
      59             :   virtual Real T_from_p_h(Real p, Real h) const override;
      60             : 
      61             :   /**
      62             :    * Pressure from specific volume and specific internal energy
      63             :    *
      64             :    * @param[in] v   specific volume (m$^3$/kg)
      65             :    * @param[in] e   specific internal energy (J/kg)
      66             :    * @return pressure (Pa)
      67             :    */
      68             :   virtual Real p_from_v_e(Real v, Real e) const override;
      69             : 
      70             :   /**
      71             :    * Isobaric specific heat from specific volume and specific internal energy
      72             :    *
      73             :    * @param[in] v   specific volume (m$^3$/kg)
      74             :    * @param[in] e   specific internal energy (J/kg)
      75             :    * @return isobaric specific heat (J/kg.K)
      76             :    */
      77             :   virtual Real cp_from_v_e(Real v, Real e) const override;
      78             :   /**
      79             :    * Isobaric specific heat capacity and its derivatives from specific volume and energy
      80             :    *
      81             :    * @param[in] v       specific volume
      82             :    * @param[in] e       specific energy
      83             :    * @param[out] cp     isobaric specific heat (J/kg/K)
      84             :    * @param[out] dcp_dv derivative of isobaric specific heat w.r.t. specific volume
      85             :    * @param[out] dcp_de derivative of isobaric specific heat w.r.t. specific energy
      86             :    */
      87             :   virtual void cp_from_v_e(Real v, Real e, Real & cp, Real & dcp_dv, Real & dcp_de) const override;
      88             : 
      89             :   /**
      90             :    * Isochoric specific heat from specific volume and specific internal energy
      91             :    *
      92             :    * @param[in] v   specific volume (m$^3$/kg)
      93             :    * @param[in] e   specific internal energy (J/kg)
      94             :    * @return isochoric specific heat (J/kg.K)
      95             :    */
      96             :   virtual Real cv_from_v_e(Real v, Real e) const override;
      97             :   /**
      98             :    * Isochoric specific heat capacity and its derivatives from pressure and temperature
      99             :    *
     100             :    * @param[in] p       pressure (Pa)
     101             :    * @param[in] T       temperature (K)
     102             :    * @param[out] cv     isochoric specific heat (J/kg/K)
     103             :    * @param[out] dcv_dv derivative of isochoric specific heat w.r.t. specific volume
     104             :    * @param[out] dcv_de derivative of isochoric specific heat w.r.t. specific energy
     105             :    */
     106             :   virtual void cv_from_v_e(Real p, Real T, Real & cv, Real & dcv_dv, Real & dcv_de) const override;
     107             : 
     108             :   /**
     109             :    * Dynamic viscosity from specific volume and specific internal energy
     110             :    *
     111             :    * @param[in] v   specific volume (m$^3$/kg)
     112             :    * @param[in] e   specific internal energy (J/kg)
     113             :    * @return dynamic viscosity (Pa.s)
     114             :    */
     115             :   virtual Real mu_from_v_e(Real v, Real e) const override;
     116             : 
     117             :   /**
     118             :    * Thermal conductivity from specific volume and specific internal energy
     119             :    *
     120             :    * @param[in] v   specific volume (m$^3$/kg)
     121             :    * @param[in] e   specific internal energy (J/kg)
     122             :    * @return thermal conductivity (W/m.K)
     123             :    */
     124             :   virtual Real k_from_v_e(Real v, Real e) const override;
     125             : 
     126             :   /**
     127             :    * Density from pressure and temperature
     128             :    *
     129             :    * @param[in] p   pressure (Pa)
     130             :    * @param[in] T   temperature (K)
     131             :    * @return density (kg/m$^3$)
     132             :    */
     133             :   virtual Real rho_from_p_T(Real p, Real T) const override;
     134             : 
     135             :   /**
     136             :    * Density and its derivatives from pressure and temperature
     137             :    *
     138             :    * @param[in] p          pressure (Pa)
     139             :    * @param[in] T          temperature (K)
     140             :    * @param[out] rho       density (kg/m$^3$)
     141             :    * @param[out] drho_dp   derivative of density w.r.t. pressure
     142             :    * @param[out] drho_dT   derivative of density w.r.t. temperature
     143             :    */
     144             :   virtual void
     145             :   rho_from_p_T(Real p, Real T, Real & rho, Real & drho_dp, Real & drho_dT) const override;
     146             :   virtual void rho_from_p_T(const ADReal & pressure,
     147             :                             const ADReal & temperature,
     148             :                             ADReal & rho,
     149             :                             ADReal & drho_dp,
     150             :                             ADReal & drho_dT) const override;
     151             : 
     152             :   /**
     153             :    * Specific volume from pressure and temperature
     154             :    * @param[in] p    pressure (Pa)
     155             :    * @param[in] T    temperature (K)
     156             :    * @return specific volume (m$^3$/kg)
     157             :    */
     158             :   virtual Real v_from_p_T(Real p, Real T) const override;
     159             : 
     160             :   /**
     161             :    * Specific volume and its derivatives from pressure and temperature
     162             :    * @param[in] p       pressure (Pa)
     163             :    * @param[in] T       temperature (K)
     164             :    * @param[out] v      specific volume (m$^3$/kg)
     165             :    * @param[out] dv_dp  derivative of specific volume with respect to pressure
     166             :    * @param[out] dv_dT  derivative of specific volume with respect to temperature
     167             :    */
     168             :   virtual void v_from_p_T(Real p, Real T, Real & v, Real & dv_dp, Real & dv_dT) const override;
     169             : 
     170             :   /**
     171             :    * Specific enthalpy from pressure and temperature
     172             :    *
     173             :    * @param[in] p   pressure (Pa)
     174             :    * @param[in] T   temperature (K)
     175             :    * @return specific enthalpy (J/kg)
     176             :    */
     177             :   virtual Real h_from_p_T(Real p, Real T) const override;
     178             : 
     179             :   /**
     180             :    * Specific enthalpy and its derivatives from pressure and temperature
     181             :    *
     182             :    * @param[in] p        pressure (Pa)
     183             :    * @param[in] T        temperature (K)
     184             :    * @param[out] h       specific enthalpy (J/kg)
     185             :    * @param[out] dh_dp   derivative of specific enthalpy w.r.t. pressure
     186             :    * @param[out] dh_dT   derivative of specific enthalpy w.r.t. temperature
     187             :    */
     188             :   virtual void h_from_p_T(Real p, Real T, Real & h, Real & dh_dp, Real & dh_dT) const override;
     189             : 
     190             :   /**
     191             :    * Specific internal energy from pressure and temperature
     192             :    *
     193             :    * @param[in] p   pressure (Pa)
     194             :    * @param[in] T   temperature (K)
     195             :    * @return specific internal energy (J/kg)
     196             :    */
     197             :   virtual Real e_from_p_T(Real p, Real T) const override;
     198             : 
     199             :   /**
     200             :    * Specific internal energy and its derivatives from pressure and temperature
     201             :    *
     202             :    * @param[in] p        pressure (Pa)
     203             :    * @param[in] T        temperature (K)
     204             :    * @param[out] e       specific internal energy (J/kg)
     205             :    * @param[out] de_dp   derivative of specific internal energy w.r.t. pressure
     206             :    * @param[out] de_dT   derivative of specific internal energy w.r.t. temperature
     207             :    */
     208             :   virtual void e_from_p_T(Real p, Real T, Real & e, Real & de_dp, Real & de_dT) const override;
     209             : 
     210             :   /**
     211             :    * Specific internal energy from pressure and density
     212             :    *
     213             :    * @param[in] p        pressure (Pa)
     214             :    * @param[in] rho      density (kg/m$^3$)
     215             :    * @param[out] e       specific internal energy (J/kg)
     216             :    */
     217             :   virtual Real e_from_p_rho(Real p, Real rho) const override;
     218             : 
     219             :   /**
     220             :    * Thermal expansion coefficient from pressure and temperature
     221             :    *
     222             :    * @param[in] p   pressure (Pa)
     223             :    * @param[in] T   temperature (K)
     224             :    * @return thermal expansion coefficient (1/K)
     225             :    */
     226             :   virtual Real beta_from_p_T(Real p, Real T) const override;
     227             : 
     228             :   /**
     229             :    * Isobaric specific heat capacity from pressure and temperature
     230             :    *
     231             :    * @param p   pressure (Pa)
     232             :    * @param T   temperature (K)
     233             :    * @return isobaric specific heat (J/kg/.K)
     234             :    */
     235             :   virtual Real cp_from_p_T(Real p, Real T) const override;
     236             : 
     237             :   /**
     238             :    * Isobaric specific heat capacity and its derivatives from pressure and temperature
     239             :    *
     240             :    * @param[in] p       pressure (Pa)
     241             :    * @param[in] T       temperature (K)
     242             :    * @param[out] cp     isobaric specific heat (J/kg/K)
     243             :    * @param[out] dcp_dp derivative of isobaric specific heat w.r.t. pressure (J/kg/K/Pa)
     244             :    * @param[out] dcp_dT derivative of isobaric specific heat w.r.t. temperature (J/kg/K/K)
     245             :    */
     246             :   virtual void cp_from_p_T(Real p, Real T, Real & cp, Real & dcp_dp, Real & dcp_dT) const override;
     247             : 
     248             :   /**
     249             :    * Isochoric specific heat capacity from pressure and temperature
     250             :    *
     251             :    * @param p   pressure (Pa)
     252             :    * @param T   temperature (K)
     253             :    * @return isochoric specific heat (J/kg.K)
     254             :    */
     255             :   virtual Real cv_from_p_T(Real p, Real T) const override;
     256             :   /**
     257             :    * Isochoric specific heat capacity and its derivatives from pressure and temperature
     258             :    *
     259             :    * @param[in] p       pressure (Pa)
     260             :    * @param[in] T       temperature (K)
     261             :    * @param[out] cv     isochoric specific heat (J/kg/K)
     262             :    * @param[out] dcv_dp derivative of isochoric specific heat w.r.t. pressure (J/kg/K/Pa)
     263             :    */
     264             :   virtual void cv_from_p_T(Real p, Real T, Real & cv, Real & dcv_dp, Real & dcv_dT) const override;
     265             : 
     266             :   /**
     267             :    * Thermal conductivity from pressure and temperature
     268             :    *
     269             :    * @param p   pressure (Pa)
     270             :    * @param T   temperature (K)
     271             :    * @return thermal conductivity  (W/m.K)
     272             :    */
     273             :   virtual Real k_from_p_T(Real p, Real T) const override;
     274             : 
     275             :   /**
     276             :    * Thermal conductivity and its derivatives wrt pressure and temperature
     277             :    *
     278             :    * @param p           pressure (Pa)
     279             :    * @param T           temperature (K)
     280             :    * @param[out]  k     thermal conductivity  (W/m.K)
     281             :    * @param[out]  dk_dp derivative of thermal conductivity wrt pressure
     282             :    * @param[out]  dk_dT derivative of thermal conductivity wrt temperature
     283             :    */
     284             :   virtual void k_from_p_T(Real p, Real T, Real & k, Real & dk_dp, Real & dk_dT) const override;
     285             : 
     286             :   /**
     287             :    * Dynamic viscosity from pressure and temperature
     288             :    *
     289             :    * @param p   pressure (Pa)
     290             :    * @param T   temperature (K)
     291             :    * @return dynamic viscosity (Pa.s)
     292             :    */
     293             :   virtual Real mu_from_p_T(Real p, Real T) const override;
     294             : 
     295             :   /**
     296             :    * Dynamic viscosity and its derivatives wrt pressure and temperature
     297             :    *
     298             :    * @param p             pressure (Pa)
     299             :    * @param T             temperature (K)
     300             :    * @param[out] mu       viscosity (Pa.s)
     301             :    * @param[out] dmu_dp   derivative of viscosity wrt pressure
     302             :    * @param[out] dmu_dT   derivative of viscosity wrt temperature
     303             :    */
     304             :   virtual void
     305             :   mu_from_p_T(Real p, Real T, Real & mu, Real & dmu_drho, Real & dmu_dT) const override;
     306             : 
     307             :   // Need those to avoid running the infinite loop of s_pT calling s_ve calling s_pT in SinglePhase
     308           0 :   Real s_from_p_T(Real /*p*/, Real /*T*/) const override { mooseError("Not implemented"); }
     309           0 :   void s_from_p_T(Real, Real, Real &, Real &, Real &) const override
     310             :   {
     311           0 :     mooseError("Not implemented");
     312             :   }
     313             : 
     314             :   // This is done to avoid hiding the AD implementations from the template
     315             :   // with the regular implementations defined here
     316             :   using SinglePhaseFluidProperties::beta_from_p_T;
     317             :   using SinglePhaseFluidProperties::cp_from_p_T;
     318             :   using SinglePhaseFluidProperties::cp_from_v_e;
     319             :   using SinglePhaseFluidProperties::cv_from_p_T;
     320             :   using SinglePhaseFluidProperties::cv_from_v_e;
     321             :   using SinglePhaseFluidProperties::e_from_p_rho;
     322             :   using SinglePhaseFluidProperties::e_from_p_T;
     323             :   using SinglePhaseFluidProperties::h_from_p_T;
     324             :   using SinglePhaseFluidProperties::k_from_p_T;
     325             :   using SinglePhaseFluidProperties::k_from_v_e;
     326             :   using SinglePhaseFluidProperties::mu_from_p_T;
     327             :   using SinglePhaseFluidProperties::mu_from_v_e;
     328             :   using SinglePhaseFluidProperties::p_from_v_e;
     329             :   using SinglePhaseFluidProperties::rho_from_p_T;
     330             :   using SinglePhaseFluidProperties::s_from_p_T;
     331             :   using SinglePhaseFluidProperties::T_from_p_h;
     332             :   using SinglePhaseFluidProperties::T_from_v_e;
     333             :   using SinglePhaseFluidProperties::v_from_p_T;
     334             : 
     335             : protected:
     336             :   /// Functions are constructed after fluid properties, so we delay the getting of the Function
     337             :   void initialSetup() override;
     338             : 
     339             :   /// whether the object is initialized, eg, the functions have been retrieved from the problem
     340             :   bool _initialized;
     341             : 
     342             :   /// function defining thermal conductivity as a function of temperature and pressure
     343             :   const Function * _k_function;
     344             : 
     345             :   /// function defining density as a function of temperature and pressure
     346             :   const Function * _rho_function;
     347             : 
     348             :   /// function defining dynamic viscosity as a function of temperature and pressure
     349             :   const Function * _mu_function;
     350             : 
     351             :   /// function defining specific heat as a function of temperature and pressure
     352             :   const Function * _cp_function;
     353             : 
     354             :   /// constant isochoric specific heat
     355             :   const Real _cv;
     356             :   /// whether a constant isochoric specific heat is used
     357             :   const bool _cv_is_constant;
     358             :   /// Reference specific energy
     359             :   const Real _e_ref;
     360             :   /// Reference temperature for the reference specific energy
     361             :   const Real _T_ref;
     362             :   /// Size of temperature intervals when integrating the specific heat to compute the specific energy
     363             :   const Real _integration_dT;
     364             : };

Generated by: LCOV version 1.14