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

Transport model: Powers of T reduced #73

Merged
merged 1 commit into from
Aug 9, 2024
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
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.);
}
Loading