Compare commits

...

8 Commits

5 changed files with 47 additions and 31 deletions

20
package-lock.json generated
View File

@@ -1,22 +1,22 @@
{ {
"name": "asm3", "name": "reactor",
"version": "0.0.1", "version": "0.0.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "asm3", "name": "reactor",
"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#fix-missing-references", "generalFunctions": "git+https://gitea.centraal.wbd-rd.nl/RnD/generalFunctions.git",
"mathjs": "^14.5.2" "mathjs": "^14.5.2"
} }
}, },
"node_modules/@babel/runtime": { "node_modules/@babel/runtime": {
"version": "7.28.3", "version": "7.28.4",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.3.tgz", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.4.tgz",
"integrity": "sha512-9uIQ10o0WGdpP6GDhXcdOJPJuDgFtIDtN/9+ArJQ2NAfAmiuhTQdzkaTGR33v43GYS2UrSA0eX2pPPHoFVvpxA==", "integrity": "sha512-Q/N6JNWvIvPnLDvjlE1OUBLPQHH6l3CltCEsHIujp45zQUSSh8K+gHnaEX45yAT1nyngnINhvWtzN+Nb9D8RAQ==",
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"node": ">=6.9.0" "node": ">=6.9.0"
@@ -62,7 +62,7 @@
}, },
"node_modules/generalFunctions": { "node_modules/generalFunctions": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "git+https://gitea.centraal.wbd-rd.nl/p.vanderwilt/generalFunctions.git#302e12238745766a679ef11ca6ed5f4ea1548f87", "resolved": "git+https://gitea.centraal.wbd-rd.nl/RnD/generalFunctions.git#efc97d6cd17399391b011298e47e8c1b1599592d",
"license": "SEE LICENSE" "license": "SEE LICENSE"
}, },
"node_modules/javascript-natural-sort": { "node_modules/javascript-natural-sort": {
@@ -72,9 +72,9 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/mathjs": { "node_modules/mathjs": {
"version": "14.7.0", "version": "14.8.0",
"resolved": "https://registry.npmjs.org/mathjs/-/mathjs-14.7.0.tgz", "resolved": "https://registry.npmjs.org/mathjs/-/mathjs-14.8.0.tgz",
"integrity": "sha512-RaMhb+9MSESjDZNox/FzzuFpIUI+oxGLyOy1t3BMoW53pGWnTzZtlucJ5cvbit0dIMYlCq00gNbW1giZX4/1Rg==", "integrity": "sha512-DN4wmAjNzFVJ9vHqpAJ3vX0UF306u/1DgGKh7iVPuAFH19JDRd9NAaQS764MsKbSwDB6uBSkQEmgVmKdgYaCoQ==",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.26.10", "@babel/runtime": "^7.26.10",

View File

@@ -1,5 +1,5 @@
{ {
"name": "asm3", "name": "reactor",
"version": "0.0.1", "version": "0.0.1",
"description": "Implementation of the asm3 model for Node-Red", "description": "Implementation of the asm3 model for Node-Red",
"repository": { "repository": {
@@ -27,7 +27,7 @@
} }
}, },
"dependencies": { "dependencies": {
"generalFunctions": "git+https://gitea.centraal.wbd-rd.nl/p.vanderwilt/generalFunctions.git#fix-missing-references", "generalFunctions": "git+https://gitea.centraal.wbd-rd.nl/RnD/generalFunctions.git",
"mathjs": "^14.5.2" "mathjs": "^14.5.2"
} }
} }

View File

@@ -1,9 +1,19 @@
<script src="/advancedReactor/menu.js"></script> <!--
| S88-niveau | Primair (blokkleur) | Tekstkleur |
| ---------------------- | ------------------- | ---------- |
| **Area** | `#0f52a5` | wit |
| **Process Cell** | `#0c99d9` | wit |
| **Unit** | `#50a8d9` | zwart |
| **Equipment (Module)** | `#86bbdd` | zwart |
| **Control Module** | `#a9daee` | zwart |
-->
<script src="/reactor/menu.js"></script>
<script type="text/javascript"> <script type="text/javascript">
RED.nodes.registerType("advancedReactor", { RED.nodes.registerType("reactor", {
category: "WWTP", category: "EVOLV",
color: "#c4cce0", color: "#50a8d9",
defaults: { defaults: {
name: { value: "" }, name: { value: "" },
reactor_type: { value: "CSTR", required: true }, reactor_type: { value: "CSTR", required: true },
@@ -39,15 +49,15 @@
outputs: 3, outputs: 3,
inputLabels: ["input"], inputLabels: ["input"],
outputLabels: ["process", "dbase", "parent"], outputLabels: ["process", "dbase", "parent"],
icon: "font-awesome/fa-recycle", icon: "font-awesome/fa-flask",
label: function() { label: function() {
return this.name || "advancedReactor"; return this.name || "Reactor";
}, },
oneditprepare: function() { oneditprepare: function() {
// wait for the menu scripts to load // wait for the menu scripts to load
const waitForMenuData = () => { const waitForMenuData = () => {
if (window.EVOLV?.nodes?.advancedReactor?.initEditor) { if (window.EVOLV?.nodes?.reactor?.initEditor) {
window.EVOLV.nodes.advancedReactor.initEditor(this); window.EVOLV.nodes.reactor.initEditor(this);
} else { } else {
setTimeout(waitForMenuData, 50); setTimeout(waitForMenuData, 50);
} }
@@ -115,8 +125,8 @@
}, },
oneditsave: function() { oneditsave: function() {
// save logger fields // save logger fields
if (window.EVOLV?.nodes?.['advancedReactor']?.loggerMenu?.saveEditor) { if (window.EVOLV?.nodes?.reactor?.loggerMenu?.saveEditor) {
window.EVOLV.nodes['advancedReactor'].loggerMenu.saveEditor(this); window.EVOLV.nodes.reactor.loggerMenu.saveEditor(this);
} }
// save position field // save position field
@@ -136,7 +146,7 @@
}); });
</script> </script>
<script type="text/html" data-template-name="advancedReactor"> <script type="text/html" data-template-name="reactor">
<div class="form-row"> <div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label> <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name"> <input type="text" id="node-input-name" placeholder="Name">
@@ -243,6 +253,6 @@
</script> </script>
<script type="text/html" data-help-name="advancedReactor"> <script type="text/html" data-help-name="reactor">
<p>New reactor node</p> <p>New reactor node</p>
</script> </script>

View File

@@ -1,4 +1,4 @@
const nameOfNode = "advancedReactor"; // name of the node, should match file name and node type in Node-RED const nameOfNode = "reactor"; // name of the node, should match file name and node type in Node-RED
const nodeClass = require('./src/nodeClass.js'); // node class const nodeClass = require('./src/nodeClass.js'); // node class
const { MenuManager } = require('generalFunctions'); const { MenuManager } = require('generalFunctions');

View File

@@ -40,7 +40,7 @@ class Reactor {
this.kla = config.kla; // if NaN, use externaly provided OTR [d-1] this.kla = config.kla; // if NaN, use externaly provided OTR [d-1]
this.currentTime = Date.now(); // milliseconds since epoch [ms] this.currentTime = Date.now(); // milliseconds since epoch [ms]
this.timeStep = 1 / (24*60*60) * this.config.timeStep; // time step [d] this.timeStep = 1 / (24*60*60) * this.config.timeStep; // time step in seconds, converted to days.
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
} }
@@ -119,13 +119,18 @@ class Reactor {
return; return;
} }
const position = measurement.config.functionality.positionVsParent; let position;
if (measurement.config.functionality.distance !== 'undefined') {
position = measurement.config.functionality.distance;
} else {
position = measurement.config.functionality.positionVsParent;
}
const measurementType = measurement.config.asset.type; const measurementType = measurement.config.asset.type;
const key = `${measurementType}_${position}`; const key = `${measurementType}_${position}`;
const eventName = `${measurementType}.measured.${position}`; const eventName = `${measurementType}.measured.${position}`;
// Register event listener for measurement updates // Register event listener for measurement updates
this.measurements.emitter.on(eventName, (eventData) => { measurement.measurements.emitter.on(eventName, (eventData) => {
this.logger.debug(`${position} ${measurementType} from ${eventData.childName}: ${eventData.value} ${eventData.unit}`); this.logger.debug(`${position} ${measurementType} from ${eventData.childName}: ${eventData.value} ${eventData.unit}`);
// Store directly in parent's measurement container // Store directly in parent's measurement container
@@ -317,13 +322,14 @@ class Reactor_PFR extends Reactor {
_updateMeasurement(measurementType, value, position, context) { _updateMeasurement(measurementType, value, position, context) {
switch(measurementType) { switch(measurementType) {
case "oxygen": case "quantity (oxygen)":
grid_pos = Math.round(position * this.n_x); let grid_pos = Math.round(position / this.config.length * this.n_x);
this.state[grid_pos][S_O_INDEX] = value; // naive approach for reconciling measurements and simulation this.state[grid_pos][S_O_INDEX] = value; // naive approach for reconciling measurements and simulation
break; break;
} default:
super._updateMeasurement(measurementType, value, position, context); super._updateMeasurement(measurementType, value, position, context);
} }
}
/** /**
* Apply boundary conditions to the reactor state. * Apply boundary conditions to the reactor state.