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 +} 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..0e2e4ec 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) { @@ -224,6 +228,7 @@ function makeScene() { } nuclei.push(new Nucleus(x, y, 1, 1, 100)); } + internuclearInteractions(); } function makeGrid() { @@ -249,4 +254,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 +