From a34bf6ee1e7dc25c0b95468234f047312a09a482 Mon Sep 17 00:00:00 2001
From: "p.vanderwilt"
Date: Mon, 22 Sep 2025 11:25:02 +0200
Subject: [PATCH] Refactor updateState and getOutput methods for clarity;
rename getPumpFlow to updatePumpFlow and adjust flow measurement position
---
src/specificClass.js | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/specificClass.js b/src/specificClass.js
index d855076..fa4ecdc 100644
--- a/src/specificClass.js
+++ b/src/specificClass.js
@@ -13,22 +13,23 @@ class liquidFlowHandler {
}
updateState(timeStamp) {
- this.getPumpFlow();
- let effluent = this.reactors[1].getEffluent;
+ this.updatePumpFlow();
+ const effluent = this.reactors[1].getEffluent;
effluent.payload.F = this.flow;
effluent.payload.inlet = 1;
this.reactors[0].setInfluent = effluent;
}
- getPumpFlow() {
- this.flow = this.pump.measurements.type("flow").variant("measured").position("atEquipment").getCurrentValue() || 0;
+ updatePumpFlow() {
+ this.flow = this.pump.measurements.type("flow").variant("measured").position("downstream").getCurrentValue() || 0;
}
getOutput() {
- let mainEffluent = this.reactors[1].getEffluent;
- let sideStream = structuredClone(mainEffluent);
- mainEffluent.payload.F -= this.flow;
- sideStream.payload.F = this.flow;
+ const mainEffluent = this.reactors[1].getEffluent;
+ const sideStream = structuredClone(mainEffluent);
+ const F_in = mainEffluent.payload.F;
+ mainEffluent.payload.F = Math.max(F_in - this.flow, 0);
+ sideStream.payload.F = F_in < this.flow ? F_in : this.flow;
sideStream.payload.inlet = 1;
return {payload: [mainEffluent.payload, sideStream.payload]};
}