Skip to content

Commit 62ed776

Browse files
committed
Added spontaneous neutron emission
1 parent a0873b7 commit 62ed776

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

Fission/sketch.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const FPS = 60;
22
const enclosed = false;
33

4-
const gridSpacing = 51;
4+
const gridSpacing = 50;
55
const marginSpacing = 100;
66

77
let horizontalOffset;
@@ -121,7 +121,6 @@ class Nucleus {
121121
this.p = createVector(x, y);
122122
this.radius = radius;
123123
this.type = type;
124-
console.log(this.type)
125124

126125
this.neutronReleaseCount = 3;
127126
}
@@ -134,12 +133,19 @@ class Nucleus {
134133
if(this.type === NON_FISSILE){
135134
let probUranium = (1 - pow(1 - 0.00011, 30 / FPS));
136135
let probXenon = (1 - pow(1 - 0.00004, 30 / FPS));
137-
138-
console.log(probUranium, probXenon);
136+
let probNeutron = (1 - pow(1 - 0.00001, 30 /FPS));
139137

140138
let r = random(0, 1);
141139

142-
this.type = r < probUranium ? URANIUM : (r < probUranium + probXenon ? XENON : NON_FISSILE);
140+
if(r < probUranium)
141+
this.type = URANIUM;
142+
143+
else if(r < probUranium + probXenon)
144+
this.type = XENON;
145+
146+
else if(r < probUranium + probXenon + probNeutron)
147+
neutrons.push(new Neutron(this.p.x, this.p.y, random(0, 2* PI), random(0.5, neutronSpeed / 2), neutronRadius));
148+
143149
}
144150
pop();
145151
}
@@ -239,8 +245,12 @@ class Neutron {
239245
// }
240246

241247
function keyPressed(){
242-
if(keyCode === 68){ // D Key
248+
if(keyCode === 67)
249+
neutrons = [];
250+
251+
else if(keyCode === 68){ // D Key
243252
debug = !debug;
253+
244254
}else if(keyCode === 83) { // S Key
245255
neutrons.push(new Neutron(random(0, width), random(0, height), random(0.5, 2 * PI), random(0, neutronSpeed), neutronRadius));
246256
}

0 commit comments

Comments
 (0)