From 302780726a8b6d850f7dd4b64440c83d63dcbd41 Mon Sep 17 00:00:00 2001
From: "p.vanderwilt"
Date: Mon, 7 Jul 2025 12:24:15 +0200
Subject: [PATCH] Refactor Reactor class to remove debug logs and enhance
setter for influent data with conditional logging
---
src/specificClass.js | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/src/specificClass.js b/src/specificClass.js
index ce5c786..384aaf0 100644
--- a/src/specificClass.js
+++ b/src/specificClass.js
@@ -41,11 +41,6 @@ class Reactor {
let index_in = input.payload.inlet;
this.Fs[index_in] = input.payload.F;
this.Cs_in[index_in] = input.payload.C;
- // DEBUG
- // console.log("Pe total " + this.length*math.sum(this.Fs)/(this.D*this.A));
- // console.log("Pe local " + this.d_x*math.sum(this.Fs)/(this.D*this.A));
- // console.log("Co ad " + math.sum(this.Fs)*this.timeStep/(this.A*this.d_x));
- // console.log("Co D " + this.D*this.timeStep/(this.d_x*this.d_x));
}
/**
@@ -57,10 +52,10 @@ 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
+ * @returns {number} - Calculated OTR [g O2 d-1].
*/
_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;
@@ -176,6 +171,20 @@ class Reactor_PFR extends Reactor {
this.D = input.payload;
}
+ /**
+ * Setter for influent data.
+ * @param {object} input - Input object (msg) containing payload with inlet index, flow rate, and concentrations.
+ */
+ set setInfluent(input) {
+ super.setInfluent = input;
+ if(DEBUG) {
+ console.log("Pe total " + this.length*math.sum(this.Fs)/(this.D*this.A));
+ console.log("Pe local " + this.d_x*math.sum(this.Fs)/(this.D*this.A));
+ console.log("Co ad " + math.sum(this.Fs)*this.timeStep/(this.A*this.d_x));
+ console.log("Co D " + this.D*this.timeStep/(this.d_x*this.d_x));
+ }
+ }
+
/**
* Getter for effluent data.
* @returns {object} Effluent data object (msg), defaults to inlet 0.