Refactor boundary condition handling in Reactor_PFR class for improved clarity and efficiency

This commit is contained in:
2025-11-06 17:24:10 +01:00
parent 260d04b96f
commit ffb4080f14

View File

@@ -365,11 +365,10 @@ class Reactor_PFR extends Reactor {
* for outlet, apply regular Danckwerts BC (Neumann BC with no flux)
*/
_applyBoundaryConditions() {
// Upstream BC
if (this.upstreamReactor) {
// Open boundary
for (let i = 0; i < BC_PADDING; i++) {
this.extendedState[i] = this.upstreamReactor.state.at(i-BC_PADDING);
}
this.extendedState.splice(0, BC_PADDING, ...this.upstreamReactor.state.slice(-BC_PADDING));
} else {
if (math.sum(this.Fs) > 0) {
// Danckwerts BC
@@ -383,11 +382,10 @@ class Reactor_PFR extends Reactor {
}
}
// Downstream BC
if (this.downstreamReactor) {
// Open boundary
for (let i = 0; i < BC_PADDING; i++) {
this.extendedState[this.n_x+BC_PADDING+i] = this.downstreamReactor.state[i];
}
this.extendedState.splice(this.n_x+BC_PADDING, BC_PADDING, ...this.downstreamReactor.state.slice(0, BC_PADDING));
} else {
// Neumann BC (no flux)
this.extendedState.fill(this.extendedState.at(-1-BC_PADDING), BC_PADDING+this.n_x);