Use improved boundary conditions for upstream and downstream reactors
This commit is contained in:
@@ -27,6 +27,7 @@ class Reactor {
|
|||||||
this.measurements = new MeasurementContainer();
|
this.measurements = new MeasurementContainer();
|
||||||
this.upstreamReactor = null;
|
this.upstreamReactor = null;
|
||||||
this.childRegistrationUtils = new childRegistrationUtils(this); // Child registration utility
|
this.childRegistrationUtils = new childRegistrationUtils(this); // Child registration utility
|
||||||
|
this.parent = null; // Gets assigned via child registration
|
||||||
|
|
||||||
this.asm = new ASM3();
|
this.asm = new ASM3();
|
||||||
|
|
||||||
@@ -126,7 +127,6 @@ class Reactor {
|
|||||||
position = measurement.config.functionality.positionVsParent;
|
position = measurement.config.functionality.positionVsParent;
|
||||||
}
|
}
|
||||||
const measurementType = measurement.config.asset.type;
|
const measurementType = measurement.config.asset.type;
|
||||||
const key = `${measurementType}_${position}`;
|
|
||||||
const eventName = `${measurementType}.measured.${position}`;
|
const eventName = `${measurementType}.measured.${position}`;
|
||||||
|
|
||||||
// Register event listener for measurement updates
|
// Register event listener for measurement updates
|
||||||
@@ -145,13 +145,13 @@ class Reactor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_connectReactor(reactor) {
|
_connectReactor(reactorChild) {
|
||||||
if (!reactor) {
|
if (!reactorChild) {
|
||||||
this.logger.warn("Invalid reactor provided.");
|
this.logger.warn("Invalid reactor provided.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.upstreamReactor = reactor;
|
this.upstreamReactor = reactorChild;
|
||||||
|
|
||||||
reactor.emitter.on("stateChange", (data) => {
|
reactor.emitter.on("stateChange", (data) => {
|
||||||
this.logger.debug(`State change of upstream reactor detected.`);
|
this.logger.debug(`State change of upstream reactor detected.`);
|
||||||
@@ -338,6 +338,9 @@ class Reactor_PFR extends Reactor {
|
|||||||
* @param {Array} state - Current reactor state without enforced BCs.
|
* @param {Array} state - Current reactor state without enforced BCs.
|
||||||
*/
|
*/
|
||||||
_applyBoundaryConditions(state) {
|
_applyBoundaryConditions(state) {
|
||||||
|
if (this.upstreamReactor) {
|
||||||
|
state[0] = this.upstreamReactor.state[this.n_x-1];
|
||||||
|
} else {
|
||||||
if (math.sum(this.Fs) > 0) { // Danckwerts BC
|
if (math.sum(this.Fs) > 0) { // Danckwerts BC
|
||||||
const BC_C_in = math.multiply(1 / math.sum(this.Fs), [this.Fs], this.Cs_in)[0];
|
const BC_C_in = math.multiply(1 / math.sum(this.Fs), [this.Fs], this.Cs_in)[0];
|
||||||
const BC_dispersion_term = (1-this.alpha)*this.D*this.A/(math.sum(this.Fs)*this.d_x);
|
const BC_dispersion_term = (1-this.alpha)*this.D*this.A/(math.sum(this.Fs)*this.d_x);
|
||||||
@@ -345,9 +348,16 @@ class Reactor_PFR extends Reactor {
|
|||||||
} else {
|
} else {
|
||||||
state[0] = state[1];
|
state[0] = state[1];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const downstreamReactor = this.parent;
|
||||||
|
if (downstreamReactor) {
|
||||||
|
state[this.n_x-1] = downstreamReactor.state[0];
|
||||||
|
} else {
|
||||||
// Neumann BC (no flux)
|
// Neumann BC (no flux)
|
||||||
state[this.n_x-1] = state[this.n_x-2];
|
state[this.n_x-1] = state[this.n_x-2];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create finite difference first derivative operator.
|
* Create finite difference first derivative operator.
|
||||||
|
|||||||
Reference in New Issue
Block a user