Compare commits
4 Commits
boundary-c
...
a18c36b2e5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a18c36b2e5 | ||
|
|
aacbc1e99d | ||
|
|
68576a8a36 | ||
|
|
442ddc60ed |
@@ -3,13 +3,12 @@ module.exports = function(RED) {
|
||||
RED.nodes.createNode(this, config);
|
||||
var node = this;
|
||||
|
||||
let name = config.name;
|
||||
let F2 = parseFloat(config.F2);
|
||||
const inlet_F2 = parseInt(config.inlet);
|
||||
|
||||
node.on('input', function(msg, send, done) {
|
||||
switch (msg.topic) {
|
||||
case "Fluent":
|
||||
case "Fluent": {
|
||||
// conserve volume flow debit
|
||||
let F_in = msg.payload.F;
|
||||
let F1 = Math.max(F_in - F2, 0);
|
||||
@@ -24,6 +23,7 @@ module.exports = function(RED) {
|
||||
|
||||
send([msg_F1, msg_F2]);
|
||||
break;
|
||||
}
|
||||
case "clock":
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -3,13 +3,12 @@ module.exports = function(RED) {
|
||||
RED.nodes.createNode(this, config);
|
||||
var node = this;
|
||||
|
||||
let name = config.name;
|
||||
let TS_set = parseFloat(config.TS_set);
|
||||
const inlet_sludge = parseInt(config.inlet);
|
||||
|
||||
node.on('input', function(msg, send, done) {
|
||||
switch (msg.topic) {
|
||||
case "Fluent":
|
||||
case "Fluent": {
|
||||
// conserve volume flow debit
|
||||
let F_in = msg.payload.F;
|
||||
let C_in = msg.payload.C;
|
||||
@@ -41,6 +40,7 @@ module.exports = function(RED) {
|
||||
|
||||
send([msg_F1, msg_F2]);
|
||||
break;
|
||||
}
|
||||
case "clock":
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const { Reactor_CSTR, Reactor_PFR } = require('./specificClass.js');
|
||||
const { configManager } = require('generalFunctions');
|
||||
|
||||
|
||||
class nodeClass {
|
||||
@@ -48,12 +49,13 @@ class nodeClass {
|
||||
case "Dispersion":
|
||||
this.source.setDispersion = msg;
|
||||
break;
|
||||
case 'registerChild':
|
||||
case 'registerChild': {
|
||||
// Register this node as a parent of the child node
|
||||
const childId = msg.payload;
|
||||
const childObj = this.RED.nodes.getNode(childId);
|
||||
this.source.childRegistrationUtils.registerChild(childObj.source, msg.positionVsParent);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
console.log("Unknown topic: " + msg.topic);
|
||||
}
|
||||
@@ -69,20 +71,10 @@ class nodeClass {
|
||||
* @param {object} uiConfig Config set in UI in node-red
|
||||
*/
|
||||
_loadConfig(uiConfig) {
|
||||
this.config = {
|
||||
general: {
|
||||
name: uiConfig.name || this.name,
|
||||
id: this.node.id,
|
||||
unit: null,
|
||||
logging: {
|
||||
enabled: uiConfig.enableLog,
|
||||
logLevel: uiConfig.logLevel
|
||||
}
|
||||
},
|
||||
functionality: {
|
||||
positionVsParent: uiConfig.positionVsParent || 'atEquipment', // Default to 'atEquipment' if not specified
|
||||
softwareType: "reactor" // should be set in config manager
|
||||
},
|
||||
const cfgMgr = new configManager();
|
||||
|
||||
// Build config: base sections + reactor-specific domain config
|
||||
this.config = cfgMgr.buildConfig('reactor', uiConfig, this.node.id, {
|
||||
reactor_type: uiConfig.reactor_type,
|
||||
volume: parseFloat(uiConfig.volume),
|
||||
length: parseFloat(uiConfig.length),
|
||||
@@ -106,7 +98,7 @@ class nodeClass {
|
||||
parseFloat(uiConfig.X_TS_init)
|
||||
],
|
||||
timeStep: parseFloat(uiConfig.timeStep)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,7 +129,7 @@ class nodeClass {
|
||||
new_reactor = new Reactor_PFR(this.config);
|
||||
break;
|
||||
default:
|
||||
console.warn("Unknown reactor type: " + uiConfig.reactor_type);
|
||||
console.warn("Unknown reactor type: " + this.config.reactor_type);
|
||||
}
|
||||
|
||||
this.source = new_reactor; // protect from reassignment
|
||||
|
||||
@@ -19,7 +19,7 @@ class ASM3 {
|
||||
nu_NO: 0.5, // anoxic reduction factor [-]
|
||||
K_O: 0.2, // saturation constant S_0 [g O2 m-3]
|
||||
K_NO: 0.5, // saturation constant S_NO [g NO3-N m-3]
|
||||
K_S: 10., // saturation constant S_s [g COD m-3]
|
||||
K_S: 10.0, // saturation constant S_s [g COD m-3]
|
||||
K_STO: 0.1, // saturation constant X_STO [g X_STO g-1 X_H]
|
||||
mu_H_max: 3., // maximum specific growth rate [d-1]
|
||||
K_NH: 0.01, // saturation constant S_NH3 [g NH3-N m-3]
|
||||
@@ -171,7 +171,7 @@ class ASM3 {
|
||||
compute_rates(state, T = 20) {
|
||||
// state: S_O, S_I, S_S, S_NH, S_N2, S_NO, S_HCO, X_I, X_S, X_H, X_STO, X_A, X_TS
|
||||
const rates = Array(12);
|
||||
const [S_O, S_I, S_S, S_NH, S_N2, S_NO, S_HCO, X_I, X_S, X_H, X_STO, X_A, X_TS] = state;
|
||||
const [S_O, , S_S, S_NH, , S_NO, S_HCO, , X_S, X_H, X_STO, X_A] = state;
|
||||
const { k_H, K_X, k_STO, nu_NO, K_O, K_NO, K_S, K_STO, mu_H_max, K_NH, K_HCO, b_H_O, b_H_NO, b_STO_O, b_STO_NO, mu_A_max, K_A_NH, K_A_O, K_A_HCO, b_A_O, b_A_NO } = this.kin_params;
|
||||
const { theta_H, theta_STO, theta_mu_H, theta_b_H_O, theta_b_H_NO, theta_b_STO_O, theta_b_STO_NO, theta_mu_A, theta_b_A_O, theta_b_A_NO } = this.temp_params;
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ class ASM3 {
|
||||
compute_rates(state, T = 20) {
|
||||
// state: S_O, S_I, S_S, S_NH, S_N2, S_NO, S_HCO, X_I, X_S, X_H, X_STO, X_A, X_TS
|
||||
const rates = Array(12);
|
||||
const [S_O, S_I, S_S, S_NH, S_N2, S_NO, S_HCO, X_I, X_S, X_H, X_STO, X_A, X_TS] = state;
|
||||
const [S_O, , S_S, S_NH, , S_NO, S_HCO, , X_S, X_H, X_STO, X_A] = state;
|
||||
const { k_H, K_X, k_STO, nu_NO, K_O, K_NO, K_S, K_STO, mu_H_max, K_NH, K_HCO, b_H_O, b_H_NO, b_STO_O, b_STO_NO, mu_A_max, K_A_NH, K_A_O, K_A_HCO, b_A_O, b_A_NO } = this.kin_params;
|
||||
const { theta_H, theta_STO, theta_mu_H, theta_b_H_O, theta_b_H_NO, theta_b_STO_O, theta_b_STO_NO, theta_mu_A, theta_b_A_O, theta_b_A_NO } = this.temp_params;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const ASM3 = require('./reaction_modules/asm3_class.js');
|
||||
const { create, all, isArray } = require('mathjs');
|
||||
const { assertNoNaN } = require('./utils.js');
|
||||
const { childRegistrationUtils, logger, MeasurementContainer } = require('generalFunctions');
|
||||
const { childRegistrationUtils, logger, MeasurementContainer, POSITIONS } = require('generalFunctions');
|
||||
const EventEmitter = require('events');
|
||||
|
||||
const mathConfig = {
|
||||
@@ -126,7 +126,6 @@ class Reactor {
|
||||
position = measurement.config.functionality.positionVsParent;
|
||||
}
|
||||
const measurementType = measurement.config.asset.type;
|
||||
const key = `${measurementType}_${position}`;
|
||||
const eventName = `${measurementType}.measured.${position}`;
|
||||
|
||||
// Register event listener for measurement updates
|
||||
@@ -160,11 +159,11 @@ class Reactor {
|
||||
}
|
||||
|
||||
|
||||
_updateMeasurement(measurementType, value, position, context) {
|
||||
_updateMeasurement(measurementType, value, position, _context) {
|
||||
this.logger.debug(`---------------------- updating ${measurementType} ------------------ `);
|
||||
switch (measurementType) {
|
||||
case "temperature":
|
||||
if (position == "atEquipment") {
|
||||
if (position == POSITIONS.AT_EQUIPMENT) {
|
||||
this.temperature = value;
|
||||
}
|
||||
break;
|
||||
@@ -320,14 +319,15 @@ class Reactor_PFR extends Reactor {
|
||||
return stateNew;
|
||||
}
|
||||
|
||||
_updateMeasurement(measurementType, value, position, context) {
|
||||
_updateMeasurement(measurementType, value, position, _context) {
|
||||
switch(measurementType) {
|
||||
case "quantity (oxygen)":
|
||||
grid_pos = Math.round(position / this.config.length * this.n_x);
|
||||
case "quantity (oxygen)": {
|
||||
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
|
||||
break;
|
||||
}
|
||||
default:
|
||||
super._updateMeasurement(measurementType, value, position, context);
|
||||
super._updateMeasurement(measurementType, value, position, _context);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user