Update state handling in reactor class and optimize time iteration logic

This commit is contained in:
2025-11-14 13:11:09 +01:00
parent f3bbf63602
commit cc89833530
2 changed files with 14 additions and 14 deletions

View File

@@ -37,6 +37,7 @@ class nodeClass {
break; break;
case "Fluent": case "Fluent":
this.source.setInfluent = msg; this.source.setInfluent = msg;
this.source.updateState(msg.timestamp);
break; break;
case "OTR": case "OTR":
this.source.setOTR = msg; this.source.setOTR = msg;

View File

@@ -214,13 +214,13 @@ class Reactor {
this.setInfluent = this.upstreamReactor.getEffluent[0]; this.setInfluent = this.upstreamReactor.getEffluent[0];
} }
if (newTime === this.currentTime) { const n_iter = Math.floor(this.speedUpFactor * (newTime-this.currentTime) / (this.timeStep*DAY2MS));
// no update necessary
if (n_iter == 0) {
// no update required
return; return;
} }
const n_iter = Math.floor(this.speedUpFactor * (newTime-this.currentTime) / (this.timeStep*DAY2MS));
if (n_iter) {
let n = 0; let n = 0;
while (n < n_iter) { while (n < n_iter) {
this.tick(this.timeStep); this.tick(this.timeStep);
@@ -233,7 +233,6 @@ class Reactor {
this.returnPump.updateSourceSink(); this.returnPump.updateSourceSink();
} }
} }
}
} }
class Reactor_CSTR extends Reactor { class Reactor_CSTR extends Reactor {