Add dispersion constraint

This commit is contained in:
2025-10-14 12:48:43 +02:00
parent 2a520be33b
commit 1dc9cd0031

View File

@@ -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 };