Switched around Debug point and added checks for Pe and Co_D

This commit is contained in:
2025-07-09 15:37:29 +02:00
parent 0f912b05e4
commit 6fd86f71c8

View File

@@ -182,21 +182,6 @@ 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("Inlet state max " + math.max(this.state[0]))
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.
@@ -205,6 +190,23 @@ class Reactor_PFR extends Reactor {
return { topic: "Fluent", payload: { inlet: 0, F: math.sum(this.Fs), C: this.state.at(-1) }, timestamp: this.currentTime };
}
updateState(newTime) {
super.updateState(newTime);
let Pe_local = this.d_x*math.sum(this.Fs)/(this.D*this.A)
let Co_D = this.D*this.timeStep/(this.d_x*this.d_x);
(Pe_local >= 2) && console.warn(`Local Péclet number (${Pe_local}) is too high! Increase reactor resolution.`);
(Co_D >= 0.5) && console.warn(`Courant number (${Co_D}) is too high! Reduce time step size.`);
if(DEBUG) {
console.log("Inlet state max " + math.max(this.state[0]))
console.log("Pe total " + this.length*math.sum(this.Fs)/(this.D*this.A));
console.log("Pe local " + Pe_local);
console.log("Co ad " + math.sum(this.Fs)*this.timeStep/(this.A*this.d_x));
console.log("Co D " + Co_D);
}
}
/**
* Tick the reactor state using explicit finite difference method.
* @param {number} time_step - Time step for the simulation [d].