-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtcGenerator.cpp
95 lines (72 loc) · 2.55 KB
/
tcGenerator.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
#include "molybdenum.hpp"
#include "technetium.hpp"
#include <iostream>
using namespace std;
void processCommandLine(int argc, char *argv[], int &initMoPop, int &Tf);
int technetiumGenerator(const int moPopSize, const int Tf);
int main(int argc, char *argv[]) {
// Initial population
int initMoPop;
// Length of simulation
int Tf;
// Process command line
processCommandLine(argc, argv, initMoPop, Tf);
// Run simulation
technetiumGenerator(initMoPop, Tf);
return 0;
}
void processCommandLine(int argc, char *argv[], int &initMoPop, int &Tf) {
/// TODO: Implement processCommandLine
if (argc != 3) {
cout << "Incorrect number of command line arguments." << endl;
exit(1);
}
// Change into integers
initMoPop = stoi(argv[1]);
Tf = stoi(argv[2]);
// Check if population is less than 1000 or greater than 10000000
if (initMoPop < 10e3 || initMoPop > 10e7) {
cout << "Invalid initial Mo-99 population." << endl;
exit(1);
}
// Check if simulation length is less than 10 or greater than 500 hours
if (Tf < 10 || Tf > 500) {
cout << "Invalid simulation length." << endl;
exit(1);
}
}
int technetiumGenerator(const int moPopSize, const int Tf) {
/// TODO: simulate technetium generator
// Seed the rng
srand(0);
// Initial population of Mo99 (specified parameter)
Mo99 mo99(moPopSize);
// Initial population of Tc99 (0)
Tc99 tc99;
// Variable to track the number of Tc99 harvested
int tcHarvested = 0;
// Print column headers
cout << "t\tMo99\tTc99" << endl;
// Run the simulation
for (int t = 0; t <= Tf; ++t) {
// Print the current hour and the populations
cout << t << "\t" << mo99.Count() << "\t" << tc99.Count() << endl;
// Decay Mo99 and produce Tc99 for this hour
int decayedMo = mo99.Decay(1.0); // Decay over 1 hour
tc99.Add(decayedMo); // Add the decayed Mo99 as Tc99
// Decay over 1 hours
tc99.Decay(1.0);
// Check if Tc99 population reaches the threshold for harvesting
if (tc99.Count() >= 10000) {
// Harvest the Tc99 and update the total
tcHarvested += tc99.Count();
// Set Tc99 to 0
tc99.Zero();
}
}
cout << "Initial Mo99 population: " << moPopSize << endl;
cout << "Simulation length: " << Tf << " hours" << endl;
cout << "Total Tc99 harvested: " << tcHarvested << endl;
// Return the total number of Tc99 harvested
return tcHarvested;
}