From 93b67e607a1005815d9eb911f212dbc2fd48cdda Mon Sep 17 00:00:00 2001 From: "p.vanderwilt" Date: Fri, 24 Oct 2025 15:00:57 +0200 Subject: [PATCH] Refactor settler node: remove unused inlet input and enhance effluent calculation logic --- settler.html | 9 ------- src/nodeClass.js | 2 +- src/specificClass.js | 56 +++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 54 insertions(+), 13 deletions(-) diff --git a/settler.html b/settler.html index 9f3a639..d3110a2 100644 --- a/settler.html +++ b/settler.html @@ -42,11 +42,6 @@ if (window.EVOLV?.nodes?.measurement?.positionMenu?.saveEditor) { window.EVOLV.nodes.rotatingMachine.positionMenu.saveEditor(this); } - - const inlet = parseInt($("#node-input-n_inlets").typedInput("value")); - if (inlet < 1) { - RED.notify("Number of inlets not set correctly", {type: "error"}); - } } }); @@ -56,10 +51,6 @@ -
- - -
diff --git a/src/nodeClass.js b/src/nodeClass.js index 702b430..4757683 100644 --- a/src/nodeClass.js +++ b/src/nodeClass.js @@ -100,7 +100,7 @@ class nodeClass { } _tick(){ - this.node.send([null, null, null]); + this.node.send([this.source.getEffluent, null, null]); } _attachCloseHandler() { diff --git a/src/specificClass.js b/src/specificClass.js index 2bf25f2..ec087d8 100644 --- a/src/specificClass.js +++ b/src/specificClass.js @@ -14,11 +14,49 @@ class Settler { this.returnPump = null; // state variables - this.F_in = 0; + this.F_in = 0; // debit in + this.Cs_in = new Array(13).fill(0); // Concentrations in + this.C_TS = 2500; // Total solids concentration sludge } get getEffluent() { - return; + // constrain flow to prevent negatives + const F_s = Math.min((this.F_in * this.Cs_in[12]) / this.C_TS, this.F_in); + const F_eff = this.F_in - F_s; + + let F_sr = 0; + if (this.returnPump) { + F_sr = Math.min(this.returnPump.measurements.type("flow").variant("measured").position("atEquipment").getCurrentValue(), F_s); + } + const F_so = F_s - F_sr; + + // effluent + const Cs_eff = structuredClone(this.Cs_in); + if (F_s > 0) { + Cs_eff[7] = 0; + Cs_eff[8] = 0; + Cs_eff[9] = 0; + Cs_eff[10] = 0; + Cs_eff[11] = 0; + Cs_eff[12] = 0; + } + + // sludge + const Cs_s = structuredClone(this.Cs_in); + if (F_s > 0) { + Cs_s[7] = this.F_in * this.Cs_in[7] / F_s; + Cs_s[8] = this.F_in * this.Cs_in[8] / F_s; + Cs_s[9] = this.F_in * this.Cs_in[9] / F_s; + Cs_s[10] = this.F_in * this.Cs_in[10] / F_s; + Cs_s[11] = this.F_in * this.Cs_in[11] / F_s; + Cs_s[12] = this.F_in * this.Cs_in[12] / F_s; + } + + return [ + { topic: "Fluent", payload: { inlet: 0, F: F_eff, C: Cs_eff }, timestamp: Date.now() }, + { topic: "Fluent", payload: { inlet: 1, F: F_so, C: Cs_s }, timestamp: Date.now() }, + { topic: "Fluent", payload: { inlet: 2, F: F_sr, C: Cs_s }, timestamp: Date.now() } + ]; } registerChild(child, softwareType) { @@ -73,7 +111,7 @@ class Settler { } if (reactorChild.config.functionality.positionVsParent != "upstream") { - this.logger.warn("Reactor children of reactors should always be upstream."); + this.logger.warn("Reactor children of settlers should be upstream."); } this.upstreamReactor = reactorChild; @@ -97,6 +135,18 @@ class Settler { this.returnPump = machineChild; } } + + _updateMeasurement(measurementType, value, position, context) { + switch(measurementType) { + case "quantity (TSS)": + this.C_TS = value; + break; + + default: + this.logger.error(`Type '${measurementType}' not recognized for measured update.`); + return; + } + } } module.exports = { Settler }; \ No newline at end of file