From 1dc9cd0031ec9d97dab318d3ec4e531139d140c3 Mon Sep 17 00:00:00 2001 From: "p.vanderwilt" Date: Tue, 14 Oct 2025 12:48:43 +0200 Subject: [PATCH] Add dispersion constraint --- src/specificClass.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/specificClass.js b/src/specificClass.js index eb42032..3aeef2f 100644 --- a/src/specificClass.js +++ b/src/specificClass.js @@ -266,15 +266,16 @@ class Reactor_PFR extends Reactor { * @param {object} input - Input object (msg) containing payload with dispersion value [m2 d-1]. */ set setDispersion(input) { - this.D = input.payload; + this.D = this._constrainDispersion(input.payload); } updateState(newTime) { super.updateState(newTime); - let Pe_local = this.d_x*math.sum(this.Fs)/(this.D*this.A) + // let Pe_local = this.d_x*math.sum(this.Fs)/(this.D*this.A) + this.D = this._constrainDispersion(this.D); let Co_D = this.D*this.timeStep/(this.d_x*this.d_x); - (Pe_local >= 2) && this.logger.warn(`Local Péclet number (${Pe_local}) is too high! Increase reactor resolution.`); + // (Pe_local >= 2) && this.logger.warn(`Local Péclet number (${Pe_local}) is too high! Increase reactor resolution.`); (Co_D >= 0.5) && this.logger.warn(`Courant number (${Co_D}) is too high! Reduce time step size.`); if(DEBUG) { @@ -402,6 +403,15 @@ class Reactor_PFR extends Reactor { D2.forEach((row, i) => i < BC_PADDING || i >= this.n_x+BC_PADDING ? row.fill(0) : row); return D2; } + + _constrainDispersion(D) { + const Dmin = math.sum(this.Fs) * this.d_x / (1.999 * this.A); + if (D < Dmin) { + this.logger.warn(`Local Péclet number too high! Constraining given dispersion (${D}) to minimal value (${Dmin}).`); + return Dmin; + } + return D; + } } module.exports = { Reactor_CSTR, Reactor_PFR };