diff --git a/advanced-reactor.html b/advanced-reactor.html index 6db1abe..ff12949 100644 --- a/advanced-reactor.html +++ b/advanced-reactor.html @@ -6,6 +6,7 @@ name: { value: "" }, volume: { value: 0., required: true}, n_inlets: { value: 1, required: true}, + kla: { value: null }, S_O_init: { value: 0., required: true }, S_I_init: { value: 30., required: true }, S_S_init: { value: 100., required: true }, @@ -36,6 +37,10 @@ type:"num", types:["num"] }); + $("#node-input-kla").typedInput({ + type:"num", + types:["num"] + }); $(".concentrations").typedInput({ type:"num", types:["num"] @@ -68,6 +73,11 @@ +

Internal mass transfer calculation (optional)

+
+ + +

Dissolved components

diff --git a/advanced-reactor.js b/advanced-reactor.js index ed8edda..edfad14 100644 --- a/advanced-reactor.js +++ b/advanced-reactor.js @@ -10,6 +10,7 @@ module.exports = function(RED) { const reactor = new Reactor( parseFloat(config.volume), parseInt(config.n_inlets), + parseFloat(config.kla), [ parseFloat(config.S_O_init), parseFloat(config.S_I_init), diff --git a/dependencies/reactor_class.js b/dependencies/reactor_class.js index 0427462..dcc5cfd 100644 --- a/dependencies/reactor_class.js +++ b/dependencies/reactor_class.js @@ -3,7 +3,7 @@ const math = require('mathjs') class Reactor_CSTR { - constructor(volume, n_inlets, initial_state) { + constructor(volume, n_inlets, kla, initial_state) { this.state = initial_state; console.log(this.state); this.asm = new ASM3(); @@ -12,6 +12,8 @@ class Reactor_CSTR { this.Fs = Array(n_inlets).fill(0.0); // fluid debits per inlet [m3 d-1] this.Cs_in = Array.from(Array(n_inlets), () => new Array(13).fill(0.0)); // composition influents this.OTR = 0.0; // oxygen transfer rate [g O2 d-1] + + this.kla = kla; // if NaN, use external OTR [d-1] this.currentTime = Date.now(); // milliseconds since epoch [ms] this.timeStep = 1/(24*60*15) // time step [d] @@ -31,6 +33,11 @@ class Reactor_CSTR { return {topic: "Fluent", payload: {inlet: 0, F: math.sum(this.Fs), C:this.state}, timestamp: this.currentTime}; } + calcOTR(S_O, T=20.0) { // caculate the OTR using basic correlation, default to temperature: 20 C + let S_O_sat = 14.652 - 4.1022e-1*T + 7.9910e-3*T*T + 7.7774e-5*T*T*T; + return this.kla * (S_O_sat - S_O); + } + // expect update with timestamp updateState(timestamp) { let newTime = timestamp; @@ -53,10 +60,10 @@ class Reactor_CSTR { const r = this.asm.compute_dC(this.state); const dC_in = math.multiply(math.divide([this.Fs], this.Vl), this.Cs_in)[0]; const dC_out = math.multiply(math.sum(this.Fs)/this.Vl, this.state); - const T_O = Array(13).fill(0.0); - T_O[0] = this.OTR; + const t_O = Array(13).fill(0.0); + t_O[0] = isNaN(this.kla) ? this.OTR : this.calcOTR(this.state[0]); // calculate OTR if kla is not NaN, otherwise use externaly calculated OTR - const dC_total = math.multiply(math.add(dC_in, dC_out, r, T_O), time_step); + const dC_total = math.multiply(math.add(dC_in, dC_out, r, t_O), time_step); this.state = math.add(this.state, dC_total); return this.state;