-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstable.cpp
More file actions
60 lines (54 loc) · 1.76 KB
/
Copy pathstable.cpp
File metadata and controls
60 lines (54 loc) · 1.76 KB
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
#include <iostream>
#include <string>
#include <vector>
std::string Stability;
std::vector<int> magicNumbers = { 2, 8, 20, 28, 50, 82, 126 };
void checkStability(int atomList[]) {
int protons = atomList[0];
int neutrons = atomList[1];
double neutronProtonRatio = static_cast<double>(neutrons) / protons;
bool isMagicProton = false;
bool isMagicNeutron = false;
// Check for magic numbers in protons and neutrons
for (int magic : magicNumbers) {
if (protons == magic) {
isMagicProton = true;
}
if (neutrons == magic) {
isMagicNeutron = true;
}
}
// Simplified stability logic based on proton count and N/Z ratio
if (protons < 20) {
if (protons == neutrons) {
Stability = "Stable atom\n";
}
else if (neutronProtonRatio > 1.5) {
Stability = "Neutron-rich, possibly unstable\n";
}
else if (neutronProtonRatio < 1.0) {
Stability = "Proton-rich, possibly unstable\n";
}
else {
Stability = "Slightly unstable\n";
}
}
// For larger atoms, consider magic numbers and ratios
else {
if (isMagicProton && isMagicNeutron) {
Stability = "Doubly magic, highly stable atom\n";
}
else if (isMagicProton || isMagicNeutron) {
Stability = "Magic number stability, likely stable\n";
}
else if (neutronProtonRatio > 1.5) {
Stability = "Neutron-rich, unstable\n";
}
else if (neutronProtonRatio < 1.0) {
Stability = "Proton-rich, unstable\n";
}
else {
Stability = "Expected to be stable\n";
}
}
}