forked from Merveille94/Radiation-Dose_Calculator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
132 lines (110 loc) · 4.7 KB
/
main.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
using namespace std;
// NRC standards for radiation dose limits (as of January 2022)
const double NRC_OCCUPATIONAL_LIMIT = 50; // Occupational dose limit in millisieverts (mSv) per year
const double NRC_ENVIRONMENTAL_LIMIT = 1; // Environmental dose limit in millisieverts (mSv) per year
// Factors for different radiation types
const double ALPHA_FACTOR = 1.5; // Factor for alpha radiation dose calculation
const double BETA_FACTOR = 1.2; // Factor for beta radiation dose calculation
const double GAMMA_FACTOR = 1.0; // Factor for gamma radiation dose calculation
const double NEUTRON_FACTOR = 2.0; // Factor for neutron radiation dose calculation
// Function to calculate radiation dose based on input parameters
double calculateDose(double exposureTime, double distance, double shieldingThickness, string radiationType, int exposureType) {
// Adjusted dose based on distance and shielding
double adjustedDose = exposureTime * distance / (shieldingThickness + 1);
// Adjust dose based on radiation type
double radiationFactor = 1.0;
if (radiationType == "alpha") {
radiationFactor = ALPHA_FACTOR;
} else if (radiationType == "beta") {
radiationFactor = BETA_FACTOR;
} else if (radiationType == "gamma") {
radiationFactor = GAMMA_FACTOR;
} else if (radiationType == "neutron") {
radiationFactor = NEUTRON_FACTOR;
}
// Calculate final dose based on exposure type (occupational or environmental)
double dose;
if (exposureType == 1) {
// Occupational exposure
dose = adjustedDose * radiationFactor;
} else {
// Environmental exposure
dose = adjustedDose / radiationFactor;
}
return dose;
}
// Function to classify dose based on NRC standards
string classifyDose(double dose, int exposureType) {
double limit;
if (exposureType == 1) {
// Occupational exposure limit
limit = NRC_OCCUPATIONAL_LIMIT;
} else {
// Environmental exposure limit
limit = NRC_ENVIRONMENTAL_LIMIT;
}
if (dose > limit) {
return "Dangerous";
} else {
return "Safe";
}
}
// Function to display the NRC standards table
void displayNRCTable() {
cout << "NRC Standards for Radiation Dose Limits (as of January 2022):" << endl;
cout << "---------------------------------------------------------" << endl;
cout << "Occupational Limit: " << NRC_OCCUPATIONAL_LIMIT << " mSv/year" << endl;
cout << "Environmental Limit: " << NRC_ENVIRONMENTAL_LIMIT << " mSv/year" << endl;
cout << "---------------------------------------------------------" << endl;
}
int main() {
// Display NRC standards table
displayNRCTable();
// Input parameters
double exposureTime, distance, shieldingThickness;
string radiationType;
int exposureType;
// Prompt user for input
cout << "Enter exposure time (hours): ";
cin >> exposureTime;
cout << "Enter distance from radiation source (meters): ";
cin >> distance;
cout << "Enter shielding thickness (centimeters): ";
cin >> shieldingThickness;
cout << "Enter radiation type (alpha, beta, gamma, neutron): ";
cin >> radiationType;
cout << "Enter exposure type (1 for occupational, 2 for environmental): ";
cin >> exposureType;
// Calculate dose
double dose = calculateDose(exposureTime, distance, shieldingThickness, radiationType, exposureType);
// Classify dose based on exposure type
string doseClassification = classifyDose(dose, exposureType);
// Display results
cout << "\nCalculated dose: " << dose << " mSv" << endl;
cout << "Dose classification: " << doseClassification << " for ";
if (exposureType == 1) {
cout << "occupational exposure" << endl;
} else {
cout << "environmental exposure" << endl;
}
// Write results to a file
ofstream outputFile("radiation_dose_result.txt");
if (outputFile.is_open()) {
outputFile << "Exposure Time (hours): " << exposureTime << endl;
outputFile << "Distance from Source (meters): " << distance << endl;
outputFile << "Shielding Thickness (centimeters): " << shieldingThickness << endl;
outputFile << "Radiation Type: " << radiationType << endl;
outputFile << "Exposure Type: " << (exposureType == 1 ? "Occupational" : "Environmental") << endl;
outputFile << "Calculated Dose (mSv): " << dose << endl;
outputFile << "Dose Classification: " << doseClassification << endl;
outputFile.close();
cout << "\nResults written to 'radiation_dose_result.txt'" << endl;
} else {
cerr << "Error: Unable to write to file." << endl;
}
return 0;
}