Refactor updateState and getOutput methods for clarity; rename getPumpFlow to updatePumpFlow and adjust flow measurement position

This commit is contained in:
2025-09-22 11:25:02 +02:00
parent 01e88466b9
commit a34bf6ee1e

View File

@@ -13,22 +13,23 @@ class liquidFlowHandler {
} }
updateState(timeStamp) { updateState(timeStamp) {
this.getPumpFlow(); this.updatePumpFlow();
let effluent = this.reactors[1].getEffluent; const effluent = this.reactors[1].getEffluent;
effluent.payload.F = this.flow; effluent.payload.F = this.flow;
effluent.payload.inlet = 1; effluent.payload.inlet = 1;
this.reactors[0].setInfluent = effluent; this.reactors[0].setInfluent = effluent;
} }
getPumpFlow() { updatePumpFlow() {
this.flow = this.pump.measurements.type("flow").variant("measured").position("atEquipment").getCurrentValue() || 0; this.flow = this.pump.measurements.type("flow").variant("measured").position("downstream").getCurrentValue() || 0;
} }
getOutput() { getOutput() {
let mainEffluent = this.reactors[1].getEffluent; const mainEffluent = this.reactors[1].getEffluent;
let sideStream = structuredClone(mainEffluent); const sideStream = structuredClone(mainEffluent);
mainEffluent.payload.F -= this.flow; const F_in = mainEffluent.payload.F;
sideStream.payload.F = this.flow; 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; sideStream.payload.inlet = 1;
return {payload: [mainEffluent.payload, sideStream.payload]}; return {payload: [mainEffluent.payload, sideStream.payload]};
} }