Update TabulatedFluidProperties to work with Multiphase Classes
Opened this issue · 4 comments
Bug Description
Currently, TabulatedFluidProperties and TabulatedBicubicFluidProperties don't work with certain other classes which call functions like TriplePointPressure() which are implemented in other fluid properties such as Water97FluidProperties.
Noted in #27159 (reply in thread)
Steps to Reproduce
# MWE showing that PorousFlowWaterVapor does not work with TabulatedBicubicFluidProperties
# based on water_vapor_phase_change.i
[Mesh]
type = GeneratedMesh
dim = 3
xmax = 10
ymax = 10
zmax = 10
[]
[GlobalParams]
PorousFlowDictator = dictator
[]
[Variables]
[pliq]
initial_condition = 9e6
[]
[h]
scaling = 1e-3
[]
[]
[ICs]
[hic]
type = PorousFlowFluidPropertyIC
variable = h
porepressure = pliq
property = enthalpy
temperature = 300
temperature_unit = Celsius
fp = water_tab
[]
[]
[DiracKernels]
[mass]
type = ConstantPointSource
point = '5 5 5'
variable = pliq
value = -1
[]
[heat]
type = ConstantPointSource
point = '5 5 5'
variable = h
value = -1.344269e6
[]
[]
[Kernels]
[mass]
type = PorousFlowMassTimeDerivative
variable = pliq
[]
[heat]
type = PorousFlowEnergyTimeDerivative
variable = h
[]
[]
[UserObjects]
[dictator]
type = PorousFlowDictator
porous_flow_vars = 'pliq h'
number_fluid_phases = 2
number_fluid_components = 1
[]
[pc]
type = PorousFlowCapillaryPressureBC
pe = 1e5
lambda = 2
pc_max = 1e6
[]
[fs]
type = PorousFlowWaterVapor
water_fp = water_tab
capillary_pressure = pc
[]
[]
[FluidProperties]
[water]
type = Water97FluidProperties
[]
[water_tab]
type = TabulatedBicubicFluidProperties
fp = water
save_file = false
[]
[]
[Materials]
[watervapor]
type = PorousFlowFluidStateSingleComponent
porepressure = pliq
enthalpy = h
temperature_unit = Celsius
capillary_pressure = pc
fluid_state = fs
[]
[permeability]
type = PorousFlowPermeabilityConst
permeability = '1e-14 0 0 0 1e-14 0 0 0 1e-14'
[]
[relperm0]
type = PorousFlowRelativePermeabilityCorey
n = 2
phase = 0
[]
[relperm1]
type = PorousFlowRelativePermeabilityCorey
n = 3
phase = 1
[]
[porosity]
type = PorousFlowPorosityConst
porosity = 0.2
[]
[internal_energy]
type = PorousFlowMatrixInternalEnergy
density = 2650
specific_heat_capacity = 1000
[]
[]
[AuxVariables]
[temperature]
order = CONSTANT
family = MONOMIAL
[]
[]
[AuxKernels]
[temperature]
type = PorousFlowPropertyAux
variable = temperature
property = temperature
execute_on = 'initial timestep_end'
[]
[]
[Executioner]
type = Transient
solve_type = NEWTON
end_time = 1e3
nl_abs_tol = 1e-12
[TimeStepper]
type = IterationAdaptiveDT
dt = 10
[]
[]
[Preconditioning]
[smp]
type = SMP
full = true
[]
[]
[Outputs]
csv = true
perf_graph = false
[]
Which produces
*** ERROR ***
/home/moose_projects/mwe_porousflowwatervapor_tab.i:87.3:
The following error occurred in the FluidProperties 'water_tab' of type TabulatedBicubicFluidProperties.
virtual libMesh::Real SinglePhaseFluidProperties::triplePointPressure() const not implemented.
Impact
Currently this means you can't use TFP with PorousFlowWaterVapor and potentially other classes which call functions associated with multiphase behavior.
It can be useful to use TFP to save time on calculations and for convergence issues.
[Optional] Diagnostics
No response
Thanks for opening your first issue @aikubo (at least I believe it's the first) 😄
Did you want to have a go at this @aikubo?
I was just checking, and TabulatedFluidProperties
passes through some things like
Real
TabulatedFluidProperties::molarMass() const
{
if (_fp)
return _fp->molarMass();
else
mooseError("Molar Mass not specified.");
}
but not critical properties or triple point properties. Adding the equivalent methods like above like you suggested in #27159 would fix this.
So I've added the necessary functions to tabulated fluid properties based off the pointer _fp
. But I was still getting errors from the MWE above like this:
The following error occurred in the FluidProperties 'water' of type TabulatedFluidProperties.
Temperature 1.07419e+19 is outside the range of tabulated temperature (300, 500).
I traced this to the h_from_p_T
function in TabulatedFluidProperties
. Additionally, it would also output the wrong values for viscosity and density.When it does the interpolation it gets the wrong phase field (liquid instead of twophase) because the dT is 0 while dh is + at the phase change.
So I added a flag in TabulatedFluidProperties called p_h_variables
which will call the _fp->h_from_p_T
instead of interpolating. This does negate some of the useful features of using tabulated properties. You might be able to add something like construct_pT_from_ph
or modify construct_pT_from_vh
which would help speed it up.
I also wrote a test for this in /modules/porousflow/tests/test/fluidstate.
Branch is here:
https://github.com/aikubo/moose/tree/tabulatedfluidproperties_watervapor