-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch default gas constant approach to mole-fraction-weighted
Can be over-written to CODATA by setting flags ={"Rmodel": "CODATA"} Closes #26
- Loading branch information
Showing
3 changed files
with
102 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
|
||
#include "teqp/constants.hpp" | ||
|
||
namespace teqp{ | ||
namespace multifluid{ | ||
namespace gasconstant{ | ||
|
||
class MoleFractionWeighted { | ||
const std::vector<double> Rvals; | ||
public: | ||
|
||
MoleFractionWeighted(const std::vector<double>& Rvals) : Rvals(Rvals) {}; | ||
|
||
template<typename MoleFractions> | ||
auto get_R(const MoleFractions& molefracs) const { | ||
using resulttype = std::common_type_t<decltype(molefracs[0])>; // Type promotion, without the const-ness | ||
resulttype out = 0.0; | ||
auto N = molefracs.size(); | ||
for (auto i = 0; i < N; ++i) { | ||
out += molefracs[i] * Rvals[i]; | ||
} | ||
return forceeval(out); | ||
} | ||
}; | ||
|
||
class CODATA{ | ||
public: | ||
template<typename MoleFractions> | ||
auto get_R(const MoleFractions& molefracs) const { | ||
return get_R_gas<decltype(molefracs[0])>(); | ||
} | ||
}; | ||
|
||
using GasConstantCalculator = std::variant<MoleFractionWeighted, CODATA>; | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters