From 04a5b1a54f268349262107e2aef0cb682ef9aec8 Mon Sep 17 00:00:00 2001
From: "p.vanderwilt"
Date: Thu, 14 Aug 2025 11:14:14 +0200
Subject: [PATCH] Fix COD balance
---
src/specificClass.js | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/specificClass.js b/src/specificClass.js
index d875f16..afa7446 100644
--- a/src/specificClass.js
+++ b/src/specificClass.js
@@ -34,7 +34,7 @@ class Reactor {
this.Fs = Array(config.n_inlets).fill(0); // fluid debits per inlet [m3 d-1]
this.Cs_in = Array.from(Array(config.n_inlets), () => new Array(NUM_SPECIES).fill(0)); // composition influents
- this.OTR = 0.0; // oxygen transfer rate [g O2 d-1]
+ this.OTR = 0.0; // oxygen transfer rate [g O2 d-1 m-3]
this.temperature = 20; // temperature [C]
this.kla = config.kla; // if NaN, use externaly provided OTR [d-1]
@@ -68,7 +68,7 @@ class Reactor {
/**
* Setter for OTR (Oxygen Transfer Rate).
- * @param {object} input - Input object (msg) containing payload with OTR value [g O2 d-1].
+ * @param {object} input - Input object (msg) containing payload with OTR value [g O2 d-1 m-3].
*/
set setOTR(input) {
this.OTR = input.payload;
@@ -89,7 +89,7 @@ class Reactor {
* Calculate the oxygen transfer rate (OTR) based on the dissolved oxygen concentration and temperature.
* @param {number} S_O - Dissolved oxygen concentration [g O2 m-3].
* @param {number} T - Temperature in Celsius, default to 20 C.
- * @returns {number} - Calculated OTR [g O2 d-1].
+ * @returns {number} - Calculated OTR [g O2 d-1 m-3].
*/
_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;
@@ -229,9 +229,13 @@ class Reactor_PFR extends Reactor {
const transfer = Array.from(Array(this.n_x), () => new Array(NUM_SPECIES).fill(0));
if (isNaN(this.kla)) { // calculate OTR if kla is not NaN, otherwise use externally calculated OTR
- transfer.forEach((x) => { x[S_O_INDEX] = this.OTR; });
+ for (let i = 1; i < this.n_x - 1; i++) {
+ transfer[i][S_O_INDEX] = this.OTR * this.n_x/(this.n_x-2);
+ }
} else {
- transfer.forEach((x, i) => { x[S_O_INDEX] = this._calcOTR(this.state[i][S_O_INDEX], this.temperature); });
+ for (let i = 1; i < this.n_x - 1; i++) {
+ transfer[i][S_O_INDEX] = this._calcOTR(this.state[i][S_O_INDEX], this.temperature) * this.n_x/(this.n_x-2);
+ }
}
const dC_total = math.multiply(math.add(dispersion, advection, reaction, transfer), time_step);