From 9be9bf767f98cea0a6a3e3f6be882037df52003c Mon Sep 17 00:00:00 2001 From: Brian Dandurand Date: Thu, 12 Feb 2026 17:28:02 +0000 Subject: [PATCH 1/3] Update to particle update and documentation; changing colour of helium nuclei from green to yellow to match the original description. --- nuclear_fusion/Nucleus.js | 15 +++++++++------ nuclear_fusion/core.js | 8 ++++++-- nuclear_fusion/simulation.html | 11 ++++++----- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/nuclear_fusion/Nucleus.js b/nuclear_fusion/Nucleus.js index 3b53229..dd29762 100644 --- a/nuclear_fusion/Nucleus.js +++ b/nuclear_fusion/Nucleus.js @@ -15,9 +15,9 @@ class Nucleus { this.undefined_safeguard = true; } - update() { - this.vx += this.ax * dt; - this.vy += this.ay * dt; + update_init() { + this.vx += 0.5*this.ax * dt; + this.vy += 0.5*this.ay * dt; this.agitate(); @@ -40,10 +40,13 @@ class Nucleus { this.vy = -Math.abs(this.vy); this.y = canvas_height - this.radius; } - this.ax = 0; this.ay = 0; } + update_finish() { + this.vx += 0.5*this.ax * dt; + this.vy += 0.5*this.ay * dt; + } applyForce(force_x, force_y) { if(this.undefined_safeguard) { if(force_x !== undefined) { @@ -85,10 +88,10 @@ class Nucleus { this.color = "#0000ff"; } else if(this.mass == 2) { - this.color = "#00ff00"; + this.color = "#ffff00"; } else { this.color = "#aaaaaa"; } } -} \ No newline at end of file +} diff --git a/nuclear_fusion/core.js b/nuclear_fusion/core.js index 0d8911f..80ef554 100644 --- a/nuclear_fusion/core.js +++ b/nuclear_fusion/core.js @@ -40,7 +40,7 @@ let dt = 0.001; function update() { for (let nucleus of nuclei) { - nucleus.update(); + nucleus.update_init(); } for(let fusion_event of fusion_events) { @@ -54,6 +54,10 @@ function update() { heatUp(); } + for (let nucleus of nuclei) { + nucleus.update_finish(); + } + frame++; frame = frame % fps if(frame == 0) { @@ -249,4 +253,4 @@ function distanceBetweenCoordAndNucleus(x, y, nucleus) { function distanceBetween(nucleus1, nucleus2) { return distance_scaling * Math.sqrt(Math.pow(nucleus2.x - nucleus1.x, 2) + Math.pow(nucleus2.y - nucleus1.y, 2)); -} \ No newline at end of file +} diff --git a/nuclear_fusion/simulation.html b/nuclear_fusion/simulation.html index 9b1df46..d3fcb04 100644 --- a/nuclear_fusion/simulation.html +++ b/nuclear_fusion/simulation.html @@ -125,10 +125,11 @@

Components

  • Dynamics

    - The motion of nuclei obtained using the following equations: - \[ a = F / m \] - \[ v(t + \Delta t) = v(t) + a \Delta t \] - \[ x(t + \Delta t) = x(t) + v(t + \Delta t) \Delta t \] + The motion of nuclei obtained using the following Verlet method updates: + \[ v(t + 0.5\Delta t) = v(t) + 0.5 a(t) \Delta t \] + \[ x(t + \Delta t) = x(t) + v(t + 0.5\Delta t) \Delta t \] + \[ a(t + \Delta t) = F(x(t + \Delta t)) / m \] + \[ v(t + \Delta t) = v(t+0.5\Delta t) + 0.5 a(t + \Delta t) \Delta t \] Where \( \Delta t = 10^{-3} \ units \). Further, when a nucleus moves through a heated cell, it gets agitated, resulting in an increase in it's velocity. Lighter nuclei are more influenced by heat than heavier nuclei.

    @@ -234,4 +235,4 @@

    Analysis

    Developed by ChanRT | Fork me at GitHub

    - \ No newline at end of file + From 956097f28df372b8703a95a86319965f36c7545c Mon Sep 17 00:00:00 2001 From: Brian Dandurand Date: Fri, 13 Feb 2026 12:07:07 +0000 Subject: [PATCH 2/3] Fixing the colouring of the 6th cluster for the k-mean clustering. --- clustering/simulation.html | 5 +---- clustering/simulation.js | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/clustering/simulation.html b/clustering/simulation.html index 719ab45..a1481b5 100644 --- a/clustering/simulation.html +++ b/clustering/simulation.html @@ -119,9 +119,6 @@

    Algorithm

  • The metric used here is Euclidean distance
  • -
  • - There is a bug that occurs with 6 clusters. Two of the centroids are of same color. -
  • Related: Gradient Descent, Genetic Algorithm, @@ -135,4 +132,4 @@

    Algorithm

    Developed by ChanRT | Fork me at GitHub

    - \ No newline at end of file + diff --git a/clustering/simulation.js b/clustering/simulation.js index 667d73b..2b3cd06 100644 --- a/clustering/simulation.js +++ b/clustering/simulation.js @@ -198,7 +198,7 @@ function getColor(group) { case 4: return "#aaaaaa"; case 5: - return "#ffcocb" + return "#ff00ff"; } } @@ -248,4 +248,4 @@ function distanceBetweenPoints(point1, point2) { function distanceBetweenCoordAndPoint(x, y, point) { return Math.sqrt(Math.pow(point.x - x, 2) + Math.pow(point.y - y, 2)); -} \ No newline at end of file +} From 3876d89e3314b2802f84aba3d18f9d7537d135a8 Mon Sep 17 00:00:00 2001 From: Brian Dandurand Date: Fri, 13 Feb 2026 12:30:06 +0000 Subject: [PATCH 3/3] Adding initial call to internuclearInteractions() once nuclei are populated. --- nuclear_fusion/core.js | 1 + 1 file changed, 1 insertion(+) diff --git a/nuclear_fusion/core.js b/nuclear_fusion/core.js index 80ef554..0e2e4ec 100644 --- a/nuclear_fusion/core.js +++ b/nuclear_fusion/core.js @@ -228,6 +228,7 @@ function makeScene() { } nuclei.push(new Nucleus(x, y, 1, 1, 100)); } + internuclearInteractions(); } function makeGrid() {