ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
mixture.hpp
1// This file is part of the ACTS project.
2//
3// Copyright (C) 2016 CERN for the benefit of the ACTS project
4//
5// This Source Code Form is subject to the terms of the Mozilla Public
6// License, v. 2.0. If a copy of the MPL was not distributed with this
7// file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
9#pragma once
10
11// Detray include(s)
12#include "detray/definitions/algebra.hpp"
13#include "detray/material/material.hpp"
14#include "detray/utils/ratio.hpp"
15
16// System include(s)
17#include <tuple>
18
19namespace detray {
20
23template <concepts::scalar scalar_t, typename... material_types>
24struct mixture
25 : public material<scalar_t, typename ratio_sum<
26 typename material_types::ratio...>::ratio> {
27 public:
29 using ratio = typename ratio_sum<typename material_types::ratio...>::ratio;
30
31 static_assert(is_ratio_one_v<ratio>,
32 "Sumation of ratios should be equal to 1");
33
35 constexpr mixture() {
36 // Compute effective relative atomic mass
37 // Zeff = Ar0 * ratio0 + Ar1 * ratio1 + ...
38 auto sum_Ar = [](material_types... M) constexpr -> decltype(auto) {
39 return ((M.Ar() * M.fraction()) + ...);
40 };
41
42 this->set_Ar(std::apply(sum_Ar, std::tuple<material_types...>()));
43
44 // Compute effective atomic number
45 // Zeff = Z0 * ratio0 + Z1 * ratio1 + ...
46 auto sum_Z = [](material_types... M) constexpr -> decltype(auto) {
47 return ((M.Z() * M.fraction()) + ...);
48 };
49
50 this->set_Z(std::apply(sum_Z, std::tuple<material_types...>()));
51
52 // Get averaged mass density
53 auto sum_rho = [](material_types... M) constexpr -> decltype(auto) {
54 return ((M.mass_density() * M.fraction()) + ...);
55 };
56
57 this->set_mass_density(
58 std::apply(sum_rho, std::tuple<material_types...>()));
59
60 // Compute effective radiation length (X0)
61 // reference:
62 // https://cds.cern.ch/record/1279627/files/PH-EP-Tech-Note-2010-013.pdf
63 // X_avg = W_avg / Sum_i[ W_i / X_i ],
64 // where:
65 // W_i is mass density of i_th component
66 // W_avg is the averaged mass density
67 auto sum_rho_over_X0 = [](material_types... M) constexpr -> decltype(auto) {
68 return ((M.fraction() / M.X0()) + ...);
69 };
70 this->set_X0(1.f /
71 std::apply(sum_rho_over_X0, std::tuple<material_types...>()));
72
73 // Compute effective nuclear radiation length
74 // Follow the same equation of effective X0
75 auto sum_rho_over_L0 = [](material_types... M) constexpr -> decltype(auto) {
76 return ((M.fraction() / M.L0()) + ...);
77 };
78
79 this->set_L0(1.f /
80 std::apply(sum_rho_over_L0, std::tuple<material_types...>()));
81
82 // Compute molar density
84 this->mass_to_molar_density(this->Ar(), this->mass_density()));
85
86 // @TODO: Calculate density effect data as well if exist?
87 }
88};
89
90} // namespace detray
Scalar concept: Elements of vectors/matrices (can be simd vectors).
Definition concepts.hpp:40
Detray include(s).
Definition array_operators.hpp:18
constexpr bool is_ratio_one_v
True when the supplied ratio is exactly one.
Definition ratio.hpp:63
constexpr void set_Ar(scalar_type ar)
Definition material.hpp:238
constexpr void set_Z(scalar_type z)
Definition material.hpp:242
constexpr scalar_type mass_density() const
Definition material.hpp:130
constexpr void set_molar_density(scalar_type molar_rho)
Definition material.hpp:252
constexpr scalar_type mass_to_molar_density(double ar, double mass_rho)
Definition material.hpp:260
constexpr scalar_type Ar() const
Definition material.hpp:124
constexpr void set_mass_density(scalar_type mass_rho)
Definition material.hpp:246
constexpr void set_L0(scalar_type l0)
Definition material.hpp:234
constexpr void set_X0(scalar_type x0)
Definition material.hpp:230
typename ratio_sum< typename material_types::ratio... >::ratio ratio
Ratio type used for material-component fractions.
Definition mixture.hpp:29
constexpr mixture()
Constructor.
Definition mixture.hpp:35
Struct to sum over variadic std::ratio.
Definition ratio.hpp:47