From 70af0885e3344bda02e1f310115182edf810817e Mon Sep 17 00:00:00 2001 From: "p.vanderwilt" Date: Fri, 14 Nov 2025 12:34:52 +0100 Subject: [PATCH] Prepare for working with relative time --- src/specificClass.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/specificClass.js b/src/specificClass.js index 23c1289..6378307 100644 --- a/src/specificClass.js +++ b/src/specificClass.js @@ -42,7 +42,7 @@ class Reactor { this.kla = config.kla; // if NaN, use externaly provided OTR [d-1] - this.currentTime = Date.now(); // milliseconds since epoch [ms] + this.currentTime = null; // milliseconds since epoch [ms] this.timeStep = 1 / (24*60*60) * this.config.timeStep; // time step in seconds, converted to days. this.speedUpFactor = 100; // speed up factor for simulation, 60 means 1 minute per simulated second } @@ -204,8 +204,19 @@ class Reactor { * @param {number} newTime - New time to update reactor state to, in milliseconds since epoch. */ updateState(newTime) { // expect update with timestamp + if (!this.currentTime) { + this.currentTime = newTime; + return; + } + if (this.upstreamReactor) { - this.setInfluent = this.upstreamReactor.getEffluent[0]; // grab main effluent upstream reactor + // grab main effluent upstream reactor + this.setInfluent = this.upstreamReactor.getEffluent[0]; + } + + if (newTime === this.currentTime) { + // no update necessary + return; } const n_iter = Math.floor(this.speedUpFactor * (newTime-this.currentTime) / (this.timeStep*DAY2MS));