From d9511dc3c7fbf8cc86d9e0e739a55bd8e6d6d811 Mon Sep 17 00:00:00 2001
From: "p.vanderwilt"
Date: Tue, 30 Sep 2025 15:36:25 +0200
Subject: [PATCH] Implement simple BCs
---
src/specificClass.js | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/src/specificClass.js b/src/specificClass.js
index 83829d8..ac562d2 100644
--- a/src/specificClass.js
+++ b/src/specificClass.js
@@ -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);
}
}