Refactor Reactor class to remove debug logs and enhance setter for influent data with conditional logging

This commit is contained in:
2025-07-07 12:24:15 +02:00
parent deb5269d1a
commit 302780726a

View File

@@ -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.