Refactor advanced-reactor node to improve input handling and initialize reactor properties
This commit is contained in:
@@ -23,10 +23,14 @@
|
|||||||
outputs: 1,
|
outputs: 1,
|
||||||
icon: "font-awesome/fa-recycle",
|
icon: "font-awesome/fa-recycle",
|
||||||
label: function() {
|
label: function() {
|
||||||
return this.name||"advanced-reactor";
|
return this.name || "advanced-reactor";
|
||||||
},
|
},
|
||||||
oneditprepare: function() {
|
oneditprepare: function() {
|
||||||
$(".typed-num").typedInput({
|
$("#node-input-volume").typedInput({
|
||||||
|
type:"num",
|
||||||
|
types:["num"]
|
||||||
|
});
|
||||||
|
$(".concentrations").typedInput({
|
||||||
type:"num",
|
type:"num",
|
||||||
types:["num"]
|
types:["num"]
|
||||||
});
|
});
|
||||||
@@ -48,61 +52,61 @@
|
|||||||
<h2> Reactor properties </h2>
|
<h2> Reactor properties </h2>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-volume"><i class="fa fa-tag"></i> Fluid volume [m3]</label>
|
<label for="node-input-volume"><i class="fa fa-tag"></i> Fluid volume [m3]</label>
|
||||||
<input type="text" id="node-input-volume" class="typed-num" placeholder="m3">
|
<input type="text" id="node-input-volume" placeholder="m3">
|
||||||
</div>
|
</div>
|
||||||
<h2> Dissolved components </h2>
|
<h2> Dissolved components </h2>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-S_O_init"><i class="fa fa-tag"></i> Initial dissolved oxygen [g O2 m-3]</label>
|
<label for="node-input-S_O_init"><i class="fa fa-tag"></i> Initial dissolved oxygen [g O2 m-3]</label>
|
||||||
<input type="text" id="node-input-S_O_init">
|
<input type="text" id="node-input-S_O_init" class="concentrations">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-S_I_init"><i class="fa fa-tag"></i> Initial soluble inert organics [g COD m-3]</label>
|
<label for="node-input-S_I_init"><i class="fa fa-tag"></i> Initial soluble inert organics [g COD m-3]</label>
|
||||||
<input type="text" id="node-input-S_I_init" class="typed-num">
|
<input type="text" id="node-input-S_I_init" class="concentrations">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-S_S_init"><i class="fa fa-tag"></i> Initial readily biodegrable substrates [g COD m-3]</label>
|
<label for="node-input-S_S_init"><i class="fa fa-tag"></i> Initial readily biodegrable substrates [g COD m-3]</label>
|
||||||
<input type="text" id="node-input-S_S_init" class="typed-num">
|
<input type="text" id="node-input-S_S_init" class="concentrations">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-S_NH_init"><i class="fa fa-tag"></i> Initial ammonium / ammonia [g N m-3]</label>
|
<label for="node-input-S_NH_init"><i class="fa fa-tag"></i> Initial ammonium / ammonia [g N m-3]</label>
|
||||||
<input type="text" id="node-input-S_NH_init" class="typed-num">
|
<input type="text" id="node-input-S_NH_init" class="concentrations">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-S_N2_init"><i class="fa fa-tag"></i> Initial dinitrogen, released by denitrification [g N m-3]</label>
|
<label for="node-input-S_N2_init"><i class="fa fa-tag"></i> Initial dinitrogen, released by denitrification [g N m-3]</label>
|
||||||
<input type="text" id="node-input-S_N2_init" class="typed-num">
|
<input type="text" id="node-input-S_N2_init" class="concentrations">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-S_NO_init"><i class="fa fa-tag"></i> Initial nitrite + nitrate [g N m-3]</label>
|
<label for="node-input-S_NO_init"><i class="fa fa-tag"></i> Initial nitrite + nitrate [g N m-3]</label>
|
||||||
<input type="text" id="node-input-S_NO_init" class="typed-num">
|
<input type="text" id="node-input-S_NO_init" class="concentrations">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-S_HCO_init"><i class="fa fa-tag"></i> Initial alkalinity, bicarbonate [mole HCO3- m-3]</label>
|
<label for="node-input-S_HCO_init"><i class="fa fa-tag"></i> Initial alkalinity, bicarbonate [mole HCO3- m-3]</label>
|
||||||
<input type="text" id="node-input-S_HCO_init" class="typed-num">
|
<input type="text" id="node-input-S_HCO_init" class="concentrations">
|
||||||
</div>
|
</div>
|
||||||
<h2> Particulate components </h2>
|
<h2> Particulate components </h2>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-X_I_init"><i class="fa fa-tag"></i> Initial inert particulate organics [g COD m-3]</label>
|
<label for="node-input-X_I_init"><i class="fa fa-tag"></i> Initial inert particulate organics [g COD m-3]</label>
|
||||||
<input type="text" id="node-input-X_I_init" class="typed-num">
|
<input type="text" id="node-input-X_I_init" class="concentrations">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-X_S_init"><i class="fa fa-tag"></i> Initial slowly biodegrable substrates [g COD m-3]</label>
|
<label for="node-input-X_S_init"><i class="fa fa-tag"></i> Initial slowly biodegrable substrates [g COD m-3]</label>
|
||||||
<input type="text" id="node-input-X_S_init" class="typed-num">
|
<input type="text" id="node-input-X_S_init" class="concentrations">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-X_H_init"><i class="fa fa-tag"></i> Initial heterotrophic biomass [g COD m-3]</label>
|
<label for="node-input-X_H_init"><i class="fa fa-tag"></i> Initial heterotrophic biomass [g COD m-3]</label>
|
||||||
<input type="text" id="node-input-X_H_init" class="typed-num">
|
<input type="text" id="node-input-X_H_init" class="concentrations">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-X_STO_init"><i class="fa fa-tag"></i> Initial Organics stored by heterotrophs [g COD m-3]</label>
|
<label for="node-input-X_STO_init"><i class="fa fa-tag"></i> Initial Organics stored by heterotrophs [g COD m-3]</label>
|
||||||
<input type="text" id="node-input-X_STO_init" class="typed-num">
|
<input type="text" id="node-input-X_STO_init" class="concentrations">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-X_A_init"><i class="fa fa-tag"></i> Initial autotrophic, nitrifying biomass [g COD m-3]</label>
|
<label for="node-input-X_A_init"><i class="fa fa-tag"></i> Initial autotrophic, nitrifying biomass [g COD m-3]</label>
|
||||||
<input type="text" id="node-input-X_A_init" class="typed-num">
|
<input type="text" id="node-input-X_A_init" class="concentrations">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-X_TS_init"><i class="fa fa-tag"></i> Initial total suspended solids [g TSS m-3]</label>
|
<label for="node-input-X_TS_init"><i class="fa fa-tag"></i> Initial total suspended solids [g TSS m-3]</label>
|
||||||
<input type="text" id="node-input-X_TS_init" class="typed-num">
|
<input type="text" id="node-input-X_TS_init" class="concentrations">
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -10,25 +10,35 @@ module.exports = function(RED) {
|
|||||||
const reactor = new Reactor(
|
const reactor = new Reactor(
|
||||||
config.volume,
|
config.volume,
|
||||||
[
|
[
|
||||||
config.S_O_init,
|
parseFloat(config.S_O_init),
|
||||||
config.S_I_init,
|
parseFloat(config.S_I_init),
|
||||||
config.S_S_init,
|
parseFloat(config.S_S_init),
|
||||||
config.S_NH_init,
|
parseFloat(config.S_NH_init),
|
||||||
config.S_N2_init,
|
parseFloat(config.S_N2_init),
|
||||||
config.S_NO_init,
|
parseFloat(config.S_NO_init),
|
||||||
config.S_HCO_init,
|
parseFloat(config.S_HCO_init),
|
||||||
config.X_I_init,
|
parseFloat(config.X_I_init),
|
||||||
config.X_S_init,
|
parseFloat(config.X_S_init),
|
||||||
config.X_H_init,
|
parseFloat(config.X_H_init),
|
||||||
config.X_STO_init,
|
parseFloat(config.X_STO_init),
|
||||||
config.X_A_init,
|
parseFloat(config.X_A_init),
|
||||||
config.X_TS_init
|
parseFloat(config.X_TS_init)
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
node.on('input', function(msg, send, done) {
|
node.on('input', function(msg, send, done) {
|
||||||
if (msg.topic == "clock") {
|
switch (msg.topic) {
|
||||||
reactor.updateState(msg);
|
case "clock":
|
||||||
|
reactor.updateState(msg);
|
||||||
|
break;
|
||||||
|
case "Influx":
|
||||||
|
reactor.setInflux = msg;
|
||||||
|
break;
|
||||||
|
case "OTR":
|
||||||
|
reactor.setOTR = msg;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
console.log("Unknown topic: " + msg.topic)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (done) {
|
if (done) {
|
||||||
|
|||||||
15
dependencies/reactor_class.js
vendored
15
dependencies/reactor_class.js
vendored
@@ -9,14 +9,23 @@ class Reactor_CSTR {
|
|||||||
this.asm = new ASM3();
|
this.asm = new ASM3();
|
||||||
|
|
||||||
this.Vl = volume; // fluid volume reactor [m3]
|
this.Vl = volume; // fluid volume reactor [m3]
|
||||||
this.F = 1.0; // fluid debit [m3 d-1]
|
this.F = 0.0; // fluid debit [m3 d-1]
|
||||||
this.C_in = [0., 30., 100., 16., 0., 0., 5., 25., 75., 30., 0., 0., 125.]; // composition influent
|
this.C_in = Array(13).fill(0.0); // composition influent
|
||||||
this.OTR = 100.0; // oxygen transfer rate [g O2 d-1]
|
this.OTR = 0.0; // oxygen transfer rate [g O2 d-1]
|
||||||
|
|
||||||
this.currentTime = Date.now(); // milliseconds since epoch [ms]
|
this.currentTime = Date.now(); // milliseconds since epoch [ms]
|
||||||
this.timeStep = 1/(24*60*15) // time step [d]
|
this.timeStep = 1/(24*60*15) // time step [d]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set setInflux(input) { // setter for C_in (WIP)
|
||||||
|
this.F = input.payload.F;
|
||||||
|
this.C_in = input.payload.C_in;
|
||||||
|
}
|
||||||
|
|
||||||
|
set setOTR(input) { // setter for OTR (WIP) [g O2 d-1]
|
||||||
|
this.OTR = input.payload;
|
||||||
|
}
|
||||||
|
|
||||||
// expect update with timestamp
|
// expect update with timestamp
|
||||||
updateState(input) {
|
updateState(input) {
|
||||||
let newTime = input.payload;
|
let newTime = input.payload;
|
||||||
|
|||||||
Reference in New Issue
Block a user