From 3828e43c12562e14703cbf49e829ab9ad16ce5b1 Mon Sep 17 00:00:00 2001
From: "p.vanderwilt"
Date: Thu, 6 Nov 2025 14:51:06 +0100
Subject: [PATCH] Refactor reactor node configuration to remove n_inlets and
simplify inlet handling
---
reactor.html | 13 -------------
src/nodeClass.js | 1 -
src/specificClass.js | 20 +++++++++++++-------
3 files changed, 13 insertions(+), 21 deletions(-)
diff --git a/reactor.html b/reactor.html
index 9d1574f..cdca7c7 100644
--- a/reactor.html
+++ b/reactor.html
@@ -11,7 +11,6 @@
length: { value: 0.},
resolution_L: { value: 0.},
alpha: {value: 0},
- n_inlets: { value: 1, required: true},
kla: { value: null },
S_O_init: { value: 0., required: true },
@@ -58,10 +57,6 @@
type:"num",
types:["num"]
});
- $("#node-input-n_inlets").typedInput({
- type:"num",
- types:["num"]
- });
$("#node-input-length").typedInput({
type:"num",
types:["num"]
@@ -128,10 +123,6 @@
if (isNaN(volume) || volume <= 0) {
RED.notify("Fluid volume not set correctly", {type: "error"});
}
- let n_inlets = parseInt($("#node-input-n_inlets").typedInput("value"));
- if (isNaN(n_inlets) || n_inlets < 1) {
- RED.notify("Number of inlets not set correctly", {type: "error"});
- }
}
});
@@ -165,10 +156,6 @@
-
-
-
-
Internal mass transfer calculation (optional)
diff --git a/src/nodeClass.js b/src/nodeClass.js
index a9e53d3..3abe037 100644
--- a/src/nodeClass.js
+++ b/src/nodeClass.js
@@ -88,7 +88,6 @@ class nodeClass {
length: parseFloat(uiConfig.length),
resolution_L: parseInt(uiConfig.resolution_L),
alpha: parseFloat(uiConfig.alpha),
- n_inlets: parseInt(uiConfig.n_inlets),
kla: parseFloat(uiConfig.kla),
initialState: [
parseFloat(uiConfig.S_O_init),
diff --git a/src/specificClass.js b/src/specificClass.js
index 1966d56..18ac54a 100644
--- a/src/specificClass.js
+++ b/src/specificClass.js
@@ -1,5 +1,5 @@
const ASM3 = require('./reaction_modules/asm3_class.js');
-const { create, all, isArray } = require('mathjs');
+const { create, all, isArray, i } = require('mathjs');
const { assertNoNaN } = require('./utils.js');
const { childRegistrationUtils, logger, MeasurementContainer } = require('generalFunctions');
const EventEmitter = require('events');
@@ -38,8 +38,8 @@ class Reactor {
this.volume = config.volume; // fluid volume reactor [m3]
- this.Fs = Array(config.n_inlets).fill(0); // fluid debits per inlet [m3 d-1]
- this.Cs_in = Array.from(Array(config.n_inlets), () => new Array(NUM_SPECIES).fill(0)); // composition influents
+ this.Fs = [0]; // fluid debits per inlet [m3 d-1]
+ this.Cs_in = [Array(NUM_SPECIES).fill(0)]; // composition influents
this.OTR = 0.0; // oxygen transfer rate [g O2 d-1 m-3]
this.temperature = 20; // temperature [C]
@@ -55,9 +55,15 @@ class Reactor {
* @param {object} input - Input object (msg) containing payload with inlet index, flow rate, and concentrations.
*/
set setInfluent(input) {
- let index_in = input.payload.inlet;
- this.Fs[index_in] = input.payload.F;
- this.Cs_in[index_in] = input.payload.C;
+ const i_in = input.payload.inlet;
+ if (this.Fs.length <= i_in) {
+ this.logger.debug(`Adding new inlet index ${i_in}.`);
+ this.Fs.push(0);
+ this.Cs_in.push(Array(NUM_SPECIES).fill(0));
+ this.setInfluent = input;
+ }
+ this.Fs[i_in] = input.payload.F;
+ this.Cs_in[i_in] = input.payload.C;
}
/**
@@ -177,7 +183,7 @@ class Reactor {
_connectMachine(machineChild) {
if (machineChild.config.functionality.positionVsParent == "downstream") {
- machineChild.upstreamReactor = this;
+ machineChild.upstreamSource = this;
this.returnPump = machineChild;
}
}