From 6fd86f71c8c26efcc4b8b4fe9e14ebec3a905ab2 Mon Sep 17 00:00:00 2001
From: "p.vanderwilt"
Date: Wed, 9 Jul 2025 15:37:29 +0200
Subject: [PATCH] Switched around Debug point and added checks for Pe and Co_D
---
src/specificClass.js | 32 +++++++++++++++++---------------
1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/src/specificClass.js b/src/specificClass.js
index efe0f1d..62236d1 100644
--- a/src/specificClass.js
+++ b/src/specificClass.js
@@ -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].