Implement simple BCs

This commit is contained in:
2025-09-30 15:36:25 +02:00
parent 993482f8c0
commit d9511dc3c7

View File

@@ -30,6 +30,7 @@ class Reactor {
this.parent = []; // Gets assigned via child registration
this.upstreamReactor = null;
this.downstreamReactor = null;
this.asm = new ASM3();
@@ -116,10 +117,6 @@ class Reactor {
}
}
setDownstreamReactor() {
this.downstreamReactor = this.parent.find((x) => x.config.functionality.softwareType == "reactor");
}
_connectMeasurement(measurementChild) {
if (!measurementChild) {
this.logger.warn("Invalid measurement provided.");
@@ -158,7 +155,7 @@ class Reactor {
}
this.upstreamReactor = reactorChild;
reactorChild.setDownstreamReactor();
reactorChild.downstreamReactor = this;
reactorChild.emitter.on("stateChange", (data) => {
this.logger.debug(`State change of upstream reactor detected.`);
@@ -346,7 +343,7 @@ class Reactor_PFR extends Reactor {
*/
_applyBoundaryConditions(state) {
if (this.upstreamReactor) {
state[0] = this.upstreamReactor.state[this.n_x-1];
state[0] = this.upstreamReactor.state.at(-1);
} else {
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];
@@ -361,7 +358,7 @@ class Reactor_PFR extends Reactor {
state[this.n_x-1] = this.downstreamReactor.state[0];
} else {
// Neumann BC (no flux)
state[this.n_x-1] = state[this.n_x-2];
state[this.n_x-1] = state.at(-2);
}
}