91 lines
2.9 KiB
C++
91 lines
2.9 KiB
C++
module;
|
|
|
|
#include <stdexcept>
|
|
#include <string>
|
|
#include <utility>
|
|
|
|
export module mean_field:eos.evaluation;
|
|
export import :eos.concepts;
|
|
|
|
export namespace mean_field::eos {
|
|
enum class EvaluationErrorCode {
|
|
unsupported_relation,
|
|
unsupported_derivative,
|
|
wrong_input_count,
|
|
wrong_input_quantity,
|
|
nonfinite_input,
|
|
outside_domain,
|
|
nonfinite_result
|
|
};
|
|
|
|
class EvaluationError final : public std::domain_error {
|
|
public:
|
|
explicit EvaluationError(
|
|
const EvaluationErrorCode code,
|
|
std::string message
|
|
)
|
|
: std::domain_error(std::move(message)),
|
|
m_code(code) {
|
|
}
|
|
|
|
[[nodiscard]] EvaluationErrorCode code() const noexcept {
|
|
return m_code;
|
|
}
|
|
|
|
private:
|
|
EvaluationErrorCode m_code;
|
|
};
|
|
|
|
template <
|
|
ThermodynamicQuantityType OutputQuantity,
|
|
EquationOfStateModel EquationOfState,
|
|
QuantityValueType... InputValues>
|
|
requires SupportsRelation<
|
|
EquationOfState,
|
|
Relation<
|
|
OutputQuantity,
|
|
QuantityOfT<InputValues>...>>
|
|
[[nodiscard]] constexpr QuantityValue<OutputQuantity> evaluate(
|
|
const EquationOfState &equationOfState,
|
|
const InputValues... inputValues
|
|
) noexcept(noexcept(equationOfState
|
|
.evaluate(
|
|
Relation<
|
|
OutputQuantity,
|
|
QuantityOfT<InputValues>...>{},
|
|
inputValues...
|
|
))) {
|
|
return equationOfState.evaluate(Relation<OutputQuantity, QuantityOfT<InputValues>...>{}, inputValues...);
|
|
}
|
|
|
|
template <
|
|
ThermodynamicQuantityType OutputQuantity,
|
|
ThermodynamicQuantityType InputQuantity,
|
|
EquationOfStateModel EquationOfState,
|
|
QuantityValueType... InputValues>
|
|
requires SupportsPartialDerivative<
|
|
EquationOfState,
|
|
Relation<
|
|
OutputQuantity,
|
|
QuantityOfT<InputValues>...>,
|
|
InputQuantity>
|
|
[[nodiscard]] constexpr PartialDerivative<
|
|
OutputQuantity,
|
|
InputQuantity>
|
|
partialDerivative(
|
|
const EquationOfState &equationOfState,
|
|
const InputValues... inputValues
|
|
) noexcept(noexcept(equationOfState
|
|
.partialDerivative(
|
|
Relation<
|
|
OutputQuantity,
|
|
QuantityOfT<InputValues>...>{},
|
|
WithRespectTo<InputQuantity>{},
|
|
inputValues...
|
|
))) {
|
|
return equationOfState.partialDerivative(
|
|
Relation<OutputQuantity, QuantityOfT<InputValues>...>{}, WithRespectTo<InputQuantity>{}, inputValues...
|
|
);
|
|
}
|
|
} // namespace mean_field::eos
|