-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathradioactivity.cpp
44 lines (38 loc) · 1.06 KB
/
radioactivity.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <benri/si/si.h>
#include <iostream>
enum class radiation_type
{
alpha,
beta,
protons,
};
auto weighting_factor(radiation_type radiation)
{
using namespace benri::si;
switch (radiation)
{
case radiation_type::alpha:
return 1_sievert_per_gray;
case radiation_type::beta:
return 20_sievert_per_gray;
case radiation_type::protons:
return 2_sievert_per_gray;
}
}
template <class T>
auto equivalent_dose(benri::quantity<benri::si::gray_t, T> absorbed_dose,
radiation_type radiation)
{
using namespace benri::casts;
return absorbed_dose * simple_cast<T>(weighting_factor(radiation));
}
int main()
{
using namespace benri::si;
// calculate dose
auto dose = equivalent_dose(10_gray, radiation_type::alpha);
std::wcout << "You received " << dose.value() << "Sv of alpha radiation.\n"
<< ((dose > 20_sievert) ? "You will die." : "You are probably fine.")
<< '\n'
<< std::flush;
}