Refactor boundary condition handling to use adjustable parameter alpha in advanced-reactor and specificClass

This commit is contained in:
2025-07-08 10:03:03 +02:00
parent 01318a2d3b
commit 5c03dddb79
3 changed files with 13 additions and 34 deletions

View File

@@ -149,7 +149,7 @@ class Reactor_PFR extends Reactor {
this.d_x = this.length / this.n_x;
this.A = this.volume / this.length; // crosssectional area [m2]
this.BC = config.boundary_condition;
this.alpha = config.alpha;
this.state = Array.from(Array(this.n_x), () => config.initialState.slice())
@@ -208,23 +208,7 @@ class Reactor_PFR extends Reactor {
const BC_gradient = Array(this.n_x).fill(0);
BC_gradient[0] = -1;
BC_gradient[1] = 1;
let BC_term = 0;
switch(this.BC) {
case "Dirichlet":
BC_term = 0;
break;
case "Danckwerts":
BC_term = this.D*this.A / math.sum(this.Fs);
break;
case "Generalised":
let Pe = this.length * math.sum(this.Fs) / (this.D * this.A);
let residence_time = this.volume/math.sum(this.Fs);
BC_term = (1 - (1 + 4*residence_time/Pe)^0.5) / Pe
break;
default:
console.warn("Unknown boundary condition: " + this.BC);
}
const BC_dispersion = math.multiply(BC_term/this.d_x, [BC_gradient], state)[0];
const BC_dispersion = math.multiply((1 - this.alpha) * this.D*this.A / (math.sum(this.Fs) * this.d_x), [BC_gradient], state)[0];
state[0] = math.add(BC_C_in, BC_dispersion).map(val => val < 0 ? 0 : val);
} else { // Neumann BC (no flux)
state[0] = state[1];