Temporary fix for undefined newTime value in updateState function

This commit is contained in:
2025-08-04 10:59:11 +02:00
parent 2c9db0fcea
commit fbbe5833b2
2 changed files with 26 additions and 29 deletions

20
package-lock.json generated
View File

@@ -14,9 +14,9 @@
}
},
"node_modules/@babel/runtime": {
"version": "7.27.6",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.27.6.tgz",
"integrity": "sha512-vbavdySgbTTrmFE+EsiqUTzlOr5bzlnJtUv9PynGCAKvfQqjIXbvFdumPM/GxMDfyuGMJaJAU6TO4zc1Jf1i8Q==",
"version": "7.28.2",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.2.tgz",
"integrity": "sha512-KHp2IflsnGywDjBWDkR9iEqiWSpc8GIi0lgTT3mOElT0PP1tG26P4tmFI2YvAdzgq9RGyoHZQEIEdZy6Ec5xCA==",
"license": "MIT",
"engines": {
"node": ">=6.9.0"
@@ -36,9 +36,9 @@
}
},
"node_modules/decimal.js": {
"version": "10.5.0",
"resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.5.0.tgz",
"integrity": "sha512-8vDa8Qxvr/+d94hSh5P3IJwI5t8/c0KsMp+g8bNw9cY2icONa5aPfvKeieW1WlG0WQYwwhJ7mjui2xtiePQSXw==",
"version": "10.6.0",
"resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.6.0.tgz",
"integrity": "sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==",
"license": "MIT"
},
"node_modules/escape-latex": {
@@ -62,7 +62,7 @@
},
"node_modules/generalFunctions": {
"version": "1.0.0",
"resolved": "git+https://gitea.centraal.wbd-rd.nl/p.vanderwilt/generalFunctions.git#950ca2b6b4e91b37479aee90bff74b02c16f130e",
"resolved": "git+https://gitea.centraal.wbd-rd.nl/p.vanderwilt/generalFunctions.git#f13ee68938ea9d4b3a17ad90618c72634769c777",
"license": "SEE LICENSE"
},
"node_modules/javascript-natural-sort": {
@@ -72,9 +72,9 @@
"license": "MIT"
},
"node_modules/mathjs": {
"version": "14.5.2",
"resolved": "https://registry.npmjs.org/mathjs/-/mathjs-14.5.2.tgz",
"integrity": "sha512-51U6hp7j4M4Rj+l+q2KbmXAV9EhQVQzUdw1wE67RnUkKKq5ibxdrl9Ky2YkSUEIc2+VU8/IsThZNu6QSHUoyTA==",
"version": "14.6.0",
"resolved": "https://registry.npmjs.org/mathjs/-/mathjs-14.6.0.tgz",
"integrity": "sha512-5vI2BLB5GKQmiSK9BH6hVkZ+GgqpdnOgEfmHl7mqVmdQObLynr63KueyYYLCQMzj66q69mV2XZZGQqqxeftQbA==",
"license": "Apache-2.0",
"dependencies": {
"@babel/runtime": "^7.26.10",

View File

@@ -113,7 +113,7 @@ class Reactor {
* Update the reactor state based on the new time.
* @param {number} newTime - New time to update reactor state to, in milliseconds since epoch.
*/
updateState(newTime) { // expect update with timestamp
updateState(newTime = Date.now()) { // expect update with timestamp
const day2ms = 1000 * 60 * 60 * 24;
if (this.upstreamReactor) {
@@ -128,7 +128,7 @@ class Reactor {
n += 1;
}
this.currentTime += n_iter * this.timeStep * day2ms / this.speedUpFactor;
this.emitter.emit("stateChange", newTime);
this.emitter.emit("stateChange", this.currentTime);
}
}
}
@@ -183,9 +183,6 @@ class Reactor_PFR extends Reactor {
this.state = Array.from(Array(this.n_x), () => config.initialState.slice())
// console.log("Initial State: ")
// console.log(this.state)
this.D = 0.0; // axial dispersion [m2 d-1]
this.D_op = this._makeDoperator(true, true);
@@ -208,8 +205,8 @@ class Reactor_PFR extends Reactor {
let Pe_local = this.d_x*math.sum(this.Fs)/(this.D*this.A)
let Co_D = this.D*this.timeStep/(this.d_x*this.d_x);
(Pe_local >= 2) && console.warn(`Local Péclet number (${Pe_local}) is too high! Increase reactor resolution.`);
(Co_D >= 0.5) && console.warn(`Courant number (${Co_D}) is too high! Reduce time step size.`);
(Pe_local >= 2) && this.logger.warn(`Local Péclet number (${Pe_local}) is too high! Increase reactor resolution.`);
(Co_D >= 0.5) && this.logger.warn(`Courant number (${Co_D}) is too high! Reduce time step size.`);
if(DEBUG) {
console.log("Inlet state max " + math.max(this.state[0]))