Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding helium fluid properties #26

Merged
merged 4 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ if(DOXYGEN_FOUND)
air_err_u.png
air_err_w.png
)
file(GLOB_RECURSE RST_FILES ${PROJECT_SOURCE_DIR}/docs/*.rst)
set(HE_ERR_IMGS
he_err_c_p.png
he_err_c_v.png
he_err_h.png
he_err_k.png
he_err_mu.png
he_err_rho.png
he_err_s.png
he_err_u.png
he_err_w.png
)

add_custom_command(
OUTPUT
Expand All @@ -46,6 +58,7 @@ if(DOXYGEN_FOUND)
${RST_FILES}
${N2_ERR_IMGS}
${AIR_ERR_IMGS}
${HE_ERR_IMGS}
)

add_custom_command(
Expand Down Expand Up @@ -84,6 +97,19 @@ if(DOXYGEN_FOUND)
${PROJECT_SOURCE_DIR}/docs/pyplots/air.yml
)

add_custom_command(
OUTPUT
${HE_ERR_IMGS}
COMMAND
${CMAKE_COMMAND} -E env "PYTHONPATH=${PROJECT_BINARY_DIR}/python/src:$ENV{PYTHONPATH}"
python3 plot_err.py he.yml
WORKING_DIRECTORY
${PROJECT_SOURCE_DIR}/docs/pyplots
DEPENDS
${PROJECT_SOURCE_DIR}/docs/pyplots/plot_err.py
${PROJECT_SOURCE_DIR}/docs/pyplots/he.yml
)

add_custom_command(
TARGET doc
POST_BUILD
Expand Down
5 changes: 5 additions & 0 deletions docs/classes/helium.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Helium
======

.. doxygenclass:: fprops::Helium
:members:
3 changes: 3 additions & 0 deletions docs/classes/helmholtz.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Models
.. doxygenclass:: fprops::Helmholtz::IdealGasPower
:members:

.. doxygenclass:: fprops::Helmholtz::IdealEnthalpyEntropyOffset
:members:

.. doxygenclass:: fprops::Helmholtz::IdealPlanckEinsteinGeneralized
:members:

Expand Down
32 changes: 32 additions & 0 deletions docs/fluids/helium.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Helium
======

Range of validity:

- Temperature: `0.8 - 1500 K`
- Pressure: to `2000 MPa`

Computation of thermodynamic properties is based on :cite:t:`oritzvega2019`.
Viscosity is based on :cite:t:`arp1989thermophysical`,
thermal conductivity is based on :cite:t:`HANDS1981697`.

Verification against CoolProp package
-------------------------------------

.. image:: ../pyplots/he_err_rho.png

.. image:: ../pyplots/he_err_u.png

.. image:: ../pyplots/he_err_h.png

.. image:: ../pyplots/he_err_s.png

.. image:: ../pyplots/he_err_w.png

.. image:: ../pyplots/he_err_c_p.png

.. image:: ../pyplots/he_err_c_v.png

.. image:: ../pyplots/he_err_mu.png

.. image:: ../pyplots/he_err_k.png
18 changes: 18 additions & 0 deletions docs/pyplots/he.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
fprops:
name: he
coolprop: Helium
fprops: Helium
p: [
0.1, 0.2,
0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4,
5, 6, 8,
10, 15, 20, 25,
50, 75, 100,
200, 400, 600, 800, 1000
]
T: [
60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150,
160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350,
400, 450, 500, 550,
600, 700, 800, 900, 1000
]
27 changes: 27 additions & 0 deletions docs/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,30 @@ @article{lemmon2004viscosity
year={2004},
publisher={Springer}
}

@unpublished{oritzvega2019,
author={D. O. Ortiz-Vega and K. R. Hall and J. C. Holste and V. D. Arp and A. H. Harvey and E. W. Lemmon},
title={Equation of state for Helium-4},
note={Coefficients from REPROP 10},
year={2019}
}

@article{HANDS1981697,
title = {A correlation of thermal conductivity data for helium},
journal = {Cryogenics},
volume = {21},
number = {12},
pages = {697-703},
year = {1981},
issn = {0011-2275},
doi = {https://doi.org/10.1016/0011-2275(81)90211-3},
author = {B.A. Hands and V.D. Arp},
abstract = {A correlation for the thermal conductivity of helium has been developed which covers the temperature range from temperatures just above the lambda line to 830 K, and densities up to about 160 kg m−3. The data used incorporate some recent experimental results which cover the temperature range from 4 K to 20 K including the critical region. The correlation gives an equation which generally fits the experimental data within ± 5%. However, at low temperature, the experimental data deviate up to about 10% from predictions based upon viscosity measurements or molecular dynamics calculations.}
}

@techreport{arp1989thermophysical,
title={Thermophysical Properties of Helium-4 from 0.8 to 1500 K with Pressures to 2000 MPa},
author={Arp, Vincent D and McCarty, Robert D},
year={1989},
institution={}
}
42 changes: 42 additions & 0 deletions include/Helium.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#pragma once

#include "Helmholtz.h"
#include "TransportModels.h"

namespace fprops {

/// Helium (He) fluid properties
///
/// References:
/// 1. D. O. Ortiz-Vega, K. R. Hall, J. C. Holste, V. D. Arp, A. H. Harvey, and E. W. Lemmon.
/// Equation of state for Helium-4. Unpublished.
/// 2. B.A. Hands and V.D. Arp. A Correlation of Thermal Conductivity Data for Helium. Cryogenics,
/// 21(12):697–703, 1981. doi:10.1016/0011-2275(81)90211-3.
/// 3. V.D. Arp, R.D. McCarty, and D.G Friend. Thermophysical Properties of Helium-4 from 0.8 to
/// 1500 K with Pressures to 2000 MPa - NIST Technical Note 1334 (revised). Technical Report,
/// NIST, 1998.
class Helium : public Helmholtz {
public:
Helium();

protected:
[[nodiscard]] double alpha(double delta, double tau) const override;
[[nodiscard]] double dalpha_ddelta(double delta, double tau) const override;
[[nodiscard]] double dalpha_dtau(double delta, double tau) const override;
[[nodiscard]] double d2alpha_ddelta2(double delta, double tau) const override;
[[nodiscard]] double d2alpha_dtau2(double delta, double tau) const override;
[[nodiscard]] double d2alpha_ddeltatau(double delta, double tau) const override;

[[nodiscard]] double mu_from_rho_T(double rho, double T) const override;
[[nodiscard]] double k_from_rho_T(double rho, double T) const override;

private:
IdealGasLead<double> lead;
IdealGasLogTau<double> log_tau;
IdealEnthalpyEntropyOffset<double> offset;
ResidualPower<double> power_r;
ResidualPowerExp<double, unsigned int> power_exp_r;
ResidualGaussian<double> gauss;
};

} // namespace fprops
27 changes: 27 additions & 0 deletions include/Helmholtz.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,33 @@ class Helmholtz : public SinglePhaseFluidProperties {
std::vector<T> t;
};

/// Offset for enthalpy and entropy
///
/// @tparam T The basic data type
///
/// \f$\alpha = a_1 + a_2 \tau\f$
template <typename T>
class IdealEnthalpyEntropyOffset {
public:
IdealEnthalpyEntropyOffset(double a1, double a2) : a1(a1), a2(a2) {}

T
alpha(T delta, T tau) const
{
return this->a1 + this->a2 * tau;
}

T
dtau(T delta, T tau) const
{
return this->a2;
}

private:
double a1;
double a2;
};

/// Generalized Planck-Einstein model
///
/// @tparam T The basic data type
Expand Down
6 changes: 6 additions & 0 deletions python/src/fprops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "Air.h"
#include "IdealGas.h"
#include "Nitrogen.h"
#include "Helium.h"

using namespace fprops;

Expand Down Expand Up @@ -44,4 +45,9 @@ PYBIND11_MODULE(pyfprops, m)
.def(py::init())
.def("p_T", &Nitrogen::p_T)
.def("v_u", &Nitrogen::v_u);

py::class_<Helium>(m, "Helium")
.def(py::init())
.def("p_T", &Nitrogen::p_T)
.def("v_u", &Nitrogen::v_u);
}
1 change: 1 addition & 0 deletions python/src/pyfprops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

__all__ = [
Air,
Helium,
IdealGas,
Nitrogen
]
10 changes: 10 additions & 0 deletions python/tests/test_helium.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import pyfprops as fp
import pytest
import math

def test_he_valid():
n2 = fp.Helium()
state = n2.p_T(1e6, 280)
assert state.p == 1e6
assert state.T == 280
assert math.isclose(state.rho, 1.7109055009783694, abs_tol=1e-14)
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ add_library(
SHARED
Air.cpp
FluidProperties.cpp
Helium.cpp
Helmholtz.cpp
IdealGas.cpp
Nitrogen.cpp
Expand Down
Loading