File indexing completed on 2026-05-27 07:23:59
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011
0012 #include "detray/definitions/algebra.hpp"
0013 #include "detray/material/material.hpp"
0014 #include "detray/utils/ratio.hpp"
0015
0016
0017 #include <tuple>
0018
0019 namespace detray {
0020
0021
0022
0023 template <concepts::scalar scalar_t, typename... material_types>
0024 struct mixture
0025 : public material<scalar_t, typename ratio_sum<
0026 typename material_types::ratio...>::ratio> {
0027 public:
0028 using ratio = typename ratio_sum<typename material_types::ratio...>::ratio;
0029
0030 static_assert(is_ratio_one_v<ratio>,
0031 "Sumation of ratios should be equal to 1");
0032
0033
0034 constexpr mixture() {
0035
0036
0037 auto sum_Ar = [](material_types... M) constexpr -> decltype(auto) {
0038 return ((M.Ar() * M.fraction()) + ...);
0039 };
0040
0041 this->set_Ar(std::apply(sum_Ar, std::tuple<material_types...>()));
0042
0043
0044
0045 auto sum_Z = [](material_types... M) constexpr -> decltype(auto) {
0046 return ((M.Z() * M.fraction()) + ...);
0047 };
0048
0049 this->set_Z(std::apply(sum_Z, std::tuple<material_types...>()));
0050
0051
0052 auto sum_rho = [](material_types... M) constexpr -> decltype(auto) {
0053 return ((M.mass_density() * M.fraction()) + ...);
0054 };
0055
0056 this->set_mass_density(
0057 std::apply(sum_rho, std::tuple<material_types...>()));
0058
0059
0060
0061
0062
0063
0064
0065
0066 auto sum_rho_over_X0 = [](material_types... M) constexpr -> decltype(auto) {
0067 return ((M.fraction() / M.X0()) + ...);
0068 };
0069 this->set_X0(1.f /
0070 std::apply(sum_rho_over_X0, std::tuple<material_types...>()));
0071
0072
0073
0074 auto sum_rho_over_L0 = [](material_types... M) constexpr -> decltype(auto) {
0075 return ((M.fraction() / M.L0()) + ...);
0076 };
0077
0078 this->set_L0(1.f /
0079 std::apply(sum_rho_over_L0, std::tuple<material_types...>()));
0080
0081
0082 this->set_molar_density(
0083 this->mass_to_molar_density(this->Ar(), this->mass_density()));
0084
0085
0086 }
0087 };
0088
0089 }