From 6de4f9ec3e3eae0d1926adad6e4629fdc765e54b Mon Sep 17 00:00:00 2001 From: HorriblePerson555 <47578455+HorriblePerson555@users.noreply.github.com> Date: Tue, 21 Oct 2025 13:02:41 +0200 Subject: [PATCH] Fix recirculation flow calculation to prevent negative flow rates and improve variable naming --- src/specificClass.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/specificClass.js b/src/specificClass.js index 3f62914..75edd08 100644 --- a/src/specificClass.js +++ b/src/specificClass.js @@ -76,11 +76,12 @@ class Reactor { const Cs = isArray(this.state.at(-1)) ? this.state.at(-1) : this.state; const effluent = [{ topic: "Fluent", payload: { inlet: 0, F: math.sum(this.Fs), C: Cs }, timestamp: this.currentTime }]; if (this.returnPump) { - const recirculationFlow = this.returnPump.measurements.type("flow").variant("measured").position("atequipment").getCurrentValue(); + const recirculationFlow = this.returnPump.measurements.type("flow").variant("measured").position("atEquipment").getCurrentValue(); + // constrain flow to prevent negatives const F_main = Math.max(effluent[0].payload.F - recirculationFlow, 0); - const F_side_constrained = effluent[0].payload.F < recirculationFlow ? effluent[0].payload.F : recirculationFlow; + const F_sidestream = effluent[0].payload.F < recirculationFlow ? effluent[0].payload.F : recirculationFlow; effluent[0].payload.F = F_main; - effluent.push({ topic: "Fluent", payload: { inlet: 1, F: F_side_constrained, C: Cs }, timestamp: this.currentTime }); + effluent.push({ topic: "Fluent", payload: { inlet: 1, F: F_sidestream, C: Cs }, timestamp: this.currentTime }); } return effluent; }