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.upstreamReactor = null;
|
||||
this.childRegistrationUtils = new childRegistrationUtils(this); // Child registration utility
|
||||
this.parent = null; // Gets assigned via child registration
|
||||
|
||||
this.asm = new ASM3();
|
||||
|
||||
@@ -126,7 +127,6 @@ class Reactor {
|
||||
position = measurement.config.functionality.positionVsParent;
|
||||
}
|
||||
const measurementType = measurement.config.asset.type;
|
||||
const key = `${measurementType}_${position}`;
|
||||
const eventName = `${measurementType}.measured.${position}`;
|
||||
|
||||
// Register event listener for measurement updates
|
||||
@@ -145,13 +145,13 @@ class Reactor {
|
||||
}
|
||||
|
||||
|
||||
_connectReactor(reactor) {
|
||||
if (!reactor) {
|
||||
_connectReactor(reactorChild) {
|
||||
if (!reactorChild) {
|
||||
this.logger.warn("Invalid reactor provided.");
|
||||
return;
|
||||
}
|
||||
|
||||
this.upstreamReactor = reactor;
|
||||
this.upstreamReactor = reactorChild;
|
||||
|
||||
reactor.emitter.on("stateChange", (data) => {
|
||||
this.logger.debug(`State change of upstream reactor detected.`);
|
||||
@@ -338,15 +338,25 @@ class Reactor_PFR extends Reactor {
|
||||
* @param {Array} state - Current reactor state without enforced BCs.
|
||||
*/
|
||||
_applyBoundaryConditions(state) {
|
||||
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_dispersion_term = (1-this.alpha)*this.D*this.A/(math.sum(this.Fs)*this.d_x);
|
||||
state[0] = math.multiply(1/(1+BC_dispersion_term), math.add(BC_C_in, math.multiply(BC_dispersion_term, state[1])));
|
||||
if (this.upstreamReactor) {
|
||||
state[0] = this.upstreamReactor.state[this.n_x-1];
|
||||
} else {
|
||||
state[0] = state[1];
|
||||
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_dispersion_term = (1-this.alpha)*this.D*this.A/(math.sum(this.Fs)*this.d_x);
|
||||
state[0] = math.multiply(1/(1+BC_dispersion_term), math.add(BC_C_in, math.multiply(BC_dispersion_term, state[1])));
|
||||
} else {
|
||||
state[0] = state[1];
|
||||
}
|
||||
}
|
||||
|
||||
const downstreamReactor = this.parent;
|
||||
if (downstreamReactor) {
|
||||
state[this.n_x-1] = downstreamReactor.state[0];
|
||||
} else {
|
||||
// Neumann BC (no flux)
|
||||
state[this.n_x-1] = state[this.n_x-2];
|
||||
}
|
||||
// Neumann BC (no flux)
|
||||
state[this.n_x-1] = state[this.n_x-2];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user