Refactor boundary condition handling in Reactor_PFR class for improved clarity and efficiency
This commit is contained in:
@@ -365,11 +365,10 @@ class Reactor_PFR extends Reactor {
|
|||||||
* for outlet, apply regular Danckwerts BC (Neumann BC with no flux)
|
* for outlet, apply regular Danckwerts BC (Neumann BC with no flux)
|
||||||
*/
|
*/
|
||||||
_applyBoundaryConditions() {
|
_applyBoundaryConditions() {
|
||||||
|
// Upstream BC
|
||||||
if (this.upstreamReactor) {
|
if (this.upstreamReactor) {
|
||||||
// Open boundary
|
// Open boundary
|
||||||
for (let i = 0; i < BC_PADDING; i++) {
|
this.extendedState.splice(0, BC_PADDING, ...this.upstreamReactor.state.slice(-BC_PADDING));
|
||||||
this.extendedState[i] = this.upstreamReactor.state.at(i-BC_PADDING);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (math.sum(this.Fs) > 0) {
|
if (math.sum(this.Fs) > 0) {
|
||||||
// Danckwerts BC
|
// Danckwerts BC
|
||||||
@@ -383,11 +382,10 @@ class Reactor_PFR extends Reactor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Downstream BC
|
||||||
if (this.downstreamReactor) {
|
if (this.downstreamReactor) {
|
||||||
// Open boundary
|
// Open boundary
|
||||||
for (let i = 0; i < BC_PADDING; i++) {
|
this.extendedState.splice(this.n_x+BC_PADDING, BC_PADDING, ...this.downstreamReactor.state.slice(0, BC_PADDING));
|
||||||
this.extendedState[this.n_x+BC_PADDING+i] = this.downstreamReactor.state[i];
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Neumann BC (no flux)
|
// Neumann BC (no flux)
|
||||||
this.extendedState.fill(this.extendedState.at(-1-BC_PADDING), BC_PADDING+this.n_x);
|
this.extendedState.fill(this.extendedState.at(-1-BC_PADDING), BC_PADDING+this.n_x);
|
||||||
|
|||||||
Reference in New Issue
Block a user