Skip to content

Commit

Permalink
Merge pull request #73 from andrsd/tr-model-pow-of-tr
Browse files Browse the repository at this point in the history
Transport model: Powers of T reduced
  • Loading branch information
andrsd authored Aug 9, 2024
2 parents df74e03 + 3b1686b commit 3136240
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
45 changes: 45 additions & 0 deletions include/fprops/transport_models.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,49 @@ class ModifiedBatshinskiHildebrand {
std::vector<double> l;
};

/// Powers of T reduced
///
/// @tparam T The basic data type
///
/// \f$ v = \displaystyle\sum_{i=0}^{n} a_i T_{r}^{t_i}\f$
template <typename TYPE>
class PowersOfTreduced {
public:
///
///
/// @param T_critical Critical temperature [K]
/// @param a Array of \f$a_i\f$ coefficients
/// @param t Array of \f$t_i\f$ exponents
PowersOfTreduced(double T_critical,
const std::vector<double> & a,
const std::vector<double> & t) :
T_crit(T_critical),
a(a),
t(t)
{
}

/// Evaluate the model
///
/// @param T Temperature
/// @return Computed value
TYPE
value(TYPE T) const
{
TYPE Tr = T / this->T_crit;
TYPE sum = 0;
for (std::size_t i = 0; i < a.size(); ++i)
sum += this->a[i] * math::pow(Tr, this->t[i]);
return sum;
}

private:
/// Critical temperature [K]
double T_crit;
/// a_i coefficients
std::vector<double> a;
/// t_i exponents
std::vector<double> t;
};

} // namespace fprops
6 changes: 6 additions & 0 deletions test/src/transport_models_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@ TEST(TransportTest, modified_batshinski_hildebrand)
ModifiedBatshinskiHildebrand<double> mbh({ 2, 3 }, { 3, 4 }, { 4, 5 }, { 4, 3 }, { 2, 3 });
EXPECT_DOUBLE_EQ(mbh.value(2., 3.), 0.000097523945419603);
}

TEST(TransportTest, powers_of_T_reduced)
{
PowersOfTreduced<double> potr(300, { 3. }, { 5. });
EXPECT_DOUBLE_EQ(potr.value(600), 96.);
}

0 comments on commit 3136240

Please sign in to comment.