Add generalFunctions dependency and implement basic measurement child registration in nodeClass

This commit is contained in:
2025-07-11 12:22:36 +02:00
parent 6fd86f71c8
commit 24de5a4c9f
4 changed files with 294 additions and 264 deletions

6
package-lock.json generated
View File

@@ -9,6 +9,7 @@
"version": "0.0.1", "version": "0.0.1",
"license": "SEE LICENSE", "license": "SEE LICENSE",
"dependencies": { "dependencies": {
"generalFunctions": "git+https://gitea.centraal.wbd-rd.nl/p.vanderwilt/generalFunctions.git",
"mathjs": "^14.5.2" "mathjs": "^14.5.2"
} }
}, },
@@ -59,6 +60,11 @@
"url": "https://github.com/sponsors/rawify" "url": "https://github.com/sponsors/rawify"
} }
}, },
"node_modules/generalFunctions": {
"version": "1.0.0",
"resolved": "git+https://gitea.centraal.wbd-rd.nl/p.vanderwilt/generalFunctions.git#950ca2b6b4e91b37479aee90bff74b02c16f130e",
"license": "SEE LICENSE"
},
"node_modules/javascript-natural-sort": { "node_modules/javascript-natural-sort": {
"version": "0.7.1", "version": "0.7.1",
"resolved": "https://registry.npmjs.org/javascript-natural-sort/-/javascript-natural-sort-0.7.1.tgz", "resolved": "https://registry.npmjs.org/javascript-natural-sort/-/javascript-natural-sort-0.7.1.tgz",

View File

@@ -27,6 +27,7 @@
} }
}, },
"dependencies": { "dependencies": {
"generalFunctions": "git+https://gitea.centraal.wbd-rd.nl/p.vanderwilt/generalFunctions.git",
"mathjs": "^14.5.2" "mathjs": "^14.5.2"
} }
} }

View File

@@ -48,6 +48,12 @@ class nodeClass {
case "Dispersion": case "Dispersion":
this.reactor.setDispersion = msg; this.reactor.setDispersion = msg;
break; break;
case 'registerChild':
// Register this node as a child of the parent node
const childId = msg.payload;
const childObj = this.RED.nodes.getNode(childId);
this.reactor.childRegistrationUtils.registerChild(childObj.source, msg.positionVsParent);
break;
default: default:
console.log("Unknown topic: " + msg.topic); console.log("Unknown topic: " + msg.topic);
} }

View File

@@ -1,6 +1,7 @@
const ASM3 = require('./reaction_modules/asm3_class.js'); const ASM3 = require('./reaction_modules/asm3_class.js');
const { create, all } = require('mathjs'); const { create, all } = require('mathjs');
const { assertNoNaN } = require('./utils.js'); const { assertNoNaN } = require('./utils.js');
const { childRegistrationUtils, logger, MeasurementContainer } = require('generalFunctions');
const config = { const config = {
matrix: 'Array' // use Array as the matrix type matrix: 'Array' // use Array as the matrix type
@@ -18,6 +19,11 @@ class Reactor {
* @param {object} config - Configuration object containing reactor parameters. * @param {object} config - Configuration object containing reactor parameters.
*/ */
constructor(config) { constructor(config) {
// EVOLV stuff
this.logger = new logger(); //TODO: attach config
this.measurements = new MeasurementContainer();
this.childRegistrationUtils = new childRegistrationUtils(this); // Child registration utility
this.asm = new ASM3(); this.asm = new ASM3();
this.volume = config.volume; // fluid volume reactor [m3] this.volume = config.volume; // fluid volume reactor [m3]
@@ -34,6 +40,18 @@ class Reactor {
this.speedUpFactor = 60; // speed up factor for simulation, 60 means 1 minute per simulated second this.speedUpFactor = 60; // speed up factor for simulation, 60 means 1 minute per simulated second
} }
updateMeasurement(variant, subType, value, position) {
this.logger.debug(`---------------------- updating ${subType} ------------------ `);
switch (subType) {
case "temperature":
this.logger.debug(`no nothing`);
break;
default:
this.logger.error(`Type '${subType}' not recognized for measured update.`);
return;
}
}
/** /**
* Setter for influent data. * Setter for influent data.
* @param {object} input - Input object (msg) containing payload with inlet index, flow rate, and concentrations. * @param {object} input - Input object (msg) containing payload with inlet index, flow rate, and concentrations.
@@ -101,7 +119,6 @@ class Reactor {
this.currentTime += n_iter * this.timeStep * day2ms / this.speedUpFactor; this.currentTime += n_iter * this.timeStep * day2ms / this.speedUpFactor;
} }
} }
} }
class Reactor_CSTR extends Reactor { class Reactor_CSTR extends Reactor {
@@ -256,7 +273,7 @@ class Reactor_PFR extends Reactor {
state[0] = state[1]; state[0] = state[1];
} }
// Neumann BC (no flux) // Neumann BC (no flux)
state[this.n_x-1] = state[this.n_x-2] state[this.n_x-1] = state[this.n_x-2];
} }
/** /**