From 62b034fb76421acd37e0b89474bb28216b2f8455 Mon Sep 17 00:00:00 2001
From: "p.vanderwilt"
Date: Thu, 19 Jun 2025 20:55:42 +0200
Subject: [PATCH] Added speed-up factor
---
dependencies/reactor_class.js | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/dependencies/reactor_class.js b/dependencies/reactor_class.js
index db8b3bb..1b2e3d9 100644
--- a/dependencies/reactor_class.js
+++ b/dependencies/reactor_class.js
@@ -16,7 +16,8 @@ class Reactor_CSTR {
this.kla = kla; // if NaN, use external OTR [d-1]
this.currentTime = Date.now(); // milliseconds since epoch [ms]
- this.timeStep = 1/(24*60*15) // time step [d]
+ this.timeStep = 1/(24*60*15); // time step [d]
+ this.speedUpFactor = 30;
}
set setInfluent(input) { // setter for C_in (WIP)
@@ -39,20 +40,18 @@ class Reactor_CSTR {
}
// expect update with timestamp
- updateState(timestamp) {
- let newTime = timestamp;
+ updateState(newTime) {
const day2ms = 1000 * 60 * 60 * 24;
- let n_iter = Math.floor((newTime - this.currentTime) / (this.timeStep * day2ms));
- if (n_iter > 0) {
+ let n_iter = Math.floor(this.speedUpFactor*(newTime - this.currentTime) / (this.timeStep * day2ms));
+ if (n_iter) {
let n = 0;
while (n < n_iter) {
- console.log(this.tick_fe(this.timeStep));
+ this.tick_fe(this.timeStep);
n += 1;
}
- this.currentTime += n_iter * this.timeStep * day2ms;
- n_iter = 0;
+ this.currentTime += n_iter * this.timeStep * day2ms / this.speedUpFactor;
}
}