Skip to content

Commit

Permalink
Merge pull request #28620 from joshuahansel/solid-properties-e
Browse files Browse the repository at this point in the history
Added specific internal energy to ThermalSolidProperties
  • Loading branch information
joshuahansel authored Sep 19, 2024
2 parents 24b6b12 + 0cbce33 commit 8543df8
Show file tree
Hide file tree
Showing 33 changed files with 450 additions and 86 deletions.
7 changes: 7 additions & 0 deletions modules/doc/content/newsletter/2024/2024_09.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ for a complete description of all MOOSE changes.

## MOOSE Improvements

### Specific internal energy added to Solid Properties objects

The [ThermalSolidProperties.md] objects from the [Solid properties module](modules/solid_properties/index.md)
now provide interfaces to compute the specific internal energy as a function of
temperature. This new interface is useful, for example, in measuring the
internal energy in solids for energy conservation verification.

## libMesh-level Changes

## PETSc-level Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,19 @@ Userobjects available in the Solid Properties module that provide thermal proper
An example will be provided later on this page for creating a new solid userobject.

On their own, these userobjects do not execute; their functions must be called from other
objects. The most common use case is to compute material properties with these
userobjects, which can be accomplished with
[ThermalSolidPropertiesMaterial](/materials/ThermalSolidPropertiesMaterial.md);
its `computeQpProperties` method evaluates the thermal conductivity, isobaric specific heat, and density at
the quadrature points using the values of a coupled variable representing temperature
plus the functions provided by the selected userobject:

!listing modules/solid_properties/src/materials/ThermalSolidPropertiesMaterial.C start=computeQpProperties

Another use case is to get a single property into a post-processor,
which is accomplished with [ThermalSolidPropertiesPostprocessor.md].
objects. Some potentially useful classes that call them are:

- [ThermalSolidPropertiesFunctorMaterial.md]: A functor material that declares
functor material properties for density, thermal conductivity, isobaric specific heat,
and specific internal energy. An option is provided for using a constant density.
This functor material can have its functor material properties converted to
regular AD or non-AD material properties by using it in conjunction with
[(AD)MaterialFunctorConverter](MaterialFunctorConverter.md).
- [ThermalSolidPropertiesMaterial.md] and [ConstantDensityThermalSolidPropertiesMaterial.md],
which declare AD or non-AD material properties for density, thermal conductivity, and isobaric specific heat,
using variable density and constant density, respectively.
- [ThermalSolidPropertiesPostprocessor.md] evaluates density, thermal conductivity,
or isobaric specific heat at a single temperature value.

## Usage

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@

## Description

The `ThermalSolidPropertiesFunctorMaterial` material declares
density, specific heat, and thermal
conductivity as functor material properties. They are evaluated on-the-fly
on every query.
`ThermalSolidPropertiesFunctorMaterial` declares functor material properties for
density, specific heat, and thermal conductivity, and specific internal energy.

!alert warning title=Conservation on fixed-sized domains
Using a variable density can lead to mass/energy conservation errors if using
a fixed-size domain. If this is a concern, it is recommended to use
a constant density, specified independently using a [GenericFunctorMaterial.md] for example.
For the density parameter of `ThermalSolidPropertiesFunctorMaterial` you may then use a
placeholder dummy name.
The parameter [!param](/FunctorMaterials/ThermalSolidPropertiesFunctorMaterial/use_constant_density)
can be used to specify that the density should be constant, evaluated at the temperature
[!param](/FunctorMaterials/ThermalSolidPropertiesFunctorMaterial/T_ref). This is
useful because for fixed-sized domains, mass/energy conservation errors result
from using a variable density.

!syntax parameters /FunctorMaterials/ThermalSolidPropertiesFunctorMaterial

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,68 @@

This is the base class for providing thermal solid properties
as a function of temperature.
This class defines functions to compute the following thermal properties
as a function of temperature:
This class defines functions to compute the following thermal properties,
which are all assumed to be functions of temperature only:

- compute isobaric specific heat - `Real cp_from_T(const Real & T)`
- compute thermal conductivity - `Real k_from_T(const Real & T)`
- compute density - `Real rho_from_T(const Real & T)`
- `cp`: isobaric specific heat, $c_p$
- `e`: specific internal energy, $e$
- `k`: thermal conductivity, $k$
- `rho`: density, $\rho$

Functions to compute derivatives of these properties as a function of temperature
are also available:
For each of these, the following methods are available, where `y` should be
replaced by the respective property name given in the list above:

- compute isobaric specific heat and its temperature derivative - `void cp_from_T(const Real & T, Real & cp, Real & dcp_dT)`
- compute thermal conductivity and its temperature derivative - `void k_from_T(const Real & T, Real & k, Real & dk_dT)`
- compute density and its temperature derivative - `void rho_from_T(const Real & T, Real & rho, Real & drho_dT)`
```
Real y_from_T(const Real & T) const
```

To create a new userobject providing thermal properties, derive from this
userobject and specify implementations of the above functions.
provides the value $y(T)$ using a `Real` input value for $T$.

```
void y_from_T(const Real & T, Real & y, Real & dy_dT) const
```

provides the value $y(T)$ and its derivative $y'(T)$ using a `Real` input value for $T$.

```
ADReal y_from_T(const ADReal & T) const
```

provides the value $y(T)$ and its derivative $y'(T)$ using an `ADReal` input value for $T$.

Thus both AD and non-AD interfaces are available. Derived classes are only responsible
for overriding the non-AD interfaces for each property. The AD interfaces are
implemented by default by combining the two non-AD interfaces.

Note that the `e_from_T` interfaces should not be overridden because they have
generic implementations, and the non-AD interfaces are not even virtual.
Instead, derived classes must override the following:

```
Real cp_integral(const Real & T) const
```

which corresponds to the indefinite integral $C(T)$ of $c_p(T)$, minus the
constant of integration:

!equation
C(T) = \int c_p(T) dT \,.

Due to the definition of the isobaric specific heat capacity,

!equation
c_p \equiv \left.\frac{\partial e}{\partial T}\right|_v \,,

the specific internal energy can be expressed as

!equation
e(T) - e(T_0) = \int\limits_{T_0}^T c_p(T') dT' = C(T) - C(T_0) \,,

where $T_0$ is the temperature at which the specific internal energy is assumed
to be zero. This is a convention supplied by the user using the parameter
[!param](/SolidProperties/ThermalSS316Properties/T_zero_e). By default, this
is taken to be at standard temperature, 273.15 K. Note that this is important
for comparing specific internal energy values to external sources, which may
be based on different reference temperatures.

!bibtex bibliography
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ namespace SolidPropertiesNames
static const std::string thermal_conductivity = "thermal_conductivity";
static const std::string density = "density";
static const std::string specific_heat = "specific_heat";
static const std::string specific_internal_energy = "specific_internal_energy";
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,21 @@ class ThermalCompositeSiCProperties : public ThermalSolidProperties

virtual void cp_from_T(const Real & T, Real & cp, Real & dcp_dT) const override;

virtual Real cp_integral(const Real & T) const override;

virtual Real rho_from_T(const Real & T) const override;

virtual void rho_from_T(const Real & T, Real & rho, Real & drho_dT) const override;

protected:
/// (constant) density
const Real & _rho_const;

// Constants used in specific heat relation
const Real _c1;
const Real _c2;
const Real _c3;
const Real _c4;
};

#pragma GCC diagnostic pop
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class ThermalGraphiteProperties : public ThermalSolidProperties

virtual void cp_from_T(const Real & T, Real & cp, Real & dcp_dT) const override;

virtual Real cp_integral(const Real & T) const override;

virtual Real rho_from_T(const Real & T) const override;

virtual void rho_from_T(const Real & T, Real & rho, Real & drho_dT) const override;
Expand All @@ -45,6 +47,15 @@ class ThermalGraphiteProperties : public ThermalSolidProperties

/// constant density
const Real & _rho_const;

// Constants used in specific heat relation
const Real _c1;
const Real _c2;
const Real _c3;
const Real _c4;
const Real _c5;
const Real _c6;
const Real _c7;
};

#pragma GCC diagnostic pop
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class ThermalMonolithicSiCProperties : public ThermalSolidProperties

virtual void cp_from_T(const Real & T, Real & cp, Real & dcp_dT) const override;

virtual Real cp_integral(const Real & T) const override;

virtual Real rho_from_T(const Real & T) const override;

virtual void rho_from_T(const Real & T, Real & rho, Real & drho_dT) const override;
Expand All @@ -46,6 +48,12 @@ class ThermalMonolithicSiCProperties : public ThermalSolidProperties

/// (constant) density
const Real & _rho_const;

// Constants used in specific heat relation
const Real _c1;
const Real _c2;
const Real _c3;
const Real _c4;
};

#pragma GCC diagnostic pop
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,16 @@ class ThermalSS316Properties : public ThermalSolidProperties

virtual void cp_from_T(const Real & T, Real & cp, Real & dcp_dT) const override;

virtual Real cp_integral(const Real & T) const override;

virtual Real rho_from_T(const Real & T) const override;

virtual void rho_from_T(const Real & T, Real & rho, Real & drho_dT) const override;

protected:
// Constants used in specific heat relation
const Real _c1;
const Real _c2;
};

#pragma GCC diagnostic pop
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,31 @@

#include "SolidProperties.h"

/**
* Adds default error implementation for non-AD value, which should be overridden in child classes
*/
#define propfuncNonADValueOnly(want) \
virtual Real want##_from_T(const Real &) const \
{ \
mooseError(__PRETTY_FUNCTION__, " not implemented."); \
}

/**
* Adds default error implementation for non-AD value and derivatives, which should be overridden
* in child classes
*/
#define propfuncNonADDerivatives(want) \
virtual void want##_from_T(const Real & T, Real & val, Real & d##want##dT) const \
{ \
solidPropError(__PRETTY_FUNCTION__, " derivatives not implemented."); \
d##want##dT = 0; \
val = want##_from_T(T); \
}

/**
* Adds AD versions of each solid property. These functions use the Real versions of these methods
* to compute the AD variables complete with derivatives. Typically, these do not need to be
* overriden in derived classes.
* overridden in derived classes.
*/
#define propfuncAD(want) \
virtual ADReal want##_from_T(const ADReal & T) const \
Expand All @@ -27,26 +48,13 @@
ADReal result = x; \
result.derivatives() = T.derivatives() * dxdT; \
return result; \
} \
\
/** \
* Adds function definitions with not implemented error. These functions should be overriden in \
* derived classes where required. AD versions are constructed automatically using propfuncAD. \
}

/**
* Adds function definitions with not implemented error. These functions should be overridden in
* derived classes where required. AD versions are constructed automatically using propfuncAD.
*/
#define propfunc(want) \
virtual Real want##_from_T(const Real &) const \
{ \
mooseError(__PRETTY_FUNCTION__, " not implemented."); \
} \
\
virtual void want##_from_T(const Real & T, Real & val, Real & d##want##dT) const \
{ \
solidPropError(__PRETTY_FUNCTION__, " derivatives not implemented."); \
d##want##dT = 0; \
val = want##_from_T(T); \
} \
\
propfuncAD(want)
#define propfunc(want) propfuncNonADValueOnly(want) propfuncNonADDerivatives(want) propfuncAD(want)

/**
* Common class for solid properties that are a function of temperature
Expand Down Expand Up @@ -84,6 +92,24 @@ class ThermalSolidProperties : public SolidProperties
propfunc(k)
propfunc(cp)
propfunc(rho)

/**
* Computes the integral of isobaric specific heat capacity w.r.t. temperature,
* from the zero-e reference temperature, provided by a user parameter.
*
* Note that the constant of integration is not included. This function is
* called in the \c e_from_T(T) method.
*/
virtual Real cp_integral(const Real & /*T*/) const
{
mooseError(__PRETTY_FUNCTION__, " not implemented.");
}

// Specific internal energy methods; these designed to not be virtual; only
// cp_integral(T) needs to be implemented.
Real e_from_T(const Real & T) const;
void e_from_T(const Real & T, Real & val, Real & dedT) const;
propfuncAD(e)
///@}

// clang-format on
Expand All @@ -101,6 +127,10 @@ class ThermalSolidProperties : public SolidProperties
else
mooseError(std::forward<Args>(args)...);
}

protected:
/// Temperature at which the specific internal energy is assumed to be zero
const Real _T_zero_e;
};

#pragma GCC diagnostic pop
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,20 @@ class ThermalUCProperties : public ThermalSolidProperties
virtual Real cp_from_T(const Real & T) const override;
virtual void cp_from_T(const Real & T, Real & cp, Real & dcp_dT) const override;

using ThermalSolidProperties::cp_integral;
virtual Real cp_integral(const Real & T) const override;

using ThermalSolidProperties::rho_from_T;
virtual Real rho_from_T(const Real & T) const override;
virtual void rho_from_T(const Real & T, Real & rho, Real & drho_dT) const override;

protected:
/// (constant) density
const Real & _rho_const;

// Constants used in specific heat relation
const Real _c1;
const Real _c2;
const Real _c3;
const Real _c4;
};
Loading

0 comments on commit 8543df8

Please sign in to comment.